2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: debugrpt.h
|
2008-04-20 19:50:56 -04:00
|
|
|
// Purpose: interface of wxDebugReport*
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxDebugReportPreview
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
This class presents the debug report to the user and allows him to veto
|
|
|
|
report entirely or remove some parts of it. Although not mandatory, using
|
|
|
|
this class is strongly recommended as data included in the debug report
|
|
|
|
might contain sensitive private information and the user should be notified
|
|
|
|
about it as well as having a possibility to examine the data which had been
|
|
|
|
gathered to check whether this is effectively the case and discard the
|
|
|
|
debug report if it is.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxDebugReportPreview is an abstract base class, currently the only concrete
|
2008-04-20 19:50:56 -04:00
|
|
|
class deriving from it is wxDebugReportPreviewStd.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxqa}
|
|
|
|
@category{debugging}
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxDebugReportPreview
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Default constructor.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxDebugReportPreview();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Destructor is trivial as well but should be virtual for a base class.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-20 19:50:56 -04:00
|
|
|
virtual ~wxDebugReportPreview();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Present the report to the user and allow him to modify it by removing
|
|
|
|
some or all of the files and, potentially, adding some notes.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the report should be processed or @false if the user
|
2008-04-20 19:50:56 -04:00
|
|
|
chose to cancel report generation or removed all files from
|
|
|
|
it.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
virtual bool Show(wxDebugReport& dbgrpt) const = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDebugReportCompress
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
wxDebugReportCompress is a wxDebugReport which compresses all the files in
|
|
|
|
this debug report into a single ZIP file in its wxDebugReport::Process()
|
|
|
|
function.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxqa}
|
|
|
|
@category{debugging}
|
|
|
|
*/
|
|
|
|
class wxDebugReportCompress : public wxDebugReport
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Default constructor does nothing special.
|
|
|
|
*/
|
|
|
|
wxDebugReportCompress();
|
|
|
|
|
2009-08-13 20:06:03 -04:00
|
|
|
/**
|
|
|
|
Set the directory where the debug report should be generated.
|
|
|
|
|
|
|
|
By default, the debug report is generated under user temporary files
|
|
|
|
directory. This is usually fine if it is meant to be processed in some
|
|
|
|
way (e.g. automatically uploaded to a remote server) but if the user is
|
|
|
|
asked to manually upload or send the report, it may be more convenient
|
|
|
|
to generate it in e.g. the users home directory and this function
|
|
|
|
allows to do this.
|
|
|
|
|
|
|
|
Notice that it should be called before wxDebugReport::Process() or it
|
|
|
|
has no effect.
|
|
|
|
|
|
|
|
@param dir
|
|
|
|
The full path to an existing directory where the debug report file
|
|
|
|
should be generated.
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
void SetCompressedFileDirectory(const wxString& dir);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the base name of the generated debug report file.
|
|
|
|
|
|
|
|
This function is similar to SetCompressedFileDirectory() but allows to
|
|
|
|
change the base name of the file. Notice that the file extension will
|
|
|
|
always be @c .zip.
|
|
|
|
|
|
|
|
By default, a unique name constructed from wxApp::GetAppName(), the
|
|
|
|
current process id and the current date and time is used.
|
|
|
|
|
2010-03-19 18:35:30 -04:00
|
|
|
@param name
|
2009-08-13 20:06:03 -04:00
|
|
|
The base name (i.e. without extension) of the file.
|
|
|
|
|
|
|
|
@since 2.9.1
|
|
|
|
*/
|
|
|
|
void SetCompressedFileBaseName(const wxString& name);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Returns the full path of the compressed file (empty if creation
|
|
|
|
failed).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
const wxString& GetCompressedFileName() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDebugReport
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
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 @ref page_samples_debugrpt.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Once a report is fully assembled, it can simply be left in the temporary
|
2008-04-20 19:50:56 -04:00
|
|
|
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:
|
|
|
|
|
|
|
|
@code
|
|
|
|
wxDebugReport report;
|
|
|
|
wxDebugReportPreviewStd preview;
|
|
|
|
|
|
|
|
report.AddCurrentContext(); // could also use AddAll()
|
|
|
|
report.AddCurrentDump(); // to do both at once
|
|
|
|
|
|
|
|
if ( preview.Show(report) )
|
|
|
|
report.Process();
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxqa}
|
|
|
|
@category{debugging}
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxDebugReport
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
2008-04-20 19:50:56 -04:00
|
|
|
/**
|
|
|
|
This enum is used for functions that report either the current state or
|
|
|
|
the state during the last (fatal) exception.
|
|
|
|
*/
|
|
|
|
enum Context {
|
|
|
|
Context_Current,
|
|
|
|
Context_Exception
|
|
|
|
};
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
The constructor creates a temporary directory where the files that will
|
2008-04-20 19:50:56 -04:00
|
|
|
be included in the report are created. Use IsOk() to check for errors.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxDebugReport();
|
|
|
|
|
|
|
|
/**
|
|
|
|
The destructor normally destroys the temporary directory created in the
|
2008-04-20 19:50:56 -04:00
|
|
|
constructor with all the files it contains. Call Reset() to prevent
|
|
|
|
this from happening.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxDebugReport();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds all available information to the report. Currently this includes a
|
2008-04-20 19:50:56 -04:00
|
|
|
text (XML) file describing the process context and, under Win32, a
|
|
|
|
minidump file.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void AddAll(Context context = Context_Exception);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Add an XML file containing the current or exception context and the
|
|
|
|
stack trace.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool AddContext(Context ctx);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
The same as calling AddContext(Context_Current).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool AddCurrentContext();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
The same as calling AddDump(Context_Current).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool AddCurrentDump();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds the minidump file to the debug report.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
|
|
|
Minidumps are only available under recent Win32 versions
|
|
|
|
(@c dbghlp32.dll can be installed under older systems to make minidumps
|
|
|
|
available).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-13 09:24:43 -04:00
|
|
|
virtual bool AddDump(Context ctx);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
The same as calling AddContext(Context_Exception).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool AddExceptionContext();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
The same as calling AddDump(Context_Exception).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool AddExceptionDump();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Add another file to the report. If @a filename is an absolute path, it
|
|
|
|
is copied to a file in the debug report directory with the same name.
|
2010-07-25 07:26:04 -04:00
|
|
|
Otherwise the file will be searched in the temporary directory returned
|
|
|
|
by GetDirectory().
|
|
|
|
|
|
|
|
The argument @a description only exists to be displayed to the user in
|
|
|
|
the report summary shown by wxDebugReportPreview.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
|
|
|
@see GetDirectory(), AddText()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void AddFile(const wxString& filename, const wxString& description);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
This is a convenient wrapper around AddFile(). It creates the file with
|
|
|
|
the given @a name and writes @a text to it, then adds the file to the
|
|
|
|
report. The @a filename shouldn't contain the path.
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if file could be added successfully, @false if an IO
|
2008-04-20 19:50:56 -04:00
|
|
|
error occurred.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool AddText(const wxString& filename, const wxString& text,
|
|
|
|
const wxString& description);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
This method should be used to construct the full name of the files
|
|
|
|
which you wish to add to the report using AddFile().
|
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return The name of the temporary directory used for the files in this
|
2008-04-20 19:50:56 -04:00
|
|
|
report.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
const wxString& GetDirectory() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Retrieves the name (relative to GetDirectory()) and the description of
|
|
|
|
the file with the given index. If @a n is greater than or equal to the
|
2011-04-03 16:31:32 -04:00
|
|
|
number of files, then @false is returned.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool GetFile(size_t n, wxString* name, wxString* desc) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the current number files in this report.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
size_t GetFilesCount() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Gets the name used as a base name for various files, by default
|
2008-04-20 19:50:56 -04:00
|
|
|
wxApp::GetAppName() is used.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetReportName() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Returns @true if the object was successfully initialized. If this
|
|
|
|
method returns @false the report can't be used.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool IsOk() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
bool Process();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Removes the file from report: this is used by wxDebugReportPreview to
|
|
|
|
allow the user to remove files potentially containing private
|
|
|
|
information from the report.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void RemoveFile(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Resets the directory name we use. The object can't be used any more
|
|
|
|
after this as it becomes uninitialized and invalid.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void Reset();
|
2008-10-29 14:55:57 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function may be overridden to add arbitrary custom context to the
|
|
|
|
XML context file created by AddContext(). By default, it does nothing.
|
|
|
|
*/
|
|
|
|
virtual void DoAddCustomContext(wxXmlNode* nodeRoot);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function may be overridden to modify the contents of the exception
|
|
|
|
tag in the XML context file.
|
|
|
|
*/
|
|
|
|
virtual bool DoAddExceptionInfo(wxXmlNode* nodeContext);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function may be overridden to modify the contents of the modules
|
|
|
|
tag in the XML context file.
|
|
|
|
*/
|
|
|
|
virtual bool DoAddLoadedModules(wxXmlNode* nodeModules);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This function may be overridden to modify the contents of the system
|
|
|
|
tag in the XML context file.
|
|
|
|
*/
|
|
|
|
virtual bool DoAddSystemInfo(wxXmlNode* nodeSystemInfo);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDebugReportPreviewStd
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
wxDebugReportPreviewStd is a standard debug report preview window. It
|
|
|
|
displays a dialog allowing the user to examine the contents of a debug
|
|
|
|
report, remove files from and add notes to it.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxqa}
|
|
|
|
@category{debugging}
|
|
|
|
*/
|
|
|
|
class wxDebugReportPreviewStd : public wxDebugReportPreview
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Trivial default constructor.
|
|
|
|
*/
|
|
|
|
wxDebugReportPreviewStd();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Shows the dialog.
|
|
|
|
|
|
|
|
@see wxDebugReportPreview::Show()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool Show(wxDebugReport& dbgrpt) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDebugReportUpload
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
This class is used to upload a compressed file using HTTP POST request. As
|
|
|
|
this class derives from wxDebugReportCompress, before upload the report is
|
|
|
|
compressed in a single ZIP file.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxqa}
|
|
|
|
@category{debugging}
|
|
|
|
*/
|
|
|
|
class wxDebugReportUpload : public wxDebugReportCompress
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
This class will upload the compressed file created by its base class to
|
|
|
|
an HTML multipart/form-data form at the specified address. The @a url
|
|
|
|
is the upload page address, @a input is the name of the @c "type=file"
|
|
|
|
control on the form used for the file name and @a action is the value
|
|
|
|
of the form action field. The report is uploaded using the @e curl
|
|
|
|
program which should be available, the @e curl parameter may be used to
|
|
|
|
specify the full path to it.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxDebugReportUpload(const wxString& url, const wxString& input,
|
2008-04-20 19:50:56 -04:00
|
|
|
const wxString& action,
|
|
|
|
const wxString& curl = "curl");
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-10-29 14:55:57 -04:00
|
|
|
protected:
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
This function may be overridden in a derived class to show the output
|
|
|
|
from curl: this may be an HTML page or anything else that the server
|
|
|
|
returned. Value returned by this function becomes the return value of
|
|
|
|
wxDebugReport::Process().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
virtual bool OnServerReply(const wxArrayString& reply);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|