Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: mirai on September 09, 2011, 06:08:20 pm

Title: Forbid debugger from entering certain sources
Post by: mirai on September 09, 2011, 06:08:20 pm
Is it possible to tell CB debugger to skip certain source files or functions when executing "step into" command ?
Expected behavior would be stopping at first allowed file or line after exiting places excluded from debugging.

The problem is that when executing "step into" command, debugger follows very exact execution path as it should do as a good and honest debugger, but sometime this peculiarity becomes too irritating.

In the following example
Code
// source#1: a.h, a.cpp
class A
{
 // class internals
 A();
 ~A();
};

// source #2: bar.h, bar.cpp
A bar(A& b)
{
 A c;
 // do something to b & c ..
 return c;
}

// source #3: foo.h, foo.cpp
void foo(void)
{
 A a;
 bar(a);
}
when stepping inside bar(a) the debugger will end up in the constructor of class A, but not in the bar() function.

This situation occurs very often and results in long and accurate stepping inside code that should not be debugged at all just to get to a desired location.
An ability to explicitly mark places in source code (units, functions) where debugger should not stop would be very useful.
Title: Re: Forbid debugger from entering certain sources
Post by: oBFusCATed on September 09, 2011, 07:09:10 pm
No, ask the GDB devs to implement this and then we will integrate it in C::B :)
Until then it is not possible.

Probably you can check what can be done with python scripting and if you find something useful share it with us :)
Title: Re: Forbid debugger from entering certain sources
Post by: tigerbeard on October 17, 2021, 11:57:21 am
I know its an old post, but I keep finding it when searching this issue. This info is from https://forums.codeblocks.org/index.php/topic,24175.msg164871.html#msg164871 (https://forums.codeblocks.org/index.php/topic,24175.msg164871.html#msg164871)

There is a function in gdb to do this, the "skip" function
link https://sourceware.org/gdb/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html (https://sourceware.org/gdb/onlinedocs/gdb/Skipping-Over-Functions-and-Files.html)
Example for the gdb command line
 
Code
skip file baseclass.cpp       #this will skip all functions that have implementations in this file. 

The command defines functions that will be ignored by "step into". There are other ways beside the filename, including regex expressions.
The manual mentions it could be used like break points which I think sounds quite useful.

Currently CB does not seem to support this. To use it  either enter at the debugger command line (temporary use) or add to the  startup command section in the Debugger Settings Dialog.

Example for wxString
Adding this line as startup command in the Settings/Debugger for gdb will step over any wxString constructors and destructors in functions calls.
Code
 skip file string.h