crashrpt.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/crashrpt.h
  3. // Purpose: helpers for the structured exception handling (SEH) under Win32
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 13.07.2003
  7. // Copyright: (c) 2003 Vadim Zeitlin <vadim@wxwidgets.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_MSW_CRASHRPT_H_
  11. #define _WX_MSW_CRASHRPT_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_CRASHREPORT
  14. struct _EXCEPTION_POINTERS;
  15. // ----------------------------------------------------------------------------
  16. // crash report generation flags
  17. // ----------------------------------------------------------------------------
  18. enum
  19. {
  20. // we always report where the crash occurred
  21. wxCRASH_REPORT_LOCATION = 0,
  22. // if this flag is given, the call stack is dumped
  23. //
  24. // this results in dump/crash report as small as possible, this is the
  25. // default flag
  26. wxCRASH_REPORT_STACK = 1,
  27. // if this flag is given, the values of the local variables are dumped
  28. //
  29. // note that with the current implementation it requires dumping the full
  30. // process address space and so this will result in huge dump file and will
  31. // take some time to generate
  32. //
  33. // it's probably not a good idea to use this by default, start with default
  34. // mini dump and ask your users to set WX_CRASH_FLAGS environment variable
  35. // to 2 or 4 if you need more information in the dump
  36. wxCRASH_REPORT_LOCALS = 2,
  37. // if this flag is given, the values of all global variables are dumped
  38. //
  39. // this creates a much larger mini dump than just wxCRASH_REPORT_STACK but
  40. // still much smaller than wxCRASH_REPORT_LOCALS one
  41. wxCRASH_REPORT_GLOBALS = 4,
  42. // default is to create the smallest possible crash report
  43. wxCRASH_REPORT_DEFAULT = wxCRASH_REPORT_LOCATION | wxCRASH_REPORT_STACK
  44. };
  45. // ----------------------------------------------------------------------------
  46. // wxCrashContext: information about the crash context
  47. // ----------------------------------------------------------------------------
  48. struct WXDLLIMPEXP_BASE wxCrashContext
  49. {
  50. // initialize this object with the given information or from the current
  51. // global exception info which is only valid inside wxApp::OnFatalException
  52. wxCrashContext(_EXCEPTION_POINTERS *ep = NULL);
  53. // get the name for this exception code
  54. wxString GetExceptionString() const;
  55. // exception code
  56. size_t code;
  57. // exception address
  58. void *addr;
  59. // machine-specific registers vaues
  60. struct
  61. {
  62. #ifdef __INTEL__
  63. wxInt32 eax, ebx, ecx, edx, esi, edi,
  64. ebp, esp, eip,
  65. cs, ds, es, fs, gs, ss,
  66. flags;
  67. #endif // __INTEL__
  68. } regs;
  69. };
  70. // ----------------------------------------------------------------------------
  71. // wxCrashReport: this class is used to create crash reports
  72. // ----------------------------------------------------------------------------
  73. struct WXDLLIMPEXP_BASE wxCrashReport
  74. {
  75. // set the name of the file to which the report is written, it is
  76. // constructed from the .exe name by default
  77. static void SetFileName(const wxString& filename);
  78. // return the current file name
  79. static wxString GetFileName();
  80. // write the exception report to the file, return true if it could be done
  81. // or false otherwise
  82. //
  83. // if ep pointer is NULL, the global exception info which is valid only
  84. // inside wxApp::OnFatalException() is used
  85. static bool Generate(int flags = wxCRASH_REPORT_DEFAULT,
  86. _EXCEPTION_POINTERS *ep = NULL);
  87. // generate a crash report from outside of wxApp::OnFatalException(), this
  88. // can be used to take "snapshots" of the program in wxApp::OnAssert() for
  89. // example
  90. static bool GenerateNow(int flags = wxCRASH_REPORT_DEFAULT);
  91. };
  92. #endif // wxUSE_CRASHREPORT
  93. #endif // _WX_MSW_CRASHRPT_H_