Author Topic: Debugger Help-stepping through a program without going into other files.  (Read 7374 times)

Offline verthex

  • Multiple posting newcomer
  • *
  • Posts: 15
I just upgraded to a newer version of codeblocks (from 8.x to 10.x) and I noticed that the debugger steps into files related to my project and it includes stl files like list and vectors which I dont really care about stepping through. Is there a way to make the debugger stick to the main file only without having to step into every single std::cout and std::endl?


Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Hm, are you sure that the problem is in C::B?
Because the real debugger is GDB, C::B is just the wrapper (it starts gdb and issues commands to it, then parses the output).
And as far as I know there is no way to black list functions for the step into command in GDB.

If you explain the problem a bit more clearly, we might help you...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline verthex

  • Multiple posting newcomer
  • *
  • Posts: 15
This is an example program:

Code
#include <iostream>
#include <vector>

int main()
{
std::vector <int> value;

value.push_back(0);

std::cout<<value[0]<<std::endl;

return 0;
}

Basically I set the breakpoint at the line before I use,
Code
value.push_back(0);

and I start the debugger and I step through the program using only F7 and I end up stepping into these 4 files.

stl_vector.h
basic_ios.h
locale_facets.h
new_allocator.h

Is there some way to prevent this from happening? I used to be able to debug without seeing those steps in the version 8.x of codeblocks.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
This can happen, if you use "Step into" instead of "Next line".
The cause why it did not happen in 8.02 is most likely, that older gdb's have not been able to step into constructors, but newer can.

Offline verthex

  • Multiple posting newcomer
  • *
  • Posts: 15
So basically there is no way to turn it off?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
So basically there is no way to turn it off?
This can happen, if you use "Step into" instead of "Next line".

If you really do that, this is the expected behaviour.
"Step into" means step into the function you call (if possible) and a constructor is a function (obviously), the same would happen for all function with a "reachable" implemantation (e.g. most likely inline-functions).
So you should use "Next line" in most cases (if you don't want to debug the called functions).

And as oBFusCATed wrote:
And as far as I know there is no way to black list functions for the step into command in GDB.

Offline verthex

  • Multiple posting newcomer
  • *
  • Posts: 15
Quote
So you should use "Next line" in most cases (if you don't want to debug the called functions).

By pressing F7 which is what I explained above and that's the problem I'm having.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Quote
So you should use "Next line" in most cases (if you don't want to debug the called functions).

By pressing F7 which is what I explained above and that's the problem I'm having.
In you menu->Debug
F7 is assigned to "Next Line" or "Step into"?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline verthex

  • Multiple posting newcomer
  • *
  • Posts: 15
Quote
In you menu->Debug
F7 is assigned to "Next Line" or "Step into"?

F7 - Next Line.
Shift-F7 Step into.

My gdb version is 6.8.
« Last Edit: July 15, 2011, 08:26:22 am by verthex »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Quote
In you menu->Debug
F7 is assigned to "Next Line" or "Step into"?

F7 - Next Line.
Shift-F7 Step into.

My gdb version is 6.8.
Your code works fine on my PC (mingw 4,5, gdb 7.2)

I guess mostly your gcc or gdb has some problem, so, you should try a recent ones.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline verthex

  • Multiple posting newcomer
  • *
  • Posts: 15
Well I downloaded the most recent codeblocks for XP (may 27, 2010) here:
http://www.codeblocks.org/downloads/26

How would I upgrade to gdb 7.2?

zabzonk

  • Guest
Upgrade both your compiler and debugger at http://tdm-gcc.tdragon.net - the current gdb there is 7.1.

Offline verthex

  • Multiple posting newcomer
  • *
  • Posts: 15
Quote
Upgrade both your compiler and debugger at http://tdm-gcc.tdragon.net - the current gdb there is 7.1.

Thanks for the help but I did it differently. I downloaded gdb 7.2 from here http://ftp.gnu.org/gnu/gdb/
opened it into the C:\gdb-7.2 directory and used cygwin to compile it by using
./configure
make

and then I just went into the c:\gdb-7.2\gdb directory and used the gdb.exe file from there and replaced the gdb.exe in the mingw/bin folder.

It took forever to compile gdb though but it works now!  :D