[fpc-pascal] showing source linenumbers on exceptions
bbartek at gmx.net
Tue Jun 28 15:57:36 CEST 2005
Vincent Snijders wrote:
> Peter Vreman wrote:
>>> how can i show source line numbers, when an exception occurs, like
>>> sysutils do?
>>> An unhandled exception occurred at $0040E9B5 :
>>> EInOutError : Invalid filename
>>> $0040E9B5 TDXF__LOAD, line 271 of dxffile.pas
>>> $0040EFFA TDXF__CREATE, line 329 of dxffile.pas
>>> $0040F24A TPAPER__CREATE, line 48 of dxfpaper.pas
>>> $00401459 INIT_OBJECTS, line 63 of e:/_development/work/dxf2mcr.pas
>>> $00401529 INITPROC, line 87 of e:/_development/work/dxf2mcr.pas
>>> $00401F1F INIT_FRAMEWORK, line 107 of
>>> the only thing i found is the ShowExeption proc. but this does not
>>> what i expected.
>>> exception at 0040EA45:
>>> Invalid filename.
>>> is there a possibility to do this on my own?
>>> if found the proc:
>>> Procedure CatchUnhandledException (Obj : TObject; Addr: Pointer;
>>> FrameCount: Longint; Frames:
>>> but i don't how to set FrameCount and Frames.
>> The current code in svn trunk contains an ExceptFrames and
>> ExceptFramecount function to return this information. See the lazarus
>> how to use the functions.
> To be precise, in the lclproc unit (lazarus\lcl\lclproc.pas) you can
> find a DumpExceptionBackTrace. If you call this procedure in you
> except block, you get the result that you want.
> If you don't want to add a dependency on the lcl in your code, you can
> copy the code in this procedure and replace debugln by writeln.
> DebugLn is like a writeln, but it can be redirected to file and does
> not crash if it is used in a windows gui application, see
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
thanks, this is exactly what i was looking for!
More information about the fpc-pascal