Delphi obtain stack trace after exception -
i'm trying figure out how obtain stack trace after exception thrown in delphi. however, when try read stack in application.onexception event using function below, stack seems flushed , replaced throwing procedures.
function getstackreport: ansistring; var retaddr, walker: ^pointer; begin // ... // history of stack, ignore esp frame asm mov walker, ebp end; // assume return address present above ebp while cardinal(walker^) <> 0 begin retaddr := walker; inc(retaddr); result := result + addressinfo(cardinal(retaddr^)); walker := walker^; end; end;
here's kind of results i'm getting:
001a63e3: tapplication.handleexception (forms) 00129072: stdwndproc (classes) 001a60b0: tapplication.processmessage (forms)
that's not i'm looking for, although it's correct. i'd retrieve stack before exception thrown, or in other words contents before (after too) onexception call.
is there way that?
i aware i'm reinventing wheel, because folks on @ madexcept/eurekalog/jcldebug have done this, i'd know how it's done.
it not possible manually obtain viable stack trace inside onexception
event. have noticed, stack @ time of error gone time event triggered. looking requires obtaining stack trace @ time exception raised. third-party exception loggers, madexcept, eurekalog, etc handle details hooking key functions , core exception handlers inside of rtl itself.
in recent delphi versions, sysutils.exception
class have public stacktrace
, stackinfo
properties now, useful in onexception
event except fact embarcadero has chosen not implement properties natively unknown reasons. requires third-party exception loggers assign handlers various callbacks exposed exception
class generate stack trace data properties. if have jcldebug installed, instance, provide own callback handlers in own code use jcl's stack tracing functions generate stack data properties.
Comments
Post a Comment