debugger: fix quoting of watched expressions with funny chars inside

Base 64 to the rescue.
This commit is contained in:
hjk
2011-04-08 13:21:18 +02:00
parent 0da6c8bcb8
commit 2074ec8a35
2 changed files with 12 additions and 7 deletions

View File

@@ -1335,15 +1335,13 @@ class Dumper:
def handleWatch(self, exp, iname): def handleWatch(self, exp, iname):
exp = str(exp) exp = str(exp)
escapedExp = exp.replace('"', '\\"') escapedExp = base64.b64encode(exp);
escapedExp = escapedExp.replace('\\', '\\\\')
#warn("HANDLING WATCH %s, INAME: '%s'" % (exp, iname)) #warn("HANDLING WATCH %s, INAME: '%s'" % (exp, iname))
if exp.startswith("[") and exp.endswith("]"): if exp.startswith("[") and exp.endswith("]"):
#warn("EVAL: EXP: %s" % exp) #warn("EVAL: EXP: %s" % exp)
with SubItem(self): with SubItem(self):
self.put('iname="%s",' % iname) self.put('iname="%s",' % iname)
self.put('name="%s",' % escapedExp) self.put('wname="%s",' % escapedExp)
self.put('exp="%s",' % escapedExp)
try: try:
list = eval(exp) list = eval(exp)
self.putValue("") self.putValue("")
@@ -1366,8 +1364,7 @@ class Dumper:
with SubItem(self): with SubItem(self):
self.put('iname="%s",' % iname) self.put('iname="%s",' % iname)
self.put('name="%s",' % escapedExp) self.put('wname="%s",' % escapedExp)
self.put('exp="%s",' % escapedExp)
handled = False handled = False
if len(exp) == 0: # The <Edit> case if len(exp) == 0: # The <Edit> case
self.putValue(" ") self.putValue(" ")

View File

@@ -152,7 +152,15 @@ void GdbEngine::handleStackFramePython(const GdbResponse &response)
foreach (const GdbMi &child, data.children()) { foreach (const GdbMi &child, data.children()) {
WatchData dummy; WatchData dummy;
dummy.iname = child.findChild("iname").data(); 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(); //qDebug() << "CHILD: " << child.toString();
parseWatchData(watchHandler()->expandedINames(), dummy, child, &list); parseWatchData(watchHandler()->expandedINames(), dummy, child, &list);
} }