[PATCH] Line table, prologue_end, and inlined functions

Adrian Prantl aprantl at apple.com
Tue Apr 23 11:55:55 PDT 2013


On Apr 23, 2013, at 5:42 AM, Eric Christopher <echristo at gmail.com> wrote:

> Hi Adrian,
> 
> I'm not sure about this as the correct design for prologue_end and
> inlined subroutines. Could you give an example of what you're thinking
> the output should be with this patch?

Thanks for the review, Eric!

I’ve looked into this again now.
Consider an example like this:

#include <vector>
#include <algorithm>

int main() {
  std::vector<int> vec;
  std::reverse(vec.begin(), vec.end());
  return 0;
}

before the patch the line table looks like this:
file_names[  1]    0 0x00000000 0x00000000 test.cpp
...
file_names[  5]    1 0x00000000 0x00000000 vector
main:
0x000000a0: DW_LNE_set_address( 0x00000001000008b0 )
0x000000ab: address += 0,  line += 3
            0x00000001000008b0      1      4      0 is_stmt

0x000000ac: DW_LNS_set_file( 5 )
0x000000ae: DW_LNS_set_prologue_end
0x000000af: DW_LNS_advance_line( 457 )
0x000000b2: DW_LNS_advance_pc( 113 )
0x000000b4: DW_LNS_copy
            0x0000000100000921      5    461      0 is_stmt prologue_end

after the patch, it will look like this:
main:
0x000000a0: DW_LNE_set_address( 0x00000001000008b0 )
0x000000ab: DW_LNS_set_prologue_end
0x000000ac: address += 0,  line += 3
            0x00000001000008b0      1      4      0 is_stmt prologue_end

0x000000ad: DW_LNS_set_file( 5 )
0x000000af: DW_LNS_advance_line( 457 )
0x000000b2: DW_LNS_advance_pc( 113 )
0x000000b4: DW_LNS_copy
            0x0000000100000921      5    461      0 is_stmt

> I'm guessing that lldb here is using the prologue_end only as the
> address where it stops execution for a given routine that happens to
> have an inlined part as the first non-prologue instruction and getting
> confused as to which function we're in or which function the
> prologue_end belongs to?

Your guess is correct. Lldb does use the prologue_end instruction as the one where “b main” would break.
> The informative text for DW_LNS_set_prologue_end says:
> 
> "Note that the function to which the prologue end applies cannot be
> directly determined from
> the line number information alone; it must be determined in
> combination with the subroutine
> information entries of the compilation (including inlined subroutines).”

Having read this I agree that this should probably be fixed in lldb instead.

> Basically if I'm reading correct your patch announces that the end of
> the prologue is, instead, the beginning of the function before the
> prologue in cases where an inlined function is at the end of the
> prologue. This seems incorrect as someone would expect that all of the
> setup for the function has been done when, in fact, it hasn't?
> 
> Thoughts?

I’ll file a bug for lldb. Thanks!

Adrian



More information about the llvm-commits mailing list