如何在gdb中跳过函数调用?

3 c++ gdb

我想了解我们如何跨越函数调用.例如,在以下最简单的程序中:

 #include<iostream>
 #include "test.h"

 using std::cout;
 using std::endl;

 Uint u;

 int main()
 {
         cout << "executin starting..." << endl;
         cout << u.a << endl;
         cout << "execution completed" << endl;
 }
Run Code Online (Sandbox Code Playgroud)

好的,我按break 11命令在第11行设置断点.现在我想跳过将要调用打印的所有指令,"executin starting..."并在operator <<调用打印endl符号时停止.我怎样才能做到这一点?我应该使用哪个命令?

use*_*326 5

在gdb中,step意味着单步执行(将调用内部函数),并next意味着单步执行(继续并在下一行停止).

但在你的特殊情况下,next可能不是你想要的,我建议首先step进入函数打印"executin starting ...",然后finish继续使用直到它返回,这样程序就会停止<<endl.