Commit dc67ea92 authored by hjk's avatar hjk
Browse files

debugger: add pretty printer for std::shared_ptr



... and polish the std::unique_ptr dumper.

Change-Id: Icbfb7241ae535e833dd983921da6e16fdb2225db
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 40b63bde
......@@ -1924,6 +1924,27 @@ def qdump__std__string(d, value):
d.putNumChild(0)
def qdump__std__shared_ptr(d, value):
i = value["_M_ptr"]
if isNull(i):
d.putValue("(null)")
d.putNumChild(0)
return
if isSimpleType(templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference(), long(i)))
else:
i = expensiveUpcast(i)
d.putValue("@0x%x" % long(i))
d.putNumChild(3)
with Children(d, 3):
d.putSubItem("data", i)
refcount = value["_M_refcount"]["_M_pi"]
d.putIntItem("usecount", refcount["_M_use_count"])
d.putIntItem("weakcount", refcount["_M_weak_count"])
def qdump__std__unique_ptr(d, value):
i = value["_M_t"]["_M_head_impl"]
if isNull(i):
......@@ -1931,9 +1952,12 @@ def qdump__std__unique_ptr(d, value):
d.putNumChild(0)
return
i = expensiveUpcast(i)
if isSimpleType(templateArgument(value.type, 0)):
d.putValue("%s @0x%x" % (i.dereference(), long(i)))
else:
i = expensiveUpcast(i)
d.putValue("@0x%x" % long(i))
d.putValue( "@0x%x" % long(i) )
d.putNumChild(1)
with Children(d, 1):
d.putSubItem("data", i)
......
......@@ -2695,7 +2695,7 @@ namespace stdmap {
namespace stdptr {
void testStdUniquePtr()
void testStdUniquePtrInt()
{
#ifdef USE_CXX11
std::unique_ptr<int> p(new int(32));
......@@ -2706,7 +2706,18 @@ namespace stdptr {
#endif
}
void testStdSharedPtr()
void testStdUniquePtrFoo()
{
#ifdef USE_CXX11
std::unique_ptr<Foo> p(new Foo);
BREAK_HERE;
// Check p 32 std::unique_ptr<Foo, std::default_delete<Foo> >.
// Continue.
dummyStatement(&p);
#endif
}
void testStdSharedPtrInt()
{
#ifdef USE_CXX11
std::shared_ptr<int> p(new int(32));
......@@ -2717,10 +2728,23 @@ namespace stdptr {
#endif
}
void testStdSharedPtrFoo()
{
#ifdef USE_CXX11
std::shared_ptr<Foo> p(new Foo);
BREAK_HERE;
// Check p 32 std::shared_ptr<Foo, std::default_delete<int> >.
// Continue.
dummyStatement(&p);
#endif
}
void testStdPtr()
{
testStdUniquePtr();
testStdSharedPtr();
testStdUniquePtrInt();
testStdUniquePtrFoo();
testStdSharedPtrInt();
testStdSharedPtrFoo();
}
} // namespace stdptr
......
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