From 42a7fd55fe35fb375c461d621d2e1f638ad9bf65 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 4 Mar 2011 16:49:25 +0100 Subject: [PATCH] debugger: add dumper for boost::shared_ptr --- share/qtcreator/gdbmacros/gdbmacros.py | 38 ++++++++++++++++++- .../gdbdebugger/simple/simple_gdbtest_app.cpp | 22 ++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/share/qtcreator/gdbmacros/gdbmacros.py b/share/qtcreator/gdbmacros/gdbmacros.py index ef5a50dfbdc..b2965641de9 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.py +++ b/share/qtcreator/gdbmacros/gdbmacros.py @@ -1661,8 +1661,8 @@ def qdump__QWeakPointer(d, item): check(int(strongref) <= int(weakref)) check(int(weakref) <= 10*1000*1000) - innerType = templateArgument(item.value.type, 0) if isSimpleType(value.dereference().type): + d.putNumChild(3) d.putItem(Item(value.dereference(), item.iname, None)) else: d.putValue("") @@ -1969,6 +1969,42 @@ def qdump__boost__optional(d, item): value = storage.cast(type) d.putItem(Item(value, item.iname)) +def qdump__boost__shared_ptr(d, item): + # s boost::shared_ptr + # pn boost::detail::shared_count + # pi_ 0x0 boost::detail::sp_counted_base * + # px 0x0 int * + if isNull(item.value["pn"]["pi_"]): + d.putValue("(null)") + d.putNumChild(0) + return + + if isNull(item.value["px"]): + d.putValue("(null)") + d.putNumChild(0) + return + + countedbase = item.value["pn"]["pi_"].dereference() + weakcount = countedbase["weak_count_"] + usecount = countedbase["use_count_"] + check(int(weakcount) >= 0) + check(int(weakcount) <= int(usecount)) + check(int(usecount) <= 10*1000*1000) + + value = item.value["px"].dereference() + if isSimpleType(value.type): + d.putNumChild(3) + d.putItem(Item(value, item.iname, None)) + else: + d.putValue("") + + d.putNumChild(3) + if d.isExpanded(item): + with Children(d, 3): + d.putSubItem(Item(value, item.iname, "data", "data")) + d.putIntItem("weakcount", weakcount) + d.putIntItem("usecount", usecount) + ####################################################################### # diff --git a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp index 8f2598c5c5c..6e3f20957fd 100644 --- a/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp +++ b/tests/manual/gdbdebugger/simple/simple_gdbtest_app.cpp @@ -84,6 +84,11 @@ #include #define USE_PRIVATE 1 +#define USE_BOOST 1 + +#if USE_BOOST +#include +#endif #if USE_PRIVATE #include @@ -105,7 +110,6 @@ #include #include #endif - Q_DECLARE_METATYPE(QHostAddress) Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QStringList) @@ -2361,6 +2365,21 @@ void testQScriptValue(int argc, char *argv[]) QScriptValue d = s.data(); } +void testBoostSharedPtr() +{ +#if USE_BOOST + QSharedPointer qs; + QSharedPointer qi(new int(43)); + QSharedPointer qj = qi; + + boost::shared_ptr s; + boost::shared_ptr i(new int(43)); + boost::shared_ptr j = i; + int k = 2; + ++k; +#endif +} + int main(int argc, char *argv[]) { testPrivate(); @@ -2454,6 +2473,7 @@ int main(int argc, char *argv[]) testQVector(); testQVectorOfQList(); + testBoostSharedPtr(); //*(int *)0 = 0;