gdb: constify auxv parse functions
Constify the input parameters of the various auxv parse functions, they don't need to modify the raw auxv data. Change-Id: I13eacd5ab8e925ec2b5c1f7722cbab39c41516ec
This commit is contained in:
parent
31282a8491
commit
3fe639b81b
26
gdb/auxv.c
26
gdb/auxv.c
@ -250,14 +250,14 @@ memory_xfer_auxv (struct target_ops *ops,
|
||||
the auxv type field as a parameter. */
|
||||
|
||||
static int
|
||||
generic_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp,
|
||||
generic_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp,
|
||||
int sizeof_auxv_type)
|
||||
{
|
||||
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
|
||||
const int sizeof_auxv_val = ptr_type->length ();
|
||||
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
||||
gdb_byte *ptr = *readptr;
|
||||
const gdb_byte *ptr = *readptr;
|
||||
|
||||
if (endptr == ptr)
|
||||
return 0;
|
||||
@ -281,8 +281,8 @@ generic_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
|
||||
/* See auxv.h. */
|
||||
|
||||
int
|
||||
default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
default_auxv_parse (struct target_ops *ops, const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
{
|
||||
struct gdbarch *gdbarch = target_gdbarch ();
|
||||
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
|
||||
@ -295,8 +295,8 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
|
||||
/* See auxv.h. */
|
||||
|
||||
int
|
||||
svr4_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
{
|
||||
struct type *int_type = builtin_type (gdbarch)->builtin_int;
|
||||
const int sizeof_auxv_type = int_type->length ();
|
||||
@ -310,8 +310,8 @@ svr4_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
|
||||
Return -1 if there is insufficient buffer for a whole entry.
|
||||
Return 1 if an entry was read into *TYPEP and *VALP. */
|
||||
int
|
||||
target_auxv_parse (gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
target_auxv_parse (const gdb_byte **readptr, const gdb_byte *endptr,
|
||||
CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
{
|
||||
struct gdbarch *gdbarch = target_gdbarch();
|
||||
|
||||
@ -383,8 +383,8 @@ target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp)
|
||||
if (!info->data)
|
||||
return -1;
|
||||
|
||||
gdb_byte *data = info->data->data ();
|
||||
gdb_byte *ptr = data;
|
||||
const gdb_byte *data = info->data->data ();
|
||||
const gdb_byte *ptr = data;
|
||||
size_t len = info->data->size ();
|
||||
|
||||
while (1)
|
||||
@ -557,8 +557,8 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
|
||||
if (!info->data)
|
||||
return -1;
|
||||
|
||||
gdb_byte *data = info->data->data ();
|
||||
gdb_byte *ptr = data;
|
||||
const gdb_byte *data = info->data->data ();
|
||||
const gdb_byte *ptr = data;
|
||||
size_t len = info->data->size ();
|
||||
|
||||
while (target_auxv_parse (&ptr, data + len, &type, &val) > 0)
|
||||
|
10
gdb/auxv.h
10
gdb/auxv.h
@ -31,8 +31,8 @@
|
||||
Return 0 if *READPTR is already at the end of the buffer.
|
||||
Return -1 if there is insufficient buffer for a whole entry.
|
||||
Return 1 if an entry was read into *TYPEP and *VALP. */
|
||||
extern int default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep,
|
||||
extern int default_auxv_parse (struct target_ops *ops, const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep,
|
||||
CORE_ADDR *valp);
|
||||
|
||||
/* The SVR4 psABI implementation of to_auxv_parse, that uses an int to
|
||||
@ -42,15 +42,15 @@ extern int default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
|
||||
Return 0 if *READPTR is already at the end of the buffer.
|
||||
Return -1 if there is insufficient buffer for a whole entry.
|
||||
Return 1 if an entry was read into *TYPEP and *VALP. */
|
||||
extern int svr4_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep,
|
||||
extern int svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep,
|
||||
CORE_ADDR *valp);
|
||||
|
||||
/* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
|
||||
Return 0 if *READPTR is already at the end of the buffer.
|
||||
Return -1 if there is insufficient buffer for a whole entry.
|
||||
Return 1 if an entry was read into *TYPEP and *VALP. */
|
||||
extern int target_auxv_parse (gdb_byte **readptr, gdb_byte *endptr,
|
||||
extern int target_auxv_parse (const gdb_byte **readptr, const gdb_byte *endptr,
|
||||
CORE_ADDR *typep, CORE_ADDR *valp);
|
||||
|
||||
/* Extract the auxiliary vector entry with a_type matching MATCH.
|
||||
|
@ -2492,8 +2492,8 @@ Return 1 if an entry was read into *TYPEP and *VALP.
|
||||
type="int",
|
||||
name="auxv_parse",
|
||||
params=[
|
||||
("gdb_byte **", "readptr"),
|
||||
("gdb_byte *", "endptr"),
|
||||
("const gdb_byte **", "readptr"),
|
||||
("const gdb_byte *", "endptr"),
|
||||
("CORE_ADDR *", "typep"),
|
||||
("CORE_ADDR *", "valp"),
|
||||
],
|
||||
|
@ -1539,8 +1539,8 @@ extern void set_gdbarch_program_breakpoint_here_p (struct gdbarch *gdbarch, gdba
|
||||
|
||||
extern bool gdbarch_auxv_parse_p (struct gdbarch *gdbarch);
|
||||
|
||||
typedef int (gdbarch_auxv_parse_ftype) (struct gdbarch *gdbarch, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
|
||||
extern int gdbarch_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
|
||||
typedef int (gdbarch_auxv_parse_ftype) (struct gdbarch *gdbarch, const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
|
||||
extern int gdbarch_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp);
|
||||
extern void set_gdbarch_auxv_parse (struct gdbarch *gdbarch, gdbarch_auxv_parse_ftype *auxv_parse);
|
||||
|
||||
/* Print the description of a single auxv entry described by TYPE and VAL
|
||||
|
@ -5149,7 +5149,7 @@ gdbarch_auxv_parse_p (struct gdbarch *gdbarch)
|
||||
}
|
||||
|
||||
int
|
||||
gdbarch_auxv_parse (struct gdbarch *gdbarch, gdb_byte **readptr, gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
gdbarch_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
{
|
||||
gdb_assert (gdbarch != NULL);
|
||||
gdb_assert (gdbarch->auxv_parse != NULL);
|
||||
|
@ -530,8 +530,8 @@ struct ppc_linux_nat_target final : public linux_nat_target
|
||||
|
||||
const struct target_desc *read_description () override;
|
||||
|
||||
int auxv_parse (gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
int auxv_parse (const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
override;
|
||||
|
||||
/* Override linux_nat_target low methods. */
|
||||
@ -1915,8 +1915,8 @@ fill_fpregset (const struct regcache *regcache,
|
||||
}
|
||||
|
||||
int
|
||||
ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep,
|
||||
ppc_linux_nat_target::auxv_parse (const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep,
|
||||
CORE_ADDR *valp)
|
||||
{
|
||||
int tid = inferior_ptid.lwp ();
|
||||
@ -1926,7 +1926,7 @@ ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
|
||||
int sizeof_auxv_field = ppc_linux_target_wordsize (tid);
|
||||
|
||||
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
|
||||
gdb_byte *ptr = *readptr;
|
||||
const gdb_byte *ptr = *readptr;
|
||||
|
||||
if (endptr == ptr)
|
||||
return 0;
|
||||
|
@ -132,8 +132,8 @@ public:
|
||||
|
||||
/* Detect target architecture. */
|
||||
const struct target_desc *read_description () override;
|
||||
int auxv_parse (gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
int auxv_parse (const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
override;
|
||||
|
||||
/* Override linux_nat_target low methods. */
|
||||
@ -962,13 +962,13 @@ s390_target_wordsize (void)
|
||||
}
|
||||
|
||||
int
|
||||
s390_linux_nat_target::auxv_parse (gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep,
|
||||
s390_linux_nat_target::auxv_parse (const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep,
|
||||
CORE_ADDR *valp)
|
||||
{
|
||||
int sizeof_auxv_field = s390_target_wordsize ();
|
||||
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
|
||||
gdb_byte *ptr = *readptr;
|
||||
const gdb_byte *ptr = *readptr;
|
||||
|
||||
if (endptr == ptr)
|
||||
return 0;
|
||||
|
@ -76,7 +76,7 @@
|
||||
target_debug_do_print (host_address_to_string (X))
|
||||
#define target_debug_print_gdb_byte_p(X) \
|
||||
target_debug_do_print (host_address_to_string (X))
|
||||
#define target_debug_print_gdb_byte_pp(X) \
|
||||
#define target_debug_print_const_gdb_byte_pp(X) \
|
||||
target_debug_do_print (host_address_to_string (*(X)))
|
||||
#define target_debug_print_enum_gdb_signal(X) \
|
||||
target_debug_do_print (gdb_signal_to_name (X))
|
||||
|
@ -119,7 +119,7 @@ struct dummy_target : public target_ops
|
||||
void flash_done () override;
|
||||
const struct target_desc *read_description () override;
|
||||
ptid_t get_ada_task_ptid (long arg0, ULONGEST arg1) override;
|
||||
int auxv_parse (gdb_byte **arg0, gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3) override;
|
||||
int auxv_parse (const gdb_byte **arg0, const gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3) override;
|
||||
int search_memory (CORE_ADDR arg0, ULONGEST arg1, const gdb_byte *arg2, ULONGEST arg3, CORE_ADDR *arg4) override;
|
||||
bool can_execute_reverse () override;
|
||||
enum exec_direction_kind execution_direction () override;
|
||||
@ -293,7 +293,7 @@ struct debug_target : public target_ops
|
||||
void flash_done () override;
|
||||
const struct target_desc *read_description () override;
|
||||
ptid_t get_ada_task_ptid (long arg0, ULONGEST arg1) override;
|
||||
int auxv_parse (gdb_byte **arg0, gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3) override;
|
||||
int auxv_parse (const gdb_byte **arg0, const gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3) override;
|
||||
int search_memory (CORE_ADDR arg0, ULONGEST arg1, const gdb_byte *arg2, ULONGEST arg3, CORE_ADDR *arg4) override;
|
||||
bool can_execute_reverse () override;
|
||||
enum exec_direction_kind execution_direction () override;
|
||||
@ -2623,27 +2623,27 @@ debug_target::get_ada_task_ptid (long arg0, ULONGEST arg1)
|
||||
}
|
||||
|
||||
int
|
||||
target_ops::auxv_parse (gdb_byte **arg0, gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3)
|
||||
target_ops::auxv_parse (const gdb_byte **arg0, const gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3)
|
||||
{
|
||||
return this->beneath ()->auxv_parse (arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
int
|
||||
dummy_target::auxv_parse (gdb_byte **arg0, gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3)
|
||||
dummy_target::auxv_parse (const gdb_byte **arg0, const gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3)
|
||||
{
|
||||
return default_auxv_parse (this, arg0, arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
int
|
||||
debug_target::auxv_parse (gdb_byte **arg0, gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3)
|
||||
debug_target::auxv_parse (const gdb_byte **arg0, const gdb_byte *arg1, CORE_ADDR *arg2, CORE_ADDR *arg3)
|
||||
{
|
||||
int result;
|
||||
gdb_printf (gdb_stdlog, "-> %s->auxv_parse (...)\n", this->beneath ()->shortname ());
|
||||
result = this->beneath ()->auxv_parse (arg0, arg1, arg2, arg3);
|
||||
gdb_printf (gdb_stdlog, "<- %s->auxv_parse (", this->beneath ()->shortname ());
|
||||
target_debug_print_gdb_byte_pp (arg0);
|
||||
target_debug_print_const_gdb_byte_pp (arg0);
|
||||
gdb_puts (", ", gdb_stdlog);
|
||||
target_debug_print_gdb_byte_p (arg1);
|
||||
target_debug_print_const_gdb_byte_p (arg1);
|
||||
gdb_puts (", ", gdb_stdlog);
|
||||
target_debug_print_CORE_ADDR_p (arg2);
|
||||
gdb_puts (", ", gdb_stdlog);
|
||||
|
@ -862,8 +862,8 @@ struct target_ops
|
||||
Return 0 if *READPTR is already at the end of the buffer.
|
||||
Return -1 if there is insufficient buffer for a whole entry.
|
||||
Return 1 if an entry was read into *TYPEP and *VALP. */
|
||||
virtual int auxv_parse (gdb_byte **readptr,
|
||||
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
virtual int auxv_parse (const gdb_byte **readptr,
|
||||
const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
|
||||
TARGET_DEFAULT_FUNC (default_auxv_parse);
|
||||
|
||||
/* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the
|
||||
|
Loading…
x
Reference in New Issue
Block a user