Blame SOURCES/gdb-rhbz1325795-framefilters-1of2.patch

2c2fa1
commit 4c9a21f6a57e0e2e382aac327f6edaa1475dd3f1
2c2fa1
Author: Tom Tromey <tromey@redhat.com>
2c2fa1
Date:   Wed Jan 22 08:44:41 2014 -0700
2c2fa1
2c2fa1
    fix erroneous error-handling in frame filter code
2c2fa1
    
2c2fa1
    This fixes PR python/16487.
2c2fa1
    
2c2fa1
    The bug here is that the function-name-handling code in py_print_frame
2c2fa1
    had a small logic error (really a misplaced closing brace).  This
2c2fa1
    error could lead to a Py_DECREF(NULL), which crashes.
2c2fa1
    
2c2fa1
    This patch fixes the bug in the obvious way.
2c2fa1
    
2c2fa1
    Built and regtested on x86-64 Fedora 18.  New test case included.
2c2fa1
    
2c2fa1
    2014-01-23  Tom Tromey  <tromey@redhat.com>
2c2fa1
    
2c2fa1
    	PR python/16487:
2c2fa1
    	* python/py-framefilter.c (py_print_frame): Don't call Py_DECREF
2c2fa1
    	on a NULL pointer.  Move "goto error" to correct place.
2c2fa1
    
2c2fa1
    2014-01-23  Tom Tromey  <tromey@redhat.com>
2c2fa1
    
2c2fa1
    	PR python/16487:
2c2fa1
    	* gdb.python/py-framefilter.exp: Add test using "Error" filter.
2c2fa1
    	* gdb.python/py-framefilter.py (ErrorInName, ErrorFilter): New
2c2fa1
    	classes.
2c2fa1
2c2fa1
### a/gdb/ChangeLog
2c2fa1
### b/gdb/ChangeLog
2c2fa1
## -1,5 +1,11 @@
2c2fa1
 2014-01-23  Tom Tromey  <tromey@redhat.com>
2c2fa1
 
2c2fa1
+	PR python/16487:
2c2fa1
+	* python/py-framefilter.c (py_print_frame): Don't call Py_DECREF
2c2fa1
+	on a NULL pointer.  Move "goto error" to correct place.
2c2fa1
+
2c2fa1
+2014-01-23  Tom Tromey  <tromey@redhat.com>
2c2fa1
+
2c2fa1
 	PR python/16491:
2c2fa1
 	* python/py-framefilter.c (apply_frame_filter): Call
2c2fa1
 	ensure_python_env after computing gdbarch.
2c2fa1
--- a/gdb/python/py-framefilter.c
2c2fa1
+++ b/gdb/python/py-framefilter.c
2c2fa1
@@ -1218,11 +1218,11 @@ py_print_frame (PyObject *filter, int flags, enum py_frame_args args_type,
2c2fa1
 		  gdbpy_convert_exception (except);
2c2fa1
 		  goto error;
2c2fa1
 		}
2c2fa1
+	      Py_DECREF (py_func);
2c2fa1
 	    }
2c2fa1
-	  Py_DECREF (py_func);
2c2fa1
+	  else
2c2fa1
+	    goto error;
2c2fa1
 	}
2c2fa1
-      else
2c2fa1
-	goto error;
2c2fa1
     }
2c2fa1
 
2c2fa1
 
2c2fa1
### a/gdb/testsuite/ChangeLog
2c2fa1
### b/gdb/testsuite/ChangeLog
2c2fa1
## -1,5 +1,12 @@
2c2fa1
 2014-01-23  Tom Tromey  <tromey@redhat.com>
2c2fa1
 
2c2fa1
+	PR python/16487:
2c2fa1
+	* gdb.python/py-framefilter.exp: Add test using "Error" filter.
2c2fa1
+	* gdb.python/py-framefilter.py (ErrorInName, ErrorFilter): New
2c2fa1
+	classes.
2c2fa1
+
2c2fa1
+2014-01-23  Tom Tromey  <tromey@redhat.com>
2c2fa1
+
2c2fa1
 	PR python/16491:
2c2fa1
 	* gdb.python/py-framefilter.py (Reverse_Function.function): Read a
2c2fa1
 	string from an inferior frame.
2c2fa1
--- a/gdb/testsuite/gdb.python/py-framefilter.exp
2c2fa1
+++ b/gdb/testsuite/gdb.python/py-framefilter.exp
2c2fa1
@@ -177,6 +177,17 @@ gdb_test "bt 1" \
2c2fa1
     "#0  end_func \\(foo=21, bar=\"Param\", fb=, bf=\{nothing = \"Foo Bar\", f = 42, s = 19\}\\) at .*py-framefilter.c.*" \
2c2fa1
     "bt 1 no addresss"
2c2fa1
 
2c2fa1
+gdb_test_no_output "set python print-stack message" \
2c2fa1
+    "Set python print-stack to message for Error filter"
2c2fa1
+gdb_test_no_output  "enable frame-filter global Error" \
2c2fa1
+    "enable frame-filter global Error"
2c2fa1
+set test "bt 1 with Error filter"
2c2fa1
+gdb_test_multiple "bt 1" $test {
2c2fa1
+    -re "Python Exception .*whoops:.*$gdb_prompt $" {
2c2fa1
+	pass $test
2c2fa1
+    }
2c2fa1
+}
2c2fa1
+
2c2fa1
 remote_file host delete ${remote_python_file}
2c2fa1
 
2c2fa1
 # Test with no debuginfo
2c2fa1
--- a/gdb/testsuite/gdb.python/py-framefilter.py
2c2fa1
+++ b/gdb/testsuite/gdb.python/py-framefilter.py
2c2fa1
@@ -128,5 +128,25 @@ class FrameElider ():
2c2fa1
     def filter (self, frame_iter):
2c2fa1
         return ElidingIterator (frame_iter)
2c2fa1
 
2c2fa1
+# A simple decorator that gives an error when computing the function.
2c2fa1
+class ErrorInName(FrameDecorator):
2c2fa1
+    def __init__(self, frame):
2c2fa1
+        FrameDecorator.__init__(self, frame)
2c2fa1
+
2c2fa1
+    def function(self):
2c2fa1
+        raise RuntimeError('whoops')
2c2fa1
+
2c2fa1
+# A filter that supplies buggy frames.  Disabled by default.
2c2fa1
+class ErrorFilter():
2c2fa1
+    def __init__ (self):
2c2fa1
+        self.name = "Error"
2c2fa1
+        self.priority = 1
2c2fa1
+        self.enabled = False
2c2fa1
+        gdb.frame_filters [self.name] = self
2c2fa1
+
2c2fa1
+    def filter(self, frame_iter):
2c2fa1
+        return itertools.imap(ErrorInName, frame_iter)
2c2fa1
+
2c2fa1
 FrameFilter()
2c2fa1
 FrameElider()
2c2fa1
+ErrorFilter()