]>
git.saurik.com Git - wxWidgets.git/blob - interface/debugrpt.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDebugReport*
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxDebugReportPreview
13 This class presents the debug report to the user and allows him to veto
14 report entirely or remove some parts of it. Although not mandatory, using
15 this class is strongly recommended as data included in the debug report
16 might contain sensitive private information and the user should be notified
17 about it as well as having a possibility to examine the data which had been
18 gathered to check whether this is effectively the case and discard the
19 debug report if it is.
21 wxDebugReportPreview is an abstract base class, currently the only concrete
22 class deriving from it is wxDebugReportPreviewStd.
27 class wxDebugReportPreview
33 wxDebugReportPreview();
36 Destructor is trivial as well but should be virtual for a base class.
38 virtual ~wxDebugReportPreview();
41 Present the report to the user and allow him to modify it by removing
42 some or all of the files and, potentially, adding some notes.
44 @return @true if the report should be processed or @false if the user
45 chose to cancel report generation or removed all files from
48 virtual bool Show(wxDebugReport
& dbgrpt
) const;
54 @class wxDebugReportCompress
57 wxDebugReportCompress is a wxDebugReport which compresses all the files in
58 this debug report into a single ZIP file in its wxDebugReport::Process()
64 class wxDebugReportCompress
: public wxDebugReport
68 Default constructor does nothing special.
70 wxDebugReportCompress();
73 Returns the full path of the compressed file (empty if creation
76 const wxString
GetCompressedFileName() const;
85 wxDebugReport is used to generate a debug report, containing information
86 about the program current state. It is usually used from
87 wxApp::OnFatalException() as shown in the @ref page_samples_debugrpt.
89 A wxDebugReport object contains one or more files. A few of them can be
90 created by the class itself but more can be created from the outside and
91 then added to the report. Also note that several virtual functions may be
92 overridden to further customize the class behaviour.
94 Once a report is fully assembled, it can simply be left in the temporary
95 directory so that the user can email it to the developers (in which case
96 you should still use wxDebugReportCompress to compress it in a single file)
97 or uploaded to a Web server using wxDebugReportUpload (setting up the Web
98 server to accept uploads is your responsibility, of course). Other
99 handlers, for example for automatically emailing the report, can be defined
100 as well but are not currently included in wxWidgets.
102 A typical usage example:
105 wxDebugReport report;
106 wxDebugReportPreviewStd preview;
108 report.AddCurrentContext(); // could also use AddAll()
109 report.AddCurrentDump(); // to do both at once
111 if ( preview.Show(report) )
122 This enum is used for functions that report either the current state or
123 the state during the last (fatal) exception.
131 The constructor creates a temporary directory where the files that will
132 be included in the report are created. Use IsOk() to check for errors.
137 The destructor normally destroys the temporary directory created in the
138 constructor with all the files it contains. Call Reset() to prevent
144 Adds all available information to the report. Currently this includes a
145 text (XML) file describing the process context and, under Win32, a
148 void AddAll(Context context
= Context_Exception
);
151 Add an XML file containing the current or exception context and the
154 bool AddContext(Context ctx
);
157 The same as calling AddContext(Context_Current).
159 bool AddCurrentContext();
162 The same as calling AddDump(Context_Current).
164 bool AddCurrentDump();
167 Adds the minidump file to the debug report.
169 Minidumps are only available under recent Win32 versions
170 (@c dbghlp32.dll can be installed under older systems to make minidumps
173 bool AddDump(Context ctx
);
176 The same as calling AddContext(Context_Exception).
178 bool AddExceptionContext();
181 The same as calling AddDump(Context_Exception).
183 bool AddExceptionDump();
186 Add another file to the report. If @a filename is an absolute path, it
187 is copied to a file in the debug report directory with the same name.
188 Otherwise the file should already exist in this directory
189 @a description only exists to be displayed to the user in the report
190 summary shown by wxDebugReportPreview.
192 @see GetDirectory(), AddText()
194 void AddFile(const wxString
& filename
, const wxString
& description
);
197 This is a convenient wrapper around AddFile(). It creates the file with
198 the given @a name and writes @a text to it, then adds the file to the
199 report. The @a filename shouldn't contain the path.
201 @return @true if file could be added successfully, @false if an IO
204 bool AddText(const wxString
& filename
, const wxString
& text
,
205 const wxString
& description
);
208 This function may be overridden to add arbitrary custom context to the
209 XML context file created by AddContext(). By default, it does nothing.
211 void DoAddCustomContext(wxXmlNode
* nodeRoot
);
214 This function may be overridden to modify the contents of the exception
215 tag in the XML context file.
217 bool DoAddExceptionInfo(wxXmlNode
* nodeContext
);
220 This function may be overridden to modify the contents of the modules
221 tag in the XML context file.
223 bool DoAddLoadedModules(wxXmlNode
* nodeModules
);
226 This function may be overridden to modify the contents of the system
227 tag in the XML context file.
229 bool DoAddSystemInfo(wxXmlNode
* nodeSystemInfo
);
232 This method should be used to construct the full name of the files
233 which you wish to add to the report using AddFile().
235 @return The name of the temporary directory used for the files in this
238 const wxString
GetDirectory() const;
241 Retrieves the name (relative to GetDirectory()) and the description of
242 the file with the given index. If @a n is greater than or equal to the
243 number of filse, @false is returned.
245 bool GetFile(size_t n
, wxString
* name
, wxString
* desc
) const;
248 Gets the current number files in this report.
250 size_t GetFilesCount() const;
253 Gets the name used as a base name for various files, by default
254 wxApp::GetAppName() is used.
256 wxString
GetReportName() const;
259 Returns @true if the object was successfully initialized. If this
260 method returns @false the report can't be used.
265 Processes this report: the base class simply notifies the user that the
266 report has been generated. This is usually not enough -- instead you
267 should override this method to do something more useful to you.
272 Removes the file from report: this is used by wxDebugReportPreview to
273 allow the user to remove files potentially containing private
274 information from the report.
276 void RemoveFile(const wxString
& name
);
279 Resets the directory name we use. The object can't be used any more
280 after this as it becomes uninitialized and invalid.
288 @class wxDebugReportPreviewStd
289 @wxheader{debugrpt.h}
291 wxDebugReportPreviewStd is a standard debug report preview window. It
292 displays a dialog allowing the user to examine the contents of a debug
293 report, remove files from and add notes to it.
298 class wxDebugReportPreviewStd
: public wxDebugReportPreview
302 Trivial default constructor.
304 wxDebugReportPreviewStd();
309 @see wxDebugReportPreview::Show()
311 bool Show(wxDebugReport
& dbgrpt
) const;
317 @class wxDebugReportUpload
318 @wxheader{debugrpt.h}
320 This class is used to upload a compressed file using HTTP POST request. As
321 this class derives from wxDebugReportCompress, before upload the report is
322 compressed in a single ZIP file.
327 class wxDebugReportUpload
: public wxDebugReportCompress
331 This class will upload the compressed file created by its base class to
332 an HTML multipart/form-data form at the specified address. The @a url
333 is the upload page address, @a input is the name of the @c "type=file"
334 control on the form used for the file name and @a action is the value
335 of the form action field. The report is uploaded using the @e curl
336 program which should be available, the @e curl parameter may be used to
337 specify the full path to it.
339 wxDebugReportUpload(const wxString
& url
, const wxString
& input
,
340 const wxString
& action
,
341 const wxString
& curl
= "curl");
344 This function may be overridden in a derived class to show the output
345 from curl: this may be an HTML page or anything else that the server
346 returned. Value returned by this function becomes the return value of
347 wxDebugReport::Process().
349 bool OnServerReply(const wxArrayString
& reply
);