]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: change gdbarch_register_to_value to return and take bool
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 27 Feb 2026 20:05:19 +0000 (15:05 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 9 Mar 2026 17:15:47 +0000 (13:15 -0400)
Convert the return value as well as two output parameters.  Convert some
frame support functions that have the same output parameters as well.

Change-Id: I4ed54aa79126b6d0387b550c20382ca21e500f1b
Approved-By: Tom Tromey <tom@tromey.com>
18 files changed:
gdb/alpha-tdep.c
gdb/dwarf2/expr.c
gdb/findvar.c
gdb/frame.c
gdb/frame.h
gdb/gdbarch-gen.c
gdb/gdbarch-gen.h
gdb/gdbarch-selftests.c
gdb/gdbarch_components.py
gdb/i386-tdep.c
gdb/i387-tdep.c
gdb/i387-tdep.h
gdb/ia64-tdep.c
gdb/m68k-tdep.c
gdb/mips-tdep.c
gdb/rs6000-tdep.c
gdb/stack.c
gdb/valops.c

index 071385eae7262d8bfa90cf27eeef652b38548748..9687c15202685a695413952ea95c77bc8660b38e 100644 (file)
@@ -213,10 +213,10 @@ alpha_convert_register_p (struct gdbarch *gdbarch, int regno,
          && type->length () == 4);
 }
 
-static int
+static bool
 alpha_register_to_value (const frame_info_ptr &frame, int regnum,
                         struct type *valtype, gdb_byte *out,
-                       int *optimizedp, int *unavailablep)
+                        bool *optimizedp, bool *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   struct value *value = get_frame_register_value (frame, regnum);
@@ -228,7 +228,7 @@ alpha_register_to_value (const frame_info_ptr &frame, int regnum,
   if (*optimizedp || *unavailablep)
     {
       release_value (value);
-      return 0;
+      return false;
     }
 
   /* Convert to VALTYPE.  */
@@ -237,7 +237,7 @@ alpha_register_to_value (const frame_info_ptr &frame, int regnum,
   alpha_sts (gdbarch, out, value->contents_all ().data ());
 
   release_value (value);
-  return 1;
+  return true;
 }
 
 static void
index 9f4a5bc7ede4947e47ea4e91b2ca0ff99c63ba92..c253460ba34ccb83e004fd77fe3833ae6897c18f 100644 (file)
@@ -209,7 +209,7 @@ rw_pieced_value (value *v, value *from, bool check_optimized)
            gdbarch *arch = frame_unwind_arch (next_frame);
            int gdb_regnum = dwarf_reg_to_regnum_or_error (arch, p->v.regno);
            ULONGEST reg_bits = 8 * register_size (arch, gdb_regnum);
-           int optim, unavail;
+           bool optim, unavail;
 
            if (p->offset + p->size < reg_bits)
              {
index 3c965117ee76033a06399fc03d8169f07db8331a..99b0d31d9d41fb8275d831cbd41f44fe1d9623b7 100644 (file)
@@ -620,7 +620,7 @@ value_from_register (struct type *type, int regnum, const frame_info_ptr &frame)
 
   if (gdbarch_convert_register_p (gdbarch, regnum, type1))
     {
-      int optim, unavail, ok;
+      bool optim, unavail;
 
       /* The ISA/ABI need to something weird when obtaining the
         specified value from this register.  It might need to
@@ -631,9 +631,9 @@ value_from_register (struct type *type, int regnum, const frame_info_ptr &frame)
         including the location.  */
       v = value::allocate_register (get_next_frame_sentinel_okay (frame),
                                    regnum, type);
-      ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
-                                     v->contents_raw ().data (), &optim,
-                                     &unavail);
+      bool ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
+                                          v->contents_raw ().data (), &optim,
+                                          &unavail);
 
       if (!ok)
        {
index 4292e1429a23fee84d8bd6e1e39c47a36a443aa1..746d7d06ec1f04cd95a92153c98f1b532f17190d 100644 (file)
@@ -1219,7 +1219,7 @@ frame_pop (const frame_info_ptr &this_frame)
 
 void
 frame_register_unwind (const frame_info_ptr &next_frame, int regnum,
-                      int *optimizedp, int *unavailablep,
+                      bool *optimizedp, bool *unavailablep,
                       enum lval_type *lvalp, CORE_ADDR *addrp,
                       int *realnump,
                       gdb::array_view<gdb_byte> buffer)
@@ -1266,8 +1266,8 @@ void
 frame_unwind_register (const frame_info_ptr &next_frame, int regnum,
                       gdb::array_view<gdb_byte> buf)
 {
-  int optimized;
-  int unavailable;
+  bool optimized;
+  bool unavailable;
   CORE_ADDR addr;
   int realnum;
   enum lval_type lval;
@@ -1485,8 +1485,8 @@ put_frame_register (const frame_info_ptr &next_frame, int regnum,
 {
   gdbarch *gdbarch = frame_unwind_arch (next_frame);
   int realnum;
-  int optim;
-  int unavail;
+  bool optim;
+  bool unavail;
   enum lval_type lval;
   CORE_ADDR addr;
   int size = register_size (gdbarch, regnum);
@@ -1531,8 +1531,8 @@ bool
 deprecated_frame_register_read (const frame_info_ptr &frame, int regnum,
                                gdb::array_view<gdb_byte> myaddr)
 {
-  int optimized;
-  int unavailable;
+  bool optimized;
+  bool unavailable;
   enum lval_type lval;
   CORE_ADDR addr;
   int realnum;
@@ -1547,7 +1547,7 @@ deprecated_frame_register_read (const frame_info_ptr &frame, int regnum,
 bool
 get_frame_register_bytes (const frame_info_ptr &next_frame, int regnum,
                          CORE_ADDR offset, gdb::array_view<gdb_byte> buffer,
-                         int *optimizedp, int *unavailablep)
+                         bool *optimizedp, bool *unavailablep)
 {
   gdbarch *gdbarch = frame_unwind_arch (next_frame);
 
@@ -2195,7 +2195,7 @@ reinit_frame_cache (void)
 
 static void
 frame_register_unwind_location (const frame_info_ptr &initial_this_frame,
-                               int regnum, int *optimizedp, lval_type *lvalp,
+                               int regnum, bool *optimizedp, lval_type *lvalp,
                                CORE_ADDR *addrp, int *realnump)
 {
   gdb_assert (initial_this_frame == nullptr || initial_this_frame->level >= 0);
@@ -2203,7 +2203,7 @@ frame_register_unwind_location (const frame_info_ptr &initial_this_frame,
   frame_info_ptr this_frame = initial_this_frame;
   while (this_frame != NULL)
     {
-      int unavailable;
+      bool unavailable;
 
       frame_register_unwind (this_frame, regnum, optimizedp, &unavailable,
                             lvalp, addrp, realnump);
@@ -2467,7 +2467,8 @@ get_prev_frame_always_1 (const frame_info_ptr &this_frame)
       && (get_frame_type (frame_info_ptr (this_frame->next)) == NORMAL_FRAME
          || get_frame_type (frame_info_ptr (this_frame->next)) == INLINE_FRAME))
     {
-      int optimized, realnum, nrealnum;
+      bool optimized;
+      int realnum, nrealnum;
       enum lval_type lval, nlval;
       CORE_ADDR addr, naddr;
 
index f5f5219ceecad2df01c87f4dcd2a9767c64f1133..00485e6d1e2750a58aa667cc8473135284b0b170 100644 (file)
@@ -690,7 +690,7 @@ const char *frame_stop_reason_string (const frame_info_ptr &);
    fetch/compute the value.  Instead just return the location of the
    value.  */
 extern void frame_register_unwind (const frame_info_ptr &frame, int regnum,
-                                  int *optimizedp, int *unavailablep,
+                                  bool *optimizedp, bool *unavailablep,
                                   enum lval_type *lvalp,
                                   CORE_ADDR *addrp, int *realnump,
                                   gdb::array_view<gdb_byte> value = {});
@@ -741,7 +741,7 @@ extern void put_frame_register (const frame_info_ptr &next_frame, int regnum,
 extern bool get_frame_register_bytes (const frame_info_ptr &next_frame,
                                      int regnum, CORE_ADDR offset,
                                      gdb::array_view<gdb_byte> buffer,
-                                     int *optimizedp, int *unavailablep);
+                                     bool *optimizedp, bool *unavailablep);
 
 /* Write bytes from BUFFER to one or multiple registers starting with REGNUM
    in NEXT_FRAME's previous frame, starting at OFFSET.  */
index 88922d2670aecd56434577decee798621fbd0d35..9fad9ff28236a82a8476e9e432da8c19b008c898 100644 (file)
@@ -2374,8 +2374,8 @@ set_gdbarch_convert_register_p (struct gdbarch *gdbarch,
   gdbarch->convert_register_p = convert_register_p;
 }
 
-int
-gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep)
+bool
+gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, bool *optimizedp, bool *unavailablep)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->register_to_value != NULL);
index 5710e1bce7b91cba69af186dd2b9aa166a1e8512..f556751f26b3dcf0c67c0dd1aade8b4c290bd401 100644 (file)
@@ -389,8 +389,8 @@ typedef bool (gdbarch_convert_register_p_ftype) (struct gdbarch *gdbarch, int re
 extern bool gdbarch_convert_register_p (struct gdbarch *gdbarch, int regnum, struct type *type);
 extern void set_gdbarch_convert_register_p (struct gdbarch *gdbarch, gdbarch_convert_register_p_ftype *convert_register_p);
 
-typedef int (gdbarch_register_to_value_ftype) (const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
-extern int gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, int *optimizedp, int *unavailablep);
+typedef bool (gdbarch_register_to_value_ftype) (const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, bool *optimizedp, bool *unavailablep);
+extern bool gdbarch_register_to_value (struct gdbarch *gdbarch, const frame_info_ptr &frame, int regnum, struct type *type, gdb_byte *buf, bool *optimizedp, bool *unavailablep);
 extern void set_gdbarch_register_to_value (struct gdbarch *gdbarch, gdbarch_register_to_value_ftype *register_to_value);
 
 typedef void (gdbarch_value_to_register_ftype) (const frame_info_ptr &frame, int regnum, struct type *type, const gdb_byte *buf);
index c89ad5ce5fde3cac761f13eca251df8c200e2828..b0f49206230c2ada88cb36f23ac52b31a6e7465e 100644 (file)
@@ -100,13 +100,14 @@ register_to_value_test (struct gdbarch *gdbarch)
 
              /* Allocate two bytes more for overflow check.  */
              std::vector<gdb_byte> buf (type->length () + 2, 0);
-             int optim, unavail, ok;
+             bool optim, unavail;
 
              /* Set the fingerprint in the last two bytes.  */
              buf [type->length ()]= 'w';
              buf [type->length () + 1]= 'l';
-             ok = gdbarch_register_to_value (gdbarch, frame, regnum, type,
-                                             buf.data (), &optim, &unavail);
+             bool ok = gdbarch_register_to_value (gdbarch, frame, regnum,
+                                                  type, buf.data (), &optim,
+                                                  &unavail);
 
              SELF_CHECK (ok);
              SELF_CHECK (!optim);
index a75a4ed260140ac65b8ad3c772e7bbd61025d6ce..2d0fc40e0ce721dfbbd4448fa24b717e04f05e12 100644 (file)
@@ -747,15 +747,15 @@ Method(
 )
 
 Function(
-    type="int",
+    type="bool",
     name="register_to_value",
     params=[
         ("const frame_info_ptr &", "frame"),
         ("int", "regnum"),
         ("struct type *", "type"),
         ("gdb_byte *", "buf"),
-        ("int *", "optimizedp"),
-        ("int *", "unavailablep"),
+        ("bool *", "optimizedp"),
+        ("bool *", "unavailablep"),
     ],
     invalid=False,
 )
index 312cef8a4faa0bffabf9d4c3877c2c49017521f9..09fd94f3d09a7d795e6de3a3c81509619a6d8abb 100644 (file)
@@ -3540,10 +3540,10 @@ i386_convert_register_p (struct gdbarch *gdbarch,
 /* Read a value of type TYPE from register REGNUM in frame FRAME, and
    return its contents in TO.  */
 
-static int
+static bool
 i386_register_to_value (const frame_info_ptr &frame, int regnum,
                        struct type *type, gdb_byte *to,
-                       int *optimizedp, int *unavailablep)
+                       bool *optimizedp, bool *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   int len = type->length ();
@@ -3566,15 +3566,15 @@ i386_register_to_value (const frame_info_ptr &frame, int regnum,
       frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
       if (!get_frame_register_bytes (next_frame, regnum, 0, to_view,
                                     optimizedp, unavailablep))
-       return 0;
+       return false;
 
       regnum = i386_next_regnum (regnum);
       len -= 4;
       to += 4;
     }
 
-  *optimizedp = *unavailablep = 0;
-  return 1;
+  *optimizedp = *unavailablep = false;
+  return true;
 }
 
 /* Write the contents FROM of a value of type TYPE into register
index a1f4510ecd55f12f3b4ac8b72be6bcaa7e038fd7..f33f5ad046e221dbaae249356a0d577a77dc440e 100644 (file)
@@ -344,10 +344,10 @@ i387_convert_register_p (struct gdbarch *gdbarch, int regnum,
 /* Read a value of type TYPE from register REGNUM in frame FRAME, and
    return its contents in TO.  */
 
-int
+bool
 i387_register_to_value (const frame_info_ptr &frame, int regnum,
                        struct type *type, gdb_byte *to,
-                       int *optimizedp, int *unavailablep)
+                       bool *optimizedp, bool *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte from[I386_MAX_REGISTER_SIZE];
@@ -359,8 +359,8 @@ i387_register_to_value (const frame_info_ptr &frame, int regnum,
     {
       warning (_("Cannot convert floating-point register value "
               "to non-floating-point type."));
-      *optimizedp = *unavailablep = 0;
-      return 0;
+      *optimizedp = *unavailablep = false;
+      return false;
     }
 
   /* Convert to TYPE.  */
@@ -369,11 +369,11 @@ i387_register_to_value (const frame_info_ptr &frame, int regnum,
   frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
   if (!get_frame_register_bytes (next_frame, regnum, 0, from_view, optimizedp,
                                 unavailablep))
-    return 0;
+    return false;
 
   target_float_convert (from, i387_ext_type (gdbarch), to, type);
-  *optimizedp = *unavailablep = 0;
-  return 1;
+  *optimizedp = *unavailablep = false;
+  return true;
 }
 
 /* Write the contents FROM of a value of type TYPE into register
index 5fb4f196fc2e85dbf7eadef8761e261a7e093e16..5d063502bce5fe591f91095854890e0c1726483f 100644 (file)
@@ -94,9 +94,9 @@ extern bool i387_convert_register_p (struct gdbarch *gdbarch, int regnum,
 /* Read a value of type TYPE from register REGNUM in frame FRAME, and
    return its contents in TO.  */
 
-extern int i387_register_to_value (const frame_info_ptr &frame, int regnum,
-                                  struct type *type, gdb_byte *to,
-                                  int *optimizedp, int *unavailablep);
+extern bool i387_register_to_value (const frame_info_ptr &frame, int regnum,
+                                   struct type *type, gdb_byte *to,
+                                   bool *optimizedp, bool *unavailablep);
 
 /* Write the contents FROM of a value of type TYPE into register
    REGNUM in frame FRAME.  */
index 9064af105fa0c0dca8e608948ed489cf9608b5f8..2b918b87bbc5551ebaa575ba46eed4d24c8e1b88 100644 (file)
@@ -1218,10 +1218,10 @@ ia64_convert_register_p (struct gdbarch *gdbarch, int regno, struct type *type)
          && type != ia64_ext_type (gdbarch));
 }
 
-static int
+static bool
 ia64_register_to_value (const frame_info_ptr &frame, int regnum,
                        struct type *valtype, gdb_byte *out,
-                       int *optimizedp, int *unavailablep)
+                       bool *optimizedp, bool *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte in[IA64_FP_REGISTER_SIZE];
@@ -1231,11 +1231,11 @@ ia64_register_to_value (const frame_info_ptr &frame, int regnum,
   frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
   if (!get_frame_register_bytes (next_frame, regnum, 0, in_view, optimizedp,
                                 unavailablep))
-    return 0;
+    return false;
 
   target_float_convert (in, ia64_ext_type (gdbarch), out, valtype);
-  *optimizedp = *unavailablep = 0;
-  return 1;
+  *optimizedp = *unavailablep = false;
+  return true;
 }
 
 static void
index ae545c0f9aa82a3d9defa1da2259119fca6a12f5..72b1a7a51875debf63d1e784953a581f87aeffb8 100644 (file)
@@ -204,10 +204,10 @@ m68k_convert_register_p (struct gdbarch *gdbarch,
 /* Read a value of type TYPE from register REGNUM in frame FRAME, and
    return its contents in TO.  */
 
-static int
+static bool
 m68k_register_to_value (const frame_info_ptr &frame, int regnum,
                        struct type *type, gdb_byte *to,
-                       int *optimizedp, int *unavailablep)
+                       bool *optimizedp, bool *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte from[M68K_MAX_REGISTER_SIZE];
@@ -221,11 +221,11 @@ m68k_register_to_value (const frame_info_ptr &frame, int regnum,
   frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
   if (!get_frame_register_bytes (next_frame, regnum, 0, from_view, optimizedp,
                                 unavailablep))
-    return 0;
+    return false;
 
   target_float_convert (from, fpreg_type, to, type);
-  *optimizedp = *unavailablep = 0;
-  return 1;
+  *optimizedp = *unavailablep = false;
+  return true;
 }
 
 /* Write the contents FROM of a value of type TYPE into register
index 6661e300c86e57cf63fd89458692a5f5479f1f8b..5a861035d6723faa2b0ff0b51924fb3e52486df3 100644 (file)
@@ -938,10 +938,10 @@ mips_convert_register_p (struct gdbarch *gdbarch,
          || mips_convert_register_gpreg_case_p (gdbarch, regnum, type));
 }
 
-static int
+static bool
 mips_register_to_value (const frame_info_ptr &frame, int regnum,
                        struct type *type, gdb_byte *to,
-                       int *optimizedp, int *unavailablep)
+                       bool *optimizedp, bool *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
@@ -956,13 +956,13 @@ mips_register_to_value (const frame_info_ptr &frame, int regnum,
 
       if (!get_frame_register_bytes (next_frame, regnum + 0, 0, second_half,
                                     optimizedp, unavailablep))
-       return 0;
+       return false;
 
       if (!get_frame_register_bytes (next_frame, regnum + 1, 0, first_half,
                                     optimizedp, unavailablep))
-       return 0;
-      *optimizedp = *unavailablep = 0;
-      return 1;
+       return false;
+      *optimizedp = *unavailablep = false;
+      return true;
     }
   else if (mips_convert_register_gpreg_case_p (gdbarch, regnum, type))
     {
@@ -972,10 +972,10 @@ mips_register_to_value (const frame_info_ptr &frame, int regnum,
       offset = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? 8 - len : 0;
       if (!get_frame_register_bytes (next_frame, regnum, offset, { to, len },
                                     optimizedp, unavailablep))
-       return 0;
+       return false;
 
-      *optimizedp = *unavailablep = 0;
-      return 1;
+      *optimizedp = *unavailablep = false;
+      return true;
     }
   else
     {
index 8723854812a0414f42f5da418c243eb33461c2fd..2c628408b41d8da394acfe3ed699b223b9392874 100644 (file)
@@ -2691,12 +2691,12 @@ ieee_128_float_regnum_adjust (struct gdbarch *gdbarch, struct type *type,
   return regnum;
 }
 
-static int
+static bool
 rs6000_register_to_value (const frame_info_ptr &frame,
                          int regnum,
                          struct type *type,
                          gdb_byte *to,
-                         int *optimizedp, int *unavailablep)
+                         bool *optimizedp, bool *unavailablep)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   gdb_byte from[PPC_MAX_REGISTER_SIZE];
@@ -2712,12 +2712,12 @@ rs6000_register_to_value (const frame_info_ptr &frame,
   frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
   if (!get_frame_register_bytes (next_frame, regnum, 0, from_view, optimizedp,
                                 unavailablep))
-    return 0;
+    return false;
 
   target_float_convert (from, builtin_type (gdbarch)->builtin_double,
                        to, type);
-  *optimizedp = *unavailablep = 0;
-  return 1;
+  *optimizedp = *unavailablep = false;
+  return true;
 }
 
 static void
index aa0257902e19c45c4afbd292320131a5214fe8b3..f1e3e8975f4fff434b816956a6867f8b08b7e64c 100644 (file)
@@ -1723,8 +1723,8 @@ info_frame_command_core (const frame_info_ptr &fi, bool selected_frame_p)
          && gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
        {
          enum lval_type lval;
-         int optimized;
-         int unavailable;
+         bool optimized;
+         bool unavailable;
          CORE_ADDR addr;
          int realnum;
 
index c89e5c4adc89c577c0c50bcc1848e6e8d63d69df..3743c8e0c823e708c9d7e27f03de944629ac09d9 100644 (file)
@@ -1207,7 +1207,7 @@ value_assign (struct value *toval, struct value *fromval)
            LONGEST offset = parent->offset () + toval->offset ();
            size_t changed_len;
            gdb_byte buffer[sizeof (LONGEST)];
-           int optim, unavail;
+           bool optim, unavail;
 
            changed_len = (toval->bitpos ()
                           + toval->bitsize ()