11

Is there a way in CLion 2017 to step into project source files only whilst debugging a program?

For example in the code segment below,

function1 (boost::doSomething())

I have a function from an external library (e.g. boost) which I don't want the debugger to go into while I step through the program.

Is there a setting that forces CLion to skip stepping into any code from an external library?

user3079474
  • 1,653
  • 2
  • 24
  • 37
  • 1
    This feature is not implemented yet, please follow for the updates: [CPP-10876 Debugger: Smart Step Into (Step into specific function)](https://youtrack.jetbrains.com/issue/CPP-10876) – Eldar Abusalimov Dec 25 '17 at 09:07

3 Answers3

8

If CLion is using gdb for it's debugger then you can create the file ~/.gdbinit and add the following to ignore all functions in boost:: namespace.

skip -rfu "boost::.*"

As another example, you can also add the following line to skip all the header files in include/bits (like unique_pointer.h).

skip -gfile include/bits/*.h

More info on skip options at Debugging with GDB: Skipping Over Functions and Files and in this useful answer https://stackoverflow.com/a/42985979/255961.

See this link for how to do something similar if CLion is using lldb - How to not step into shared_ptr in xcode.

studgeek
  • 14,272
  • 6
  • 84
  • 96
0

Try:

auto result = boost::doSomething();
function1 (result);
Patrick
  • 141
  • 9
  • This would not skip the first statement while stepping into the code while debugging. – user3079474 Dec 23 '17 at 18:39
  • 1
    @user3079474 If no exceptions are thrown from `doSomething`, you just step over it while debugging. What else makes debugger step into `doSomething` ? – Patrick Dec 23 '17 at 18:47
  • This helps in one specific instance, but is not a general solution. I can't pull out all `std::`, `boost::` etc. calls into their own lines across the entire codebase just to make it easier to step over them. It would be a huge amount of work and decrease readability by blowing up the line count simple algorithms get smeared across. – uliwitness Sep 24 '22 at 09:32
0

As mentioned in the comment above, the feature is not yet implemented.

user3079474
  • 1,653
  • 2
  • 24
  • 37
  • If it helps somebody, method breakpoints may provide an alternative. https://www.jetbrains.com/help/idea/types-of-breakpoints.html#method_breakpoint – user3079474 Jan 08 '18 at 06:19