Skip to content

Instantly share code, notes, and snippets.

@jstaursky
Last active July 22, 2020 16:54
Show Gist options
  • Save jstaursky/6bb061ada3f0f7a356e42c12e760d98e to your computer and use it in GitHub Desktop.
Save jstaursky/6bb061ada3f0f7a356e42c12e760d98e to your computer and use it in GitHub Desktop.
#!/bin/sh
# Useful for debugging a process that gets initialized from another process.
# credit to https://stackoverflow.com/questions/4382348/is-there-any-way-to-tell-gdb-to-wait-for-a-process-to-start-and-attach-to-it
progstr=$1
progpid=`pgrep -o $progstr`
while [ "$progpid" = "" ]; do
progpid=`pgrep -o $progstr`
done
gdb -ex 'break <function signature>' -ex 'starti' -p $progpid
# eg. gdbwait <app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment