localizing a crash

Started by
6 comments, last by Evil Steve 15 years, 3 months ago
I've made a small program, game. The game treats input from the mouse. The game works, but, somtimes it just crashes. How do you go about finding the reason for such an event? I'm using Visual Express 2008. but I've tried DevC++ with the same results... It seems to crash only when moving the mouse in a certain way... I mean, I breakpointed around a little, but the game is looping threw the code alot of times before crashing. Thanks.
Advertisement
Well, the debugger should drop you right to the line the crash happens on. (VS2008, set the project to build debug mode, then run with F5)
Tracking down WHY that line is crashing might be a bit harder.
Check and find out exactly what crashes. Then post some code, and maybe we can point you in a direction to finding out the cause of the crash.
Yeah, I've used the debugger, but I've never used it before, so I didn't really know what to expect. It didn't look liked it crashed at all.

I did like: Lazy Foo @ http://lazyfoo.net/articles/article05/index.php

And turns out; the application actually quits, it sets the quit flag to true.

//while there's an event to handlewhile( SDL_PollEvent( &event ) ){    /* some commented out stuff i removed */    //If the user X out the window    if( event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE)    {	log( "Quitting..." );        //quit the program        quit = true;    }}


It quits, just because i'm moving the mouse?

I'm commenting out "event.key.keysym.sym == SDLK_ESCAPE" for now, and it seems to work...

why would it do that?

[Edited by - RawBeen on January 8, 2009 1:17:47 AM]
You probably need to check that the event is actually a key-down (or up) type of event _before_ checking on the actual key.
That is, something along the lines of this: if(event.type == SDL_KEYDOWN && blabla.key == ESCAPE)...

:)
| Stein Nygård - http://steinware.dk |
Thats probably right, wont look in to it rigt now thow...

...so I guess SDL is flayling keypresses around when it thinks your not looking.

maybe its trying to say something, or is trying to communicate to my hardware or something.

maybe I should try

if( event.type != SDL_KEYDOWN )
{
switch( event.key.keysym.sym )
/*write out the silent keystrokes*/
}
Quote:Original post by RawBeen
...so I guess SDL is flayling keypresses around when it thinks your not looking.
}


Eh, no. The SDL_Event is a union-construct.
You're checking the key-id on an event that has (potentially) nothing todo with the keyboard... Not healthy.
| Stein Nygård - http://steinware.dk |
not healthy indeed.

...but secret.
if( event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE)
Should be:
if( event.type == SDL_QUIT || ( event.type == SDL_KEYBOARD && event.key.keysym.sym == SDLK_ESCAPE))
Or whatever the name of the SDL_KEYBOARD event is.

Also, I'd high recommend reading This for details on using Visual Studio's debugger.

This topic is closed to new replies.

Advertisement