Debugging fullscreen on Mac

Hello,

Can anybody give me advice on debugging SDL full screen apps? I’ve got a
game that uses windowed and full screen modes on Mac OS X. I start the game
in windowed mode and switch the game to full screen. I follow the debugger
through to the SDL_SetVideoMode call. When this is called, the switch is
made to full screen, but I only get a black screen with the mouse pointer.
At this point, my Mac crashes and I can’t do anything.

Any help is greatly appreciated.

Thanks,

Ryan

Michael Ryan Bannon wrote:

Can anybody give me advice on debugging SDL full screen apps? I’ve
got a game that uses windowed and full screen modes on Mac OS X. I
start the game in windowed mode and switch the game to full screen.
I follow the debugger through to the SDL_SetVideoMode call. When
this is called, the switch is made to full screen, but I only get a
black screen with the mouse pointer. At this point, my Mac crashes
and I can’t do anything.

Report this to Apple ASAP. You’ve found a local user DOS vulnerability,
maybe worse.

Concerning your original question, I would think any (game) developer
uses a dual-headed machine for such reasons.–
Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060526/e1e7c8bb/attachment.pgp

Hello Michael,

Friday, May 26, 2006, 4:52:52 PM, you wrote:

MRB> Can anybody give me advice on debugging SDL full screen apps? I’ve got a
MRB> game that uses windowed and full screen modes on Mac OS X. I start the game
MRB> in windowed mode and switch the game to full screen. I follow the debugger
MRB> through to the SDL_SetVideoMode call. When this is called, the switch is
MRB> made to full screen, but I only get a black screen with the mouse pointer.
MRB> At this point, my Mac crashes and I can’t do anything.

The best thing to do is get another machine (PC, Mac, anything that
has network connectivity and an SSH client will do) and log into your
Mac through SSH. Then start the program over SSH. You can then either
use GDB or printf() debugging, which will appear on your SSH terminal.

This is how I debug all my Mac ports.–
Best regards,
Peter mailto:@Peter_Mulholland

Christian Biere wrote:

Concerning your original question, I would think any (game) developer
uses a dual-headed machine for such reasons.

Or, of course, just a second machine with a remote terminal e.g., ssh.–
Christian
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060526/5ad04dd6/attachment.pgp

Hello Christian,

Friday, May 26, 2006, 5:03:52 PM, you wrote:

CB> Michael Ryan Bannon wrote:

Can anybody give me advice on debugging SDL full screen apps? I’ve
got a game that uses windowed and full screen modes on Mac OS X. I
start the game in windowed mode and switch the game to full screen.
I follow the debugger through to the SDL_SetVideoMode call. When
this is called, the switch is made to full screen, but I only get a
black screen with the mouse pointer. At this point, my Mac crashes
and I can’t do anything.

CB> Report this to Apple ASAP. You’ve found a local user DOS vulnerability,
CB> maybe worse.

Actually, you just made me think about it. Unless he’s running it
through a debugger, the crash should return the display to normal and
then pop up a crash dialog. I’d assume he is either going into an
infinite loop, or he’s running it through a debugger.–
Best regards,
Peter mailto:@Peter_Mulholland

I am running it through a debugger. As for another machine or another
screen, can’t be done on my budget. I’ll give SSH a try though.

Thanks,

Ryan

“Peter Mulholland” wrote in message
news:1206327753.20060526170424 at freeuk.com…> Hello Michael,

Friday, May 26, 2006, 4:52:52 PM, you wrote:

MRB> Can anybody give me advice on debugging SDL full screen apps? I’ve
got a
MRB> game that uses windowed and full screen modes on Mac OS X. I start
the game
MRB> in windowed mode and switch the game to full screen. I follow the
debugger
MRB> through to the SDL_SetVideoMode call. When this is called, the
switch is
MRB> made to full screen, but I only get a black screen with the mouse
pointer.
MRB> At this point, my Mac crashes and I can’t do anything.

The best thing to do is get another machine (PC, Mac, anything that
has network connectivity and an SSH client will do) and log into your
Mac through SSH. Then start the program over SSH. You can then either
use GDB or printf() debugging, which will appear on your SSH terminal.

This is how I debug all my Mac ports.


Best regards,
Peter mailto:darkmatter at freeuk.com

Hello Michael,

Friday, May 26, 2006, 6:03:03 PM, you wrote:

MRB> I am running it through a debugger. As for another machine or another
MRB> screen, can’t be done on my budget. I’ll give SSH a try though.

No point if you cant do it remotely. The idea is you end up with an
output on another screen to the one that’s displaying your game.

I would say you are best printing messages to a log file as an
indicator of how far your game is getting, and NOT running through the
debugger. That way, your game will crash, MacOS will close your
display down and tell you, and then you can read the log file to see
where you got to.–
Best regards,
Peter mailto:@Peter_Mulholland

I use mingw/msys on windows and use notepad as my ide so I have TONS of
experience debugging without a debugger.

Do you know how I do it? Log files! :stuck_out_tongue:

When my program starts up I have it clear the log file, and then in places
where I need to know what’s going wrong, I make it output the values of
variables to the log file, or I just have it output text and debug that way.

Let’s say your program crashes and you’re trying to find out where it
crashes. What I do is in my main loop I put a couple log statements in
there like one at the top of the loop, one at the bottom of the loop and a
couple in the middle, then I run the program and make it crash.

When I look in the log file, I’ll know where it crashed because I’ll know
it’s somewhere between where it outputs the message that’s the last message
in the log file and the next message.

Then, I refine my search by putting more log outputs between those 2
statements, or by going into the function calls and putting log output in
there.

Continue until you find the statement that causes the crash, then start
outputting the values of variables at different points in the code to find
what’s going wrong and why.

It works really well for me, and should work well for you too (:

These are 2 functions that should help you a lot:

#include <stdarg.h>

void ClearLog(void)
{
FILE *File;

if(File=fopen(“log.txt”,“wt”))
fclose(File);
else
printf(“Could not open log.txt for writing”);
}

void Log(char *Message,…)
{

FILE *File;
va_list Params;

if(File=fopen(“log.txt”,“at”))
{
va_start(Params,Message);
vfprintf(File,Message,Params);
va_end(Params);
fclose(File);
}
else
printf(“Could not open log.txt for append\n”);

va_start(Params,Message);
vprintf(Message,Params);
va_end(Params);

}

The good thing about the above log function is that it works exactly like
printf, so that means you can do things like this:

Printf(“Playercount is %i and server name is
%s\n”,PlayerCount,GameInfo.ServerName);

And it will output the text and the values of the variables to the log file.

Also you’ll notice the file is opened and closed with every Log() call.
This is because when a program crashes sometimes it doesn’t flush the file
buffers so you can lose parts of your logfile that you’ve written if you
don’t close after every entry which can lead to some confusing debugging!

Hope this helps!
Aln> ----- Original Message -----

From: sdl-bounces+atrix2=cox.net@libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of Michael Ryan
Bannon
Sent: Friday, May 26, 2006 8:53 AM
To: sdl at libsdl.org
Subject: [SDL] Debugging fullscreen on Mac

Hello,

Can anybody give me advice on debugging SDL full screen apps? I’ve got a
game that uses windowed and full screen modes on Mac OS X. I start the game

in windowed mode and switch the game to full screen. I follow the debugger
through to the SDL_SetVideoMode call. When this is called, the switch is
made to full screen, but I only get a black screen with the mouse pointer.
At this point, my Mac crashes and I can’t do anything.

Any help is greatly appreciated.

Thanks,

Ryan


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Printf(“Playercount is %i and server name is
%s\n”,PlayerCount,GameInfo.ServerName);

Sorry for the confusion, that should be:

Log(“Playercount is %i and server name is
%s\n”,PlayerCount,GameInfo.ServerName);> ----- Original Message -----

From: sdl-bounces+atrix2=cox.net@libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of Alan Wolfe
Sent: Friday, May 26, 2006 10:15 AM
To: 'A list for developers using the SDL library. (includesSDL-announce)'
Subject: Re: [SDL] Debugging fullscreen on Mac

I use mingw/msys on windows and use notepad as my ide so I have TONS of
experience debugging without a debugger.

Do you know how I do it? Log files! :stuck_out_tongue:

When my program starts up I have it clear the log file, and then in places
where I need to know what’s going wrong, I make it output the values of
variables to the log file, or I just have it output text and debug that way.

Let’s say your program crashes and you’re trying to find out where it
crashes. What I do is in my main loop I put a couple log statements in
there like one at the top of the loop, one at the bottom of the loop and a
couple in the middle, then I run the program and make it crash.

When I look in the log file, I’ll know where it crashed because I’ll know
it’s somewhere between where it outputs the message that’s the last message
in the log file and the next message.

Then, I refine my search by putting more log outputs between those 2
statements, or by going into the function calls and putting log output in
there.

Continue until you find the statement that causes the crash, then start
outputting the values of variables at different points in the code to find
what’s going wrong and why.

It works really well for me, and should work well for you too (:

These are 2 functions that should help you a lot:

#include <stdarg.h>

void ClearLog(void)
{
FILE *File;

if(File=fopen(“log.txt”,“wt”))
fclose(File);
else
printf(“Could not open log.txt for writing”);
}

void Log(char *Message,…)
{

FILE *File;
va_list Params;

if(File=fopen(“log.txt”,“at”))
{
va_start(Params,Message);
vfprintf(File,Message,Params);
va_end(Params);
fclose(File);
}
else
printf(“Could not open log.txt for append\n”);

va_start(Params,Message);
vprintf(Message,Params);
va_end(Params);

}

The good thing about the above log function is that it works exactly like
printf, so that means you can do things like this:

Printf(“Playercount is %i and server name is
%s\n”,PlayerCount,GameInfo.ServerName);

And it will output the text and the values of the variables to the log file.

Also you’ll notice the file is opened and closed with every Log() call.
This is because when a program crashes sometimes it doesn’t flush the file
buffers so you can lose parts of your logfile that you’ve written if you
don’t close after every entry which can lead to some confusing debugging!

Hope this helps!
Aln

-----Original Message-----
From: sdl-bounces+atrix2=cox.net@libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of Michael Ryan
Bannon
Sent: Friday, May 26, 2006 8:53 AM
To: sdl at libsdl.org
Subject: [SDL] Debugging fullscreen on Mac

Hello,

Can anybody give me advice on debugging SDL full screen apps? I’ve got a
game that uses windowed and full screen modes on Mac OS X. I start the game

in windowed mode and switch the game to full screen. I follow the debugger
through to the SDL_SetVideoMode call. When this is called, the switch is
made to full screen, but I only get a black screen with the mouse pointer.
At this point, my Mac crashes and I can’t do anything.

Any help is greatly appreciated.

Thanks,

Ryan


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Regarding the log files…thanks for the help. I actually am using log
files and I know where my app crashes. It occurs at SDL_SetVideoMode call.
That’s why I asked for help on the SDL forum :slight_smile:

Maybe a better question for me to ask would be, “How do I get error info
from a failed SDL call?”

Thanks,

Ryan

“Michael Ryan Bannon” <ryan.bannon at humagade.com> wrote in message
news:e5788l$apb$1 at sea.gmane.org…> Hello,

Can anybody give me advice on debugging SDL full screen apps? I’ve got a
game that uses windowed and full screen modes on Mac OS X. I start the
game in windowed mode and switch the game to full screen. I follow the
debugger through to the SDL_SetVideoMode call. When this is called, the
switch is made to full screen, but I only get a black screen with the
mouse pointer. At this point, my Mac crashes and I can’t do anything.

Any help is greatly appreciated.

Thanks,

Ryan

Sorry, when I meant another machine, I meant I don’t have another Mac…I’m
logging in through Windows though…that’s what I’m trying. Sorry for the
confusion.

“Peter Mulholland” wrote in message
news:1314194239.20060526180617 at freeuk.com…> Hello Michael,

Friday, May 26, 2006, 6:03:03 PM, you wrote:

MRB> I am running it through a debugger. As for another machine or
another
MRB> screen, can’t be done on my budget. I’ll give SSH a try though.

No point if you cant do it remotely. The idea is you end up with an
output on another screen to the one that’s displaying your game.

I would say you are best printing messages to a log file as an
indicator of how far your game is getting, and NOT running through the
debugger. That way, your game will crash, MacOS will close your
display down and tell you, and then you can read the log file to see
where you got to.


Best regards,
Peter mailto:darkmatter at freeuk.com

Hello again,

To answer my own question, use SDL_GetError(). :slight_smile:
Also, I fixed my bug. If anybody was interested, SDL_FWSURFACE was not used
while double buffering was turned on. According to the docs, this doesn’t
work…and the docs were right :slight_smile:

http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fSetVideoMode

Regarding SDL_DOUBLEBUF, maybe it should be automatically disabled if
SDL_HWSURFACE isn’t used? Just a thought.

Thanks,

Ryan

“Michael Ryan Bannon” <ryan.bannon at humagade.com> wrote in message
news:e5788l$apb$1 at sea.gmane.org…> Hello,

Can anybody give me advice on debugging SDL full screen apps? I’ve got a
game that uses windowed and full screen modes on Mac OS X. I start the
game in windowed mode and switch the game to full screen. I follow the
debugger through to the SDL_SetVideoMode call. When this is called, the
switch is made to full screen, but I only get a black screen with the
mouse pointer. At this point, my Mac crashes and I can’t do anything.

Any help is greatly appreciated.

Thanks,

Ryan