Skip to content

Commit cc1defb

Browse files
committed
Allow really large fortran array bounds: TYPE_LENGTH to ULONGEST
This series is revisit of Siddhesh Poyarekar's patch from back in 2012. The last status on the patch is in the following gdb-patches thread: https://sourceware.org/ml/gdb-patches/2012-08/msg00562.html It appears that Tom approved the patch, but Jan had some issues with a compiler error that made the test fail on -m32 test runs. He wrote up a hand-tweaked .S file to deal with it. Siddesh said he would update tests. Then nothing. Siddesh and Jan have both moved on since. The patch originally required a large precursor patch to work. I have whittled this down to/rewritten the bare minimum, and this first patch is the result, changing the type of TYPE_LENGTH to ULONGEST from unsigned int. The majority of the changes involve changing printf format strings to use %s and pulongest instead of %d. gdb/ChangeLog: * ada-lang.c (ada_template_to_fixed_record_type_1): Use %s/pulongest for TYPE_LENGTH instead of %d in format strings. * ada-typerint.c (ada_print_type): Likewise. * amd64-windows-tdep.c (amd64_windows_store_arg_in_reg): Likewise. * compile/compile-c-support.c (generate_register_struct): Likewise. * gdbtypes.c (recursive_dump_type): Likewise. * gdbtypes.h (struct type) <length>: Change type to ULONGEST. * m2-typeprint.c (m2_array): Use %s/pulongest for TYPE_LENGTH instead of %d in format strings. * riscv-tdep.c (riscv_type_alignment): Cast second argument to std::min to ULONGEST. * symmisc.c (print_symbol): Use %s/pulongest for TYPE_LENGTH instead of %d in format strings. * tracepoint.c (info_scope_command): Likewise. * typeprint.c (print_offset_data::update) (print_offset_data::finish): Likewise. * xtensa-tdep.c (xtensa_store_return_value) (xtensa_push_dummy_call): Likewise.
1 parent 2487ef0 commit cc1defb

File tree

13 files changed

+54
-27
lines changed

13 files changed

+54
-27
lines changed

gdb/ChangeLog

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
2019-03-29 Keith Seitz <keiths@redhat.com>
2+
3+
* ada-lang.c (ada_template_to_fixed_record_type_1): Use
4+
%s/pulongest for TYPE_LENGTH instead of %d in format
5+
strings.
6+
* ada-typerint.c (ada_print_type): Likewise.
7+
* amd64-windows-tdep.c (amd64_windows_store_arg_in_reg): Likewise.
8+
* compile/compile-c-support.c (generate_register_struct): Likewise.
9+
* gdbtypes.c (recursive_dump_type): Likewise.
10+
* gdbtypes.h (struct type) <length>: Change type to ULONGEST.
11+
* m2-typeprint.c (m2_array): Use %s/pulongest for TYPE_LENGTH
12+
instead of %d in format strings.
13+
* riscv-tdep.c (riscv_type_alignment): Cast second argument
14+
to std::min to ULONGEST.
15+
* symmisc.c (print_symbol): Use %s/pulongest for TYPE_LENGTH
16+
instead of %d in format strings.
17+
* tracepoint.c (info_scope_command): Likewise.
18+
* typeprint.c (print_offset_data::update)
19+
(print_offset_data::finish): Likewise.
20+
* xtensa-tdep.c (xtensa_store_return_value)
21+
(xtensa_push_dummy_call): Likewise.
22+
123
2019-03-28 Jon Turney <jon.turney@dronecode.org.uk>
224

325
* windows-nat.c (display_selector): Fixed format specifications

gdb/ada-lang.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8500,11 +8500,11 @@ ada_template_to_fixed_record_type_1 (struct type *type,
85008500
if (TYPE_LENGTH (type) <= 0)
85018501
{
85028502
if (TYPE_NAME (rtype))
8503-
warning (_("Invalid type size for `%s' detected: %d."),
8504-
TYPE_NAME (rtype), TYPE_LENGTH (type));
8503+
warning (_("Invalid type size for `%s' detected: %s."),
8504+
TYPE_NAME (rtype), pulongest (TYPE_LENGTH (type)));
85058505
else
8506-
warning (_("Invalid type size for <unnamed> detected: %d."),
8507-
TYPE_LENGTH (type));
8506+
warning (_("Invalid type size for <unnamed> detected: %s."),
8507+
pulongest (TYPE_LENGTH (type)));
85088508
}
85098509
else
85108510
{

gdb/ada-typeprint.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,8 @@ ada_print_type (struct type *type0, const char *varstring,
895895
const char *name = ada_type_name (type);
896896

897897
if (!ada_is_range_type_name (name))
898-
fprintf_filtered (stream, _("<%d-byte integer>"),
899-
TYPE_LENGTH (type));
898+
fprintf_filtered (stream, _("<%s-byte integer>"),
899+
pulongest (TYPE_LENGTH (type)));
900900
else
901901
{
902902
fprintf_filtered (stream, "range ");
@@ -917,7 +917,8 @@ ada_print_type (struct type *type0, const char *varstring,
917917
}
918918
break;
919919
case TYPE_CODE_FLT:
920-
fprintf_filtered (stream, _("<%d-byte float>"), TYPE_LENGTH (type));
920+
fprintf_filtered (stream, _("<%s-byte float>"),
921+
pulongest (TYPE_LENGTH (type)));
921922
break;
922923
case TYPE_CODE_ENUM:
923924
if (show < 0)

gdb/amd64-windows-tdep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ amd64_windows_store_arg_in_reg (struct regcache *regcache,
144144

145145
gdb_assert (TYPE_LENGTH (type) <= 8);
146146
memset (buf, 0, sizeof buf);
147-
memcpy (buf, valbuf, std::min (TYPE_LENGTH (type), (unsigned int) 8));
147+
memcpy (buf, valbuf, std::min (TYPE_LENGTH (type), (ULONGEST) 8));
148148
regcache->cooked_write (regno, buf);
149149
}
150150

gdb/compile/compile-c-support.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ generate_register_struct (struct ui_file *stream, struct gdbarch *gdbarch,
270270

271271
default:
272272
fprintf_unfiltered (stream,
273-
" unsigned char %s[%d]"
273+
" unsigned char %s[%s]"
274274
" __attribute__((__aligned__("
275275
"__BIGGEST_ALIGNMENT__)))",
276276
regname.c_str (),
277-
TYPE_LENGTH (regtype));
277+
pulongest (TYPE_LENGTH (regtype)));
278278
}
279279
fputs_unfiltered (";\n", stream);
280280
}

gdb/gdbtypes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4591,7 +4591,7 @@ recursive_dump_type (struct type *type, int spaces)
45914591
break;
45924592
}
45934593
puts_filtered ("\n");
4594-
printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
4594+
printfi_filtered (spaces, "length %s\n", pulongest (TYPE_LENGTH (type)));
45954595
if (TYPE_OBJFILE_OWNED (type))
45964596
{
45974597
printfi_filtered (spaces, "objfile ");

gdb/gdbtypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ struct type
859859
type_length_units function should be used in order to get the length
860860
expressed in target addressable memory units. */
861861

862-
unsigned int length;
862+
ULONGEST length;
863863

864864
/* * Core type, shared by a group of qualified types. */
865865

gdb/m2-typeprint.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ static void m2_array (struct type *type, struct ui_file *stream,
234234
m2_print_bounds (TYPE_INDEX_TYPE (type), stream, show, -1, 1);
235235
}
236236
else
237-
fprintf_filtered (stream, "%d",
238-
(TYPE_LENGTH (type)
239-
/ TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
237+
fputs_filtered (pulongest ((TYPE_LENGTH (type)
238+
/ TYPE_LENGTH (TYPE_TARGET_TYPE (type)))),
239+
stream);
240240
}
241241
fprintf_filtered (stream, "] OF ");
242242
m2_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level, flags);

gdb/riscv-tdep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ riscv_type_alignment (struct type *t)
16451645

16461646
case TYPE_CODE_ARRAY:
16471647
if (TYPE_VECTOR (t))
1648-
return std::min (TYPE_LENGTH (t), (unsigned) BIGGEST_ALIGNMENT);
1648+
return std::min (TYPE_LENGTH (t), (ULONGEST) BIGGEST_ALIGNMENT);
16491649
/* FALLTHROUGH */
16501650

16511651
case TYPE_CODE_COMPLEX:

gdb/symmisc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
583583
unsigned i;
584584
struct type *type = check_typedef (SYMBOL_TYPE (symbol));
585585

586-
fprintf_filtered (outfile, "const %u hex bytes:",
587-
TYPE_LENGTH (type));
586+
fprintf_filtered (outfile, "const %s hex bytes:",
587+
pulongest (TYPE_LENGTH (type)));
588588
for (i = 0; i < TYPE_LENGTH (type); i++)
589589
fprintf_filtered (outfile, " %02x",
590590
(unsigned) SYMBOL_VALUE_BYTES (symbol)[i]);

0 commit comments

Comments
 (0)