Getting C++Builder stack trace from call site

delphi package - automated exception handling

Getting C++Builder stack trace from call site

Postby jussi » Wed Jun 07, 2017 12:00 pm

I am trying to evaluate madExcept for our BCB 10.2 Tokyo project. We use the 32bit clang toolchain. Everything looks very good apart from not being able to show stack trace which would begin at the original throw site.

So for example:

Code: Select all
void test()
{
    throw new std::exception("test");
}

void __fastcall TForm7::Button2Click(TObject *Sender)
{
    try
    {
        test();
    }
    catch(...)
    {
        HandleException();
    }
}


Will show no exception information (not even EEFFACE, just Unknown) and the stack trace begins from the HandleException line. I would like to see the stack trace start from the throw line.

Code: Select all
main thread ($513fc):
00000000 +000 ???
76527908 +026 USER32.dll                               GetMessageW
004449a3 +2f7 Project17.exe  Madexcept                 HandleException
00404b47 +0df Project17.exe  Unit7.cpp         62   +8 TForm7.Button2Click
50ab5287 +073 vcl250.bpl     Vcl.Controls    7442   +9 TControl.Click
50adaf8a +01e vcl250.bpl     Vcl.StdCtrls    5441   +3 TCustomButton.Click
50adba98 +010 vcl250.bpl     Vcl.StdCtrls    5902   +1 TCustomButton.CNCommand


If the try/catch is commented out and madExcept handles the exception in Delphi side, it works as expected:

Code: Select all
void __fastcall TForm7::Button2Click(TObject *Sender)
{
    //try
    //{
        test();
    //}
    //catch(...)
    //{
    //    HandleException();
    //}
}


Code: Select all
main thread ($50e18):
75efc41f +058 KERNELBASE.dll                          RaiseException
3222d751 +07d CC32C250MT.DLL                          ___cxa_throw
004045a7 +0d7 Project17.exe  Unit7.cpp        28   +2 test
00404a74 +00c Project17.exe  Unit7.cpp        58   +4 TForm7.Button2Click
50ab5287 +073 vcl250.bpl     Vcl.Controls   7442   +9 TControl.Click
50adaf8a +01e vcl250.bpl     Vcl.StdCtrls   5441   +3 TCustomButton.Click
50adba98 +010 vcl250.bpl     Vcl.StdCtrls   5902   +1 TCustomButton.CNCommand


Should this work in c++ code?

Thanks!

Jussi
jussi
 
Posts: 3
Joined: Wed Jun 07, 2017 11:27 am

Re: Getting C++Builder stack trace from call site

Postby madshi » Wed Jun 14, 2017 9:20 am

That actually is supposed to work, I'm not sure why it fails. Could it have to do with runtime packages being enabled or disabled, or dynamic RTL being enabled or disabled? These 2 options result in 4 different possible situations which madExcept needs to handle. Does switching those options make any difference?

Does this problem only occur in your main project, or also in a brand new almost empty test project?
madshi
Site Admin
 
Posts: 9387
Joined: Sun Mar 21, 2004 5:25 pm

Re: Getting C++Builder stack trace from call site

Postby jussi » Wed Jun 14, 2017 1:37 pm

I tried all the different options (runtime packages and dynamic RTL) with the same result. The project was created just for this. I now did a new fresh project just to check and the trace is now good!

I did have to modify some library paths for the first project before it found madexcept.obj or similar. Now I did not have to do that.
jussi
 
Posts: 3
Joined: Wed Jun 07, 2017 11:27 am

Re: Getting C++Builder stack trace from call site

Postby madshi » Wed Jun 14, 2017 1:41 pm

Strange! So it works now with the brand new project? I'm not sure why it didn't work before!

Anyway, does this mean the problem is "solved" for you?
madshi
Site Admin
 
Posts: 9387
Joined: Sun Mar 21, 2004 5:25 pm

Re: Getting C++Builder stack trace from call site

Postby jussi » Fri Jun 16, 2017 9:45 am

Yes. It is now solved. Thank you!
jussi
 
Posts: 3
Joined: Wed Jun 07, 2017 11:27 am


Return to madExcept

Who is online

Users browsing this forum: No registered users and 2 guests