[llvm-dev] [RFC] Generate Debug Information for Labels in Function

via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 29 12:36:17 PDT 2018


> >> Thanks that's a good point. I still wonder what a debugger would do
> with
> >> the source location of a label though? For setting breakpoints it seems
> >> redundant with the location of the next instruction. Does GCC emit
> source
> >> location for a label, or just its name? If yes, does GDB do anything
> with
> >> that information?
> >>
> >> -- adrian
> >
> > A GUI debugger might show the source text near the label definition.
> > Suppose the first code after the label is an inlined function call.
> > Using the instruction's location would take you to the source for the
> > inlined function, not to the label and the source for the call.
> 
> Yes, but LLDB at least only looks at .debug_line to determine the source
> to display for a given PC. This is quite annoying at -O0 with
> always_inline constructors in libcxx.

If you're stopped at the goto, you could do a "show me the definition"
of the label, and you'd want the source location of the label.

> 
> A label immediately followed by an inlined instruction will be invisible
> to the .debug_line table. It would also be ambiguous whether the label is
> part of a (lexical, inlined) scope in the .debug_info section if it
> appears at the beginning that scope.
> 
> -- adrian
> 

The label DIE does need to be in the correct scope.  Hmm it would need
to be a child of the inlined subprogram DIE because its code address
would be different for each inlined instance.
--paulr


More information about the llvm-dev mailing list