JclLastExceptStackListToStrings(LLines, True, True, True, True) įunction GetStackInfoStringProc(Info: Pointer): string I’ve built a small unit which demonstrates this with the Jcl in combination with our logging tool SmartInspect and I’ve heard Fabio of Eurekalog is working on a similar feature for his component:įunction GetExceptionStackInfoProc(P: PExceptionRecord): Pointer Though a bit disappointing, the good thing is that there’s now finally a standardized way to get a stack trace, even if it’s not implemented by default.Įxception reporting tools such as Eurekalog or madExcept or debug helpers such as the JclDebug unit can register themselves as providers and use their engines to return a stack trace when an exception is raised. So, without such a provider (and there’s none that comes directly with Delphi), there is still no way to get a stack trace for your exceptions. The initial happiness soon wore off when I realized that the StackTrace property was really just a placeholder to return a stack trace from a possible stack trace provider rather than a real stack trace implementation. So, I was happy to see that Delphi 2009 finally introduced a new StackTrace property which, I hoped, would return a full-blown stack trace when you caught an exception. The features for stack traces during debugging in the IDE are/were okay, but there were nothing in the language or framework which helped you to find out programmatically where an exception occurred at run-time and, more importantly, how it got passed to your exception handler (besides the original exception address, maybe). Unfortunately, Delphi never had good (built-in) run-time support for stack traces. You just call Exception.StackTrace (.NET) or Exception.getStackTrace (Java) and get a detailed analysis of where the exception was thrown and how it got passed to your exception handler. NET and Java have excellent stack trace support built right into the framework and the Exception classes. You know, those useful stack traces that show you exactly where an exception occurred, ideally with the method name and line number of where the exception was raised. One feature I often miss when using Delphi is the support for proper exception stack traces at run-time.