[PATCH 01/12] Introduce is_unavailable_error

Andrew Burgess aburgess@broadcom.com
Mon Aug 12 12:16:00 GMT 2013


Is some places we specifically check for the NOT_AVAILABLE_ERROR error
code, in a later patch I'll be adding a new error for optimized out
values and I'll want to detect both error codes at the same time.

In preparation for this upcoming change I add a new function for
detecting the NOT_AVAILABLE_ERROR code, this is just a refactor.

OK to apply?

Thanks,
Andrew

gdb/ChangeLog

2013-08-08  Andrew Burgess  <aburgess@broadcom.com>

	* exceptions.c (is_unavailable_error): New function definition.
	* exceptions.h (is_unavailable_error): New function declaration.
	* cp-abi.c (baseclass_offset): Switch to use
	is_unavailable_error, and rethrow whatever error we recieved
	rather than a specific error code.
	* amd64-tdep.c (amd64_frame_cache, amd64_sigtramp_frame_cache)
	(amd64_epilogue_frame_cache): Switch to use
	is_unavailable_error.
	* cp-valprint.c (cp_print_value): Likewise.
	* dwarf2-frame.c (dwarf2_frame_cache): Likewise.
	* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Likewise.
	* frame-unwind.c (frame_unwind_find_by_frame): Likewise.
	* frame.c (frame_unwind_pc_if_available)
	(get_frame_address_in_block_if_available): Likewise.
	* i386-tdep.c (i386_frame_cache, i386_epilogue_frame_cache)
	(i386_sigtramp_frame_cache): Likewise.
	* infcmd.c (post_create_inferior): Likewise.
	* p-valprint.c (pascal_object_print_value): Likewise.
	* stack.c (get_frame_language): Likewise.

diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 3ab74f0..71525b8 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -2366,7 +2366,7 @@ amd64_frame_cache (struct frame_info *this_frame,
void **this_cache)
     {
       amd64_frame_cache_1 (this_frame, cache);
     }
-  if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+  if (ex.reason < 0 && !is_unavailable_error (ex.error))
     throw_exception (ex);
    return cache;
@@ -2490,7 +2490,7 @@ amd64_sigtramp_frame_cache (struct frame_info
*this_frame, void **this_cache)
        cache->base_p = 1;
     }
-  if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+  if (ex.reason < 0 && !is_unavailable_error (ex.error))
     throw_exception (ex);
    *this_cache = cache;
@@ -2658,10 +2658,9 @@ amd64_epilogue_frame_cache (struct frame_info
*this_frame, void **this_cache)
        /* The saved %eip will be at cache->base plus 8.  */
       cache->saved_regs[AMD64_RIP_REGNUM] = cache->base + 8;
-
       cache->base_p = 1;
     }
-  if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+  if (ex.reason < 0 && !is_unavailable_error (ex.error))
     throw_exception (ex);
    return cache;
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index 2540eca..fbc68a4 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -85,8 +85,8 @@ baseclass_offset (struct type *type, int index, const
gdb_byte *valaddr,
 						address, val);
     }
 -  if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR)
-    throw_error (NOT_AVAILABLE_ERROR,
+  if (ex.reason < 0 && is_unavailable_error (ex.error))
+    throw_error (ex.error,
 		 _("Cannot determine virtual baseclass offset "
 		   "of incomplete object"));
   else if (ex.reason < 0)
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index e83d979..795b7b0 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -519,7 +519,7 @@ cp_print_value (struct type *type, struct type
*real_type,
 	{
 	  boffset = baseclass_offset (type, i, valaddr, offset, address, val);
 	}
-      if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR)
+      if (ex.reason < 0 && is_unavailable_error (ex.error))
 	skip = -1;
       else if (ex.reason < 0)
 	skip = 1;
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 5c88b03..b709d3b 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1117,7 +1117,7 @@ dwarf2_frame_cache (struct frame_info *this_frame,
void **this_cache)
     }
   if (ex.reason < 0)
     {
-      if (ex.error == NOT_AVAILABLE_ERROR)
+      if (is_unavailable_error (ex.error))
 	{
 	  cache->unavailable_retaddr = 1;
 	  do_cleanups (old_chain);
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 02afcdf..3b843fa 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -2237,7 +2237,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type,
struct frame_info *frame,
     }
   if (ex.reason < 0)
     {
-      if (ex.error == NOT_AVAILABLE_ERROR)
+      if (is_unavailable_error (ex.error))
 	{
 	  do_cleanups (old_chain);
 	  retval = allocate_value (type);
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index c4c1e57..134d918 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -571,3 +571,11 @@ catch_command_errors_const
(catch_command_errors_const_ftype *command,
     return 0;
   return 1;
 }
+
+/* Return true if this is an error indicating a value was unavailable.  */
+
+int
+is_unavailable_error (const enum errors error)
+{
+  return error == NOT_AVAILABLE_ERROR;
+}
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index bf41860..1baecf4 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -101,6 +101,10 @@ struct gdb_exception
   const char *message;
 };
 +/* Return true for those errors relating to value unavailability.  */
+
+extern int is_unavailable_error (enum errors error);
+
 /* A pre-defined non-exception.  */
 extern const struct gdb_exception exception_none;
 diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index ce2f6da..25b1e08 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -112,7 +112,7 @@ frame_unwind_find_by_frame (struct frame_info
*this_frame, void **this_cache)
 	  res = entry->unwinder->sniffer (entry->unwinder, this_frame,
 					  this_cache);
 	}
-      if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR)
+      if (ex.reason < 0 && is_unavailable_error (ex.error))
 	{
 	  /* This usually means that not even the PC is available,
 	     thus most unwinders aren't able to determine if they're
diff --git a/gdb/frame.c b/gdb/frame.c
index d52c26a..54f828c 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -721,7 +721,7 @@ frame_unwind_pc_if_available (struct frame_info
*this_frame, CORE_ADDR *pc)
 	    {
 	      pc = gdbarch_unwind_pc (prev_gdbarch, this_frame);
 	    }
-	  if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR)
+	  if (ex.reason < 0 && is_unavailable_error (ex.error))
 	    {
 	      this_frame->prev_pc.p = -1;
 @@ -2064,7 +2064,7 @@ get_frame_pc_if_available (struct frame_info
*frame, CORE_ADDR *pc)
     }
   if (ex.reason < 0)
     {
-      if (ex.error == NOT_AVAILABLE_ERROR)
+      if (is_unavailable_error (ex.error))
 	return 0;
       else
 	throw_exception (ex);
@@ -2145,7 +2145,7 @@ get_frame_address_in_block_if_available (struct
frame_info *this_frame,
     {
       *pc = get_frame_address_in_block (this_frame);
     }
-  if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR)
+  if (ex.reason < 0 && is_unavailable_error (ex.error))
     return 0;
   else if (ex.reason < 0)
     throw_exception (ex);
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index b159b49..1c9fa68 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -1834,7 +1834,7 @@ i386_frame_cache (struct frame_info *this_frame,
void **this_cache)
     {
       i386_frame_cache_1 (this_frame, cache);
     }
-  if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+  if (ex.reason < 0 && !is_unavailable_error (ex.error))
     throw_exception (ex);
    return cache;
@@ -2004,7 +2004,7 @@ i386_epilogue_frame_cache (struct frame_info
*this_frame, void **this_cache)
        cache->base_p = 1;
     }
-  if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+  if (ex.reason < 0 && !is_unavailable_error (ex.error))
     throw_exception (ex);
    return cache;
@@ -2197,7 +2197,7 @@ i386_sigtramp_frame_cache (struct frame_info
*this_frame, void **this_cache)
        cache->base_p = 1;
     }
-  if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+  if (ex.reason < 0 && !is_unavailable_error (ex.error))
     throw_exception (ex);
    *this_cache = cache;
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 154cde2..ed9ec5e 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -422,7 +422,7 @@ post_create_inferior (struct target_ops *target, int
from_tty)
     {
       stop_pc = regcache_read_pc (get_current_regcache ());
     }
-  if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
+  if (ex.reason < 0 && !is_unavailable_error (ex.error))
     throw_exception (ex);
    if (exec_bfd)
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 05d4c6f..cfafe99 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -754,7 +754,7 @@ pascal_object_print_value (struct type *type, const
gdb_byte *valaddr,
 	{
 	  boffset = baseclass_offset (type, i, valaddr, offset, address, val);
 	}
-      if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR)
+      if (ex.reason < 0 && is_unavailable_error (ex.error))
 	skip = -1;
       else if (ex.reason < 0)
 	skip = 1;
diff --git a/gdb/stack.c b/gdb/stack.c
index 7d97dc8..af05f84 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2558,7 +2558,7 @@ get_frame_language (void)
 	}
       if (ex.reason < 0)
 	{
-	  if (ex.error != NOT_AVAILABLE_ERROR)
+	  if (!is_unavailable_error (ex.error))
 	    throw_exception (ex);
 	}
       else




More information about the Gdb-patches mailing list