Page 1 of 1

Exception position in try - catch - block

Posted: Thu Dec 20, 2018 10:24 am
by n2iewerth
Hi forum,

I have a question regarding exception location.
When running inside a catch block and an exception occures I can dump the stack trace when entering the catch block.
But I have only the routine where the exception occured and not the exact position inside this routine.
I use the function

AutoSaveBugReport(CreateBugReport())

Does one know how to determin the exact position where an exception occured?

Regards
Norbert

Re: Exception position in try - catch - block

Posted: Sun Dec 23, 2018 1:07 pm
by madshi
Do you need the full bug report, or just the stack trace? If you need just the stack trace, please use "madExcept.GetCrashStackTrace()":

http://help.madshi.net/madExceptUnit.ht ... StackTrace

If you need the full bug report, CreateBugReport() is the right API to use, but then please make sure the first parameter is set to "etNormal".

Also please make sure you run the latest 4.0.21 or 5.0 build, which has some improvements for x64 stack tracing.

Re: Exception position in try - catch - block

Posted: Mon Jan 14, 2019 10:36 am
by n2iewerth
I am using the latest version of MadException (4.0.21)
But I still get just the information of the routine with the try block where the exception occured.
Even a routine inside this try block will not be reported.

Example:

Code: Select all

void foo(char *x)
{
  *x = 0; 
}

void fuu()
{
  try
  {
    foo(NULL); //should crash in foo
  }
  catch(...)
  {
    AutoSaveBugReport(CreateBugReport(etNormal)); //no foo here in; last position is fuu that is reported
  }  
}
I would like to see the line number of foo in the crash report (because here the exception occured)

Is this possible?

Re: Exception position in try - catch - block

Posted: Mon Jan 14, 2019 1:45 pm
by madshi
Just tested your exact code and it produces a perfect bug report on my PC. Testing with BCB 10.3 32bit, using classic compiler.

Do you have madExcept enabled in your project? Does madExcept automatically catch exceptions, if you don't use a try..except/catch block?