This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 04/12] Introduce OPTIMIZED_OUT_ERROR.
- From: "Andrew Burgess" <aburgess at broadcom dot com>
- To: gdb-patches at sourceware dot org
- Date: Mon, 12 Aug 2013 13:21:48 +0100
- Subject: [PATCH 04/12] Introduce OPTIMIZED_OUT_ERROR.
- References: <5208D1DF dot 1090201 at broadcom dot 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"));