[Crash-utility] Re: [PATCH 0/2] Display local variables & function parameters from stack frames

Dave Anderson anderson at redhat.com
Wed May 6 15:10:13 UTC 2009


----- "Sharyathi Nagesh" <sharyath at in.ibm.com> wrote:

> Hi
> 	Mohan, Sachin and myself have implemented this feature in crash to 
> display local variables and arguments from vmcore dumps. This feature
> introduces a new command 'local' in crash utility which provides
> interface for stack unwinding along with option to display local
> variables and arguments. This patch is based on crash utility
> crash-4.0-8.9. It has dependency on libdw/libelf libraries provided by
> elfutils package.
> 	This has been tested on dumps taken on ppc64 machine. We were able to 
> unwind the stack as well as display local variables, arguments. It 
> currently displays values for non-optimized variables only (this fallows 
> gdb's convention)
> 
> TODO Items:
> 	1. Support on x86_64 and x86 need to be implemented/tested
> 	2. Makefile need to be updated to help packaging this feature
> 	
> Regards
> Sharyathi Nagesh

A couple suggestions -- move the get_netdump_arch() and get_regs_from_elf_notes()
prototypes to defs.h under the others listed for netdump.c.

Then remove this from local.c:

  + #include <../netdump.h>

By removing the netdump.h inclusion, you can build your package with just
the "defs.h" file like so:

  # make -f local.mk TARGET=X86_64
  gcc -nostartfiles -shared -g -rdynamic -o local.so local.c unwind_dw.c -fPIC \
      -ldw -L ../../elfutils-0.137/libdw -I ../../elfutils-0.137/libdw \
      -I ../../elfutils-0.137/libelf/ -DX86_64   -Wall;
  #

Also, the TARGET_FLAGS setting you have in your local.mk doesn't do anything.
I see that you copied it from the sial.mk file, where it's used as a replacement
in sial.mk to replace the suggested "-D$(TARGET) $(TARGET_CFLAGS)" part of the
compile line.  For x86_64 nothing is needed in TARGET_CFLAGS -- these are what
the supported arches need:

  #define TARGET_CFLAGS_X86    "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
  #define TARGET_CFLAGS_ALPHA  "TARGET_CFLAGS="
  #define TARGET_CFLAGS_PPC    "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
  #define TARGET_CFLAGS_IA64   "TARGET_CFLAGS="
  #define TARGET_CFLAGS_S390   "TARGET_CFLAGS=-D_FILE_OFFSET_BITS=64"
  #define TARGET_CFLAGS_S390X  "TARGET_CFLAGS="
  #define TARGET_CFLAGS_PPC64  "TARGET_CFLAGS=-m64"
  #define TARGET_CFLAGS_X86_64 "TARGET_CFLAGS="

So I presume you do need the -m64 for ppc64, but I don't see how your
local.mk file would pick it up?  I also don't understand where your extra
$ADD_CFLAGS is supposed to get set up?

For that matter, the additional -L and -I for the elfutils stuff you've added
seem to be unnecessary, just -ldw seems to be suffice:

  # make -f local2.mk TARGET=X86_64
  gcc -nostartfiles -shared -g -rdynamic -o local.so local.c unwind_dw.c -fPIC -ldw -DX86_64 -Wall; 
  # 

Thanks,
  Dave







More information about the Crash-utility mailing list