Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why trace.py can not give full userstack with kernel stack #4735

Open
yangguosdxl opened this issue Sep 11, 2023 · 4 comments
Open

why trace.py can not give full userstack with kernel stack #4735

yangguosdxl opened this issue Sep 11, 2023 · 4 comments

Comments

@yangguosdxl
Copy link

./trace-bpfcc -UK __alloc_pages -L $(pidof myhi)
I trace my demo program, it output like this:

PID     TID     COMM            FUNC             
132657  132657  myhi            __alloc_pages    
        b'__alloc_pages+0x1 [kernel]'
        b'vma_alloc_folio+0x9c [kernel]'
        b'do_anonymous_page+0xf5 [kernel]'
        b'handle_pte_fault+0x250 [kernel]'
        b'__handle_mm_fault+0x41f [kernel]'
        b'handle_mm_fault+0xba [kernel]'
        b'do_user_addr_fault+0x1be [kernel]'
        b'exc_page_fault+0x81 [kernel]'
        b'asm_exc_page_fault+0x27 [kernel]'
        b'_int_malloc+0xf00 [libc.so.6]'

the user stack not show all stack. the full may like below:

malloc [libc.so.6]
hello [libhi.so]
main [myhi]

anyone know why there is not have full user stack?

thanks

demo.zip

@chenhengqi
Copy link
Collaborator

Kernel relies on stack pointer to unwind the stack, and likely, your libc is compiled with omit frame pointer, so the stack is imcomplete.

There is an attempt to using DWARF to unwind the stack, see https://www.polarsignals.com/blog/posts/2022/11/29/dwarf-based-stack-walking-using-ebpf/.

@yangguosdxl
Copy link
Author

Kernel relies on stack pointer to unwind the stack, and likely, your libc is compiled with omit frame pointer, so the stack is imcomplete.

There is an attempt to using DWARF to unwind the stack, see https://www.polarsignals.com/blog/posts/2022/11/29/dwarf-based-stack-walking-using-ebpf/.

how do you know my libc is compiled with omit frame pointer?

@chenhengqi
Copy link
Collaborator

I don't know, I just guess, most Linux distributions do that.

https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer

@Bojun-Seo
Copy link
Contributor

These PR may help you to unwind(or guess) stack without recompiling libc.so with -fno-omit-frame-pointer.
#4463 #4679

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants