PR14291: KeyboardInterrupt not caught for Python output
authorMichael Eager <eager@eagercon.com>
Mon, 25 Jun 2012 16:53:20 +0000 (16:53 +0000)
committerMichael Eager <eager@eagercon.com>
Mon, 25 Jun 2012 16:53:20 +0000 (16:53 +0000)
gdb/ChangeLog
gdb/python/python.c

index fe013dee4b0815912a3d39c0efd9d54e9dca6900..a36ce76e2bdc36cdee7a4ddc7446dadf31bffc51 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-25  Michael Eager  <eager@eagercon.com>
+
+       PR python/14291
+       * python/python.c (gdbpy_write): Check for interrupted output. 
+
 2012-06-25  Greta Yorsh  <greta.yorsh@arm.com>
 
        * arm-tdep.c (arm_in_function_epilogue_p): Recognize POP with a single
index 19eb7b546af753e8d57b93f810529e5514111f7e..c66efe465e74c0689298d5bc84922c17b243dc72 100644 (file)
@@ -862,26 +862,31 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
   const char *arg;
   static char *keywords[] = {"text", "stream", NULL };
   int stream_type = 0;
+  volatile struct gdb_exception except;
   
   if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg,
                                     &stream_type))
     return NULL;
 
-  switch (stream_type)
+  TRY_CATCH (except, RETURN_MASK_ALL)
     {
-    case 1:
-      {
-       fprintf_filtered (gdb_stderr, "%s", arg);
-       break;
-      }
-    case 2:
-      {
-       fprintf_filtered (gdb_stdlog, "%s", arg);
-       break;
-      }
-    default:
-      fprintf_filtered (gdb_stdout, "%s", arg);
+      switch (stream_type)
+        {
+        case 1:
+          {
+           fprintf_filtered (gdb_stderr, "%s", arg);
+           break;
+          }
+        case 2:
+          {
+           fprintf_filtered (gdb_stdlog, "%s", arg);
+           break;
+          }
+        default:
+          fprintf_filtered (gdb_stdout, "%s", arg);
+        }
     }
+  GDB_PY_HANDLE_EXCEPTION (except);
      
   Py_RETURN_NONE;
 }