[LLDB][RFC] Add inline info into line table in Dwarf symbol file plugin

Hi,

Currently, SymbolFileDWARF::ParseLineTable only parses the line table .debug_line and does not store the inline information in DW_TAG_inlined_subroutine. This causes problem when users try to set breakpoint at the call site of an inlined function using b [file]:[line], example: lldb not stopped at a inline function call statement · Issue #44953 · llvm/llvm-project · GitHub.

In that example, the line table is the following:

Address            Line   Column File   ISA Discriminator OpIndex Flags
------------------ ------ ------ ------ --- ------------- ------- -------------
0x0000000000001130      6      0      0   0             0       0  is_stmt
0x0000000000001143      3      2      0   0             0       0  is_stmt prologue_end
0x0000000000001147      3      4      0   0             0       0
0x000000000000114d      9      8      0   0             0       0  is_stmt
0x0000000000001150      9      1      0   0             0       0  epilogue_begin
0x0000000000001152      9      1      0   0             0       0  end_sequence

And here’s inline information:

0x00000053:     DW_TAG_inlined_subroutine
                  DW_AT_abstract_origin (0x00000023 "foo")
                  DW_AT_low_pc  (0x0000000000001143)
                  DW_AT_high_pc (0x000000000000114d)
                  DW_AT_call_file       ("./small.c")
                  DW_AT_call_line       (8)
                  DW_AT_call_column     (0x01)

Because only line table is used, when users use command “b small.c:8”, lldb actually breaks at line 9 which is the nearest line number in line table.

If we parse inline info and store them into the line table, it benefits all users of LineTable::FindLineEntryIndexByFileIndex (I’m only aware of two commands using it b [file]:[line] and thread until [line]).

In this example, we will have an extra line entry from inline info (0x1143 line 8 column 1). When setting breakpoint using b [file]:[line], the one from inline info should be chosen because it has the exact line number.

Is there any concern for adding inline info into line table?

Storing the inline information in the LineTable so that’s there only one place to query makes sense to me. The parsing part sounds slightly more concerning. Is your suggestion to eagerly parse the .debug_info for the inline info when we build the current line table (i.e. to set file and line breakpoints) or to do it “lazily” and extend the line table when something else prompts us to parse the .debug_info?

When setting breakpoint with line number, LLDB firstly finds a line entry without exact match (the nearest one: https://github.com/llvm/llvm-project/blob/bc802407d16f4aa0df9f32610e3b25b6a791c085/lldb/source/Symbol/CompileUnit.cpp#L303), and then later use the the nearest line entry’s line number to find the “best” line entry result with exact match (https://github.com/llvm/llvm-project/blob/7e7aaa53a11009a28228e6f39c48adf64d26d1d6/lldb/source/Symbol/CompileUnit.cpp#L370). So, if we get line 9 in the first query (without inline info), this will mislead us to line 9 even with inline info. in the updated line table.

I think we can “lazily” parse inline info only when we cannot find the line entry with exact line number in line table after the first query and discard the result to retry with parsed inline info to see if we can get a possible line entry with exact line number.