aboutsummaryrefslogtreecommitdiff
path: root/gdb/stabsread.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-09-21 10:21:04 -0600
committerTom Tromey <tromey@adacore.com>2023-11-21 14:52:05 -0700
commit61461a5b41fb660ef11a7a9ffe457ea52b5c2a6a (patch)
tree1455a4495a78e319930a706c1dc6cf30689f248c /gdb/stabsread.c
parent5ffb4736f079c3dbc01be4b6cb961a60094ee18f (diff)
downloadgdb-61461a5b41fb660ef11a7a9ffe457ea52b5c2a6a.zip
gdb-61461a5b41fb660ef11a7a9ffe457ea52b5c2a6a.tar.gz
gdb-61461a5b41fb660ef11a7a9ffe457ea52b5c2a6a.tar.bz2
Remove byte vectors from cplus_struct_type
This removes some byte vectors from cplus_struct_type, moving the information into bitfields in holes in struct field. A new 'enum accessibility' is added to hold some of this information. A similar enum is removed from c-varobj.c. Note that the stabs reader treats "ignored" as an accessibility. However, the stabs texinfo documents this as a public field that is optimized out -- unfortunately nobody has updated the stabs reader to use the better value-based optimized-out machinery. I looked and apparently gcc never emitted this visibility value, so whatever compiler generated this stab is unknown. I left a comment in gdbtypes.h to this effect. Acked-By: Simon Marchi <simon.marchi@efficios.com> Reviewed-by: Keith Seitz <keiths@redhat.com>
Diffstat (limited to 'gdb/stabsread.c')
-rw-r--r--gdb/stabsread.c123
1 files changed, 42 insertions, 81 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 4011475..4d5ae10 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -65,11 +65,6 @@ struct stabs_nextfield
{
struct stabs_nextfield *next;
- /* This is the raw visibility from the stab. It is not checked
- for being one of the visibilities we recognize, so code which
- examines this field better be able to deal. */
- int visibility;
-
struct field field;
};
@@ -2789,7 +2784,7 @@ read_cpp_abbrev (struct stab_field_info *fip, const char **pp,
}
/* This field is unpacked. */
fip->list->field.set_bitsize (0);
- fip->list->visibility = VISIBILITY_PRIVATE;
+ fip->list->field.set_accessibility (accessibility::PRIVATE);
}
else
{
@@ -2814,15 +2809,42 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp,
*pp = p + 1;
/* This means we have a visibility for a field coming. */
+ int visibility;
if (**pp == '/')
{
(*pp)++;
- fip->list->visibility = *(*pp)++;
+ visibility = *(*pp)++;
}
else
{
/* normal dbx-style format, no explicit visibility */
- fip->list->visibility = VISIBILITY_PUBLIC;
+ visibility = VISIBILITY_PUBLIC;
+ }
+
+ switch (visibility)
+ {
+ case VISIBILITY_PRIVATE:
+ fip->list->field.set_accessibility (accessibility::PRIVATE);
+ break;
+
+ case VISIBILITY_PROTECTED:
+ fip->list->field.set_accessibility (accessibility::PROTECTED);
+ break;
+
+ case VISIBILITY_IGNORE:
+ fip->list->field.set_ignored ();
+ break;
+
+ case VISIBILITY_PUBLIC:
+ break;
+
+ default:
+ /* Unknown visibility. Complain and treat it as public. */
+ {
+ complaint (_("Unknown visibility `%c' for field"),
+ visibility);
+ }
+ break;
}
fip->list->field.set_type (read_type (pp, objfile));
@@ -2892,7 +2914,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp,
for dbx compatibility. */
/* Ignore this field. */
- fip->list->visibility = VISIBILITY_IGNORE;
+ fip->list->field.set_ignored ();
}
else
{
@@ -3066,21 +3088,6 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
return 0;
}
-#if 0
- /* Some stupid compilers have trouble with the following, so break
- it up into simpler expressions. */
- TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
- TYPE_ZALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
-#else
- {
- int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
- char *pointer;
-
- pointer = (char *) TYPE_ZALLOC (type, num_bytes);
- TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
- }
-#endif /* 0 */
-
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
{
newobj = OBSTACK_ZALLOC (&fip->obstack, struct stabs_nextfield);
@@ -3097,7 +3104,7 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
/* Nothing to do. */
break;
case '1':
- SET_TYPE_FIELD_VIRTUAL (type, i);
+ newobj->field.set_virtual ();
break;
default:
/* Unknown character. Complain and treat it as non-virtual. */
@@ -3108,11 +3115,15 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
}
++(*pp);
- newobj->visibility = *(*pp)++;
- switch (newobj->visibility)
+ int visibility = *(*pp)++;
+ switch (visibility)
{
case VISIBILITY_PRIVATE:
+ newobj->field.set_accessibility (accessibility::PRIVATE);
+ break;
case VISIBILITY_PROTECTED:
+ newobj->field.set_accessibility (accessibility::PROTECTED);
+ break;
case VISIBILITY_PUBLIC:
break;
default:
@@ -3120,8 +3131,7 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
public. */
{
complaint (_("Unknown visibility `%c' for baseclass"),
- newobj->visibility);
- newobj->visibility = VISIBILITY_PUBLIC;
+ visibility);
}
}
@@ -3268,43 +3278,19 @@ attach_fields_to_type (struct stab_field_info *fip, struct type *type,
struct objfile *objfile)
{
int nfields = 0;
- int non_public_fields = 0;
struct stabs_nextfield *scan;
- /* Count up the number of fields that we have, as well as taking note of
- whether or not there are any non-public fields, which requires us to
- allocate and build the private_field_bits and protected_field_bits
- bitfields. */
+ /* Count up the number of fields that we have. */
for (scan = fip->list; scan != NULL; scan = scan->next)
- {
- nfields++;
- if (scan->visibility != VISIBILITY_PUBLIC)
- {
- non_public_fields++;
- }
- }
+ nfields++;
/* Now we know how many fields there are, and whether or not there are any
non-public fields. Record the field count, allocate space for the
- array of fields, and create blank visibility bitfields if necessary. */
+ array of fields. */
type->alloc_fields (nfields);
- if (non_public_fields)
- {
- ALLOCATE_CPLUS_STRUCT_TYPE (type);
-
- TYPE_FIELD_PRIVATE_BITS (type) =
- (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
-
- TYPE_FIELD_PROTECTED_BITS (type) =
- (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
-
- TYPE_FIELD_IGNORE_BITS (type) =
- (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
- }
-
/* Copy the saved-up fields into the field vector. Start from the
head of the list, adding to the tail of the field array, so that
they end up in the same order in the array in which they were
@@ -3313,31 +3299,6 @@ attach_fields_to_type (struct stab_field_info *fip, struct type *type,
while (nfields-- > 0)
{
type->field (nfields) = fip->list->field;
- switch (fip->list->visibility)
- {
- case VISIBILITY_PRIVATE:
- SET_TYPE_FIELD_PRIVATE (type, nfields);
- break;
-
- case VISIBILITY_PROTECTED:
- SET_TYPE_FIELD_PROTECTED (type, nfields);
- break;
-
- case VISIBILITY_IGNORE:
- SET_TYPE_FIELD_IGNORE (type, nfields);
- break;
-
- case VISIBILITY_PUBLIC:
- break;
-
- default:
- /* Unknown visibility. Complain and treat it as public. */
- {
- complaint (_("Unknown visibility `%c' for field"),
- fip->list->visibility);
- }
- break;
- }
fip->list = fip->list->next;
}
return 1;