0

I want to write a (or use existing) crash handler for my app. The problem I've with that is that I want it for Windows and gcc.

I deeply searched for such solution but there are only VS ones.

So far I've a handler registered with SetUnhandledExceptionFilter. According to my observations when handler is called, stack is 'limited' to my handler function + a few extra system functions.

Original stack seems to be above it (according to original esp and ebp stored in EXCEPTION_POINTERS passed to my handler).

I was trying to switch current esp and ebp to saved ones, but I usualy ends with crash.

I've also tried using posix' signal but stack is limited in the same way.

Shachaf.Gortler
  • 5,655
  • 14
  • 43
  • 71
Michał Walenciak
  • 4,257
  • 4
  • 33
  • 61

1 Answers1

0

I kept searching for the answer and here is what I've got:

there are (at least) two ways of finding real stack in case of application crash under windows.

  1. stack can be backtraced with simple trick described here. It is necessary to use ebp member from EXCEPTION_POINTERS instead of real ebp register.
  2. STACKFRAME64 example usage here

Then it is necessary to convert addresses into function names. Here I've found 3 approaches:

  1. addr2line
  2. SymFromAddr
  3. bfd

What's problematic - all these are working with particular executable file. It is necessary to handle extra dll files separately.

In my program I'll try to use KDE5's KCrash + drkonqi. Both projects are source of valuable information by the way.

Community
  • 1
  • 1
Michał Walenciak
  • 4,257
  • 4
  • 33
  • 61