From 547855bf021a845fec5b37dcd77aa5a5f3bba15f Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 10 Feb 2015 13:40:26 +0100 Subject: [PATCH] Debugger: Using DebuggerCommand instead of bbedit call Mid-term goal is to reduce the amount of similar code at least in GDB and LLDB engines. Change-Id: I4883686a102246be3135ddc694b837b1187ac9e9 Reviewed-by: hjk --- share/qtcreator/debugger/gdbbridge.py | 32 ++++++++------------------ src/plugins/debugger/gdb/gdbengine.cpp | 20 +++++++--------- 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index 1fc1725fc33..63cee8255eb 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -214,18 +214,6 @@ def stripTypedefs(typeobj): return typeobj -####################################################################### -# -# Edit Command -# -####################################################################### - -def bbedit(args): - theDumper.bbedit(args) - -registerCommand("bbedit", bbedit) - - ####################################################################### # # Frame Command @@ -1456,9 +1444,11 @@ class Dumper(DumperBase): self.currentQtNamespaceGuess = "" return "" - def bbedit(self, args): - (typeName, expr, data) = args.split(',') - typeName = self.hexdecode(typeName) + def assignValue(self, args): + typeName = self.hexdecode(args['type']) + expr = self.hexdecode(args['expr']) + value = self.hexdecode(args['value']) + simpleType = int(args['simpleType']) ns = self.qtNamespace() if typeName.startswith(ns): typeName = typeName[len(ns):] @@ -1466,14 +1456,12 @@ class Dumper(DumperBase): pos = typeName.find('<') if pos != -1: typeName = typeName[0:pos] - expr = self.hexdecode(expr) - data = self.hexdecode(data) - if typeName in self.qqEditable: - #self.qqEditable[typeName](self, expr, data) - value = gdb.parse_and_eval(expr) - self.qqEditable[typeName](self, value, data) + if typeName in self.qqEditable and not simpleType: + #self.qqEditable[typeName](self, expr, value) + expr = gdb.parse_and_eval(expr) + self.qqEditable[typeName](self, expr, value) else: - cmd = "set variable (%s)=%s" % (expr, data) + cmd = "set variable (%s)=%s" % (expr, value) gdb.execute(cmd) def hasVTable(self, typeobj): diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index f1d58be4ee9..8fefd3d9c6b 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -855,7 +855,7 @@ void GdbEngine::maybeHandleInferiorPidChanged(const QString &pid0) void GdbEngine::runCommand(const DebuggerCommand &command) { QByteArray cmd = command.function + "({" + command.args + "})"; - postCommand("python theDumper." + cmd); + postCommand("python theDumper." + cmd, command.flags, command.callback); } void GdbEngine::postCommand(const QByteArray &command, int flags, @@ -3786,17 +3786,13 @@ void GdbEngine::insertData(const WatchData &data) void GdbEngine::assignValueInDebugger(const WatchData *data, const QString &expression, const QVariant &value) { - if (!isIntOrFloatType(data->type)) { - QByteArray cmd = "bbedit " - + data->type.toHex() + ',' - + expression.toUtf8().toHex() + ',' - + value.toString().toUtf8().toHex(); - postCommand(cmd, Discardable, CB(handleVarAssign)); - } else { - postCommand("set variable (" + expression.toLatin1() + ")=" - + GdbMi::escapeCString(value.toString().toLatin1()), - Discardable, CB(handleVarAssign)); - } + DebuggerCommand cmd("assignValue"); + cmd.arg("type", data->type.toHex()); + cmd.arg("expr", expression.toLatin1().toHex()); + cmd.arg("value", value.toString().toLatin1().toHex()); + cmd.arg("simpleType", isIntOrFloatType(data->type)); + cmd.callback = CB(handleVarAssign); + runCommand(cmd); } void GdbEngine::watchPoint(const QPoint &pnt)