[Lazarus] Listing out a call stack...
Graeme Geldenhuys
graemeg.lists at gmail.com
Mon Aug 25 14:04:24 CEST 2008
On 8/25/08, Dominique Louis <dominique at savagesoftware.com.au> wrote:
> Hi all,
> Is there anyway for me to output a call stack at run-time?
----------------------------------------------------
procedure DumpStack;
Var
Message : String;
i : longint;
begin
writeln(' Stack trace:');
// Dump_Stack(StdOut, get_frame);
Writeln(stdout,'An unhandled exception occurred at
$',HexStr(Ptrint(ExceptAddr),sizeof(PtrInt)*2),' :');
if ExceptObject is exception then
begin
Message:=Exception(ExceptObject).ClassName+' :
'+Exception(ExceptObject).Message;
Writeln(stdout,Message);
end
else
Writeln(stdout,'Exception object ',ExceptObject.ClassName,' is not
of class Exception.');
Writeln(stdout,BackTraceStrFunc(ExceptAddr));
if (ExceptFrameCount>0) then
begin
for i:=0 to ExceptFrameCount-1 do
Writeln(stdout,BackTraceStrFunc(ExceptFrames[i]));
end;
Writeln(stdout,'');
end;
----------------------------------------------------
Please note that the above needs stdout to be available, so Windows
applications must be compiler without gui option enabled (-WG must not
be specified).
I think there is such a function in LCLProc unit as well...
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
More information about the Lazarus
mailing list