Skip to content

Commit

Permalink
helpers/gdbconnector.py: PEP8 reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
giselher committed Mar 27, 2012
1 parent 9742718 commit 542a7c3
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/helpers/gdbconnector.py
Expand Up @@ -37,7 +37,8 @@ def __init__(self):
self.reader = GdbReader(self)

def start(self):
self.gdb = subprocess.Popen(['gdb', '--interpreter', 'mi'], shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
self.gdb = subprocess.Popen(['gdb', '--interpreter', 'mi'], \
shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
self.reader.startReading(self.gdb.stdout)

def execute(self, cmd, error_msg=None):
Expand All @@ -47,7 +48,8 @@ def execute(self, cmd, error_msg=None):
res = self.reader.getResult(GdbOutput.RESULT_RECORD)

if res.class_ == GdbOutput.ERROR:
logging.debug("Command '%s' failed with %s (%s, '%s')", cmd, res.msg, res.raw, error_msg)
logging.debug("Command '%s' failed with %s (%s, '%s')", \
cmd, res.msg, res.raw, error_msg)

return res

Expand All @@ -63,13 +65,16 @@ def executeAndRaiseIfFailed(self, cmd, error_msg=None):
return res

def setTty(self, tty):
self.executeAndRaiseIfFailed("-inferior-tty-set " + tty, "Could not set target's TTY!")
self.executeAndRaiseIfFailed("-inferior-tty-set " + tty, \
"Could not set target's TTY!")

def openFile(self, filename):
self.executeAndRaiseIfFailed("-file-exec-and-symbols " + filename, "Could not open file!")
self.executeAndRaiseIfFailed("-file-exec-and-symbols " + filename, \
"Could not open file!")

def getSources(self):
res = self.executeAndRaiseIfFailed("-file-list-exec-source-files", "Could not get files.")
res = self.executeAndRaiseIfFailed("-file-list-exec-source-files", \
"Could not get files.")

files = []
for f in res.files:
Expand All @@ -83,11 +88,13 @@ def getSources(self):
return files

def getMultipleBreakpoints(self, nr):
res = self.executeAndRaiseIfFailed("info break " + str(nr), "Could not get multiple breakpoint list.")
res = self.executeAndRaiseIfFailed("info break " + str(nr), \
"Could not get multiple breakpoint list.")
return res

def getBreakpoints(self):
res = self.executeAndRaiseIfFailed("-break-list", "Could not get breakpoint list.")
res = self.executeAndRaiseIfFailed("-break-list", \
"Could not get breakpoint list.")

breakpoints = []
for bp in res.BreakpointTable.body:
Expand Down Expand Up @@ -140,28 +147,36 @@ def getStack(self):

def insertBreakpoint(self, file_, line):
loc = file_ + ":" + str(line)
return self.executeAndRaiseIfFailed("-break-insert " + loc, "Could not create breakpoint " + loc + ".")
return self.executeAndRaiseIfFailed("-break-insert " + loc, \
"Could not create breakpoint " + loc + ".")

def deleteBreakpoint(self, number):
return self.executeAndRaiseIfFailed("-break-delete " + str(number))

def enableBreakpoint(self, number):
return self.executeAndRaiseIfFailed("-break-enable " + str(number), "Could not enable breakpoint " + str(number) + ".")
return self.executeAndRaiseIfFailed("-break-enable " + str(number), \
"Could not enable breakpoint " + str(number) + ".")

def disableBreakpoint(self, number):
return self.executeAndRaiseIfFailed("-break-disable " + str(number), "Could not disable breakpoint " + str(number) + ".")
return self.executeAndRaiseIfFailed("-break-disable " + str(number), \
"Could not disable breakpoint " + str(number) + ".")

def setSkipBreakpoint(self, number, skip):
return self.executeAndRaiseIfFailed("-break-after " + str(number) + " " + str(skip), "Could not set breakpoint interval '" + str(skip) + "' for breakpoint " + str(number) + ".")
return self.executeAndRaiseIfFailed("-break-after " + str(number) + \
" " + str(skip), "Could not set breakpoint interval '" + \
str(skip) + "' for breakpoint " + str(number) + ".")

def setConditionBreakpoint(self, number, condition):
return self.executeAndRaiseIfFailed("-break-condition " + str(number) + " " + str(condition), "Could not set condition '" + str(condition) + "' for breakpoint " + str(number) + ".")
''
return self.executeAndRaiseIfFailed("-break-condition " + str(number) \
+ " " + str(condition), "Could not set condition '" + \
str(condition) + "' for breakpoint " + str(number) + ".")

def changeWorkingDirectory(self, dir_):
return self.executeAndRaiseIfFailed("-environment-cd " + dir_)

def run(self):
return self.executeAndRaiseIfFailed("-exec-run", "Could not run the program.")
return self.executeAndRaiseIfFailed("-exec-run", \
"Could not run the program.")

def next_(self):
return self.executeAndRaiseIfFailed("-exec-next")
Expand Down Expand Up @@ -208,7 +223,8 @@ def var_assign(self, exp, value):
return self.execute("-var-assign \"" + exp + "\" " + value)

def var_list_children(self, exp):
return self.execute("-var-list-children --all-values \"" + str(exp) + "\"")
return self.execute("-var-list-children --all-values \"" + \
str(exp) + "\"")

def var_update(self, exp):
return self.execute("-var-update --all-values \"" + exp + "\"")
Expand Down

0 comments on commit 542a7c3

Please sign in to comment.