Sign in Join

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

Mailing lists / lazarus / 2009-10

Lazarus Digest, Vol 21, Issue 14

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Seth Grover

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

Show quoted text 19 lines
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

Reply by email