+def gdbShowBreakpoints():
+ global gdbBps
+
+ if len(gdbBps) == 0:
+ print "No breakpoints set."
+ else:
+ print "%d breakpoints set:" % len(gdbBps)
+
+ for bp in gdbBps:
+ if bp["cond"] != None:
+ print "%(file)s:%(lineno)d if %(cond)s" % bp
+ else:
+ 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)
+
+
+
+def gdbLoadConfig():
+ global clientcmd, gdbBps
+
+
+ #Load configuration
+ conf = Configuration.Configuration()
+ conf.load(".pygdb.conf")
+
+ #Remove all breakpoints
+ while len(gdbBps)>0:
+ removeBreakpoint(0)
+
+ #Add breakpoints from configuration
+ cmdset = False
+ for bp in conf.breakpoints:
+
+ file = bp["file"]
+
+ #Not a absolute path --> make one
+ if file[0] != os.sep:
+
+ #We need the client command to expand the paths...
+ while clientcmd == "" or not cmdset:
+ clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip()
+ cmdset = True
+
+ #Get the dirs where executeable is in
+ relcmd = string.split(clientcmd)[0]
+ abscmd = getAbsPath(getCurrentFile(), relcmd)
+ bp["file"] = file = getAbsPath(abscmd, file)
+
+ assert(file[0] == "/")
+
+ addBreakpoint(bp["file"], bp["lineno"], bp["cond"])