1
votes

I'm having a problem with debugging Fortran code within emacs using gdb.

Gdb starts up fine and the program loads OK and stops on the first breakpoint, which I set at the beginning main. Then when I type n to go to the next line, the program proceeds to run all the way through (as if I typed c), instead of going to the next line. To get around this, I set another breakpoint further down. After hitting c, (at the first breakpoint in main) the code skips to and stops at the latter breakpoint (which is what I want).

However, at this point, I can no longer enter gdb commands, as the source code has moved to the top window, and the output to the bottom window (whereas normally all the gdb input commands and program output occur in the top window, and the source code being traversed through on the bottom). So now at this point, when I enter gdb commands, it becomes part of the source code and I cannot navigate through it with n and c and such - instead the code has a bunch of n's an c's in it!

I'm running Fedora 18, and GNU Emacs 24.3.1. Also, to run gdb in emacs, it insists I use the switch -i=mi. After I hit M-x gdb, the line at the bottom pops up as: Run gdb (like this): gdb -i=mi .... I tried playing around with the switches, such as -annotate=3 to no avail.

1
Does it work correctly from a shell (without Emacs)? Which Fortran compiler do you use?Peter
Hi, thanks for responding. It works fine without the shell, from the command line, just not in emacs. I'm using gfortran v. 4.8.2. Maybe I'll try another compiler.jdeckman
Is your Emacs launched from the same shell from which gdb works when used directly?Peter
Do you mean shell as in bash shell? Both are launched from the bash command line.jdeckman

1 Answers

0
votes

If I understand correctly, you only have two windows open within emacs, and what has happened is that the output and source code buffers have replaced the gdb command buffer.

You can switch back to the gdb command buffer with C-x b *gud-programname* RET, where programname is the name of the program you are debugging. You might find it helpful to create a new window and switch to the gdb command buffer in that.

This happens because the gdb mode isn't clever enough to keep the command window on top. You can use M-x gdb-many-windows which improves on this a bit.

These two questions may also be helpful.