GDB Debugger hangs with SDL with MinGW, Netbeans, Windows 7

I’m using Netbeans 6.8, MinGW 5 point something (pretty new one), and GDB 7 point something. By themselves they work very well. However when I’m writing a program with SDL, the debugger seems to hang at initialization. I don’t even have to call any SDL functions, just including the headers causes the debugger to hang.

The code below, when uncommented, should make a 640x480 opengl window and then just wait for you to close it. When I run normally (Run Main Project, F6), it works fine. It does exactly what it should. When I run with a debugger (Debug Main Project, Ctrl+F5), the program hangs before anything happens. Even when I don’t call any SDL functions. Just including the headers breaks the debugger.

Code:
#include
#include

//if I don’t include SDL header, debugger runs normally
#include <SDL/SDL.h>
#include <SDL/SDL_opengl.h>
//if I do, program hangs when run with debugger
//but runs ok if I run normally, without debugger

using namespace std;
//SDL_Surface* screen;

int main(int argc, char** argv) {
cout << “INITING” << endl;
//SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE);
//SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//screen=SDL_SetVideoMode(640,480,32,SDL_OPENGL|SDL_RESIZABLE);
//SDL_Event event;
/while(SDL_WaitEvent(&event)){
if(event.type==SDL_QUIT)
break;
}
/
//SDL_Quit();
system(“PAUSE”);
return 0;
}

Nobody else has this issue? Is there a way to fix this?

Please help!

Would it be possible to receive a response to this question before spring break begins? I’d really appreciate that. Thank you.

I don’t think you’ll receive an answer about GDB/MinGW/Netbeans/Windows7
problems here.

Are you able to debug some other app that doesn’t link to SDL?

Cheers,

AndreOn 10/03/2010 23:03, Zcool31 wrote:

Would it be possible to receive a response to this question before
spring break begins? I’d really appreciate that. Thank you.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Sorry, this is the only place I had left to ask. The Netbeans forums can’t really help me because its MinGW/Windows 7 related. The MinGW forums can’t help me because It’s SDL related. And the SDL forums can’t help me because it’s MinGW related.

It worked perfectly fine by itself, with pdcurses, and Allegro. Only when I include SDL headers does it crash. Is it something I’m doing?

Sorry, this is the only place I had left to ask. The Netbeans forums
can’t really help me because its MinGW/Windows 7 related. The MinGW
forums can’t help me because It’s SDL related. And the SDL forums
can’t help me because it’s MinGW related.
Yeah, I know how it feels.

It worked perfectly fine by itself, with pdcurses, and Allegro. Only
when I include SDL headers does it crash. Is it something I’m doing?
I’d try a couple of things to help identify where the problem is:

  1. Can you run the program in Netbeans without debugging it?
  2. Can you debug it from the command line? Type “gdb program.exe” to
    start the debugger and then enter “run” to run it.On 13/03/2010 16:25, Zcool31 wrote:

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks for your replies, Andre. I really appreciate the help.

Something really weird happened. Like I said before, the app runs fine when not being debugged, but hangs when I debug from the Netbeans IDE. So I tried doing it through command line like you said, and it worked flawlessly. Gdb was running in the command prompt, and my app in it’s own window. Did exactly what it should have, then quit successfully like it should have. I’m guessing this means there’s a problem with how Netbeans uses GDB. Any suggestions on where I can find info about this?

Once again, thanks for the help.

I’d ask for help at Netbeans forums since gdb appears to be working.

I usually use Code::Blocks to develop SDL applications. Debugging works
just fine there.

Cheers,

AndreOn 14/03/2010 02:39, Zcool31 wrote:

Thanks for your replies, Andre. I really appreciate the help.

Something really weird happened. Like I said before, the app runs fine
when not being debugged, but hangs when I debug from the Netbeans IDE.
So I tried doing it through command line like you said, and it worked
flawlessly. Gdb was running in the command prompt, and my app in it’s
own window. Did exactly what it should have, then quit successfully
like it should have. I’m guessing this means there’s a problem with
how Netbeans uses GDB. Any suggestions on where I can find info about
this?

Once again, thanks for the help.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

ahem

Which compiler is that?

You haven’t told us anything about what builds of various software you are
using. One common pitfall I have experienced developing software on Windows
is that there can be problems trying to use different compilers or tools
written for binaries generated by different compilers. If you haven’t built
your libraries yourself, you’re just in for trouble. It can be a lot of work
to get up and running, but start building your own libraries now, and save
yourself these kinds of headaches in the future.

Generally it’s been my experience that problems stem from trying to link
binaries together that have been linked to different C and/or C++ runtimes.

You could run your program within gdb within gdb (sic) and see if you can
see where it’s hanging. You’ll need a gdb build with debugging info compiled
in if you want to get anywhere.

Also it’s a little vague to me whether the “#include <SDL.h>” is triggering
your problem, or if it is actually using SDL APIs that is the problem.
Knowing your compiler would help. If it’s only the header and without using
any APIs, then with a nice compiler like gcc the only thing that should be
changed is that SDL may #define main out of the way so that it can link in
its own main routine. Try “#undef main” after “#include <SDL.h>” if you want
to try a little experiment and see if that makes a difference to how it
blows up.

Good luck :)On Wed, Mar 3, 2010 at 6:35 PM, Zcool31 <dr_z0idb3rg at hotmail.com> wrote:

I’m using Netbeans 6.8, MinGW 5 point something (pretty new one), and GDB
7 point something. By themselves they work very well. However when I’m
writing a program with SDL, the debugger seems to hang at initialization. I
don’t even have to call any SDL functions, just including the headers causes
the debugger to hang.

The code below, when uncommented, should make a 640x480 opengl window and
then just wait for you to close it. When I run normally (Run Main Project,
F6), it works fine. It does exactly what it should. When I run with a
debugger (Debug Main Project, Ctrl+F5), the program hangs before anything
happens. Even when I don’t call any SDL functions. Just including the
headers breaks the debugger.

Code:

#include
#include

//if I don’t include SDL header, debugger runs normally
#include
#include
//if I do, program hangs when run with debugger
//but runs ok if I run normally, without debugger

using namespace std;
//SDL_Surface* screen;

int main(int argc, char** argv) {
cout << “INITING” << endl;
//SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE);
//SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//screen=SDL_SetVideoMode(640,480,32,SDL_OPENGL|SDL_RESIZABLE);
//SDL_Event event;
/while(SDL_WaitEvent(&event)){
if(event.type==SDL_QUIT)
break;
}
/
//SDL_Quit();
system(“PAUSE”);
return 0;
}

Nobody else has this issue? Is there a way to fix this?

Please help!


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/

Donny Viszneki wrote:

Try “#undef main” after “#include <SDL.h>” if you want to try a little experiment and see if that makes a difference to how it blows up.

You, sir, have just solved me about a month’s worth of headaches. Now it runs beautifully. And in addition, it fixed a small problem I was having. Before, when including SDL, output through cout or printf wouldn’t show up in the command prompt, but now they do. And of course I’m able to run and debug without any problems whatsoever.

I was pretty sure this wasn’t a problem with my tools. I’ve written SDL code before (after jumping through a number of hoops to get it to link properly), and I’ve been using MinGW (installed using the automatic installation tool, set to current version) and GDB (7.0.1) for a good while.

In any case, I sincerely thank you from the bottom of my source code for helping me solve this problem. Now I can get to writing my code and being able to properly debug it.

Thank you sir!