pygdb now saves absolute breakpoint paths
authorStefan Huber <shuber2@gmail.com>
Wed, 11 Jun 2008 20:57:36 +0000 (22:57 +0200)
committerStefan Huber <shuber2@gmail.com>
Wed, 11 Jun 2008 20:57:36 +0000 (22:57 +0200)
BreakpointsFrame.py
DbgTerminal.py
GdbTerminal.py
pygdb.vim

index 7d53cc2cfa699ab4b5048297049d3b6d4b365f74..b3e0030a9627475465ed076792d0a04e795b8618 100644 (file)
@@ -122,7 +122,13 @@ class BreakpointsFrame (StatusFrame.StatusFrame):
                iter = self.model.get_iter_first()
                while iter != None:
                        spec, = self.model.get(iter, 1)
                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)
 
 
                        iter = self.model.iter_next(iter)
 
 
index afeca3de2d2cf1cccbddbbc3c0477d661782c056..5cc7b279e5e41f636c05ee8c95967a38309fe4e1 100644 (file)
@@ -62,6 +62,24 @@ class DbgTerminal (vte.Terminal):
                        os.kill(self.childpid, 15);
                        self.childpid = None
 
                        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:
        def checkActivityChanged(self):
 
                try:
@@ -219,6 +237,24 @@ def quitHandler(*w):
        except:
                pass
 
        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):
 
 
 class DbgWindow (gtk.Window):
index 5e6ba6d75d821583107faaccb258991bdd56032a..81a6300ca19abafd894007a865b7c47e7e6e9746 100644 (file)
@@ -164,11 +164,14 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
 
                if string.find(line, "Program exited") == 0:
                        code = string.split(line)[-1]
 
                if string.find(line, "Program exited") == 0:
                        code = string.split(line)[-1]
-                       code = code[1:-1]
 
                        codeno = 0
 
                        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
 
 
                        return "exited", codeno
 
index e505b0aca7c938994a9725403cbce21efa63526f..ea552d307a0b130646770c4b4607a0de7527de64 100644 (file)
--- a/pygdb.vim
+++ b/pygdb.vim
@@ -16,6 +16,7 @@ import threading
 import vim
 
 import Configuration
 import vim
 
 import Configuration
+import DbgTerminal
 
 
 
 
 
 
@@ -187,27 +188,7 @@ def gdbShowBreakpoints():
                        print "%(file)s:%(lineno)d" % bp
 
 
                        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
 
 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]
 
                #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] == "/")
 
 
                assert(path[0] == "/")