[llvm] [DebugInfo][DWARF] Emit Per-Function Line Table Offsets and End Sequences (PR #110192)
Shubham Sandeep Rastogi via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 17:01:56 PDT 2024
rastogishubham wrote:
@alx32 there is a major bug with this patch and I am not sure why it is happening.
If we take this test file:
```
// /tmp/a.cpp
int foo() {
return 1;
}
int bar() {
return 2;
}
int baz() {
return 3;
}
```
compile it regularly:
`clang -c -g /tmp/a.cpp -o /tmp/a.o`
then use dwarfdump on it with the verbose mode (-v):
`dwarfdump --debug-line /tmp/a.o -v`
We will see:
```
Address Line Column File ISA Discriminator OpIndex Flags
------------------ ------ ------ ------ --- ------------- ------- -------------
0x00000043: 04 DW_LNS_set_file (0)
0x00000045: 05 DW_LNS_set_column (5)
0x00000047: 0a DW_LNS_set_prologue_end
0x00000048: 00 DW_LNE_set_address (0x0000000000000000)
0x00000053: 13 address += 0, line += 1, op-index += 0
0x0000000000000000 2 5 0 0 0 0 is_stmt prologue_end
0x00000054: 0a DW_LNS_set_prologue_end
0x00000055: 86 address += 8, line += 4, op-index += 0
0x0000000000000008 6 5 0 0 0 0 is_stmt prologue_end
0x00000056: 0a DW_LNS_set_prologue_end
0x00000057: 86 address += 8, line += 4, op-index += 0
0x0000000000000010 10 5 0 0 0 0 is_stmt prologue_end
0x00000058: 02 DW_LNS_advance_pc (addr += 8, op-index += 0)
0x0000005a: 00 DW_LNE_end_sequence
0x0000000000000018 10 5 0 0 0 0 is_stmt end_sequence
```
However, when I use apply your patch and use:
`clang -mllvm -emit-func-debug-line-table-offsets -c -g /tmp/a.cpp -o /tmp/a.o`
then use dwardump:
`dwarfdump --debug-line /tmp/a.o -v`
I see:
```
Address Line Column File ISA Discriminator OpIndex Flags
------------------ ------ ------ ------ --- ------------- ------- -------------
0x00000043: 00 DW_LNE_set_address (0x0000000000000008)
0x0000004e: 01 DW_LNS_copy
0x0000000000000008 1 0 1 0 0 0 is_stmt
0x0000004f: 00 DW_LNE_end_sequence
0x0000000000000008 1 0 1 0 0 0 is_stmt end_sequence
0x00000052: 00 DW_LNE_set_address (0x0000000000000010)
0x0000005d: 01 DW_LNS_copy
0x0000000000000010 1 0 1 0 0 0 is_stmt
0x0000005e: 00 DW_LNE_end_sequence
0x0000000000000010 1 0 1 0 0 0 is_stmt end_sequence
0x00000061: 00 DW_LNE_set_address (0x0000000000000018)
0x0000006c: 01 DW_LNS_copy
0x0000000000000018 1 0 1 0 0 0 is_stmt
0x0000006d: 00 DW_LNE_end_sequence
0x0000000000000018 1 0 1 0 0 0 is_stmt end_sequence
```
Notice that there are no line table opcodes that advance the file and line, the file and line stay 1 and 0 for the duration of the line table. That is very wrong.
https://github.com/llvm/llvm-project/pull/110192
More information about the llvm-commits
mailing list