[英]GDB C++ How to Stop Stepping Inside Standard Libraries
this post briefly discusses the same trouble I am facing. 这篇文章简要讨论了我面临的同样麻烦。 Essentially, is there a default setting or a hack for gdb to stop stepping inside every single glib library and only step inside user files?
本质上,gdb 是否有默认设置或 hack 以停止进入每个 glib 库并仅进入用户文件? I know I can call
finish
each time it steps inside one but it's some wasted keystrokes I'd rather avoid.我知道每次它进入其中时我都可以调用
finish
,但这是我宁愿避免的一些浪费的击键。
It's already annoying as it is to deal with g++'s output. If this exhibitionism cannot be stopped, are there good alternatives to these gnu tools?处理 g++ 的 output 已经很烦人了。如果不能停止这种暴露癖,这些 gnu 工具是否有好的替代品? I do hear good things about eclipse, but I'm just a student looking for quick and dirty fixes with minimal effort.
我确实听说过有关 eclipse 的好消息,但我只是一名学生,正在寻找以最少的努力进行快速而肮脏的修复。
If you have GDB 7.12.1 or above you can add the following to your ~/.gdbinit
file:如果您有 GDB 7.12.1 或更高版本,您可以将以下内容添加到您的
~/.gdbinit
文件中:
skip -gfi /usr/include/c++/*/*/*
skip -gfi /usr/include/c++/*/*
skip -gfi /usr/include/c++/*
Double check that these are in fact the right places for those libs.仔细检查这些实际上是这些库的正确位置。 This answer comes from here .
这个答案来自这里。
Some options without editing gdb init一些选项无需编辑 gdb init
If you want to "step over" a line (like std::vector<int> a;
) without stepping into it, you can use next
.如果你想“跨过”一行(比如
std::vector<int> a;
)而不进入它,你可以使用next
。
If you have a situation like int b = is_negative(a[0])
and you want to stop in is_negative
you have a few options:如果你遇到类似
int b = is_negative(a[0])
的情况并且你想在is_negative
中停止,你有几个选择:
a[0]
function then use finish
to step out again.a[0]
function 然后使用finish
再次退出。tbreak is_negative
to create a temporary breakpoint on the is_negative
function then use next
to step which will break on the breakpoint.tbreak is_negative
在is_negative
function 上创建一个临时断点,然后使用next
将在断点处中断。 2 is faster in the case where you have something with many sub calls in a function like:如果 function 中有许多子调用,则 2 会更快,例如:
is_negative(a[b.at(2)] * c[3]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.