14

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?

1
  • 1
    The gdb-approach is a bit different. Instead of stepping into a specific function you can define skips. If you input skip g() gdb will execute g() without stepping into it and step into f.
    – Tobias
    Commented Jun 5, 2014 at 5:47

2 Answers 2

17
+50

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.

2
  • 2
    This is the correct answer! skip is designed to solve the exact problem that the question describes. step and finish alternative gets tedious and tiring very soon! I'll add a bounty for this answer so that it gets more attention and saves people some time. Commented Jun 20, 2019 at 18:35
  • 2
    Is there any update to this? skip command is useful but not the solution. If there is a line of code with many overridden operators and whatnot, it's tedious to get to the point you want to be at. Why not directly specify the function you're interested in stepping into?
    – Amir
    Commented Jun 8, 2022 at 13:39
14

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.