我可以继续使用gdb,但每次我想看看我在源代码中的位置时,我都必须给出"list"命令.
(gdb) next
351 int right = get_variable(right_token, right_id);
(gdb) list
346 op = "<>";
347 right_id = parse_id_or_crash();
348 }
349 Token * right_token = tokens[parser_index - 1];
350 int left = get_variable(left_token, left_id);
351 int right = get_variable(right_token, right_id);
352 if (op == "<")
353 return left < right;
354 if (op == ">")
355 return left > right;
Run Code Online (Sandbox Code Playgroud)
如果gdb在每一步之后自动列出源代码,那就太好了.如果gdb可以指示我在源代码中的位置(例如使用" - >"或其他内容),这也会很棒.一次看到只有一行代码让我有点幽闭恐慌.
ks1*_*322 18
使用gdb TUI模式http://sourceware.org/gdb/onlinedocs/gdb/TUI-Overview.html#TUI-Overview 您可以使用Cx A键绑定进入或退出TUI模式.
hook-stop
define hook-stop
l
end
Run Code Online (Sandbox Code Playgroud)
Doc:https://sourceware.org/gdb/current/onlinedocs/gdb/Hooks.html
另外,存在伪命令"停止".定义('hook-stop')使得每次执行程序停止时都会执行相关命令:在运行断点命令之前,打印显示或打印堆栈帧.
据了解:https://stackoverflow.com/a/8374474/895245
突出显示当前行
这是完全取代错误-tui模式的唯一缺失.
如果没有Python脚本,目前是不可能的:https://sourceware.org/bugzilla/show_bug.cgi? id = 21044
使用Python脚本,我目前正在使用:https://github.com/cyrus-and/gdb-dashboard

您可以使用GDB宏:
(gdb) def n
Type commands for definition of "n".
End with a line saying just "end".
>next
>list
>end
Run Code Online (Sandbox Code Playgroud)
如果您想要一个指向当前行的箭头,您可以考虑使用GDB前端(例如M-x gdb在Emacs中).