]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: change gdbarch_insn_is_{call,ret,jump} to return bool
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 27 Feb 2026 20:05:26 +0000 (15:05 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 9 Mar 2026 17:15:47 +0000 (13:15 -0400)
Change-Id: I5ff05978a1526d9aaeb6c4e46440009ca0d51116
Approved-By: Tom Tromey <tom@tromey.com>
gdb/amd64-tdep.c
gdb/arch-utils.c
gdb/arch-utils.h
gdb/gdbarch-gen.c
gdb/gdbarch-gen.h
gdb/gdbarch_components.py
gdb/i386-tdep.c
gdb/z80-tdep.c

index 60e38687e4712980d8c4f9dca33bc0f99909c5ba..0d23abb31641437522a5aac834a71b40ca1bc14b 100755 (executable)
@@ -1148,9 +1148,9 @@ static const unsigned char twobyte_has_modrm[256] = {
   /*      0 1 2 3 4 5 6 7 8 9 a b c d e f        */
 };
 
-static int amd64_syscall_p (const struct amd64_insn *insn, int *lengthp);
+static bool amd64_syscall_p (const struct amd64_insn *insn, int *lengthp);
 
-static int
+static bool
 rex_prefix_p (gdb_byte pfx)
 {
   return REX_PREFIX_P (pfx);
@@ -1673,7 +1673,7 @@ amd64_displaced_step_copy_insn (struct gdbarch *gdbarch,
   return displaced_step_copy_insn_closure_up (dsc.release ());
 }
 
-static int
+static bool
 amd64_absolute_jmp_p (const struct amd64_insn *details)
 {
   const gdb_byte *insn = &details->raw_insn[details->opcode_offset];
@@ -1682,35 +1682,35 @@ amd64_absolute_jmp_p (const struct amd64_insn *details)
     {
       /* jump near, absolute indirect (/4) */
       if ((insn[1] & 0x38) == 0x20)
-       return 1;
+       return true;
 
       /* jump far, absolute indirect (/5) */
       if ((insn[1] & 0x38) == 0x28)
-       return 1;
+       return true;
     }
 
-  return 0;
+  return false;
 }
 
-/* Return non-zero if the instruction DETAILS is a jump, zero otherwise.  */
+/* Return true if the instruction DETAILS is a jump, false otherwise.  */
 
-static int
+static bool
 amd64_jmp_p (const struct amd64_insn *details)
 {
   const gdb_byte *insn = &details->raw_insn[details->opcode_offset];
 
   /* jump short, relative.  */
   if (insn[0] == 0xeb)
-    return 1;
+    return true;
 
   /* jump near, relative.  */
   if (insn[0] == 0xe9)
-    return 1;
+    return true;
 
   return amd64_absolute_jmp_p (details);
 }
 
-static int
+static bool
 amd64_absolute_call_p (const struct amd64_insn *details)
 {
   const gdb_byte *insn = &details->raw_insn[details->opcode_offset];
@@ -1719,17 +1719,17 @@ amd64_absolute_call_p (const struct amd64_insn *details)
     {
       /* Call near, absolute indirect (/2) */
       if ((insn[1] & 0x38) == 0x10)
-       return 1;
+       return true;
 
       /* Call far, absolute indirect (/3) */
       if ((insn[1] & 0x38) == 0x18)
-       return 1;
+       return true;
     }
 
-  return 0;
+  return false;
 }
 
-static int
+static bool
 amd64_ret_p (const struct amd64_insn *details)
 {
   /* NOTE: gcc can emit "repz ; ret".  */
@@ -1742,32 +1742,32 @@ amd64_ret_p (const struct amd64_insn *details)
     case 0xca: /* ret far, pop N bytes */
     case 0xcb: /* ret far */
     case 0xcf: /* iret */
-      return 1;
+      return true;
 
     default:
-      return 0;
+      return false;
     }
 }
 
-static int
+static bool
 amd64_call_p (const struct amd64_insn *details)
 {
   const gdb_byte *insn = &details->raw_insn[details->opcode_offset];
 
   if (amd64_absolute_call_p (details))
-    return 1;
+    return true;
 
   /* call near, relative */
   if (insn[0] == 0xe8)
-    return 1;
+    return true;
 
-  return 0;
+  return false;
 }
 
-/* Return non-zero if INSN is a system call, and set *LENGTHP to its
-   length in bytes.  Otherwise, return zero.  */
+/* Return true if INSN is a system call, and set *LENGTHP to its
+   length in bytes.  Otherwise, return false.  */
 
-static int
+static bool
 amd64_syscall_p (const struct amd64_insn *details, int *lengthp)
 {
   const gdb_byte *insn = &details->raw_insn[details->opcode_offset];
@@ -1775,18 +1775,18 @@ amd64_syscall_p (const struct amd64_insn *details, int *lengthp)
   if (insn[0] == 0x0f && insn[1] == 0x05)
     {
       *lengthp = 2;
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
 /* Classify the instruction at ADDR using PRED.
    Throw an error if the memory can't be read.  */
 
-static int
+static bool
 amd64_classify_insn_at (struct gdbarch *gdbarch, CORE_ADDR addr,
-                       int (*pred) (const struct amd64_insn *))
+                       bool (*pred) (const struct amd64_insn *))
 {
   struct amd64_insn details;
 
@@ -1795,14 +1795,12 @@ amd64_classify_insn_at (struct gdbarch *gdbarch, CORE_ADDR addr,
   read_code (addr, buf.data (), buf.size ());
   amd64_get_insn_details (buf.data (), &details);
 
-  int classification = pred (&details);
-
-  return classification;
+  return pred (&details);
 }
 
 /* The gdbarch insn_is_call method.  */
 
-static int
+static bool
 amd64_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   return amd64_classify_insn_at (gdbarch, addr, amd64_call_p);
@@ -1810,7 +1808,7 @@ amd64_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
 
 /* The gdbarch insn_is_ret method.  */
 
-static int
+static bool
 amd64_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   return amd64_classify_insn_at (gdbarch, addr, amd64_ret_p);
@@ -1818,7 +1816,7 @@ amd64_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
 
 /* The gdbarch insn_is_jump method.  */
 
-static int
+static bool
 amd64_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   return amd64_classify_insn_at (gdbarch, addr, amd64_jmp_p);
index 3a0e3f35f2caa0e19fd572da56f04cb58429a853..4fcd82f01111f09e0bc7e4a431b391645b715c85 100644 (file)
@@ -903,19 +903,22 @@ default_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
   return !(language_pass_by_reference (type).trivially_copyable);
 }
 
-int default_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
+bool
+default_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  return 0;
+  return false;
 }
 
-int default_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
+bool
+default_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  return 0;
+  return false;
 }
 
-int default_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
+bool
+default_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
-  return 0;
+  return false;
 }
 
 /*  See arch-utils.h.  */
index 66a5c89744906ae4d530f7b7862de2203b5a04d5..4d1c76a69bfe034c8754ea5845d8bf92098024a7 100644 (file)
@@ -324,9 +324,9 @@ extern const char *default_auto_wide_charset (void);
 extern bool default_return_in_first_hidden_param_p (struct gdbarch *,
                                                    struct type *);
 
-extern int default_insn_is_call (struct gdbarch *, CORE_ADDR);
-extern int default_insn_is_ret (struct gdbarch *, CORE_ADDR);
-extern int default_insn_is_jump (struct gdbarch *, CORE_ADDR);
+extern bool default_insn_is_call (struct gdbarch *, CORE_ADDR);
+extern bool default_insn_is_ret (struct gdbarch *, CORE_ADDR);
+extern bool default_insn_is_jump (struct gdbarch *, CORE_ADDR);
 
 /* Default implementation of gdbarch_program_breakpoint_here_p.  */
 extern bool default_program_breakpoint_here_p (struct gdbarch *gdbarch,
index 52211c138022638fc6939f286634e1fdc438b301..2c6da958bdddd50f99c34ef0218fca415bf396a6 100644 (file)
@@ -4899,7 +4899,7 @@ set_gdbarch_ravenscar_ops (struct gdbarch *gdbarch,
   gdbarch->ravenscar_ops = ravenscar_ops;
 }
 
-int
+bool
 gdbarch_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_assert (gdbarch != NULL);
@@ -4916,7 +4916,7 @@ set_gdbarch_insn_is_call (struct gdbarch *gdbarch,
   gdbarch->insn_is_call = insn_is_call;
 }
 
-int
+bool
 gdbarch_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_assert (gdbarch != NULL);
@@ -4933,7 +4933,7 @@ set_gdbarch_insn_is_ret (struct gdbarch *gdbarch,
   gdbarch->insn_is_ret = insn_is_ret;
 }
 
-int
+bool
 gdbarch_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_assert (gdbarch != NULL);
index 03b4ee0561cbb366840c4e6cd760a1c80d5f5ccf..db7cdb437fd5d2499d53f7e5f6ce2b2d60e84422 100644 (file)
@@ -1574,22 +1574,22 @@ extern void set_gdbarch_core_info_proc (struct gdbarch *gdbarch, gdbarch_core_in
 extern struct ravenscar_arch_ops * gdbarch_ravenscar_ops (struct gdbarch *gdbarch);
 extern void set_gdbarch_ravenscar_ops (struct gdbarch *gdbarch, struct ravenscar_arch_ops * ravenscar_ops);
 
-/* Return non-zero if the instruction at ADDR is a call; zero otherwise. */
+/* Return true if the instruction at ADDR is a call; false otherwise. */
 
-typedef int (gdbarch_insn_is_call_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
-extern int gdbarch_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr);
+typedef bool (gdbarch_insn_is_call_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
+extern bool gdbarch_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern void set_gdbarch_insn_is_call (struct gdbarch *gdbarch, gdbarch_insn_is_call_ftype *insn_is_call);
 
-/* Return non-zero if the instruction at ADDR is a return; zero otherwise. */
+/* Return true if the instruction at ADDR is a return; false otherwise. */
 
-typedef int (gdbarch_insn_is_ret_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
-extern int gdbarch_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr);
+typedef bool (gdbarch_insn_is_ret_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
+extern bool gdbarch_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern void set_gdbarch_insn_is_ret (struct gdbarch *gdbarch, gdbarch_insn_is_ret_ftype *insn_is_ret);
 
-/* Return non-zero if the instruction at ADDR is a jump; zero otherwise. */
+/* Return true if the instruction at ADDR is a jump; false otherwise. */
 
-typedef int (gdbarch_insn_is_jump_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
-extern int gdbarch_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr);
+typedef bool (gdbarch_insn_is_jump_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
+extern bool gdbarch_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr);
 extern void set_gdbarch_insn_is_jump (struct gdbarch *gdbarch, gdbarch_insn_is_jump_ftype *insn_is_jump);
 
 /* Return true if there's a program/permanent breakpoint planted in
index 1b1e73bbe66c627791df5486e0179c46970b4f8a..77c82c300441efc819186351fbc056dcda74b4a9 100644 (file)
@@ -2507,9 +2507,9 @@ Ravenscar arch-dependent ops.
 
 Method(
     comment="""
-Return non-zero if the instruction at ADDR is a call; zero otherwise.
+Return true if the instruction at ADDR is a call; false otherwise.
 """,
-    type="int",
+    type="bool",
     name="insn_is_call",
     params=[("CORE_ADDR", "addr")],
     predefault="default_insn_is_call",
@@ -2518,9 +2518,9 @@ Return non-zero if the instruction at ADDR is a call; zero otherwise.
 
 Method(
     comment="""
-Return non-zero if the instruction at ADDR is a return; zero otherwise.
+Return true if the instruction at ADDR is a return; false otherwise.
 """,
-    type="int",
+    type="bool",
     name="insn_is_ret",
     params=[("CORE_ADDR", "addr")],
     predefault="default_insn_is_ret",
@@ -2529,9 +2529,9 @@ Return non-zero if the instruction at ADDR is a return; zero otherwise.
 
 Method(
     comment="""
-Return non-zero if the instruction at ADDR is a jump; zero otherwise.
+Return true if the instruction at ADDR is a jump; false otherwise.
 """,
-    type="int",
+    type="bool",
     name="insn_is_jump",
     params=[("CORE_ADDR", "addr")],
     predefault="default_insn_is_jump",
index e52140a3c13fe943e487e4dd9445eee01451f2bf..9cee112facd8cf1c7622863ef0c146d8f97e32fa 100644 (file)
@@ -556,65 +556,65 @@ i386_skip_prefixes (gdb_byte *insn, size_t max_len)
   return NULL;
 }
 
-static int
+static bool
 i386_absolute_jmp_p (const gdb_byte *insn)
 {
   /* jmp far (absolute address in operand).  */
   if (insn[0] == 0xea)
-    return 1;
+    return true;
 
   if (insn[0] == 0xff)
     {
       /* jump near, absolute indirect (/4).  */
       if ((insn[1] & 0x38) == 0x20)
-       return 1;
+       return true;
 
       /* jump far, absolute indirect (/5).  */
       if ((insn[1] & 0x38) == 0x28)
-       return 1;
+       return true;
     }
 
-  return 0;
+  return false;
 }
 
-/* Return non-zero if INSN is a jump, zero otherwise.  */
+/* Return true if INSN is a jump, false otherwise.  */
 
-static int
+static bool
 i386_jmp_p (const gdb_byte *insn)
 {
   /* jump short, relative.  */
   if (insn[0] == 0xeb)
-    return 1;
+    return true;
 
   /* jump near, relative.  */
   if (insn[0] == 0xe9)
-    return 1;
+    return true;
 
   return i386_absolute_jmp_p (insn);
 }
 
-static int
+static bool
 i386_absolute_call_p (const gdb_byte *insn)
 {
   /* call far, absolute.  */
   if (insn[0] == 0x9a)
-    return 1;
+    return true;
 
   if (insn[0] == 0xff)
     {
       /* Call near, absolute indirect (/2).  */
       if ((insn[1] & 0x38) == 0x10)
-       return 1;
+       return true;
 
       /* Call far, absolute indirect (/3).  */
       if ((insn[1] & 0x38) == 0x18)
-       return 1;
+       return true;
     }
 
-  return 0;
+  return false;
 }
 
-static int
+static bool
 i386_ret_p (const gdb_byte *insn)
 {
   switch (insn[0])
@@ -624,30 +624,30 @@ i386_ret_p (const gdb_byte *insn)
     case 0xca: /* ret far, pop N bytes.  */
     case 0xcb: /* ret far */
     case 0xcf: /* iret */
-      return 1;
+      return true;
 
     default:
-      return 0;
+      return false;
     }
 }
 
-static int
+static bool
 i386_call_p (const gdb_byte *insn)
 {
   if (i386_absolute_call_p (insn))
-    return 1;
+    return true;
 
   /* call near, relative.  */
   if (insn[0] == 0xe8)
-    return 1;
+    return true;
 
-  return 0;
+  return false;
 }
 
-/* Return non-zero if INSN is a system call, and set *LENGTHP to its
-   length in bytes.  Otherwise, return zero.  */
+/* Return true if INSN is a system call, and set *LENGTHP to its
+   length in bytes.  Otherwise, return false.  */
 
-static int
+static bool
 i386_syscall_p (const gdb_byte *insn, int *lengthp)
 {
   /* Is it 'int $0x80'?  */
@@ -658,15 +658,15 @@ i386_syscall_p (const gdb_byte *insn, int *lengthp)
       || (insn[0] == 0x0f && insn[1] == 0x05))
     {
       *lengthp = 2;
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
 /* The gdbarch insn_is_call method.  */
 
-static int
+static bool
 i386_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_byte buf[I386_MAX_INSN_LEN], *insn;
@@ -679,7 +679,7 @@ i386_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
 
 /* The gdbarch insn_is_ret method.  */
 
-static int
+static bool
 i386_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_byte buf[I386_MAX_INSN_LEN], *insn;
@@ -692,7 +692,7 @@ i386_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
 
 /* The gdbarch insn_is_jump method.  */
 
-static int
+static bool
 i386_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_byte buf[I386_MAX_INSN_LEN], *insn;
index b304b7764c26ba150258445076dffe7d9404ace0..f7e207d02ec3b989be20b43c8bf73154ca4eefa3 100644 (file)
@@ -1000,8 +1000,8 @@ z80_overlay_update (struct obj_section *osect)
       }
 }
 
-/* Return non-zero if the instruction at ADDR is a call; zero otherwise.  */
-static int
+/* Return true if the instruction at ADDR is a call; false otherwise.  */
+static bool
 z80_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_byte buf[8];
@@ -1015,13 +1015,13 @@ z80_insn_is_call (struct gdbarch *gdbarch, CORE_ADDR addr)
       case insn_call_nn:
       case insn_call_cc_nn:
       case insn_rst_n:
-       return 1;
+       return true;
       }
-  return 0;
+  return false;
 }
 
-/* Return non-zero if the instruction at ADDR is a return; zero otherwise. */
-static int
+/* Return true if the instruction at ADDR is a return; false otherwise. */
+static bool
 z80_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_byte buf[8];
@@ -1034,13 +1034,13 @@ z80_insn_is_ret (struct gdbarch *gdbarch, CORE_ADDR addr)
       {
       case insn_ret:
       case insn_ret_cc:
-       return 1;
+       return true;
       }
-  return 0;
+  return false;
 }
 
-/* Return non-zero if the instruction at ADDR is a jump; zero otherwise.  */
-static int
+/* Return true if the instruction at ADDR is a jump; false otherwise.  */
+static bool
 z80_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   gdb_byte buf[8];
@@ -1057,9 +1057,9 @@ z80_insn_is_jump (struct gdbarch *gdbarch, CORE_ADDR addr)
       case insn_jr_d:
       case insn_jr_cc_d:
       case insn_djnz_d:
-       return 1;
+       return true;
       }
-  return 0;
+  return false;
 }
 
 static const struct frame_unwind_legacy z80_frame_unwind (