Source Column Numbers in DWARF Row Table

For any element in the C / C ++ source file, I would like to be able to define the appropriate memory location in its compiled executable. Compiling with debugging and using the resulting DWARF information is of great importance for this, but it does not meet my purpose. GCC seems to generate DWARF.debug_line information with only line numbers, leaving column numbers equal to 0! It seems strange to me that the DWARF specification allows you to specify column numbers, but GCC does not seem to create them.

Is there something that I am missing - maybe some configuration parameter or command line so that GCC knows that I need columns in my debugging information? Or maybe there is a completely different way to achieve my goal?

Here is a simple bit of code demonstrating the lack of column numbers in DWARF:

int f(int x)
{
    x = 0; x++;
    return x;
}

Compile this with:

gcc -g -c test.c

Then view the DWARF information with:

dwarfdump -l test.o

Here's the conclusion:

.debug_line: line number info for a single cu
Source lines (from CU-DIE at .debug_info offset 0x0000000b):

<pc>        [row,col] NS BB ET PE EB IS= DI= uri: "filepath"
NS new statement, BB new basic block, ET end of text sequence
PE prologue end, EB epilogue begin
IA=val ISA number, DI=val discriminator value
0x00000000  [   2, 0] NS uri: "test.c"
0x00000007  [   3, 0] NS
0x00000012  [   4, 0] NS
0x00000015  [   5, 0] NS
0x00000017  [   5, 0] NS ET
+4
source share
1 answer

GCC does not allocate column numbers in DWARF. This can be done, but no one has provided a patch for this. If you're interested, the GCC DWARF generation code is (almost) located in gcc / dwarf2out.c.

+3
source

Source: https://habr.com/ru/post/1526647/


All Articles