Getting stacktrace of all threads without attaching GDB

后端 未结 6 875
甜味超标
甜味超标 2021-02-13 16:24

Is there a way to print stacktrace of all threads without attaching GDB?

Or is there a command which I can use as gdb batch mode to print stacktrace of all threads?

6条回答
  •  自闭症患者
    2021-02-13 16:44

    elfutils among other utilities includes eu-stack:

    eu-stack
        Print a stack for each thread in a process or core file.
    

    It is faster than gdb or pstack, which is just a shell script wrapper around gdb. To print stack traces run eu-stack as follows:

    $ eu-stack -p 2209
    PID 2209 - process
    TID 2209:
    #0  0x00007f53476b667b __poll
    #1  0x00007f5348f98e99 g_main_context_iterate.isra.23
    #2  0x00007f5348f99232 g_main_loop_run
    #3  0x000055e604b1e56a main
    #4  0x00007f53475cc00a __libc_start_main
    #5  0x000055e604b1e76a _start
    TID 2223:
    #0  0x00007f53476b667b __poll
    #1  0x00007f5348f98e99 g_main_context_iterate.isra.23
    #2  0x00007f5348f98fac g_main_context_iteration
    #3  0x00007f5348f98ff1 glib_worker_main
    #4  0x00007f5348fc0486 g_thread_proxy
    #5  0x00007f534813761b start_thread
    #6  0x00007f53476c2c2f __clone
    TID 2224:
    #0  0x00007f53476b667b __poll
    #1  0x00007f5348f98e99 g_main_context_iterate.isra.23
    #2  0x00007f5348f99232 g_main_loop_run
    #3  0x00007f5349581b56 gdbus_shared_thread_func
    #4  0x00007f5348fc0486 g_thread_proxy
    #5  0x00007f534813761b start_thread
    #6  0x00007f53476c2c2f __clone
    

提交回复
热议问题