summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-09-14 11:07:59 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-09-14 11:07:59 -0400
commit8f53807e5c957fb947fb8d61fc2583e2dcbd6f06 (patch)
tree649228e0a30a2999240fd9de4691f72a259dc536
parente46d3488de137cd5a01377513ff49e32595456af (diff)
downloadbinutils-gdb-8f53807e5c957fb947fb8d61fc2583e2dcbd6f06.tar.gz
gdb: add type::target_is_stub / type::set_target_is_stub
Add the `target_is_stub` and `set_target_is_stub` methods on `struct type`, in order to remove the `TYPE_TARGET_STUB` macro. In this patch, the macro is changed to use the getter, so all the call sites of the macro that are used as a setter are changed to use the setter method directly. The next patch will remove the macro completely. gdb/ChangeLog: * gdbtypes.h (struct type) <target_is_stub, set_target_is_stub>: New methods. (TYPE_TARGET_STUB): Use type::is_stub, change all write call sites to use type::set_target_is_stub. Change-Id: I9c71a89adc7ae8d018db9ee156f41c623be0484a
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/ctfread.c5
-rw-r--r--gdb/dwarf2/read.c2
-rw-r--r--gdb/fbsd-tdep.c4
-rw-r--r--gdb/gdbtypes.c8
-rw-r--r--gdb/gdbtypes.h14
-rw-r--r--gdb/linux-tdep.c6
-rw-r--r--gdb/mdebugread.c2
-rw-r--r--gdb/stabsread.c2
9 files changed, 34 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index aac62fceb0f..644d70038d0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2020-09-14 Simon Marchi <simon.marchi@efficios.com>
+ * gdbtypes.h (struct type) <target_is_stub, set_target_is_stub>:
+ New methods.
+ (TYPE_TARGET_STUB): Use type::is_stub, change all write call
+ sites to use type::set_target_is_stub.
+
+2020-09-14 Simon Marchi <simon.marchi@efficios.com>
+
* gdbtypes.h (TYPE_STUB): Remove, replace all
uses with type::is_stub.
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 14f64047fc1..81490baecc1 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -776,7 +776,7 @@ read_array_type (struct ctf_context *ccp, ctf_id_t tid)
{
range_type->bounds ()->high.set_undefined ();
TYPE_LENGTH (type) = 0;
- TYPE_TARGET_STUB (type) = 1;
+ type->set_target_is_stub (true);
}
else
TYPE_LENGTH (type) = ctf_type_size (fp, tid);
@@ -876,7 +876,8 @@ read_typedef_type (struct ctf_context *ccp, ctf_id_t tid,
TYPE_TARGET_TYPE (this_type) = target_type;
else
TYPE_TARGET_TYPE (this_type) = NULL;
- TYPE_TARGET_STUB (this_type) = TYPE_TARGET_TYPE (this_type) ? 1 : 0;
+
+ this_type->set_target_is_stub (TYPE_TARGET_TYPE (this_type) != nullptr);
return set_tid_type (objfile, tid, this_type);
}
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b9358331386..5f02acc01cb 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -17795,7 +17795,7 @@ read_typedef (struct die_info *die, struct dwarf2_cu *cu)
name = dwarf2_full_name (NULL, die, cu);
this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, name);
- TYPE_TARGET_STUB (this_type) = 1;
+ this_type->set_target_is_stub (true);
set_die_type (die, this_type, cu);
target_type = die_type (die, cu);
if (target_type != this_type)
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index ca397fa8e0f..a462e4d4ee2 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -1643,14 +1643,14 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch)
pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
TYPE_LENGTH (int32_type) * TARGET_CHAR_BIT, "__pid_t");
TYPE_TARGET_TYPE (pid_type) = int32_type;
- TYPE_TARGET_STUB (pid_type) = 1;
+ pid_type->set_target_is_stub (true);
/* __uid_t */
uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
TYPE_LENGTH (uint32_type) * TARGET_CHAR_BIT,
"__uid_t");
TYPE_TARGET_TYPE (uid_type) = uint32_type;
- TYPE_TARGET_STUB (uid_type) = 1;
+ pid_type->set_target_is_stub (true);
/* _reason */
reason_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 492061fa0a4..6dc073fb5ae 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -935,7 +935,7 @@ create_range_type (struct type *result_type, struct type *index_type,
result_type->set_code (TYPE_CODE_RANGE);
TYPE_TARGET_TYPE (result_type) = index_type;
if (index_type->is_stub ())
- TYPE_TARGET_STUB (result_type) = 1;
+ result_type->set_target_is_stub (true);
else
TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
@@ -1307,7 +1307,7 @@ create_array_type_with_stride (struct type *result_type,
/* TYPE_TARGET_STUB will take care of zero length arrays. */
if (TYPE_LENGTH (result_type) == 0)
- TYPE_TARGET_STUB (result_type) = 1;
+ result_type->set_target_is_stub (true);
return result_type;
}
@@ -2875,11 +2875,11 @@ check_typedef (struct type *type)
else if (type->code () == TYPE_CODE_RANGE)
{
TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
- TYPE_TARGET_STUB (type) = 0;
+ type->set_target_is_stub (false);
}
else if (type->code () == TYPE_CODE_ARRAY
&& update_static_array_size (type))
- TYPE_TARGET_STUB (type) = 0;
+ type->set_target_is_stub (false);
}
type = make_qualified_type (type, instance_flags, NULL);
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index bceb1b87605..c6c25183609 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -222,7 +222,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
based on the TYPE_LENGTH of the target type. Also, set for
TYPE_CODE_TYPEDEF. */
-#define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub)
+#define TYPE_TARGET_STUB(t) ((t)->target_is_stub ())
/* * This is a function type which appears to have a prototype. We
need this for function calls in order to tell us if it's necessary
@@ -841,7 +841,7 @@ struct main_type
unsigned int m_flag_unsigned : 1;
unsigned int m_flag_nosign : 1;
unsigned int m_flag_stub : 1;
- unsigned int flag_target_stub : 1;
+ unsigned int m_flag_target_stub : 1;
unsigned int flag_prototyped : 1;
unsigned int flag_varargs : 1;
unsigned int flag_vector : 1;
@@ -1092,6 +1092,16 @@ struct type
this->main_type->m_flag_stub = is_stub;
}
+ bool target_is_stub () const
+ {
+ return this->main_type->m_flag_target_stub;
+ }
+
+ void set_target_is_stub (bool target_is_stub)
+ {
+ this->main_type->m_flag_target_stub = target_is_stub;
+ }
+
/* * Return the dynamic property of the requested KIND from this type's
list of dynamic properties. */
dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 0b2b032dc74..a0d954a6206 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -266,20 +266,20 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
TYPE_LENGTH (int_type) * TARGET_CHAR_BIT, "__pid_t");
TYPE_TARGET_TYPE (pid_type) = int_type;
- TYPE_TARGET_STUB (pid_type) = 1;
+ pid_type->set_target_is_stub (true);
/* __uid_t */
uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
TYPE_LENGTH (uint_type) * TARGET_CHAR_BIT, "__uid_t");
TYPE_TARGET_TYPE (uid_type) = uint_type;
- TYPE_TARGET_STUB (uid_type) = 1;
+ uid_type->set_target_is_stub (true);
/* __clock_t */
clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
TYPE_LENGTH (long_type) * TARGET_CHAR_BIT,
"__clock_t");
TYPE_TARGET_TYPE (clock_type) = long_type;
- TYPE_TARGET_STUB (clock_type) = 1;
+ clock_type->set_target_is_stub (true);
/* _sifields */
sifields_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 735f00864d9..f68f4efdafa 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1866,7 +1866,7 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend,
/* TYPE_TARGET_STUB now takes care of the zero TYPE_LENGTH problem. */
if (TYPE_LENGTH (*tpp) == 0)
- TYPE_TARGET_STUB (t) = 1;
+ t->set_target_is_stub (true);
*tpp = t;
return 4 + off;
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 33a23cb61ee..752612f14e8 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1716,7 +1716,7 @@ again:
}
else
{
- TYPE_TARGET_STUB (type) = 1;
+ type->set_target_is_stub (true);
TYPE_TARGET_TYPE (type) = xtype;
}
}