在 Visual Studio 中,如果单击调用堆栈中的某个条目,则会打开编辑器并显示该函数的源代码。 gdb 中可能有类似的东西吗?我在 gdb 中使用 tui(文本用户界面)。是否可以让 tui 显示回溯中给定条目的源代码?
如果没有,那么如何利用回溯中的信息?您是否手动打开文件并导航到正确的行?
当你停下来时gdb
(在任何模式下)在断点中并且可以看到回溯backtrace
or where
命令、使用up
and down
命令专注于回溯的不同功能(框架)。
您可以使用up 2
向上移动两帧。list
命令将显示当前帧周围的源行。
我认为,tui 会在之后更改当前显示的函数/寄存器up
/down
命令;并且tui中不能有点击式回溯(tui中是否支持鼠标?)。仅记录了 tui 的窗口https://sourceware.org/gdb/onlinedocs/gdb/TUI-Commands.html https://sourceware.org/gdb/onlinedocs/gdb/TUI-Commands.html
源窗口、汇编窗口和命令窗口。
TUI 中有更改当前帧的按键,但在普通 TUI 模式下没有(https://sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html https://sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html),这样就可以使用gdb的文本命令了。
还有“TUI 单键模式”,通过以下方式激活Ctrl-x s
,该模式下有向上/向下命令:u
/d
and w
获得回溯。该模式记录在https://sourceware.org/gdb/onlinedocs/gdb/TUI-Single-Key-Mode.html#TUI-Single-Key-Mode https://sourceware.org/gdb/onlinedocs/gdb/TUI-Single-Key-Mode.html#TUI-Single-Key-Mode:
25.3 TUI 单键模式
w where
u up
d down
r run
s step
n next
c continue
f finish
q exit the SingleKey mode.
v info locals
其他键暂时切换到 gdb 命令提示符。按下的键将插入编辑缓冲区中,以便可以键入大多数 gdb 命令,而无需与 TUI SingleKey 模式交互。输入命令后,TUI SingleKey 模式将恢复。永久离开此模式的唯一方法是输入q
or C-x s
.
您还可以尝试一些带有 GUI 的调试器(gnu ddd https://en.wikipedia.org/wiki/Data_Display_Debugger or KDbg http://www.kdbg.org/),或大多数 Linux IDE 中内置的任何其他 gdb 包装器(list https://stackoverflow.com/questions/24109/c-ide-for-linux, 维基列表 https://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#C.2FC.2B.2B:Eclipse、Netbeans、CLion、KDevelop、Code::Blocks、CodeLite,...)。它们都更加现代并且方便调试。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)