Skip to content

Instantly share code, notes, and snippets.

@justdoit0823
Last active February 27, 2018 09:31
Show Gist options
  • Save justdoit0823/2a09aea129edf2ae8d085fa05c5b643f to your computer and use it in GitHub Desktop.
Save justdoit0823/2a09aea129edf2ae8d085fa05c5b643f to your computer and use it in GitHub Desktop.
How to debug multithread program under linux system?
# get processes with related threads
ps -eLf |grep "process name"
# list all opened file descriptors in a process PID and under which thread
lsof -aKp PID
# trace syscalls in a process's main thread or other thread PID
strace -p PID
# report statistics for different tasks within process
pidstat -tdru -p PID 1
# debug a process associated with PID
gdb exec_cmd PID
# list threads within process PID
info threads
# jump to thread with ID
thread ID
# print a stack trace of a running process
gstack PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment