diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-07-03 13:56:27 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-07-03 13:56:27 +0200 |
commit | 5a8b61b2ee6a9ebcb91f351bb0212f6ad40f9064 (patch) | |
tree | 3e26c4664a1870c64743c4da501db3bfa404160f /share | |
parent | 89d49e3b2052ef96245e5e786d5f509ba4ac818b (diff) | |
download | qt-creator-5a8b61b2ee6a9ebcb91f351bb0212f6ad40f9064.tar.gz |
Great debugger helper bug fixing spree.
- Fix extractTemplate() not to kill blanks in case there is no
blank after a comma, fix hardcoded types accordingly.
- Make niceType()'s regexps ignore blanks after commas, add
unsigned short as char_type and cache the mappings, making
them work for CDB.
- CDB: Parse map output of dumpers correctly, generally don't
confuse the parser by unknown keywords encountered when
parsing children, thus enabling simple QMap types.
- Make dumpInnerValueHelper output std::string types.
Diffstat (limited to 'share')
-rw-r--r-- | share/qtcreator/gdbmacros/gdbmacros.cpp | 66 | ||||
-rw-r--r-- | share/qtcreator/gdbmacros/test/main.cpp | 14 |
2 files changed, 58 insertions, 22 deletions
diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index 29b6feed76..156bfc5e3f 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -844,6 +844,26 @@ static void qDumpUnknown(QDumper &d, const char *why = 0) d.disarm(); } +static inline void dumpStdStringValue(QDumper &d, const std::string &str) +{ + d.beginItem("value"); + d.putBase64Encoded(str.c_str(), str.size()); + d.endItem(); + d.putItem("valueencoded", "1"); + d.putItem("type", "std::string"); + d.putItem("numchild", "0"); +} + +static inline void dumpStdWStringValue(QDumper &d, const std::wstring &str) +{ + d.beginItem("value"); + d.putBase64Encoded((const char *)str.c_str(), str.size() * sizeof(wchar_t)); + d.endItem(); + d.putItem("valueencoded", (sizeof(wchar_t) == 2 ? "2" : "3")); + d.putItem("type", "std::wstring"); + d.putItem("numchild", "0"); +} + static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr, const char *field = "value") { @@ -928,6 +948,16 @@ static void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr d.putItem(field, *(QString*)addr); } return; + case 't': + if (isEqual(type, "std::string") + || isEqual(type, "std::basic_string<char,std::char_traits<char>,std::allocator<char> >")) { + d.putCommaIfNeeded(); + dumpStdStringValue(d, *reinterpret_cast<const std::string*>(addr)); + } else if (isEqual(type, "std::wstring") + || isEqual(type, "std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >")) { + dumpStdWStringValue(d, *reinterpret_cast<const std::wstring*>(addr)); + } + return; default: return; } @@ -944,7 +974,6 @@ static void qDumpInnerValue(QDumper &d, const char *type, const void *addr) qDumpInnerValueHelper(d, type, addr); } - static void qDumpInnerValueOrPointer(QDumper &d, const char *type, const char *strippedtype, const void *addr) { @@ -2753,37 +2782,28 @@ static void qDumpStdString(QDumper &d) { const std::string &str = *reinterpret_cast<const std::string *>(d.data); - if (!str.empty()) { + const std::string::size_type size = str.size(); + if (int(size) < 0) + return; + if (size) { qCheckAccess(str.c_str()); - qCheckAccess(str.c_str() + str.size() - 1); + qCheckAccess(str.c_str() + size - 1); } - - d.beginItem("value"); - d.putBase64Encoded(str.c_str(), str.size()); - d.endItem(); - d.putItem("valueencoded", "1"); - d.putItem("type", "std::string"); - d.putItem("numchild", "0"); - + dumpStdStringValue(d, str); d.disarm(); } static void qDumpStdWString(QDumper &d) { const std::wstring &str = *reinterpret_cast<const std::wstring *>(d.data); - - if (!str.empty()) { + const std::wstring::size_type size = str.size(); + if (int(size) < 0) + return; + if (size) { qCheckAccess(str.c_str()); - qCheckAccess(str.c_str() + str.size() - 1); + qCheckAccess(str.c_str() + size - 1); } - - d.beginItem("value"); - d.putBase64Encoded((const char *)str.c_str(), str.size() * sizeof(wchar_t)); - d.endItem(); - d.putItem("valueencoded", (sizeof(wchar_t) == 2 ? "2" : "3")); - d.putItem("type", "std::wstring"); - d.putItem("numchild", "0"); - + dumpStdWStringValue(d, str); d.disarm(); } @@ -3164,6 +3184,8 @@ void *qDumpObjectData440( .put("std::string=\"").put(sizeof(std::string)).put("\",") .put("std::wstring=\"").put(sizeof(std::wstring)).put("\",") .put("std::allocator=\"").put(sizeof(std::allocator<int>)).put("\",") + .put("std::char_traits<char>=\"").put(sizeof(std::char_traits<char>)).put("\",") + .put("std::char_traits<unsigned short>=\"").put(sizeof(std::char_traits<unsigned short>)).put("\",") #if QT_VERSION >= 0x040500 .put(NS"QSharedPointer=\"").put(sizeof(QSharedPointer<int>)).put("\",") .put(NS"QSharedDataPointer=\"").put(sizeof(QSharedDataPointer<QSharedData>)).put("\",") diff --git a/share/qtcreator/gdbmacros/test/main.cpp b/share/qtcreator/gdbmacros/test/main.cpp index fe6c2c6723..eca00156df 100644 --- a/share/qtcreator/gdbmacros/test/main.cpp +++ b/share/qtcreator/gdbmacros/test/main.cpp @@ -256,6 +256,18 @@ static int dumpStdStringVector() return 0; } +static int dumpStdWStringVector() +{ + std::vector<std::wstring> test; + test.push_back(L"item1"); + test.push_back(L"item2"); + prepareInBuffer("std::vector", "local.wstringvector", "local.wstringvector", "std::wstring"); + qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(std::wstring), sizeof(std::list<int>::allocator_type), 0, 0); + fputs(qDumpOutBuffer, stdout); + fputc('\n', stdout); + return 0; +} + static int dumpStdIntSet() { std::set<int> test; @@ -335,6 +347,8 @@ static bool dumpType(const char *arg) { dumpStdIntVector(); return true; } if (!qstrcmp(arg, "vector<string>")) { dumpStdStringVector(); return true; } + if (!qstrcmp(arg, "vector<wstring>")) + { dumpStdWStringVector(); return true; } if (!qstrcmp(arg, "set<int>")) { dumpStdIntSet(); return true; } if (!qstrcmp(arg, "set<string>")) |