user2953119
user2953119

Reputation:

How can we step over a function call in GDB?

I want to understand how we can step over a function call. For instance, consider the following program:

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

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

 Uint u;

 int main()
 {
     cout << "execution starting..." << endl;
     cout << u.a << endl;
     cout << "execution completed" << endl;
 }

In GDB, I set a breakpoint at the 11th line (cout << "execution starting..." << endl;) with break 11.

Now I want to step over all instructions which are going to be invoked in printing "execution starting..." and stop at the << operator call that prints the endl symbol.

How can I do that? Which command should I use?

Upvotes: 11

Views: 13269

Answers (2)

user4098326
user4098326

Reputation: 1742

In GDB, step means stepping into (will go inside functions called), and next means stepping over (continue and stop at the next line).

But in your particular case, next may not be what you want, and I would suggest to first step into the function printing "execution starting...", then use finish to continue until it returns, so that the program will stop at << endl.

Upvotes: 16

nclaflin
nclaflin

Reputation: 289

If you set a breakpoint, then just use continue to resume execution until that breakpoint. Unless you want to skip those calls altogether, then you would just set $eip or $rip to your breakpoint'ed address like set $[e|r]ip=0x[your_address]

Upvotes: 1

Related Questions