[PATCHv2 04/10] gdb: additional changes to make use of type_instance_flags more

Andrew Burgess
2020-08-26T14:49:37Z

Further updates to make use of type_instance_flags.

gdb/ChangeLog:

* avr-tdep.c (avr_address_class_type_flags): Update return type.
(avr_address_class_type_flags_to_name): Update argument types.
(avr_address_class_name_to_type_flags): Update return type and
argument types.
* ft32-tdep.c (ft32_address_class_type_flags): Update return type.
(ft32_address_class_type_flags_to_name): Update argument types.
(ft32_address_class_name_to_type_flags): Update return type and
argument types.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (address_class_type_flags_to_name): Update argument
types.
* s390-tdep.c (s390_address_class_type_flags): Update return type.
(s390_address_class_type_flags_to_name): Update argument types.
(s390_address_class_name_to_type_flags): Update return type and
argument types.
---
gdb/ChangeLog | 19 +++++++++++++++++++
gdb/avr-tdep.c | 13 +++++++------
gdb/ft32-tdep.c | 13 +++++++------
gdb/gdbarch.c | 2 +-
gdb/gdbarch.h | 4 ++--
gdb/gdbarch.sh | 2 +-
gdb/s390-tdep.c | 13 +++++++------
7 files changed, 44 insertions(+), 22 deletions(-)

diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 74ab531711e..0148f4e4db2 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -1372,7 +1372,7 @@ avr_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
This method maps DW_AT_address_class attributes to a
type_instance_flag_value. */

-static int
+static type_instance_flags
avr_address_class_type_flags (int byte_size, int dwarf2_addr_class)
{
/* The value 1 of the DW_AT_address_class attribute corresponds to the
@@ -1389,7 +1389,8 @@ avr_address_class_type_flags (int byte_size, int dwarf2_addr_class)
Convert a type_instance_flag_value to an address space qualifier. */

static const char*
-avr_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+avr_address_class_type_flags_to_name (struct gdbarch *gdbarch,
+ type_instance_flags type_flags)
{
if (type_flags & AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH)
return "flash";
@@ -1401,18 +1402,18 @@ avr_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)

Convert an address space qualifier to a type_instance_flag_value. */

-static int
+static bool
avr_address_class_name_to_type_flags (struct gdbarch *gdbarch,
const char* name,
- int *type_flags_ptr)
+ type_instance_flags *type_flags_ptr)
{
if (strcmp (name, "flash") == 0)
{
*type_flags_ptr = AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH;
- return 1;
+ return true;
}
else
- return 0;
+ return false;
}

/* Initialize the gdbarch structure for the AVR's. */
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 99ef69de770..8ce16c06505 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -341,7 +341,7 @@ ft32_pointer_to_address (struct gdbarch *gdbarch,
This method maps DW_AT_address_class attributes to a
type_instance_flag_value. */

-static int
+static type_instance_flags
ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class)
{
/* The value 1 of the DW_AT_address_class attribute corresponds to the
@@ -357,7 +357,8 @@ ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class)
Convert a type_instance_flag_value to an address space qualifier. */

static const char*
-ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch,
+ type_instance_flags type_flags)
{
if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
return "flash";
@@ -369,18 +370,18 @@ ft32_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)

Convert an address space qualifier to a type_instance_flag_value. */

-static int
+static bool
ft32_address_class_name_to_type_flags (struct gdbarch *gdbarch,
const char* name,
- int *type_flags_ptr)
+ type_instance_flags *type_flags_ptr)
{
if (strcmp (name, "flash") == 0)
{
*type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
- return 1;
+ return true;
}
else
- return 0;
+ return false;
}

/* Given a return value in `regbuf' with a type `valtype',
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 2be959ecfc9..a3a67020078 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -3526,7 +3526,7 @@ gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch)
}

const char *
-gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->address_class_type_flags_to_name != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 8a4a384fda9..5ac4f5495c4 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -854,8 +854,8 @@ extern void set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, gdbar

extern int gdbarch_address_class_type_flags_to_name_p (struct gdbarch *gdbarch);

-typedef const char * (gdbarch_address_class_type_flags_to_name_ftype) (struct gdbarch *gdbarch, int type_flags);
-extern const char * gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags);
+typedef const char * (gdbarch_address_class_type_flags_to_name_ftype) (struct gdbarch *gdbarch, type_instance_flags type_flags);
+extern const char * gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, type_instance_flags type_flags);
extern void set_gdbarch_address_class_type_flags_to_name (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_to_name_ftype *address_class_type_flags_to_name);

/* Execute vendor-specific DWARF Call Frame Instruction. OP is the instruction.
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 7e9204119bd..a64afb5a3d2 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -690,7 +690,7 @@ v;int;cannot_step_breakpoint;;;0;0;;0
# non-steppable watchpoints.
v;int;have_nonsteppable_watchpoint;;;0;0;;0
F;type_instance_flags;address_class_type_flags;int byte_size, int dwarf2_addr_class;byte_size, dwarf2_addr_class
-M;const char *;address_class_type_flags_to_name;int type_flags;type_flags
+M;const char *;address_class_type_flags_to_name;type_instance_flags type_flags;type_flags
# Execute vendor-specific DWARF Call Frame Instruction. OP is the instruction.
# FS are passed from the generic execute_cfa_program function.
m;bool;execute_dwarf_cfa_vendor_op;gdb_byte op, struct dwarf2_frame_state *fs;op, fs;;default_execute_dwarf_cfa_vendor_op;;0
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 65cb23705d2..49a507f7c2d 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1583,7 +1583,7 @@ s390_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
/* Implement addr_class_type_flags gdbarch method.
Only used for ABI_LINUX_ZSERIES. */

-static int
+static type_instance_flags
s390_address_class_type_flags (int byte_size, int dwarf2_addr_class)
{
if (byte_size == 4)
@@ -1596,7 +1596,8 @@ s390_address_class_type_flags (int byte_size, int dwarf2_addr_class)
Only used for ABI_LINUX_ZSERIES. */

static const char *
-s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
+s390_address_class_type_flags_to_name (struct gdbarch *gdbarch,
+ type_instance_flags type_flags)
{
if (type_flags & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
return "mode32";
@@ -1607,18 +1608,18 @@ s390_address_class_type_flags_to_name (struct gdbarch *gdbarch, int type_flags)
/* Implement addr_class_name_to_type_flags gdbarch method.
Only used for ABI_LINUX_ZSERIES. */

-static int
+static bool
s390_address_class_name_to_type_flags (struct gdbarch *gdbarch,
const char *name,
- int *type_flags_ptr)
+ type_instance_flags *type_flags_ptr)
{
if (strcmp (name, "mode32") == 0)
{
*type_flags_ptr = TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
- return 1;
+ return true;
}
else
- return 0;
+ return false;
}

/* Inferior function calls. */
--
2.25.4