Hooking a Stacktrace in Delphi 2009

╄→гoц情女王★ 提交于 2019-12-03 15:28:01

问题


The Exception class in Delphi 2009 received a number of new features. A number of them are related to getting a stacktrace:

  • property StackTrace: string read GetStackTrace;
  • property StackInfo: Pointer read FStackInfo;
  • class var GetExceptionStackInfoProc: function (P: PExceptionRecord): Pointer;
  • class var GetStackInfoStringProc: function (Info: Pointer): string;
  • class var CleanUpStackInfoProc: procedure (Info: Pointer);

Has anyone used these to obtain a stack trace yet? Yeah, I know there are other ways to get a stack trace, but if it is supported natively in the Exception class I would rather leverage that.

Update: There is an interest blog post about this. Covers it in a lot of depth.


回答1:


To me this looks like a framework where you can plug in your own stack tracing. I guess this might be used internally in the IDE with JCLDebug. Perhaps it's intended for users to be able to supply madExcept or another implementation.




回答2:


No, I haven't used them yet (currently using madExcept for that, and also did some experiments with JclDebug) - but thanks for the tip!




回答3:


TOndrej is correct. The new features added to Exception class are for third-parties to hook their own stack tracing code into the RTL. The default implementation of the Exception class does not produce its own stack traces.




回答4:


You would be well advised to look at MadExcept. Not only does it provide excellent handling of any unhandled exceptions (screen grab, email etc) but it has a nice set of callable routines to hand you back a stack trace that you can use almost anywhere. Bri



来源:https://stackoverflow.com/questions/286628/hooking-a-stacktrace-in-delphi-2009

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!