Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Exception.StackTrace support for LogException


#1

Hello,

How does this feature work like? I’m calling SiMain.logException( exception,“info”) inside my code, but Console v.3.2.0.8449 shows only Exception.message property. I couldn’t find exception call stack.

best regards
Piotr Rezmer


#2

Hello Piotr,

the StackTrace property of the Exception class is a new feature of Delphi 2009. The LogException method has been extended to make use of this new property when available. The Exception class does not really provide a stack trace by itself but rather provides an interface for installing some kind of stack trace provider. The stack trace provider is responsible for filling the StackTrace property in case of an exception. Exception reporter tools such as Eurekalog or madExcept can install such a provider and provide the necessary information.

So, this new LogException feature essentially depends on the availability of a real stack trace provider.


#3

Thanks for response,
So it is before me to migrate to D2009 existing applications, some weeks of tough work :wink:


#4

Please note that you also need a stack trace provider such as Eurekalog which can install itself into the new Exception API and provides the stack traces. Not sure if Eurekalog (or madExcept) already have support for this feature, though.

We ported the Console to Delphi 2009 as well. It was quite a lot of work to get the 3.2.0 to the current state. We have been using WideStrings and the Tnt controls all over the place, so it was quite time-consuming. We also needed to update all the third-party controls (some by installing new versions from the vendors and others ourselves). However, I think it was well worth it. Delphi 2009 seems to be a pretty good release and we could finally throw out all the Tnt and WideString related code.


#5

[quote=tgurock]Hello Piotr,

the StackTrace property of the Exception class is a new feature of Delphi 2009. The LogException method has been extended to make use of this new property when available. The Exception class does not really provide a stack trace by itself but rather provides an interface for installing some kind of stack trace provider. The stack trace provider is responsible for filling the StackTrace property in case of an exception. Exception reporter tools such as Eurekalog or madExcept can install such a provider and provide the necessary information.

So, this new LogException feature essentially depends on the availability of a real stack trace provider.[/quote]

Hi, I’ve just tried to have stack trace visible in console. But as before, I have only exception message, without call stack. I activated Eurekalog for this test project but it didn’t help. Can you give me some hints, how to do it?

best regards
Piotr Rezmer


#6

Hello Piotr,

the new StackTrace property of the Delphi Exception class needs a “stack trace provider” to determine the current stack trace.

With this I meant that tools such as Eurekalog or madExcept can and probably will eventually ship with such a provider. Since you don’t see a proper stack trace in the Console, it seems that they do not yet install such a provider. Maybe you can ask Fabio (one of the Eurekalog developers) about a time frame for such a provider?


#7

[quote=tgurock]Hello Piotr,

Maybe you can ask Fabio (one of the Eurekalog developers) about a time frame for such a provider?[/quote]

No problem, but can you help me with specifying the question :expressionless: so that Fabio would understand me what I’m talking about. What kind of interface should such a provider support?

best regards
Piotr Rezmer


#8

Sorry for the late response, Piotr. The Exception class introduced several class variables for registering such a stack trace provider, for example:

[code]Exception = class(TObject)

class var
// Hook this function to return an opaque data structure that
// contains stack information for the given exception information
// record. This function will be called when the exception is
// about to be raised or if this is an external exception such as an
// Access Violation, called soon after the object is created.
GetExceptionStackInfoProc: function (P: PExceptionRecord): Pointer;

// This function is called to return a string representation of the
// above opaque data structure
GetStackInfoStringProc: function (Info: Pointer): string;

[/code]

I’m pretty sure if you mention the stack trace provider API and point Fabio to these class variables, then he will know what you are talking about. Or, alternatively, point him to this forum topic. This should do the trick as well. Hope this helps.


#9

[quote=tgurock]
I’m pretty sure if you mention the stack trace provider API and point Fabio to these class variables, then he will know what you are talking about. Or, alternatively, point him to this forum topic. This should do the trick as well. Hope this helps.[/quote]

Hi, the feature is scheduled on version 7. of eurekalog. Currently, there’s a function getlastExceptionStack() which returns:

TEurekaStackList = class(TList)
public

property Items[Index: Integer]: PEurekaDebugInfo read GetItem; default;
end;


#10

Good news and thanks for the update! Looking forward to the new version.