[5/6,gdb/symtab] Replace TYPE_ALLOC + B_CLRALL with TYPE_ZALLOC
Checks
Commit Message
I noticed some cases of TYPE_ALLOC followed by B_CLRALL.
Replace these with TYPE_ZALLOC.
Tested on x86_64-linux.
---
gdb/dwarf2/read.c | 12 ++++--------
gdb/stabsread.c | 15 +++++----------
2 files changed, 9 insertions(+), 18 deletions(-)
Comments
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> I noticed some cases of TYPE_ALLOC followed by B_CLRALL.
Tom> Replace these with TYPE_ZALLOC.
Looks good.
I wonder if B_CLRALL is still used anywhere after this.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
On 8/30/23 22:21, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Tom> I noticed some cases of TYPE_ALLOC followed by B_CLRALL.
> Tom> Replace these with TYPE_ZALLOC.
>
> Looks good.
> I wonder if B_CLRALL is still used anywhere after this.
I guess not:
...
$ find gdb* -type f | egrep -v ChangeLog | xargs grep B_CLR
gdb/gdbtypes.h:#define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7)))
gdb/gdbtypes.h:#define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x))
...
Thanks,
- Tom
@@ -12064,16 +12064,13 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_FIELD_PRIVATE_BITS (type) =
- (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
- B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
+ (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
TYPE_FIELD_PROTECTED_BITS (type) =
- (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
- B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
+ (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
TYPE_FIELD_IGNORE_BITS (type) =
- (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
- B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
+ (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
}
/* If the type has baseclasses, allocate and clear a bit vector for
@@ -12084,9 +12081,8 @@ dwarf2_attach_fields_to_type (struct field_info *fip, struct type *type,
unsigned char *pointer;
ALLOCATE_CPLUS_STRUCT_TYPE (type);
- pointer = (unsigned char *) TYPE_ALLOC (type, num_bytes);
+ pointer = (unsigned char *) TYPE_ZALLOC (type, num_bytes);
TYPE_FIELD_VIRTUAL_BITS (type) = pointer;
- B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), fip->baseclasses.size ());
TYPE_N_BASECLASSES (type) = fip->baseclasses.size ();
}
@@ -3067,19 +3067,17 @@ read_baseclasses (struct stab_field_info *fip, const char **pp,
/* Some stupid compilers have trouble with the following, so break
it up into simpler expressions. */
TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
- TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (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_ALLOC (type, num_bytes);
+ pointer = (char *) TYPE_ZALLOC (type, num_bytes);
TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
}
#endif /* 0 */
- B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
-
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
{
newobj = OBSTACK_ZALLOC (&fip->obstack, struct stabs_nextfield);
@@ -3295,16 +3293,13 @@ attach_fields_to_type (struct stab_field_info *fip, struct type *type,
ALLOCATE_CPLUS_STRUCT_TYPE (type);
TYPE_FIELD_PRIVATE_BITS (type) =
- (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
- B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
+ (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
TYPE_FIELD_PROTECTED_BITS (type) =
- (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
- B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
+ (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
TYPE_FIELD_IGNORE_BITS (type) =
- (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
- B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
+ (B_TYPE *) TYPE_ZALLOC (type, B_BYTES (nfields));
}
/* Copy the saved-up fields into the field vector. Start from the