2

我有一个 codegear C++ 构建器项目,并添加了 JCL 库以在发生异常时获取堆栈转储。我得到了堆栈转储,但最重要的是缺少实际发生异常的行号。我得到了函数名,但如果函数有 30 行长,就不容易猜出问题出在哪里。

我在这里错过了什么吗?

4

1 回答 1

1

我进一步调查它,它至少现在使用 Delphi 2007 对我有用。我认为它对 C++ Builder 的工作方式相同。

我的猜测是您没有在编译器选项中检查调试信息以及“使用调试 DCU”。我尝试了使用 Delphi examples\windows\debug\stacktrack\StackTrackDemoMain.pas编译的 JCL 中包含的示例 。

以下是输出示例:

[0047C478]{StackTrackExample.exe} StackTrackDemoMain.TMainForm.Button1Click (Line 49, "StackTrackDemoMain.pas")
[00442590]{StackTrackExample.exe} Controls.TControl.Click (Line 5229, "Controls.pas")
[00446083]{StackTrackExample.exe} Controls.TWinControl.WndProc (Line 7304, "Controls.pas")
[0042ECB8]{StackTrackExample.exe} StdCtrls.TButtonControl.WndProc (Line 3684, "StdCtrls.pas")
[004461D3]{StackTrackExample.exe} Controls.DoControlMsg (Line 7353, "Controls.pas")
[00446083]{StackTrackExample.exe} Controls.TWinControl.WndProc (Line 7304, "Controls.pas")
[004577A3]{StackTrackExample.exe} Forms.TCustomForm.WndProc (Line 3512, "Forms.pas")
[004457AC]{StackTrackExample.exe} Controls.TWinControl.MainWndProc (Line 7073, "Controls.pas")
[0041EC14]{StackTrackExample.exe} Classes.StdWndProc (Line 11583, "common\Classes.pas")
[0044617F]{StackTrackExample.exe} Controls.TWinControl.DefaultHandler (Line 7334, "Controls.pas")
[00446083]{StackTrackExample.exe} Controls.TWinControl.WndProc (Line 7304, "Controls.pas")
[0042ECB8]{StackTrackExample.exe} StdCtrls.TButtonControl.WndProc (Line 3684, "StdCtrls.pas")
[0041EC14]{StackTrackExample.exe} Classes.StdWndProc (Line 11583, "common\Classes.pas")

注意:我已更改文件 StackTrackDemoMain.pas 方法 TMainForm.ApplicationEventsException

JclLastExceptStackListToStrings(ExceptionLogMemo.Lines, True, False, False, False);

祝你好运!

于 2010-11-13T15:28:58.940 回答