Very often it is useful to have more information about the program's internal state when it crashes - for example, what files were open, dataset states, contents of internal variables etc.
I've found that this can be easily accomplished by writing a madExcept plugin which is included in the project and registered at runtime - in the main form's OnCreate, for example. However, I've noticed that all values must be fully dereferenced: MainUnit.MainForm.Edit1.Text will work but MainForm.Edit1.Text won't work even if MainUnit is included in the plugin's Uses clause.
Mark
How to include more information in the bug reports
The first step is to write a plugin according to the guidelines published on the help web site. Include the following at the end of the plugin.pas file:
The function that will collect the data - "GetProgramData" in this example - will need to address variables in their fully dereferenced form. So, fo example, if you need to know the contents of an edit box on your main form, the correct way to collect that data is MainUnit.MainForm.EditBox1.Text. Unless you give the unit name as well as the Form name, the thread that collects this data will hang and your plugin function will not return a value (resulting in the "will be completed shortly" default string.
Having done this, add a reference to your project's DPR file - a good place is immediately after all the "mad*" units:
Then finally, ensure that the plugin is used by default whenever madExcept gains control - say in the OnCreate handler for your main form:
Now, unless you subsequently disable the plugin, whenever madExcept gains control to report an exception, a new Tab will be included in the Bug Report which contains the contents of the string returned by the "GetProgramData" function.
Using this technique, I have been able to find and eliminate bugs that only appear under a certain sets of circumstances quickly and easily and without having to enter into a lengthy email dialogue with the reporting end-user. It adds "why it happened" to "what happened".
Mark
Code: Select all
initialization
RegisterBugReportPlugin('MyPlugin', 'MyPlugin', GetProgramData);
finalization
UnregisterBugReportPlugin('MyPlugin');
Having done this, add a reference to your project's DPR file - a good place is immediately after all the "mad*" units:
Code: Select all
madExcept,
madLinkDisAsm,
madListHardware,
madListProcesses,
madListModules,
MyDebugUnit in 'MyDebugUnit.pas', // Our madExcept plugin
Forms,
...
Code: Select all
MESettings.PluginEnabled['MyPlugin'] := True; // Enable our plug-in (MyDebugUnit.pas)
Using this technique, I have been able to find and eliminate bugs that only appear under a certain sets of circumstances quickly and easily and without having to enter into a lengthy email dialogue with the reporting end-user. It adds "why it happened" to "what happened".
Mark