debugger: fix display of member function pointers

Change-Id: I957e805aad45bf62b6fb8318accd29f54b474b11
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2012-07-19 11:33:45 +02:00
parent e0e8cf3ada
commit d92df40125
3 changed files with 53 additions and 11 deletions

View File

@@ -334,8 +334,8 @@ try:
#BitStringCode = gdb.TYPE_CODE_BITSTRING
#ErrorTypeCode = gdb.TYPE_CODE_ERROR
MethodCode = gdb.TYPE_CODE_METHOD
#MethodPointerCode = gdb.TYPE_CODE_METHODPTR
#MemberPointerCode = gdb.TYPE_CODE_MEMBERPTR
MethodPointerCode = gdb.TYPE_CODE_METHODPTR
MemberPointerCode = gdb.TYPE_CODE_MEMBERPTR
ReferenceCode = gdb.TYPE_CODE_REF
CharCode = gdb.TYPE_CODE_CHAR
BoolCode = gdb.TYPE_CODE_BOOL

View File

@@ -1616,6 +1616,13 @@ class Dumper:
self.putPointerValue(value.address)
return
if type.code == MethodPointerCode or type.code == MemberPointerCode:
self.putType(typeName)
self.putAddress(value.address)
self.putValue(value)
self.putNumChild(0)
return
if typeName.startswith("<anon"):
# Anonymous union. We need a dummy name to distinguish
# multiple anonymous unions in the struct.

View File

@@ -4971,21 +4971,54 @@ namespace basic {
dummyStatement(&ba);
}
void testFunctionPointerHelper() {}
static int someData;
int testFunctionPointerHelper(int x) { return x; }
void testFunctionPointer()
{
typedef void (*func_t)();
func_t f2 = testFunctionPointerHelper;
int *p = &someData;
typedef int (*func_t)(int);
func_t f = testFunctionPointerHelper;
int a = f(43);
BREAK_HERE;
// CheckType f2 basic::func_t.
// CheckType f basic::func_t.
// Continue.
// Check there's a valid display for f2.
dummyStatement(&f2, p);
// Check there's a valid display for f.
dummyStatement(&f, &a);
}
struct Class
{
Class() : a(34) {}
int testFunctionPointerHelper(int x) { return x; }
int a;
};
void testMemberFunctionPointer()
{
Class x;
typedef int (Class::*func_t)(int);
func_t f = &Class::testFunctionPointerHelper;
int a = (x.*f)(43);
BREAK_HERE;
// CheckType f basic::func_t.
// Continue.
// Check there's a valid display for f.
dummyStatement(&f, &a);
}
void testMemberPointer()
{
Class x;
typedef int (Class::*member_t);
member_t m = &Class::a;
int a = x.*m;
BREAK_HERE;
// CheckType m basic::member_t.
// Continue.
// Check there's a valid display for m.
dummyStatement(&m, &a);
}
void testPassByReferenceHelper(Foo &f)
@@ -5139,6 +5172,8 @@ namespace basic {
testLongEvaluation2();
testFork();
testFunctionPointer();
testMemberPointer();
testMemberFunctionPointer();
testPassByReference();
testBigInt();
testHidden();