Page 1 of 1

how to specify settings for CreateBugReport

Posted: Tue Jul 11, 2017 4:14 pm
by bottura
Hi,
i try to specify specific settings when calling CreateBugReport, but it doesn't work ...

MESettings.ShowPleaseWaitBox := false;
MESettings.ListThreads := false;
MESettings.ShowCpuRegisters := false;
MESettings.ShowStackDump := false;
MESettings.ShowDisAsm := false;
MESettings.ShowRelativeAddrs := true;
MESettings.ShowRelativeLines := true;
MESettings.GeneralNoBugReport := false;
str := MadExcept.CreateBugReport(etNormal, E, nil, 0, 0, 0, nil, false, MESettings);

Could you tell me what is wrong ?

I can only specify settings thru the "madexcept settings" option from the Project menu of Delphi ...

Thanks in advance.

Re: how to specify settings for CreateBugReport

Posted: Tue Jul 11, 2017 6:07 pm
by madshi
MESettings() is a function, so I would not advice having dozens of lines calling MESettings() over and over again. My recommendation would be to do something like this:

Code: Select all

var settings : IMESettings;
begin
  settings := MESettings();
  settings.ShowPleaseWaitBox := false;
  ...
  str := madExcept.CreateBugReport(..., settings);
To be honest, though, I'm not sure if changing your code like this will make any practical difference. It's just better (faster) code. In theory I would have expected your code to work. Anyway, can you double check, just to be safe, if changing your code as I suggested helps, before I dig deeper into this?

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 7:09 am
by bottura
I changed my code like this :

madSettings: IMEModuleSettings;

madSettings := MESettings();
madSettings.ListThreads := false;
madSettings.ShowCpuRegisters := false;
madSettings.ShowStackDump := false;
madSettings.ShowDisAsm := false;
madSettings.ShowRelativeAddrs := true;
madSettings.ShowRelativeLines := true;
writeExceptionLog(MadExcept.CreateBugReport(etNormal, E, nil, 0, 0, 0, nil, false, madSettings));

with the same result ...

attached are :
- MoovappsDocumentServer_exception1.log : bugreport when specifying the settings in the code like above
- MoovappsDocumentServer_exception.log : bugreport when specifying the settings thru the project menu option (.mes attached too) = what i'd like to get with the settings in the code ...

Thanks in advance for your help.

PS : we are using the madExcept 4.0 Company Edition (v4.0.16).

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 7:12 am
by bottura
another question : must I free madSettings in my code above ?

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 12:22 pm
by madshi
Hmmmm... I've just tested this code and it works perfectly for me:

Code: Select all

  try
    integer(nil^) := 0;
  except
    madSettings := MESettings();
    madSettings.ListThreads := false;
    madSettings.ShowCpuRegisters := false;
    madSettings.ShowStackDump := false;
    madSettings.ShowDisAsm := false;
    madSettings.ShowRelativeAddrs := true;
    madSettings.ShowRelativeLines := true; 
    FillClipboard(CreateBugReport(etNormal, nil, nil, 0, 0, 0, nil, false, madSettings));
  end;
Can you double check? If it still doesn't work for you, can you please create a little test project and upload it for me?

P.S: You don't have to free madSettings. It's a dynamic interface, so Delphi automatically frees it at the right time, just like dynamic strings, dynamic arrays etc.

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 1:21 pm
by bottura
ok, attached is a small project.

I better see the problem :
- if "enable madexcept" is not checked in the project/madExcept settings, even if i set :
madSettings.ListThreads := false;
in the code, i got the list of the threads in the bugreport ...

then it seems i must check it to be able to specify the settings in the code.

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 1:28 pm
by madshi
Oh, I see. It's unusual that you try to use madExcept functionality without having it "enabled". Why are you doing that? If you don't have madExcept "enabled" then your EXE will also not get the map file information stored into the resource section. So CreateBugReport will not be able to provide function names and line numbers, unless you manually ship with map file with your EXE.

The reason why changing settings in this situation fails is that there are no valid madExcept settings in the project to be found, so the whole MESettings() logic is kinda broken in that situation. I suppose it might be possible to add code to make it work in this specific situation, but to be honest, I think if you don't enable madExcept, then you shouldn't expect it to work.

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 1:45 pm
by bottura
the reason was not to be dependent of the madexcept activation from the IDE.
but with your comment about the map file, it's not pertinent.
I am going to enable it.
Thank you for your support.

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 1:59 pm
by madshi
In which way is being "dependent" on the madExcept action from the IDE problematic for you? Maybe I can suggest something to reduce that problem for you?

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 2:56 pm
by bottura
I have just discovered that we encounter the problem as we are using Delphi's command line tools to build the project.
We use madExceptPatch.exe, but the output of CreateBugReport is the same as if madexcept was disabled in the project setting ...
that is to say the MESettings set in the code are not taken into account.

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 3:34 pm
by madshi
Hmmm... Is madExcept in the "uses" list in your project (*.dpr) file? Please do this:

1) Create an empty file "madExceptWizard.txt" on your desktop.
2) Do batch compiling including madExceptPatch.exe as you usually do.
3) Zip the txt file and attach it here.

Re: how to specify settings for CreateBugReport

Posted: Wed Jul 12, 2017 3:45 pm
by bottura
sorry, the guy who had configured the batch compiling has just told me he didn't do the patch at the right time :-(
After having corrected it, the bugreport is correct.

Thanks again.