| Version: 3.3.1

Public Types | Public Member Functions | Protected Member Functions | List of all members
wxDebugReport Class Reference
Class List by Category » Debugging

`#include <wx/debugrpt.h>`

Inheritance diagram for wxDebugReport:
[legend]

## Detailed Description

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 Debug Reporter 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.

A typical usage example:

wxDebugReport report;
wxDebugReportPreviewStd preview;
report.AddCurrentContext(); // could also use AddAll()
report.AddCurrentDump(); // to do both at once
if ( preview.Show(report) )
report.Process();
wxDebugReport
wxDebugReport is used to generate a debug report, containing information about the program current st...
Definition: debugrpt.h:153
wxDebugReport::AddCurrentContext
bool AddCurrentContext()
The same as calling AddContext(Context_Current).
wxDebugReport::Process
bool Process()
Processes this report: the base class simply notifies the user that the report has been generated.
wxDebugReport::AddCurrentDump
bool AddCurrentDump()
The same as calling AddDump(Context_Current).
wxDebugReportPreviewStd
wxDebugReportPreviewStd is a standard debug report preview window.
Definition: debugrpt.h:336
wxDebugReportPreviewStd::Show
bool Show(wxDebugReport &dbgrpt) const
Shows the dialog.

##

Library: wxQA
Category: Debugging

## Public Types
enum | Context { Context_Current , Context_Exception }
| This enum is used for functions that report either the current state or the state during the last (fatal) exception. More...

## Public Member Functions
| wxDebugReport ()
| The constructor creates a temporary directory where the files that will be included in the report are created. More...
virtual | ~wxDebugReport ()
| The destructor normally destroys the temporary directory created in the constructor with all the files it contains. More...
void | AddAll (Context context=Context_Exception)
| Adds all available information to the report. More...
virtual bool | AddContext (Context ctx)
| Add an XML file containing the current or exception context and the stack trace. More...
bool | AddCurrentContext ()
| The same as calling AddContext(Context_Current). More...
bool | AddCurrentDump ()
| The same as calling AddDump(Context_Current). More...
virtual bool | AddDump (Context ctx)
| Adds the minidump file to the debug report. More...
bool | AddExceptionContext ()
| The same as calling AddContext(Context_Exception). More...
bool | AddExceptionDump ()
| The same as calling AddDump(Context_Exception). More...
virtual void | AddFile (const wxString &filename, const wxString &description)
| Add another file to the report. More...
bool | AddText (const wxString &filename, const wxString &text, const wxString &description)
| This is a convenient wrapper around AddFile(). More...
const wxString & | GetDirectory () const
| This method should be used to construct the full name of the files which you wish to add to the report using AddFile(). More...
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. More...
size_t | GetFilesCount () const
| Gets the current number files in this report. More...
virtual wxString | GetReportName () const
| Gets the name used as a base name for various files, by default wxApp::GetAppName() is used. More...
bool | IsOk () const
| Returns true if the object was successfully initialized. More...
bool | Process ()
| Processes this report: the base class simply notifies the user that the report has been generated. More...
void | RemoveFile (const wxString &name)
| Removes the file from report: this is used by wxDebugReportPreview to allow the user to remove files potentially containing private information from the report. More...
void | Reset ()
| Resets the directory name we use. More...

## Protected Member Functions
virtual void | DoAddCustomContext (wxXmlNode *nodeRoot)
| This function may be overridden to add arbitrary custom context to the XML context file created by AddContext(). More...
virtual bool | DoAddExceptionInfo (wxXmlNode *nodeContext)
| This function may be overridden to modify the contents of the exception tag in the XML context file. More...
virtual bool | DoAddLoadedModules (wxXmlNode *nodeModules)
| This function may be overridden to modify the contents of the modules tag in the XML context file. More...
virtual bool | DoAddSystemInfo (wxXmlNode *nodeSystemInfo)
| This function may be overridden to modify the contents of the system tag in the XML context file. More...

## Member Enumeration Documentation

## ◆ Context

enum wxDebugReport::Context

This enum is used for functions that report either the current state or the state during the last (fatal) exception.

Enumerator
Context_Current |
Context_Exception |

## Constructor & Destructor Documentation

## ◆ wxDebugReport()

wxDebugReport::wxDebugReport | ( |  | ) |

The constructor creates a temporary directory where the files that will be included in the report are created.

Use IsOk() to check for errors.

## ◆ ~wxDebugReport()

virtual wxDebugReport::~wxDebugReport | ( |  | ) |
| virtual

The destructor normally destroys the temporary directory created in the constructor with all the files it contains.

Call Reset() to prevent this from happening.

## Member Function Documentation

## ◆ AddAll()

void wxDebugReport::AddAll | ( | Context | context = `Context_Exception` | ) |

Adds all available information to the report.

Currently this includes a text (XML) file describing the process context and, under Win32, a minidump file.

## ◆ AddContext()

virtual bool wxDebugReport::AddContext | ( | Context | ctx | ) |
| virtual

Add an XML file containing the current or exception context and the stack trace.

## ◆ AddCurrentContext()

bool wxDebugReport::AddCurrentContext | ( |  | ) |

The same as calling AddContext(Context_Current).

## ◆ AddCurrentDump()

bool wxDebugReport::AddCurrentDump | ( |  | ) |

The same as calling AddDump(Context_Current).

## ◆ AddDump()

virtual bool wxDebugReport::AddDump | ( | Context | ctx | ) |
| virtual

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).

## ◆ AddExceptionContext()

bool wxDebugReport::AddExceptionContext | ( |  | ) |

The same as calling AddContext(Context_Exception).

## ◆ AddExceptionDump()

bool wxDebugReport::AddExceptionDump | ( |  | ) |

The same as calling AddDump(Context_Exception).

## ◆ AddFile()

virtual void wxDebugReport::AddFile | ( | const wxString & | filename,
|  | const wxString & | description
| ) |  |
| virtual

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 will be searched in the temporary directory returned by GetDirectory().

The argument description only exists to be displayed to the user in the report summary shown by wxDebugReportPreview.

See also
  GetDirectory(), AddText()

## ◆ AddText()

bool wxDebugReport::AddText | ( | const wxString & | filename,
|  | const wxString & | text,
|  | const wxString & | description
| ) |  |

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
  true if file could be added successfully, false if an IO error occurred.

## ◆ DoAddCustomContext()

virtual void wxDebugReport::DoAddCustomContext | ( | wxXmlNode * | nodeRoot | ) |
| protected virtual

This function may be overridden to add arbitrary custom context to the XML context file created by AddContext().

By default, it does nothing.

## ◆ DoAddExceptionInfo()

virtual bool wxDebugReport::DoAddExceptionInfo | ( | wxXmlNode * | nodeContext | ) |
| protected virtual

This function may be overridden to modify the contents of the exception tag in the XML context file.

## ◆ DoAddLoadedModules()

virtual bool wxDebugReport::DoAddLoadedModules | ( | wxXmlNode * | nodeModules | ) |
| protected virtual

This function may be overridden to modify the contents of the modules tag in the XML context file.

## ◆ DoAddSystemInfo()

virtual bool wxDebugReport::DoAddSystemInfo | ( | wxXmlNode * | nodeSystemInfo | ) |
| protected virtual

This function may be overridden to modify the contents of the system tag in the XML context file.

## ◆ GetDirectory()

const wxString& wxDebugReport::GetDirectory | ( |  | ) | const

This method should be used to construct the full name of the files which you wish to add to the report using AddFile().

Returns
  The name of the temporary directory used for the files in this report.

## ◆ GetFile()

bool wxDebugReport::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 files, then false is returned.

## ◆ GetFilesCount()

size_t wxDebugReport::GetFilesCount | ( |  | ) | const

Gets the current number files in this report.

## ◆ GetReportName()

virtual wxString wxDebugReport::GetReportName | ( |  | ) | const
| virtual

Gets the name used as a base name for various files, by default wxApp::GetAppName() is used.

## ◆ IsOk()

bool wxDebugReport::IsOk | ( |  | ) | const

Returns true if the object was successfully initialized.

If this method returns false the report can't be used.

## ◆ Process()

bool wxDebugReport::Process | ( |  | ) |

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.

## ◆ RemoveFile()

void wxDebugReport::RemoveFile | ( | const wxString & | name | ) |

Removes the file from report: this is used by wxDebugReportPreview to allow the user to remove files potentially containing private information from the report.

## ◆ Reset()

void wxDebugReport::Reset | ( |  | ) |

Resets the directory name we use.

The object can't be used any more after this as it becomes uninitialized and invalid.