public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Small cleanups in auxv.c
@ 2022-09-29 20:43 Simon Marchi
  2022-09-29 20:43 ` [PATCH 1/3] gdb: constify auxv parse functions Simon Marchi
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Simon Marchi @ 2022-09-29 20:43 UTC (permalink / raw)
  To: gdb-patches

I'm currently reviewing an auxv-related patch, and found these little
cleanups could be done.

Simon Marchi (3):
  gdb: constify auxv parse functions
  gdb: make fprint_target_auxv static
  gdb: make target_auxv_parse static and rename

 gdb/auxv.c                | 38 +++++++++++++++++++++-----------------
 gdb/auxv.h                | 18 ++++--------------
 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, 50 insertions(+), 56 deletions(-)


base-commit: 31282a849107d95d3cfe115ba160f976dd99844c
-- 
2.37.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] gdb: constify auxv parse functions
  2022-09-29 20:43 [PATCH 0/3] Small cleanups in auxv.c Simon Marchi
@ 2022-09-29 20:43 ` Simon Marchi
  2022-09-29 20:43 ` [PATCH 2/3] gdb: make fprint_target_auxv static Simon Marchi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Simon Marchi @ 2022-09-29 20:43 UTC (permalink / raw)
  To: gdb-patches

Constify the input parameters of the various auxv parse functions, they
don't need to modify the raw auxv data.

Change-Id: I13eacd5ab8e925ec2b5c1f7722cbab39c41516ec
---
 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 b248f997f1ca..63ee01c333c5 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.  */
 
 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)
diff --git a/gdb/auxv.h b/gdb/auxv.h
index a4801c34d2f6..497318e87a04 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 **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 ad71bf754de9..6374240ae4b5 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 c7a24704c7cf..706dbb3befe1 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 18d46a39d7a5..be73d399069e 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 b089fcc8a5f5..dfa81e19a79f 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 73961c877691..2b21e0822362 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -132,8 +132,8 @@ class s390_linux_nat_target final : public linux_nat_target
 
   /* 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 ab89c0a51858..77033f00289b 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 b6628c4d0be6..daf46821be07 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 8e13ada07b6a..28aa92738930 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
-- 
2.37.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] gdb: make fprint_target_auxv static
  2022-09-29 20:43 [PATCH 0/3] Small cleanups in auxv.c Simon Marchi
  2022-09-29 20:43 ` [PATCH 1/3] gdb: constify auxv parse functions Simon Marchi
@ 2022-09-29 20:43 ` Simon Marchi
  2022-09-29 20:43 ` [PATCH 3/3] gdb: make target_auxv_parse static and rename Simon Marchi
  2022-09-29 21:31 ` [PATCH 0/3] Small cleanups in auxv.c John Baldwin
  3 siblings, 0 replies; 6+ messages in thread
From: Simon Marchi @ 2022-09-29 20:43 UTC (permalink / raw)
  To: gdb-patches

It's only used in auxv.c.

Change-Id: I4992d9aae37b6631a074ab99bbab2f619725b642
---
 gdb/auxv.c | 2 +-
 gdb/auxv.h | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/gdb/auxv.c b/gdb/auxv.c
index 63ee01c333c5..a9337d9f7ff4 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -546,7 +546,7 @@ default_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
 
 /* Print the contents of the target's AUXV on the specified file.  */
 
-int
+static int
 fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
 {
   struct gdbarch *gdbarch = target_gdbarch ();
diff --git a/gdb/auxv.h b/gdb/auxv.h
index 497318e87a04..2e8b2ab33fc6 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -74,9 +74,6 @@ extern void default_print_auxv_entry (struct gdbarch *gdbarch,
 				      struct ui_file *file, CORE_ADDR type,
 				      CORE_ADDR val);
 
-/* Print the contents of the target's AUXV on the specified file.  */
-extern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops);
-
 extern target_xfer_partial_ftype memory_xfer_auxv;
 
 
-- 
2.37.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/3] gdb: make target_auxv_parse static and rename
  2022-09-29 20:43 [PATCH 0/3] Small cleanups in auxv.c Simon Marchi
  2022-09-29 20:43 ` [PATCH 1/3] gdb: constify auxv parse functions Simon Marchi
  2022-09-29 20:43 ` [PATCH 2/3] gdb: make fprint_target_auxv static Simon Marchi
@ 2022-09-29 20:43 ` Simon Marchi
  2022-09-29 21:31 ` [PATCH 0/3] Small cleanups in auxv.c John Baldwin
  3 siblings, 0 replies; 6+ messages in thread
From: Simon Marchi @ 2022-09-29 20:43 UTC (permalink / raw)
  To: gdb-patches

It is only used in auxv.c.  Also, given it is not strictly a wrapper
around target_ops::auxv (since 27a48a9223d0 "Add auxv parsing to the
architecture vector."), I think that the name prefixed with target is a
bit misleading.  Rename to just parse_auxv.

Change-Id: I41cca055b92c8ede37c258ba6583746a07d8f77e
---
 gdb/auxv.c | 14 +++++++++-----
 gdb/auxv.h |  7 -------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/gdb/auxv.c b/gdb/auxv.c
index a9337d9f7ff4..76fc821c07c3 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -306,12 +306,16 @@ svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
 }
 
 /* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
+
+   Use the auxv_parse method from the current inferior's gdbarch, if defined,
+   else use the current inferior's target stack's auxv_parse.
+
    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.  */
-int
-target_auxv_parse (const gdb_byte **readptr, const gdb_byte *endptr,
-		   CORE_ADDR *typep, CORE_ADDR *valp)
+static int
+parse_auxv (const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep,
+	    CORE_ADDR *valp)
 {
   struct gdbarch *gdbarch = target_gdbarch();
 
@@ -388,7 +392,7 @@ target_auxv_search (struct target_ops *ops, CORE_ADDR match, CORE_ADDR *valp)
   size_t len = info->data->size ();
 
   while (1)
-    switch (target_auxv_parse (&ptr, data + len, &type, &val))
+    switch (parse_auxv (&ptr, data + len, &type, &val))
       {
       case 1:			/* Here's an entry, check it.  */
 	if (type == match)
@@ -561,7 +565,7 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
   const gdb_byte *ptr = data;
   size_t len = info->data->size ();
 
-  while (target_auxv_parse (&ptr, data + len, &type, &val) > 0)
+  while (parse_auxv (&ptr, data + len, &type, &val) > 0)
     {
       gdbarch_print_auxv_entry (gdbarch, file, type, val);
       ++ents;
diff --git a/gdb/auxv.h b/gdb/auxv.h
index 2e8b2ab33fc6..ab2a5dee5f74 100644
--- a/gdb/auxv.h
+++ b/gdb/auxv.h
@@ -46,13 +46,6 @@ 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 (const gdb_byte **readptr, const gdb_byte *endptr,
-			      CORE_ADDR *typep, CORE_ADDR *valp);
-
 /* Extract the auxiliary vector entry with a_type matching MATCH.
    Return zero if no such entry was found, or -1 if there was
    an error getting the information.  On success, return 1 after
-- 
2.37.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] Small cleanups in auxv.c
  2022-09-29 20:43 [PATCH 0/3] Small cleanups in auxv.c Simon Marchi
                   ` (2 preceding siblings ...)
  2022-09-29 20:43 ` [PATCH 3/3] gdb: make target_auxv_parse static and rename Simon Marchi
@ 2022-09-29 21:31 ` John Baldwin
  2022-09-29 23:57   ` Simon Marchi
  3 siblings, 1 reply; 6+ messages in thread
From: John Baldwin @ 2022-09-29 21:31 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 9/29/22 1:43 PM, Simon Marchi via Gdb-patches wrote:
> I'm currently reviewing an auxv-related patch, and found these little
> cleanups could be done.
> 
> Simon Marchi (3):
>    gdb: constify auxv parse functions
>    gdb: make fprint_target_auxv static
>    gdb: make target_auxv_parse static and rename
> 
>   gdb/auxv.c                | 38 +++++++++++++++++++++-----------------
>   gdb/auxv.h                | 18 ++++--------------
>   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, 50 insertions(+), 56 deletions(-)
> 
> 
> base-commit: 31282a849107d95d3cfe115ba160f976dd99844c

These all look fine to me.

-- 
John Baldwin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/3] Small cleanups in auxv.c
  2022-09-29 21:31 ` [PATCH 0/3] Small cleanups in auxv.c John Baldwin
@ 2022-09-29 23:57   ` Simon Marchi
  0 siblings, 0 replies; 6+ messages in thread
From: Simon Marchi @ 2022-09-29 23:57 UTC (permalink / raw)
  To: John Baldwin, gdb-patches



On 2022-09-29 17:31, John Baldwin wrote:
> On 9/29/22 1:43 PM, Simon Marchi via Gdb-patches wrote:
>> I'm currently reviewing an auxv-related patch, and found these little
>> cleanups could be done.
>>
>> Simon Marchi (3):
>>    gdb: constify auxv parse functions
>>    gdb: make fprint_target_auxv static
>>    gdb: make target_auxv_parse static and rename
>>
>>   gdb/auxv.c                | 38 +++++++++++++++++++++-----------------
>>   gdb/auxv.h                | 18 ++++--------------
>>   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, 50 insertions(+), 56 deletions(-)
>>
>>
>> base-commit: 31282a849107d95d3cfe115ba160f976dd99844c
> 
> These all look fine to me.
> 

Thanks, pushed.

Simon

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-29 23:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 20:43 [PATCH 0/3] Small cleanups in auxv.c Simon Marchi
2022-09-29 20:43 ` [PATCH 1/3] gdb: constify auxv parse functions Simon Marchi
2022-09-29 20:43 ` [PATCH 2/3] gdb: make fprint_target_auxv static Simon Marchi
2022-09-29 20:43 ` [PATCH 3/3] gdb: make target_auxv_parse static and rename Simon Marchi
2022-09-29 21:31 ` [PATCH 0/3] Small cleanups in auxv.c John Baldwin
2022-09-29 23:57   ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).