WIN32 Debugging
i''ve posted a long time ago about debugging in win32. i wonder how all you guys do it. I know about the TextOut() method, but i just miss the good ol'' cout and printf. this is the major thing that''s preventing me from porting it to win32.
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
September 19, 2000 12:02 PM
I always use log files, they are easy to use, if you wish you can use the good old fopen() function series!
Logfiles, MessageBox(), using MSVC++ debugger. MessageBox() is good for showing stuff to the user, better than textout because it suspends the whole program waiting for you to click OK.
------------------------------
#pragma twice
------------------------------
#pragma twice
I''ve found that using consoles is a fairly effective way of debugging. I also have a function pointer to the type of log I want to generate (messageBoxes, file, or console) so I can change it later, if I wanted to change the app to fullscreen for example (since consoles only work in windowed applications).
is there a way to open up and output to a console, even with a win32 application? also, i thought about outputting to a log file. i guess you guys really DO do that. isn''t that kinda slow? (but hey, maybe it''s time to think about coding a replay feature....)
but anyway, with the log files, you cannot effectively "check" what you see on the screen with the values in realtime, can you? i guess this is where the message boxes come in?
like, supposing i wanted to test for a distance from a point to a plane in realtime, while i move the point around. i want to be able to see the distance values, and to see when it changes negative and stuff like that...
a2k
but anyway, with the log files, you cannot effectively "check" what you see on the screen with the values in realtime, can you? i guess this is where the message boxes come in?
like, supposing i wanted to test for a distance from a point to a plane in realtime, while i move the point around. i want to be able to see the distance values, and to see when it changes negative and stuff like that...
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
OutputDebugString(char *); outputs to the debugger.
To log a string to a file I created this function:
1) Outputs debug string to debugger
2) Logs error to file
BOOL LogError(char *error, char *filename)
{
FILE *error_file;
char *temp = malloc(strlen(error) * sizeof(char) + sizeof("\n"));
if (!strchr(error, ''\n'')) /* Check for \n at end of error, if no \n add one */
{
strcpy(temp, error);
strcat(temp, "\n");
OutputDebugString(temp);
error = malloc(strlen(temp) * sizeof(char) + 1);
strcpy(error, temp);
}
OutputDebugString(error);
if (!(error_file = fopen(filename, "a")))
{
OutputDebugString("Error opening log file!");
}
fwrite(error, strlen(error), 1, error_file);
fclose(error_file);
return TRUE;
}
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
To log a string to a file I created this function:
1) Outputs debug string to debugger
2) Logs error to file
BOOL LogError(char *error, char *filename)
{
FILE *error_file;
char *temp = malloc(strlen(error) * sizeof(char) + sizeof("\n"));
if (!strchr(error, ''\n'')) /* Check for \n at end of error, if no \n add one */
{
strcpy(temp, error);
strcat(temp, "\n");
OutputDebugString(temp);
error = malloc(strlen(temp) * sizeof(char) + 1);
strcpy(error, temp);
}
OutputDebugString(error);
if (!(error_file = fopen(filename, "a")))
{
OutputDebugString("Error opening log file!");
}
fwrite(error, strlen(error), 1, error_file);
fclose(error_file);
return TRUE;
}
-----------------------------
A wise man once said "A person with half a clue is more dangerous than a person with or without one."
-----------------------------A wise man once said "A person with half a clue is more dangerous than a person with or without one."The Micro$haft BSOD T-Shirt
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement