I have a codegear C++ builder project and added the JCL library to get a stackdump when an exception occurs. I get the stackdump, but the most important thing is missing, the line number where the exception actually happe开发者_StackOverflow中文版ned. I get the function name, but if the function is 30 lines long it's not easy to guess where the problem is.
Am I missing something here?
I investigate it further and it works for me at least now using Delphi 2007. I think it works the same way for C++ Builder.
My guess is that you have not checked the Debug information also "Use debug DCU's" in compiler options. I tried the included example in JCL that is compiled with Delphi examples\windows\debug\stacktrack\StackTrackDemoMain.pas.
Here is an example of the output:
[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")
NOTE: I have changed in file StackTrackDemoMain.pas method TMainForm.ApplicationEventsException
to
JclLastExceptStackListToStrings(ExceptionLogMemo.Lines, True, False, False, False);
Good luck!
精彩评论