X-Git-Url: https://git.sthu.org/?p=pygdb.git;a=blobdiff_plain;f=DbgTerminal.py;h=5cc7b279e5e41f636c05ee8c95967a38309fe4e1;hp=afeca3de2d2cf1cccbddbbc3c0477d661782c056;hb=ae13f1cd2401475e1fc58be3418fb349cd69fb98;hpb=b621a683513577d563621942f1ba7c98fe423999 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):