From ae13f1cd2401475e1fc58be3418fb349cd69fb98 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Wed, 11 Jun 2008 22:57:36 +0200 Subject: [PATCH] pygdb now saves absolute breakpoint paths --- BreakpointsFrame.py | 8 +++++++- DbgTerminal.py | 36 ++++++++++++++++++++++++++++++++++++ GdbTerminal.py | 9 ++++++--- pygdb.vim | 25 +++---------------------- 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/BreakpointsFrame.py b/BreakpointsFrame.py index 7d53cc2..b3e0030 100644 --- a/BreakpointsFrame.py +++ b/BreakpointsFrame.py @@ -122,7 +122,13 @@ class BreakpointsFrame (StatusFrame.StatusFrame): iter = self.model.get_iter_first() while iter != None: spec, = self.model.get(iter, 1) - conf.parseBreak(spec) + + #Replacing file by absolute path + file = string.split(spec, ":")[0] + file = self.debugger.toAbsPath(file) + postfile = string.join( string.split(spec,":")[1:], ":") + + conf.parseBreak(file + ":" + postfile ) iter = self.model.iter_next(iter) diff --git a/DbgTerminal.py b/DbgTerminal.py index afeca3d..5cc7b27 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -62,6 +62,24 @@ class DbgTerminal (vte.Terminal): os.kill(self.childpid, 15); self.childpid = None + def getClientExecuteable(self): + return string.split(self.clientCmd)[0] + + + def toAbsPath(self, path): + """convert path to an absolute path relative to the client + executable we debug.""" + + #Current working dir + pwd = os.getcwd() + "/" + + #executeable path + client = self.getClientExecuteable() + client = relToAbsPath(pwd, client) + + return relToAbsPath(client, path) + + def checkActivityChanged(self): try: @@ -219,6 +237,24 @@ def quitHandler(*w): except: pass +def relToAbsPath(absfile, relfile): + """When an absfile is given and a relfile is given by + relative paths relative to absfile, determine the abs + path of relfile""" + + #Get directories except for "." parts + relsplit = filter(lambda x: x!=".", string.split(relfile, os.sep)) + #Get the directories of absfile withouth the trailing filename + abssplit = string.split(absfile, os.sep)[:-1] + + #Determine number of ".." and remove them + up=0 + while relsplit[0] == "..": + up += 1 + del relsplit[0] + del abssplit[-1] + + return string.join(abssplit + relsplit, os.sep) class DbgWindow (gtk.Window): diff --git a/GdbTerminal.py b/GdbTerminal.py index 5e6ba6d..81a6300 100644 --- a/GdbTerminal.py +++ b/GdbTerminal.py @@ -164,11 +164,14 @@ class GdbTerminal (DbgTerminal.DbgTerminal): if string.find(line, "Program exited") == 0: code = string.split(line)[-1] - code = code[1:-1] codeno = 0 - for c in code: - codeno = codeno*8 + int(c) + + #Parse the octal number + if code[0] == "O": + code = code[1:-1] + for c in code: + codeno = codeno*8 + int(c) return "exited", codeno diff --git a/pygdb.vim b/pygdb.vim index e505b0a..ea552d3 100644 --- a/pygdb.vim +++ b/pygdb.vim @@ -16,6 +16,7 @@ import threading import vim import Configuration +import DbgTerminal @@ -187,27 +188,7 @@ def gdbShowBreakpoints(): print "%(file)s:%(lineno)d" % bp -def getAbsPath(absfile, relfile): - """When an absfile is given and a relfile is given by - relative paths relative to absfile, determine the abs - path of relfile""" - #Get directories except for "." parts - relsplit = filter(lambda x: x!=".", string.split(relfile, os.sep)) - #Get the directories of absfile withouth the trailing filename - abssplit = string.split(absfile, os.sep)[:-1] - - #Determine number of ".." and remove them - up=0 - while relsplit[0] == "..": - up += 1 - del relsplit[0] - del abssplit[-1] - - return string.join(abssplit + relsplit, os.sep) - - -#Change to absolute path def toAbsPath(path): global clientcmd, cmdset @@ -221,8 +202,8 @@ def toAbsPath(path): #Get the dirs where executeable is in relcmd = string.split(clientcmd)[0] - abscmd = getAbsPath(getCurrentFile(), relcmd) - path = getAbsPath(abscmd, path) + abscmd = DbgTerminal.relToAbsPath(getCurrentFile(), relcmd) + path = DbgTerminal.relToAbsPath(abscmd, path) assert(path[0] == "/") -- 2.39.5