This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: dwarf_getscope() fails on x86_64 arch


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

#include <stdio.h>
#include <libdw.h>    
#include <libdwfl.h>    
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <dwarf.h>
#include <string.h>
#include <inttypes.h>
#include <argp.h>

int main(int argc, char **argv)
{
	Dwfl *dwfl = NULL;
	Dwarf_Addr cubias;
	Dwarf_Die *scopes, *cu_die;
	uintmax_t pc;
  	int argi = 0, nscopes;
	char *endp;
	
	argp_parse (dwfl_standard_argp (), argc, argv, 0, &argi, &dwfl);
	if ( !dwfl )
		printf("\n dwfl null");	
	
	pc = strtoumax(argv[argi], &endp,0);
	
	cu_die  = dwfl_addrdie (dwfl, pc, &cubias);
	if (!cu_die)
		printf("\n cu_die is null");

	nscopes = dwarf_getscopes(cu_die, pc - cubias, &scopes);
	if(nscopes < 0)
		printf ("\n nscopes: %d dwarf_getscopes error:%s", nscopes, dwarf_errmsg(-1));
	nscopes = dwarf_getscopes_die(cu_die, &scopes);
		printf ("\n nscopes: %d dwarf_getscopes error:%s", nscopes, dwarf_errmsg(-1));
	printf("\n");
	return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]