Hi I was testing one of my application written using libdw library provided by elfutils-0.141/elfutils-0.137 and it consistently hit error with dwarf_getscopes(). API returned -1 and dwarf_errmsg() returned (null). This problem was observed when the application is made to run over 64 bit vmlinux (with debug info) image, The function address are 64 bit and of the format 0xffffffff800aa89f. Same code works fine with other non vmlinux executables, in which address is 32 bit, Same code works fine on ppc64 and on 64 bit vmlinux image on that machine.
--------------------------------------------------------------------------- Ex: Pseudo code of what I was trying
#define Addr 0xffffffff800aa956 <== Hard Coded function pc
int main(int argc, char *argv[]) { fd = open_file(argv[1] /* Vmlinux Executable */); elf_descriptor = elf_begin(fd, elf_cmd, (Elf *) 0); dbg = dwarf_begin_elf(elf_descriptor, dwarf_cmd, NULL); process_debug_information(dbg) }
int process_debug_information(Dwarf *dbg, Dwarf_Addr *addr) { Dwarf_Die result_cu; Dwarf_Die *cu_die;
//Find the Required Compiler Unit cu_die = dwarf_addrdie(dbg,Addr,&result_cu); <== PASS
//Find the required Function Die nscopes = dwarf_getscopes(cu_die,addr, &scopes); <== FAIL /* This returns -1 and dwarf_errmsg() returns null */ }
--------------------------------------------------------------------------- If some can help me with this bug fixing it will be of great help
Thanks Sharyathi Nagesh
Please point us to an exact kernel binary (e.g. precise Fedora rpm version) and PC to try in it. Note that a handy test program for this is built in systemtap, called "loc2c-test". (That's what I'll likely use to debug the case myself.)
Thanks, Roland
Roland Thanks a lot for responding to the query, excuse me for the late response. loc2c-test.c succeeds ,on the same machine, and I am able to see the expected out put, but the sample test code I am using still fails. Excuse me to ask you to look into my code but I am still not convinced that library is not to blame.
This is the system information OS: Red Hat Enterprise Linux Server release 5.2 (Tikanga) Kernel: 2.6.18-92.el5 elfutils: elfutils-0.139 arch: x86_64
I am attaching the sample code that I am using for testing. This is what I get while testing: ----------------------------------------------- ./read_cu -e ../vmlinux 0xffffffff800aa956
nscopes: -1 dwarf_getscopes error:no error nscopes: 0 dwarf_getscopes error:no error -----------------------------------------------
This is the system detail on which I tested Roland McGrath wrote:
Please point us to an exact kernel binary (e.g. precise Fedora rpm version) and PC to try in it. Note that a handy test program for this is built in systemtap, called "loc2c-test". (That's what I'll likely use to debug the case myself.)
Thanks, Roland
Your test program works correctly for me.
$ ./getscopes -e ~/redhat/tmp/usr/lib/debug/lib/modules/2.6.18-92.el5/vmlinux 0xffffffff800aa956
nscopes: 0 dwarf_getscopes error:no error $
When I debug it to see what's going on, the dwarf_getscopes call returned 2 as expected (not printed here). The line printed actually refers to the dwarf_getscopes_die call, despite the confusing message text. That call returned 0 as expected, since you called it on the CU itself, and by definition there are no containing scopes of a CU.
I tried it with elfutils-0.141-1.fc10.x86_64 on Fedora 10. If 0.139 or 0.140 works differently that's a surprise off hand--I don't recall any relevant fixes, but there might have been some.
Thanks, Roland
Roland Thanks for helping out. I got the problem, even though in Makefile I was specifying the elfutils -0.139 ldd showed that it was linking to libdw/libelf provided by elfutils-0.125 (shipped with system) and elfutils-0.125 is broken. Updating LD_LIBRARY_PATH helped.
Thanks a ton for bearing with me
Regards Sharyathi N
Roland McGrath wrote:
Your test program works correctly for me.
$ ./getscopes -e ~/redhat/tmp/usr/lib/debug/lib/modules/2.6.18-92.el5/vmlinux 0xffffffff800aa956
nscopes: 0 dwarf_getscopes error:no error $
When I debug it to see what's going on, the dwarf_getscopes call returned 2 as expected (not printed here). The line printed actually refers to the dwarf_getscopes_die call, despite the confusing message text. That call returned 0 as expected, since you called it on the CU itself, and by definition there are no containing scopes of a CU.
I tried it with elfutils-0.141-1.fc10.x86_64 on Fedora 10. If 0.139 or 0.140 works differently that's a surprise off hand--I don't recall any relevant fixes, but there might have been some.
Thanks, Roland
elfutils-devel@lists.fedorahosted.org