From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 413943858CDB; Thu, 29 Sep 2022 23:57:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 413943858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664495843; bh=iEd8n99uWgc4dy6dB4ZDvRmXHeSXFCoXS3zdu0OVQ4w=; h=From:To:Subject:Date:From; b=LoGAPzKgPe2a7lXj7iYypR3zus92CjI5q99dQzMF2cp4WOFdzWa1o5rQ70il88NHB iftKqzJRewWufJPNR6bzjDne8cAga90O1YucuUL8QWJ6lfwumqgqXnrefX4ddXgdHK qBs2eI5lRxGfjIMG1txWG15k+Nn+8B3Bnme/Ug4M= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: constify auxv parse functions X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 31282a849107d95d3cfe115ba160f976dd99844c X-Git-Newrev: 3fe639b81b452b79460a8527aa57011f1c42ec8b Message-Id: <20220929235723.413943858CDB@sourceware.org> Date: Thu, 29 Sep 2022 23:57:23 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3fe639b81b45= 2b79460a8527aa57011f1c42ec8b commit 3fe639b81b452b79460a8527aa57011f1c42ec8b Author: Simon Marchi Date: Thu Sep 29 15:13:09 2022 -0400 gdb: constify auxv parse functions =20 Constify the input parameters of the various auxv parse functions, they don't need to modify the raw auxv data. =20 Change-Id: I13eacd5ab8e925ec2b5c1f7722cbab39c41516ec Diff: --- gdb/auxv.c | 26 +++++++++++++------------- gdb/auxv.h | 10 +++++----- gdb/gdbarch-components.py | 4 ++-- gdb/gdbarch-gen.h | 4 ++-- gdb/gdbarch.c | 2 +- gdb/ppc-linux-nat.c | 10 +++++----- gdb/s390-linux-nat.c | 10 +++++----- gdb/target-debug.h | 2 +- gdb/target-delegates.c | 14 +++++++------- gdb/target.h | 4 ++-- 10 files changed, 43 insertions(+), 43 deletions(-) diff --git a/gdb/auxv.c b/gdb/auxv.c index b248f997f1c..63ee01c333c 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -250,14 +250,14 @@ memory_xfer_auxv (struct target_ops *ops, the auxv type field as a parameter. */ =20 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 =3D builtin_type (gdbarch)->builtin_data_ptr; const int sizeof_auxv_val =3D ptr_type->length (); enum bfd_endian byte_order =3D gdbarch_byte_order (gdbarch); - gdb_byte *ptr =3D *readptr; + const gdb_byte *ptr =3D *readptr; =20 if (endptr =3D=3D ptr) return 0; @@ -281,8 +281,8 @@ generic_auxv_parse (struct gdbarch *gdbarch, gdb_byte *= *readptr, /* See auxv.h. */ =20 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 =3D target_gdbarch (); struct type *ptr_type =3D builtin_type (gdbarch)->builtin_data_ptr; @@ -295,8 +295,8 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **= readptr, /* See auxv.h. */ =20 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 =3D builtin_type (gdbarch)->builtin_int; const int sizeof_auxv_type =3D int_type->length (); @@ -310,8 +310,8 @@ svr4_auxv_parse (struct gdbarch *gdbarch, gdb_byte **re= adptr, 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 =3D target_gdbarch(); =20 @@ -383,8 +383,8 @@ target_auxv_search (struct target_ops *ops, CORE_ADDR m= atch, CORE_ADDR *valp) if (!info->data) return -1; =20 - gdb_byte *data =3D info->data->data (); - gdb_byte *ptr =3D data; + const gdb_byte *data =3D info->data->data (); + const gdb_byte *ptr =3D data; size_t len =3D info->data->size (); =20 while (1) @@ -557,8 +557,8 @@ fprint_target_auxv (struct ui_file *file, struct target= _ops *ops) if (!info->data) return -1; =20 - gdb_byte *data =3D info->data->data (); - gdb_byte *ptr =3D data; + const gdb_byte *data =3D info->data->data (); + const gdb_byte *ptr =3D data; size_t len =3D info->data->size (); =20 while (target_auxv_parse (&ptr, data + len, &type, &val) > 0) diff --git a/gdb/auxv.h b/gdb/auxv.h index a4801c34d2f..497318e87a0 100644 --- a/gdb/auxv.h +++ b/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 **re= adptr, + const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp); =20 /* 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 **read= ptr, + const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp); =20 /* Read one auxv entry from *READPTR, not reading locations >=3D 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 *en= dptr, CORE_ADDR *typep, CORE_ADDR *valp); =20 /* Extract the auxiliary vector entry with a_type matching MATCH. diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py index ad71bf754de..6374240ae4b 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=3D"int", name=3D"auxv_parse", params=3D[ - ("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 c7a24704c7c..706dbb3befe 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -1539,8 +1539,8 @@ extern void set_gdbarch_program_breakpoint_here_p (st= ruct gdbarch *gdbarch, gdba =20 extern bool gdbarch_auxv_parse_p (struct gdbarch *gdbarch); =20 -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 **r= eadptr, 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); =20 /* Print the description of a single auxv entry described by TYPE and VAL diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 18d46a39d7a..be73d399069 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -5149,7 +5149,7 @@ gdbarch_auxv_parse_p (struct gdbarch *gdbarch) } =20 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, con= st gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) { gdb_assert (gdbarch !=3D NULL); gdb_assert (gdbarch->auxv_parse !=3D NULL); diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index b089fcc8a5f..dfa81e19a79 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_ta= rget =20 const struct target_desc *read_description () override; =20 - 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; =20 /* Override linux_nat_target low methods. */ @@ -1915,8 +1915,8 @@ fill_fpregset (const struct regcache *regcache, } =20 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 =3D inferior_ptid.lwp (); @@ -1926,7 +1926,7 @@ ppc_linux_nat_target::auxv_parse (gdb_byte **readptr, int sizeof_auxv_field =3D ppc_linux_target_wordsize (tid); =20 enum bfd_endian byte_order =3D gdbarch_byte_order (target_gdbarch ()); - gdb_byte *ptr =3D *readptr; + const gdb_byte *ptr =3D *readptr; =20 if (endptr =3D=3D ptr) return 0; diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c index 73961c87769..2b21e082236 100644 --- a/gdb/s390-linux-nat.c +++ b/gdb/s390-linux-nat.c @@ -132,8 +132,8 @@ public: =20 /* 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; =20 /* Override linux_nat_target low methods. */ @@ -962,13 +962,13 @@ s390_target_wordsize (void) } =20 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 =3D s390_target_wordsize (); enum bfd_endian byte_order =3D gdbarch_byte_order (target_gdbarch ()); - gdb_byte *ptr =3D *readptr; + const gdb_byte *ptr =3D *readptr; =20 if (endptr =3D=3D ptr) return 0; diff --git a/gdb/target-debug.h b/gdb/target-debug.h index ab89c0a5185..77033f00289 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 b6628c4d0be..daf46821be0 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_A= DDR *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_A= DDR *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, ULONGES= T arg1) } =20 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); } =20 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, COR= E_ADDR *arg2, CORE_ADDR *arg3) { return default_auxv_parse (this, arg0, arg1, arg2, arg3); } =20 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, COR= E_ADDR *arg2, CORE_ADDR *arg3) { int result; gdb_printf (gdb_stdlog, "-> %s->auxv_parse (...)\n", this->beneath ()->s= hortname ()); result =3D this->beneath ()->auxv_parse (arg0, arg1, arg2, arg3); gdb_printf (gdb_stdlog, "<- %s->auxv_parse (", this->beneath ()->shortna= me ()); - 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 8e13ada07b6..28aa9273893 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); =20 /* Search SEARCH_SPACE_LEN bytes beginning at START_ADDR for the