This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Split TRY_CATCH into TRY + CATCH


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=492d29ea1c9a8b2c7d5193908119a4e27c045687

commit 492d29ea1c9a8b2c7d5193908119a4e27c045687
Author: Pedro Alves <palves@redhat.com>
Date:   Sat Mar 7 15:14:14 2015 +0000

    Split TRY_CATCH into TRY + CATCH
    
    This patch splits the TRY_CATCH macro into three, so that we go from
    this:
    
    ~~~
      volatile gdb_exception ex;
    
      TRY_CATCH (ex, RETURN_MASK_ERROR)
        {
        }
      if (ex.reason < 0)
        {
        }
    ~~~
    
    to this:
    
    ~~~
      TRY
        {
        }
      CATCH (ex, RETURN_MASK_ERROR)
        {
        }
      END_CATCH
    ~~~
    
    Thus, we'll be getting rid of the local volatile exception object, and
    declaring the caught exception in the catch block.
    
    This allows reimplementing TRY/CATCH in terms of C++ exceptions when
    building in C++ mode, while still allowing to build GDB in C mode
    (using setjmp/longjmp), as a transition step.
    
    TBC, after this patch, is it _not_ valid to have code between the TRY
    and the CATCH blocks, like:
    
      TRY
        {
        }
    
      // some code here.
    
      CATCH (ex, RETURN_MASK_ERROR)
        {
        }
      END_CATCH
    
    Just like it isn't valid to do that with C++'s native try/catch.
    
    By switching to creating the exception object inside the CATCH block
    scope, we can get rid of all the explicitly allocated volatile
    exception objects all over the tree, and map the CATCH block more
    directly to C++'s catch blocks.
    
    The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
    done with a script, rerun from scratch at every rebase, no manual
    editing involved.  After the mechanical conversion, a few places
    needed manual intervention, to fix preexisting cases where we were
    using the exception object outside of the TRY_CATCH block, and cases
    where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
    after this patch].  The result was folded into this patch so that GDB
    still builds at each incremental step.
    
    END_CATCH is necessary for two reasons:
    
    First, because we name the exception object in the CATCH block, which
    requires creating a scope, which in turn must be closed somewhere.
    Declaring the exception variable in the initializer field of a for
    block, like:
    
      #define CATCH(EXCEPTION, mask) \
        for (struct gdb_exception EXCEPTION; \
             exceptions_state_mc_catch (&EXCEPTION, MASK); \
    	 EXCEPTION = exception_none)
    
    would avoid needing END_CATCH, but alas, in C mode, we build with C90,
    which doesn't allow mixed declarations and code.
    
    Second, because when TRY/CATCH are wired to real C++ try/catch, as
    long as we need to handle cleanup chains, even if there's no CATCH
    block that wants to catch the exception, we need for stop at every
    frame in the unwind chain and run cleanups, then rethrow.  That will
    be done in END_CATCH.
    
    After we require C++, we'll still need TRY/CATCH/END_CATCH until
    cleanups are completely phased out -- TRY/CATCH in C++ mode will
    save/restore the current cleanup chain, like in C mode, and END_CATCH
    catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
    that C++ cleanups and exceptions can coexist.
    
    IMO, this still makes the TRY/CATCH code look a bit more like a
    newcomer would expect, so IMO worth it even if we weren't considering
    C++.
    
    gdb/ChangeLog.
    2015-03-07  Pedro Alves  <palves@redhat.com>
    
    	* common/common-exceptions.c (struct catcher) <exception>: No
    	longer a pointer to volatile exception.  Now an exception value.
    	<mask>: Delete field.
    	(exceptions_state_mc_init): Remove all parameters.  Adjust.
    	(exceptions_state_mc): No longer pop the catcher here.
    	(exceptions_state_mc_catch): New function.
    	(throw_exception): Adjust.
    	* common/common-exceptions.h (exceptions_state_mc_init): Remove
    	all parameters.
    	(exceptions_state_mc_catch): Declare.
    	(TRY_CATCH): Rename to ...
    	(TRY): ... this.  Remove EXCEPTION and MASK parameters.
    	(CATCH, END_CATCH): New.
    	All callers adjusted.
    
    gdb/gdbserver/ChangeLog:
    2015-03-07  Pedro Alves  <palves@redhat.com>
    
    	Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
    	instead.

Diff:
---
 gdb/ChangeLog                    |  17 +++
 gdb/ada-lang.c                   |  42 ++++---
 gdb/ada-typeprint.c              |  11 +-
 gdb/ada-valprint.c               |   7 +-
 gdb/amd64-tdep.c                 |  18 +--
 gdb/break-catch-throw.c          |  22 ++--
 gdb/breakpoint.c                 | 116 ++++++++++---------
 gdb/btrace.c                     |  18 ++-
 gdb/c-varobj.c                   |  38 +++---
 gdb/cli/cli-interp.c             |   6 +-
 gdb/cli/cli-script.c             |  12 +-
 gdb/common/common-exceptions.c   |  64 +++++-----
 gdb/common/common-exceptions.h   |  32 +++--
 gdb/compile/compile-c-symbols.c  |  26 +++--
 gdb/compile/compile-object-run.c |   6 +-
 gdb/completer.c                  |  11 +-
 gdb/corelow.c                    |  19 +--
 gdb/cp-abi.c                     |  17 +--
 gdb/cp-support.c                 |  34 ++++--
 gdb/cp-valprint.c                |  21 ++--
 gdb/dwarf2-frame-tailcall.c      |   6 +-
 gdb/dwarf2-frame.c               |  17 +--
 gdb/dwarf2loc.c                  |  13 ++-
 gdb/dwarf2read.c                 |  24 ++--
 gdb/eval.c                       |  33 +++---
 gdb/event-loop.c                 |   7 +-
 gdb/event-top.c                  |  12 +-
 gdb/exceptions.c                 |  15 ++-
 gdb/f-valprint.c                 |  11 +-
 gdb/frame-unwind.c               |   6 +-
 gdb/frame.c                      |  29 ++---
 gdb/gcore.c                      |  13 ++-
 gdb/gdbserver/ChangeLog          |   5 +
 gdb/gdbserver/server.c           |  38 +++---
 gdb/gdbtypes.c                   |  20 ++--
 gdb/gnu-v3-abi.c                 |  15 ++-
 gdb/guile/guile.c                |  10 +-
 gdb/guile/scm-block.c            |   9 +-
 gdb/guile/scm-breakpoint.c       |  79 +++++++++----
 gdb/guile/scm-cmd.c              |   9 +-
 gdb/guile/scm-disasm.c           |   9 +-
 gdb/guile/scm-frame.c            | 170 ++++++++++++++++++---------
 gdb/guile/scm-lazy-string.c      |  15 ++-
 gdb/guile/scm-math.c             |  38 ++++--
 gdb/guile/scm-param.c            |  19 ++-
 gdb/guile/scm-ports.c            |   9 +-
 gdb/guile/scm-pretty-print.c     |   7 +-
 gdb/guile/scm-symbol.c           |  46 ++++++--
 gdb/guile/scm-symtab.c           |   9 +-
 gdb/guile/scm-type.c             | 105 +++++++++++------
 gdb/guile/scm-value.c            | 244 ++++++++++++++++++++++++++-------------
 gdb/i386-tdep.c                  |  18 +--
 gdb/inf-loop.c                   |  15 ++-
 gdb/infcall.c                    |  13 ++-
 gdb/infcmd.c                     |  16 +--
 gdb/infrun.c                     |  23 ++--
 gdb/jit.c                        |  16 ++-
 gdb/linespec.c                   |  12 +-
 gdb/linux-nat.c                  |   6 +-
 gdb/linux-tdep.c                 |  11 +-
 gdb/linux-thread-db.c            |  19 +--
 gdb/main.c                       |  24 ++--
 gdb/mi/mi-cmd-stack.c            |  17 +--
 gdb/mi/mi-interp.c               |  24 +++-
 gdb/mi/mi-main.c                 |  15 +--
 gdb/p-valprint.c                 |   6 +-
 gdb/parse.c                      |  12 +-
 gdb/ppc-linux-tdep.c             |  10 +-
 gdb/printcmd.c                   |  40 ++++---
 gdb/python/py-arch.c             |   6 +-
 gdb/python/py-block.c            |   9 +-
 gdb/python/py-breakpoint.c       |  57 +++++----
 gdb/python/py-cmd.c              |   7 +-
 gdb/python/py-finishbreakpoint.c |  40 ++++---
 gdb/python/py-frame.c            | 162 ++++++++++++++++----------
 gdb/python/py-framefilter.c      | 134 +++++++++++----------
 gdb/python/py-gdb-readline.c     |  19 +--
 gdb/python/py-inferior.c         |  39 +++++--
 gdb/python/py-infthread.c        |   9 +-
 gdb/python/py-lazy-string.c      |   9 +-
 gdb/python/py-linetable.c        |   9 +-
 gdb/python/py-objfile.c          |  18 ++-
 gdb/python/py-param.c            |   7 +-
 gdb/python/py-prettyprint.c      |  16 ++-
 gdb/python/py-symbol.c           |  45 +++++---
 gdb/python/py-type.c             | 152 ++++++++++++++++--------
 gdb/python/py-utils.c            |   9 +-
 gdb/python/py-value.c            | 228 ++++++++++++++++++++++++------------
 gdb/python/python.c              |  69 ++++++++---
 gdb/record-btrace.c              |  80 +++++++------
 gdb/remote.c                     |  40 ++++---
 gdb/rs6000-aix-tdep.c            |   7 +-
 gdb/rs6000-tdep.c                |   6 +-
 gdb/s390-linux-tdep.c            |   6 +-
 gdb/solib-dsbt.c                 |   8 +-
 gdb/solib-frv.c                  |   8 +-
 gdb/solib-ia64-hpux.c            |  20 ++--
 gdb/solib-spu.c                  |   6 +-
 gdb/solib-svr4.c                 |  19 ++-
 gdb/solib.c                      |  58 ++++++----
 gdb/stack.c                      | 135 +++++++++++++---------
 gdb/symtab.c                     |   6 +-
 gdb/target.c                     |   6 +-
 gdb/top.c                        |  37 +++---
 gdb/tracefile-tfile.c            |   6 +-
 gdb/tui/tui.c                    |   6 +-
 gdb/typeprint.c                  |  10 +-
 gdb/valops.c                     |  13 ++-
 gdb/valprint.c                   |  10 +-
 gdb/value.c                      |  11 +-
 gdb/varobj.c                     |  55 +++++----
 gdb/xml-support.c                |  12 +-
 112 files changed, 2190 insertions(+), 1295 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 641a94c..6df72f7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,20 @@
+2015-03-07  Pedro Alves  <palves@redhat.com>
+
+	* common/common-exceptions.c (struct catcher) <exception>: No
+	longer a pointer to volatile exception.  Now an exception value.
+	<mask>: Delete field.
+	(exceptions_state_mc_init): Remove all parameters.  Adjust.
+	(exceptions_state_mc): No longer pop the catcher here.
+	(exceptions_state_mc_catch): New function.
+	(throw_exception): Adjust.
+	* common/common-exceptions.h (exceptions_state_mc_init): Remove
+	all parameters.
+	(exceptions_state_mc_catch): Declare.
+	(TRY_CATCH): Rename to ...
+	(TRY): ... this.  Remove EXCEPTION and MASK parameters.
+	(CATCH, END_CATCH): New.
+	All callers adjusted.
+
 2015-03-07  Tom Tromey  <tromey@redhat.com>
 
 	* top.c (quit_force): Inline and delete DO_TRY, DO_PRINT_EX.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1e70d12..124e370 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -6479,7 +6479,6 @@ type_from_tag (struct value *tag)
 struct value *
 ada_tag_value_at_base_address (struct value *obj)
 {
-  volatile struct gdb_exception e;
   struct value *val;
   LONGEST offset_to_top = 0;
   struct type *ptr_type, *obj_type;
@@ -6514,13 +6513,16 @@ ada_tag_value_at_base_address (struct value *obj)
      see ada_tag_name for more details.  We do not print the error
      message for the same reason.  */
 
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       offset_to_top = value_as_long (value_ind (value_ptradd (val, -2)));
     }
 
-  if (e.reason < 0)
-    return obj;
+  CATCH (e, RETURN_MASK_ERROR)
+    {
+      return obj;
+    }
+  END_CATCH
 
   /* If offset is null, nothing to do.  */
 
@@ -6632,7 +6634,6 @@ ada_tag_name_from_tsd (struct value *tsd)
 const char *
 ada_tag_name (struct value *tag)
 {
-  volatile struct gdb_exception e;
   char *name = NULL;
 
   if (!ada_is_tag_type (value_type (tag)))
@@ -6647,13 +6648,17 @@ ada_tag_name (struct value *tag)
      We also do not print the error message either (which often is very
      low-level (Eg: "Cannot read memory at 0x[...]"), but instead let
      the caller print a more meaningful message if necessary.  */
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       struct value *tsd = ada_get_tsd_from_tag (tag);
 
       if (tsd != NULL)
 	name = ada_tag_name_from_tsd (tsd);
     }
+  CATCH (e, RETURN_MASK_ERROR)
+    {
+    }
+  END_CATCH
 
   return name;
 }
@@ -11817,19 +11822,19 @@ static CORE_ADDR
 ada_exception_name_addr (enum ada_exception_catchpoint_kind ex,
                          struct breakpoint *b)
 {
-  volatile struct gdb_exception e;
   CORE_ADDR result = 0;
 
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       result = ada_exception_name_addr_1 (ex, b);
     }
 
-  if (e.reason < 0)
+  CATCH (e, RETURN_MASK_ERROR)
     {
       warning (_("failed to get exception name: %s"), e.message);
       return 0;
     }
+  END_CATCH
 
   return result;
 }
@@ -11929,16 +11934,15 @@ create_excep_cond_exprs (struct ada_catchpoint *c)
 
       if (!bl->shlib_disabled)
 	{
-	  volatile struct gdb_exception e;
 	  const char *s;
 
 	  s = cond_string;
-	  TRY_CATCH (e, RETURN_MASK_ERROR)
+	  TRY
 	    {
 	      exp = parse_exp_1 (&s, bl->address,
 				 block_for_pc (bl->address), 0);
 	    }
-	  if (e.reason < 0)
+	  CATCH (e, RETURN_MASK_ERROR)
 	    {
 	      warning (_("failed to reevaluate internal exception condition "
 			 "for catchpoint %d: %s"),
@@ -11951,6 +11955,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c)
 		 to NULL.  */
 	      exp = NULL;
 	    }
+	  END_CATCH
 	}
 
       ada_loc->excep_cond_expr = exp;
@@ -12014,7 +12019,6 @@ should_stop_exception (const struct bp_location *bl)
   struct ada_catchpoint *c = (struct ada_catchpoint *) bl->owner;
   const struct ada_catchpoint_location *ada_loc
     = (const struct ada_catchpoint_location *) bl;
-  volatile struct gdb_exception ex;
   int stop;
 
   /* With no specific exception, should always stop.  */
@@ -12029,7 +12033,7 @@ should_stop_exception (const struct bp_location *bl)
     }
 
   stop = 1;
-  TRY_CATCH (ex, RETURN_MASK_ALL)
+  TRY
     {
       struct value *mark;
 
@@ -12037,9 +12041,13 @@ should_stop_exception (const struct bp_location *bl)
       stop = value_true (evaluate_expression (ada_loc->excep_cond_expr));
       value_free_to_mark (mark);
     }
-  if (ex.reason < 0)
-    exception_fprintf (gdb_stderr, ex,
-		       _("Error in testing exception condition:\n"));
+  CATCH (ex, RETURN_MASK_ALL)
+    {
+      exception_fprintf (gdb_stderr, ex,
+			 _("Error in testing exception condition:\n"));
+    }
+  END_CATCH
+
   return stop;
 }
 
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 6dba71b..fd85138 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -159,19 +159,19 @@ print_range (struct type *type, struct ui_file *stream,
     case TYPE_CODE_ENUM:
       {
 	struct type *target_type;
-	volatile struct gdb_exception e;
 	LONGEST lo = 0, hi = 0; /* init for gcc -Wall */
+	int got_error = 0;
 
 	target_type = TYPE_TARGET_TYPE (type);
 	if (target_type == NULL)
 	  target_type = type;
 
-	TRY_CATCH (e, RETURN_MASK_ERROR)
+	TRY
 	  {
 	    lo = ada_discrete_type_low_bound (type);
 	    hi = ada_discrete_type_high_bound (type);
 	  }
-	if (e.reason < 0)
+	CATCH (e, RETURN_MASK_ERROR)
 	  {
 	    /* This can happen when the range is dynamic.  Sometimes,
 	       resolving dynamic property values requires us to have
@@ -179,8 +179,11 @@ print_range (struct type *type, struct ui_file *stream,
 	       when the user is using the "ptype" command on a type.
 	       Print the range as an unbounded range.  */
 	    fprintf_filtered (stream, "<>");
+	    got_error = 1;
 	  }
-	else
+	END_CATCH
+
+	if (!got_error)
 	  {
 	    ada_print_scalar (target_type, lo, stream);
 	    fprintf_filtered (stream, " .. ");
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index d5cd04f..34539de 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1159,15 +1159,18 @@ ada_val_print (struct type *type, const gdb_byte *valaddr,
 	       const struct value *val,
 	       const struct value_print_options *options)
 {
-  volatile struct gdb_exception except;
 
   /* XXX: this catches QUIT/ctrl-c as well.  Isn't that busted?  */
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       ada_val_print_1 (type, valaddr, embedded_offset, address,
 		       stream, recurse, val, options,
 		       current_language);
     }
+  CATCH (except, RETURN_MASK_ALL)
+    {
+    }
+  END_CATCH
 }
 
 void
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index ca82858..3e5d1bd 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2466,7 +2466,6 @@ amd64_frame_cache_1 (struct frame_info *this_frame,
 static struct amd64_frame_cache *
 amd64_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
-  volatile struct gdb_exception ex;
   struct amd64_frame_cache *cache;
 
   if (*this_cache)
@@ -2475,15 +2474,16 @@ amd64_frame_cache (struct frame_info *this_frame, void **this_cache)
   cache = amd64_alloc_frame_cache ();
   *this_cache = cache;
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       amd64_frame_cache_1 (this_frame, cache);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error != NOT_AVAILABLE_ERROR)
 	throw_exception (ex);
     }
+  END_CATCH
 
   return cache;
 }
@@ -2582,7 +2582,6 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  volatile struct gdb_exception ex;
   struct amd64_frame_cache *cache;
   CORE_ADDR addr;
   gdb_byte buf[8];
@@ -2593,7 +2592,7 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 
   cache = amd64_alloc_frame_cache ();
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
       cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8;
@@ -2607,11 +2606,12 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
 
       cache->base_p = 1;
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error != NOT_AVAILABLE_ERROR)
 	throw_exception (ex);
     }
+  END_CATCH
 
   *this_cache = cache;
   return cache;
@@ -2758,7 +2758,6 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache)
 {
   struct gdbarch *gdbarch = get_frame_arch (this_frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  volatile struct gdb_exception ex;
   struct amd64_frame_cache *cache;
   gdb_byte buf[8];
 
@@ -2768,7 +2767,7 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache)
   cache = amd64_alloc_frame_cache ();
   *this_cache = cache;
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       /* Cache base will be %esp plus cache->sp_offset (-8).  */
       get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
@@ -2786,11 +2785,12 @@ amd64_epilogue_frame_cache (struct frame_info *this_frame, void **this_cache)
 
       cache->base_p = 1;
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error != NOT_AVAILABLE_ERROR)
 	throw_exception (ex);
     }
+  END_CATCH
 
   return cache;
 }
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 726825a..f5616c8 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -163,7 +163,6 @@ check_status_exception_catchpoint (struct bpstats *bs)
   struct exception_catchpoint *self
     = (struct exception_catchpoint *) bs->breakpoint_at;
   char *type_name = NULL;
-  volatile struct gdb_exception e;
 
   bkpt_breakpoint_ops.check_status (bs);
   if (bs->stop == 0)
@@ -172,7 +171,7 @@ check_status_exception_catchpoint (struct bpstats *bs)
   if (self->pattern == NULL)
     return;
 
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       struct value *typeinfo_arg;
       char *canon;
@@ -187,8 +186,11 @@ check_status_exception_catchpoint (struct bpstats *bs)
 	  type_name = canon;
 	}
     }
-  if (e.reason < 0)
-    exception_print (gdb_stderr, e);
+  CATCH (e, RETURN_MASK_ERROR)
+    {
+      exception_print (gdb_stderr, e);
+    }
+  END_CATCH
 
   if (type_name != NULL)
     {
@@ -206,38 +208,38 @@ re_set_exception_catchpoint (struct breakpoint *self)
 {
   struct symtabs_and_lines sals = {0};
   struct symtabs_and_lines sals_end = {0};
-  volatile struct gdb_exception e;
   struct cleanup *cleanup;
   enum exception_event_kind kind = classify_exception_breakpoint (self);
 
   /* We first try to use the probe interface.  */
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       char *spec = ASTRDUP (exception_functions[kind].probe);
 
       sals = parse_probes (&spec, NULL);
     }
 
-  if (e.reason < 0)
+  CATCH (e, RETURN_MASK_ERROR)
     {
-      volatile struct gdb_exception ex;
 
       /* Using the probe interface failed.  Let's fallback to the normal
 	 catchpoint mode.  */
-      TRY_CATCH (ex, RETURN_MASK_ERROR)
+      TRY
 	{
 	  char *spec = ASTRDUP (exception_functions[kind].function);
 
 	  self->ops->decode_linespec (self, &spec, &sals);
 	}
-      if (ex.reason < 0)
+      CATCH (ex, RETURN_MASK_ERROR)
 	{
 	  /* NOT_FOUND_ERROR just means the breakpoint will be
 	     pending, so let it through.  */
 	  if (ex.error != NOT_FOUND_ERROR)
 	    throw_exception (ex);
 	}
+      END_CATCH
     }
+  END_CATCH
 
   cleanup = make_cleanup (xfree, sals.sals);
   update_breakpoint_locations (self, sals, sals_end);
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d85f271..0e59638 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2221,25 +2221,25 @@ static struct agent_expr *
 parse_cond_to_aexpr (CORE_ADDR scope, struct expression *cond)
 {
   struct agent_expr *aexpr = NULL;
-  volatile struct gdb_exception ex;
 
   if (!cond)
     return NULL;
 
   /* We don't want to stop processing, so catch any errors
      that may show up.  */
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       aexpr = gen_eval_for_expr (scope, cond);
     }
 
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       /* If we got here, it means the condition could not be parsed to a valid
 	 bytecode expression and thus can't be evaluated on the target's side.
 	 It's no use iterating through the conditions.  */
       return NULL;
     }
+  END_CATCH
 
   /* We have a valid agent expression.  */
   return aexpr;
@@ -2361,7 +2361,6 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
   struct cleanup *old_cleanups = 0;
   struct expression *expr, **argvec;
   struct agent_expr *aexpr = NULL;
-  volatile struct gdb_exception ex;
   const char *cmdrest;
   const char *format_start, *format_end;
   struct format_piece *fpieces;
@@ -2420,22 +2419,22 @@ parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
 
   /* We don't want to stop processing, so catch any errors
      that may show up.  */
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       aexpr = gen_printf (scope, gdbarch, 0, 0,
 			  format_start, format_end - format_start,
 			  fpieces, nargs, argvec);
     }
-
-  do_cleanups (old_cleanups);
-
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       /* If we got here, it means the command could not be parsed to a valid
 	 bytecode expression and thus can't be evaluated on the target's side.
 	 It's no use iterating through the other commands.  */
-      return NULL;
+      aexpr = NULL;
     }
+  END_CATCH
+
+  do_cleanups (old_cleanups);
 
   /* We have a valid agent expression, return it.  */
   return aexpr;
@@ -2572,7 +2571,6 @@ insert_bp_location (struct bp_location *bl,
 {
   enum errors bp_err = GDB_NO_ERROR;
   const char *bp_err_message = NULL;
-  volatile struct gdb_exception e;
 
   if (!should_be_inserted (bl) || (bl->inserted && !bl->needs_update))
     return 0;
@@ -2675,7 +2673,7 @@ insert_bp_location (struct bp_location *bl,
 	  || !(section_is_overlay (bl->section)))
 	{
 	  /* No overlay handling: just set the breakpoint.  */
-	  TRY_CATCH (e, RETURN_MASK_ALL)
+	  TRY
 	    {
 	      int val;
 
@@ -2683,11 +2681,12 @@ insert_bp_location (struct bp_location *bl,
 	      if (val)
 		bp_err = GENERIC_ERROR;
 	    }
-	  if (e.reason < 0)
+	  CATCH (e, RETURN_MASK_ALL)
 	    {
 	      bp_err = e.error;
 	      bp_err_message = e.message;
 	    }
+	  END_CATCH
 	}
       else
 	{
@@ -2710,7 +2709,7 @@ insert_bp_location (struct bp_location *bl,
 		  bl->overlay_target_info.reqstd_address = addr;
 
 		  /* No overlay handling: just set the breakpoint.  */
-		  TRY_CATCH (e, RETURN_MASK_ALL)
+		  TRY
 		    {
 		      int val;
 
@@ -2719,11 +2718,12 @@ insert_bp_location (struct bp_location *bl,
 		      if (val)
 			bp_err = GENERIC_ERROR;
 		    }
-		  if (e.reason < 0)
+		  CATCH (e, RETURN_MASK_ALL)
 		    {
 		      bp_err = e.error;
 		      bp_err_message = e.message;
 		    }
+		  END_CATCH
 
 		  if (bp_err != GDB_NO_ERROR)
 		    fprintf_unfiltered (tmp_error_stream,
@@ -2736,7 +2736,7 @@ insert_bp_location (struct bp_location *bl,
 	  if (section_is_mapped (bl->section))
 	    {
 	      /* Yes.  This overlay section is mapped into memory.  */
-	      TRY_CATCH (e, RETURN_MASK_ALL)
+	      TRY
 	        {
 		  int val;
 
@@ -2744,11 +2744,12 @@ insert_bp_location (struct bp_location *bl,
 		  if (val)
 		    bp_err = GENERIC_ERROR;
 	        }
-	      if (e.reason < 0)
+	      CATCH (e, RETURN_MASK_ALL)
 	        {
 		  bp_err = e.error;
 		  bp_err_message = e.message;
 	        }
+	      END_CATCH
 	    }
 	  else
 	    {
@@ -10004,7 +10005,6 @@ create_breakpoint (struct gdbarch *gdbarch,
 		   int from_tty, int enabled, int internal,
 		   unsigned flags)
 {
-  volatile struct gdb_exception e;
   char *copy_arg = NULL;
   char *addr_start = arg;
   struct linespec_result canonical;
@@ -10018,24 +10018,17 @@ create_breakpoint (struct gdbarch *gdbarch,
 
   init_linespec_result (&canonical);
 
-  TRY_CATCH (e, RETURN_MASK_ALL)
+  TRY
     {
       ops->create_sals_from_address (&arg, &canonical, type_wanted,
 				     addr_start, &copy_arg);
     }
-
-  /* If caller is interested in rc value from parse, set value.  */
-  switch (e.reason)
+  CATCH (e, RETURN_MASK_ERROR)
     {
-    case GDB_NO_ERROR:
-      if (VEC_empty (linespec_sals, canonical.sals))
-	return 0;
-      break;
-    case RETURN_ERROR:
-      switch (e.error)
+      /* If caller is interested in rc value from parse, set
+	 value.  */
+      if (e.error == NOT_FOUND_ERROR)
 	{
-	case NOT_FOUND_ERROR:
-
 	  /* If pending breakpoint support is turned off, throw
 	     error.  */
 
@@ -10066,14 +10059,14 @@ create_breakpoint (struct gdbarch *gdbarch,
 	    pending = 1;
 	    VEC_safe_push (linespec_sals, canonical.sals, &lsal);
 	  }
-	  break;
-	default:
-	  throw_exception (e);
 	}
-      break;
-    default:
-      throw_exception (e);
+      else
+	throw_exception (e);
     }
+  END_CATCH
+
+  if (VEC_empty (linespec_sals, canonical.sals))
+    return 0;
 
   /* Create a chain of things that always need to be cleaned up.  */
   old_chain = make_cleanup_destroy_linespec_result (&canonical);
@@ -11343,7 +11336,6 @@ static void
 watch_command_1 (const char *arg, int accessflag, int from_tty,
 		 int just_location, int internal)
 {
-  volatile struct gdb_exception e;
   struct breakpoint *b, *scope_breakpoint = NULL;
   struct expression *exp;
   const struct block *exp_valid_block = NULL, *cond_exp_valid_block = NULL;
@@ -11655,17 +11647,18 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
   if (!just_location)
     value_free_to_mark (mark);
 
-  TRY_CATCH (e, RETURN_MASK_ALL)
+  TRY
     {
       /* Finally update the new watchpoint.  This creates the locations
 	 that should be inserted.  */
       update_watchpoint (w, 1);
     }
-  if (e.reason < 0)
+  CATCH (e, RETURN_MASK_ALL)
     {
       delete_breakpoint (b);
       throw_exception (e);
     }
+  END_CATCH
 
   install_breakpoint (internal, b, 1);
   do_cleanups (back_to);
@@ -13011,10 +13004,15 @@ breakpoint_retire_moribund (void)
 static void
 update_global_location_list_nothrow (enum ugll_insert_mode insert_mode)
 {
-  volatile struct gdb_exception e;
 
-  TRY_CATCH (e, RETURN_MASK_ERROR)
-    update_global_location_list (insert_mode);
+  TRY
+    {
+      update_global_location_list (insert_mode);
+    }
+  CATCH (e, RETURN_MASK_ERROR)
+    {
+    }
+  END_CATCH
 }
 
 /* Clear BKP from a BPS.  */
@@ -14485,22 +14483,22 @@ update_breakpoint_locations (struct breakpoint *b,
       if (b->cond_string != NULL)
 	{
 	  const char *s;
-	  volatile struct gdb_exception e;
 
 	  s = b->cond_string;
-	  TRY_CATCH (e, RETURN_MASK_ERROR)
+	  TRY
 	    {
 	      new_loc->cond = parse_exp_1 (&s, sals.sals[i].pc,
 					   block_for_pc (sals.sals[i].pc), 
 					   0);
 	    }
-	  if (e.reason < 0)
+	  CATCH (e, RETURN_MASK_ERROR)
 	    {
 	      warning (_("failed to reevaluate condition "
 			 "for breakpoint %d: %s"), 
 		       b->number, e.message);
 	      new_loc->enabled = 0;
 	    }
+	  END_CATCH
 	}
 
       if (sals_end.nelts)
@@ -14564,18 +14562,21 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
 {
   char *s;
   struct symtabs_and_lines sals = {0};
-  volatile struct gdb_exception e;
+  struct gdb_exception exception = exception_none;
 
   gdb_assert (b->ops != NULL);
   s = addr_string;
 
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       b->ops->decode_linespec (b, &s, &sals);
     }
-  if (e.reason < 0)
+  CATCH (e, RETURN_MASK_ERROR)
     {
       int not_found_and_ok = 0;
+
+      exception = e;
+
       /* For pending breakpoints, it's expected that parsing will
 	 fail until the right shared library is loaded.  User has
 	 already told to create pending breakpoints and don't need
@@ -14602,8 +14603,9 @@ addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
 	  throw_exception (e);
 	}
     }
+  END_CATCH
 
-  if (e.reason == 0 || e.error != NOT_FOUND_ERROR)
+  if (exception.reason == 0 || exception.error != NOT_FOUND_ERROR)
     {
       int i;
 
@@ -15094,9 +15096,8 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
     {
       /* Initialize it just to avoid a GCC false warning.  */
       enum enable_state orig_enable_state = 0;
-      volatile struct gdb_exception e;
 
-      TRY_CATCH (e, RETURN_MASK_ALL)
+      TRY
 	{
 	  struct watchpoint *w = (struct watchpoint *) bpt;
 
@@ -15104,13 +15105,14 @@ enable_breakpoint_disp (struct breakpoint *bpt, enum bpdisp disposition,
 	  bpt->enable_state = bp_enabled;
 	  update_watchpoint (w, 1 /* reparse */);
 	}
-      if (e.reason < 0)
+      CATCH (e, RETURN_MASK_ALL)
 	{
 	  bpt->enable_state = orig_enable_state;
 	  exception_fprintf (gdb_stderr, e, _("Cannot enable watchpoint %d: "),
 			     bpt->number);
 	  return;
 	}
+      END_CATCH
     }
 
   bpt->enable_state = bp_enabled;
@@ -15924,19 +15926,21 @@ save_breakpoints (char *filename, int from_tty,
 
     if (tp->type != bp_dprintf && tp->commands)
       {
-	volatile struct gdb_exception ex;	
 
 	fprintf_unfiltered (fp, "  commands\n");
 	
 	ui_out_redirect (current_uiout, fp);
-	TRY_CATCH (ex, RETURN_MASK_ALL)
+	TRY
 	  {
 	    print_command_lines (current_uiout, tp->commands->commands, 2);
 	  }
 	ui_out_redirect (current_uiout, NULL);
 
-	if (ex.reason < 0)
-	  throw_exception (ex);
+	CATCH (ex, RETURN_MASK_ALL)
+	  {
+	    throw_exception (ex);
+	  }
+	END_CATCH
 
 	fprintf_unfiltered (fp, "  end\n");
       }
diff --git a/gdb/btrace.c b/gdb/btrace.c
index 5436ee9..68057c5 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -549,11 +549,10 @@ ftrace_update_insns (struct btrace_function *bfun,
 static enum btrace_insn_class
 ftrace_classify_insn (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
-  volatile struct gdb_exception error;
   enum btrace_insn_class iclass;
 
   iclass = BTRACE_INSN_OTHER;
-  TRY_CATCH (error, RETURN_MASK_ERROR)
+  TRY
     {
       if (gdbarch_insn_is_call (gdbarch, pc))
 	iclass = BTRACE_INSN_CALL;
@@ -562,6 +561,10 @@ ftrace_classify_insn (struct gdbarch *gdbarch, CORE_ADDR pc)
       else if (gdbarch_insn_is_jump (gdbarch, pc))
 	iclass = BTRACE_INSN_JUMP;
     }
+  CATCH (error, RETURN_MASK_ERROR)
+    {
+    }
+  END_CATCH
 
   return iclass;
 }
@@ -598,7 +601,6 @@ btrace_compute_ftrace_bts (struct thread_info *tp,
 
       for (;;)
 	{
-	  volatile struct gdb_exception error;
 	  struct btrace_insn insn;
 	  int size;
 
@@ -628,8 +630,14 @@ btrace_compute_ftrace_bts (struct thread_info *tp,
 	    level = min (level, end->level);
 
 	  size = 0;
-	  TRY_CATCH (error, RETURN_MASK_ERROR)
-	    size = gdb_insn_length (gdbarch, pc);
+	  TRY
+	    {
+	      size = gdb_insn_length (gdbarch, pc);
+	    }
+	  CATCH (error, RETURN_MASK_ERROR)
+	    {
+	    }
+	  END_CATCH
 
 	  insn.pc = pc;
 	  insn.size = size;
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 363a356..59d8b0f 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -91,15 +91,17 @@ adjust_value_for_child_access (struct value **value,
 	{
 	  if (value && *value)
 	    {
-	      volatile struct gdb_exception except;
 
-	      TRY_CATCH (except, RETURN_MASK_ERROR)
+	      TRY
 		{
 		  *value = value_ind (*value);
 		}
 
-	      if (except.reason < 0)
-		*value = NULL;
+	      CATCH (except, RETURN_MASK_ERROR)
+		{
+		  *value = NULL;
+		}
+	      END_CATCH
 	    }
 	  *type = target_type;
 	  if (was_ptr)
@@ -245,7 +247,6 @@ static struct value *
 value_struct_element_index (struct value *value, int type_index)
 {
   struct value *result = NULL;
-  volatile struct gdb_exception e;
   struct type *type = value_type (value);
 
   type = check_typedef (type);
@@ -253,21 +254,20 @@ value_struct_element_index (struct value *value, int type_index)
   gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT
 	      || TYPE_CODE (type) == TYPE_CODE_UNION);
 
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       if (field_is_static (&TYPE_FIELD (type, type_index)))
 	result = value_static_field (type, type_index);
       else
 	result = value_primitive_field (value, 0, type_index, type);
     }
-  if (e.reason < 0)
+  CATCH (e, RETURN_MASK_ERROR)
     {
       return NULL;
     }
-  else
-    {
-      return result;
-    }
+  END_CATCH
+
+  return result;
 }
 
 /* Obtain the information about child INDEX of the variable
@@ -290,7 +290,6 @@ c_describe_child (const struct varobj *parent, int index,
   struct type *type = varobj_get_value_type (parent);
   char *parent_expression = NULL;
   int was_ptr;
-  volatile struct gdb_exception except;
 
   if (cname)
     *cname = NULL;
@@ -319,10 +318,14 @@ c_describe_child (const struct varobj *parent, int index,
 	{
 	  int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
 
-	  TRY_CATCH (except, RETURN_MASK_ERROR)
+	  TRY
 	    {
 	      *cvalue = value_subscript (value, real_index);
 	    }
+	  CATCH (except, RETURN_MASK_ERROR)
+	    {
+	    }
+	  END_CATCH
 	}
 
       if (ctype)
@@ -391,13 +394,16 @@ c_describe_child (const struct varobj *parent, int index,
 
       if (cvalue && value)
 	{
-	  TRY_CATCH (except, RETURN_MASK_ERROR)
+	  TRY
 	    {
 	      *cvalue = value_ind (value);
 	    }
 
-	  if (except.reason < 0)
-	    *cvalue = NULL;
+	  CATCH (except, RETURN_MASK_ERROR)
+	    {
+	      *cvalue = NULL;
+	    }
+	  END_CATCH
 	}
 
       /* Don't use get_target_type because it calls
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 1069018..ce43a4a 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -179,7 +179,6 @@ cli_interpreter_exec (void *data, const char *command_str)
 static struct gdb_exception
 safe_execute_command (struct ui_out *command_uiout, char *command, int from_tty)
 {
-  volatile struct gdb_exception exception;
   struct gdb_exception e = exception_none;
   struct ui_out *saved_uiout;
 
@@ -187,14 +186,15 @@ safe_execute_command (struct ui_out *command_uiout, char *command, int from_tty)
   saved_uiout = current_uiout;
   current_uiout = command_uiout;
 
-  TRY_CATCH (exception, RETURN_MASK_ALL)
+  TRY
     {
       execute_command (command, from_tty);
     }
-  if (exception.reason < 0)
+  CATCH (exception, RETURN_MASK_ALL)
     {
       e = exception;
     }
+  END_CATCH
 
   /* Restore the global builder.  */
   current_uiout = saved_uiout;
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 2ec8bcd..7a4ed78 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1111,17 +1111,17 @@ process_next_line (char *p, struct command_line **command, int parse_commands,
 
   if (validator)
     {
-      volatile struct gdb_exception ex;
 
-      TRY_CATCH (ex, RETURN_MASK_ALL)
+      TRY
 	{
 	  validator ((*command)->line, closure);
 	}
-      if (ex.reason < 0)
+      CATCH (ex, RETURN_MASK_ALL)
 	{
 	  xfree (*command);
 	  throw_exception (ex);
 	}
+      END_CATCH
     }
 
   /* Nothing special.  */
@@ -1700,13 +1700,12 @@ script_from_file (FILE *stream, const char *file)
   interpreter_async = 0;
 
   {
-    volatile struct gdb_exception e;
 
-    TRY_CATCH (e, RETURN_MASK_ERROR)
+    TRY
       {
 	read_command_file (stream);
       }
-    if (e.reason < 0)
+    CATCH (e, RETURN_MASK_ERROR)
       {
 	/* Re-throw the error, but with the file name information
 	   prepended.  */
@@ -1714,6 +1713,7 @@ script_from_file (FILE *stream, const char *file)
 		     _("%s:%d: Error in sourced command file:\n%s"),
 		     source_file_name, source_line_number, e.message);
       }
+    END_CATCH
   }
 
   do_cleanups (old_cleanups);
diff --git a/gdb/common/common-exceptions.c b/gdb/common/common-exceptions.c
index b65f259..2ad0ce1 100644
--- a/gdb/common/common-exceptions.c
+++ b/gdb/common/common-exceptions.c
@@ -46,9 +46,7 @@ struct catcher
   /* Jump buffer pointing back at the exception handler.  */
   SIGJMP_BUF buf;
   /* Status buffer belonging to the exception handler.  */
-  volatile struct gdb_exception *exception;
-  /* Saved/current state.  */
-  int mask;
+  struct gdb_exception exception;
   struct cleanup *saved_cleanup_chain;
   /* Back link.  */
   struct catcher *prev;
@@ -74,16 +72,12 @@ catcher_list_size (void)
 }
 
 SIGJMP_BUF *
-exceptions_state_mc_init (volatile struct gdb_exception *exception,
-			  return_mask mask)
+exceptions_state_mc_init (void)
 {
   struct catcher *new_catcher = XCNEW (struct catcher);
 
-  /* Start with no exception, save it's address.  */
-  *exception = exception_none;
-  new_catcher->exception = exception;
-
-  new_catcher->mask = mask;
+  /* Start with no exception.  */
+  new_catcher->exception = exception_none;
 
   /* Prevent error/quit during FUNC from calling cleanups established
      prior to here.  */
@@ -134,8 +128,7 @@ exceptions_state_mc (enum catcher_action action)
       switch (action)
 	{
 	case CATCH_ITER:
-	  /* No error/quit has occured.  Just clean up.  */
-	  catcher_pop ();
+	  /* No error/quit has occured.  */
 	  return 0;
 	case CATCH_ITER_1:
 	  current_catcher->state = CATCHER_RUNNING_1;
@@ -152,7 +145,6 @@ exceptions_state_mc (enum catcher_action action)
 	{
 	case CATCH_ITER:
 	  /* The did a "break" from the inner while loop.  */
-	  catcher_pop ();
 	  return 0;
 	case CATCH_ITER_1:
 	  current_catcher->state = CATCHER_RUNNING;
@@ -169,21 +161,10 @@ exceptions_state_mc (enum catcher_action action)
 	{
 	case CATCH_ITER:
 	  {
-	    struct gdb_exception exception = *current_catcher->exception;
-
-	    if (current_catcher->mask & RETURN_MASK (exception.reason))
-	      {
-		/* Exit normally if this catcher can handle this
-		   exception.  The caller analyses the func return
-		   values.  */
-		catcher_pop ();
-		return 0;
-	      }
-	    /* The caller didn't request that the event be caught,
-	       relay the event to the next containing
-	       catch_errors().  */
-	    catcher_pop ();
-	    throw_exception (exception);
+	    /* Exit normally if this catcher can handle this
+	       exception.  The caller analyses the func return
+	       values.  */
+	    return 0;
 	  }
 	default:
 	  internal_error (__FILE__, __LINE__, _("bad state"));
@@ -194,6 +175,31 @@ exceptions_state_mc (enum catcher_action action)
 }
 
 int
+exceptions_state_mc_catch (struct gdb_exception *exception,
+			   int mask)
+{
+  *exception = current_catcher->exception;
+  catcher_pop ();
+
+  if (exception->reason < 0)
+    {
+      if (mask & RETURN_MASK (exception->reason))
+	{
+	  /* Exit normally and let the called handle the
+	     exception.  */
+	  return 1;
+	}
+
+      /* The caller didn't request that the event be caught, relay the
+	 event to the next exception_catch/CATCH.  */
+      throw_exception (*exception);
+    }
+
+  /* No exception was thrown.  */
+  return 0;
+}
+
+int
 exceptions_state_mc_action_iter (void)
 {
   return exceptions_state_mc (CATCH_ITER);
@@ -218,7 +224,7 @@ throw_exception (struct gdb_exception exception)
      to that call via setjmp's return value.  Note that REASON can't
      be zero, by definition in defs.h.  */
   exceptions_state_mc (CATCH_THROWING);
-  *current_catcher->exception = exception;
+  current_catcher->exception = exception;
   SIGLONGJMP (current_catcher->buf, exception.reason);
 }
 
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
index a32e6f9..d2c0bee 100644
--- a/gdb/common/common-exceptions.h
+++ b/gdb/common/common-exceptions.h
@@ -118,14 +118,13 @@ struct gdb_exception
 
 /* Functions to drive the exceptions state machine.  Though declared
    here by necessity, these functions should be considered internal to
-   the exceptions subsystem and not used other than via the TRY_CATCH
-   macro defined below.  */
+   the exceptions subsystem and not used other than via the TRY/CATCH
+   macros defined below.  */
 
-extern SIGJMP_BUF *exceptions_state_mc_init (volatile struct
-					     gdb_exception *exception,
-					     return_mask mask);
+extern SIGJMP_BUF *exceptions_state_mc_init (void);
 extern int exceptions_state_mc_action_iter (void);
 extern int exceptions_state_mc_action_iter_1 (void);
+extern int exceptions_state_mc_catch (struct gdb_exception *, int);
 
 /* Macro to wrap up standard try/catch behavior.
 
@@ -138,26 +137,37 @@ extern int exceptions_state_mc_action_iter_1 (void);
 
    *INDENT-OFF*
 
-   volatile struct gdb_exception e;
-   TRY_CATCH (e, RETURN_MASK_ERROR)
+   TRY
      {
      }
-   switch (e.reason)
+   CATCH (e, RETURN_MASK_ERROR)
      {
-     case RETURN_ERROR: ...
+       switch (e.reason)
+         {
+           case RETURN_ERROR: ...
+         }
      }
+   END_CATCH
 
   */
 
-#define TRY_CATCH(EXCEPTION,MASK) \
+#define TRY \
      { \
        SIGJMP_BUF *buf = \
-	 exceptions_state_mc_init (&(EXCEPTION), (MASK)); \
+	 exceptions_state_mc_init (); \
        SIGSETJMP (*buf); \
      } \
      while (exceptions_state_mc_action_iter ()) \
        while (exceptions_state_mc_action_iter_1 ())
 
+#define CATCH(EXCEPTION, MASK)				\
+  {							\
+    struct gdb_exception EXCEPTION;				\
+    if (exceptions_state_mc_catch (&(EXCEPTION), MASK))
+
+#define END_CATCH				\
+  }
+
 /* *INDENT-ON* */
 
 /* Hook to allow client-specific actions to be performed prior to
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 1921704..15efeff 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -424,7 +424,6 @@ gcc_convert_symbol (void *datum,
 {
   struct compile_c_instance *context = datum;
   domain_enum domain;
-  volatile struct gdb_exception e;
   int found = 0;
 
   switch (request)
@@ -444,7 +443,7 @@ gcc_convert_symbol (void *datum,
 
   /* We can't allow exceptions to escape out of this callback.  Safest
      is to simply emit a gcc error.  */
-  TRY_CATCH (e, RETURN_MASK_ALL)
+  TRY
     {
       struct symbol *sym;
 
@@ -467,8 +466,11 @@ gcc_convert_symbol (void *datum,
 	}
     }
 
-  if (e.reason < 0)
-    C_CTX (context)->c_ops->error (C_CTX (context), e.message);
+  CATCH (e, RETURN_MASK_ALL)
+    {
+      C_CTX (context)->c_ops->error (C_CTX (context), e.message);
+    }
+  END_CATCH
 
   if (compile_debug && !found)
     fprintf_unfiltered (gdb_stdout,
@@ -484,13 +486,12 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
 		    const char *identifier)
 {
   struct compile_c_instance *context = datum;
-  volatile struct gdb_exception e;
   gcc_address result = 0;
   int found = 0;
 
   /* We can't allow exceptions to escape out of this callback.  Safest
      is to simply emit a gcc error.  */
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       struct symbol *sym;
 
@@ -527,8 +528,11 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
 	}
     }
 
-  if (e.reason < 0)
-    C_CTX (context)->c_ops->error (C_CTX (context), e.message);
+  CATCH (e, RETURN_MASK_ERROR)
+    {
+      C_CTX (context)->c_ops->error (C_CTX (context), e.message);
+    }
+  END_CATCH
 
   if (compile_debug && !found)
     fprintf_unfiltered (gdb_stdout,
@@ -643,9 +647,8 @@ generate_c_for_for_one_variable (struct compile_c_instance *compiler,
 				 CORE_ADDR pc,
 				 struct symbol *sym)
 {
-  volatile struct gdb_exception e;
 
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       if (is_dynamic_type (SYMBOL_TYPE (sym)))
 	{
@@ -699,7 +702,7 @@ generate_c_for_for_one_variable (struct compile_c_instance *compiler,
 	}
     }
 
-  if (e.reason < 0)
+  CATCH (e, RETURN_MASK_ERROR)
     {
       if (compiler->symbol_err_map == NULL)
 	compiler->symbol_err_map = htab_create_alloc (10,
@@ -710,6 +713,7 @@ generate_c_for_for_one_variable (struct compile_c_instance *compiler,
 						      xfree);
       insert_symbol_error (compiler->symbol_err_map, sym, e.message);
     }
+  END_CATCH
 }
 
 /* See compile-internal.h.  */
diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c
index c40de0e..6738aad 100644
--- a/gdb/compile/compile-object-run.c
+++ b/gdb/compile/compile-object-run.c
@@ -87,7 +87,6 @@ compile_object_run (struct compile_module *module)
   struct frame_id dummy_id;
   struct cleanup *cleanups;
   struct do_module_cleanup *data;
-  volatile struct gdb_exception ex;
   const char *objfile_name_s = objfile_name (module->objfile);
   int dtor_found, executed = 0;
   CORE_ADDR func_addr = module->func_addr;
@@ -101,7 +100,7 @@ compile_object_run (struct compile_module *module)
   xfree (module->source_file);
   xfree (module);
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       func_val = value_from_pointer
 		 (builtin_type (target_gdbarch ())->builtin_func_ptr,
@@ -121,7 +120,7 @@ compile_object_run (struct compile_module *module)
 				       do_module_cleanup, data);
 	}
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       /* In the case of DTOR_FOUND or in the case of EXECUTED nothing
 	 needs to be done.  */
@@ -133,6 +132,7 @@ compile_object_run (struct compile_module *module)
 	do_module_cleanup (data);
       throw_exception (ex);
     }
+  END_CATCH
 
   dtor_found = find_dummy_frame_dtor (do_module_cleanup, data);
   gdb_assert (!dtor_found && executed);
diff --git a/gdb/completer.c b/gdb/completer.c
index 58418f6..c8c0e4c 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -395,18 +395,21 @@ expression_completer (struct cmd_list_element *ignore,
   struct type *type = NULL;
   char *fieldname;
   const char *p;
-  volatile struct gdb_exception except;
   enum type_code code = TYPE_CODE_UNDEF;
 
   /* Perform a tentative parse of the expression, to see whether a
      field completion is required.  */
   fieldname = NULL;
-  TRY_CATCH (except, RETURN_MASK_ERROR)
+  TRY
     {
       type = parse_expression_for_completion (text, &fieldname, &code);
     }
-  if (except.reason < 0)
-    return NULL;
+  CATCH (except, RETURN_MASK_ERROR)
+    {
+      return NULL;
+    }
+  END_CATCH
+
   if (fieldname && type)
     {
       for (;;)
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 65e1326..9218003 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -278,7 +278,6 @@ core_open (const char *arg, int from_tty)
   bfd *temp_bfd;
   int scratch_chan;
   int flags;
-  volatile struct gdb_exception except;
   char *filename;
 
   target_preopen (from_tty);
@@ -411,13 +410,16 @@ core_open (const char *arg, int from_tty)
      may be a thread_stratum target loaded on top of target core by
      now.  The layer above should claim threads found in the BFD
      sections.  */
-  TRY_CATCH (except, RETURN_MASK_ERROR)
+  TRY
     {
       target_update_thread_list ();
     }
 
-  if (except.reason < 0)
-    exception_print (gdb_stderr, except);
+  CATCH (except, RETURN_MASK_ERROR)
+    {
+      exception_print (gdb_stderr, except);
+    }
+  END_CATCH
 
   p = bfd_core_file_failing_command (core_bfd);
   if (p)
@@ -462,12 +464,15 @@ core_open (const char *arg, int from_tty)
      anything about threads.  That is why the test is >= 2.  */
   if (thread_count () >= 2)
     {
-      TRY_CATCH (except, RETURN_MASK_ERROR)
+      TRY
 	{
 	  thread_command (NULL, from_tty);
 	}
-      if (except.reason < 0)
-	exception_print (gdb_stderr, except);
+      CATCH (except, RETURN_MASK_ERROR)
+	{
+	  exception_print (gdb_stderr, except);
+	}
+      END_CATCH
     }
 }
 
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 70a0528..b8af8f0 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -69,18 +69,17 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr,
 		  int embedded_offset, CORE_ADDR address,
 		  const struct value *val)
 {
-  volatile struct gdb_exception ex;
   int res = 0;
 
   gdb_assert (current_cp_abi.baseclass_offset != NULL);
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       res = (*current_cp_abi.baseclass_offset) (type, index, valaddr,
 						embedded_offset,
 						address, val);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error != NOT_AVAILABLE_ERROR)
 	throw_exception (ex);
@@ -89,6 +88,7 @@ baseclass_offset (struct type *type, int index, const gdb_byte *valaddr,
 		   _("Cannot determine virtual baseclass offset "
 		     "of incomplete object"));
     }
+  END_CATCH
 
   return res;
 }
@@ -109,16 +109,19 @@ value_rtti_type (struct value *v, int *full,
 		 int *top, int *using_enc)
 {
   struct type *ret = NULL;
-  volatile struct gdb_exception e;
 
   if ((current_cp_abi.rtti_type) == NULL)
     return NULL;
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       ret = (*current_cp_abi.rtti_type) (v, full, top, using_enc);
     }
-  if (e.reason < 0)
-    return NULL;
+  CATCH (e, RETURN_MASK_ERROR)
+    {
+      return NULL;
+    }
+  END_CATCH
+
   return ret;
 }
 
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 260601f..4bbee94 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -157,7 +157,6 @@ inspect_type (struct demangle_parse_info *info,
   int i;
   char *name;
   struct symbol *sym;
-  volatile struct gdb_exception except;
 
   /* Copy the symbol's name from RET_COMP and look it up
      in the symbol table.  */
@@ -173,12 +172,18 @@ inspect_type (struct demangle_parse_info *info,
     }
 
   sym = NULL;
-  TRY_CATCH (except, RETURN_MASK_ALL)
-  {
-    sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
-  }
 
-  if (except.reason >= 0 && sym != NULL)
+  TRY
+    {
+      sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
+    }
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      return 0;
+    }
+  END_CATCH
+
+  if (sym != NULL)
     {
       struct type *otype = SYMBOL_TYPE (sym);
 
@@ -241,18 +246,19 @@ inspect_type (struct demangle_parse_info *info,
 	    }
 
 	  buf = mem_fileopen ();
-	  TRY_CATCH (except, RETURN_MASK_ERROR)
+	  TRY
 	  {
 	    type_print (type, "", buf, -1);
 	  }
 
 	  /* If type_print threw an exception, there is little point
 	     in continuing, so just bow out gracefully.  */
-	  if (except.reason < 0)
+	  CATCH (except, RETURN_MASK_ERROR)
 	    {
 	      ui_file_delete (buf);
 	      return 0;
 	    }
+	  END_CATCH
 
 	  name = ui_file_obsavestring (buf, &info->obstack, &len);
 	  ui_file_delete (buf);
@@ -446,17 +452,21 @@ replace_typedefs (struct demangle_parse_info *info,
 
 	  if (local_name != NULL)
 	    {
-	      struct symbol *sym;
-	      volatile struct gdb_exception except;
+	      struct symbol *sym = NULL;
 
 	      sym = NULL;
-	      TRY_CATCH (except, RETURN_MASK_ALL)
+	      TRY
 		{
 		  sym = lookup_symbol (local_name, 0, VAR_DOMAIN, 0);
 		}
+	      CATCH (except, RETURN_MASK_ALL)
+		{
+		}
+	      END_CATCH
+
 	      xfree (local_name);
 
-	      if (except.reason >= 0 && sym != NULL)
+	      if (sym != NULL)
 		{
 		  struct type *otype = SYMBOL_TYPE (sym);
 		  const char *new_name = (*finder) (otype, data);
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index deb0ed8..feb3a66 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -313,18 +313,21 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 		}
 	      else if (field_is_static (&TYPE_FIELD (type, i)))
 		{
-		  volatile struct gdb_exception ex;
 		  struct value *v = NULL;
 
-		  TRY_CATCH (ex, RETURN_MASK_ERROR)
+		  TRY
 		    {
 		      v = value_static_field (type, i);
 		    }
 
-		  if (ex.reason < 0)
-		    fprintf_filtered (stream,
-				      _("<error reading variable: %s>"),
-				      ex.message);
+		  CATCH (ex, RETURN_MASK_ERROR)
+		    {
+		      fprintf_filtered (stream,
+					_("<error reading variable: %s>"),
+					ex.message);
+		    }
+		  END_CATCH
+
 		  cp_print_static_field (TYPE_FIELD_TYPE (type, i),
 					 v, stream, recurse + 1,
 					 options);
@@ -486,7 +489,6 @@ cp_print_value (struct type *type, struct type *real_type,
       const char *basename = TYPE_NAME (baseclass);
       const gdb_byte *base_valaddr = NULL;
       const struct value *base_val = NULL;
-      volatile struct gdb_exception ex;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
 	{
@@ -506,17 +508,18 @@ cp_print_value (struct type *type, struct type *real_type,
       thisoffset = offset;
       thistype = real_type;
 
-      TRY_CATCH (ex, RETURN_MASK_ERROR)
+      TRY
 	{
 	  boffset = baseclass_offset (type, i, valaddr, offset, address, val);
 	}
-      if (ex.reason < 0)
+      CATCH (ex, RETURN_MASK_ERROR)
 	{
 	  if (ex.error == NOT_AVAILABLE_ERROR)
 	    skip = -1;
 	  else
 	    skip = 1;
 	}
+      END_CATCH
 
       if (skip == 0)
 	{
diff --git a/gdb/dwarf2-frame-tailcall.c b/gdb/dwarf2-frame-tailcall.c
index c99fde0..b412a5b 100644
--- a/gdb/dwarf2-frame-tailcall.c
+++ b/gdb/dwarf2-frame-tailcall.c
@@ -368,7 +368,6 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame,
   struct gdbarch *prev_gdbarch;
   struct call_site_chain *chain = NULL;
   struct tailcall_cache *cache;
-  volatile struct gdb_exception except;
 
   gdb_assert (*tailcall_cachep == NULL);
 
@@ -377,7 +376,7 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame,
   this_pc = get_frame_address_in_block (this_frame);
 
   /* Catch any unwinding errors.  */
-  TRY_CATCH (except, RETURN_MASK_ERROR)
+  TRY
     {
       int sp_regnum;
 
@@ -397,12 +396,13 @@ dwarf2_tailcall_sniffer_first (struct frame_info *this_frame,
       prev_sp = frame_unwind_register_unsigned (this_frame, sp_regnum);
       prev_sp_p = 1;
     }
-  if (except.reason < 0)
+  CATCH (except, RETURN_MASK_ERROR)
     {
       if (entry_values_debug)
 	exception_print (gdb_stdout, except);
       return;
     }
+  END_CATCH
 
   /* Ambiguous unwind or unambiguous unwind verified as matching.  */
   if (chain == NULL || chain->length == 0)
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index b648aa3..8fb2ac7 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1025,7 +1025,6 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
   struct dwarf2_frame_cache *cache;
   struct dwarf2_frame_state *fs;
   struct dwarf2_fde *fde;
-  volatile struct gdb_exception ex;
   CORE_ADDR entry_pc;
   const gdb_byte *instr;
 
@@ -1102,7 +1101,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
   execute_cfa_program (fde, instr, fde->end, gdbarch,
 		       get_frame_address_in_block (this_frame), fs);
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       /* Calculate the CFA.  */
       switch (fs->regs.cfa_how)
@@ -1126,7 +1125,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
 	  internal_error (__FILE__, __LINE__, _("Unknown CFA rule."));
 	}
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error == NOT_AVAILABLE_ERROR)
 	{
@@ -1138,6 +1137,7 @@ dwarf2_frame_cache (struct frame_info *this_frame, void **this_cache)
 
       throw_exception (ex);
     }
+  END_CATCH
 
   /* Initialize the register state.  */
   {
@@ -2269,7 +2269,6 @@ dwarf2_build_frame_info (struct objfile *objfile)
   struct dwarf2_cie_table cie_table;
   struct dwarf2_fde_table fde_table;
   struct dwarf2_fde_table *fde_table2;
-  volatile struct gdb_exception e;
 
   cie_table.num_entries = 0;
   cie_table.entries = NULL;
@@ -2311,7 +2310,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
           if (txt)
             unit->tbase = txt->vma;
 
-	  TRY_CATCH (e, RETURN_MASK_ERROR)
+	  TRY
 	    {
 	      frame_ptr = unit->dwarf_frame_buffer;
 	      while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size)
@@ -2320,7 +2319,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
 						EH_CIE_OR_FDE_TYPE_ID);
 	    }
 
-	  if (e.reason < 0)
+	  CATCH (e, RETURN_MASK_ERROR)
 	    {
 	      warning (_("skipping .eh_frame info of %s: %s"),
 		       objfile_name (objfile), e.message);
@@ -2333,6 +2332,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
 		}
 	      /* The cie_table is discarded by the next if.  */
 	    }
+	  END_CATCH
 
           if (cie_table.num_entries != 0)
             {
@@ -2352,7 +2352,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
     {
       int num_old_fde_entries = fde_table.num_entries;
 
-      TRY_CATCH (e, RETURN_MASK_ERROR)
+      TRY
 	{
 	  frame_ptr = unit->dwarf_frame_buffer;
 	  while (frame_ptr < unit->dwarf_frame_buffer + unit->dwarf_frame_size)
@@ -2360,7 +2360,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
 					    &cie_table, &fde_table,
 					    EH_CIE_OR_FDE_TYPE_ID);
 	}
-      if (e.reason < 0)
+      CATCH (e, RETURN_MASK_ERROR)
 	{
 	  warning (_("skipping .debug_frame info of %s: %s"),
 		   objfile_name (objfile), e.message);
@@ -2383,6 +2383,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
 	  fde_table.num_entries = num_old_fde_entries;
 	  /* The cie_table is discarded by the next if.  */
 	}
+      END_CATCH
     }
 
   /* Discard the cie_table, it is no longer needed.  */
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index aa569ee..e674933 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -983,14 +983,13 @@ struct call_site_chain *
 call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
 		      CORE_ADDR callee_pc)
 {
-  volatile struct gdb_exception e;
   struct call_site_chain *retval = NULL;
 
-  TRY_CATCH (e, RETURN_MASK_ERROR)
+  TRY
     {
       retval = call_site_find_chain_1 (gdbarch, caller_pc, callee_pc);
     }
-  if (e.reason < 0)
+  CATCH (e, RETURN_MASK_ERROR)
     {
       if (e.error == NO_ENTRY_VALUE_ERROR)
 	{
@@ -1002,6 +1001,8 @@ call_site_find_chain (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
       else
 	throw_exception (e);
     }
+  END_CATCH
+
   return retval;
 }
 
@@ -2183,7 +2184,6 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
   struct dwarf_expr_context *ctx;
   struct cleanup *old_chain, *value_chain;
   struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
-  volatile struct gdb_exception ex;
 
   if (byte_offset < 0)
     invalid_synthetic_pointer ();
@@ -2206,11 +2206,11 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
   ctx->baton = &baton;
   ctx->funcs = &dwarf_expr_ctx_funcs;
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       dwarf_expr_eval (ctx, data, size);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error == NOT_AVAILABLE_ERROR)
 	{
@@ -2229,6 +2229,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
       else
 	throw_exception (ex);
     }
+  END_CATCH
 
   if (ctx->num_pieces > 0)
     {
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a283cba..c185d51 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4221,14 +4221,13 @@ dwarf2_initialize_objfile (struct objfile *objfile)
 void
 dwarf2_build_psymtabs (struct objfile *objfile)
 {
-  volatile struct gdb_exception except;
 
   if (objfile->global_psymbols.size == 0 && objfile->static_psymbols.size == 0)
     {
       init_psymbol_list (objfile, 1024);
     }
 
-  TRY_CATCH (except, RETURN_MASK_ERROR)
+  TRY
     {
       /* This isn't really ideal: all the data we allocate on the
 	 objfile's obstack is still uselessly kept around.  However,
@@ -4238,8 +4237,11 @@ dwarf2_build_psymtabs (struct objfile *objfile)
       dwarf2_build_psymtabs_hard (objfile);
       discard_cleanups (cleanups);
     }
-  if (except.reason < 0)
-    exception_print (gdb_stderr, except);
+  CATCH (except, RETURN_MASK_ERROR)
+    {
+      exception_print (gdb_stderr, except);
+    }
+  END_CATCH
 }
 
 /* Return the total length of the CU described by HEADER.  */
@@ -23171,16 +23173,18 @@ save_gdb_index_command (char *arg, int from_tty)
     dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
     if (dwarf2_per_objfile)
       {
-	volatile struct gdb_exception except;
 
-	TRY_CATCH (except, RETURN_MASK_ERROR)
+	TRY
 	  {
 	    write_psymtabs_to_index (objfile, arg);
 	  }
-	if (except.reason < 0)
-	  exception_fprintf (gdb_stderr, except,
-			     _("Error while writing index for `%s': "),
-			     objfile_name (objfile));
+	CATCH (except, RETURN_MASK_ERROR)
+	  {
+	    exception_fprintf (gdb_stderr, except,
+			       _("Error while writing index for `%s': "),
+			       objfile_name (objfile));
+	  }
+	END_CATCH
       }
   }
 }
diff --git a/gdb/eval.c b/gdb/eval.c
index bb2a0da..9804a97 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -212,7 +212,6 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp,
 		    int preserve_errors)
 {
   struct value *mark, *new_mark, *result;
-  volatile struct gdb_exception ex;
 
   *valp = NULL;
   if (resultp)
@@ -224,11 +223,11 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp,
   mark = value_mark ();
   result = NULL;
 
-  TRY_CATCH (ex, RETURN_MASK_ALL)
+  TRY
     {
       result = evaluate_subexp (NULL_TYPE, exp, pc, EVAL_NORMAL);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ALL)
     {
       /* Ignore memory errors if we want watchpoints pointing at
 	 inaccessible memory to still be created; otherwise, throw the
@@ -243,6 +242,7 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp,
 	  break;
 	}
     }
+  END_CATCH
 
   new_mark = value_mark ();
   if (mark == new_mark)
@@ -258,13 +258,16 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp,
 	*valp = result;
       else
 	{
-	  volatile struct gdb_exception except;
 
-	  TRY_CATCH (except, RETURN_MASK_ERROR)
+	  TRY
 	    {
 	      value_fetch_lazy (result);
 	      *valp = result;
 	    }
+	  CATCH (except, RETURN_MASK_ERROR)
+	    {
+	    }
+	  END_CATCH
 	}
     }
 
@@ -762,16 +765,15 @@ evaluate_subexp_standard (struct type *expect_type,
 	 or reference to a base class and print object is on.  */
 
       {
-	volatile struct gdb_exception except;
 	struct value *ret = NULL;
 
-	TRY_CATCH (except, RETURN_MASK_ERROR)
+	TRY
 	  {
 	    ret = value_of_variable (exp->elts[pc + 2].symbol,
 				     exp->elts[pc + 1].block);
 	  }
 
-	if (except.reason < 0)
+	CATCH (except, RETURN_MASK_ERROR)
 	  {
 	    if (noside == EVAL_AVOID_SIDE_EFFECTS)
 	      ret = value_zero (SYMBOL_TYPE (exp->elts[pc + 2].symbol),
@@ -779,6 +781,7 @@ evaluate_subexp_standard (struct type *expect_type,
 	    else
 	      throw_exception (except);
 	  }
+	END_CATCH
 
 	return ret;
       }
@@ -1446,20 +1449,21 @@ evaluate_subexp_standard (struct type *expect_type,
 	         operator and continue evaluation.  */
 	      while (unop_user_defined_p (op, arg2))
 		{
-		  volatile struct gdb_exception except;
 		  struct value *value = NULL;
-		  TRY_CATCH (except, RETURN_MASK_ERROR)
+		  TRY
 		    {
 		      value = value_x_unop (arg2, op, noside);
 		    }
 
-		  if (except.reason < 0)
+		  CATCH (except, RETURN_MASK_ERROR)
 		    {
 		      if (except.error == NOT_FOUND_ERROR)
 			break;
 		      else
 			throw_exception (except);
 		    }
+		  END_CATCH
+
 		  arg2 = value;
 		}
 	    }
@@ -1863,20 +1867,21 @@ evaluate_subexp_standard (struct type *expect_type,
          arg1 with the value returned by evaluating operator->().  */
       while (unop_user_defined_p (op, arg1))
 	{
-	  volatile struct gdb_exception except;
 	  struct value *value = NULL;
-	  TRY_CATCH (except, RETURN_MASK_ERROR)
+	  TRY
 	    {
 	      value = value_x_unop (arg1, op, noside);
 	    }
 
-	  if (except.reason < 0)
+	  CATCH (except, RETURN_MASK_ERROR)
 	    {
 	      if (except.error == NOT_FOUND_ERROR)
 		break;
 	      else
 		throw_exception (except);
 	    }
+	  END_CATCH
+
 	  arg1 = value;
 	}
 
diff --git a/gdb/event-loop.c b/gdb/event-loop.c
index a2b41a7..79e41fd 100644
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -326,14 +326,13 @@ start_event_loop (void)
      processes it.  */
   while (1)
     {
-      volatile struct gdb_exception ex;
       int result = 0;
 
-      TRY_CATCH (ex, RETURN_MASK_ALL)
+      TRY
 	{
 	  result = gdb_do_one_event ();
 	}
-      if (ex.reason < 0)
+      CATCH (ex, RETURN_MASK_ALL)
 	{
 	  exception_print (gdb_stderr, ex);
 
@@ -356,6 +355,8 @@ start_event_loop (void)
 	  /* Maybe better to set a flag to be checked somewhere as to
 	     whether display the prompt or not.  */
 	}
+      END_CATCH
+
       if (result < 0)
 	break;
     }
diff --git a/gdb/event-top.c b/gdb/event-top.c
index bbda5dc..e9cc2d7 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -935,24 +935,28 @@ handle_sighup (int sig)
 static void
 async_disconnect (gdb_client_data arg)
 {
-  volatile struct gdb_exception exception;
 
-  TRY_CATCH (exception, RETURN_MASK_ALL)
+  TRY
     {
       quit_cover ();
     }
 
-  if (exception.reason < 0)
+  CATCH (exception, RETURN_MASK_ALL)
     {
       fputs_filtered ("Could not kill the program being debugged",
 		      gdb_stderr);
       exception_print (gdb_stderr, exception);
     }
+  END_CATCH
 
-  TRY_CATCH (exception, RETURN_MASK_ALL)
+  TRY
     {
       pop_all_targets ();
     }
+  CATCH (exception, RETURN_MASK_ALL)
+    {
+    }
+  END_CATCH
 
   signal (SIGHUP, SIG_DFL);	/*FIXME: ???????????  */
   raise (SIGHUP);
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 64a653a..623e8e0 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -174,7 +174,6 @@ catch_exceptions_with_msg (struct ui_out *func_uiout,
 			   char **gdberrmsg,
 		  	   return_mask mask)
 {
-  volatile struct gdb_exception ex;
   struct gdb_exception exception = exception_none;
   volatile int val = 0;
   struct ui_out *saved_uiout;
@@ -183,14 +182,15 @@ catch_exceptions_with_msg (struct ui_out *func_uiout,
   saved_uiout = current_uiout;
   current_uiout = func_uiout;
 
-  TRY_CATCH (ex, RETURN_MASK_ALL)
+  TRY
     {
       val = (*func) (current_uiout, func_args);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ALL)
     {
       exception = ex;
     }
+  END_CATCH
 
   /* Restore the global builder.  */
   current_uiout = saved_uiout;
@@ -228,17 +228,22 @@ int
 catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
 	      return_mask mask)
 {
+  struct gdb_exception exception = exception_none;
   volatile int val = 0;
-  volatile struct gdb_exception exception;
   struct ui_out *saved_uiout;
 
   /* Save the global ``struct ui_out'' builder.  */
   saved_uiout = current_uiout;
 
-  TRY_CATCH (exception, RETURN_MASK_ALL)
+  TRY
     {
       val = func (func_args);
     }
+  CATCH (ex, RETURN_MASK_ALL)
+    {
+      exception = ex;
+    }
+  END_CATCH
 
   /* Restore the global builder.  */
   current_uiout = saved_uiout;
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index c2aca71..e841edf 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -443,19 +443,22 @@ info_common_command_for_block (const struct block *block, const char *comname,
 	for (index = 0; index < common->n_entries; index++)
 	  {
 	    struct value *val = NULL;
-	    volatile struct gdb_exception except;
 
 	    printf_filtered ("%s = ",
 			     SYMBOL_PRINT_NAME (common->contents[index]));
 
-	    TRY_CATCH (except, RETURN_MASK_ERROR)
+	    TRY
 	      {
 		val = value_of_variable (common->contents[index], block);
 		value_print (val, gdb_stdout, &opts);
 	      }
 
-	    if (except.reason < 0)
-	      printf_filtered ("<error reading variable: %s>", except.message);
+	    CATCH (except, RETURN_MASK_ERROR)
+	      {
+		printf_filtered ("<error reading variable: %s>", except.message);
+	      }
+	    END_CATCH
+
 	    putchar_filtered ('\n');
 	  }
       }
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index fcfedfd..bba1ae7 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -96,16 +96,15 @@ frame_unwind_try_unwinder (struct frame_info *this_frame, void **this_cache,
                           const struct frame_unwind *unwinder)
 {
   struct cleanup *old_cleanup;
-  volatile struct gdb_exception ex;
   int res = 0;
 
   old_cleanup = frame_prepare_for_sniffer (this_frame, unwinder);
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       res = unwinder->sniffer (unwinder, this_frame, this_cache);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error == NOT_AVAILABLE_ERROR)
 	{
@@ -118,6 +117,7 @@ frame_unwind_try_unwinder (struct frame_info *this_frame, void **this_cache,
 	}
       throw_exception (ex);
     }
+  END_CATCH
 
   if (res)
     {
diff --git a/gdb/frame.c b/gdb/frame.c
index 7088f32..b3cbf23 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -784,9 +784,9 @@ frame_unwind_pc (struct frame_info *this_frame)
     {
       if (gdbarch_unwind_pc_p (frame_unwind_arch (this_frame)))
 	{
-	  volatile struct gdb_exception ex;
 	  struct gdbarch *prev_gdbarch;
 	  CORE_ADDR pc = 0;
+	  int pc_p = 0;
 
 	  /* The right way.  The `pure' way.  The one true way.  This
 	     method depends solely on the register-unwind code to
@@ -806,11 +806,12 @@ frame_unwind_pc (struct frame_info *this_frame)
 	     different ways that a PC could be unwound.  */
 	  prev_gdbarch = frame_unwind_arch (this_frame);
 
-	  TRY_CATCH (ex, RETURN_MASK_ERROR)
+	  TRY
 	    {
 	      pc = gdbarch_unwind_pc (prev_gdbarch, this_frame);
+	      pc_p = 1;
 	    }
-	  if (ex.reason < 0)
+	  CATCH (ex, RETURN_MASK_ERROR)
 	    {
 	      if (ex.error == NOT_AVAILABLE_ERROR)
 		{
@@ -835,7 +836,9 @@ frame_unwind_pc (struct frame_info *this_frame)
 	      else
 		throw_exception (ex);
 	    }
-	  else
+	  END_CATCH
+
+	  if (pc_p)
 	    {
 	      this_frame->prev_pc.value = pc;
 	      this_frame->prev_pc.status = CC_VALUE;
@@ -1963,14 +1966,13 @@ get_prev_frame_always_1 (struct frame_info *this_frame)
 struct frame_info *
 get_prev_frame_always (struct frame_info *this_frame)
 {
-  volatile struct gdb_exception ex;
   struct frame_info *prev_frame = NULL;
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       prev_frame = get_prev_frame_always_1 (this_frame);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error == MEMORY_ERROR)
 	{
@@ -1994,6 +1996,7 @@ get_prev_frame_always (struct frame_info *this_frame)
       else
 	throw_exception (ex);
     }
+  END_CATCH
 
   return prev_frame;
 }
@@ -2222,21 +2225,21 @@ get_frame_pc (struct frame_info *frame)
 int
 get_frame_pc_if_available (struct frame_info *frame, CORE_ADDR *pc)
 {
-  volatile struct gdb_exception ex;
 
   gdb_assert (frame->next != NULL);
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       *pc = frame_unwind_pc (frame->next);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error == NOT_AVAILABLE_ERROR)
 	return 0;
       else
 	throw_exception (ex);
     }
+  END_CATCH
 
   return 1;
 }
@@ -2307,18 +2310,18 @@ int
 get_frame_address_in_block_if_available (struct frame_info *this_frame,
 					 CORE_ADDR *pc)
 {
-  volatile struct gdb_exception ex;
 
-  TRY_CATCH (ex, RETURN_MASK_ERROR)
+  TRY
     {
       *pc = get_frame_address_in_block (this_frame);
     }
-  if (ex.reason < 0)
+  CATCH (ex, RETURN_MASK_ERROR)
     {
       if (ex.error == NOT_AVAILABLE_ERROR)
 	return 0;
       throw_exception (ex);
     }
+  END_CATCH
 
   return 1;
 }
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 3e05c61..44b9d0c 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -114,12 +114,19 @@ write_gcore_file_1 (bfd *obfd)
 void
 write_gcore_file (bfd *obfd)
 {
-  volatile struct gdb_exception except;
+  struct gdb_exception except = exception_none;
 
   target_prepare_to_generate_core ();
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
-    write_gcore_file_1 (obfd);
+  TRY
+    {
+      write_gcore_file_1 (obfd);
+    }
+  CATCH (e, RETURN_MASK_ALL)
+    {
+      except = e;
+    }
+  END_CATCH
 
   target_done_generating_core ();
 
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index e735c8e..70cc374 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-07  Pedro Alves  <palves@redhat.com>
+
+	Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
+	instead.
+
 2015-03-06  Yao Qi  <yao.qi@linaro.org>
 
 	* linux-aarch64-low.c (aarch64_insert_point): Use
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 4189877..08dbb60 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -3144,19 +3144,19 @@ static int exit_code;
 static void
 detach_or_kill_for_exit_cleanup (void *ignore)
 {
-  volatile struct gdb_exception exception;
 
-  TRY_CATCH (exception, RETURN_MASK_ALL)
+  TRY
     {
       detach_or_kill_for_exit ();
     }
 
-  if (exception.reason < 0)
+  CATCH (exception, RETURN_MASK_ALL)
     {
       fflush (stdout);
       fprintf (stderr, "Detach or kill failed: %s\n", exception.message);
       exit_code = 1;
     }
+  END_CATCH
 }
 
 /* Main function.  This is called by the real "main" function,
@@ -3385,7 +3385,6 @@ captured_main (int argc, char *argv[])
 
   while (1)
     {
-      volatile struct gdb_exception exception;
 
       noack_mode = 0;
       multi_process = 0;
@@ -3397,7 +3396,7 @@ captured_main (int argc, char *argv[])
 
       remote_open (port);
 
-      TRY_CATCH (exception, RETURN_MASK_ERROR)
+      TRY
 	{
 	  /* Wait for events.  This will return when all event sources
 	     are removed from the event loop.  */
@@ -3450,8 +3449,7 @@ captured_main (int argc, char *argv[])
 		}
 	    }
 	}
-
-      if (exception.reason == RETURN_ERROR)
+      CATCH (exception, RETURN_MASK_ERROR)
 	{
 	  if (response_needed)
 	    {
@@ -3459,6 +3457,7 @@ captured_main (int argc, char *argv[])
 	      putpkt (own_buf);
 	    }
 	}
+      END_CATCH
     }
 }
 
@@ -3467,25 +3466,26 @@ captured_main (int argc, char *argv[])
 int
 main (int argc, char *argv[])
 {
-  volatile struct gdb_exception exception;
 
-  TRY_CATCH (exception, RETURN_MASK_ALL)
+  TRY
     {
       captured_main (argc, argv);
     }
-
-  /* captured_main should never return.  */
-  gdb_assert (exception.reason < 0);
-
-  if (exception.reason == RETURN_ERROR)
+  CATCH (exception, RETURN_MASK_ALL)
     {
-      fflush (stdout);
-      fprintf (stderr, "%s\n", exception.message);
-      fprintf (stderr, "Exiting\n");
-      exit_code = 1;
+      if (exception.reason == RETURN_ERROR)
+	{
+	  fflush (stdout);
+	  fprintf (stderr, "%s\n", exception.message);
+	  fprintf (stderr, "Exiting\n");
+	  exit_code = 1;
+	}
+
+      exit (exit_code);
     }
+  END_CATCH
 
-  exit (exit_code);
+  gdb_assert_not_reached ("captured_main should never return");
 }
 
 /* Skip PACKET until the next semi-colon (or end of string).  */
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index d087a12..af59d42 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2299,20 +2299,22 @@ safe_parse_type (struct gdbarch *gdbarch, char *p, int length)
 {
   struct ui_file *saved_gdb_stderr;
   struct type *type = NULL; /* Initialize to keep gcc happy.  */
-  volatile struct gdb_exception except;
 
   /* Suppress error messages.  */
   saved_gdb_stderr = gdb_stderr;
   gdb_stderr = ui_file_new ();
 
   /* Call parse_and_eval_type() without fear of longjmp()s.  */
-  TRY_CATCH (except, RETURN_MASK_ERROR)
+  TRY
     {
       type = parse_and_eval_type (p, length);
     }
 
-  if (except.reason < 0)
-    type = builtin_type (gdbarch)->builtin_void;
+  CATCH (except, RETURN_MASK_ERROR)
+    {
+      type = builtin_type (gdbarch)->builtin_void;
+    }
+  END_CATCH
 
   /* Stop suppressing error messages.  */
   ui_file_delete (gdb_stderr);
@@ -3235,7 +3237,6 @@ check_types_worklist (VEC (type_equality_entry_d) **worklist,
 int
 types_deeply_equal (struct type *type1, struct type *type2)
 {
-  volatile struct gdb_exception except;
   int result = 0;
   struct bcache *cache;
   VEC (type_equality_entry_d) *worklist = NULL;
@@ -3253,7 +3254,7 @@ types_deeply_equal (struct type *type1, struct type *type2)
   entry.type2 = type2;
   VEC_safe_push (type_equality_entry_d, worklist, &entry);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       result = check_types_worklist (&worklist, cache);
     }
@@ -3264,8 +3265,11 @@ types_deeply_equal (struct type *type1, struct type *type2)
   bcache_xfree (cache);
   VEC_free (type_equality_entry_d, worklist);
   /* Rethrow if there was a problem.  */
-  if (except.reason < 0)
-    throw_exception (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      throw_exception (except);
+    }
+  END_CATCH
 
   return result;
 }
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index d1ed8fc..5c04011 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -904,8 +904,8 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value,
     {
       /* Initialize it just to avoid a GCC false warning.  */
       CORE_ADDR addr = 0;
+      int got_error = 0;
       struct value *vfn;
-      volatile struct gdb_exception ex;
 
       printf_filtered ("[%d]: ", i);
 
@@ -916,13 +916,18 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value,
       if (gdbarch_vtable_function_descriptors (gdbarch))
 	vfn = value_addr (vfn);
 
-      TRY_CATCH (ex, RETURN_MASK_ERROR)
+      TRY
 	{
 	  addr = value_as_address (vfn);
 	}
-      if (ex.reason < 0)
-	printf_filtered (_("<error: %s>"), ex.message);
-      else
+      CATCH (ex, RETURN_MASK_ERROR)
+	{
+	  printf_filtered (_("<error: %s>"), ex.message);
+	  got_error = 1;
+	}
+      END_CATCH
+
+      if (!got_error)
 	print_function_pointer_address (opts, gdbarch, addr, gdb_stdout);
       printf_filtered ("\n");
     }
diff --git a/gdb/guile/guile.c b/gdb/guile/guile.c
index 1895118..16d15b7 100644
--- a/gdb/guile/guile.c
+++ b/gdb/guile/guile.c
@@ -310,11 +310,11 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest)
 {
   int from_tty_arg_pos = -1, to_string_arg_pos = -1;
   int from_tty = 0, to_string = 0;
-  volatile struct gdb_exception except;
   const SCM keywords[] = { from_tty_keyword, to_string_keyword, SCM_BOOL_F };
   char *command;
   char *result = NULL;
   struct cleanup *cleanups;
+  struct gdb_exception except = exception_none;
 
   gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#tt",
 			      command_scm, &command, rest,
@@ -325,7 +325,7 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest)
      executed.  */
   cleanups = make_cleanup (xfree, command);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       struct cleanup *inner_cleanups;
 
@@ -346,6 +346,12 @@ gdbscm_execute_gdb_command (SCM command_scm, SCM rest)
 
       do_cleanups (inner_cleanups);
     }
+  CATCH (ex, RETURN_MASK_ALL)
+    {
+      except = ex;
+    }
+  END_CATCH
+
   do_cleanups (cleanups);
   GDBSCM_HANDLE_GDB_EXCEPTION (except);
 
diff --git a/gdb/guile/scm-block.c b/gdb/guile/scm-block.c
index 36c14da..50dc6c7 100644
--- a/gdb/guile/scm-block.c
+++ b/gdb/guile/scm-block.c
@@ -678,18 +678,21 @@ gdbscm_lookup_block (SCM pc_scm)
   CORE_ADDR pc;
   const struct block *block = NULL;
   struct compunit_symtab *cust = NULL;
-  volatile struct gdb_exception except;
 
   gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "U", pc_scm, &pc);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       cust = find_pc_compunit_symtab (pc);
 
       if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
 	block = block_for_pc (pc);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
     {
diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
index c1f9f91..ad853ed 100644
--- a/gdb/guile/scm-breakpoint.c
+++ b/gdb/guile/scm-breakpoint.c
@@ -407,7 +407,7 @@ gdbscm_register_breakpoint_x (SCM self)
 {
   breakpoint_smob *bp_smob
     = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
-  volatile struct gdb_exception except;
+  struct gdb_exception except = exception_none;
 
   /* We only support registering breakpoints created with make-breakpoint.  */
   if (!bp_smob->is_scheme_bkpt)
@@ -418,7 +418,7 @@ gdbscm_register_breakpoint_x (SCM self)
 
   pending_breakpoint_scm = self;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       char *location = bp_smob->spec.location;
       int internal = bp_smob->spec.is_internal;
@@ -455,6 +455,12 @@ gdbscm_register_breakpoint_x (SCM self)
 	  gdb_assert_not_reached ("invalid breakpoint type");
 	}
     }
+  CATCH (ex, RETURN_MASK_ALL)
+    {
+      except = ex;
+    }
+  END_CATCH
+
   /* Ensure this gets reset, even if there's an error.  */
   pending_breakpoint_scm = SCM_BOOL_F;
   GDBSCM_HANDLE_GDB_EXCEPTION (except);
@@ -473,13 +479,16 @@ gdbscm_delete_breakpoint_x (SCM self)
 {
   breakpoint_smob *bp_smob
     = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
-  volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       delete_breakpoint (bp_smob->bp);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return SCM_UNSPECIFIED;
 }
@@ -565,19 +574,22 @@ gdbscm_set_breakpoint_enabled_x (SCM self, SCM newvalue)
 {
   breakpoint_smob *bp_smob
     = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
-  volatile struct gdb_exception except;
 
   SCM_ASSERT_TYPE (gdbscm_is_bool (newvalue), newvalue, SCM_ARG2, FUNC_NAME,
 		   _("boolean"));
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       if (gdbscm_is_true (newvalue))
 	enable_breakpoint (bp_smob->bp);
       else
 	disable_breakpoint (bp_smob->bp);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return SCM_UNSPECIFIED;
 }
@@ -600,16 +612,19 @@ gdbscm_set_breakpoint_silent_x (SCM self, SCM newvalue)
 {
   breakpoint_smob *bp_smob
     = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
-  volatile struct gdb_exception except;
 
   SCM_ASSERT_TYPE (gdbscm_is_bool (newvalue), newvalue, SCM_ARG2, FUNC_NAME,
 		   _("boolean"));
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       breakpoint_set_silent (bp_smob->bp, gdbscm_is_true (newvalue));
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return SCM_UNSPECIFIED;
 }
@@ -634,7 +649,6 @@ gdbscm_set_breakpoint_ignore_count_x (SCM self, SCM newvalue)
   breakpoint_smob *bp_smob
     = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   long value;
-  volatile struct gdb_exception except;
 
   SCM_ASSERT_TYPE (scm_is_signed_integer (newvalue, LONG_MIN, LONG_MAX),
 		   newvalue, SCM_ARG2, FUNC_NAME, _("integer"));
@@ -643,11 +657,15 @@ gdbscm_set_breakpoint_ignore_count_x (SCM self, SCM newvalue)
   if (value < 0)
     value = 0;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       set_ignore_count (bp_smob->number, (int) value, 0);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return SCM_UNSPECIFIED;
 }
@@ -755,17 +773,20 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue)
     = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   long id;
   int valid_id = 0;
-  volatile struct gdb_exception except;
 
   if (scm_is_signed_integer (newvalue, LONG_MIN, LONG_MAX))
     {
       id = scm_to_long (newvalue);
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY
 	{
 	  valid_id = valid_task_id (id);
 	}
-      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+      CATCH (except, RETURN_MASK_ALL)
+	{
+	  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+	}
+      END_CATCH
 
       if (! valid_id)
 	{
@@ -778,11 +799,15 @@ gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue)
   else
     SCM_ASSERT_TYPE (0, newvalue, SCM_ARG2, FUNC_NAME, _("integer or #f"));
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       breakpoint_set_task (bp_smob->bp, id);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return SCM_UNSPECIFIED;
 }
@@ -855,7 +880,7 @@ gdbscm_set_breakpoint_condition_x (SCM self, SCM newvalue)
   breakpoint_smob *bp_smob
     = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   char *exp;
-  volatile struct gdb_exception except;
+  struct gdb_exception except = exception_none;
 
   SCM_ASSERT_TYPE (scm_is_string (newvalue) || gdbscm_is_false (newvalue),
 		   newvalue, SCM_ARG2, FUNC_NAME,
@@ -866,10 +891,16 @@ gdbscm_set_breakpoint_condition_x (SCM self, SCM newvalue)
   else
     exp = gdbscm_scm_to_c_string (newvalue);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       set_breakpoint_condition (bp_smob->bp, exp ? exp : "", 0);
     }
+  CATCH (ex, RETURN_MASK_ALL)
+    {
+      except = ex;
+    }
+  END_CATCH
+
   xfree (exp);
   GDBSCM_HANDLE_GDB_EXCEPTION (except);
 
@@ -936,7 +967,6 @@ gdbscm_breakpoint_commands (SCM self)
     = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   struct breakpoint *bp;
   long length;
-  volatile struct gdb_exception except;
   struct ui_file *string_file;
   struct cleanup *chain;
   SCM result;
@@ -951,16 +981,17 @@ gdbscm_breakpoint_commands (SCM self)
   chain = make_cleanup_ui_file_delete (string_file);
 
   ui_out_redirect (current_uiout, string_file);
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       print_command_lines (current_uiout, breakpoint_commands (bp), 0);
     }
   ui_out_redirect (current_uiout, NULL);
-  if (except.reason < 0)
+  CATCH (except, RETURN_MASK_ALL)
     {
       do_cleanups (chain);
       gdbscm_throw_gdb_exception (except);
     }
+  END_CATCH
 
   cmdstr = ui_file_xstrdup (string_file, &length);
   make_cleanup (xfree, cmdstr);
diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
index 7c6d010..c870fcc 100644
--- a/gdb/guile/scm-cmd.c
+++ b/gdb/guile/scm-cmd.c
@@ -762,7 +762,6 @@ gdbscm_register_command_x (SCM self)
   char *cmd_name, *pfx_name;
   struct cmd_list_element **cmd_list;
   struct cmd_list_element *cmd = NULL;
-  volatile struct gdb_exception except;
 
   if (cmdscm_is_valid (c_smob))
     scm_misc_error (FUNC_NAME, _("command is already registered"), SCM_EOL);
@@ -772,7 +771,7 @@ gdbscm_register_command_x (SCM self)
   c_smob->cmd_name = gdbscm_gc_xstrdup (cmd_name);
   xfree (cmd_name);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       if (c_smob->is_prefix)
 	{
@@ -790,7 +789,11 @@ gdbscm_register_command_x (SCM self)
 			 NULL, c_smob->doc, cmd_list);
 	}
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   /* Note: At this point the command exists in gdb.
      So no more errors after this point.  */
diff --git a/gdb/guile/scm-disasm.c b/gdb/guile/scm-disasm.c
index 5ae7075..782d915 100644
--- a/gdb/guile/scm-disasm.c
+++ b/gdb/guile/scm-disasm.c
@@ -283,9 +283,8 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest)
       char *as = NULL;
       struct ui_file *memfile = mem_fileopen ();
       struct cleanup *cleanups = make_cleanup_ui_file_delete (memfile);
-      volatile struct gdb_exception except;
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY
 	{
 	  if (using_port)
 	    {
@@ -295,7 +294,11 @@ gdbscm_arch_disassemble (SCM self, SCM start_scm, SCM rest)
 	  else
 	    insn_len = gdb_print_insn (gdbarch, pc, memfile, NULL);
 	}
-      GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups);
+      CATCH (except, RETURN_MASK_ALL)
+	{
+	  GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups);
+	}
+      END_CATCH
 
       as = ui_file_xstrdup (memfile, NULL);
 
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index a30c093..6189802 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -220,7 +220,6 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior)
   SCM f_scm;
   htab_t htab;
   eqable_gdb_smob **slot;
-  volatile struct gdb_exception except;
   struct frame_id frame_id = null_frame_id;
   struct gdbarch *gdbarch = NULL;
   int frame_id_is_next = 0;
@@ -234,7 +233,7 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior)
   if (*slot != NULL)
     return (*slot)->containing_scm;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       /* Try to get the previous frame, to determine if this is the last frame
 	 in a corrupt stack.  If so, we need to store the frame_id of the next
@@ -253,8 +252,11 @@ frscm_scm_from_frame (struct frame_info *frame, struct inferior *inferior)
 	}
       gdbarch = get_frame_arch (frame);
     }
-  if (except.reason < 0)
-    return gdbscm_scm_from_gdb_exception (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      return gdbscm_scm_from_gdb_exception (except);
+    }
+  END_CATCH
 
   f_scm = frscm_make_frame_smob ();
   f_smob = (frame_smob *) SCM_SMOB_DATA (f_scm);
@@ -396,15 +398,18 @@ gdbscm_frame_valid_p (SCM self)
 {
   frame_smob *f_smob;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return scm_from_bool (frame != NULL);
 }
@@ -421,18 +426,23 @@ gdbscm_frame_name (SCM self)
   enum language lang = language_minimal;
   struct frame_info *frame = NULL;
   SCM result;
-  volatile struct gdb_exception except;
+  struct gdb_exception except = exception_none;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	find_frame_funname (frame, &name, &lang, NULL);
     }
-  if (except.reason < 0)
-    xfree (name);
+  CATCH (ex, RETURN_MASK_ALL)
+    {
+      except = ex;
+    }
+  END_CATCH
+
+  xfree (name);
   GDBSCM_HANDLE_GDB_EXCEPTION (except);
 
   if (frame == NULL)
@@ -461,17 +471,20 @@ gdbscm_frame_type (SCM self)
   frame_smob *f_smob;
   enum frame_type type = NORMAL_FRAME;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	type = get_frame_type (frame);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -490,15 +503,18 @@ gdbscm_frame_arch (SCM self)
 {
   frame_smob *f_smob;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -517,16 +533,19 @@ gdbscm_frame_unwind_stop_reason (SCM self)
 {
   frame_smob *f_smob;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
   enum unwind_stop_reason stop_reason;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -548,17 +567,20 @@ gdbscm_frame_pc (SCM self)
   frame_smob *f_smob;
   CORE_ADDR pc = 0;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	pc = get_frame_pc (frame);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -578,17 +600,20 @@ gdbscm_frame_block (SCM self)
   frame_smob *f_smob;
   const struct block *block = NULL, *fn_block;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	block = get_frame_block (frame, NULL);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -626,17 +651,20 @@ gdbscm_frame_function (SCM self)
   frame_smob *f_smob;
   struct symbol *sym = NULL;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	sym = find_pc_function (get_frame_address_in_block (frame));
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -660,17 +688,20 @@ gdbscm_frame_older (SCM self)
   frame_smob *f_smob;
   struct frame_info *prev = NULL;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	prev = get_prev_frame (frame);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -694,17 +725,20 @@ gdbscm_frame_newer (SCM self)
   frame_smob *f_smob;
   struct frame_info *next = NULL;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	next = get_next_frame (frame);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -727,17 +761,20 @@ gdbscm_frame_sal (SCM self)
   frame_smob *f_smob;
   struct symtab_and_line sal;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	find_frame_sal (frame, &sal);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -767,15 +804,18 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest)
   struct frame_info *frame = NULL;
   struct symbol *var = NULL;
   struct value *value = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -797,7 +837,7 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest)
       char *var_name;
       const struct block *block = NULL;
       struct cleanup *cleanup;
-      volatile struct gdb_exception except;
+      struct gdb_exception except = exception_none;
 
       if (! SCM_UNBNDP (block_scm))
 	{
@@ -815,14 +855,19 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest)
       /* N.B. Between here and the call to do_cleanups, don't do anything
 	 to cause a Scheme exception without performing the cleanup.  */
 
-      TRY_CATCH (except, RETURN_MASK_ALL)
+      TRY
 	{
 	  if (block == NULL)
 	    block = get_frame_block (frame, NULL);
 	  var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL);
 	}
-      if (except.reason < 0)
-	do_cleanups (cleanup);
+      CATCH (ex, RETURN_MASK_ALL)
+	{
+	  except = ex;
+	}
+      END_CATCH
+
+      do_cleanups (cleanup);
       GDBSCM_HANDLE_GDB_EXCEPTION (except);
 
       if (var == NULL)
@@ -841,11 +886,15 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest)
 		       _("gdb:symbol or string"));
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       value = read_var_value (var, frame);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return vlscm_scm_from_value (value);
 }
@@ -858,17 +907,20 @@ gdbscm_frame_select (SCM self)
 {
   frame_smob *f_smob;
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
   f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = frscm_frame_smob_to_frame (f_smob);
       if (frame != NULL)
 	select_frame (frame);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   if (frame == NULL)
     {
@@ -886,13 +938,16 @@ static SCM
 gdbscm_newest_frame (void)
 {
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = get_current_frame ();
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return frscm_scm_from_frame_unsafe (frame, current_inferior ());
 }
@@ -904,13 +959,16 @@ static SCM
 gdbscm_selected_frame (void)
 {
   struct frame_info *frame = NULL;
-  volatile struct gdb_exception except;
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       frame = get_selected_frame (_("No frame is currently selected"));
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return frscm_scm_from_frame_unsafe (frame, current_inferior ());
 }
diff --git a/gdb/guile/scm-lazy-string.c b/gdb/guile/scm-lazy-string.c
index d9ca97e9..c84ead7 100644
--- a/gdb/guile/scm-lazy-string.c
+++ b/gdb/guile/scm-lazy-string.c
@@ -234,7 +234,6 @@ gdbscm_lazy_string_to_value (SCM self)
   SCM ls_scm = lsscm_get_lazy_string_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   lazy_string_smob *ls_smob = (lazy_string_smob *) SCM_SMOB_DATA (ls_scm);
   struct value *value = NULL;
-  volatile struct gdb_exception except;
 
   if (ls_smob->address == 0)
     {
@@ -242,11 +241,15 @@ gdbscm_lazy_string_to_value (SCM self)
 				_("cannot create a value from NULL")));
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       value = value_at_lazy (ls_smob->type, ls_smob->address);
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION (except);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION (except);
+    }
+  END_CATCH
 
   return vlscm_scm_from_value (value);
 }
@@ -268,7 +271,6 @@ lsscm_safe_lazy_string_to_value (SCM string, int arg_pos,
 {
   lazy_string_smob *ls_smob;
   struct value *value = NULL;
-  volatile struct gdb_exception except;
 
   gdb_assert (lsscm_is_lazy_string (string));
 
@@ -283,15 +285,16 @@ lsscm_safe_lazy_string_to_value (SCM string, int arg_pos,
       return NULL;
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       value = value_at_lazy (ls_smob->type, ls_smob->address);
     }
-  if (except.reason < 0)
+  CATCH (except, RETURN_MASK_ALL)
     {
       *except_scmp = gdbscm_scm_from_gdb_exception (except);
       return NULL;
     }
+  END_CATCH
 
   return value;
 }
diff --git a/gdb/guile/scm-math.c b/gdb/guile/scm-math.c
index 7ff37ce..4b6bb5d 100644
--- a/gdb/guile/scm-math.c
+++ b/gdb/guile/scm-math.c
@@ -83,7 +83,6 @@ vlscm_unop (enum valscm_unary_opcode opcode, SCM x, const char *func_name)
   struct value *res_val = NULL;
   SCM except_scm;
   struct cleanup *cleanups;
-  volatile struct gdb_exception except;
 
   cleanups = make_cleanup_value_free_to_mark (value_mark ());
 
@@ -95,7 +94,7 @@ vlscm_unop (enum valscm_unary_opcode opcode, SCM x, const char *func_name)
       gdbscm_throw (except_scm);
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       switch (opcode)
 	{
@@ -128,7 +127,11 @@ vlscm_unop (enum valscm_unary_opcode opcode, SCM x, const char *func_name)
 	  gdb_assert_not_reached ("unsupported operation");
 	}
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups);
+    }
+  END_CATCH
 
   gdb_assert (res_val != NULL);
   result = vlscm_scm_from_value (res_val);
@@ -156,7 +159,6 @@ vlscm_binop (enum valscm_binary_opcode opcode, SCM x, SCM y,
   struct value *res_val = NULL;
   SCM except_scm;
   struct cleanup *cleanups;
-  volatile struct gdb_exception except;
 
   cleanups = make_cleanup_value_free_to_mark (value_mark ());
 
@@ -175,7 +177,7 @@ vlscm_binop (enum valscm_binary_opcode opcode, SCM x, SCM y,
       gdbscm_throw (except_scm);
     }
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       switch (opcode)
 	{
@@ -264,7 +266,11 @@ vlscm_binop (enum valscm_binary_opcode opcode, SCM x, SCM y,
 	  gdb_assert_not_reached ("unsupported operation");
 	}
     }
-  GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups);
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      GDBSCM_HANDLE_GDB_EXCEPTION_WITH_CLEANUPS (except, cleanups);
+    }
+  END_CATCH
 
   gdb_assert (res_val != NULL);
   result = vlscm_scm_from_value (res_val);
@@ -441,7 +447,7 @@ vlscm_rich_compare (int op, SCM x, SCM y, const char *func_name)
   int result = 0;
  [...]

[diff truncated at 100000 bytes]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]