Commit 38905e52 authored by hjk's avatar hjk
Browse files

debugger: fix display of type of dynamic references

This is actually a bug in gdb, but can be worked around.
See http://sourceware.org/bugzilla/show_bug.cgi?id=14077



Change-Id: I5aab39e9a3cfd9d7c12d52339005b1979421229e
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 12e7c262
......@@ -1414,6 +1414,19 @@ class Dumper:
return
except:
pass
try:
# Dynamic references are not supported by gdb, see
# http://sourceware.org/bugzilla/show_bug.cgi?id=14077.
# Find the dynamic type manually using referenced_type.
value = value.referenced_value()
value = value.cast(value.dynamic_type)
self.putItem(value)
self.putBetterType("%s &" % value.type)
return
except:
pass
try:
# FIXME: This throws "RuntimeError: Attempt to dereference a
# generic pointer." with MinGW's gcc 4.5 when it "identifies"
......
......@@ -275,6 +275,21 @@ struct SomeType
} // namespace nsA
struct BaseClass
{
BaseClass() : a(1) {}
virtual ~BaseClass() {}
virtual int foo() { return a; }
int a;
};
struct DerivedClass : BaseClass
{
DerivedClass() : b(2) {}
int foo() { return b; }
int b;
};
namespace multibp {
// This tests multiple breakpoints.
......@@ -4788,6 +4803,20 @@ namespace basic {
dummyStatement(&a, &b, &d);
}
void testDynamicReference()
{
DerivedClass d;
BaseClass *b1 = &d;
BaseClass &b2 = d;
BREAK_HERE;
// CheckType b1 DerivedClass *.
// CheckType b2 DerivedClass &.
// Continue.
int x = b1->foo();
int y = b2.foo();
dummyStatement(&d, &b1, &b2, &x, &y);
}
void testLongEvaluation1()
{
QDateTime time = QDateTime::currentDateTime();
......@@ -4981,6 +5010,7 @@ namespace basic {
testReference1();
testReference2();
testReference3("hello");
testDynamicReference();
testReturn();
testArray1();
testArray2();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment