Created
September 2, 2018 15:52
-
-
Save hilbix/f375b4019ac68244c079f54c339f0729 to your computer and use it in GitHub Desktop.
No-Brainer function to debug with `gdb` from shell level
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This function keeps IO redirection and commandline arguments | |
# when you want to debug some executable. | |
# | |
# Just type "debug" in front of the call: | |
# "b u g" "${p[@]}" < <(in) 1> >(out) 2> >(two) 3> >(three) | |
# debug "b u g" "${p[@]}" < <(in) 1> >(out) 2> >(two) 3> >(three) | |
# | |
# All you need is a /dev/tty | |
debug() | |
{ | |
1000<&0 1001>&1 1002>&2 \ | |
0</dev/tty 1>/dev/tty 2>&0 \ | |
/usr/bin/gdb -q -nx -nw \ | |
-ex 'set exec-wrapper /bin/bash -c "exec 0<&1000 1>&1001 2>&1002 \"\$@\"" exec' \ | |
-ex r \ | |
--args "$@"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See Stackoverflow
And I currently realize, that this probably can be expressed as shell alias as well.