From 2074ec8a358c3733d20269fbc6d4e4514ac1306a Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 8 Apr 2011 13:21:18 +0200 Subject: [PATCH] debugger: fix quoting of watched expressions with funny chars inside Base 64 to the rescue. --- share/qtcreator/gdbmacros/dumper.py | 9 +++------ src/plugins/debugger/gdb/pythongdbengine.cpp | 10 +++++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py index ed9853af18d..b2029125cbc 100644 --- a/share/qtcreator/gdbmacros/dumper.py +++ b/share/qtcreator/gdbmacros/dumper.py @@ -1335,15 +1335,13 @@ class Dumper: def handleWatch(self, exp, iname): exp = str(exp) - escapedExp = exp.replace('"', '\\"') - escapedExp = escapedExp.replace('\\', '\\\\') + escapedExp = base64.b64encode(exp); #warn("HANDLING WATCH %s, INAME: '%s'" % (exp, iname)) if exp.startswith("[") and exp.endswith("]"): #warn("EVAL: EXP: %s" % exp) with SubItem(self): self.put('iname="%s",' % iname) - self.put('name="%s",' % escapedExp) - self.put('exp="%s",' % escapedExp) + self.put('wname="%s",' % escapedExp) try: list = eval(exp) self.putValue("") @@ -1366,8 +1364,7 @@ class Dumper: with SubItem(self): self.put('iname="%s",' % iname) - self.put('name="%s",' % escapedExp) - self.put('exp="%s",' % escapedExp) + self.put('wname="%s",' % escapedExp) handled = False if len(exp) == 0: # The case self.putValue(" ") diff --git a/src/plugins/debugger/gdb/pythongdbengine.cpp b/src/plugins/debugger/gdb/pythongdbengine.cpp index dff647e17c5..bab182cfda2 100644 --- a/src/plugins/debugger/gdb/pythongdbengine.cpp +++ b/src/plugins/debugger/gdb/pythongdbengine.cpp @@ -152,7 +152,15 @@ void GdbEngine::handleStackFramePython(const GdbResponse &response) foreach (const GdbMi &child, data.children()) { WatchData dummy; dummy.iname = child.findChild("iname").data(); - dummy.name = _(child.findChild("name").data()); + GdbMi wname = child.findChild("wname"); + if (wname.isValid()) { + // Happens (only) for watched expressions. They are encoded as. + // base64 encoded 8 bit data, without quotes + dummy.name = decodeData(wname.data(), 5); + dummy.exp = dummy.name.toUtf8(); + } else { + dummy.name = _(child.findChild("name").data()); + } //qDebug() << "CHILD: " << child.toString(); parseWatchData(watchHandler()->expandedINames(), dummy, child, &list); }