Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-06

showing source linenumbers on exceptions

7 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bartek

hi,

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
E:/_development/units/uframe_sdlogl.pas
...

the only thing i found is the ShowExeption proc. but this does not write 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:
PPointer);[public,alias:'FPC_BREAK_UNHANDLED_EXCEPTION']; ...
but i don't how to set FrameCount and Frames.

thanks in advance
bartek

Reply by email

Gerhard Scholz
to Bartek

Hi,

compilation with the parameter -gl should do your job:

ppc386 -gl myprogram

(if your compiler name is ppc386, else insert your name instead

Gerhard

Earlier message 46 lines
-----Ursprüngliche Nachricht----- Von: "Bartek" An: Gesendet: Montag, 27. Juni 2005 22:51 Betreff: [fpc-pascal] showing source linenumbers on exceptions > hi, > > 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 > E:/_development/units/uframe_sdlogl.pas > ... > > the only thing i found is the ShowExeption proc. but this does not write > 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: > PPointer);[public,alias:'FPC_BREAK_UNHANDLED_EXCEPTION']; > ... > but i don't how to set FrameCount and Frames. > > thanks in advance > bartek > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >

Reply by email

Peter Vreman
to Bartek: how can i show source line numbers, when an exception occurs, like sysutils do? ... An…
Show quoted text 31 lines
hi, 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 E:/_development/units/uframe_sdlogl.pas ... the only thing i found is the ShowExeption proc. but this does not write 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: PPointer);[public,alias:'FPC_BREAK_UNHANDLED_EXCEPTION']; ... 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 code how to use the functions.

Reply by email

Vincent Snijders
to Peter Vreman
Peter Vreman wrote 37 lines
>hi, > >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 >E:/_development/units/uframe_sdlogl.pas >... > >the only thing i found is the ShowExeption proc. but this does not write >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: >PPointer);[public,alias:'FPC_BREAK_UNHANDLED_EXCEPTION']; >... >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 code 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
http://lazarus-ccr.sourceforge.net/kb/index.php/Lazarus_Faq#How_can_I_see_debug_output.3F)

Vincent.

Reply by email

Bartek
to Vincent Snijders
Vincent Snijders wrote 61 lines
Peter Vreman wrote: >> hi, >> >> 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 >> E:/_development/units/uframe_sdlogl.pas >> ... >> >> the only thing i found is the ShowExeption proc. but this does not >> write >> 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: >> PPointer);[public,alias:'FPC_BREAK_UNHANDLED_EXCEPTION']; >> ... >> 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 > code > 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 http://lazarus-ccr.sourceforge.net/kb/index.php/Lazarus_Faq#How_can_I_see_debug_output.3F) Vincent. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

thanks, this is exactly what i was looking for!

Reply by email

Rolf Grunsky
to Bartek

I am trying to read the VolumeID from a DVD (or a CD) and find that

r := FindFirst(Drive, faVolumeID, Sr);

Does not work (at least not with Win2000.) Not a surprise I suppose since this will not work in OS/2. So the question is, how do I do it? The only reference I can find in the documentation refers to FindFirst/Next which does not work.

Is this something that has been left out?

Cheers
Rolf Grunsky

No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.8.7/34 - Release Date: 29/06/2005

Reply by email

Tomas Hajny
to Rolf Grunsky

Date sent: Thu, 30 Jun 2005 11:49:24 -0400
From: Rolf Grunsky
To: FPC-Pascal users discussions
Subject: [fpc-pascal] How to read VolumeID on a CD (or DVD)? Send reply to: FPC-Pascal users discussions

Show quoted text 10 lines
I am trying to read the VolumeID from a DVD (or a CD) and find that r := FindFirst(Drive, faVolumeID, Sr); Does not work (at least not with Win2000.) Not a surprise I suppose since this will not work in OS/2. So the question is, how do I do it? The only reference I can find in the documentation refers to FindFirst/Next which does not work. Is this something that has been left out?

Well, I'm not sure what you mean exactly. First of all, you're right that FindFirst/Next doesn't provide VolumeID on anything other than plain DOS (it's only emulated even under Dos, in fact). We don't provide platform-independent function to read volume IDs in our RTL (it wouldn't be really platform independent anyway).

If your reference to something "left out" was related to missing documentation for such a function, then I'm sorry, but we don't provide documentation for the complete platform APIs - you need to refer to something like MSDN for Win32 documentation. However, being no Win32 programmer myself, I found function GetVolumeInformation while searching through sources of unit Windows - I guess this should the right bet for you.

Hope this helps

Tomas

Reply by email