Commit c3649f53 authored by hjk's avatar hjk

Debugger: Handle some watchpoint failures more gracefully

Change-Id: I09524aa8a3b0256ec0468416bc823353d5b011ea
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 1f72afb9
......@@ -102,6 +102,7 @@ def call(value, func, *args):
#######################################################################
qqStringCutOff = 10000
qqWatchpointOffset = 10000
# This is a cache mapping from 'type name' to 'display alternatives'.
qqFormats = {}
......@@ -220,11 +221,11 @@ BreakpointAtCatch = 5
BreakpointAtMain = 6
BreakpointAtFork = 7
BreakpointAtExec = 8
BreakpointAtSysCall = 10
WatchpointAtAddress = 11
WatchpointAtExpression = 12
BreakpointOnQmlSignalEmit = 13
BreakpointAtJavaScriptThrow = 14
BreakpointAtSysCall = 9
WatchpointAtAddress = 10
WatchpointAtExpression = 11
BreakpointOnQmlSignalEmit = 12
BreakpointAtJavaScriptThrow = 13
# See db.StateType
stateNames = ["invalid", "unloaded", "connected", "attaching", "launching", "stopped",
......@@ -1206,30 +1207,36 @@ class Dumper:
self.handleEvent(event)
def describeBreakpoint(self, bp, modelId):
cond = bp.GetCondition()
result = 'lldbid="%s"' % bp.GetID()
isWatch = isinstance(bp, lldb.SBWatchpoint)
if isWatch:
result = 'lldbid="%s"' % (qqWatchpointOffset + bp.GetID())
else:
result = 'lldbid="%s"' % bp.GetID()
result += ',modelid="%s"' % modelId
if not bp.IsValid():
return
result += ',hitcount="%s"' % bp.GetHitCount()
result += ',threadid="%s"' % bp.GetThreadID()
try:
if hasattr(bp, 'GetThreadID'):
result += ',threadid="%s"' % bp.GetThreadID()
if hasattr(bp, 'IsOneShot'):
result += ',oneshot="%s"' % (1 if bp.IsOneShot() else 0)
except:
pass
cond = bp.GetCondition()
result += ',enabled="%s"' % (1 if bp.IsEnabled() else 0)
result += ',valid="%s"' % (1 if bp.IsValid() else 0)
result += ',condition="%s"' % ("" if cond is None else cond)
result += ',condition="%s"' % binascii.hexlify("" if cond is None else cond)
result += ',ignorecount="%s"' % bp.GetIgnoreCount()
result += ',locations=['
for i in xrange(bp.GetNumLocations()):
loc = bp.GetLocationAtIndex(i)
addr = loc.GetAddress()
result += '{locid="%s"' % loc.GetID()
result += ',func="%s"' % addr.GetFunction().GetName()
result += ',enabled="%s"' % (1 if loc.IsEnabled() else 0)
result += ',resolved="%s"' % (1 if loc.IsResolved() else 0)
result += ',valid="%s"' % (1 if loc.IsValid() else 0)
result += ',ignorecount="%s"' % loc.GetIgnoreCount()
result += ',addr="%s"},' % loc.GetLoadAddress()
if hasattr(bp, 'GetNumLocations'):
for i in xrange(bp.GetNumLocations()):
loc = bp.GetLocationAtIndex(i)
addr = loc.GetAddress()
result += '{locid="%s"' % loc.GetID()
result += ',func="%s"' % addr.GetFunction().GetName()
result += ',enabled="%s"' % (1 if loc.IsEnabled() else 0)
result += ',resolved="%s"' % (1 if loc.IsResolved() else 0)
result += ',valid="%s"' % (1 if loc.IsValid() else 0)
result += ',ignorecount="%s"' % loc.GetIgnoreCount()
result += ',addr="%s"},' % loc.GetLoadAddress()
result += '],'
return result
......@@ -1240,6 +1247,8 @@ class Dumper:
str(args["file"]), int(args["line"]))
elif bpType == BreakpointByFunction:
bpNew = self.target.BreakpointCreateByName(args["function"])
elif bpType == BreakpointByAddress:
bpNew = self.target.BreakpointCreateByAddress(args["address"])
elif bpType == BreakpointAtMain:
bpNew = self.target.BreakpointCreateByName(
"main", self.target.GetExecutable().GetFilename())
......@@ -1249,29 +1258,48 @@ class Dumper:
elif bpType == BreakpointAtCatch:
bpNew = self.target.BreakpointCreateForException(
lldb.eLanguageTypeC_plus_plus, True, False)
elif bpType == WatchpointAtAddress:
error = lldb.SBError()
bpNew = self.target.WatchAddress(args["address"], 4, False, True, error)
#warn("BPNEW: %s" % bpNew)
self.reportError(error)
elif bpType == WatchpointAtExpression:
# FIXME: Top level-only for now.
try:
frame = self.currentFrame()
value = frame.FindVariable(args["expression"])
error = lldb.SBError()
bpNew = self.target.WatchAddress(value.GetAddress(),
value.GetByteSize(), False, True, error)
except:
return
else:
warn("UNKNOWN TYPE")
warn("UNKNOWN BREAKPOINT TYPE: %s" % bpType)
return
bpNew.SetIgnoreCount(int(args["ignorecount"]))
bpNew.SetCondition(str(args["condition"]))
bpNew.SetCondition(binascii.unhexlify(args["condition"]))
bpNew.SetEnabled(int(args["enabled"]))
try:
if hasattr(bpNew, 'SetOneShot'):
bpNew.SetOneShot(int(args["oneshot"]))
except:
pass
return bpNew
def changeBreakpoint(self, args):
bpChange = self.target.FindBreakpointByID(int(args["lldbid"]))
bpChange.SetIgnoreCount(int(args["ignorecount"]))
bpChange.SetCondition(str(args["condition"]))
bpChange.SetEnabled(int(args["enabled"]))
try:
bpChange.SetOneShot(int(args["oneshot"]))
except:
pass
id = int(args["lldbid"])
if id > qqWatchpointOffset:
bp = self.target.FindWatchpointByID(id)
else:
bp = self.target.FindBreakpointByID(id)
bp.SetIgnoreCount(int(args["ignorecount"]))
bp.SetCondition(binascii.unhexlify(args["condition"]))
bp.SetEnabled(int(args["enabled"]))
if hasattr(bp, 'SetOneShot'):
bp.SetOneShot(int(args["oneshot"]))
def removeBreakpoint(self, args):
return self.target.BreakpointDelete(int(args["lldbid"]))
id = int(args['lldbid'])
if id > qqWatchpointOffset:
return self.target.DeleteWatchpoint(id - qqWatchpointOffset)
return self.target.BreakpointDelete(id)
def handleBreakpoints(self, args):
result = 'bkpts=['
......
......@@ -342,7 +342,8 @@ bool LldbEngine::attemptBreakpointSynchronizationHelper(Command *cmd)
cmd->beginList("bkpts");
foreach (BreakpointModelId id, handler->engineBreakpointIds(this)) {
const BreakpointResponse &response = handler->response(id);
switch (handler->state(id)) {
const BreakpointState bpState = handler->state(id);
switch (bpState) {
case BreakpointNew:
// Should not happen once claimed.
QTC_CHECK(false);
......@@ -354,12 +355,14 @@ bool LldbEngine::attemptBreakpointSynchronizationHelper(Command *cmd)
.arg("modelid", id.toByteArray())
.arg("type", handler->type(id))
.arg("ignorecount", handler->ignoreCount(id))
.arg("condition", handler->condition(id))
.arg("condition", handler->condition(id).toHex())
.arg("function", handler->functionName(id).toUtf8())
.arg("oneshot", handler->isOneShot(id))
.arg("enabled", handler->isEnabled(id))
.arg("file", handler->fileName(id).toUtf8())
.arg("line", handler->lineNumber(id))
.arg("address", handler->address(id))
.arg("expression", handler->expression(id))
.endGroup();
handler->notifyBreakpointInsertProceeding(id);
break;
......@@ -371,12 +374,14 @@ bool LldbEngine::attemptBreakpointSynchronizationHelper(Command *cmd)
.arg("lldbid", response.id.toByteArray())
.arg("type", handler->type(id))
.arg("ignorecount", handler->ignoreCount(id))
.arg("condition", handler->condition(id))
.arg("condition", handler->condition(id).toHex())
.arg("function", handler->functionName(id).toUtf8())
.arg("oneshot", handler->isOneShot(id))
.arg("enabled", handler->isEnabled(id))
.arg("file", handler->fileName(id).toUtf8())
.arg("line", handler->lineNumber(id))
.arg("address", handler->address(id))
.arg("expression", handler->expression(id))
.endGroup();
handler->notifyBreakpointChangeProceeding(id);
break;
......@@ -394,10 +399,10 @@ bool LldbEngine::attemptBreakpointSynchronizationHelper(Command *cmd)
case BreakpointRemoveProceeding:
case BreakpointInserted:
case BreakpointDead:
QTC_CHECK(false);
QTC_ASSERT(false, qDebug() << "UNEXPECTED STATE" << bpState << "FOR BP " << id);
break;
default:
QTC_ASSERT(false, qDebug() << "UNKNOWN STATE" << id << state());
QTC_ASSERT(false, qDebug() << "UNKNOWN STATE" << bpState << "FOR BP" << id);
}
}
cmd->endList();
......@@ -433,7 +438,7 @@ void LldbEngine::updateBreakpointData(const GdbMi &bkpt, bool added)
response.address = 0;
response.enabled = bkpt["enabled"].toInt();
response.ignoreCount = bkpt["ignorecount"].toInt();
response.condition = bkpt["condition"].data();
response.condition = QByteArray::fromHex(bkpt["condition"].data());
response.hitCount = bkpt["hitcount"].toInt();
if (added) {
......@@ -814,7 +819,7 @@ void LldbEngine::readLldbStandardError()
QByteArray err = m_lldbProc.readAllStandardError();
qDebug() << "\nLLDB STDERR" << err;
//qWarning() << "Unexpected lldb stderr:" << err;
showMessage(_("Lldb stderr: " + err));
showMessage(_(err), LogError);
m_lldbProc.kill();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment