Sign in Join

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

Mailing lists / fpc-pascal / 2004-10

how to locate address of method name table (cvs build)

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Dean Zobec

Using the recent cvs builds of the compiler I was unable to locate the address of the method name table. Here is a test that works with version 1.9.4 but does not work in 1.9.5 anymore:

program prova;
uses
  classes;
type
{$M+}
  TTestCaseTest = class(TObject)
  published
    procedure TestSetUp;
    procedure TestAsString;
  end;
procedure TTestCaseTest.TestSetup;
begin
  writeln('TestSetup');
end;
procedure TTestCaseTest.TestAsString;
begin
  writeln('TestAsString');
end;
function GetMethodNameTableAddress(AClass: TClass): Pointer;
type
  TMethodNameRec = packed record
    name : pshortstring;
    addr : pointer;
  end;
  TMethodNameTable = packed record
    count : dword;
    entries : packed array[0..0] of TMethodNameRec;
  end;
  pMethodNameTable =  ^TMethodNameTable;
var
  methodTable : pMethodNameTable;
  vmt: TClass;
begin
  vmt := aClass;
  if assigned(vmt) then
  begin
    methodTable := pMethodNameTable((Pointer(vmt) + vmtMethodTable)^);
    Result := methodTable;
  end;
end;
begin
  writeln('Address of TestSetUp : ',
longint(TTestCaseTest.MethodAddress('TestSetUp')));
  writeln('Address of TestAsString : ',
longint(TTestCaseTest.MethodAddress('TestAsString')));
  writeln(Assigned(GetMethodNameTableAddress(TTestCaseTest)));
end.

The function GetMethodNameTableAddress allways returns nil. Any idea about how to fix it?

Ciao,
Dean

Peter Vreman
to Dean Zobec
you wrote
Using the recent cvs builds of the compiler I was unable to locate the address of the method name table. Here is a test that works with version 1.9.4 but does not work in 1.9.5 anymore:

It was a recently introduced bug, Fixed

Peter

Dean Zobec
to Peter Vreman

Alle 16:03, domenica 24 ottobre 2004, Peter Vreman ha scritto:

Show quoted text 9 lines
At 17:55 22-10-2004, you wrote: >Using the recent cvs builds of the compiler I was unable to locate the >address >of the method name table. Here is a test that works with version 1.9.4 but >does not work in 1.9.5 anymore: It was a recently introduced bug, Fixed Peter

Thank you for the prompt fix Peter. I've just rebuilt the compiler and it's all ok now.
Ciao,
Dean