Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there any crash reporter tool for C++? 1

Status
Not open for further replies.

Dhafir

Programmer
Sep 22, 2002
28
0
0
NZ
Hi all,
I am looking for a tool that can be embedded with an exe file to report or spit out the call stack when the exe (written in C++) crashes.
I read about the PC-lint, but this costs real money, are you guys aware of any other tool that can do the job?

Thanks in advance!


Dhafir
 
> I am looking for a tool that can be embedded with an exe file to report or spit out the call stack when the exe (written in C++) crashes.
You really need the OS to do this for you. Assuming your 'crash dump' subroutine even runs (there's no guarantee that it would), there's no guarantee that it would produce any meaningful information either. It could corrupt the information simply by being run itself.

A better idea would be to have a "-debug" command line parameter which could record everything up to the fatal moment, thus giving you a much better idea of how your program got into a crash state in the first place. But this too is useless if your user has an unrepeatable event.

Having said that, there is one open source scheme which may be of some use, but it will need a lot of digging on your part.
Netscape navigator implements a Quality Feedback System which does as you describe IIRC.
You would need to dig through the vast amount of source code and articles (here) to find out how it is done, and whether it could be adapted to what you want.

> I read about the PC-lint, but this costs real money
This examines the code for bugs (and other problems) before the code is run. It is not a post-mortem tool for after the event (that's what a debugger is for).

If you think it costs money, how much money do you spend looking for the problems which PC-lint can find?
You can freely download the list of error messages PC-lint can generate. Have any of those been problems to you in the past? How long did it take you to find those bugs (and how much did it cost you?)

--
 
>I am looking for a tool that can ... report or spit out the call stack when the exe ... crashes.

You can incorporate such functionality into your code yourself.

To copy the call-stack to the clipboard (which you for example write to a log file/stream):
Code:
AfxDumpStack(AFX_STACK_DUMP_TARGET_CLIPBOARD);


It can be used where an assertion/contract fails. Ie put in contracts (simplest form is the ASSERT macro) which you configure to dump the stack on failure. Naturally you'd have to make sure that the assertion fires in release builds as well.

In addition to assertions you can use the
Code:
_set_new_handler
set_terminate
_set_se_translator
functions to handle errors "beyond your control". See docs in MSDN on each function. Let them dump the stack as well.

> I read about the PC-lint, but this costs real money

PC-lint is outstanding. If you plan to make any money from your software be prepared to have some expenses for it. There is no free lunch.

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Hi,

try CrashRpt library which can be found here.

I use it in my applications and I'm satisfied with it.

Standa K.
 
Thanks Per & Standa,
My application is non MFC , multi- threaded ( console Win32), so the AfxDumpStack(...) doesn't sound possible in my case ( I guess), so as the CrashRpt which I tried to embed with my application but faces a multi-threadinh conflicts.
I am relying totally on Dr. Watson reports, WinDbg and CrashFinder tolls for the time being.

Thanks alot guys.

Dhafir
 
>My application is non MFC , multi- threaded ( console Win32), so the AfxDumpStack(...) doesn't sound possible in my case ( I guess)

It is possible if you can live with a thin dependancy to MFC. Use it myself in very multithreaded applications (even in server apps, ie no GUI, not even a console) that aren't really MFC apps (except for AfxDump and possibly CString). Typically I set them up by defining my own terminate handler (one for each thread).


/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top