[RFA,06/10] Allow C-c to work in backtrace in more cases

Message ID 20170425194113.17862-7-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey April 25, 2017, 7:41 p.m. UTC
  PR cli/17716 notes that it is difficult to C-c (or "q" at a pagination
prompt) while backtracing using a frame filter.  One reason for this
is that many places in py-framefilter.c use RETURN_MASK_ALL in a
try/catch.

This patch changes these spots to use RETURN_MASK_ERROR instead.  This
is safe to do because this entire file is exception safe now.

ChangeLog
2017-04-25  Tom Tromey  <tom@tromey.com>

	PR cli/17716:
	* python/py-framefilter.c (py_print_type, py_print_value)
	(enumerate_args, py_print_args, gdbpy_apply_frame_filter): Use
	RETURN_MASK_ERROR.
---
 gdb/ChangeLog               |  7 +++++++
 gdb/python/py-framefilter.c | 22 +++++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)
  

Comments

Phil Muldoon April 28, 2017, 2:55 p.m. UTC | #1
On 25/04/17 20:41, Tom Tromey wrote:
> PR cli/17716 notes that it is difficult to C-c (or "q" at a pagination
> prompt) while backtracing using a frame filter.  One reason for this
> is that many places in py-framefilter.c use RETURN_MASK_ALL in a
> try/catch.
> 
> This patch changes these spots to use RETURN_MASK_ERROR instead.  This
> is safe to do because this entire file is exception safe now.
> 
> ChangeLog
> 2017-04-25  Tom Tromey  <tom@tromey.com>
> 
> 	PR cli/17716:
> 	* python/py-framefilter.c (py_print_type, py_print_value)
> 	(enumerate_args, py_print_args, gdbpy_apply_frame_filter): Use
> 	RETURN_MASK_ERROR.

Ugh that was a simple mistake from when I submitted the patch and thanks for cleaning that up.

Patch LGTM

Cheers,

Phil
  
Pedro Alves June 27, 2017, 4:46 p.m. UTC | #2
On 04/25/2017 08:41 PM, Tom Tromey wrote:
> PR cli/17716 notes that it is difficult to C-c (or "q" at a pagination
> prompt) while backtracing using a frame filter.  One reason for this
> is that many places in py-framefilter.c use RETURN_MASK_ALL in a
> try/catch.
> 
> This patch changes these spots to use RETURN_MASK_ERROR instead.  This
> is safe to do because this entire file is exception safe now.

Are any of these returning back to the Python runtime?  If so, then
we can't let C++ exceptions cross it.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6b0c584..d0e0be4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@ 
 2017-04-25  Tom Tromey  <tom@tromey.com>
 
+	PR cli/17716:
+	* python/py-framefilter.c (py_print_type, py_print_value)
+	(enumerate_args, py_print_args, gdbpy_apply_frame_filter): Use
+	RETURN_MASK_ERROR.
+
+2017-04-25  Tom Tromey  <tom@tromey.com>
+
 	* python/py-framefilter.c (enumerate_args): Use
 	gdb::unique_xmalloc_ptr.
 
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 2ae2158..e0a7bd0 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -215,7 +215,7 @@  py_print_type (struct ui_out *out, struct value *val)
       type_print (value_type (val), "", &stb, -1);
       out->field_stream ("type", stb);
     }
-  CATCH (except, RETURN_MASK_ALL)
+  CATCH (except, RETURN_MASK_ERROR)
     {
       gdbpy_convert_exception (except);
       return EXT_LANG_BT_ERROR;
@@ -255,7 +255,7 @@  py_print_value (struct ui_out *out, struct value *val,
 	{
 	  type = check_typedef (value_type (val));
 	}
-      CATCH (except, RETURN_MASK_ALL)
+      CATCH (except, RETURN_MASK_ERROR)
 	{
 	  gdbpy_convert_exception (except);
 	  return EXT_LANG_BT_ERROR;
@@ -282,7 +282,7 @@  py_print_value (struct ui_out *out, struct value *val,
 	  common_val_print (val, &stb, indent, opts, language);
 	  out->field_stream ("value", stb);
 	}
-      CATCH (except, RETURN_MASK_ALL)
+      CATCH (except, RETURN_MASK_ERROR)
 	{
 	  gdbpy_convert_exception (except);
 	  return EXT_LANG_BT_ERROR;
@@ -497,7 +497,7 @@  enumerate_args (PyObject *iter,
     {
       annotate_frame_args ();
     }
-  CATCH (except, RETURN_MASK_ALL)
+  CATCH (except, RETURN_MASK_ERROR)
     {
       gdbpy_convert_exception (except);
       return EXT_LANG_BT_ERROR;
@@ -553,7 +553,7 @@  enumerate_args (PyObject *iter,
 	    {
 	      read_frame_arg (sym, frame, &arg, &entryarg);
 	    }
-	  CATCH (except, RETURN_MASK_ALL)
+	  CATCH (except, RETURN_MASK_ERROR)
 	    {
 	      gdbpy_convert_exception (except);
 	      return EXT_LANG_BT_ERROR;
@@ -586,7 +586,7 @@  enumerate_args (PyObject *iter,
 		      out->text (", ");
 		      out->wrap_hint ("    ");
 		    }
-		  CATCH (except, RETURN_MASK_ALL)
+		  CATCH (except, RETURN_MASK_ERROR)
 		    {
 		      gdbpy_convert_exception (except);
 		      return EXT_LANG_BT_ERROR;
@@ -622,7 +622,7 @@  enumerate_args (PyObject *iter,
 	    {
 	      out->text (", ");
 	    }
-	  CATCH (except, RETURN_MASK_ALL)
+	  CATCH (except, RETURN_MASK_ERROR)
 	    {
 	      gdbpy_convert_exception (except);
 	      return EXT_LANG_BT_ERROR;
@@ -636,7 +636,7 @@  enumerate_args (PyObject *iter,
 	{
 	  annotate_arg_end ();
 	}
-      CATCH (except, RETURN_MASK_ALL)
+      CATCH (except, RETURN_MASK_ERROR)
 	{
 	  gdbpy_convert_exception (except);
 	  return EXT_LANG_BT_ERROR;
@@ -867,7 +867,7 @@  py_print_args (PyObject *filter,
       if (! out->is_mi_like_p ())
 	out->text (" (");
     }
-  CATCH (except, RETURN_MASK_ALL)
+  CATCH (except, RETURN_MASK_ERROR)
     {
       gdbpy_convert_exception (except);
       return EXT_LANG_BT_ERROR;
@@ -884,7 +884,7 @@  py_print_args (PyObject *filter,
       if (! out->is_mi_like_p ())
 	out->text (")");
     }
-  CATCH (except, RETURN_MASK_ALL)
+  CATCH (except, RETURN_MASK_ERROR)
     {
       gdbpy_convert_exception (except);
       return EXT_LANG_BT_ERROR;
@@ -1336,7 +1336,7 @@  gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
     {
       gdbarch = get_frame_arch (frame);
     }
-  CATCH (except, RETURN_MASK_ALL)
+  CATCH (except, RETURN_MASK_ERROR)
     {
       /* Let gdb try to print the stack trace.  */
       return EXT_LANG_BT_NO_FILTERS;