Does anyone have any suggestions or tutorials for creating crash reports on a program? I want to start sending out a game I have been developing to people, but if the game crashes through error handling, I want to see those reports to an email address that I have registered (along with data collected from the program). Does anyone know how to do this?
-
3You've not accepted many answers so far. What makes me think I'll be able to satisfy you this time? – David Heffernan Feb 17 '11 at 00:00
-
2My ittybitty effort: search "SetUnhandledExceptionFilter". Well covered at SO. – Hans Passant Feb 17 '11 at 00:13
-
1David Heffernan, many of the reponses are not on topic and deviate from what I am asking. – jack Feb 17 '11 at 00:29
-
See also http://stackoverflow.com/questions/1547211/how-to-create-minidump-for-my-process-when-it-crashes, http://stackoverflow.com/questions/5028781/c-how-to-write-a-sample-code-that-will-crash-and-produce-dump-file or http://stackoverflow.com/questions/132116/heisenbug-winapi-program-crashes-on-some-computers/132189#132189 – Suma Mar 09 '11 at 14:24
-
You write several times in comments you want to "roll your own". It seems you have a hard time implementing this. Can you state some reasons why you are not willing to use something which is already implemented? – Suma Mar 09 '11 at 14:37
5 Answers
IF you're using Visual Studio 2010 you can use the built in error reporting. You can then register with Microsoft, see http://msdn.microsoft.com/en-us/isv/bb190483

- 511
- 1
- 3
- 7
-
I would rather roll me own, do you know if the crash report information that they generate for this is generated through some sort of functionality that is exposed to coders? – jack Feb 17 '11 at 06:51
-
Windows Error Reporting is definetely a lot easier to use for the people who will be testing your game (providing they use at least Windows XP). To get started you need to spent about $100 on the digital ID and to sign some paperwork with Microsoft, but if you intend to do this seriously, it will pay off very quickly, as you will get a lot more reports than you would via email,. and the reports will be pre-sorted for you (crashes caused by the same cause will be grouped together). – Suma Mar 09 '11 at 14:31
There's some good sample code on Maciej Sinilo's blog (he's a game programmer too). The code includes how to get information from the crash (e.g. was it an invalid read or write) and the callstack or minidump. That was enough to get me started adding a crash handler to our testing system.
Hope that helps.
The most straightforward way to do a crash-report is to have try-catch statements in your code. When an exception happens you create a temporary log file including the exception type, the source code class, function and line where the crash happened and the data of the global and the local variables/containers, some of which should include the user input.
You don't send the error log through email but your program opens a port and sends the data to a server which listens continuously to a predefined port for error reports.
More advanced error reports can include a memory dump and the values of the registers. To read the memory values a quick-and-dirty way is to use a pointer that will read iteratively the values of the stack region. For the register values you can use the asm
keyword.

- 2,721
- 7
- 33
- 54
-
Where do you place these try-catch statements? You also want to think about showing the user what you are sending back to base so that they can check you aren't stealing their personal information (e.g. credit card details etc.) – David Heffernan Feb 17 '11 at 00:14
-
Rather than trying to write your own code to do this it would make sense to use one of the many available ready-made tools to do the job. – David Heffernan Feb 17 '11 at 00:15
-
1You are right about sensitive information but since it's a game I supposed that the info will mostly be stages level, cursor position etc. Surely one can use ready-made tools but as programmer I answered how I would implement it. However such a tool would be a good option indeed. – Vasilis Feb 17 '11 at 00:22
-
Vasilis: Do you have an example of how to do "More advanced error reports can include a memory dump and the values of the registers. To read the memory values a quick-and-dirty way is to use a pointer that will read iteratively the values of the stack region. For the register values you can use the asm keyword.". – jack Feb 18 '11 at 04:49
-
1
You can use the MiniDumpWriteDump function from the Debug Help Library to create the dump file with the stack dumps from each thread. I believe that you can then open up the file in Visual Studio and view it the debugger (or close to that).

- 31,086
- 2
- 52
- 86
-
-
2It just creates a file, so you could send it as an attachment or upload it. If you are looking for an email library that's a different question. – shf301 Feb 17 '11 at 15:17
if you want some kind of out of the box error reporting via the internet, you should check out EQATEC analytics
which has a C++ interface available.

- 111
- 4