0

I'm debugging a C++ program in gdb and stepping through the code. At various points the debugger will start stepping through the code in libraries/included files which is very tedious and not helpful for me. Is there anyway to suppress or 'jump' out of this information. I'm only concerned of following the trace as pertains to the current .cpp file.

Lore
  • 3
  • 1
  • 1
    Possible duplicate of [Step out of current function with gdb](https://stackoverflow.com/questions/24712690/step-out-of-current-function-with-gdb) and also https://stackoverflow.com/questions/43004019/gdb-step-over-command – Richard Critten Feb 03 '18 at 13:15
  • 1
    When stepping through code there are two modes: Stepping *over* function calls, or stepping *into* calls. Stepping into calls is very useful, but isn't needed quite as often as stepping *over*. You should probably step *over* function calls. Read the help for the `next` and `step` GDB commands, they do different things. – Some programmer dude Feb 03 '18 at 13:18

1 Answers1

2

At various points the debugger will start stepping through the code in libraries/included files which is very tedious and not helpful for me.

You are probably trying to step through code that looks something like this:

std::vector<int> v = ...

foo(v[i]);  // Want to step into foo, but step will get into
            // std::vector::operator[](size_t) instead.

The need to step over uninteresting "accessor" functions has been recognized long time ago (bug) but nobody implemented this in GDB yet.

Your best bet is to use the finish command when you find yourself in uninteresting function, and step again.

You can also ask GDB to ignore certain functions while stepping with the skip command. Documentation.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • that's exactly what my code looks like. thank you, you should get awarded extra points for using your psychic powers. – Lore Feb 04 '18 at 05:11