Sign in Join

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

Mailing lists / fpc-devel / 2011-09

Calling methods from within gdb

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Joost van der Sluis

Hi all,

Does someone knows a trick how to make gdb call a method (function) from a class?

When I have this class defined, compiled with dwarf2: (-gw3 gives an IE, I'll have a look at that too)

type
  TMyClass = class
  public
    function Read: integer;
  end;
ptype returns:
(gdb) ptype aclass
type = ^TMYCLASS = class : public TOBJECT
  public
    function  READ () : LONGINT;
end

Which seems ok to me, but something like print or call gives: (gdb) call aclass^.READ()
Type TMYCLASS = class has no component named READ().

Is there some syntactical trick that makes this work, or do I have to debug gdb again?

Jonas Maebe
to Joost van der Sluis
Joost van der Sluis wrote
Does someone knows a trick how to make gdb call a method (function) from a class?

It requires a patch to gdb. I'm fairly sure I already sent it to you in the past. It was part of an, incomplete, patch set to also add support for the Borland fastcall calling convention. The patch to add the method calling support was a hack though.

I don't have those patches anymore because they were on a laptop that was stolen last year, but they may still be somewhere in my mail archive (I think I also sent them to Pierre once). I can only search for them in my mail tomorrow though (after having two laptops stolen, I've stopped allowing my mail client to cache my entire IMAP account locally; I'm not interested in the overhead of whole disk or home directory encryption).

Jonas

Joost van der Sluis
to Jonas Maebe
Jonas Maebe wrote 6 lines
On 12 Sep 2011, at 22:05, Joost van der Sluis wrote: > Does someone knows a trick how to make gdb call a method (function) from > a class? It requires a patch to gdb. I'm fairly sure I already sent it to you in the past. It was part of an, incomplete, patch set to also add support for the Borland fastcall calling convention. The patch to add the method calling support was a hack though.

I think I have that patch applied. Calling functions in itself does work, even when they use Borland fastcall. The problem is that it does not work for a method, this inside a class.

I'll have a look at those patches again. (I still have them)

Joost

Jonas Maebe
to Joost van der Sluis
Joost van der Sluis wrote
I think I have that patch applied. Calling functions in itself does work, even when they use Borland fastcall. The problem is that it does not work for a method, this inside a class.

I've found the patch again: http://www.hu.freepascal.org/lists/fpc-devel/2010-March/019626.html

There's also another patch, which makes sure that the calling convention is properly set for method calls: http://sourceware.org/ml/gdb-patches/2009-04/msg00110.html

Jonas