C++ 在跳过所有内部实现的同时,如何跳转到GDB中std::function内的函数?
以这个代码为例:C++ 在跳过所有内部实现的同时,如何跳转到GDB中std::function内的函数?,c++,gdb,C++,Gdb,以这个代码为例: #include <iostream> #include <memory> #include <functional> std::function<int()> getint = [] { return 5; }; void foo(int i) { std::cout<<i<<std::endl; } int main() { foo(getint()); } 但这会导致步
#include <iostream>
#include <memory>
#include <functional>
std::function<int()> getint = []
{
return 5;
};
void foo(int i)
{
std::cout<<i<<std::endl;
}
int main()
{
foo(getint());
}
但这会导致步骤
直接跳入foo
,完全跳过std::function
中的lambda
如果第17行的
步骤将直接带我到第7行的lambda,是否可以配置gdb?好的,我使用一个简单的python脚本解决了这个问题:
import gdb
import re
def stop_handler(event):
frame_name = gdb.selected_frame().name();
if re.search("(^std::.*)|(^boost::.*)", frame_name) != None:
gdb.execute("step")
gdb.events.stop.connect(stop_handler)
不适合我(GDB8.0.1)。我对u_gnu_cxx进行了奇怪的分析::u是_null_指针和u subvdi3,后面是gdb segfault。所以我很高兴看到其他的尝试。在GDB8.2中对我有效。在IDE中观看它真的很有趣,它显示了一秒钟内跳过的十几个文件:))
import gdb
import re
def stop_handler(event):
frame_name = gdb.selected_frame().name();
if re.search("(^std::.*)|(^boost::.*)", frame_name) != None:
gdb.execute("step")
gdb.events.stop.connect(stop_handler)