linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* can the kernel show user task stack backtrace ?
@ 2009-07-30 15:46 Norbert van Bolhuis
  2009-07-30 16:19 ` Alessandro Rubini
  0 siblings, 1 reply; 4+ messages in thread
From: Norbert van Bolhuis @ 2009-07-30 15:46 UTC (permalink / raw)
  To: linuxppc-dev


Afaik the kernel only shows the stack backtrace of the kernel stack
(of a task).

I wonder if there would be anything wrong with letting it show
the user task stack backtrace in certain cases.

Read the rest to see what I mean.


If kernel.print-fatal-signals has been enabled a crashing
application makes the kernel show this:
ca2/943: potentially unexpected fatal signal 11.

NIP: 1000044c LR: 10000444 CTR: 00000000
REGS: ce73df50 TRAP: 0300   Not tainted  (2.6.28)
MSR: 0000d032 <EE,PR,ME,IR,DR>  CR: 22000422  XER: 20000000
DAR: d0000003, DSISR: 22000000
TASK = ceb7a3e0[943] 'ca2' THREAD: ce73c000

GPR00: 0000000e bf963b30 48025450 0000000a 0ff0ac2c 22000422 00000001 0ff5e6b0
GPR08: 00000001 d0000003 00001032 00000000 ffffffff 1001896c 0ffe9000 00000000
GPR16: 0ffca59c 00000000 1009b940 100a8b6a 100bf234 bfea22b8 100bf224 00000000
GPR24: 100bf008 1009b960 4801e858 4802dd34 4802e7e0 00000000 0ffec8d8 bf963b30
Call Trace:
Segmentation fault
#

It's a real pity the user task stack backtrace isn't shown.
We're dealing with some complex (3rd party) applications and I like to see a
user task stack backtrace.

(Of course the way to go here is to use a debugger (gdb) and
  do a backtrace (with the coredump file).
  However, debugging takes some time. Besides the info is there
  it only needs to be shown. Often just this info is enough to
  pinpoint the problem)

Obviously the arch/powerpc/kernel/process.c:show_stack function
isn't meant for doing this. It only shows the kernel stack.

Btw. this doesn't work in my case since validate_sp returns 0 (because
sp is assigned the user-space stack (bf963b30) while kernel stack starts at ce73c000).
Though if it would work it isn't very usefull I guess since the crashing app
not enters kernel-mode (via sys-calls).

If I change arch/powerpc/kernel/process.c:show_stack (of kernel 2.6.28) like this:

	do {
#if 0
		if (!validate_sp(sp, tsk, STACK_FRAME_OVERHEAD))
			return;
#endif
		 .
		 .
		 .
	} while ((count++ < kstack_depth_to_print) && (sp != 0));


the following is shown:

ca2/943: potentially unexpected fatal signal 11.

NIP: 1000044c LR: 10000444 CTR: c001fd7c

REGS: ce73df50 TRAP: 0300   Not tainted  (2.6.28)
MSR: 0000f932 <EE,PR,FP,ME,IR,DR>  CR: 22000422  XER: 20000000
DAR: d0000003, DSISR: 22000000
TASK = cf09b340[943] 'ca2' THREAD: ce73c000
GPR00: 0000000e bfd65b30 48025450 0000000a 0ff0ac2c 22000422 00000001 0ff5e6b0
GPR08: 00000001 d0000003 00001032 00000000 ffffffff 1001896c 0ffe9000 00000000
GPR16: 0ffca59c 00000000 1009b940 100a8b6a 100bf234 bfb532b8 100bf224 00000000
GPR24: 100bf008 1009b960 4801e858 4802dd34 4802e7e0 00000000 0ffec8d8 bfd65b30
Call Trace:
[bfd65b30] [10000444] 0x10000444 (unreliable)
[bfd65b60] [10000490] 0x10000490
[bfd65b90] [100004cc] 0x100004cc
[bfd65ba0] [0feb39c8] 0xfeb39c8
[bfd65dd0] [0feb3ad4] 0xfeb3ad4
[bfd65de0] [00000000] 0x000000
Segmentation fault
#

which is what I want.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: can the kernel show user task stack backtrace ?
  2009-07-30 15:46 can the kernel show user task stack backtrace ? Norbert van Bolhuis
@ 2009-07-30 16:19 ` Alessandro Rubini
  2009-07-30 16:55   ` Nicholas Mc Guire
  0 siblings, 1 reply; 4+ messages in thread
From: Alessandro Rubini @ 2009-07-30 16:19 UTC (permalink / raw)
  To: nvbolhuis; +Cc: linuxppc-dev

> We're dealing with some complex (3rd party) applications and I like to see a
> user task stack backtrace.
> 
> (Of course the way to go here is to use a debugger (gdb) and
>   do a backtrace (with the coredump file).

Actually, you can intercept SIGSEGV and print your own stack from within
the signal handler. You can also open /proc/self/maps and print it, to
ease understanding the various pointers in there, especially if the
application is using a number of shared libs.

This is usually easier than getting to a core dump, although there is
less information than what the core offers.

I have the code for ARM and I've it on ppc once, but I must dig for the actual
code.

/alessandro

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: can the kernel show user task stack backtrace ?
  2009-07-30 16:19 ` Alessandro Rubini
@ 2009-07-30 16:55   ` Nicholas Mc Guire
  2009-07-31  8:01     ` Norbert van Bolhuis
  0 siblings, 1 reply; 4+ messages in thread
From: Nicholas Mc Guire @ 2009-07-30 16:55 UTC (permalink / raw)
  To: Alessandro Rubini; +Cc: linuxppc-dev, nvbolhuis

On Thu, 30 Jul 2009, Alessandro Rubini wrote:

> > We're dealing with some complex (3rd party) applications and I like to see a
> > user task stack backtrace.
> > 
> > (Of course the way to go here is to use a debugger (gdb) and
> >   do a backtrace (with the coredump file).
> 
> Actually, you can intercept SIGSEGV and print your own stack from within
> the signal handler. You can also open /proc/self/maps and print it, to
> ease understanding the various pointers in there, especially if the
> application is using a number of shared libs.
> 
> This is usually easier than getting to a core dump, although there is
> less information than what the core offers.
> 
> I have the code for ARM and I've it on ppc once, but I must dig for the actual
> code.
>
I think libSegFault.so (part of glibc) can do that by simply preloading it 

LD_PRELOAD=/lib/libSegFault.so ./your_segfaulting_app

should do the trick.

hofrat

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: can the kernel show user task stack backtrace ?
  2009-07-30 16:55   ` Nicholas Mc Guire
@ 2009-07-31  8:01     ` Norbert van Bolhuis
  0 siblings, 0 replies; 4+ messages in thread
From: Norbert van Bolhuis @ 2009-07-31  8:01 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Mc Guire, Alessandro Rubini


Thanks for the answers!

libSegFault.so seems to do what I want. I'll replace
sysctl -w kernel.print-fatal-signals=1
with
export LD_PRELOAD=/lib/libSegFault.so
since it better suits my needs.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-31  8:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-30 15:46 can the kernel show user task stack backtrace ? Norbert van Bolhuis
2009-07-30 16:19 ` Alessandro Rubini
2009-07-30 16:55   ` Nicholas Mc Guire
2009-07-31  8:01     ` Norbert van Bolhuis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).