在 Free Pascal 中捕获堆栈跟踪
我有一个用 Free Pascal 编写的控制台应用程序,与大多数大型应用程序一样,它有时会崩溃。由于这个应用程序是实时的,我通常会要求人们在崩溃时写下堆栈跟踪——我将它与调试和线路信息一起分发。但是,应用程序使用 FPC video.pas 输出,有时文本输出堆栈跟踪不可见。
有没有办法通过堆栈跟踪拦截在未处理的异常上写入的文本,以便我可以将其写入文件?我不能只是将标准错误传输到文件,因为 FPC 视频在某种程度上不能与此一起工作,而且我希望人们只运行可执行文件而不是批处理或 shell 文件。
举个例子,我想将其捕获到文件或其他输出源:
ERangeError : Range check error∙
$0048C0EA TCELLS__GETCELL, line 104 of dfmap.pas
$004AD133 TDOOMGENERATOR__GENERATECITYDUNGEON, line 397 of dfdungen.pas
$004AF87D TDOOMGENERATOR__GENERATE, line 760 of dfdungen.pas
$0041293B TDOOM__RUN, line 354 of doombase.pas
$00401CD6 main, line 51 of doomrl.pas
有可能干净地做到这一点吗?
I have a console application written in Free Pascal, that like most larger applications sometimes crashes. As this application is live, I usually ask people to write me down the stack-trace on crash -- I distribute it with both debug and lineinfo. However, the application uses FPC video.pas output, and sometimes the text output stacktrace is not visible.
Is there a way to intercept the text that is written on unhandled exceptions WITH the stack trace, so I can write it to file? I can't just pipe standard error to a file, because FPC video somehow doesn't work with that, and also I'd like people just running the executable not a batch or shell file.
As an example, I'd like to catch this to a file or other output source:
ERangeError : Range check error∙
$0048C0EA TCELLS__GETCELL, line 104 of dfmap.pas
$004AD133 TDOOMGENERATOR__GENERATECITYDUNGEON, line 397 of dfdungen.pas
$004AF87D TDOOMGENERATOR__GENERATE, line 760 of dfdungen.pas
$0041293B TDOOM__RUN, line 354 of doombase.pas
$00401CD6 main, line 51 of doomrl.pas
Any possibility to do that cleanly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
涉及两个(系统单元)过程变量:
当前的处理 iirc 是分层的,
简而言之:
请注意,当您执行以下操作时,将隐式包含 lineinfo 单元 -格
There are two (system unit) procedure variables involved:
The current handling iirc is layered
So in short:
Note that the lineinfo unit is implicitely included when you do -gl