Exception position in try - catch - block

delphi package - automated exception handling
Post Reply
n2iewerth
Posts: 2
Joined: Wed Dec 19, 2018 9:31 pm

Exception position in try - catch - block

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

Re: Exception position in try - catch - block

Post 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.
n2iewerth
Posts: 2
Joined: Wed Dec 19, 2018 9:31 pm

Re: Exception position in try - catch - block

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

Re: Exception position in try - catch - block

Post 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?
Post Reply