Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jan 2000 01:13:32 -0800
From:      Ken Marx <kmarx@bigshed.com>
To:        "freebsd-questions@FreeBSD.ORG" <freebsd-questions@FreeBSD.ORG>
Cc:        Ken Marx <kmarx@bigshed.com>
Subject:   gdb on 3.x/c++ object methods?
Message-ID:  <3885803C.E277D44A@bigshed.com>

next in thread | raw e-mail | index | archive | help
Hi,

I'm trying to access and examine methods of c++ objects on
3.x/4.x boxes using gdb. Gdb seems unable to comply though:

-----------------
(gdb) p bf.geti
Cannot take address of a method
(gdb) p bf.geti()
Cannot resolve method buckfubble::geti to any overloaded instance
-----------------

Anyone know how to get around this. Hard to debug memory corruption
in an object if I can't see what this stuff points to and/or returns.

Thanks in advance,
k.


Here's some sample code that produces the problem for me:
------------------------- <snip>

[weevil] /tmp <182> cat bf.cc 
#include <stdio.h>

class buckfubble
{
public:
    buckfubble( ) {i = 666;}
    ~buckfubble( ) {}

    geti( ) {return i;}

private:

    int i;
};

main()
{
    buckfubble bf;

    printf("i=%d\n", bf.geti());
}
[weevil] /tmp <183> g++ -g3 -O0 bf.cc -o bf
[weevil] /tmp <184> gdb bf
GNU gdb 4.18
Copyright 1998 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 "i386-unknown-freebsd"...
Dynamic symbol table reloading multiple times in one run is on.

(gdb) b 20
Breakpoint 1 at 0x80486c6: file bf.cc, line 20.
(gdb) r
Starting program: /tmp/bf 

Breakpoint 1, main () at bf.cc:20
20          printf("i=%d\n", bf.geti());
(gdb) p bf.geti
Cannot take address of a method
(gdb) p bf.geti()
Cannot resolve method buckfubble::geti to any overloaded instance
-------------------------------------- <snip>
-- 
Ken Marx, kmarx@bigshed.com
We're still on the edge unless we do what we have to do and architect the 
vertical application package.
		- http://cgi.bigshed.com/~kmarx/cgi-bin/speak.cgi


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3885803C.E277D44A>