[Dwarf-discuss] Question on DW_AT_low_pc for "repeated" DW_TAG_subprogram

Martin lists@mfriebe.de
Thu May 16 19:58:02 GMT 2024


On 16/05/2024 18:46, David Blaikie via Dwarf-discuss wrote:
> On Thu, May 16, 2024 at 7:10 AM Martin via Dwarf-discuss 
> <dwarf-discuss@lists.dwarfstd.org 
> <mailto:dwarf-discuss@lists.dwarfstd.org>> wrote:
> 
>     If a compiler adds a DW_TAG_subprogram for a routine from a different
>     compilation unit ...
>     Maybe because
>     - the other CU has no debug info
>     - The compiler does not support referencing cross CU
> 
> 
> None that I can think of.
> 
> This happens in some cases in more normal situations - such as concrete 
> definitions of inline functions - you'd have multiple CUs with 
> subprograms that describe the same function definition, with low/high pc.
> 
> In the "doesn't support cross-CU references" - I'd expect in that case 
> to only produce a subprogram declaration (eg: if you need a call_site 
> for a call to a function defined in another object file). In the first 
> case (other CU has no debug info) yeah, theoretically, I guess, maybe 
> you'd want to produce debug info for the thing you didn't define.
> 
> But generally my understanding is producers don't do that.

Thanks for the answer, but I am not quite sure how to interpret it.

"None that I can think of" => So, it would be ok for a producer to add a 
DW_AT_low_pc ?

But
- "producers don't do that" => It would not be ok?
- "only produce a subprogram declaration" => not ok

If there is code (with debug info) that uses a class/struct that is 
defined in a unit with debug info (or at least a base class is in such a 
unit), then IMHO the debugger should be able to show the entire 
structure, including fields/methods from that unit without debug info. 
(because only the type is in the other unit, but the variable itself is 
in a unit with debug info).

For that, the declaration of that class can be repeated. But if the user 
then wants to call (from the debugger) a function on that (base-) class, 
then it needs the DW_AT_low_pc?

What is the recommended way for the producer to supply this?


About your answers regarding the linking, I will keep that in mind, when 
discussing it with the others involved.
For info, my background is on implementing the debugger. The compiler is 
done by others. But obviously both ends need to work together.

Thanks
Martin


More information about the Dwarf-discuss mailing list