I'm attempting to use GDB to debug a PowerPC ELF image compiled by the Green Hills GHS compiler from C++ source. The GHS MULTI debugger uses a proprietary debugging format, but the compiler provides a -dwarf2 option to produce native DWARF-2 debugging information as well. GDB is able to read at least some information from the DWARF-2, and can do things like map line numbers to addresses and find the addresses of symbols, but many things such printing local variables in member functions do not work.
I compiled this very simple program with g++ targeting x86 and GHS targeting PowerPC to compare the two. The -dwarf2 and -G flags were set in the top level .gpj for GHS to produce DWARF-2 debug information. I did a readelf --debug-dump
and confirmed that GHS did generate what looks like reasonably correct DWARF-2.
class ClassA {
public:
int Method(bool arg) {
int local_1 = arg * 2;
member_var_ = local_1;
return local_1;
}
int member_var_;
};
int FuncA(int arg) {
int local_2 = arg * 2;
return local_2;
}
double global_a = 1;
namespace NamespaceA {
int FuncB(int arg) {
int local_3 = arg * 2;
return local_3;
}
}
int main(int argc, char *argv[]) {
ClassA a;
return a.Method(true);
}
GDB is able to list all the functions from the g++ compiled ELF:
gdb hello
...
Reading symbols from hello...done.
(gdb) info func
All defined functions:
File hello.cc:
int ClassA::Method(bool);
int FuncA(int);
int NamespaceA::FuncB(int);
int main(int, char**);
GDB does not list the member function or the function declared inside a namespace from the GHS compiled ELF:
gdb hello
...
Reading symbols from hello...done.
(gdb) info func
All defined functions:
File src/hello.cc:
int FuncA(int);
int main(int, char**);
Non-debugging symbols:
...
Is there an incompatibility between GHS generated DWARF-2 and GDB?