Domanda

Im trying to get DWARF info from a C++ file using dwarfdump. The C++ file is very simple -

int foo();

I compile it by doing g++ -g -c test.cpp. I then do dwarfdump test.o, but for some reason I get

----------------------------------------------------------------------
 File: test.o (x86_64)
----------------------------------------------------------------------
.debug_info contents:
< EMPTY >

Why is this? And how can I get my debug dwarf info?

È stato utile?

Soluzione

I figured out what was wrong. No debug information was generated. This is because the optimizer realizes that int foo(); is never called and has no declaration, and as such does not need debug info. Changing the function to

int foo(){
    int x=5;
}

is enough to generate debug info.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top