Commit 6b850546 authored by David Taylor's avatar David Taylor Committed by David Taylor
Browse files

Support structure offsets that are 512K or larger.

GDB computes structure byte offsets using a 32 bit integer.  And,
first it computes the offset in bits and then converts to bytes.  The
result is that any offset that if 512K bytes or larger overflows.
This patch changes GDB to use LONGEST for such calculations.

	PR gdb/17520 Structure offset wrong when 1/4 GB or greater.
	* c-lang.h: Change all parameters, variables, and struct or union
	members used as struct or union fie3ld offsets from int to
	LONGEST.
	* c-valprint.c: Likewise.
	* cp-abi.c: Likewise.
	* cp-abi.h: Likewise.
	* cp-valprint.c: Likewise.
	* d-valprint.c: Likewise.
	* dwarf2loc.c: Likewise.
	* eval.c: Likewise.
	* extension-priv.h: Likewise.
	* extension.c: Likewise.
	* extension.h: Likewise.
	* findvar.c: Likewise.
	* gdbtypes.h: Likewise.
	* gnu-v2-abi.c: Likewise.
	* gnu-v3-abi.c: Likewise.
	* go-valprint.c: Likewise.
	* guile/guile-internal.h: Likewise.
	* guile/scm-pretty-print.c: Likewise.
	* jv-valprint.c Likewise.
	* opencl-lang.c: Likewise.
	* p-lang.h: Likewise.
	* python/py-prettyprint.c: Likewise.
	* python/python-internal.h: Likewise.
	* spu-tdep.c: Likewise.
	* typeprint.c: Likewise.
	* valarith.c: Likewise.
	* valops.c: Likewise.
	* valprint.c: Likewise.
	* valprint.h: Likewise.
	* value.c: Likewise.
	* value.h: Likewise.
	* p-valprint.c: Likewise.
	* c-typeprint.c (c_type_print_base): When printing offset, use
	plongest, not %d.
	* gdbtypes.c (recursive_dump_type): Ditto.
parent e0204c4d
2016-06-24 David Taylor <dtaylor@emc.com>
PR gdb/17520 Structure offset wrong when 1/4 GB or greater.
* c-lang.h: Change all parameters, variables, and struct or union
members used as struct or union fie3ld offsets from int to
LONGEST.
* c-valprint.c: Likewise.
* cp-abi.c: Likewise.
* cp-abi.h: Likewise.
* cp-valprint.c: Likewise.
* d-valprint.c: Likewise.
* dwarf2loc.c: Likewise.
* eval.c: Likewise.
* extension-priv.h: Likewise.
* extension.c: Likewise.
* extension.h: Likewise.
* findvar.c: Likewise.
* gdbtypes.h: Likewise.
* gnu-v2-abi.c: Likewise.
* gnu-v3-abi.c: Likewise.
* go-valprint.c: Likewise.
* guile/guile-internal.h: Likewise.
* guile/scm-pretty-print.c: Likewise.
* jv-valprint.c Likewise.
* opencl-lang.c: Likewise.
* p-lang.h: Likewise.
* python/py-prettyprint.c: Likewise.
* python/python-internal.h: Likewise.
* spu-tdep.c: Likewise.
* typeprint.c: Likewise.
* valarith.c: Likewise.
* valops.c: Likewise.
* valprint.c: Likewise.
* valprint.h: Likewise.
* value.c: Likewise.
* value.h: Likewise.
* p-valprint.c: Likewise.
* c-typeprint.c (c_type_print_base): When printing offset, use
plongest, not %d.
* gdbtypes.c (recursive_dump_type): Ditto.
2016-06-24 David Taylor <david.taylor@emc.com>
* MAINTAINERS (Write After Approval): Add David Taylor.
......
......@@ -123,14 +123,14 @@ extern void cp_print_class_member (const gdb_byte *, struct type *,
struct ui_file *, char *);
extern void cp_print_value_fields (struct type *, struct type *,
const gdb_byte *, int, CORE_ADDR,
const gdb_byte *, LONGEST, CORE_ADDR,
struct ui_file *, int,
const struct value *,
const struct value_print_options *,
struct type **, int);
extern void cp_print_value_fields_rtti (struct type *,
const gdb_byte *, int, CORE_ADDR,
const gdb_byte *, LONGEST, CORE_ADDR,
struct ui_file *, int,
const struct value *,
const struct value_print_options *,
......
......@@ -1437,13 +1437,14 @@ c_type_print_base (struct type *type, struct ui_file *stream,
TYPE_FIELD_NAME (type, i),
stream, show, level + 4,
&local_flags);
fprintf_filtered (stream, " @%d",
TYPE_FIELD_BITPOS (type, i));
fprintf_filtered (stream, " @%s",
plongest (TYPE_FIELD_BITPOS (type, i)));
if (TYPE_FIELD_BITSIZE (type, i) > 1)
{
fprintf_filtered (stream, "-%d",
TYPE_FIELD_BITPOS (type, i)
+ TYPE_FIELD_BITSIZE (type, i) - 1);
fprintf_filtered (stream, "-%s",
plongest (TYPE_FIELD_BITPOS (type, i)
+ TYPE_FIELD_BITSIZE (type, i)
- 1));
}
fprintf_filtered (stream, ";\n");
}
......
......@@ -567,7 +567,8 @@ c_value_print (struct value *val, struct ui_file *stream,
const struct value_print_options *options)
{
struct type *type, *real_type, *val_type;
int full, top, using_enc;
int full, using_enc;
LONGEST top;
struct value_print_options opts = *options;
opts.deref_ref = 1;
......
......@@ -66,7 +66,7 @@ is_operator_name (const char *name)
int
baseclass_offset (struct type *type, int index, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
LONGEST embedded_offset, CORE_ADDR address,
const struct value *val)
{
int res = 0;
......@@ -106,7 +106,7 @@ value_virtual_fn_field (struct value **arg1p,
struct type *
value_rtti_type (struct value *v, int *full,
int *top, int *using_enc)
LONGEST *top, int *using_enc)
{
struct type *ret = NULL;
......
......@@ -135,7 +135,7 @@ extern struct value *value_virtual_fn_field (struct value **valuep,
FULL, TOP, and USING_ENC can each be zero, in which case we don't
provide the corresponding piece of information. */
extern struct type *value_rtti_type (struct value *value,
int *full, int *top,
int *full, LONGEST *top,
int *using_enc);
/* Compute the offset of the baseclass which is the INDEXth baseclass
......@@ -146,7 +146,7 @@ extern struct type *value_rtti_type (struct value *value,
extern int baseclass_offset (struct type *type,
int index, const gdb_byte *valaddr,
int embedded_offset,
LONGEST embedded_offset,
CORE_ADDR address,
const struct value *val);
......@@ -229,9 +229,9 @@ struct cp_abi_ops
int j, struct type * type,
int offset);
struct type *(*rtti_type) (struct value *v, int *full,
int *top, int *using_enc);
LONGEST *top, int *using_enc);
int (*baseclass_offset) (struct type *type, int index,
const bfd_byte *valaddr, int embedded_offset,
const bfd_byte *valaddr, LONGEST embedded_offset,
CORE_ADDR address, const struct value *val);
void (*print_method_ptr) (const gdb_byte *contents,
struct type *type,
......
......@@ -80,7 +80,7 @@ static void cp_print_static_field (struct type *, struct value *,
const struct value_print_options *);
static void cp_print_value (struct type *, struct type *,
const gdb_byte *, int,
const gdb_byte *, LONGEST,
CORE_ADDR, struct ui_file *,
int, const struct value *,
const struct value_print_options *,
......@@ -154,7 +154,7 @@ cp_is_vtbl_member (struct type *type)
void
cp_print_value_fields (struct type *type, struct type *real_type,
const gdb_byte *valaddr, int offset,
const gdb_byte *valaddr, LONGEST offset,
CORE_ADDR address, struct ui_file *stream,
int recurse, const struct value *val,
const struct value_print_options *options,
......@@ -417,7 +417,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
void
cp_print_value_fields_rtti (struct type *type,
const gdb_byte *valaddr, int offset,
const gdb_byte *valaddr, LONGEST offset,
CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
......@@ -434,7 +434,8 @@ cp_print_value_fields_rtti (struct type *type,
TARGET_CHAR_BIT * TYPE_LENGTH (type)))
{
struct value *value;
int full, top, using_enc;
int full, using_enc;
LONGEST top;
/* Ugh, we have to convert back to a value here. */
value = value_from_contents_and_address (type, valaddr + offset,
......@@ -459,7 +460,7 @@ cp_print_value_fields_rtti (struct type *type,
static void
cp_print_value (struct type *type, struct type *real_type,
const gdb_byte *valaddr, int offset,
const gdb_byte *valaddr, LONGEST offset,
CORE_ADDR address, struct ui_file *stream,
int recurse, const struct value *val,
const struct value_print_options *options,
......@@ -469,7 +470,7 @@ cp_print_value (struct type *type, struct type *real_type,
= (struct type **) obstack_next_free (&dont_print_vb_obstack);
struct obstack tmp_obstack = dont_print_vb_obstack;
int i, n_baseclasses = TYPE_N_BASECLASSES (type);
int thisoffset;
LONGEST thisoffset;
struct type *thistype;
if (dont_print_vb == 0)
......@@ -483,7 +484,7 @@ cp_print_value (struct type *type, struct type *real_type,
for (i = 0; i < n_baseclasses; i++)
{
int boffset = 0;
LONGEST boffset = 0;
int skip = 0;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
const char *basename = TYPE_NAME (baseclass);
......
......@@ -29,7 +29,7 @@
static int
dynamic_array_type (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
const struct value_print_options *options)
......
......@@ -1765,7 +1765,7 @@ read_pieced_value (struct value *v)
struct gdbarch *arch = get_frame_arch (frame);
int gdb_regnum = dwarf_reg_to_regnum_or_error (arch, p->v.regno);
int optim, unavail;
int reg_offset = source_offset;
LONGEST reg_offset = source_offset;
if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG
&& this_size < register_size (arch, gdb_regnum))
......@@ -2016,7 +2016,7 @@ write_pieced_value (struct value *to, struct value *from)
a synthetic pointer. */
static int
check_pieced_synthetic_pointer (const struct value *value, int bit_offset,
check_pieced_synthetic_pointer (const struct value *value, LONGEST bit_offset,
int bit_length)
{
struct piece_closure *c
......@@ -2132,7 +2132,8 @@ indirect_pieced_value (struct value *value)
struct type *type;
struct frame_info *frame;
struct dwarf2_locexpr_baton baton;
int i, bit_offset, bit_length;
int i, bit_length;
LONGEST bit_offset;
struct dwarf_expr_piece *piece = NULL;
LONGEST byte_offset;
enum bfd_endian byte_order;
......
......@@ -1900,7 +1900,8 @@ evaluate_subexp_standard (struct type *expect_type,
{
struct type *type = value_type (arg1);
struct type *real_type;
int full, top, using_enc;
int full, using_enc;
LONGEST top;
struct value_print_options opts;
get_user_print_options (&opts);
......
......@@ -181,7 +181,7 @@ struct extension_language_ops
enum ext_lang_rc (*apply_val_pretty_printer)
(const struct extension_language_defn *,
struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val, const struct value_print_options *options,
const struct language_defn *language);
......
......@@ -497,7 +497,7 @@ free_ext_lang_type_printers (struct ext_lang_type_printers *printers)
int
apply_ext_lang_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
const struct value_print_options *options,
......
......@@ -226,7 +226,7 @@ extern void free_ext_lang_type_printers (struct ext_lang_type_printers *);
extern int apply_ext_lang_val_pretty_printer
(struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val, const struct value_print_options *options,
const struct language_defn *language);
......
......@@ -835,8 +835,8 @@ void
read_frame_register_value (struct value *value, struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
int offset = 0;
int reg_offset = value_offset (value);
LONGEST offset = 0;
LONGEST reg_offset = value_offset (value);
int regnum = VALUE_REGNUM (value);
int len = type_length_units (check_typedef (value_type (value)));
......
......@@ -4297,8 +4297,8 @@ recursive_dump_type (struct type *type, int spaces)
idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
else
printfi_filtered (spaces + 2,
"[%d] bitpos %d bitsize %d type ",
idx, TYPE_FIELD_BITPOS (type, idx),
"[%d] bitpos %s bitsize %d type ",
idx, plongest (TYPE_FIELD_BITPOS (type, idx)),
TYPE_FIELD_BITSIZE (type, idx));
gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
printf_filtered (" name '%s' (",
......
......@@ -511,7 +511,7 @@ union field_location
gdbarch_bits_big_endian=0 targets, it is the bit offset to
the LSB. */
int bitpos;
LONGEST bitpos;
/* * Enum value. */
LONGEST enumval;
......
......@@ -183,7 +183,7 @@ gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j,
static struct type *
gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
gnuv2_value_rtti_type (struct value *v, int *full, LONGEST *top, int *using_enc)
{
struct type *known_type;
struct type *rtti_type;
......@@ -340,7 +340,7 @@ vb_match (struct type *type, int index, struct type *basetype)
static int
gnuv2_baseclass_offset (struct type *type, int index,
const bfd_byte *valaddr, int embedded_offset,
const bfd_byte *valaddr, LONGEST embedded_offset,
CORE_ADDR address, const struct value *val)
{
struct type *basetype = TYPE_BASECLASS (type, index);
......@@ -358,7 +358,7 @@ gnuv2_baseclass_offset (struct type *type, int index,
if (vb_match (type, i, basetype))
{
struct type *field_type;
int field_offset;
LONGEST field_offset;
int field_length;
CORE_ADDR addr;
......
......@@ -286,7 +286,7 @@ gnuv3_get_vtable (struct gdbarch *gdbarch,
static struct type *
gnuv3_rtti_type (struct value *value,
int *full_p, int *top_p, int *using_enc_p)
int *full_p, LONGEST *top_p, int *using_enc_p)
{
struct gdbarch *gdbarch;
struct type *values_type = check_typedef (value_type (value));
......@@ -443,7 +443,7 @@ gnuv3_virtual_fn_field (struct value **value_p,
static int
gnuv3_baseclass_offset (struct type *type, int index,
const bfd_byte *valaddr, int embedded_offset,
const bfd_byte *valaddr, LONGEST embedded_offset,
CORE_ADDR address, const struct value *val)
{
struct gdbarch *gdbarch;
......
......@@ -37,7 +37,7 @@
static void
print_go_string (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
const struct value_print_options *options)
......
......@@ -606,7 +606,7 @@ extern void gdbscm_preserve_values
extern enum ext_lang_rc gdbscm_apply_val_pretty_printer
(const struct extension_language_defn *,
struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
const struct value *val,
const struct value_print_options *options,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment