Commit 9d1bc2fd authored by hjk's avatar hjk

Debugger: Add boost::unordered_set dumper

Change-Id: I42c39ccfe979023e2aa8957132a0ef3404f45aa8
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 8b2cff4b
......@@ -124,3 +124,19 @@ def qdump__boost__posix_time__time_duration(d, value):
d.putNumChild(0)
def qdump__boost__unordered__unordered_set(d, value):
base = d.addressOf(value)
ptrSize = d.ptrSize()
size = d.extractInt(base + 2 * ptrSize)
d.putItemCount(size)
if d.isExpanded():
innerType = d.templateArgument(value.type, 0)
bucketCount = d.extractInt(base + ptrSize)
offset = ((innerType.sizeof + ptrSize - 1) / ptrSize) * ptrSize
with Children(d, size, maxNumChild=10000):
afterBuckets = d.extractPointer(base + 5 * ptrSize)
afterBuckets += bucketCount * ptrSize
item = d.extractPointer(afterBuckets)
for j in d.childRange():
d.putSubItem(j, d.createValue(item - offset, innerType))
item = d.extractPointer(item)
......@@ -218,6 +218,14 @@ QString simplifyType(const QString &typeIn)
if (unorderedSetRE.indexIn(type) != -1)
type.replace(unorderedSetRE.cap(0), QString::fromLatin1("unordered_set<%1>").arg(inner));
// boost::unordered_set
QRegExp boostUnorderedSetRE(QString::fromLatin1("unordered_set<%1, ?boost::hash<%2>, ?std::equal_to<%3>, ?%4\\s*>")
.arg(innerEsc, innerEsc, innerEsc, allocEsc));
boostUnorderedSetRE.setMinimal(true);
QTC_ASSERT(boostUnorderedSetRE.isValid(), return typeIn);
if (boostUnorderedSetRE.indexIn(type) != -1)
type.replace(boostUnorderedSetRE.cap(0), QString::fromLatin1("unordered_set<%1>").arg(inner));
// std::map
if (inner.startsWith(QLatin1String("std::pair<"))) {
// search for outermost ',', split key and value
......
......@@ -5042,6 +5042,29 @@ GdbEngine
+ Check("l.2.second", "65", "double");
QTest::newRow("BoostUnorderedSet")
<< Data("#include <boost/unordered_set.hpp>\n"
"#include <string>\n",
"boost::unordered_set<int> s1;\n"
"s1.insert(11);\n"
"s1.insert(22);\n\n"
"boost::unordered_set<std::string> s2;\n"
"s2.insert(\"abc\");\n"
"s2.insert(\"def\");\n")
+ BoostProfile()
+ Check("s1", "<2 items>", "boost::unordered::unordered_set<int>")
+ Check("s1.0", "[0]", "22", "int")
+ Check("s1.1", "[1]", "11", "int")
+ Check("s2", "<2 items>", "boost::unordered::unordered_set<std::string>")
+ Check("s2.0", "[0]", "\"def\"", "std::string")
+ Check("s2.1", "[1]", "\"abc\"", "std::string");
// // This tests qdump__KRBase in share/qtcreator/debugger/qttypes.py which uses
// // a static typeflag to dispatch to subclasses");
......
......@@ -38,6 +38,8 @@
#include <private/qfileinfo_p.h>
#include <private/qobject_p.h>
#include <boost/unordered/unordered_set.hpp>
class tst_offsets : public QObject
{
Q_OBJECT
......@@ -187,6 +189,16 @@ void tst_offsets::offsets_data()
#endif
}
{
boost::unordered::unordered_set<int> *p = 0;
QTest::newRow("boost::unordered::unordered_set::size")
<< int((char *)&p->table_.size_ - (char *)p) << 8 << 16;
QTest::newRow("boost::unordered::unordered_set::bucket_count")
<< int((char *)&p->table_.bucket_count_ - (char *)p) << 4 << 8;
QTest::newRow("boost::unordered::unordered_set::buckets_")
<< int((char *)&p->table_.buckets_ - (char *)p) << 20 << 40;
}
}
......
......@@ -61,8 +61,10 @@ const char *description[] =
"msvc_stringvector",
"msvc_wstringvector",
"boost_shared_ptr",
"std_shared_ptr",
"boost_shared_ptr",
"boost_unordered_set",
};
const char *input[] =
......@@ -96,10 +98,11 @@ const char *input[] =
"class std::set<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >",
"class std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >",
"class std::vector<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >,std::allocator<std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> > > >",
// boost
"boost::shared_ptr<int>::element_type",
// std
"std::shared_ptr<int>::element_type",
// boost
"boost::shared_ptr<int>::element_type",
"boost::unordered_set<int, boost::hash<int>, std::equal_to<int>, std::allocator<int> >",
};
const char *output[] =
......@@ -128,10 +131,11 @@ const char *output[] =
"std::set<std::string>",
"std::vector<std::string>",
"std::vector<std::wstring>",
// boost
"int",
// std
"int",
// boost
"int",
"boost::unordered_set<int>",
};
class SimplifyTypesTest : public QObject
......
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