How to include more information in the bug reports

delphi package - automated exception handling
Post Reply
Markham
Posts: 26
Joined: Wed Nov 02, 2005 11:46 am

How to include more information in the bug reports

Post by Markham »

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
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Can you show me some code? I'm not sure right now what you mean. Thanks...
Markham
Posts: 26
Joined: Wed Nov 02, 2005 11:46 am

Post by Markham »

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:

Code: Select all

initialization
	RegisterBugReportPlugin('MyPlugin', 'MyPlugin', GetProgramData);
finalization
	UnregisterBugReportPlugin('MyPlugin');
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:

Code: Select all

madExcept,
madLinkDisAsm,
madListHardware,
madListProcesses,
madListModules,
MyDebugUnit in 'MyDebugUnit.pas', // Our madExcept plugin
Forms,
...
Then finally, ensure that the plugin is used by default whenever madExcept gains control - say in the OnCreate handler for your main form:

Code: Select all

MESettings.PluginEnabled['MyPlugin'] := True;	// Enable our plug-in (MyDebugUnit.pas)
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
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Sorry, I think I've misunderstood you.

Your original post was meant to be a help to other people working with madExcept, right? I originally thought you were asking for my help... :D
Markham
Posts: 26
Joined: Wed Nov 02, 2005 11:46 am

Post by Markham »

Yes, my post is a tip to other users who may not realise that the plugin feature can be used to provide application-specific runtime information.


Mark
Post Reply