Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have been looking through the documentation for /proc and the "stack" object being a new'ish object in proc, I have also looked through the kernel commit to create it -- however the documentation does not detail exactly what is in the /proc/self/stack file -- and since I intuitively expected it to be the actual stack of the process -- however the old pstack tool gives a different (and more believable) output.

So as an example of the stack for bash

$ cat /proc/self/stack 
[<ffffffff8106f955>] do_wait+0x1c5/0x250
[<ffffffff8106fa83>] sys_wait4+0xa3/0x100
[<ffffffff81013172>] system_call_fastpath+0x16/0x1b
[<ffffffffffffffff>] 0xffffffffffffffff

and, using pstack

$ pstack $$
#0  0x00000038cfaa664e in waitpid () from /lib64/libc.so.6
#1  0x000000000043ed42 in ?? ()
#2  0x000000000043ffbf in wait_for ()
#3  0x0000000000430bc9 in execute_command_internal ()
#4  0x0000000000430dbe in execute_command ()
#5  0x000000000041d526 in reader_loop ()
#6  0x000000000041ccde in main ()

The addresses are different, and obviously the symbols are not at all the same....

Does anybody have an explanation for the difference and/or a document which describes what is actually shown in /proc-stack?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

The file /proc/$pid/stacks shows kernel stacks. On your system, memory addresses of the form ffffffff8xxxxxxx are in the space that's reserved for the kernel. There's not much documentation, you can check the source code. In contracst, the pstack program shows user-space stacks (using its knowledge of executable formats).

share|improve this answer
    
That was what I was guessing as well -- however I could not find any documentation on that. –  Soren Oct 25 '11 at 5:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.