Use enum for gdbarch's call_dummy_location
authorTom Tromey <tromey@adacore.com>
Mon, 12 Sep 2022 13:04:21 +0000 (07:04 -0600)
committerTom Tromey <tromey@adacore.com>
Mon, 31 Oct 2022 15:04:11 +0000 (09:04 -0600)
This changes gdbarch to use an enum for call_dummy_location, providing
a little more type safety.

gdb/gdbarch-components.py
gdb/gdbarch-gen.h
gdb/gdbarch.c
gdb/gdbarch.h
gdb/inferior.h

index c997a709cbb3f7600d246eefaf71dd088557098a..b2c7b784761f03060c037147d393d799274c19e1 100644 (file)
@@ -647,7 +647,7 @@ Method(
 )
 
 Value(
-    type="int",
+    type="enum call_dummy_location_type",
     name="call_dummy_location",
     predefault="AT_ENTRY_POINT",
     invalid=False,
index 840de585869e35a7a4ba47e727d1dfd61a3b1309..e0d7a08ff6a3dd9254336da299b9b5ec74c09c98 100644 (file)
@@ -331,8 +331,8 @@ typedef CORE_ADDR (gdbarch_push_dummy_call_ftype) (struct gdbarch *gdbarch, stru
 extern CORE_ADDR gdbarch_push_dummy_call (struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr);
 extern void set_gdbarch_push_dummy_call (struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call);
 
-extern int gdbarch_call_dummy_location (struct gdbarch *gdbarch);
-extern void set_gdbarch_call_dummy_location (struct gdbarch *gdbarch, int call_dummy_location);
+extern enum call_dummy_location_type gdbarch_call_dummy_location (struct gdbarch *gdbarch);
+extern void set_gdbarch_call_dummy_location (struct gdbarch *gdbarch, enum call_dummy_location_type call_dummy_location);
 
 extern bool gdbarch_push_dummy_code_p (struct gdbarch *gdbarch);
 
index 6ff4fee5b3f201b89239429ba05731838121dd5e..9d929da6da927acd03cf79f2b8192d7e189083da 100644 (file)
@@ -97,7 +97,7 @@ struct gdbarch
   gdbarch_dummy_id_ftype *dummy_id = default_dummy_id;
   int deprecated_fp_regnum = -1;
   gdbarch_push_dummy_call_ftype *push_dummy_call = nullptr;
-  int call_dummy_location = AT_ENTRY_POINT;
+  enum call_dummy_location_type call_dummy_location = AT_ENTRY_POINT;
   gdbarch_push_dummy_code_ftype *push_dummy_code = nullptr;
   gdbarch_code_of_frame_writable_ftype *code_of_frame_writable = default_code_of_frame_writable;
   gdbarch_print_registers_info_ftype *print_registers_info = default_print_registers_info;
@@ -2229,7 +2229,7 @@ set_gdbarch_push_dummy_call (struct gdbarch *gdbarch,
   gdbarch->push_dummy_call = push_dummy_call;
 }
 
-int
+enum call_dummy_location_type
 gdbarch_call_dummy_location (struct gdbarch *gdbarch)
 {
   gdb_assert (gdbarch != NULL);
@@ -2241,7 +2241,7 @@ gdbarch_call_dummy_location (struct gdbarch *gdbarch)
 
 void
 set_gdbarch_call_dummy_location (struct gdbarch *gdbarch,
-                                 int call_dummy_location)
+                                 enum call_dummy_location_type call_dummy_location)
 {
   gdbarch->call_dummy_location = call_dummy_location;
 }
index 2f1c7399d78ab8222b7944e54562fccf3d644b53..f2ba5f97765f3f10fa6d28ecb1fb1ee9d24f10d7 100644 (file)
@@ -149,6 +149,13 @@ using read_core_file_mappings_loop_ftype =
                           const char *filename,
                           const bfd_build_id *build_id)>;
 
+/* Possible values for gdbarch_call_dummy_location.  */
+enum call_dummy_location_type
+{
+  ON_STACK,
+  AT_ENTRY_POINT,
+};
+
 #include "gdbarch-gen.h"
 
 /* An internal function that should _only_ be called from gdbarch_tdep.
index 8877be38e369cf792fd62619c009d21c2a3f018e..69525a2e053f73ac2be9ec17a6ec2e0d493dd64b 100644 (file)
@@ -282,9 +282,6 @@ enum stop_kind
   };
 
 \f
-/* Possible values for gdbarch_call_dummy_location.  */
-#define ON_STACK 1
-#define AT_ENTRY_POINT 4
 
 /* Base class for target-specific inferior data.  */