When compiling the following program:
------------------------------
program project1;

uses
  Classes;

var
  i : pinteger;
begin
  i := nil;
  i^ := 0;
end.
------------------------------
with the default compiler options lazarus gives a new program:
   /usr/local/bin/fpc  -MObjFPC -Scgi -O1 -gl -vewnhi -l -Fu.
-oproject1 project1.lpr
and then running it, I get:
$ ./project1
An unhandled exception occurred at $080480B2 :
EAccessViolation : Access violation
  $080480B2  main,  line 10 of project1.lpr

Note the line number in the output.

For another example, here's a "DumpStack" routine you can use to dump
the stack backtrace during runtime:
------------------------------
program project1;

uses
  Classes,
  SysUtils;

  procedure DumpStack ();
  Var
    i : longint;
  begin
    writeln('Exception at $' +
HexStr(Ptrint(ExceptAddr),sizeof(PtrInt)*2) + ':');
    if ExceptObject is Exception then begin
      writeln(Exception(ExceptObject).ClassName+':
'+Exception(ExceptObject).Message);
    end else begin
      writeln('Exception object ' + ExceptObject.ClassName + ' is not
of class Exception.');
    end;
    writeln(BackTraceStrFunc(ExceptAddr));
    if (ExceptFrameCount > 0) then begin
      for i:=0 to ExceptFrameCount-1 do begin
        writeln(BackTraceStrFunc(ExceptFrames[i]));
      end;
    end;
  end;

var
  i : pinteger;
begin
  try
    i := nil;
    i^ := 0;
  except
    on E : Exception do begin
      DumpStack();
    end;
  end;
  writeln('recovered!');
end.
------------------------------

I think you must just not be putting the write compiler options (-g
and -gl) in to get the line numbers in the backtrace, because I rely
on it quite heavily and it "works for me."

-SG

>
> I'm running a custom program under Lazarus control. When occurs an
> exception that I didn't intercept I receive a assembly screen.
>
> For me, it's totally useless. I don't program in assembly.  I know
> lots of programmers that program in  high level languages(as pascal)
> and don't know assembly.
>
> I would like to suggest that Lazarus Team and FPC Team spend efforts
> in develop ways to inform the command line number of the exception.
> Even when I compile in Free Pascal using "-CX -XX -gl" I don't
> receive the line number of the exception.
>
> IMHO, I have no doubts that the command line number information would
> be more useful that the assembly code.
>
> Greatings from Sao Paulo - Brazil
>
> Ricardo

--
This email is fiction. Any resemblance to actual events
or persons living or dead is purely coincidental.

Seth Grover
sethdgrover[at]gmail[dot]com

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to