X-Git-Url: https://git.sthu.org/?p=pygdb.git;a=blobdiff_plain;f=DbgTerminal.py;h=8fc569fcf1821588cafb71f08b15ed8ab8025745;hp=f69d8036fc8e5c3785903acb21f081a823ce268d;hb=afd9117c8d1d5f614acc120f28c668655be20abf;hpb=e8f5eba24b3fd5cdd839bcfc170a2e3aa16dd05d diff --git a/DbgTerminal.py b/DbgTerminal.py index f69d803..8fc569f 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: @@ -81,8 +99,8 @@ class DbgTerminal (vte.Terminal): print "got inactive: ", res for cb in self.gotInactiveCallback: cb(status, param) - except: - pass + except Exception, e: + print e return True @@ -193,6 +211,9 @@ class DbgTerminal (vte.Terminal): def getExpression(self, expr): raise NotImplementedError() + def listCodeSnippet(self): + raise NotImplementedError() + def waitForPrompt(self, his): raise NotImplementedError() @@ -217,6 +238,29 @@ def quitHandler(*w): pass +def updateVim(): + os.system('gvim --servername pygdb --remote-send ":GDBLoadConfig"') + + +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):