Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] PR14291:  KeyboardInterrupt not caught for Python output
@ 2012-06-25 12:33 Michael Eager
  2012-06-25 15:26 ` Tom Tromey
  2012-06-27 13:37 ` Tom Tromey
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Eager @ 2012-06-25 12:33 UTC (permalink / raw)
  To: gdb-patches

http://sourceware.org/bugzilla/show_bug.cgi?id=14291

python
try:
     for i in range(400):
         print i
except KeyboardInterrupt:
     print "caught interrupt"
end

Entering "q" at "q <return> to quit" results in the Python
program being prematurely terminated.

(BTW, I tried to add this to the test suite, but gdb_test_multiple
catches the "enter q <return>" prompt and fails the test.)


2012-06-25  Michael Eager  <eager@eagercon.com>

	* python/python.c (gdbpy_write): Check for interrupted
	output.


Index: python/python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.90
diff -u -p -r1.90 python.c
--- python/python.c	18 May 2012 21:02:52 -0000	1.90
+++ python/python.c	25 Jun 2012 12:25:33 -0000
@@ -862,26 +862,31 @@ gdbpy_write (PyObject *self, PyObject *a
    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;
  }

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PR14291:  KeyboardInterrupt not caught for Python output
  2012-06-25 12:33 [PATCH] PR14291: KeyboardInterrupt not caught for Python output Michael Eager
@ 2012-06-25 15:26 ` Tom Tromey
  2012-06-25 16:54   ` Michael Eager
  2012-06-27 13:37 ` Tom Tromey
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2012-06-25 15:26 UTC (permalink / raw)
  To: Michael Eager; +Cc: gdb-patches

>>>>> "Michael" == Michael Eager <eager@eagerm.com> writes:

Michael> 2012-06-25  Michael Eager  <eager@eagercon.com>
Michael> 	* python/python.c (gdbpy_write): Check for interrupted
Michael> 	output.

Ok.

Tom


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PR14291:  KeyboardInterrupt not caught for Python output
  2012-06-25 15:26 ` Tom Tromey
@ 2012-06-25 16:54   ` Michael Eager
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Eager @ 2012-06-25 16:54 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 06/25/2012 08:25 AM, Tom Tromey wrote:
>>>>>> "Michael" == Michael Eager<eager@eagerm.com>  writes:
>
> Michael>  2012-06-25  Michael Eager<eager@eagercon.com>
> Michael>  	* python/python.c (gdbpy_write): Check for interrupted
> Michael>  	output.
>
> Ok.

Checked in.


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PR14291:  KeyboardInterrupt not caught for Python output
  2012-06-25 12:33 [PATCH] PR14291: KeyboardInterrupt not caught for Python output Michael Eager
  2012-06-25 15:26 ` Tom Tromey
@ 2012-06-27 13:37 ` Tom Tromey
  2012-06-27 14:06   ` Michael Eager
  1 sibling, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2012-06-27 13:37 UTC (permalink / raw)
  To: Michael Eager; +Cc: gdb-patches

>>>>> "Michael" == Michael Eager <eager@eagerm.com> writes:

Michael> 2012-06-25  Michael Eager  <eager@eagercon.com>

Michael> 	* python/python.c (gdbpy_write): Check for interrupted
Michael> 	output.

This caused a regression:

FAIL: gdb.python/python.exp: verify pagination beforehand: q
FAIL: gdb.python/python.exp: verify pagination afterwards: q

I'm checking in the appended.
It just updates the regexps to match what is printed.

Tom

2012-06-27  Tom Tromey  <tromey@redhat.com>

	* gdb.python/python.exp: Fix regexps in pagination tests.

Index: gdb.python/python.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.python/python.exp,v
retrieving revision 1.34
diff -u -r1.34 python.exp
--- gdb.python/python.exp	22 Jun 2012 17:59:33 -0000	1.34
+++ gdb.python/python.exp	27 Jun 2012 13:35:24 -0000
@@ -112,7 +112,7 @@
 	pass $test
     }
 }
-gdb_test "q" "Quit" "verify pagination beforehand: q"
+gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination beforehand: q"
 
 gdb_test "python if gdb.execute('python print \"\\\\n\" * $lines', to_string=True) == \"\\n\" * [expr $lines + 1]: print \"yes\"" "yes" "gdb.execute does not page"
 
@@ -128,7 +128,7 @@
 	pass $test
     }
 }
-gdb_test "q" "Quit" "verify pagination afterwards: q"
+gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination afterwards: q"
 
 gdb_test_no_output "set height 0"
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] PR14291:  KeyboardInterrupt not caught for Python output
  2012-06-27 13:37 ` Tom Tromey
@ 2012-06-27 14:06   ` Michael Eager
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Eager @ 2012-06-27 14:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 06/27/2012 06:37 AM, Tom Tromey wrote:
>>>>>> "Michael" == Michael Eager<eager@eagerm.com>  writes:
>
> Michael>  2012-06-25  Michael Eager<eager@eagercon.com>
>
> Michael>  	* python/python.c (gdbpy_write): Check for interrupted
> Michael>  	output.
>
> This caused a regression:
>
> FAIL: gdb.python/python.exp: verify pagination beforehand: q
> FAIL: gdb.python/python.exp: verify pagination afterwards: q
>
> I'm checking in the appended.
> It just updates the regexps to match what is printed.

Sorry, I didn't notice that.

I tried to add a new test case to the test suite, but found it
difficult.  I didn't think that the existing tests would have
anything to do with the change.

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-06-27 14:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-25 12:33 [PATCH] PR14291: KeyboardInterrupt not caught for Python output Michael Eager
2012-06-25 15:26 ` Tom Tromey
2012-06-25 16:54   ` Michael Eager
2012-06-27 13:37 ` Tom Tromey
2012-06-27 14:06   ` Michael Eager

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox