wxDebugReport is used to generate a debug report, containing information about the program current state. It is usually used from wxApp::OnFatalException() as shown in the sample.
A wxDebugReport object contains one or more files. A few of them can be created by the class itself but more can be created from the outside and then added to the report. Also note that several virtual functions may be overridden to further customize the class behaviour.
Once a report is fully assembled, it can simply be left in the temporary directory so that the user can email it to the developers (in which case you should still use wxDebugReportCompress to compress it in a single file) or uploaded to a Web server using wxDebugReportUpload (setting up the Web server to accept uploads is your responsibility, of course). Other handlers, for example for automatically emailing the report, can be defined as well but are not currently included in wxWidgets.
Example of use
wxDebugReport report; wxDebugReportPreviewStd preview; report.AddCurrentContext(); // could also use AddAll() report.AddCurrentDump(); // to do both at once if ( preview.Show(report) ) report.Process();
Derived from
No base class
Include files
<wx/debugrpt.h>
Data structures
This enum is used for functions that report either the current state or the state during the last (fatal) exception:
enum wxDebugReport::Context { Context_Current, Context_Exception };
The constructor creates a temporary directory where the files that will be included in the report are created. Use IsOk() to check for errors.
The destructor normally destroys the temporary directory created in the constructor with all the files it contains. Call Reset() to prevent this from happening.
Adds all available information to the report. Currently this includes a text (XML) file describing the process context and, under Win32, a minidump file.
Add an XML file containing the current or exception context and the stack trace.
The same as AddContext(Context_Current).
The same as AddDump(Context_Current).
Adds the minidump file to the debug report.
Minidumps are only available under recent Win32 versions (dbghlp32.dll can be installed under older systems to make minidumps available).
The same as AddContext(Context_Exception).
The same as AddDump(Context_Exception).
Add another file to the report. If filename is an absolute path, it is copied to a file in the debug report directory with the same name. Otherwise the file should already exist in this directory
description only exists to be displayed to the user in the report summary shown by wxDebugReportPreview.
See also
This is a convenient wrapper around AddFile. It creates the file with the given name and writes text to it, then adds the file to the report. The filename shouldn't contain the path.
Returns TRUEif file could be added successfully, FALSEif an IO error occured.
This function may be overridden to add arbitrary custom context to the XML context file created by AddContext. By default, it does nothing.
This function may be overridden to modify the contents of the exception tag in the XML context file.
This function may be overridden to modify the contents of the modules tag in the XML context file.
This function may be overridden to modify the contents of the system tag in the XML context file.
const wxString& GetDirectory(void) const
Returns the name of the temporary directory used for the files in this report.
This method should be used to construct the full name of the files which you wish to add to the report using AddFile.
bool GetFile(size_t n, wxString* name, wxString* desc) const
Retrieves the name (relative to GetDirectory()) and the description of the file with the given index. If n is greater than or equal to the number of filse, FALSEis returned.
size_t GetFilesCount(void) const
Gets the current number files in this report.
wxString GetReportName(void) const
Gets the name used as a base name for various files, by default wxApp::GetAppName() is used.
Returns TRUEif the object was successfully initialized. If this method returns FALSEthe report can't be used.
Processes this report: the base class simply notifies the user that the report has been generated. This is usually not enough - instead you should override this method to do something more useful to you.
Removes the file from report: this is used by wxDebugReportPreview to allow the user to remove files potentially containing private information from the report.
Resets the directory name we use. The object can't be used any more after this as it becomes uninitialized and invalid.
ymasuda 平成17年11月19日