News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Debugger Help-stepping through a program without going into other files.

Started by verthex, July 14, 2011, 05:49:54 PM

Previous topic - Next topic

verthex

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?


oBFusCATed

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!]

verthex

This is an example program:

#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,
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.

Jenna

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.

verthex


Jenna

Quote from: verthex on July 15, 2011, 01:46:02 AM
So basically there is no way to turn it off?
Quote from: jens on July 14, 2011, 07:37:20 PM
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:
Quote from: oBFusCATed on July 14, 2011, 06:11:07 PM
And as far as I know there is no way to black list functions for the step into command in GDB.

verthex

QuoteSo 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.

ollydbg

Quote from: verthex on July 15, 2011, 08:05:24 AM
QuoteSo 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.

verthex

QuoteIn 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.

ollydbg

Quote from: verthex on July 15, 2011, 08:22:54 AM
QuoteIn 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.

verthex

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


verthex

QuoteUpgrade 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