简体   繁体   中英

How can we step over a function call in GDB?

I want to understand how we can do stepping over a function call. For instance, in the following simplest 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;
 }

Ok, I set a breakpoint at the 11th line by the break 11 command. Now I want to step over all instructions which are going to be invoked to printing "execution starting..." and stop at the operator << call to printing the endl symbol. How can I do that? Which command should I use?

In GDB, step means stepping in (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 first step into the function printing "execution starting...", then use finish to continue until it returns, so that the program will stop at <<endl .

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM