aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2016-04-13 18:19:45 +0200
committerhjk <hjk@theqtcompany.com>2016-04-15 10:50:45 +0000
commitc0fabbe169a9678eb8df0505de54fdaf9fec1a3f (patch)
treeaf34a6567046167fb8ed817c5827af3974aed56c
parent62fc258ac01dc31caada235568c2e92e21d3208d (diff)
Debugger: Add breakpoint commands for LLDB backend
Commands needs to be given in Python, i.e. something like import time print time.asctime() for i in range(1, 10): print(i) works. Task-number: QTCREATORBUG-15585 Change-Id: I7724617e4bbe85a717ae78b21014e2b55c4089c8 Reviewed-by: Alexandru Croitor <alexandru.croitor@theqtcompany.com> Reviewed-by: hjk <hjk@theqtcompany.com>
-rw-r--r--share/qtcreator/debugger/lldbbridge.py16
-rw-r--r--src/plugins/debugger/breakhandler.cpp2
-rw-r--r--src/plugins/debugger/breakhandler.h2
-rw-r--r--src/plugins/debugger/lldb/lldbengine.cpp2
4 files changed, 22 insertions, 0 deletions
diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py
index 6fd697fcc3..506f2379a8 100644
--- a/share/qtcreator/debugger/lldbbridge.py
+++ b/share/qtcreator/debugger/lldbbridge.py
@@ -160,6 +160,7 @@ lldb.SBType.__str__ = lldb.SBType.GetName
class Dumper(DumperBase):
def __init__(self):
DumperBase.__init__(self)
+ lldb.theDumper = self
self.outputLock = threading.Lock()
self.debugger = lldb.SBDebugger.Create()
@@ -1489,6 +1490,21 @@ class Dumper(DumperBase):
bp.SetIgnoreCount(int(args["ignorecount"]))
bp.SetCondition(self.hexdecode(args["condition"]))
bp.SetEnabled(bool(args["enabled"]))
+ bp.SetScriptCallbackBody('\n'.join([
+ "def foo(frame = frame, bp_loc = bp_loc, dict = internal_dict):",
+ " " + self.hexdecode(args["command"]).replace('\n', '\n '),
+ "from cStringIO import StringIO",
+ "origout = sys.stdout",
+ "sys.stdout = StringIO()",
+ "result = foo()",
+ "d = lldb.theDumper",
+ "output = d.hexencode(sys.stdout.getvalue())",
+ "sys.stdout = origout",
+ "d.report('output={channel=\"stderr\",data=\"' + output + '\"}')",
+ "if result is False:",
+ " d.reportState('continueafternextstop')",
+ "return True"
+ ]))
if isinstance(bp, lldb.SBBreakpoint):
bp.SetOneShot(bool(args["oneshot"]))
self.reportResult(self.describeBreakpoint(bp) + extra, args)
diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp
index f49bbf6881..207cddbf27 100644
--- a/src/plugins/debugger/breakhandler.cpp
+++ b/src/plugins/debugger/breakhandler.cpp
@@ -733,6 +733,7 @@ PROPERTY(QString, functionName, setFunctionName)
PROPERTY(BreakpointType, type, setType)
PROPERTY(int, threadSpec, setThreadSpec)
PROPERTY(QByteArray, condition, setCondition)
+PROPERTY(QString, command, setCommand)
PROPERTY(quint64, address, setAddress)
PROPERTY(QString, expression, setExpression)
PROPERTY(QString, message, setMessage)
@@ -757,6 +758,7 @@ void Breakpoint::addToCommand(DebuggerCommand *cmd) const
cmd->arg("type", type());
cmd->arg("ignorecount", ignoreCount());
cmd->arg("condition", condition().toHex());
+ cmd->arg("command", command().toUtf8().toHex());
cmd->arg("function", functionName().toUtf8());
cmd->arg("oneshot", isOneShot());
cmd->arg("enabled", isEnabled());
diff --git a/src/plugins/debugger/breakhandler.h b/src/plugins/debugger/breakhandler.h
index 763db17ce5..150cfd4375 100644
--- a/src/plugins/debugger/breakhandler.h
+++ b/src/plugins/debugger/breakhandler.h
@@ -113,6 +113,8 @@ public:
QString expression() const;
void setExpression(const QString &expression);
QString message() const;
+ QString command() const;
+ void setCommand(const QString &command);
void setMessage(const QString &m);
BreakpointType type() const;
void setType(const BreakpointType &type);
diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp
index 196972a013..03c627e14d 100644
--- a/src/plugins/debugger/lldb/lldbengine.cpp
+++ b/src/plugins/debugger/lldb/lldbengine.cpp
@@ -895,6 +895,8 @@ void LldbEngine::handleStateNotification(const GdbMi &reportedState)
notifyInferiorRunOk();
else if (newState == "inferiorrunfailed")
notifyInferiorRunFailed();
+ else if (newState == "continueafternextstop")
+ m_continueAtNextSpontaneousStop = true;
else if (newState == "stopped") {
notifyInferiorSpontaneousStop();
if (m_continueAtNextSpontaneousStop) {