3

I like emacs's gdb mode a lot better than GDB's command line or TUI modes, but there are some programs that want a "debugger command line" program that it can take and run in an environment it sets up.

I'm wondering if there's a simple way to make emacs pop up in gdb mode using a command line substitute for gdb.

Thanks in advance.

1 Answer 1

7

Put this in your .bashrc:

gdbtool () { emacs --eval "(gdb \"gdb --annotate=3 $*\")";}

Then you can run "gdbtool programToDebug"

Source: http://www.inet.net.nz/~nickrob/

Sign up to request clarification or add additional context in comments.

5 Comments

Great! Do you happen to know how to pass it arguments to run with as well? I started a gist: gist.github.com/971442
Is there such a way to start gdb? I would start it as given in the answer, then, pass the program's command line arguments to gdb's run command. Or, sometimes use set args and then simply do run.
@cdleary: gdbtool() { emacs --eval "(gdb --annotate=3; --args $* \")";}
And just pass arguments after your program name as if you were running your program. Like "gdbtool foo 1 2 3 blah blah"
And if you are running a more modern emacs/gdb and/or are getting funny output at the start, try "-i=mi" instead of older "--annotate=3".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.