I believe that the most common problem with program debugging is that you don't actually see the people who run your program
.
All you have - only a few words from them, and a logfile.
So the problem is this: to actually know exactly what happened when your program hanged on user with no adequate reason or explanation.
And what I want to discuss here is what you guys do with this problem.
I'm personally using logging, but it's very slow, so you can't just logg every function, at least in a game. I may know that it happened somewhere in a main cycle after the game mode is changed and all stuff properly loaded, and that's it.
Maybe there's something wrong with my logging function, I'm openning and closing log file every time, because I think that if the program hangs, it won't log last messages, so the logging will be useless.
So I'm now trying to implement exceptions handling, which I never did.
I wrote a few macros for them, I didn't have a chace to test them well, and I also probably need an example of proper exceptions filter(I don't know how to print what kind of exception really happened).
Here are my macros:
Any comments on them are welcome.
So, what I do is this: every main cycle routine I envelop with this macros like this:
Looks ugly, but should probably work, I suppose.
The best thing would be a call stack, but this probably is impossible. Memory dump, using which I could determine the call stack would be extremely nice thing, but I have no idea of how to do such thing.
There's also no __FUNCTION__(or just doesn't work?) macro in EVC as far as I see, which is pretty unpleasant.
I believe there are more experienced people on subject of exception handling. What do you say on the topic? Any tricks are welcome
.
All you have - only a few words from them, and a logfile.
So the problem is this: to actually know exactly what happened when your program hanged on user with no adequate reason or explanation.
And what I want to discuss here is what you guys do with this problem.
I'm personally using logging, but it's very slow, so you can't just logg every function, at least in a game. I may know that it happened somewhere in a main cycle after the game mode is changed and all stuff properly loaded, and that's it.
Maybe there's something wrong with my logging function, I'm openning and closing log file every time, because I think that if the program hangs, it won't log last messages, so the logging will be useless.
So I'm now trying to implement exceptions handling, which I never did.
I wrote a few macros for them, I didn't have a chace to test them well, and I also probably need an example of proper exceptions filter(I don't know how to print what kind of exception really happened).
Here are my macros:
- Code:
#ifdef EXCEPTIONS_ENABLE
#define MY_EXCEPT_START \
__try {
#define MY_EXCEPT_END(expr) \
} __except (1) \
{LoggEx(_T("Exception in %s"), expr);}
#else
#define MY_EXCEPT_START
#define MY_EXCEPT_END(expr)
#endif
Any comments on them are welcome.
So, what I do is this: every main cycle routine I envelop with this macros like this:
- Code:
MY_EXCEPT_START
Flyer.Process(dt);
MY_EXCEPT_END(_T("Flyer.Process"));
MY_EXCEPT_START
ProcessMapActiveObjects(dt);
MY_EXCEPT_END(_T("ProcessMapActiveObjects"));
Looks ugly, but should probably work, I suppose.
The best thing would be a call stack, but this probably is impossible. Memory dump, using which I could determine the call stack would be extremely nice thing, but I have no idea of how to do such thing.
There's also no __FUNCTION__(or just doesn't work?) macro in EVC as far as I see, which is pretty unpleasant.
I believe there are more experienced people on subject of exception handling. What do you say on the topic? Any tricks are welcome