env() function at different places returns different addresses

Norman Feske norman.feske at ...1...
Mon Nov 19 16:31:42 CET 2012


Hello Jaeyong,

> One more question is that "how do you backtrace init?"

this depends on the used base platform. In this particular case, I
reproduced the issue using the 'base-linux' platform where each Genode
process is a plain Linux process. Hence, it is possible to attach the
GNU debugger to the individual process:

  gdb -p `pidof "[Genode] init"`

The 'bt' GDB command reveals the backtrace. Pretty convenient, isn't it?

On L4/Fiasco and Fiasco.OC, the kernel debugger comes with a basic
backtrace feature. After breaking-in into the debugger (by pressing
[esc]), you can list all threads using the 'lp' command. There you can
see all threads and their respective IDs. This ID can then be specified
to the backtrace command ('btt'). The back trace is just a bunch of EIP
values, which can be looked up in the disassembled binary. (e.g.,
searching in the output of 'objdump -lSd') Alternatively, you might use
a convenience script that comes with the Fiasco kernel and parses the
EIP values for you. It is located at
'base-foc/contrib/kernel/fiasco/tool/backtrace' (after you issued 'make
prepare' within the 'base-foc' directory).

On other kernels such as OKL4 and L4ka::Pistachio, obtaining backtraces
must be done by hand by dumping the user stack of the corresponding
thread and looking for "interesting" addresses. This is less convenient
but principally works. On NOVA or base-hw, no kernel debugger is
available. Here, the "-S" option of qemu becomes handy, which allows GDB
to be attached to Qemu.

In practice, we often find ourselves jumping from one kernel to another
while debugging because the facilities are so different and most code on
Genode (and thereby also the bugs) is platform-agnostic anyway. ;-)

> And, by any chance, is there any builtin function that performs backtrace
> (like backtrace function of glibc in Linux)?

There is the built-in compiler function command
'__builtin_return_address'. On the x86 architecture, you can obtain the
return address of the current stack frame as follows:

  PLOG("came from: %p", __builtin_return_address(0));

Using the argument, it is possible to select the stack frame, in which
you are interested in. Unfortunately, this capability is severe limited
on ARM.

I hope these pointers will be of help. If you are interested in reading
about further user-level debugging options for Genode, I recommend the
following document:

  http://genode.org/documentation/developer-resources/gdb

Cheers
Norman


-- 
Dr.-Ing. Norman Feske
Genode Labs

http://www.genode-labs.com · http://genode.org

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth




More information about the users mailing list