Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stepping into Specific Function in GDB

Does GDB support Stepping into a Specific function, say either f or g, on lines containing expressions of nested function calls such as

f(g());

similar to what Visual Studio 2010 support. Maybe a GDB script is the solution?

like image 549
Nordlöw Avatar asked Aug 15 '12 10:08

Nordlöw


People also ask

Can a debugger step over a function?

Step through code and skip some functions The functions still run, but the debugger skips over them. If the current line contains a function call, Step Over runs the code and then suspends execution at the first line of code after the called function returns.

How do I skip a function in GDB?

Functions may be skipped by providing either a function name, linespec (see Specify Location), regular expression that matches the function's name, file name or a glob -style pattern that matches the file name.

Can you step back in GDB?

If the target environment supports it, gdb can allow you to “rewind” the program by running it backward. A target environment that supports reverse execution should be able to “undo” the changes in machine state that have taken place as the program was executing normally.


2 Answers

The command advance from the answer https://stackoverflow.com/a/1133403/2708138 is useful. You can combine that command with print f to get the type of f in the current context beforehand.

Furthermore, I have already mentioned in the comment to your question that you can skip the function g if you never want to step through it.

See the gdb-help for the keywords advance, print and skip.

At least the skip-feature is quite new. So maybe, it was not available at the time when Employed Russian gave his answer.

like image 179
Tobias Avatar answered Jan 19 '23 05:01

Tobias


Does GDB support Stepping into a Specific function

No. If you want to step into g, a simple step should do it. If you want to step into f, do step, finish, step.

You are welcome to file a feature request in GDB bugzilla, though I doubt Step into Specific can be reasonably implemented in a CLI debugger.

like image 40
Employed Russian Avatar answered Jan 19 '23 05:01

Employed Russian