Exceptions in TApplication.OnException have no line info
Original Reporter info from Mantis: dezlov
-
Reporter name: Denis Kozlov
Original Reporter info from Mantis: dezlov
- Reporter name: Denis Kozlov
Description:
I am trying to produce exception call stack with line information for exceptions raised in a GUI app.
I assign an event handler for TApplication.OnException. Inside the event handler procedure, I display the call stack using a slightly modified version of DumpExceptionCallStack function (http://wiki.freepascal.org/Logging_exceptions). Basically, it iterates through ExceptFrames and calls BackTraceStrFunc function.
Unfortunately, BackTraceStrFunc function never produces any line info (line number and source file name). The example project is created using the built-in application template, with "Generate debugging info" and "Display line numbers" enabled by default.
Do exception frames get corrupted somehow, line info retrieval is broken, or am I missing something?
Another strangeness is that if exception is thrown and caught (using try...except), then BackTraceStrFunc function does produce line info BUT only for the first thrown exception, while further exceptions result in the same call stack but without line info.
Tested on Lazarus 1.2.4 and 1.5 r49263, FPC 2.6.4.
Additional information:
function GetExceptionCallStack(E: Exception): String;
var
I: Integer;
Frames: PPointer;
begin
Result := '';
if E <> nil then
begin
Result := Result +
'Exception class: ' + E.ClassName + LineEnding +
'Message: ' + E.Message + LineEnding;
end;
Result := Result + BackTraceStrFunc(ExceptAddr);
Frames := ExceptFrames;
for I := 0 to ExceptFrameCount - 1 do
begin
Result := Result + LineEnding + BackTraceStrFunc(Frames[I]);
end;
end;
Mantis conversion info:
- Mantis ID: 28245
- OS Build: 7
- Build: r49263
- Platform: Windows
- Version: 1.5 (SVN)
- Monitored by: » dezlov (Denis Kozlov)