Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Andrew Burgess" <aburgess@broadcom.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 04/12] Introduce OPTIMIZED_OUT_ERROR.
Date: Mon, 12 Aug 2013 12:22:00 -0000	[thread overview]
Message-ID: <5208D35C.2040402@broadcom.com> (raw)
In-Reply-To: <5208D1DF.1090201@broadcom.com>

We already have a NOT_AVAILABLE_ERROR, this patch adds
an OPTIMIZED_OUT_ERROR.

It is not clear to me if the original intention of the
NOT_AVAILABLE_ERROR was to cover all reasons why a value
is missing, but from how it is currently used the
NOT_AVAILABLE_ERROR is for specifically the case where
a value is unavailable.   So, in order to catch the
optimized out errors just like we catch the unavailable
errors, I've added a new error code, and throw it in
various places.

OK to apply?

Thanks,
Andrew

gdb/ChangeLog

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

	* exceptions.h (errors): Add OPTIMIZED_OUT_ERROR.
	* exceptions.c (is_unavailable_error): Check for
	OPTIMIZED_OUT_ERROR.
	* dwarf2loc.c (write_pieced_value): Throw OPTIMIZED_OUT_ERROR.
	* frame.c (frame_unwind_pc_if_available): Display correct string
	for optimized out or unavailable values.
	(frame_unwind_register): Throw OPTIMIZED_OUT_ERROR.
	* spu-tdep.c (spu_software_single_step): Throw
	OPTIMIZED_OUT_ERROR.
	* valops.c (value_assign): Throw OPTIMIZED_OUT_ERROR.

diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 36b80fb..bae425a 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -1880,9 +1880,10 @@ write_pieced_value (struct value *to, struct
value *from)
 						   &optim, &unavail))
 		      {
 			if (optim)
-			  error (_("Can't do read-modify-write to "
-				   "update bitfield; containing word has been "
-				   "optimized out"));
+			  throw_error (OPTIMIZED_OUT_ERROR,
+				       _("Can't do read-modify-write to "
+					 "update bitfield; containing word "
+					 "has been optimized out"));
 			if (unavail)
 			  throw_error (NOT_AVAILABLE_ERROR,
 				       _("Can't do read-modify-write to update "
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index 134d918..c6248bc 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -577,5 +577,6 @@ catch_command_errors_const
(catch_command_errors_const_ftype *command,
 int
 is_unavailable_error (const enum errors error)
 {
-  return error == NOT_AVAILABLE_ERROR;
+  return (error == NOT_AVAILABLE_ERROR
+	  || error == OPTIMIZED_OUT_ERROR);
 }
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index 1baecf4..f2cc528 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -79,9 +79,9 @@ enum errors {
   /* Feature is not supported in this copy of GDB.  */
   UNSUPPORTED_ERROR,
 -  /* Value not available.  E.g., a register was not collected in a
-     traceframe.  */
-  NOT_AVAILABLE_ERROR,
+  /* Value not available.  */
+  NOT_AVAILABLE_ERROR, /* Not collected, e.g. in a traceframe.  */
+  OPTIMIZED_OUT_ERROR, /* Optimized out by compiler or ABI.  */
    /* DW_OP_GNU_entry_value resolving failed.  */
   NO_ENTRY_VALUE_ERROR,
diff --git a/gdb/frame.c b/gdb/frame.c
index 54f828c..f825f96 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -728,8 +728,11 @@ frame_unwind_pc_if_available (struct frame_info
*this_frame, CORE_ADDR *pc)
 	      if (frame_debug)
 		fprintf_unfiltered (gdb_stdlog,
 				    "{ frame_unwind_pc (this_frame=%d)"
-				    " -> <unavailable> }\n",
-				    this_frame->level);
+				    " -> %s }\n",
+				    this_frame->level,
+				    (ex.error == NOT_AVAILABLE_ERROR
+				     ? "<unavailable>"
+				     : "<optimized out>"));
 	    }
 	  else if (ex.reason < 0)
 	    {
@@ -988,7 +991,8 @@ frame_unwind_register (struct frame_info *frame, int
regnum, gdb_byte *buf)
 			 &lval, &addr, &realnum, buf);
    if (optimized)
-    error (_("Register %d was optimized out"), regnum);
+    throw_error (OPTIMIZED_OUT_ERROR,
+		 _("Register %d was optimized out"), regnum);
   if (unavailable)
     throw_error (NOT_AVAILABLE_ERROR,
 		 _("Register %d is not available"), regnum);
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 46f3e2c..6fa3e7e 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -1614,8 +1614,9 @@ spu_software_single_step (struct frame_info *frame)
 	  else
 	    {
 	      if (optim)
-		error (_("Could not determine address of "
-			 "single-step breakpoint."));
+		throw_error (OPTIMIZED_OUT_ERROR,
+			     _("Could not determine address of "
+			       "single-step breakpoint."));
 	      if (unavail)
 		throw_error (NOT_AVAILABLE_ERROR,
 			     _("Could not determine address of "
diff --git a/gdb/valops.c b/gdb/valops.c
index f86b283..48dbeaa 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1188,7 +1188,8 @@ value_assign (struct value *toval, struct value
*fromval)
 					       &optim, &unavail))
 		  {
 		    if (optim)
-		      error (_("value has been optimized out"));
+		      throw_error (OPTIMIZED_OUT_ERROR,
+				   _("value has been optimized out"));
 		    if (unavail)
 		      throw_error (NOT_AVAILABLE_ERROR,
 				   _("value is not available"));



  parent reply	other threads:[~2013-08-12 12:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-12 12:15 [RFC 00/12] Merge value optimized_out and unavailable Andrew Burgess
2013-08-12 12:16 ` [PATCH 01/12] Introduce is_unavailable_error Andrew Burgess
2013-08-12 12:18 ` [PATCH 02/12]: Remove set_value_optimized_out Andrew Burgess
2013-08-12 12:20 ` [PATCH 03/12] Mark optimized out values as non-lazy Andrew Burgess
2013-11-26 16:38   ` Pedro Alves
2013-11-26 19:19     ` Andrew Burgess
2013-08-12 12:22 ` Andrew Burgess [this message]
2013-08-12 12:24 ` [PATCH 05/12] Convert the unavailable to be bit based Andrew Burgess
2013-08-12 12:27 ` [PATCH 06/12] Delete value_bits_valid Andrew Burgess
2013-11-25 21:41   ` [PATCH] Print entirely unavailable struct/union values as a single <unavailable>. (Re: [PATCH 06/12] Delete value_bits_valid.) Pedro Alves
2013-11-26 10:13     ` Andrew Burgess
2013-11-28 20:14       ` Pedro Alves
2013-08-12 12:28 ` [PATCH 07/12] Generic print unavailable or optimized out function Andrew Burgess
2013-08-12 12:29 ` [PATCH 08/12] Replace some value_optimized_out with value_entirely_available Andrew Burgess
2013-11-27 17:52   ` [COMMITTED PATCH 0/2] "set debug frame 1" and not saved registers (was: Re: [PATCH 08/12] Replace some value_optimized_out with value_entirely_available) Pedro Alves
2013-11-27 18:14     ` [PATCH 1/2] Make "set debug frame 1" use the standard print routine for optimized out values Pedro Alves
2013-11-27 18:35     ` [PATCH 2/2] Make "set debug frame 1" output print <not saved> instead of <optimized out> Pedro Alves
2013-11-27 18:41       ` Pedro Alves
2013-11-27 18:53         ` [pushed] Fix type of not saved registers. (was: Re: [PATCH 2/2] Make "set debug frame 1" output print <not saved> instead of <optimized out>.) Pedro Alves
2013-08-12 12:30 ` [PATCH 09/12] DWARF value, mark unavailable in bits not bytes Andrew Burgess
2013-08-12 12:31 ` [PATCH 10/12] Merge optimized_out into unavailable vector Andrew Burgess
2013-08-12 12:32 ` [PATCH 11/12] Add test mechanism for value " Andrew Burgess
2013-08-12 12:33 ` [PATCH 12/12] Remove old lval check valid functions Andrew Burgess
2013-08-29 17:21 ` PING: Re: [RFC 00/12] Merge value optimized_out and unavailable Andrew Burgess
2013-11-12  9:37   ` Andrew Burgess
2013-11-29 22:31 ` Pedro Alves
2013-12-04 14:54   ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5208D35C.2040402@broadcom.com \
    --to=aburgess@broadcom.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox