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>
This commit is contained in:
hjk
2016-04-13 18:19:45 +02:00
parent 62fc258ac0
commit c0fabbe169
4 changed files with 22 additions and 0 deletions

View File

@@ -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)

View File

@@ -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());

View File

@@ -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);

View File

@@ -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) {