2003-07-12 22:28:11 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2003-07-13 17:18:04 -04:00
|
|
|
// Name: wx/msw/crashrpt.h
|
2003-07-12 22:28:11 -04:00
|
|
|
// Purpose: helpers for the structured exception handling (SEH) under Win32
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 13.07.2003
|
|
|
|
// RCS-ID: $Id$
|
2004-05-23 10:56:36 -04:00
|
|
|
// Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2003-07-12 22:28:11 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-01-16 20:21:57 -05:00
|
|
|
#ifndef _WX_MSW_CRASHRPT_H_
|
|
|
|
#define _WX_MSW_CRASHRPT_H_
|
2003-07-12 22:28:11 -04:00
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2005-01-16 20:21:57 -05:00
|
|
|
#if wxUSE_CRASHREPORT
|
|
|
|
|
|
|
|
struct _EXCEPTION_POINTERS;
|
2003-07-12 22:28:11 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2005-01-16 20:21:57 -05:00
|
|
|
// crash report generation flags
|
2003-07-12 22:28:11 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-07-13 17:18:04 -04:00
|
|
|
enum
|
|
|
|
{
|
2005-05-31 05:20:43 -04:00
|
|
|
// we always report where the crash occurred
|
2003-07-13 17:18:04 -04:00
|
|
|
wxCRASH_REPORT_LOCATION = 0,
|
|
|
|
|
|
|
|
// if this flag is given, the call stack is dumped
|
2003-09-29 13:14:52 -04:00
|
|
|
//
|
|
|
|
// this results in dump/crash report as small as possible, this is the
|
|
|
|
// default flag
|
2003-07-13 17:18:04 -04:00
|
|
|
wxCRASH_REPORT_STACK = 1,
|
|
|
|
|
|
|
|
// if this flag is given, the values of the local variables are dumped
|
2003-09-29 13:14:52 -04:00
|
|
|
//
|
2005-01-16 20:21:57 -05:00
|
|
|
// note that with the current implementation it requires dumping the full
|
|
|
|
// process address space and so this will result in huge dump file and will
|
|
|
|
// take some time to generate
|
|
|
|
//
|
|
|
|
// it's probably not a good idea to use this by default, start with default
|
|
|
|
// mini dump and ask your users to set WX_CRASH_FLAGS environment variable
|
|
|
|
// to 2 or 4 if you need more information in the dump
|
2003-07-13 17:18:04 -04:00
|
|
|
wxCRASH_REPORT_LOCALS = 2,
|
|
|
|
|
|
|
|
// if this flag is given, the values of all global variables are dumped
|
|
|
|
//
|
2005-01-16 20:21:57 -05:00
|
|
|
// this creates a much larger mini dump than just wxCRASH_REPORT_STACK but
|
|
|
|
// still much smaller than wxCRASH_REPORT_LOCALS one
|
2005-01-16 21:04:06 -05:00
|
|
|
wxCRASH_REPORT_GLOBALS = 4,
|
|
|
|
|
|
|
|
// default is to create the smallest possible crash report
|
|
|
|
wxCRASH_REPORT_DEFAULT = wxCRASH_REPORT_LOCATION | wxCRASH_REPORT_STACK
|
2003-07-13 17:18:04 -04:00
|
|
|
};
|
|
|
|
|
2005-01-16 20:21:57 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxCrashContext: information about the crash context
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct WXDLLIMPEXP_BASE wxCrashContext
|
|
|
|
{
|
|
|
|
// initialize this object with the given information or from the current
|
|
|
|
// global exception info which is only valid inside wxApp::OnFatalException
|
|
|
|
wxCrashContext(_EXCEPTION_POINTERS *ep = NULL);
|
|
|
|
|
|
|
|
// get the name for this exception code
|
|
|
|
wxString GetExceptionString() const;
|
|
|
|
|
|
|
|
|
|
|
|
// exception code
|
|
|
|
size_t code;
|
|
|
|
|
|
|
|
// exception address
|
|
|
|
void *addr;
|
|
|
|
|
|
|
|
// machine-specific registers vaues
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
#ifdef __INTEL__
|
|
|
|
wxInt32 eax, ebx, ecx, edx, esi, edi,
|
|
|
|
ebp, esp, eip,
|
|
|
|
cs, ds, es, fs, gs, ss,
|
|
|
|
flags;
|
|
|
|
#endif // __INTEL__
|
|
|
|
} regs;
|
|
|
|
};
|
|
|
|
|
2003-07-13 17:18:04 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxCrashReport: this class is used to create crash reports
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct WXDLLIMPEXP_BASE wxCrashReport
|
2003-07-12 22:28:11 -04:00
|
|
|
{
|
|
|
|
// set the name of the file to which the report is written, it is
|
|
|
|
// constructed from the .exe name by default
|
|
|
|
static void SetFileName(const wxChar *filename);
|
|
|
|
|
|
|
|
// return the current file name
|
|
|
|
static const wxChar *GetFileName();
|
|
|
|
|
|
|
|
// write the exception report to the file, return true if it could be done
|
|
|
|
// or false otherwise
|
2005-01-16 20:21:57 -05:00
|
|
|
//
|
|
|
|
// if ep pointer is NULL, the global exception info which is valid only
|
|
|
|
// inside wxApp::OnFatalException() is used
|
2005-01-16 21:04:06 -05:00
|
|
|
static bool Generate(int flags = wxCRASH_REPORT_DEFAULT,
|
2005-01-16 20:21:57 -05:00
|
|
|
_EXCEPTION_POINTERS *ep = NULL);
|
|
|
|
|
2005-01-16 21:04:06 -05:00
|
|
|
|
|
|
|
// generate a crash report from outside of wxApp::OnFatalException(), this
|
|
|
|
// can be used to take "snapshots" of the program in wxApp::OnAssert() for
|
|
|
|
// example
|
|
|
|
static bool GenerateNow(int flags = wxCRASH_REPORT_DEFAULT);
|
2003-07-12 22:28:11 -04:00
|
|
|
};
|
|
|
|
|
2005-01-16 20:21:57 -05:00
|
|
|
#endif // wxUSE_CRASHREPORT
|
2003-07-12 22:28:11 -04:00
|
|
|
|
2005-01-16 20:21:57 -05:00
|
|
|
#endif // _WX_MSW_CRASHRPT_H_
|
2003-07-12 22:28:11 -04:00
|
|
|
|