OSDN Git Service

debugger: enable latin1 or utf8 char[] display
authorhjk <qtc-committer@nokia.com>
Mon, 18 Apr 2011 14:15:39 +0000 (16:15 +0200)
committerhjk <qtc-committer@nokia.com>
Mon, 18 Apr 2011 14:15:39 +0000 (16:15 +0200)
share/qtcreator/gdbmacros/dumper.py
src/plugins/debugger/watchhandler.cpp

index 0565159..f0b5511 100644 (file)
@@ -1643,11 +1643,19 @@ class Dumper:
             return
 
         if value.type.code == gdb.TYPE_CODE_ARRAY:
-            self.putType(realtype)
-            self.putAddress(value.address)
-            self.putNumChild(1)
             baseptr = value.cast(realtype.pointer())
-            self.putValue("%s" % baseptr)
+            if format == 0 or format == 1:
+                # Explicityly requested Latin1 or UTF-8 formatting.
+                f = select(format == 0, Hex2EncodedLatin1, Hex2EncodedUtf8)
+                self.putAddress(value.address)
+                self.putType(realtype)
+                self.putValue(encodeCharArray(value, 100), f)
+                self.putNumChild(1)
+            else:
+                self.putType(realtype)
+                self.putAddress(value.address)
+                self.putValue("%s" % baseptr)
+                self.putNumChild(1)
             if self.isExpanded(item):
                 charptr = lookupType("unsigned char").pointer()
                 addr1 = (baseptr+1).cast(charptr)
index 817cd2f..b2502fd 100644 (file)
@@ -702,9 +702,16 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
                     << tr("UTF8 string")
                     << tr("UTF16 string")
                     << tr("UCS4 string");
+            if (data.type.contains("char[") || data.type.contains("char ["))
+                return QStringList()
+                    << tr("Latin1 string")
+                    << tr("UTF8 string");
             if (isIntType(data.type) && data.type != "bool")
-                return QStringList() << tr("decimal") << tr("hexadecimal")
-                    << tr("binary") << tr("octal");
+                return QStringList()
+                    << tr("decimal")
+                    << tr("hexadecimal")
+                    << tr("binary")
+                    << tr("octal");
             // Hack: Compensate for namespaces.
             QString type = data.type;
             int pos = type.indexOf("::Q");