Hi all,
I am trying to unwind stack frame using lib unwind lib, but most of the time i could not able to get the stack trace, especially t system call frames and pthread lib frame ( am not sure about the other lib frames).
A little debugging inside the code i figured out libwind failes where the base pointer getting changed for eg pthread_cond_wait changes the bp and copies it into some other register
Is there anyway i can unwind the stack similar to gdb does libwind has that support?
Attached below is the out of the stack trace using libunwind (
http://techie-builder.blogspot.in/2011/07/get-call-stack-programatically-for.html) and using pstack
using libunwind
----------------------------
address@hidden Sample_testing]$ ./a.out 4200
----------tid4200----------
main
__libc_start_main
_start
----------tid4201----------
----------tid4202----------
tsk_wrap
start_thread
clone
----------tid4203----------
----------tid4204----------
----------tid4205----------
sntpd
tsk_wrap
start_thread
clone
----------tid4206----------
----------tid4207----------
if_link_monitor
tsk_wrap
start_thread
clone
----------tid4208----------
packet_processing_task
tsk_wrap
start_thread
clone
----------tid4209----------
packet_processing_task
tsk_wrap
start_thread
clone
----------tid4210----------
packet_processing_task
tsk_wrap
start_thread
clone
----------tid4211----------
packet_processing_task
tsk_wrap
start_thread
clone
----------tid4212----------
read_username_password
process_login
show_login_prompt
cparser_run
cmdinterface
tsk_wrap
start_thread
clone
Pstack output
---------------------
address@hidden Sample_testing]$ pstack 4269
Thread 12 (Thread 0xb77ca870 (LWP 4270)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x004ac22c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2 0x08064743 in evt_rx ()
#3 0x08063928 in tick_service ()
#4 0x08064909 in tsk_wrap ()
#5 0x004a8919 in start_thread () from /lib/libpthread.so.0
#6 0x001ecd4e in clone () from /lib/libc.so.6
Thread 11 (Thread 0xb77c2870 (LWP 4271)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x004afbd6 in nanosleep () from /lib/libpthread.so.0
#2 0x080638c7 in tick_clock ()
#3 0x08064909 in tsk_wrap ()
#4 0x004a8919 in start_thread () from /lib/libpthread.so.0
#5 0x001ecd4e in clone () from /lib/libc.so.6
Thread 10 (Thread 0xb5b76870 (LWP 4272)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x004ac22c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2 0x08060a04 in msg_rcv ()
#3 0x08071142 in stpmgr_task ()
#4 0x08064909 in tsk_wrap ()
#5 0x004a8919 in start_thread () from /lib/libpthread.so.0
#6 0x001ecd4e in clone () from /lib/libc.so.6
Thread 9 (Thread 0x8db6cb70 (LWP 4273)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x004ac22c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2 0x0805bb56 in EvtRx ()
#3 0x08061a36 in dequeue_packet ()
#4 0x08071834 in dhcp_task ()
#5 0x08064909 in tsk_wrap ()
#6 0x004a8919 in start_thread () from /lib/libpthread.so.0
#7 0x001ecd4e in clone () from /lib/libc.so.6
Thread 8 (Thread 0x8db67b70 (LWP 4274)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x001acea6 in nanosleep () from /lib/libc.so.6
#2 0x001e5c2c in usleep () from /lib/libc.so.6
#3 0x080859b3 in sntpd ()
#4 0x08064909 in tsk_wrap ()
#5 0x004a8919 in start_thread () from /lib/libpthread.so.0
#6 0x001ecd4e in clone () from /lib/libc.so.6
Thread 7 (Thread 0x8db62b70 (LWP 4275)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x004ac22c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2 0x0805bb56 in EvtRx ()
#3 0x08061a36 in dequeue_packet ()
#4 0x0806a382 in netconn_accept ()
#5 0x0806ce6e in lwip_accept ()
#6 0x0808f887 in telnetd ()
#7 0x08064909 in tsk_wrap ()
#8 0x004a8919 in start_thread () from /lib/libpthread.so.0
#9 0x001ecd4e in clone () from /lib/libc.so.6
Thread 6 (Thread 0x8db5d870 (LWP 4276)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x001acea6 in nanosleep () from /lib/libc.so.6
#2 0x001accd0 in sleep () from /lib/libc.so.6
#3 0x08092977 in if_link_monitor ()
#4 0x08064909 in tsk_wrap ()
#5 0x004a8919 in start_thread () from /lib/libpthread.so.0
#6 0x001ecd4e in clone () from /lib/libc.so.6
Thread 5 (Thread 0x8d955870 (LWP 4277)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x001acea6 in nanosleep () from /lib/libc.so.6
#2 0x001accd0 in sleep () from /lib/libc.so.6
#3 0x08092c4c in packet_processing_task ()
#4 0x08064909 in tsk_wrap ()
#5 0x004a8919 in start_thread () from /lib/libpthread.so.0
#6 0x001ecd4e in clone () from /lib/libc.so.6
Thread 4 (Thread 0x8db55870 (LWP 4278)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x001acea6 in nanosleep () from /lib/libc.so.6
#2 0x001accd0 in sleep () from /lib/libc.so.6
#3 0x08092c4c in packet_processing_task ()
#4 0x08064909 in tsk_wrap ()
#5 0x004a8919 in start_thread () from /lib/libpthread.so.0
#6 0x001ecd4e in clone () from /lib/libc.so.6
Thread 3 (Thread 0x8db4d870 (LWP 4279)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x001acea6 in nanosleep () from /lib/libc.so.6
#2 0x001accd0 in sleep () from /lib/libc.so.6
#3 0x08092c4c in packet_processing_task ()
#4 0x08064909 in tsk_wrap ()
#5 0x004a8919 in start_thread () from /lib/libpthread.so.0
#6 0x001ecd4e in clone () from /lib/libc.so.6
Thread 2 (Thread 0x8db45870 (LWP 4280)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x004af3fb in read () from /lib/libpthread.so.0
#2 0x0804acfc in read_input ()
#3 0x08053862 in read_username_password ()
#4 0x0805378c in process_login ()
#5 0x08053684 in show_login_prompt ()
#6 0x0804e4dc in cparser_run ()
#7 0x0804a7a7 in cmdinterface ()
#8 0x08064909 in tsk_wrap ()
#9 0x004a8919 in start_thread () from /lib/libpthread.so.0
#10 0x001ecd4e in clone () from /lib/libc.so.6
Thread 1 (Thread 0xb77abb30 (LWP 4269)):
#0 0x0059b424 in __kernel_vsyscall ()
#1 0x001acea6 in nanosleep () from /lib/libc.so.6
#2 0x001accd0 in sleep () from /lib/libc.so.6
#3 0x080929f5 in main ()
Thanks
Sasi