Debugger: Move LLDB state reporting to separate function

Change-Id: I4e250173efc1c0df002d2ce94f7e8df57339544b
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-03-19 12:12:24 +01:00
parent 05d7dd1bb9
commit 358500e7fc

View File

@@ -667,24 +667,24 @@ class Dumper(DumperBase):
attachInfo = lldb.SBAttachInfo(self.attachPid_)
self.process = self.target.Attach(attachInfo, error)
if not error.Success():
self.report('state="inferiorrunfailed"')
self.reportState("inferiorrunfailed")
return
self.report('pid="%s"' % self.process.GetProcessID())
# even if it stops it seems that lldb assumes it is running and later detects that
# it did stop after all, so it is be better to mirror that and wait for the spontaneous
# stop
self.report('state="enginerunandinferiorrunok"')
# Even if it stops it seems that LLDB assumes it is running
# and later detects that it did stop after all, so it is be
# better to mirror that and wait for the spontaneous stop.
self.reportState("enginerunandinferiorrunok")
elif len(self.remoteChannel_) > 0:
self.process = self.target.ConnectRemote(
self.debugger.GetListener(),
self.remoteChannel_, None, error)
if not error.Success():
self.report('state="inferiorrunfailed"')
self.reportState("inferiorrunfailed")
return
# even if it stops it seems that lldb assumes it is running and later detects that
# it did stop after all, so it is be better to mirror that and wait for the spontaneous
# stop
self.report('state="enginerunandinferiorrunok"')
# Even if it stops it seems that LLDB assumes it is running
# and later detects that it did stop after all, so it is be
# better to mirror that and wait for the spontaneous stop.
self.reportState("enginerunandinferiorrunok")
else:
launchInfo = lldb.SBLaunchInfo(self.processArgs_)
launchInfo.SetWorkingDirectory(os.getcwd())
@@ -695,10 +695,10 @@ class Dumper(DumperBase):
self.process = self.target.Launch(launchInfo, error)
if not error.Success():
self.reportError(error)
self.report('state="enginerunfailed"')
self.reportState("enginerunfailed")
return
self.report('pid="%s"' % self.process.GetProcessID())
self.report('state="enginerunandinferiorrunok"')
self.reportState("enginerunandinferiorrunok")
event = lldb.SBEvent()
while True:
@@ -732,7 +732,8 @@ class Dumper(DumperBase):
frame = thread.GetSelectedFrame()
file = fileName(frame.line_entry.file)
line = frame.line_entry.line
self.report('location={file="%s",line="%s",addr="%s"}' % (file, line, frame.pc))
self.report('location={file="%s",line="%s",addr="%s"}'
% (file, line, frame.pc))
def firstStoppedThread(self):
for i in xrange(0, self.process.GetNumThreads()):
@@ -1202,7 +1203,7 @@ class Dumper(DumperBase):
self.reportError(error)
def quitDebugger(self, _ = None):
self.report('state="inferiorshutdownrequested"')
self.reportState("inferiorshutdownrequested")
self.process.Kill()
def handleEvent(self, event):
@@ -1219,22 +1220,22 @@ class Dumper(DumperBase):
self.eventState = state
if state == lldb.eStateExited:
if self.isShuttingDown_:
self.report('state="inferiorshutdownok"')
self.reportState("inferiorshutdownok")
else:
self.report('state="inferiorexited"')
self.reportState("inferiorexited")
self.report('exited={status="%s",desc="%s"}'
% (self.process.GetExitStatus(), self.process.GetExitDescription()))
elif state == lldb.eStateStopped:
if self.isInterrupting_:
self.isInterrupting_ = False
self.report('state="inferiorstopok"')
self.reportState("inferiorstopok")
elif self.ignoreStops > 0:
self.ignoreStops -= 1
self.process.Continue()
else:
self.report('state="stopped"')
self.reportState("stopped")
else:
self.report('state="%s"' % stateNames[state])
self.reportState(stateNames[state])
if type == lldb.SBProcess.eBroadcastBitStateChanged:
state = self.process.GetState()
if state == lldb.eStateStopped:
@@ -1260,6 +1261,9 @@ class Dumper(DumperBase):
elif type == lldb.SBProcess.eBroadcastBitProfileData:
pass
def reportState(self, state):
self.report('state="%s"' % state)
def describeBreakpoint(self, bp):
isWatch = isinstance(bp, lldb.SBWatchpoint)
if isWatch:
@@ -1457,7 +1461,7 @@ class Dumper(DumperBase):
self.process.Kill()
def quit(self, _ = None):
self.report('state="engineshutdownok"')
self.reportState("engineshutdownok")
self.process.Kill()
def executeStepI(self, _ = None):
@@ -1476,8 +1480,8 @@ class Dumper(DumperBase):
line = int(args['line'])
error = self.currentThread().StepOverUntil(frame, lldb.SBFileSpec(file), line)
if error.GetType():
self.report('state="running"')
self.report('state="stopped"')
self.reportState("running")
self.reportState("stopped")
self.reportError(error)
self.reportLocation()
else:
@@ -1485,7 +1489,7 @@ class Dumper(DumperBase):
def executeJumpToLocation(self, args):
frame = self.currentFrame()
self.report('state="stopped"')
self.reportSate("stopped")
if not frame:
self.reportStatus("No frame available.")
self.reportLocation()
@@ -1676,7 +1680,7 @@ def doit():
db = Dumper()
db.report('lldbversion="%s"' % lldb.SBDebugger.GetVersionString())
db.report('state="enginesetupok"')
db.reportState("enginesetupok")
line = sys.stdin.readline()
while line: