Skip to main content
GameDev.net gamedev.net
🔒 Locked

Debugging...

Started by soehrimnir Oct 25, 2000 at 2:36 AM 11 replies 400+ views
Original Post
soehrimnir
soehrimnir
I was wondering if anyone here creates a debug file, when they create a game. I just made my first game and while programming it, I realized I had to create a debug file, because it is hard to debug a fullscreen game with the debugger itself. I have two questions now: - Is this debugging information still usefull, when the game is finished? I think it's an important question, because this debugging takes up a lot of disk space. Without the debugging stuff my game is 104kb and with debug info it is 174kb. - And second, how is your debug file setup? Now, I'm just writing some text with an indentation. Something like this:
  Starting Game
    General Information
      Date: 24/10/00
      Time: 21:39:48
      Name of debug file: D:\Mijn documenten\Bricks\debug.log
      Windows Version: 4.10. A
      Processor type: Intel Pentium or higher
      Keyboard language: English (United States)

  Sub Main()
    Initializing Procedure
      Initializing DirectSound
        Setting soundbuffer: CTRLFREQUENCY, CTRLPAN, CTRLVOLUME, STATIC
        Setting wave format: PCM
        Setting number of channels: 2
        Setting sound frequency: 22050
        Setting bits per sample: 16
      Initializing DirectDraw
...
  
In my program I just call this method: WriteLog("Initializing DirectSound", 3). Is this a good technique? Edited by - soehrimnir on 10/25/00 2:47:06 AM
Quantum
Quantum
you might want to do something like

#define LOG(text,num) (#ifdef DEBUG WriteLog(text, num) #endif)

i think that will work to only log when you compile in debug mode

as for debug file setup, i use variable arguments
so i can do something like this:

WriteLog("Error: something failed, returned %d", ReturnVal);
if you want this and aren''t sure how to do it, let me know
soehrimnir
soehrimnir
This game is made in VB, so I can''t use precompiler commands and macro functions.

And for the function you''re using, looks interesting. What you''re trying to show is a method that has the functionality of the printf function in C, am I right? If so, no, I don''t know how to implement this and yes, I would like to know .

btw, do you only log error messages? As you can see in my example, it logs some general information, too. I also log the game events that happen (like: went game_over, starting new game, new high score is reached, ...). I think this is all unnecessary information.
Quantum
Quantum
after i went and wrote that message i looked back and realised you probably were using VB - Sub Main()

well instead of using preprocessor defines, you could always just make a global variable debug, and then check if its on before printing debug info
what i do, is print debug info in debug, and only print errors in release

as for variable arguments, im not sure if its even possible in VB
Tornado
Tornado
I also use a debug file, but I don't write alot of info in it, usually stuff I need to know
There's no "good" technique-"bad technique It's just a debug file
I usually use it when I need tomake sure an if statement is performed or something similar.
There are another 100000 ways to do it (ASSERTs, Message boxes etc.) but I'm just used to a debug file
I think writing information from the actual game is useless, maybe it's good for trying out a new feature, but not for debugging/profiling because it can take down the FPS.
I also use variable arguments, here's the code:

        

char opbuffer[256];
va_list arg_list;

int Write_Debug(char *text,...)
{
va_start(arg_list,text);
vsprintf(opbuffer,text,arg_list);
va_end(arg_list);
if (output)
{
output << opbuffer << endl;
output << flush;
}
return(1);
}



Very handy when your debugging.

EDIT: Oops, forgot you were using VB, I don't know how to use variable arguments in VB

- Goblineye Entertainment
The road to success is always under construction

Edited by - Tornado on October 25, 2000 7:25:38 AM
Goblineye EntertainmentThe road to success is always under construction
MadKeithV
MadKeithV
I know this is off-topic, but I must say, I''m pleasantly surprised. That log-file sample looks nice, and I wasn''t expecting you to have used VB! People are using the tools that they are comfortable with to produce great things. Power to you, I know nothing about VB


People might not remember what you said, or what you did, but they will always remember how you made them feel.
~ (V)^|) |<é!t|-| ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
soehrimnir
soehrimnir
Hello, again,


quote:

Quantum

what i do, is print debug info in debug, and only print errors in release



To bad, but you can''t do that in VB. You can only compile to the release version. There isn''t anything like a debug version.


quote:

Tornado

EDIT: Oops, forgot you were using VB, I don''t know how to use variable arguments in VB



I know it''s possible to use variable arguments in VB, but I don''t know how. I could look it up in the MSDN, but I''m at work now and we are working with Linux here.
But don''t mind, I know C, too (a little). Thanks for the source. However, there are some things that I don''t understand.
What is a va_list data type and what do the functions va_start, va_end and vsprintf do. And what is the ''output'' variable used for?
The return statement is clear, though .


quote:

MadKeithV

That log-file sample looks nice, and I wasn''t expecting you to have used VB!



And what made you think I wasn''t?
MadKeithV
MadKeithV
I guess my experience as a professional programmer has made me pretty blind to a language other than C++ - I wasn''t expecting anyone to make a full-blown, well-thought-out piece of software in a language like Visual Basic..


People might not remember what you said, or what you did, but they will always remember how you made them feel.
~ (V)^|) |<é!t|-| ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Jaxks
Jaxks
va_list is c++ struct used to save somekind of data.
va_start initializes va_list.
va_start(arg_list,text);
here arg list is va_list and text pointer to start.
Then he writes with vsprintf text in va_list to buffer.
If buffer includes data he writes it to file.

Power of va_list is that you can use macro va_arg after list is initialized with va_arg to retrieve current data,same time macro va_arg moves pointer to next argument.

After all is done you set the pointer to null using va_end.

Output is C++ file stream and operator << is overloaded so that it writes text to file.
soehrimnir
soehrimnir
Well, MadKeithV, thanks for the compliments. I believe such techniques (like debugging) should be used everywhere, no matter what language you''re using.
I started this thread because I wondered if debugging is an important thing in games. Like in UT: they also log everything. How else can they generate their NgLocalStats. (With NgLocalStats you can see how many frags you have made, how many kills with a specific weapon, how many suicides, .... You can let UT generate a HTML overview of all your games you''ve played).
And if you use debugging, how to do it. Do you write to a simple text file, or do you use a more ingenious XML like framework.
Anyway, I think my technique is satisfactory for now. It''s a simple Tetris clone, so...


Oh yeah, Jaxks, the output stream is something like cout and cin then. How can I tell ''output'' to which file to write to?
MadKeithV
MadKeithV
Well, since I''ve never had the (mis)fortune of working on a fullscreen-only application, and I''m a Visual C++ 6.0 only user, I get away without logging so far. I make copious use of TRACE and ASSERT ( which are debugger utilities, TRACE outputs a formatted string into the debug window, while ASSERT stops execution and breaks to the offending line of code if a condition is not met ).

Logging with XML would be nice, but I imagine you''d have to do a lot of tool-writing to read the info you''ve just written out! HTML is a good compromise, I''ve used that on occasion.


People might not remember what you said, or what you did, but they will always remember how you made them feel.
~ (V)^|) |<é!t|-| ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Tornado
Tornado
Oops, Sorry soehrimnir, Forgot to mention ''output'' is of type ''ofstream'' (A C++ File Stream, As Jaxks said)



- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
dennis428
dennis428
I wrote a cool function for debugging DirectX once. Go ahead and take a look:
http://members.nbci.com/dennis428/default.htm

Dennis
visit my site, please:members.nbci.com/dennis428/default.htm

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.