mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
gdb: change gdbarch_register_to_value to return and take bool
Convert the return value as well as two output parameters. Convert some frame support functions that have the same output parameters as well. Change-Id: I4ed54aa79126b6d0387b550c20382ca21e500f1b Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
parent
21f83ead48
commit
17e0597f73
18 changed files with 76 additions and 74 deletions
|
|
@ -213,10 +213,10 @@ alpha_convert_register_p (struct gdbarch *gdbarch, int regno,
|
|||
&& type->length () == 4);
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
alpha_register_to_value (const frame_info_ptr &frame, int regnum,
|
||||
struct type *valtype, gdb_byte *out,
|
||||
int *optimizedp, int *unavailablep)
|
||||
bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
||||
struct value *value = get_frame_register_value (frame, regnum);
|
||||
|
|
@ -228,7 +228,7 @@ alpha_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
if (*optimizedp || *unavailablep)
|
||||
{
|
||||
release_value (value);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Convert to VALTYPE. */
|
||||
|
|
@ -237,7 +237,7 @@ alpha_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
alpha_sts (gdbarch, out, value->contents_all ().data ());
|
||||
|
||||
release_value (value);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
|
|||
gdbarch *arch = frame_unwind_arch (next_frame);
|
||||
int gdb_regnum = dwarf_reg_to_regnum_or_error (arch, p->v.regno);
|
||||
ULONGEST reg_bits = 8 * register_size (arch, gdb_regnum);
|
||||
int optim, unavail;
|
||||
bool optim, unavail;
|
||||
|
||||
if (p->offset + p->size < reg_bits)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ value_from_register (struct type *type, int regnum, const frame_info_ptr &frame)
|
|||
|
||||
if (gdbarch_convert_register_p (gdbarch, regnum, type1))
|
||||
{
|
||||
int optim, unavail, ok;
|
||||
bool optim, unavail;
|
||||
|
||||
/* The ISA/ABI need to something weird when obtaining the
|
||||
specified value from this register. It might need to
|
||||
|
|
@ -631,9 +631,9 @@ value_from_register (struct type *type, int regnum, const frame_info_ptr &frame)
|
|||
including the location. */
|
||||
v = value::allocate_register (get_next_frame_sentinel_okay (frame),
|
||||
regnum, type);
|
||||
ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
|
||||
v->contents_raw ().data (), &optim,
|
||||
&unavail);
|
||||
bool ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
|
||||
v->contents_raw ().data (), &optim,
|
||||
&unavail);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
|
|
|
|||
23
gdb/frame.c
23
gdb/frame.c
|
|
@ -1219,7 +1219,7 @@ frame_pop (const frame_info_ptr &this_frame)
|
|||
|
||||
void
|
||||
frame_register_unwind (const frame_info_ptr &next_frame, int regnum,
|
||||
int *optimizedp, int *unavailablep,
|
||||
bool *optimizedp, bool *unavailablep,
|
||||
enum lval_type *lvalp, CORE_ADDR *addrp,
|
||||
int *realnump,
|
||||
gdb::array_view<gdb_byte> buffer)
|
||||
|
|
@ -1266,8 +1266,8 @@ void
|
|||
frame_unwind_register (const frame_info_ptr &next_frame, int regnum,
|
||||
gdb::array_view<gdb_byte> buf)
|
||||
{
|
||||
int optimized;
|
||||
int unavailable;
|
||||
bool optimized;
|
||||
bool unavailable;
|
||||
CORE_ADDR addr;
|
||||
int realnum;
|
||||
enum lval_type lval;
|
||||
|
|
@ -1485,8 +1485,8 @@ put_frame_register (const frame_info_ptr &next_frame, int regnum,
|
|||
{
|
||||
gdbarch *gdbarch = frame_unwind_arch (next_frame);
|
||||
int realnum;
|
||||
int optim;
|
||||
int unavail;
|
||||
bool optim;
|
||||
bool unavail;
|
||||
enum lval_type lval;
|
||||
CORE_ADDR addr;
|
||||
int size = register_size (gdbarch, regnum);
|
||||
|
|
@ -1531,8 +1531,8 @@ bool
|
|||
deprecated_frame_register_read (const frame_info_ptr &frame, int regnum,
|
||||
gdb::array_view<gdb_byte> myaddr)
|
||||
{
|
||||
int optimized;
|
||||
int unavailable;
|
||||
bool optimized;
|
||||
bool unavailable;
|
||||
enum lval_type lval;
|
||||
CORE_ADDR addr;
|
||||
int realnum;
|
||||
|
|
@ -1547,7 +1547,7 @@ deprecated_frame_register_read (const frame_info_ptr &frame, int regnum,
|
|||
bool
|
||||
get_frame_register_bytes (const frame_info_ptr &next_frame, int regnum,
|
||||
CORE_ADDR offset, gdb::array_view<gdb_byte> buffer,
|
||||
int *optimizedp, int *unavailablep)
|
||||
bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
gdbarch *gdbarch = frame_unwind_arch (next_frame);
|
||||
|
||||
|
|
@ -2195,7 +2195,7 @@ reinit_frame_cache (void)
|
|||
|
||||
static void
|
||||
frame_register_unwind_location (const frame_info_ptr &initial_this_frame,
|
||||
int regnum, int *optimizedp, lval_type *lvalp,
|
||||
int regnum, bool *optimizedp, lval_type *lvalp,
|
||||
CORE_ADDR *addrp, int *realnump)
|
||||
{
|
||||
gdb_assert (initial_this_frame == nullptr || initial_this_frame->level >= 0);
|
||||
|
|
@ -2203,7 +2203,7 @@ frame_register_unwind_location (const frame_info_ptr &initial_this_frame,
|
|||
frame_info_ptr this_frame = initial_this_frame;
|
||||
while (this_frame != NULL)
|
||||
{
|
||||
int unavailable;
|
||||
bool unavailable;
|
||||
|
||||
frame_register_unwind (this_frame, regnum, optimizedp, &unavailable,
|
||||
lvalp, addrp, realnump);
|
||||
|
|
@ -2467,7 +2467,8 @@ get_prev_frame_always_1 (const frame_info_ptr &this_frame)
|
|||
&& (get_frame_type (frame_info_ptr (this_frame->next)) == NORMAL_FRAME
|
||||
|| get_frame_type (frame_info_ptr (this_frame->next)) == INLINE_FRAME))
|
||||
{
|
||||
int optimized, realnum, nrealnum;
|
||||
bool optimized;
|
||||
int realnum, nrealnum;
|
||||
enum lval_type lval, nlval;
|
||||
CORE_ADDR addr, naddr;
|
||||
|
||||
|
|
|
|||
|
|
@ -690,7 +690,7 @@ const char *frame_stop_reason_string (const frame_info_ptr &);
|
|||
fetch/compute the value. Instead just return the location of the
|
||||
value. */
|
||||
extern void frame_register_unwind (const frame_info_ptr &frame, int regnum,
|
||||
int *optimizedp, int *unavailablep,
|
||||
bool *optimizedp, bool *unavailablep,
|
||||
enum lval_type *lvalp,
|
||||
CORE_ADDR *addrp, int *realnump,
|
||||
gdb::array_view<gdb_byte> value = {});
|
||||
|
|
@ -741,7 +741,7 @@ extern void put_frame_register (const frame_info_ptr &next_frame, int regnum,
|
|||
extern bool get_frame_register_bytes (const frame_info_ptr &next_frame,
|
||||
int regnum, CORE_ADDR offset,
|
||||
gdb::array_view<gdb_byte> buffer,
|
||||
int *optimizedp, int *unavailablep);
|
||||
bool *optimizedp, bool *unavailablep);
|
||||
|
||||
/* Write bytes from BUFFER to one or multiple registers starting with REGNUM
|
||||
in NEXT_FRAME's previous frame, starting at OFFSET. */
|
||||
|
|
|
|||
|
|
@ -2374,8 +2374,8 @@ set_gdbarch_convert_register_p (struct gdbarch *gdbarch,
|
|||
gdbarch->convert_register_p = convert_register_p;
|
||||
}
|
||||
|
||||
int
|
||||
gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep)
|
||||
bool
|
||||
gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
gdb_assert (gdbarch != NULL);
|
||||
gdb_assert (gdbarch->register_to_value != NULL);
|
||||
|
|
|
|||
|
|
@ -389,8 +389,8 @@ typedef bool (gdbarch_convert_register_p_ftype) (struct gdbarch *gdbarch, int re
|
|||
extern bool gdbarch_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type);
|
||||
extern void set_gdbarch_convert_register_p (struct gdbarch *gdbarch, gdbarch_convert_register_p_ftype *convert_register_p);
|
||||
|
||||
typedef int (gdbarch_register_to_value_ftype) (const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
|
||||
extern int gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
|
||||
typedef bool (gdbarch_register_to_value_ftype) (const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, bool *optimizedp, bool *unavailablep);
|
||||
extern bool gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, bool *optimizedp, bool *unavailablep);
|
||||
extern void set_gdbarch_register_to_value (struct gdbarch *gdbarch, gdbarch_register_to_value_ftype *register_to_value);
|
||||
|
||||
typedef void (gdbarch_value_to_register_ftype) (const frame_info_ptr &frame, int regnum, struct type *type, const gdb_byte *buf);
|
||||
|
|
|
|||
|
|
@ -100,13 +100,14 @@ register_to_value_test (struct gdbarch *gdbarch)
|
|||
|
||||
/* Allocate two bytes more for overflow check. */
|
||||
std::vector<gdb_byte> buf (type->length () + 2, 0);
|
||||
int optim, unavail, ok;
|
||||
bool optim, unavail;
|
||||
|
||||
/* Set the fingerprint in the last two bytes. */
|
||||
buf [type->length ()]= 'w';
|
||||
buf [type->length () + 1]= 'l';
|
||||
ok = gdbarch_register_to_value (gdbarch, frame, regnum, type,
|
||||
buf.data (), &optim, &unavail);
|
||||
bool ok = gdbarch_register_to_value (gdbarch, frame, regnum,
|
||||
type, buf.data (), &optim,
|
||||
&unavail);
|
||||
|
||||
SELF_CHECK (ok);
|
||||
SELF_CHECK (!optim);
|
||||
|
|
|
|||
|
|
@ -747,15 +747,15 @@ Method(
|
|||
)
|
||||
|
||||
Function(
|
||||
type="int",
|
||||
type="bool",
|
||||
name="register_to_value",
|
||||
params=[
|
||||
("const frame_info_ptr &", "frame"),
|
||||
("int", "regnum"),
|
||||
("struct type *", "type"),
|
||||
("gdb_byte *", "buf"),
|
||||
("int *", "optimizedp"),
|
||||
("int *", "unavailablep"),
|
||||
("bool *", "optimizedp"),
|
||||
("bool *", "unavailablep"),
|
||||
],
|
||||
invalid=False,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3540,10 +3540,10 @@ i386_convert_register_p (struct gdbarch *gdbarch,
|
|||
/* Read a value of type TYPE from register REGNUM in frame FRAME, and
|
||||
return its contents in TO. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
i386_register_to_value (const frame_info_ptr &frame, int regnum,
|
||||
struct type *type, gdb_byte *to,
|
||||
int *optimizedp, int *unavailablep)
|
||||
bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
||||
int len = type->length ();
|
||||
|
|
@ -3566,15 +3566,15 @@ i386_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
|
||||
if (!get_frame_register_bytes (next_frame, regnum, 0, to_view,
|
||||
optimizedp, unavailablep))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
regnum = i386_next_regnum (regnum);
|
||||
len -= 4;
|
||||
to += 4;
|
||||
}
|
||||
|
||||
*optimizedp = *unavailablep = 0;
|
||||
return 1;
|
||||
*optimizedp = *unavailablep = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Write the contents FROM of a value of type TYPE into register
|
||||
|
|
|
|||
|
|
@ -344,10 +344,10 @@ i387_convert_register_p (struct gdbarch *gdbarch, int regnum,
|
|||
/* Read a value of type TYPE from register REGNUM in frame FRAME, and
|
||||
return its contents in TO. */
|
||||
|
||||
int
|
||||
bool
|
||||
i387_register_to_value (const frame_info_ptr &frame, int regnum,
|
||||
struct type *type, gdb_byte *to,
|
||||
int *optimizedp, int *unavailablep)
|
||||
bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
||||
gdb_byte from[I386_MAX_REGISTER_SIZE];
|
||||
|
|
@ -359,8 +359,8 @@ i387_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
{
|
||||
warning (_("Cannot convert floating-point register value "
|
||||
"to non-floating-point type."));
|
||||
*optimizedp = *unavailablep = 0;
|
||||
return 0;
|
||||
*optimizedp = *unavailablep = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Convert to TYPE. */
|
||||
|
|
@ -369,11 +369,11 @@ i387_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
|
||||
if (!get_frame_register_bytes (next_frame, regnum, 0, from_view, optimizedp,
|
||||
unavailablep))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
target_float_convert (from, i387_ext_type (gdbarch), to, type);
|
||||
*optimizedp = *unavailablep = 0;
|
||||
return 1;
|
||||
*optimizedp = *unavailablep = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Write the contents FROM of a value of type TYPE into register
|
||||
|
|
|
|||
|
|
@ -94,9 +94,9 @@ extern bool i387_convert_register_p (struct gdbarch *gdbarch, int regnum,
|
|||
/* Read a value of type TYPE from register REGNUM in frame FRAME, and
|
||||
return its contents in TO. */
|
||||
|
||||
extern int i387_register_to_value (const frame_info_ptr &frame, int regnum,
|
||||
struct type *type, gdb_byte *to,
|
||||
int *optimizedp, int *unavailablep);
|
||||
extern bool i387_register_to_value (const frame_info_ptr &frame, int regnum,
|
||||
struct type *type, gdb_byte *to,
|
||||
bool *optimizedp, bool *unavailablep);
|
||||
|
||||
/* Write the contents FROM of a value of type TYPE into register
|
||||
REGNUM in frame FRAME. */
|
||||
|
|
|
|||
|
|
@ -1218,10 +1218,10 @@ ia64_convert_register_p (struct gdbarch *gdbarch, int regno, struct type *type)
|
|||
&& type != ia64_ext_type (gdbarch));
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
ia64_register_to_value (const frame_info_ptr &frame, int regnum,
|
||||
struct type *valtype, gdb_byte *out,
|
||||
int *optimizedp, int *unavailablep)
|
||||
bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
||||
gdb_byte in[IA64_FP_REGISTER_SIZE];
|
||||
|
|
@ -1231,11 +1231,11 @@ ia64_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
|
||||
if (!get_frame_register_bytes (next_frame, regnum, 0, in_view, optimizedp,
|
||||
unavailablep))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
target_float_convert (in, ia64_ext_type (gdbarch), out, valtype);
|
||||
*optimizedp = *unavailablep = 0;
|
||||
return 1;
|
||||
*optimizedp = *unavailablep = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -204,10 +204,10 @@ m68k_convert_register_p (struct gdbarch *gdbarch,
|
|||
/* Read a value of type TYPE from register REGNUM in frame FRAME, and
|
||||
return its contents in TO. */
|
||||
|
||||
static int
|
||||
static bool
|
||||
m68k_register_to_value (const frame_info_ptr &frame, int regnum,
|
||||
struct type *type, gdb_byte *to,
|
||||
int *optimizedp, int *unavailablep)
|
||||
bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
||||
gdb_byte from[M68K_MAX_REGISTER_SIZE];
|
||||
|
|
@ -221,11 +221,11 @@ m68k_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
|
||||
if (!get_frame_register_bytes (next_frame, regnum, 0, from_view, optimizedp,
|
||||
unavailablep))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
target_float_convert (from, fpreg_type, to, type);
|
||||
*optimizedp = *unavailablep = 0;
|
||||
return 1;
|
||||
*optimizedp = *unavailablep = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Write the contents FROM of a value of type TYPE into register
|
||||
|
|
|
|||
|
|
@ -938,10 +938,10 @@ mips_convert_register_p (struct gdbarch *gdbarch,
|
|||
|| mips_convert_register_gpreg_case_p (gdbarch, regnum, type));
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
mips_register_to_value (const frame_info_ptr &frame, int regnum,
|
||||
struct type *type, gdb_byte *to,
|
||||
int *optimizedp, int *unavailablep)
|
||||
bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
||||
frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
|
||||
|
|
@ -956,13 +956,13 @@ mips_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
|
||||
if (!get_frame_register_bytes (next_frame, regnum + 0, 0, second_half,
|
||||
optimizedp, unavailablep))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (!get_frame_register_bytes (next_frame, regnum + 1, 0, first_half,
|
||||
optimizedp, unavailablep))
|
||||
return 0;
|
||||
*optimizedp = *unavailablep = 0;
|
||||
return 1;
|
||||
return false;
|
||||
*optimizedp = *unavailablep = false;
|
||||
return true;
|
||||
}
|
||||
else if (mips_convert_register_gpreg_case_p (gdbarch, regnum, type))
|
||||
{
|
||||
|
|
@ -972,10 +972,10 @@ mips_register_to_value (const frame_info_ptr &frame, int regnum,
|
|||
offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 8 - len : 0;
|
||||
if (!get_frame_register_bytes (next_frame, regnum, offset, { to, len },
|
||||
optimizedp, unavailablep))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
*optimizedp = *unavailablep = 0;
|
||||
return 1;
|
||||
*optimizedp = *unavailablep = false;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2691,12 +2691,12 @@ ieee_128_float_regnum_adjust (struct gdbarch *gdbarch, struct type *type,
|
|||
return regnum;
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
rs6000_register_to_value (const frame_info_ptr &frame,
|
||||
int regnum,
|
||||
struct type *type,
|
||||
gdb_byte *to,
|
||||
int *optimizedp, int *unavailablep)
|
||||
bool *optimizedp, bool *unavailablep)
|
||||
{
|
||||
struct gdbarch *gdbarch = get_frame_arch (frame);
|
||||
gdb_byte from[PPC_MAX_REGISTER_SIZE];
|
||||
|
|
@ -2712,12 +2712,12 @@ rs6000_register_to_value (const frame_info_ptr &frame,
|
|||
frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
|
||||
if (!get_frame_register_bytes (next_frame, regnum, 0, from_view, optimizedp,
|
||||
unavailablep))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
target_float_convert (from, builtin_type (gdbarch)->builtin_double,
|
||||
to, type);
|
||||
*optimizedp = *unavailablep = 0;
|
||||
return 1;
|
||||
*optimizedp = *unavailablep = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -1723,8 +1723,8 @@ info_frame_command_core (const frame_info_ptr &fi, bool selected_frame_p)
|
|||
&& gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
|
||||
{
|
||||
enum lval_type lval;
|
||||
int optimized;
|
||||
int unavailable;
|
||||
bool optimized;
|
||||
bool unavailable;
|
||||
CORE_ADDR addr;
|
||||
int realnum;
|
||||
|
||||
|
|
|
|||
|
|
@ -1207,7 +1207,7 @@ value_assign (struct value *toval, struct value *fromval)
|
|||
LONGEST offset = parent->offset () + toval->offset ();
|
||||
size_t changed_len;
|
||||
gdb_byte buffer[sizeof (LONGEST)];
|
||||
int optim, unavail;
|
||||
bool optim, unavail;
|
||||
|
||||
changed_len = (toval->bitpos ()
|
||||
+ toval->bitsize ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue