使用gdb中的函数调用堆栈进行导航 [英] Navigate using function call stack in gdb

查看:168
本文介绍了使用gdb中的函数调用堆栈进行导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中,如果单击调用堆栈中的条目,则会打开编辑器并显示该函数的源代码. gdb中可能有类似的东西吗?我在gdb中使用tui(文本用户界面).是否可以使tui在backtrace中显示给定条目的源代码?

In Visual Studio, if you click on an entry in the call stack, that opens editor and shows you the source code for that function. Is something similar possible in gdb? I use tui (text user interface) in gdb. Is it possible to make tui show source code for a given entry in backtrace?

如果没有,那么您如何利用回溯中的信息?您是否手动打开文件并导航到正确的行?

If not, then how do you make use of information in backtrace? Do you manually open the files and navigate to correct line?

推荐答案

当您在断点处使用gdb(在任何模式下)停止并可以使用backtracewhere命令查看回溯时,请使用updown命令专注于回溯的不同功能(框架).

When you stopped with gdb (in any mode) in breakpoint and can see backtrace with backtrace or where commands, use up and down commands to focus on different functions (frames) of backtrace.

您可以使用up 2向上移动两帧. list命令将向您显示当前帧周围的源代码行.

You may use up 2 to go two frames upper. list command will show you source lines around current frame.

我认为,在up/down命令之后,ui将更改当前显示的功能/寄存器;并且在tui中没有指向和单击的回溯跟踪(在tui中是否有对鼠标的任何支持?).只有记录在案的tui窗口是 https://sourceware.org/gdb/onlinedocs/gdb/TUI-Commands. html

I think, tui will change current displayed function/registers after up/down commands; and there can be no point-and-click backtrace in tui (is there any support of mouse in tui?). Only documented windows of tui are https://sourceware.org/gdb/onlinedocs/gdb/TUI-Commands.html

源,程序集和命令窗口.

source, assembly, and command windows.

有些按键可以在TUI中更改当前帧,但不能在正常的TUI模式下更改(

There are keys to change current frame in TUI, but not in the normal TUI mode (https://sourceware.org/gdb/onlinedocs/gdb/TUI-Keys.html), so you can use text commands of gdb.

还有一个由Ctrl-x s激活的"TUI单键模式",并且在此模式下有向上/向下命令:u/dw以获取回溯.该模式记录在 https ://sourceware.org/gdb/onlinedocs/gdb/TUI-Single-Key-Mode.html#TUI-Single-Key-Mode :

There is also "TUI Single Key Mode", activated by Ctrl-x s, and there are up/down commands in this mode: u/d and w to get backtrace. The mode is documented at https://sourceware.org/gdb/onlinedocs/gdb/TUI-Single-Key-Mode.html#TUI-Single-Key-Mode:

25.3 TUI单键模式

25.3 TUI Single Key Mode

 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命令提示符.按下的键被插入到编辑缓冲区中,这样就可以在不与TUI SingleKey模式交互的情况下键入大多数gdb命令.输入命令后,将恢复TUI单键模式.永久退出此模式的唯一方法是键入qC-x s.

Other keys temporarily switch to the gdb command prompt. The key that was pressed is inserted in the editing buffer so that it is possible to type most gdb commands without interaction with the TUI SingleKey mode. Once the command is entered the TUI SingleKey mode is restored. The only way to permanently leave this mode is by typing q or C-x s.

您还可以尝试使用GUI调试器( gnu ddd KDbg ),或大多数Linux IDE中内置的任何其他gdb包装器(

You may also try some debugger with GUI (gnu ddd or KDbg), or any other gdb wrapper builtin in most Linux IDEs (list, wiki list: Eclipse, Netbeans, CLion, KDevelop, Code::Blocks, CodeLite, ...). They all are more modern and convenient for debugging.

这篇关于使用gdb中的函数调用堆栈进行导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆