简体   繁体   English

使用gdb在Emacs中调试Fortran代码

[英]Debugging Fortran code in Emacs with gdb

I'm having a problem with debugging Fortran code within emacs using gdb. 我在使用gdb调试emacs中的Fortran代码时遇到问题。

Gdb starts up fine and the program loads OK and stops on the first breakpoint, which I set at the beginning main . GDB启动了罚款和程序加载确定并停在第一个断点,这是我年初设定的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. 然后,当我键入n转到下一行时,程序将一直运行到整个过程(就像我键入c ),而不是转到下一行。 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). 击中c后(在main中的第一个断点处),代码跳至并在后一个断点处停止(这是我想要的)。

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). 但是,在这一点上,我无法再输入gdb命令,因为源代码已移至顶部窗口,输出已移至底部窗口(而通常所有gdb输入命令和程序输出均位于顶部窗口中,并且在底部遍历的源代码)。 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! 因此,现在在这一点上,当我输入gdb命令时,它就成为源代码的一部分,并且我无法使用nc来导航它-而是代码中包含了一堆n和一个c

I'm running Fedora 18, and GNU Emacs 24.3.1. 我正在运行Fedora 18和GNU Emacs 24.3.1。 Also, to run gdb in emacs, it insists I use the switch -i=mi . 另外,要在emacs中运行gdb,它坚持要求我使用开关-i=mi After I hit Mx gdb , the line at the bottom pops up as: Run gdb (like this): gdb -i=mi ... . 在我击中Mx gdb ,底部的行弹出为: Run gdb (like this): gdb -i=mi ... I tried playing around with the switches, such as -annotate=3 to no avail. 我尝试玩弄开关,例如-annotate=3无济于事。

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. 如果我理解正确,您将在emacs中打开两个窗口,而实际上是输出缓冲区和源代码缓冲区已替换了gdb命令缓冲区。

You can switch back to the gdb command buffer with Cx b *gud- programname * RET , where programname is the name of the program you are debugging. 您可以切换回与CX B * gud- PROGRAMNAME * RET,其中PROGRAMNAME是要调试的程序的名称gdb命令缓冲区。 You might find it helpful to create a new window and switch to the gdb command buffer in that. 您可能会发现创建一个新窗口并在其中切换到gdb命令缓冲区很有用。

This happens because the gdb mode isn't clever enough to keep the command window on top. 发生这种情况是因为gdb模式不够聪明,无法使命令窗口位于顶部。 You can use Mx gdb-many-windows which improves on this a bit. 您可以使用Mx gdb-many-windows对此进行一些改进。

These two questions may also be helpful. 两个问题也可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM