Sign in Join

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

Mailing lists / fpc-devel / 2010-08

LineInfo unit seems broken in 2.5.1

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

Not sure if this affects 2.4.x as well (I haven't tested yet). DUnit2 unit testing framework tries to report the line number and method that caused a unit test failure. Under 64-bit systems, the method name information is unknown (always blank) - it at least works under 32-bit systems. And under both 64-bit and 32-bit, the line number information is total rubbish. It reports line numbers that aren't even close to where the information (caller method) occurs.

I'm pretty sure if I use fpcunit, I'll probably get the same results because the code I use in DUnit2 is near identical to FPCUnit's. I tried with DUnit2, and with a stand-alone app that requests line info when entering and exiting a method/procedure/function. Every time the results are as described above.

Below is my standalone test application...

----------------[  lineinfotest1.pas ]--------------------------
program testlineinfo1;
{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
{$ifdef mswindows}{$apptype console}{$endif}
uses
 sysutils;
type
  MyClass = class(TObject)
  public
    procedure Run;
    procedure RunTwo;
  end;
procedure ReportLineInfo(position: string; frame_pointer: pointer);
var
  caller_addr: Pointer;
  func, source: shortstring;
  line: longint;
  sline: string;
begin
  func := '';
  source := '';
  line := 0;
  caller_addr := get_caller_addr(frame_pointer);
  GetLineInfo(ptruint(caller_addr), func, source, line);
  str(line, sline);
  Writeln(position, ' ', func, ' ', source, ' ', sline);
end;
procedure MyClass.Run;
begin
  ReportLineInfo('MyClass.Run [32] >', get_frame);
  writeln('inside MyClass.Run...');
  RunTwo;
  ReportLineInfo('MyClass.Run [35] <', get_frame);
end;
procedure MyClass.RunTwo;
begin
  ReportLineInfo('MyClass.RunTwo [40] >', get_frame);
  writeln('inside MyClass.RunTwo...');
  ReportLineInfo('MyClass.RunTwo [42] <', get_frame);
end;
var
  c: MyClass;
begin
  ReportLineInfo('main [48]', get_frame);
  c := MyClass.Create;
  c.Run;
  c.Free;
  ReportLineInfo('main [54]', get_frame);
end.

-------------------------------------------------------------------

Command line to compile above application:

/home/graemeg/programming/fpc-2.5.1/bin/ppc386 -otestlineinfo1.elf32 -l -Mobjfpc -Sh -gl -O- testlineinfo1.pas

And here is the console output on my 32-bit system. I only have a 64-bit system at work, so can only post that output on Monday. But in this output you can already see the line number information being completely rubbish. In square brackets is the real line numbers I typed myself in the first parameter to ReportLineInfo() which is just reference information to compare with LineInfo unit information.

$ ./testlineinfo1.elf32
main [48] 0
MyClass.Run [32] > main testlineinfo1.pas 51
inside MyClass.Run...
MyClass.RunTwo [40] > MYCLASS__RUN testlineinfo1.pas 34 inside MyClass.RunTwo...
MyClass.RunTwo [42] < MYCLASS__RUN testlineinfo1.pas 34 MyClass.Run [35] < main testlineinfo1.pas 51
main [54] 0

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys
Graeme Geldenhuys wrote 10 lines
$ ./testlineinfo1.elf32 main [48]   0 MyClass.Run [32] > main testlineinfo1.pas 51 inside MyClass.Run... MyClass.RunTwo [40] > MYCLASS__RUN testlineinfo1.pas 34 inside MyClass.RunTwo... MyClass.RunTwo [42] < MYCLASS__RUN testlineinfo1.pas 34 MyClass.Run [35] < main testlineinfo1.pas 51 main [54]  0

I managed to SSH into one of our work servers that has an old FPC 2.2.3 (64-bit) compiler installed. I compiled and ran the test app, and even as far back as FPC 2.2.3, the LineInfo unit seems broken, or missing data.

$ ./testlineinfo.elf64
main [48] 0
MyClass.Run [32] > testlineinfo.pas 51
inside MyClass.Run...
MyClass.RunTwo [40] > testlineinfo.pas 34
inside MyClass.RunTwo...
MyClass.RunTwo [42] < testlineinfo.pas 34
MyClass.Run [35] < testlineinfo.pas 51
main [54] 0

As you can see from the output above, the 'func' information is completely missing, and the source code line number information is also wrong (compared to the reference info is square brackets).

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email