Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: sophron on September 16, 2012, 02:20:53 pm

Title: C::B becomes unresponsive, when watching big data structure on debug session
Post by: sophron on September 16, 2012, 02:20:53 pm
It has been an issue since the new debugger branch merged into the C::B code base.  :-\
For example, when debugging a simple OpenCV Application below, C::B freezes after unfolding the "*pImg" data structure and scroll down to the image data portion in the watches window (on Windows XP SP3 EN).

Code
#include <stdio.h>
using namespace std;

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

int main( int argc, char** argv )
{
    IplImage* pImg; //declare image pointer

    //Load the image
    if( argc == 2 && (pImg = cvLoadImage( argv[1], 1)) != 0 )
    {
        cvNamedWindow( "Image", CV_WINDOW_AUTOSIZE );
        cvShowImage( "Image", pImg ); //show the image

        cvWaitKey(0); //pause

        cvDestroyWindow( "Image" );
        cvReleaseImage( &pImg );
        return 0;
    }

    printf("Error: Couldn't open the image file.\n");
    return -1;
}
Title: Re: C::B becomes unresponsive, when watching big data structure on debug session
Post by: ollydbg on September 21, 2012, 04:47:01 am
Quote
C::B freezes after unfolding the "*pImg" data structure
Did you use gdb?
If you does not limit the element of a buffer, the whole data buffer of the pImg will be show which cause the lag.
Try to set the element number by enter the command "set print elements 200" (this means only show the first 200 elements if the buffer is too large) in the debugger's initial command.
Title: Re: C::B becomes unresponsive, when watching big data structure on debug session
Post by: sophron on September 21, 2012, 06:12:24 pm
Yes, the debugger is GDB.
But it is obvious that setting "show print elements 200" may stop the whole elements of a large array from being displayed.
And what is also different from the former debugger plug-in of C::B is that the watches window does not display local variables and "this" pointer automatically when stepping into a certain scope. (other GDB initialization commands needed?)
Anyway, the merging of the new debugger plug-in seems slapdash.
Title: Re: C::B becomes unresponsive, when watching big data structure on debug session
Post by: oBFusCATed on September 21, 2012, 07:52:50 pm
Anyway, the merging of the new debugger plug-in seems slapdash.
I hope you're joking here.
The watches in the old plugin where useless and badly broken. You can go back to 10.05 and play with them, I'm sure you won't like them.
Yes there are locals and function args, but they are broken when showing complex variables and classes.
The backtrace window was broken.
Many other things were broken.

If you want to watch the this pointer put it in the watches. Simple as this.

But it is obvious that setting "show print elements 200" may stop the whole elements of a large array from being displayed.
So, you prefer to see a list with 20000 elements in there?

Title: Re: C::B becomes unresponsive, when watching big data structure on debug session
Post by: MortenMacFly on September 21, 2012, 10:26:12 pm
But it is obvious that setting "show print elements 200" may stop the whole elements of a large array from being displayed.
So, you prefer to see a list with 20000 elements in there?
Harhar... some people make really weird debugging... :-)
Title: Re: C::B becomes unresponsive, when watching big data structure on debug session
Post by: O-san on March 15, 2016, 10:25:15 pm
Sorry to reply to such an old thread but this is an excellent tip. I was getting pretty annoyed when the gdb tried printing a rather large buffer.. this trick saved me a ton of headache :)