madExcept, getting top of current stack

≡放荡痞女 提交于 2019-12-06 03:32:06

问题


In an delphi 2007 application, we have used madExcept to handle exeptions for us. We use the standard dialog, letting the user send us a report with mail if he want to.

We want to add a little to this functionality. If the user choose not to send a full report, we still want to log the exception to a file, but not a full report. We want the exception class and message, and the source file and line number.

The first two is easy, but I can't find a straight forward way of finding the latter.

I have the full exception report in the form of an IMEException interface. As far as I can see, the call stack is available only through the BugReportSections property, which gives me the stack in plain text.

In madStackTrace.pas, there is a StackTrace( )-function that should give me what I want. It takes a lot of parameters, and the documentation is a little short on information..

Question: Does anybody know the right parameters to feed into StackTrace( ), so that it only return the top item of the stack from the thread where the exception was thrown?


回答1:


madStackTrace.pas has another function, StackAddrToStr that just takes a single address and returns the formatted text for it. If you're in the except block for the crashing thread you can pass the global ExceptAddr variable to it. If you're in one of the madExcept callbacks use `IMEException.ExceptAddr' instead.



来源:https://stackoverflow.com/questions/4625364/madexcept-getting-top-of-current-stack

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