Which project files need to have madExcept enabled?

delphi package - automated exception handling

Which project files need to have madExcept enabled?

Postby AMMSRU » Wed Mar 27, 2019 2:53 pm

Hi,

I am evaluating madExcept for use with C++ Builder 10.2 in my software and I am wondering exactly how madExcept needs to be enabled in my various projects. I have numerous DLL and BPL files, all of which are used by the main executable and there are other executables (some of which are services that present no UI) that use only some of them.

I know that I will need to enable madExcept on the executables, and configure the exception box settings for the service executables to never show the box and instead always write the bug report to a file. In my understanding that will report on the uncaught exceptions.

I also have cases, mostly in the various low-level DLL files, where an exception is caught so that my software can recover as gracefully as possible but I would like to save the bug report for that exception to a file to allow for further debugging and troubleshooting. I have found that I can call HandleException inside of the "catch" block and that works fine. And so it seems that I will at least need to enable madExcept in the DLL/BPL projects that I want to call HandleException in, as those exceptions will not bubble up to the executable. Is this correct, or is there another way of accomplishing what I am trying to do without enabling madExcept in what will probably end up being nearly all of my DLL/BPL files?

Also, for release builds if madExcept is not enabled for a DLL/BPL module will the necessary information still be available to produce the stack trace? C++ Builder itself doesn't show nice stack traces when an exception happens in the IDE for release builds.

If I do need to enable madExcept in all of my DLL/BPL projects in order to do what I want, will changes to the properties in MESettings need to be made in code in each of the modules separately, or are they global settings for the entire application? It would be nice to not have to duplicate the code for setting those properties in every module, but I'm concerned most about handling the exceptions the proper way given the context of the executable. I can easily set the madExcept settings for each executable based on whether it presents a UI and should show the exception box, but if these settings need to be repeated in each of the low-level DLL files (in order to allow me to call HandleException wherever I want) then that could be problematic since it is a bit more complicated for the DLL to know the context of how it is running.

Thank you very much.


-- Adrian
AMMSRU
 
Posts: 3
Joined: Wed Mar 27, 2019 2:27 pm

Re: Which project files need to have madExcept enabled?

Postby madshi » Wed Mar 27, 2019 9:05 pm

A key question is if all those DLLs and BPLs link to the RTL.bpl or not? Because most of the stuff madExcept does works by hooking into the RTL. If each of your DLLs has its own copy of the RTL linked in, then you'll also have to link madExcept in, because madExcept will then have to hook the RTL in each DLL. But if all your files use the RTL.bpl, then it should be good enough to only link your EXE with madExcept, because the EXE's RTL hooking should then cover all modules in the process.

Generally, if you want to call madExcept.HandleException() in a try..except block, obviously you need to link in madExcept. However, there's a little trick to avoid it: If the module you want to call madExcept::HandleException() in links to RTL.bpl, then you can instead just call SysUtils::ShowException(). This works because madExcept has hooked ShowException() and internally calls madExcept::HandleException() instead.

On the first page of the madExcept settings dialog there's an option named "link in madExcept settings". If you uncheck that in your DLL/BPL projects and only store settings for your EXE files, then all the DLLs and BPLs will share the settings of your EXE file.

In order to create nice callstacks for all your DLL/BPL files, of course madExcept needs to know which function in your DLLs/BPLs have which name etc. So although you don't necessarily have to link in the madExcept code (depending on whether you use RTL.bpl or not), you at least have to "link in function names and line numbers" for every DLL/BPL project. Doing that will make your DLL/BPL files grow by maybe 5% or something. But there will be no actual madExcept code added, as long as you don't activate "link in madExcept code".

Hope that helps?
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm

Re: Which project files need to have madExcept enabled?

Postby madshi » Wed Mar 27, 2019 9:06 pm

P.S: Newer BCB builds have a bug that in release mode RTL and VCL debug information is incomplete. You can workaround that by copying the RTL.lib from your BCB's debug into the release folder. It's ugly, but it seems to do the trick.
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm

Re: Which project files need to have madExcept enabled?

Postby AMMSRU » Thu Mar 28, 2019 12:43 am

Thank you very much for the information.

A key question is if all those DLLs and BPLs link to the RTL.bpl or not?


All of the modules are dynamically linked to the RTL, so this shouldn't be a problem.

In order to create nice callstacks for all your DLL/BPL files, of course madExcept needs to know which function in your DLLs/BPLs have which name etc. So although you don't necessarily have to link in the madExcept code (depending on whether you use RTL.bpl or not), you at least have to "link in function names and line numbers" for every DLL/BPL project.


So, if I understand correctly, in order to get proper call stacks on release builds I will need to enable madExcept on all of the modules but I can un-check "link in madExcept code" and "link in madExcept settings", leaving only "link in function names and line numbers", on everything except the EXEs. Right?

P.S: Newer BCB builds have a bug that in release mode RTL and VCL debug information is incomplete. You can workaround that by copying the RTL.lib from your BCB's debug into the release folder. It's ugly, but it seems to do the trick.


Since all of my modules are dynamically linked to rtl.bpl as opposed to static linking to rtl.lib, does this still apply?

Thanks again!


-- Adrian
AMMSRU
 
Posts: 3
Joined: Wed Mar 27, 2019 2:27 pm

Re: Which project files need to have madExcept enabled?

Postby madshi » Thu Mar 28, 2019 8:12 am

AMMSRU wrote:So, if I understand correctly, in order to get proper call stacks on release builds I will need to enable madExcept on all of the modules but I can un-check "link in madExcept code" and "link in madExcept settings", leaving only "link in function names and line numbers", on everything except the EXEs. Right?

Yes.

AMMSRU wrote:Since all of my modules are dynamically linked to rtl.bpl as opposed to static linking to rtl.lib, does this still apply?

I think not. I'd suggest you simply give it a try. You can use the non-commercial edition for evaluation:

http://madshi.net/madCollectionBeta.exe
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: No registered users and 10 guests

cron