harden breakpoint parsing v0.99.4
authorStefan Huber <shuber2@gmail.com>
Fri, 4 Jul 2008 09:08:34 +0000 (11:08 +0200)
committerStefan Huber <shuber2@gmail.com>
Fri, 4 Jul 2008 09:08:34 +0000 (11:08 +0200)
GdbTerminal.py

index 842f76862123027b809e690aebab5fda54ae220b..58c3bbe13cdcad7b05ca023d6d172f4a38f938d5 100644 (file)
@@ -95,45 +95,47 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
                bplines = self.__getAnswerFromCmd("info breakpoints\n")
 
                rxbp = re.compile("^\d+\s+breakpoint")
-               rxpos = re.compile("^.*at\s+\S+:\d+$")
+               rxpos = re.compile("at \S+:\d+$")
                rxcond = re.compile("^\s+stop only if")
 
                bpnts = []
-               i = 1
 
-               #Parse the resulting lines
-               while i<len(bplines):
-                       line = bplines[i]
+               try:
+                       i = 1
 
-                       if not rxbp.search(line):
-                               i += 1
-                               continue
-       
-                       #Get number of breakpoint
-                       no = string.split(line)[0]
+                       #Parse the resulting lines
+                       while i<len(bplines):
 
-                       #This line does not contain the file!
-                       #Check for next line...
-                       if not rxpos.search(line):
-                               i += 1
                                line = bplines[i]
-                       if not rxpos.search(line):
-                               i += 1
-                               continue
+                               while not rxbp.search(line):
+                                       i += 1
+                                       line = bplines[i]
+               
+                               #Get number of breakpoint
+                               no = string.split(line)[0]
 
-                       pos = string.split(line)[-1]
-                       [file,lineno] = string.split(pos,":")
-                       cond = None
+                               #This line does not contain the file!
+                               #Check for next line...
+                               while not rxpos.search(line):
+                                       i += 1
+                                       line = bplines[i]
 
-                       #Look for conditions
-                       if i+1<len(bplines) and rxcond.search(bplines[i+1]):
-                               i +=1
-                               line = bplines[i]
-                               cond = string.join(string.split(line," if ")[1:], " if ")
-                               cond = cond.strip()
+                               pos = string.split(line)[-1]
+                               [file,lineno] = string.split(pos,":")
+                               cond = None
 
-                       bpnts += [[no, file, lineno, cond]]
-                       i += 1
+                               #Look for conditions
+                               if i+1<len(bplines) and rxcond.search(bplines[i+1]):
+                                       i +=1
+                                       line = bplines[i]
+                                       cond = string.join(string.split(line," if ")[1:], " if ")
+                                       cond = cond.strip()
+
+                               bpnts += [[no, file, lineno, cond]]
+                               i += 1
+
+               except IndexError:
+                       pass
 
                return bpnts
                
@@ -185,7 +187,6 @@ class GdbTerminal (DbgTerminal.DbgTerminal):
 
                                #Search for file position
                                while not rxpos.search(line):
-                                       print "Warning: '", line, "' does not match file pos marker."
                                        i+=1
                                        line = answ[i]