[python] Avoid saving signal masks for Python API.

Message ID 1423100402-19533-1-git-send-email-agentzh@gmail.com
State New, archived
Headers

Commit Message

Yichun Zhang (agentzh) Feb. 5, 2015, 1:40 a.m. UTC
  Saving the siginal mask in sigsetjmp involes the expensive
sigprocmask syscall while in our Python API, it is not likely
for the C primitives to mess up with signals. Also, value_rtti_type
is heavily called from within Python API, which does not mess up with
signals either (feel free to prove me wrong).

This change leads to 11%+ speedup in our "lgcstat" [1] GDB python script
and 14%+ speedup in our "lgcpath" [2] script while Python 3.2 is used.

Alas, even the sigsetjmp calls without signal mask saving still
introduce significant performance overhead (also for the surrounding
code). Nevertheless, this patch can serve as a good start anyway and
we can try further optimizations along this way in the future.

If you have any better suggestions, please don't hesitate to drop
me a note.

[1] https://github.com/openresty/nginx-gdb-utils#lgcstat
[2] https://github.com/openresty/nginx-gdb-utils#lgcpath

gdb/ChangeLog:
    * gdb/common/gdb_setjmp.h: add the SIGSETJMP_NOSIG macro.
    * gdb/common/common-exceptions.h: add TRY_CATCH_NOSIG which is
      a variant of TRY_CATCH that calls SIGSETJMP_NOSIG instead.
    * gdb/cp-abi.c (value_rtti_type): replace TRY_CATCH with
      TRY_CATCH_NOSIG.
    * gdb/python/*: replace TRY_CATCH with TRY_CATCH_NOSIG.
---
 gdb/common/common-exceptions.h   | 10 ++++++++
 gdb/common/gdb_setjmp.h          |  2 ++
 gdb/cp-abi.c                     |  2 +-
 gdb/python/py-arch.c             |  2 +-
 gdb/python/py-block.c            |  2 +-
 gdb/python/py-breakpoint.c       | 14 +++++------
 gdb/python/py-cmd.c              |  2 +-
 gdb/python/py-finishbreakpoint.c | 12 +++++-----
 gdb/python/py-frame.c            | 36 ++++++++++++++--------------
 gdb/python/py-framefilter.c      | 46 +++++++++++++++++------------------
 gdb/python/py-gdb-readline.c     |  2 +-
 gdb/python/py-inferior.c         |  8 +++----
 gdb/python/py-infthread.c        |  2 +-
 gdb/python/py-lazy-string.c      |  2 +-
 gdb/python/py-linetable.c        |  2 +-
 gdb/python/py-objfile.c          |  4 ++--
 gdb/python/py-param.c            |  2 +-
 gdb/python/py-prettyprint.c      |  4 ++--
 gdb/python/py-symbol.c           | 10 ++++----
 gdb/python/py-type.c             | 34 +++++++++++++-------------
 gdb/python/py-utils.c            |  2 +-
 gdb/python/py-value.c            | 52 ++++++++++++++++++++--------------------
 gdb/python/python.c              | 16 ++++++-------
 23 files changed, 140 insertions(+), 128 deletions(-)
  

Comments

Pedro Alves Feb. 10, 2015, 6:32 p.m. UTC | #1
On 02/05/2015 01:40 AM, Yichun Zhang (agentzh) wrote:
> Saving the siginal mask in sigsetjmp involes the expensive
> sigprocmask syscall while in our Python API, it is not likely
> for the C primitives to mess up with signals. Also, value_rtti_type
> is heavily called from within Python API, which does not mess up with
> signals either (feel free to prove me wrong).
> 
> This change leads to 11%+ speedup in our "lgcstat" [1] GDB python script
> and 14%+ speedup in our "lgcpath" [2] script while Python 3.2 is used.
> 
> Alas, even the sigsetjmp calls without signal mask saving still
> introduce significant performance overhead (also for the surrounding
> code). Nevertheless, this patch can serve as a good start anyway and
> we can try further optimizations along this way in the future.
> 
> If you have any better suggestions, please don't hesitate to drop
> me a note.

Thanks.  Impressive the speed we can get out of this.

It seems to me this tackles things from the wrong end though.

I think we should enumerate the cases where we throw
from a signal handler, and treat _those_ specially.

Off the top of my head, that will be when immediate_quit it set,
the SIGFPE handler, though that seems to be broken anyway,
and when calling into the demangler and catch_demangler_crashes
is set (though that uses explicit sigsetjmp instead of TRY_CATCH),
and maybe the various SIGINT handlers.

We'll need to contain these for C++ too.

I'd be curious if you already see the speedup with this series

 https://sourceware.org/ml/gdb-patches/2015-02/msg00202.html

given that that switches TRY/CATCH to use C++ exceptions / Dwarf
unwinding instead of sigsetjmp/longjmp.

Thanks,
Pedro Alves
  
Pedro Alves April 12, 2016, 5:42 p.m. UTC | #2
Hi Yichun,

A year later, but ...

On 02/10/2015 06:32 PM, Pedro Alves wrote:
> On 02/05/2015 01:40 AM, Yichun Zhang (agentzh) wrote:
>> Saving the siginal mask in sigsetjmp involes the expensive
>> sigprocmask syscall while in our Python API, it is not likely
>> for the C primitives to mess up with signals. Also, value_rtti_type
>> is heavily called from within Python API, which does not mess up with
>> signals either (feel free to prove me wrong).
>>
>> This change leads to 11%+ speedup in our "lgcstat" [1] GDB python script
>> and 14%+ speedup in our "lgcpath" [2] script while Python 3.2 is used.
>>
>> Alas, even the sigsetjmp calls without signal mask saving still
>> introduce significant performance overhead (also for the surrounding
>> code). Nevertheless, this patch can serve as a good start anyway and
>> we can try further optimizations along this way in the future.
>>
>> If you have any better suggestions, please don't hesitate to drop
>> me a note.
> 
> Thanks.  Impressive the speed we can get out of this.
> 
> It seems to me this tackles things from the wrong end though.
> 
> I think we should enumerate the cases where we throw
> from a signal handler, and treat _those_ specially.
> 
> Off the top of my head, that will be when immediate_quit it set,
> the SIGFPE handler, though that seems to be broken anyway,
> and when calling into the demangler and catch_demangler_crashes
> is set (though that uses explicit sigsetjmp instead of TRY_CATCH),
> and maybe the various SIGINT handlers.
> 
> We'll need to contain these for C++ too.
> 
> I'd be curious if you already see the speedup with this series
> 
>  https://sourceware.org/ml/gdb-patches/2015-02/msg00202.html
> 
> given that that switches TRY/CATCH to use C++ exceptions / Dwarf
> unwinding instead of sigsetjmp/longjmp.

As you've seen in the other email, this is now complete.
gdb now uses setjmp/longmp for all TRY/CATCH blocks.  In addition, 
current master also uses C++ exceptions / Dwarf unwinding in C++
mode.  I'm curious on whether you could try your scripts again 
with current master.

I'm hoping for an extra speed up in C++ mode.  There's still a
little bit of overhead in TRY/CATCH to maintain the cleanups chain,
but should be less than in C.  If you could try C++ mode, it'd
be much appreciated.  You just need to configure gdb
with --enable-build-with-cxx for that (assuming GNU/Linux).

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
index e349ed0..4f5c843 100644
--- a/gdb/common/common-exceptions.h
+++ b/gdb/common/common-exceptions.h
@@ -158,6 +158,16 @@  extern int exceptions_state_mc_action_iter_1 (void);
      while (exceptions_state_mc_action_iter ()) \
        while (exceptions_state_mc_action_iter_1 ())
 
+/* A much more efficient version of TRY_CATCH without saving signal masks */
+#define TRY_CATCH_NOSIG(EXCEPTION,MASK) \
+     { \
+       SIGJMP_BUF *buf = \
+	 exceptions_state_mc_init (&(EXCEPTION), (MASK)); \
+       SIGSETJMP_NOSIG (*buf); \
+     } \
+     while (exceptions_state_mc_action_iter ()) \
+       while (exceptions_state_mc_action_iter_1 ())
+
 /* *INDENT-ON* */
 
 /* Hook to allow client-specific actions to be performed prior to
diff --git a/gdb/common/gdb_setjmp.h b/gdb/common/gdb_setjmp.h
index f5b67f6..2847b82 100644
--- a/gdb/common/gdb_setjmp.h
+++ b/gdb/common/gdb_setjmp.h
@@ -24,10 +24,12 @@ 
 #ifdef HAVE_SIGSETJMP
 #define SIGJMP_BUF		sigjmp_buf
 #define SIGSETJMP(buf)		sigsetjmp((buf), 1)
+#define SIGSETJMP_NOSIG(buf)	sigsetjmp((buf), 0)
 #define SIGLONGJMP(buf,val)	siglongjmp((buf), (val))
 #else
 #define SIGJMP_BUF		jmp_buf
 #define SIGSETJMP(buf)		setjmp(buf)
+#define SIGSETJMP_NOSIG(buf)	setjmp(buf)
 #define SIGLONGJMP(buf,val)	longjmp((buf), (val))
 #endif
 
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 9316c4c..a194733 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -111,7 +111,7 @@  value_rtti_type (struct value *v, int *full,
 
   if ((current_cp_abi.rtti_type) == NULL)
     return NULL;
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY_CATCH_NOSIG (e, RETURN_MASK_ERROR)
     {
       ret = (*current_cp_abi.rtti_type) (v, full, top, using_enc);
     }
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index da6801e..036ec36 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -217,7 +217,7 @@  archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
           return NULL;  /* PyList_Append Sets the exception.  */
         }
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
         {
           insn_len = gdb_print_insn (gdbarch, pc, memfile, NULL);
         }
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 140c521..da7a109 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -378,7 +378,7 @@  gdbpy_block_for_pc (PyObject *self, PyObject *args)
   if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       cust = find_pc_compunit_symtab (pc);
 
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 7807e4e..00f8203 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -136,7 +136,7 @@  bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
   if (cmp < 0)
     return -1;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (cmp == 1)
 	enable_breakpoint (self_bp->bp);
@@ -242,7 +242,7 @@  bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
       if (! gdb_py_int_as_long (newvalue, &id))
 	return -1;
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  valid_id = valid_task_id (id);
 	}
@@ -282,7 +282,7 @@  bppy_delete_breakpoint (PyObject *self, PyObject *args)
 
   BPPY_REQUIRE_VALID (self_bp);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       delete_breakpoint (self_bp->bp);
     }
@@ -321,7 +321,7 @@  bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
   if (value < 0)
     value = 0;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       set_ignore_count (self_bp->number, (int) value, 0);
     }
@@ -448,7 +448,7 @@  bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
 	return -1;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       set_breakpoint_condition (self_bp->bp, exp, 0);
     }
@@ -483,7 +483,7 @@  bppy_get_commands (PyObject *self, void *closure)
   chain = make_cleanup_ui_file_delete (string_file);
 
   ui_out_redirect (current_uiout, string_file);
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       print_command_lines (current_uiout, breakpoint_commands (bp), 0);
     }
@@ -644,7 +644,7 @@  bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
   bppy_pending_object->number = -1;
   bppy_pending_object->bp = NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       char *copy = xstrdup (spec);
       struct cleanup *cleanup = make_cleanup (xfree, copy);
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index c0b6464..0e481da 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -637,7 +637,7 @@  cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
 
   Py_INCREF (self);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct cmd_list_element *cmd;
 
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 94f19e0..0ebd10a 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -101,7 +101,7 @@  bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
   if (!self_finishbp->return_type)
     return;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct value *function =
         value_object_to_value (self_finishbp->function_value);
@@ -136,7 +136,7 @@  bpfinishpy_post_stop_hook (struct gdbpy_breakpoint_object *bp_obj)
 {
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       /* Can't delete it here, but it will be removed at the next stop.  */
       disable_breakpoint (bp_obj->bp);
@@ -174,7 +174,7 @@  bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
                                     &frame_obj, &internal))
     return -1;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       /* Default frame to newest frame if necessary.  */
       if (frame_obj == NULL)
@@ -243,7 +243,7 @@  bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
   self_bpfinish->return_type = NULL;
   self_bpfinish->function_value = NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (get_frame_pc_if_available (frame, &pc))
         {
@@ -284,7 +284,7 @@  bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
   bppy_pending_object->number = -1;
   bppy_pending_object->bp = NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       /* Set a breakpoint on the return address.  */
       finish_pc = get_frame_pc (prev_frame);
@@ -357,7 +357,7 @@  bpfinishpy_detect_out_scope_cb (struct breakpoint *b, void *args)
       /* Check scope if not currently stopped at the FinishBreakpoint.  */
       if (b != bp_stopped)
         {
-          TRY_CATCH (except, RETURN_MASK_ALL)
+          TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
             {
               if (b->pspace == current_inferior ()->pspace
                   && (!target_has_registers
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 9ef8608..83c25b9 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -103,7 +103,7 @@  frapy_is_valid (PyObject *self, PyObject *args)
   struct frame_info *frame = NULL;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       frame = frame_object_to_frame_info (self);
     }
@@ -127,7 +127,7 @@  frapy_name (PyObject *self, PyObject *args)
   PyObject *result;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
@@ -163,7 +163,7 @@  frapy_type (PyObject *self, PyObject *args)
   enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning.  */
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
@@ -184,7 +184,7 @@  frapy_arch (PyObject *self, PyObject *args)
   frame_object *obj = (frame_object *) self;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
     }
@@ -203,7 +203,7 @@  frapy_unwind_stop_reason (PyObject *self, PyObject *args)
   volatile struct gdb_exception except;
   enum unwind_stop_reason stop_reason;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
     }
@@ -224,7 +224,7 @@  frapy_pc (PyObject *self, PyObject *args)
   struct frame_info *frame;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
@@ -248,7 +248,7 @@  frapy_read_register (PyObject *self, PyObject *args)
   if (!PyArg_ParseTuple (args, "s", &regnum_str))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct frame_info *frame;
       int regnum;
@@ -279,7 +279,7 @@  frapy_block (PyObject *self, PyObject *args)
   const struct block *block = NULL, *fn_block;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
       block = get_frame_block (frame, NULL);
@@ -318,7 +318,7 @@  frapy_function (PyObject *self, PyObject *args)
   struct frame_info *frame;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
@@ -345,7 +345,7 @@  frame_info_to_frame_object (struct frame_info *frame)
   if (frame_obj == NULL)
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
 
       /* Try to get the previous frame, to determine if this is the last frame
@@ -385,7 +385,7 @@  frapy_older (PyObject *self, PyObject *args)
   volatile struct gdb_exception except;
   PyObject *prev_obj = NULL;   /* Initialize to appease gcc warning.  */
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
@@ -415,7 +415,7 @@  frapy_newer (PyObject *self, PyObject *args)
   volatile struct gdb_exception except;
   PyObject *next_obj = NULL;   /* Initialize to appease gcc warning.  */
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
@@ -445,7 +445,7 @@  frapy_find_sal (PyObject *self, PyObject *args)
   volatile struct gdb_exception except;
   PyObject *sal_obj = NULL;   /* Initialize to appease gcc warning.  */
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
@@ -502,7 +502,7 @@  frapy_read_var (PyObject *self, PyObject *args)
 	    }
 	}
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  FRAPY_REQUIRE_VALID (self, frame);
 
@@ -535,7 +535,7 @@  frapy_read_var (PyObject *self, PyObject *args)
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, frame);
 
@@ -554,7 +554,7 @@  frapy_select (PyObject *self, PyObject *args)
   struct frame_info *fi;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       FRAPY_REQUIRE_VALID (self, fi);
 
@@ -574,7 +574,7 @@  gdbpy_newest_frame (PyObject *self, PyObject *args)
   struct frame_info *frame = NULL;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       frame = get_current_frame ();
     }
@@ -592,7 +592,7 @@  gdbpy_selected_frame (PyObject *self, PyObject *args)
   struct frame_info *frame = NULL;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       frame = get_selected_frame ("No frame is currently selected.");
     }
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 97dce89..3c8a986 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -203,7 +203,7 @@  py_print_type (struct ui_out *out, struct value *val)
 {
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct type *type;
       struct ui_file *stb;
@@ -257,7 +257,7 @@  py_print_value (struct ui_out *out, struct value *val,
     {
       struct type *type = NULL;
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  type = check_typedef (value_type (val));
 	}
@@ -280,7 +280,7 @@  py_print_value (struct ui_out *out, struct value *val,
 
   if (should_print)
     {
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  struct ui_file *stb;
 	  struct cleanup *cleanup;
@@ -376,7 +376,7 @@  py_print_single_arg (struct ui_out *out,
   else
     val = fv;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
 
@@ -511,7 +511,7 @@  enumerate_args (PyObject *iter,
 
   opts.deref_ref = 1;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       annotate_frame_args ();
     }
@@ -578,7 +578,7 @@  enumerate_args (PyObject *iter,
 	      goto error;
 	    }
 
-	  TRY_CATCH (except, RETURN_MASK_ALL)
+	  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	    {
 	      read_frame_arg (sym, frame, &arg, &entryarg);
 	    }
@@ -612,7 +612,7 @@  enumerate_args (PyObject *iter,
 	    {
 	      if (arg.entry_kind != print_entry_values_only)
 		{
-		  TRY_CATCH (except, RETURN_MASK_ALL)
+		  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 		    {
 		      ui_out_text (out, ", ");
 		      ui_out_wrap_hint (out, "    ");
@@ -664,7 +664,7 @@  enumerate_args (PyObject *iter,
       item = PyIter_Next (iter);
       if (item != NULL)
 	{
-	  TRY_CATCH (except, RETURN_MASK_ALL)
+	  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	    {
 	      ui_out_text (out, ", ");
 	    }
@@ -678,7 +678,7 @@  enumerate_args (PyObject *iter,
       else if (PyErr_Occurred ())
 	goto error;
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  annotate_arg_end ();
 	}
@@ -761,7 +761,7 @@  enumerate_locals (PyObject *iter,
       /* If the object did not provide a value, read it.  */
       if (val == NULL)
 	{
-	  TRY_CATCH (except, RETURN_MASK_ALL)
+	  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	    {
 	      val = read_var_value (sym, frame);
 	    }
@@ -781,7 +781,7 @@  enumerate_locals (PyObject *iter,
 	  if (print_args_field || args_type != NO_VALUES)
 	    make_cleanup_ui_out_tuple_begin_end (out, NULL);
 	}
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  if (! ui_out_is_mi_like_p (out))
 	    {
@@ -838,7 +838,7 @@  enumerate_locals (PyObject *iter,
 
       do_cleanups (locals_cleanups);
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  ui_out_text (out, "\n");
 	}
@@ -954,7 +954,7 @@  py_print_args (PyObject *filter,
 
   make_cleanup_ui_out_list_begin_end (out, "args");
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       annotate_frame_args ();
       if (! ui_out_is_mi_like_p (out))
@@ -971,7 +971,7 @@  py_print_args (PyObject *filter,
 	== EXT_LANG_BT_ERROR)
       goto args_error;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (! ui_out_is_mi_like_p (out))
 	ui_out_text (out, ")");
@@ -1042,7 +1042,7 @@  py_print_frame (PyObject *filter, int flags,
   if (frame == NULL)
     goto error;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       gdbarch = get_frame_arch (frame);
     }
@@ -1117,7 +1117,7 @@  py_print_frame (PyObject *filter, int flags,
 
       slot = (struct frame_info **) htab_find_slot (levels_printed,
 						    frame, INSERT);
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  level = frame_relative_level (frame);
 
@@ -1150,7 +1150,7 @@  py_print_frame (PyObject *filter, int flags,
 	 print nothing.  */
       if (opts.addressprint && has_addr)
 	{
-	  TRY_CATCH (except, RETURN_MASK_ALL)
+	  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	    {
 	      annotate_frame_address ();
 	      ui_out_field_core_addr (out, "addr", gdbarch, address);
@@ -1209,7 +1209,7 @@  py_print_frame (PyObject *filter, int flags,
 		}
 
 
-	      TRY_CATCH (except, RETURN_MASK_ALL)
+	      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 		{
 		  annotate_frame_function_name ();
 		  if (function == NULL)
@@ -1242,7 +1242,7 @@  py_print_frame (PyObject *filter, int flags,
   /* File name/source/line number information.  */
   if (print_frame_info)
     {
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  annotate_frame_source_begin ();
 	}
@@ -1269,7 +1269,7 @@  py_print_frame (PyObject *filter, int flags,
 		    }
 
 		  make_cleanup (xfree, filename);
-		  TRY_CATCH (except, RETURN_MASK_ALL)
+		  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 		    {
 		      ui_out_wrap_hint (out, "   ");
 		      ui_out_text (out, " at ");
@@ -1300,7 +1300,7 @@  py_print_frame (PyObject *filter, int flags,
 	      if (py_line != Py_None)
 		{
 		  line = PyLong_AsLong (py_line);
-		  TRY_CATCH (except, RETURN_MASK_ALL)
+		  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 		    {
 		      ui_out_text (out, ":");
 		      annotate_frame_source_line ();
@@ -1324,7 +1324,7 @@  py_print_frame (PyObject *filter, int flags,
      elided frames, so if MI output detected do not send newline.  */
   if (! ui_out_is_mi_like_p (out))
     {
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  annotate_frame_end ();
 	  ui_out_text (out, "\n");
@@ -1481,7 +1481,7 @@  gdbpy_apply_frame_filter (const struct extension_language_defn *extlang,
   if (!gdb_python_initialized)
     return EXT_LANG_BT_NO_FILTERS;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       gdbarch = get_frame_arch (frame);
     }
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index 7a5c853..11e046f 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -39,7 +39,7 @@  gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
   char *p = NULL, *q;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     p = command_line_input (prompt, 0, "python");
 
   /* Detect user interrupt (Ctrl-C).  */
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index ae73040..e57506f 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -399,7 +399,7 @@  infpy_threads (PyObject *self, PyObject *args)
 
   INFPY_REQUIRE_VALID (inf_obj);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     update_thread_list ();
   GDB_PY_HANDLE_EXCEPTION (except);
 
@@ -514,7 +514,7 @@  infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
       || get_addr_from_python (length_obj, &length) < 0)
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       buffer = xmalloc (length);
 
@@ -588,7 +588,7 @@  infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw)
   else if (get_addr_from_python (length_obj, &length) < 0)
     goto fail;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       write_memory_with_notification (addr, (gdb_byte *) buffer, length);
     }
@@ -760,7 +760,7 @@  infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
       goto fail;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       found = target_search_memory (start_addr, length,
 				    buffer, pattern_size,
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index fa4cc25..fda0f6d 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -151,7 +151,7 @@  thpy_switch (PyObject *self, PyObject *args)
 
   THPY_REQUIRE_VALID (thread_obj);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       switch_to_thread (thread_obj->thread->ptid);
     }
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index 7df6a9e..0b576e6 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -105,7 +105,7 @@  stpy_convert_to_value  (PyObject *self, PyObject *args)
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       val = value_at_lazy (self_string->type, self_string->address);
     }
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index 49007ce..55cbd3b 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -179,7 +179,7 @@  ltpy_get_pcs_for_line (PyObject *self, PyObject *args)
   if (! PyArg_ParseTuple (args, GDB_PY_LL_ARG, &py_line))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       pcs = find_pcs_for_symtab_line (symtab, py_line, &best_entry);
     }
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 0aecaf6..3046123 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -135,7 +135,7 @@  objfpy_get_build_id (PyObject *self, void *closure)
 
   OBJFPY_REQUIRE_VALID (obj);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       build_id = build_id_bfd_get (objfile->obfd);
     }
@@ -393,7 +393,7 @@  objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
   if (!PyArg_ParseTupleAndKeywords (args, kw, "s", keywords, &file_name))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       bfd *abfd = symfile_bfd_open (file_name);
 
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index 48173c8..fde38bb 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -724,7 +724,7 @@  parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
 
   Py_INCREF (self);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       add_setshow_generic (parmclass, (enum command_class) cmdtype,
 			   cmd_name, obj,
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index f4c91d0..57ad42a 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -217,7 +217,7 @@  pretty_print_one_value (PyObject *printer, struct value **out_value)
   PyObject *result = NULL;
 
   *out_value = NULL;
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL);
       if (result)
@@ -805,7 +805,7 @@  gdbpy_get_varobj_pretty_printer (struct value *value)
   PyObject *pretty_printer = NULL;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       value = value_copy (value);
     }
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 696935b..9b57f7d 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -197,7 +197,7 @@  sympy_needs_frame (PyObject *self, void *closure)
 
   SYMPY_REQUIRE_VALID (self, symbol);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       result = symbol_read_needs_frame (symbol);
     }
@@ -264,7 +264,7 @@  sympy_value (PyObject *self, PyObject *args)
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (frame_obj != NULL)
 	{
@@ -378,7 +378,7 @@  gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
       struct frame_info *selected_frame;
       volatile struct gdb_exception except;
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  selected_frame = get_selected_frame (_("No frame selected."));
 	  block = get_frame_block (selected_frame, NULL);
@@ -386,7 +386,7 @@  gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
       GDB_PY_HANDLE_EXCEPTION (except);
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       symbol = lookup_symbol (name, block, domain, &is_a_field_of_this);
     }
@@ -436,7 +436,7 @@  gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
 				     &domain))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       symbol = lookup_global_symbol (name, NULL, domain);
     }
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index bf92363..5cd076b 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -345,7 +345,7 @@  typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind)
   struct type *type = ((type_object *) py_type)->type;
   struct type *checked_type = type;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       CHECK_TYPEDEF (checked_type);
     }
@@ -451,7 +451,7 @@  typy_strip_typedefs (PyObject *self, PyObject *args)
   struct type *type = ((type_object *) self)->type;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       type = check_typedef (type);
     }
@@ -470,7 +470,7 @@  typy_get_composite (struct type *type)
 
   for (;;)
     {
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  CHECK_TYPEDEF (type);
 	}
@@ -535,7 +535,7 @@  typy_array_1 (PyObject *self, PyObject *args, int is_vector)
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       array = lookup_array_range_type (type, n1, n2);
       if (is_vector)
@@ -569,7 +569,7 @@  typy_pointer (PyObject *self, PyObject *args)
   struct type *type = ((type_object *) self)->type;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       type = lookup_pointer_type (type);
     }
@@ -650,7 +650,7 @@  typy_reference (PyObject *self, PyObject *args)
   struct type *type = ((type_object *) self)->type;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       type = lookup_reference_type (type);
     }
@@ -682,7 +682,7 @@  typy_const (PyObject *self, PyObject *args)
   struct type *type = ((type_object *) self)->type;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       type = make_cv_type (1, 0, type, NULL);
     }
@@ -698,7 +698,7 @@  typy_volatile (PyObject *self, PyObject *args)
   struct type *type = ((type_object *) self)->type;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       type = make_cv_type (0, 1, type, NULL);
     }
@@ -714,7 +714,7 @@  typy_unqualified (PyObject *self, PyObject *args)
   struct type *type = ((type_object *) self)->type;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       type = make_cv_type (0, 0, type, NULL);
     }
@@ -730,7 +730,7 @@  typy_get_sizeof (PyObject *self, void *closure)
   struct type *type = ((type_object *) self)->type;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       check_typedef (type);
     }
@@ -745,7 +745,7 @@  typy_lookup_typename (const char *type_name, const struct block *block)
   struct type *type = NULL;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (!strncmp (type_name, "struct ", 7))
 	type = lookup_struct (type_name + 7, NULL);
@@ -784,7 +784,7 @@  typy_lookup_type (struct demangle_component *demangled,
       if (! type)
 	return NULL;
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  /* If the demangled_type matches with one of the types
 	     below, run the corresponding function and save the type
@@ -845,7 +845,7 @@  typy_legacy_template_argument (struct type *type, const struct block *block,
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       /* Note -- this is not thread-safe.  */
       info = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
@@ -919,7 +919,7 @@  typy_template_argument (PyObject *self, PyObject *args)
 	}
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       type = check_typedef (type);
       if (TYPE_CODE (type) == TYPE_CODE_REF)
@@ -950,7 +950,7 @@  typy_template_argument (PyObject *self, PyObject *args)
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       val = value_of_variable (sym, block);
     }
@@ -967,7 +967,7 @@  typy_str (PyObject *self)
   long length = 0;
   PyObject *result;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct cleanup *old_chain;
       struct ui_file *stb;
@@ -1015,7 +1015,7 @@  typy_richcompare (PyObject *self, PyObject *other, int op)
     result = Py_EQ;
   else
     {
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  result = types_deeply_equal (type1, type2);
 	}
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 58a5934..de257e5 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -318,7 +318,7 @@  get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
     {
       volatile struct gdb_exception except;
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  *addr = value_as_address (value_object_to_value (obj));
 	}
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 5a13777..53b68a5 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -175,7 +175,7 @@  valpy_dereference (PyObject *self, PyObject *args)
   volatile struct gdb_exception except;
   PyObject *result = NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct value *res_val;
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
@@ -203,7 +203,7 @@  valpy_referenced_value (PyObject *self, PyObject *args)
   volatile struct gdb_exception except;
   PyObject *result = NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct value *self_val, *res_val;
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
@@ -239,7 +239,7 @@  valpy_get_address (PyObject *self, void *closure)
 
   if (!val_obj->address)
     {
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  struct value *res_val;
 	  struct cleanup *cleanup
@@ -292,7 +292,7 @@  valpy_get_dynamic_type (PyObject *self, void *closure)
       return obj->dynamic_type;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct value *val = obj->value;
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
@@ -364,7 +364,7 @@  valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
 				    &user_encoding, &length))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
 
@@ -407,7 +407,7 @@  valpy_string (PyObject *self, PyObject *args, PyObject *kw)
 				    &user_encoding, &errors, &length))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       LA_GET_STRING (value, &buffer, &length, &char_type, &la_encoding);
     }
@@ -442,7 +442,7 @@  valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op)
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct value *val = ((value_object *) self)->value;
       struct value *res_val;
@@ -524,7 +524,7 @@  value_has_field (struct value *v, PyObject *field)
       return -1;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       val_type = value_type (v);
       val_type = check_typedef (val_type);
@@ -673,7 +673,7 @@  valpy_getitem (PyObject *self, PyObject *key)
 	}
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct value *tmp = self_value->value;
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
@@ -751,7 +751,7 @@  valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
   struct value *mark = value_mark ();
   PyObject *result = NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       ftype = check_typedef (value_type (function));
     }
@@ -790,7 +790,7 @@  valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
 	}
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (mark);
       struct value *return_value;
@@ -817,7 +817,7 @@  valpy_str (PyObject *self)
   get_user_print_options (&opts);
   opts.deref_ref = 0;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct ui_file *stb = mem_fileopen ();
       struct cleanup *old_chain = make_cleanup_ui_file_delete (stb);
@@ -844,7 +844,7 @@  valpy_get_is_optimized_out (PyObject *self, void *closure)
   int opt = 0;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       opt = value_optimized_out (value);
     }
@@ -864,7 +864,7 @@  valpy_get_is_lazy (PyObject *self, void *closure)
   int opt = 0;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       opt = value_lazy (value);
     }
@@ -883,7 +883,7 @@  valpy_fetch_lazy (PyObject *self, PyObject *args)
   struct value *value = ((value_object *) self)->value;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (value_lazy (value))
 	value_fetch_lazy (value);
@@ -929,7 +929,7 @@  valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
   volatile struct gdb_exception except;
   PyObject *result = NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct value *arg1, *arg2;
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
@@ -1106,7 +1106,7 @@  valpy_negative (PyObject *self)
   volatile struct gdb_exception except;
   PyObject *result = NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       /* Perhaps overkill, but consistency has some virtue.  */
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
@@ -1134,7 +1134,7 @@  valpy_absolute (PyObject *self)
   volatile struct gdb_exception except;
   int isabs = 1;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
 
@@ -1160,7 +1160,7 @@  valpy_nonzero (PyObject *self)
   struct type *type;
   int nonzero = 0; /* Appease GCC warning.  */
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       type = check_typedef (value_type (self_value->value));
 
@@ -1191,7 +1191,7 @@  valpy_invert (PyObject *self)
   struct value *val = NULL;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       val = value_complement (((value_object *) self)->value);
     }
@@ -1262,7 +1262,7 @@  valpy_richcompare (PyObject *self, PyObject *other, int op)
 	return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct value *value_other, *mark = value_mark ();
       struct cleanup *cleanup;
@@ -1329,7 +1329,7 @@  valpy_int (PyObject *self)
   LONGEST l = 0;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (!is_integral_type (type))
 	error (_("Cannot convert value to int."));
@@ -1351,7 +1351,7 @@  valpy_long (PyObject *self)
   LONGEST l = 0;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       CHECK_TYPEDEF (type);
 
@@ -1375,7 +1375,7 @@  valpy_float (PyObject *self)
   double d = 0;
   volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       CHECK_TYPEDEF (type);
 
@@ -1436,7 +1436,7 @@  convert_value_from_python (PyObject *obj)
 
   gdb_assert (obj != NULL);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (PyBool_Check (obj))
 	{
@@ -1554,7 +1554,7 @@  gdbpy_history (PyObject *self, PyObject *args)
   if (!PyArg_ParseTuple (args, "i", &i))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       res_val = access_value_history (i);
     }
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 344d8d2..73604fe 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -575,7 +575,7 @@  gdbpy_parameter (PyObject *self, PyObject *args)
 
   newarg = concat ("show ", arg, (char *) NULL);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd);
     }
@@ -646,7 +646,7 @@  execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
       to_string = cmp;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       /* Copy the argument text in case the command modifies it.  */
       char *copy = xstrdup (arg);
@@ -727,7 +727,7 @@  gdbpy_decode_line (PyObject *self, PyObject *args)
   cleanups = make_cleanup (null_cleanup, NULL);
 
   sals.sals = NULL;
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       if (arg)
 	{
@@ -829,7 +829,7 @@  gdbpy_parse_and_eval (PyObject *self, PyObject *args)
   if (!PyArg_ParseTuple (args, "s", &expr_str))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       result = parse_and_eval (expr_str);
     }
@@ -851,7 +851,7 @@  gdbpy_find_pc_line (PyObject *self, PyObject *args)
   if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc_llu))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       struct symtab_and_line sal;
       CORE_ADDR pc;
@@ -1102,7 +1102,7 @@  gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
 				     &stream_type))
     return NULL;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
     {
       switch (stream_type)
         {
@@ -1179,7 +1179,7 @@  gdbpy_print_stack (void)
       /* PyErr_Print doesn't necessarily end output with a newline.
 	 This works because Python's stdout/stderr is fed through
 	 printf_filtered.  */
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  begin_line ();
 	}
@@ -1196,7 +1196,7 @@  gdbpy_print_stack (void)
       msg = gdbpy_exception_to_string (ptype, pvalue);
       type = gdbpy_obj_to_string (ptype);
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY_CATCH_NOSIG (except, RETURN_MASK_ALL)
 	{
 	  if (msg == NULL)
 	    {