]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: change gdbarch_ax_pseudo_register_collect to return void
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 27 Feb 2026 20:05:01 +0000 (15:05 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 9 Mar 2026 17:15:46 +0000 (13:15 -0400)
I initially changed it to return bool instead of int, but then realized
that none of the implementations actually ever returned an error, so
change the return type to void.

Use gdb_assert_not_reached instead of internal_error, and remove the use
of the gettext macro, because these messages are typically not
translated, if we look at other call sites of gdb_assert_not_reached.

Change-Id: Iab9804f090805ded5a50336dbab8d1a0c099ce33
Approved-By: Tom Tromey <tom@tromey.com>
gdb/amd64-tdep.c
gdb/ax-general.c
gdb/gdbarch-gen.c
gdb/gdbarch-gen.h
gdb/gdbarch_components.py
gdb/i386-tdep.c
gdb/i386-tdep.h
gdb/mips-tdep.c
gdb/rs6000-tdep.c
gdb/s390-tdep.c

index 1334ce6fb07c2bb2f4987457523a7d42d6dde6a2..66411b4877720fd7627b7206e74874b917ef2fb5 100755 (executable)
@@ -424,7 +424,7 @@ amd64_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 
 /* Implement the 'ax_pseudo_register_collect' gdbarch method.  */
 
-static int
+static void
 amd64_ax_pseudo_register_collect (struct gdbarch *gdbarch,
                                  struct agent_expr *ax, int regnum)
 {
@@ -438,17 +438,15 @@ amd64_ax_pseudo_register_collect (struct gdbarch *gdbarch,
        ax_reg_mask (ax, gpnum - AMD64_NUM_LOWER_BYTE_REGS);
       else
        ax_reg_mask (ax, gpnum);
-      return 0;
     }
   else if (i386_dword_regnum_p (gdbarch, regnum))
     {
       int gpnum = regnum - tdep->eax_regnum;
 
       ax_reg_mask (ax, gpnum);
-      return 0;
     }
   else
-    return i386_ax_pseudo_register_collect (gdbarch, ax, regnum);
+    i386_ax_pseudo_register_collect (gdbarch, ax, regnum);
 }
 
 \f
index 66cb9da99624326254c93cdea697752d74bde513..05ca556703e086303a04e9be55aea39cc5ac0605 100644 (file)
@@ -402,9 +402,8 @@ ax_reg_mask (struct agent_expr *ax, int reg)
        error (_("'%s' is a pseudo-register; "
                 "GDB cannot yet trace its contents."),
               user_reg_map_regnum_to_name (ax->gdbarch, reg));
-      if (gdbarch_ax_pseudo_register_collect (ax->gdbarch, ax, reg))
-       error (_("Trace '%s' failed."),
-              user_reg_map_regnum_to_name (ax->gdbarch, reg));
+
+      gdbarch_ax_pseudo_register_collect (ax->gdbarch, ax, reg);
     }
   else
     {
index 573f6eefc96091376e45948868b5f0e5ed0a2dab..c4da3fa4c29c9c4284f8384489955354fc4b4e51 100644 (file)
@@ -1950,14 +1950,14 @@ gdbarch_ax_pseudo_register_collect_p (struct gdbarch *gdbarch)
   return gdbarch->ax_pseudo_register_collect != NULL;
 }
 
-int
+void
 gdbarch_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->ax_pseudo_register_collect != NULL);
   if (gdbarch_debug >= 2)
     gdb_printf (gdb_stdlog, "gdbarch_ax_pseudo_register_collect called\n");
-  return gdbarch->ax_pseudo_register_collect (gdbarch, ax, reg);
+  gdbarch->ax_pseudo_register_collect (gdbarch, ax, reg);
 }
 
 void
index 1ff02b1067c590d6e99924fc1cac49069cbcb701..13e9b94a8ff8384206ab33b5f097e5c842ea561f 100644 (file)
@@ -236,12 +236,12 @@ extern int gdbarch_num_pseudo_regs (struct gdbarch *gdbarch);
 extern void set_gdbarch_num_pseudo_regs (struct gdbarch *gdbarch, int num_pseudo_regs);
 
 /* Assemble agent expression bytecode to collect pseudo-register REG.
-   Return -1 if something goes wrong, 0 otherwise. */
+   REG must be a valid register number. */
 
 extern bool gdbarch_ax_pseudo_register_collect_p (struct gdbarch *gdbarch);
 
-typedef int (gdbarch_ax_pseudo_register_collect_ftype) (struct gdbarch *gdbarch, struct agent_expr *ax, int reg);
-extern int gdbarch_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg);
+typedef void (gdbarch_ax_pseudo_register_collect_ftype) (struct gdbarch *gdbarch, struct agent_expr *ax, int reg);
+extern void gdbarch_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, int reg);
 extern void set_gdbarch_ax_pseudo_register_collect (struct gdbarch *gdbarch, gdbarch_ax_pseudo_register_collect_ftype *ax_pseudo_register_collect);
 
 /* Assemble agent expression bytecode to push the value of pseudo-register
index 46283c1bd7d436cf82bcde4a22073234e46a9a2e..4c51dc3d04cb128fb863547fb3d41382d8f75bb7 100644 (file)
@@ -486,9 +486,9 @@ combinations of other registers, or they may be computed by GDB.
 Method(
     comment="""
 Assemble agent expression bytecode to collect pseudo-register REG.
-Return -1 if something goes wrong, 0 otherwise.
+REG must be a valid register number.
 """,
-    type="int",
+    type="void",
     name="ax_pseudo_register_collect",
     params=[("struct agent_expr *", "ax"), ("int", "reg")],
     predicate=True,
index 52ceef20d09fa396111a40a8ebfa816efddb7605..8200683a6b74cdb1c92aec4e5a031bb64a6ca697 100644 (file)
@@ -3415,7 +3415,7 @@ i386_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
 
 /* Implement the 'ax_pseudo_register_collect' gdbarch method.  */
 
-int
+void
 i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
                                 struct agent_expr *ax, int regnum)
 {
@@ -3430,7 +3430,6 @@ i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
       ax_reg_mask (ax, I387_FSTAT_REGNUM (tdep));
       for (i = 0; i < 8; i++)
        ax_reg_mask (ax, I387_ST0_REGNUM (tdep) + i);
-      return 0;
     }
   else if (i386_zmm_regnum_p (gdbarch, regnum))
     {
@@ -3448,39 +3447,33 @@ i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
                           - num_lower_zmm_regs);
        }
       ax_reg_mask (ax, tdep->zmm0h_regnum + regnum);
-      return 0;
     }
   else if (i386_ymm_regnum_p (gdbarch, regnum))
     {
       regnum -= tdep->ymm0_regnum;
       ax_reg_mask (ax, I387_XMM0_REGNUM (tdep) + regnum);
       ax_reg_mask (ax, tdep->ymm0h_regnum + regnum);
-      return 0;
     }
   else if (i386_ymm_avx512_regnum_p (gdbarch, regnum))
     {
       regnum -= tdep->ymm16_regnum;
       ax_reg_mask (ax, I387_XMM16_REGNUM (tdep) + regnum);
       ax_reg_mask (ax, tdep->ymm16h_regnum + regnum);
-      return 0;
     }
   else if (i386_word_regnum_p (gdbarch, regnum))
     {
       int gpnum = regnum - tdep->ax_regnum;
 
       ax_reg_mask (ax, gpnum);
-      return 0;
     }
   else if (i386_byte_regnum_p (gdbarch, regnum))
     {
       int gpnum = regnum - tdep->al_regnum;
 
       ax_reg_mask (ax, gpnum % 4);
-      return 0;
     }
   else
-    internal_error (_("invalid regnum"));
-  return 1;
+    gdb_assert_not_reached ("invalid regnum");
 }
 \f
 
index b4df39722aee34e10b8a34303cda6409aeff755c..ee33b8b530deed3a095cf8c469e72d28f6afe8b3 100644 (file)
@@ -384,9 +384,9 @@ extern void i386_pseudo_register_write (gdbarch *gdbarch,
                                        const frame_info_ptr &next_frame, int regnum,
                                        gdb::array_view<const gdb_byte> buf);
 
-extern int i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
-                                           struct agent_expr *ax,
-                                           int regnum);
+extern void i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
+                                            struct agent_expr *ax,
+                                            int regnum);
 
 /* Segment selectors.  */
 #define I386_SEL_RPL   0x0003  /* Requester's Privilege Level mask.  */
index aa52c0b245845295df8c2cfffa1c71af1ac1904b..0babb8b9b987b37e371800c0648bed26add0599a 100644 (file)
@@ -830,7 +830,7 @@ mips_pseudo_register_write (struct gdbarch *gdbarch,
     internal_error (_("bad register size"));
 }
 
-static int
+static void
 mips_ax_pseudo_register_collect (struct gdbarch *gdbarch,
                                 struct agent_expr *ax, int reg)
 {
@@ -839,8 +839,6 @@ mips_ax_pseudo_register_collect (struct gdbarch *gdbarch,
              && reg < 2 * gdbarch_num_regs (gdbarch));
 
   ax_reg_mask (ax, rawnum);
-
-  return 0;
 }
 
 static int
index 7d0902941a03cc5bbcf9f7c16ce3f06ff344e9a9..444dd5ffc386329a5d73f890a421eb7910746d4d 100644 (file)
@@ -3300,7 +3300,7 @@ efp_ax_pseudo_register_collect (struct gdbarch *gdbarch,
   ax_reg_mask (ax, vr0 + reg_index);
 }
 
-static int
+static void
 rs6000_ax_pseudo_register_collect (struct gdbarch *gdbarch,
                                   struct agent_expr *ax, int reg_nr)
 {
@@ -3331,10 +3331,9 @@ rs6000_ax_pseudo_register_collect (struct gdbarch *gdbarch,
       efp_ax_pseudo_register_collect (gdbarch, ax, reg_nr);
     }
   else
-    internal_error (_("rs6000_pseudo_register_collect: "
-                   "called on unexpected register '%s' (%d)"),
-                   gdbarch_register_name (gdbarch, reg_nr), reg_nr);
-  return 0;
+    gdb_assert_not_reached ("rs6000_pseudo_register_collect: "
+                           "called on unexpected register '%s' (%d)",
+                           gdbarch_register_name (gdbarch, reg_nr), reg_nr);
 }
 
 
index f52e898047b72128ee200fac41081e8d756e07cf..8a3bde525e93add622d50e970eba49bf6af57119 100644 (file)
@@ -1505,7 +1505,7 @@ s390_pseudo_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 
 /* The "ax_pseudo_register_collect" gdbarch method.  */
 
-static int
+static void
 s390_ax_pseudo_register_collect (struct gdbarch *gdbarch,
                                 struct agent_expr *ax, int regnum)
 {
@@ -1531,10 +1531,7 @@ s390_ax_pseudo_register_collect (struct gdbarch *gdbarch,
       ax_reg_mask (ax, S390_V0_LOWER_REGNUM + regnum);
     }
   else
-    {
-      internal_error (_("invalid regnum"));
-    }
-  return 0;
+    gdb_assert_not_reached ("invalid regnum");
 }
 
 /* The "ax_pseudo_register_push_stack" gdbarch method.  */