diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2022-09-29 15:13:09 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2022-09-29 16:42:34 -0400 |
commit | 3fe639b81b452b79460a8527aa57011f1c42ec8b (patch) | |
tree | 21ac377df7dfa287c46d00b11045fdb1b0fa8388 /gdb | |
parent | 31282a849107d95d3cfe115ba160f976dd99844c (diff) | |
download | gdb-3fe639b81b452b79460a8527aa57011f1c42ec8b.zip gdb-3fe639b81b452b79460a8527aa57011f1c42ec8b.tar.gz gdb-3fe639b81b452b79460a8527aa57011f1c42ec8b.tar.bz2 |
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
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/auxv.c | 26 | ||||
-rw-r--r-- | gdb/auxv.h | 10 | ||||
-rw-r--r-- | gdb/gdbarch-components.py | 4 | ||||
-rw-r--r-- | gdb/gdbarch-gen.h | 4 | ||||
-rw-r--r-- | gdb/gdbarch.c | 2 | ||||
-rw-r--r-- | gdb/ppc-linux-nat.c | 10 | ||||
-rw-r--r-- | gdb/s390-linux-nat.c | 10 | ||||
-rw-r--r-- | gdb/target-debug.h | 2 | ||||
-rw-r--r-- | gdb/target-delegates.c | 14 | ||||
-rw-r--r-- | gdb/target.h | 4 |
10 files changed, 43 insertions, 43 deletions
@@ -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) @@ -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. diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py index ad71bf7..6374240 100644 --- a/gdb/gdbarch-components.py +++ b/gdb/gdbarch-components.py @@ -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"), ], diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index c7a2470..706dbb3 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -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 diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 18d46a3..be73d39 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -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); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index b089fcc..dfa81e1 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -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; diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c index 73961c8..2b21e08 100644 --- a/gdb/s390-linux-nat.c +++ b/gdb/s390-linux-nat.c @@ -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; diff --git a/gdb/target-debug.h b/gdb/target-debug.h index ab89c0a..77033f0 100644 --- a/gdb/target-debug.h +++ b/gdb/target-debug.h @@ -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)) diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index b6628c4..daf4682 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -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); diff --git a/gdb/target.h b/gdb/target.h index 8e13ada..28aa927 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -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 |