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 #BitStringCode = gdb.TYPE_CODE_BITSTRING
#ErrorTypeCode = gdb.TYPE_CODE_ERROR #ErrorTypeCode = gdb.TYPE_CODE_ERROR
MethodCode = gdb.TYPE_CODE_METHOD MethodCode = gdb.TYPE_CODE_METHOD
#MethodPointerCode = gdb.TYPE_CODE_METHODPTR MethodPointerCode = gdb.TYPE_CODE_METHODPTR
#MemberPointerCode = gdb.TYPE_CODE_MEMBERPTR MemberPointerCode = gdb.TYPE_CODE_MEMBERPTR
ReferenceCode = gdb.TYPE_CODE_REF ReferenceCode = gdb.TYPE_CODE_REF
CharCode = gdb.TYPE_CODE_CHAR CharCode = gdb.TYPE_CODE_CHAR
BoolCode = gdb.TYPE_CODE_BOOL BoolCode = gdb.TYPE_CODE_BOOL

View File

@@ -1616,6 +1616,13 @@ class Dumper:
self.putPointerValue(value.address) self.putPointerValue(value.address)
return 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"): if typeName.startswith("<anon"):
# Anonymous union. We need a dummy name to distinguish # Anonymous union. We need a dummy name to distinguish
# multiple anonymous unions in the struct. # multiple anonymous unions in the struct.

View File

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