Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using gdb -i=mi integration in emacs 24

Tags:

emacs

gdb

I'm checking out a segfault in one of our apps. A short time after starting the app, the main gdb status bar changes to:

(Debugger:run [signal-received])

A (gdb) prompt appears but the contents of all other windows remain unchanged (empty). Typing anything at the prompt does nothing - gdb appears to be hanging. Running the same steps on the command line results in the expected output from gdb with a complete and correct backtrace.

This is my first time debugging with the -i=mi integration between emacs and gdb. I'm using emacs 24.2 and gdb 7.5.

Are there any suggestions on how I can debug this further?

Is it possible to reduce the level of integration? Would that allow me to determine which area is causing the problem?

A final point is that the initial loading of the app takes around 70s compared with around 3s from the command line.

like image 430
Richard Corden Avatar asked Dec 19 '12 19:12

Richard Corden


People also ask

How do you use Gdbgui?

You need to help gdbgui out by typing main into the file browser box: and selecting the main.rs file. The source code should then appear in the browser and you can click to set breakpoints and run the program. Of course, if you want to break in some other file, you can find that in the file browser instead.

Why is GDB useful?

GDB (GNU debugger) can pause the execution of a running program and let you examine/take control of its memory. It's probably one of the most powerful tools that can help you nail down the exact cause of a problem with your program.

At which point does GDB stop a running program?

gdb will stop your program at whatever line it has just executed. From here you can examine variables and move through your program.


3 Answers

Load time can be reduced by setting gdb-create-source-file-list to nil (use customize). See the documentation for what this does and why it substantially increases load times in some instances.

like image 146
Alastair Avatar answered Oct 20 '22 20:10

Alastair


You can use M-x gud-gdb to use the old gud mode (i.e. without the mi interaction). Less fancy but more reliable.

like image 26
Stefan Avatar answered Oct 20 '22 19:10

Stefan


It appears that gdb-ui from emacs 23 will still work in emacs 24:

  • Find a copy of gdb-ui (In my case gdb-ui.el.gz and gdb-ui.elc from a backup)
  • Place these into a directory (I have added ~/emacs-modes)

Then add the following to your .emacs:

(add-to-list 'load-path "~/emacs-modes")
(require 'gdb-ui)

Running gdb will now use the old --annotate=3 mode rather than -i=mi.

like image 4
2 revs Avatar answered Oct 20 '22 20:10

2 revs