I have the following pascal object:
There is one function 'GETTST2' which returns a number.
Every call to GETTST2 increments the number.
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
i:integer;
public
{ public declarations }
function gettst2:integer;
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var s:string;
j:integer;
begin
j:=2;
s:='Andi'+inttostr(j);
showmessage(s);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
i:=1;
end;
function TForm1.gettst2: integer;
begin
inc(i);
result:=i;
end;
After compilation I start gdb:
andi@athlon-mp ~/lazarus2/dbgtest $ gdb project1
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) break TFORM1__BUTTON1CLICK
Breakpoint 1 at 0x807993b: file unit1.pas, line 36.
(gdb) run
Starting program: /home/andi/lazarus2/dbgtest/project1
Failed to read a valid object file image from memory.
[Thread debugging using libthread_db enabled]
[New Thread -1212778832 (LWP 25239)]
[Switching to Thread -1212778832 (LWP 25239)]
Breakpoint 1, TFORM1__BUTTON1CLICK (SENDER=0xb7b2d5f8, this=0xb7b2c1a8) at unit1.pas:36
36 begin
Current language: auto; currently pascal
(gdb) call TFORM1__GETTST2(this)
$1 = 2
(gdb) call TFORM1__GETTST2(0)
$2 = 3
(gdb) next
37 j:=2;
(gdb)
38 s:='Andi'+inttostr(j);
(gdb)
40 showmessage(s);
(gdb) call TFORM1__GETTST2(this)
$3 = -1208243567
(gdb)
Ok, first question:
As you can see above looking at the first two call statements, it follows that the parameter to the function call is ignored. Why?
Shouldn't it be 'this'
Second, stepping three lines further, the call doesn't work anymore. See result $3. So why is the 'this' pointer not passed to the function?
It looks like if the parameter is ignored at all. Why?
Does anyone know the problem?
Please help me.
Thanks, Andreas