From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 362173858D33; Mon, 13 Feb 2023 22:28:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 362173858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676327300; bh=7SGugPltfI5Q4AKho2yTFr2mNNvonnOkIwVbswdkU3w=; h=From:To:Subject:Date:From; b=cd0fF36VqR0Wf87waMANYu1TesZ2shb42J5G3iMvu1OHibzL5qvU1aaKhYhQBTMny NGQI6EO518aRbm6m7JKRbmpXcwBFczYpMFCHjYX4tzsntO+3floFGGRSaJ48CuJ5P3 D+6wZTufvGuqZdKfRbL6h0aGRrCyWAtPb8lXL+64= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Turn value_enclosing_type into method X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 4b53ca88831137e94a6882f224d755a2d32ab8ef X-Git-Newrev: 463b870d01ae26aa3366e99fb86416b1c67f8061 Message-Id: <20230213222820.362173858D33@sourceware.org> Date: Mon, 13 Feb 2023 22:28:20 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D463b870d01ae= 26aa3366e99fb86416b1c67f8061 commit 463b870d01ae26aa3366e99fb86416b1c67f8061 Author: Tom Tromey Date: Tue Jan 31 10:19:10 2023 -0700 Turn value_enclosing_type into method =20 This changes value_enclosing_type to be a method of value. Much of this patch was written by script. =20 Approved-By: Simon Marchi Diff: --- gdb/ada-lang.c | 6 ++-- gdb/bfin-tdep.c | 4 +-- gdb/c-valprint.c | 8 ++--- gdb/cp-valprint.c | 2 +- gdb/gnu-v3-abi.c | 2 +- gdb/i386-darwin-tdep.c | 2 +- gdb/i386-tdep.c | 6 ++-- gdb/m68k-tdep.c | 2 +- gdb/rl78-tdep.c | 2 +- gdb/tilegx-tdep.c | 4 +-- gdb/valops.c | 33 +++++++++--------- gdb/value.c | 60 ++++++++++++++------------------ gdb/value.h | 93 +++++++++++++++++++++++++---------------------= ---- gdb/vax-tdep.c | 2 +- gdb/xstormy16-tdep.c | 4 +-- 15 files changed, 111 insertions(+), 119 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 5aec8b77b14..baffea75657 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -3060,7 +3060,7 @@ ada_value_ptr_subscript (struct value *arr, int arity= , struct value **ind) int k; struct value *array_ind =3D ada_value_ind (arr); struct type *type - =3D check_typedef (value_enclosing_type (array_ind)); + =3D check_typedef (array_ind->enclosing_type ()); =20 if (type->code () =3D=3D TYPE_CODE_ARRAY && TYPE_FIELD_BITSIZE (type, 0) > 0) @@ -3334,7 +3334,7 @@ ada_array_bound (struct value *arr, int n, int which) =20 if (check_typedef (arr->type ())->code () =3D=3D TYPE_CODE_PTR) arr =3D value_ind (arr); - arr_type =3D value_enclosing_type (arr); + arr_type =3D arr->enclosing_type (); =20 if (ada_is_constrained_packed_array_type (arr_type)) return ada_array_bound (decode_constrained_packed_array (arr), n, whic= h); @@ -3358,7 +3358,7 @@ ada_array_length (struct value *arr, int n) =20 if (check_typedef (arr->type ())->code () =3D=3D TYPE_CODE_PTR) arr =3D value_ind (arr); - arr_type =3D value_enclosing_type (arr); + arr_type =3D arr->enclosing_type (); =20 if (ada_is_constrained_packed_array_type (arr_type)) return ada_array_length (decode_constrained_packed_array (arr), n); diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index 4d84407cc45..e1be4b77071 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -509,7 +509,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch, =20 for (i =3D nargs - 1; i >=3D 0; i--) { - struct type *value_type =3D value_enclosing_type (args[i]); + struct type *value_type =3D args[i]->enclosing_type (); =20 total_len +=3D align_up (value_type->length (), 4); } @@ -525,7 +525,7 @@ bfin_push_dummy_call (struct gdbarch *gdbarch, =20 for (i =3D nargs - 1; i >=3D 0; i--) { - struct type *value_type =3D value_enclosing_type (args[i]); + struct type *value_type =3D args[i]->enclosing_type (); struct type *arg_type =3D check_typedef (value_type); int container_len =3D align_up (arg_type->length (), 4); =20 diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 8d28c45cbfc..0a9e4f49ba6 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -571,18 +571,18 @@ c_value_print (struct value *val, struct ui_file *str= eam, better to leave the object as-is. */ if (!(full && (real_type->length () - < value_enclosing_type (val)->length ()))) + < val->enclosing_type ()->length ()))) val =3D value_cast (real_type, val); gdb_printf (stream, "(%s%s) ", real_type->name (), full ? "" : _(" [incomplete object]")); } - else if (type !=3D check_typedef (value_enclosing_type (val))) + else if (type !=3D check_typedef (val->enclosing_type ())) { /* No RTTI information, so let's do our best. */ gdb_printf (stream, "(%s ?) ", - value_enclosing_type (val)->name ()); - val =3D value_cast (value_enclosing_type (val), val); + val->enclosing_type ()->name ()); + val =3D value_cast (val->enclosing_type (), val); } } =20 diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 33ff17b8d2b..476ec9c1b1e 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -763,7 +763,7 @@ test_print_fields (gdbarch *arch) =20 value *val =3D allocate_value (the_struct); gdb_byte *contents =3D value_contents_writeable (val).data (); - store_unsigned_integer (contents, value_enclosing_type (val)->length (), + store_unsigned_integer (contents, val->enclosing_type ()->length (), gdbarch_byte_order (arch), 0xe9); =20 string_file out; diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index d9e0d579259..782f5765d6f 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -372,7 +372,7 @@ gnuv3_rtti_type (struct value *value, =20 if (full_p) *full_p =3D (- offset_to_top =3D=3D value_embedded_offset (value) - && (value_enclosing_type (value)->length () + && (value->enclosing_type ()->length () >=3D run_time_type->length ())); if (top_p) *top_p =3D - offset_to_top; diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c index d84e5ed8005..abf68ef7c39 100644 --- a/gdb/i386-darwin-tdep.c +++ b/gdb/i386-darwin-tdep.c @@ -183,7 +183,7 @@ i386_darwin_push_dummy_call (struct gdbarch *gdbarch, s= truct value *function, =20 for (i =3D 0; i < nargs; i++) { - struct type *arg_type =3D value_enclosing_type (args[i]); + struct type *arg_type =3D args[i]->enclosing_type (); =20 if (i386_m128_p (arg_type) && num_m128 < 4) { diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 090f5468067..aea5e12f387 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2725,11 +2725,11 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdba= rch, struct value *function, =20 for (i =3D thiscall ? 1 : 0; i < nargs; i++) { - int len =3D value_enclosing_type (args[i])->length (); + int len =3D args[i]->enclosing_type ()->length (); =20 if (write_pass) { - if (i386_16_byte_align_p (value_enclosing_type (args[i]))) + if (i386_16_byte_align_p (args[i]->enclosing_type ())) args_space_used =3D align_up (args_space_used, 16); =20 write_memory (sp + args_space_used, @@ -2745,7 +2745,7 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarc= h, struct value *function, } else { - if (i386_16_byte_align_p (value_enclosing_type (args[i]))) + if (i386_16_byte_align_p (args[i]->enclosing_type ())) args_space =3D align_up (args_space, 16); args_space +=3D align_up (len, 4); } diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index ae020c89d19..e776060935c 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -544,7 +544,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct v= alue *function, /* Push arguments in reverse order. */ for (i =3D nargs - 1; i >=3D 0; i--) { - struct type *value_type =3D value_enclosing_type (args[i]); + struct type *value_type =3D args[i]->enclosing_type (); int len =3D value_type->length (); int container_len =3D (len + 3) & ~3; int offset; diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c index 4979e09b15f..cd846669169 100644 --- a/gdb/rl78-tdep.c +++ b/gdb/rl78-tdep.c @@ -1340,7 +1340,7 @@ rl78_push_dummy_call (struct gdbarch *gdbarch, struct= value *function, /* Push arguments in reverse order. */ for (i =3D nargs - 1; i >=3D 0; i--) { - struct type *value_type =3D value_enclosing_type (args[i]); + struct type *value_type =3D args[i]->enclosing_type (); int len =3D value_type->length (); int container_len =3D (len + 1) & ~1; =20 diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 5dfb2376e99..8f005e81dcc 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -298,7 +298,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, for (i =3D 0; i < nargs && argreg <=3D TILEGX_R9_REGNUM; i++) { const gdb_byte *val; - typelen =3D value_enclosing_type (args[i])->length (); + typelen =3D args[i]->enclosing_type ()->length (); =20 if (typelen > (TILEGX_R9_REGNUM - argreg + 1) * tilegx_reg_size) break; @@ -325,7 +325,7 @@ tilegx_push_dummy_call (struct gdbarch *gdbarch, { const gdb_byte *contents =3D value_contents (args[j]).data (); =20 - typelen =3D value_enclosing_type (args[j])->length (); + typelen =3D args[j]->enclosing_type ()->length (); slacklen =3D align_up (typelen, 8) - typelen; gdb::byte_vector val (typelen + slacklen); memcpy (val.data (), contents, typelen); diff --git a/gdb/valops.c b/gdb/valops.c index f462da8b564..9870e0da337 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -327,7 +327,7 @@ value_cast_pointers (struct type *type, struct value *a= rg2, /* No superclass found, just change the pointer type. */ arg2 =3D value_copy (arg2); arg2->deprecated_set_type (type); - set_value_enclosing_type (arg2, type); + arg2->set_enclosing_type (type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; } @@ -649,7 +649,7 @@ value_cast (struct type *type, struct value *arg2) =20 arg2 =3D value_copy (arg2); arg2->deprecated_set_type (to_type); - set_value_enclosing_type (arg2, to_type); + arg2->set_enclosing_type (to_type); set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */ return arg2; } @@ -1352,7 +1352,7 @@ value_assign (struct value *toval, struct value *from= val) to by TOVAL retains its original dynamic type after assignment. */ if (type->code () =3D=3D TYPE_CODE_PTR) { - set_value_enclosing_type (val, value_enclosing_type (fromval)); + val->set_enclosing_type (fromval->enclosing_type ()); set_value_pointed_to_offset (val, value_pointed_to_offset (fromval)); } =20 @@ -1371,14 +1371,14 @@ value_repeat (struct value *arg1, int count) if (count < 1) error (_("Invalid number %d of repetitions."), count); =20 - val =3D allocate_repeat_value (value_enclosing_type (arg1), count); + val =3D allocate_repeat_value (arg1->enclosing_type (), count); =20 VALUE_LVAL (val) =3D lval_memory; set_value_address (val, value_address (arg1)); =20 read_value_memory (val, 0, value_stack (val), value_address (val), value_contents_all_raw (val).data (), - type_length_units (value_enclosing_type (val))); + type_length_units (val->enclosing_type ())); =20 return val; } @@ -1568,13 +1568,13 @@ value_addr (struct value *arg1) struct type *type_ptr =3D lookup_pointer_type (type->target_type ()); struct type *enclosing_type - =3D check_typedef (value_enclosing_type (arg1)); + =3D check_typedef (arg1->enclosing_type ()); struct type *enclosing_type_ptr =3D lookup_pointer_type (enclosing_type->target_type ()); =20 arg2 =3D value_copy (arg1); arg2->deprecated_set_type (type_ptr); - set_value_enclosing_type (arg2, enclosing_type_ptr); + arg2->set_enclosing_type (enclosing_type_ptr); =20 return arg2; } @@ -1596,8 +1596,7 @@ value_addr (struct value *arg1) =20 /* This may be a pointer to a base subobject; so remember the full derived object's type ... */ - set_value_enclosing_type (arg2, - lookup_pointer_type (value_enclosing_type (arg1))); + arg2->set_enclosing_type (lookup_pointer_type (arg1->enclosing_type ())); /* ... and also the relative position of the subobject in the full object. */ set_value_pointed_to_offset (arg2, value_embedded_offset (arg1)); @@ -1657,7 +1656,7 @@ value_ind (struct value *arg1) =20 /* We may be pointing to something embedded in a larger object. Get the real type of the enclosing object. */ - enc_type =3D check_typedef (value_enclosing_type (arg1)); + enc_type =3D check_typedef (arg1->enclosing_type ()); enc_type =3D enc_type->target_type (); =20 CORE_ADDR base_addr; @@ -1710,17 +1709,17 @@ value_array (int lowbound, int highbound, struct va= lue **elemvec) { error (_("bad array bounds (%d, %d)"), lowbound, highbound); } - typelength =3D type_length_units (value_enclosing_type (elemvec[0])); + typelength =3D type_length_units (elemvec[0]->enclosing_type ()); for (idx =3D 1; idx < nelem; idx++) { - if (type_length_units (value_enclosing_type (elemvec[idx])) + if (type_length_units (elemvec[idx]->enclosing_type ()) !=3D typelength) { error (_("array elements must all be the same size")); } } =20 - arraytype =3D lookup_array_range_type (value_enclosing_type (elemvec[0]), + arraytype =3D lookup_array_range_type (elemvec[0]->enclosing_type (), lowbound, highbound); =20 if (!current_language->c_style_arrays_p ()) @@ -2095,7 +2094,7 @@ struct_field_searcher::search (struct value *arg1, LO= NGEST offset, =20 boffset +=3D value_embedded_offset (arg1) + offset; if (boffset < 0 - || boffset >=3D value_enclosing_type (arg1)->length ()) + || boffset >=3D arg1->enclosing_type ()->length ()) { CORE_ADDR base_addr; =20 @@ -3944,14 +3943,14 @@ value_full_object (struct value *argp, real_type =3D value_rtti_type (argp, &full, &top, &using_enc); =20 /* If no RTTI data, or if object is already complete, do nothing. */ - if (!real_type || real_type =3D=3D value_enclosing_type (argp)) + if (!real_type || real_type =3D=3D argp->enclosing_type ()) return argp; =20 /* In a destructor we might see a real type that is a superclass of the object's type. In this case it is better to leave the object as-is. */ if (full - && real_type->length () < value_enclosing_type (argp)->length ()) + && real_type->length () < argp->enclosing_type ()->length ()) return argp; =20 /* If we have the full object, but for some reason the enclosing @@ -3960,7 +3959,7 @@ value_full_object (struct value *argp, if (full) { argp =3D value_copy (argp); - set_value_enclosing_type (argp, real_type); + argp->set_enclosing_type (real_type); return argp; } =20 diff --git a/gdb/value.c b/gdb/value.c index 783ef7deae7..efa780a897a 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -177,7 +177,7 @@ value_bits_available (const struct value *value, /* Don't pretend we have anything available there in the history beyond the boundaries of the value recorded. It's not like inferior memory where there is actual stuff underneath. */ - ULONGEST val_len =3D TARGET_CHAR_BIT * value_enclosing_type (value)->len= gth (); + ULONGEST val_len =3D TARGET_CHAR_BIT * value->enclosing_type ()->length = (); return !((value->m_in_history && (offset < 0 || offset + length > val_len)) || ranges_contain (value->m_unavailable, offset, length)); @@ -240,7 +240,7 @@ value_entirely_covered_by_range_vector (struct value *v= alue, =20 if (t.offset =3D=3D 0 && t.length =3D=3D (TARGET_CHAR_BIT - * value_enclosing_type (value)->length ())) + * value->enclosing_type ()->length ())) return 1; } =20 @@ -725,8 +725,8 @@ value_contents_eq (const struct value *val1, LONGEST of= fset1, bool value_contents_eq (const struct value *val1, const struct value *val2) { - ULONGEST len1 =3D check_typedef (value_enclosing_type (val1))->length (); - ULONGEST len2 =3D check_typedef (value_enclosing_type (val2))->length (); + ULONGEST len1 =3D check_typedef (val1->enclosing_type ())->length (); + ULONGEST len2 =3D check_typedef (val2->enclosing_type ())->length (); if (len1 !=3D len2) return false; return value_contents_eq (val1, 0, val2, 0, len1); @@ -934,7 +934,7 @@ allocate_value_contents (struct value *val, bool check_= size) { if (!val->m_contents) { - struct type *enclosing_type =3D value_enclosing_type (val); + struct type *enclosing_type =3D val->enclosing_type (); ULONGEST len =3D enclosing_type->length (); =20 if (check_size) @@ -1042,16 +1042,10 @@ value_contents_all_raw (struct value *value) { allocate_value_contents (value, true); =20 - ULONGEST length =3D value_enclosing_type (value)->length (); + ULONGEST length =3D value->enclosing_type ()->length (); return gdb::make_array_view (value->m_contents.get (), length); } =20 -struct type * -value_enclosing_type (const struct value *value) -{ - return value->m_enclosing_type; -} - /* Look at value.h for description. */ =20 struct type * @@ -1089,7 +1083,7 @@ value_actual_type (struct value *value, int resolve_s= imple_types, { if (real_type_found) *real_type_found =3D 1; - result =3D value_enclosing_type (value); + result =3D value->enclosing_type (); } } =20 @@ -1128,7 +1122,7 @@ value_contents_for_printing (struct value *value) if (value->m_lazy) value_fetch_lazy (value); =20 - ULONGEST length =3D value_enclosing_type (value)->length (); + ULONGEST length =3D value->enclosing_type ()->length (); return gdb::make_array_view (value->m_contents.get (), length); } =20 @@ -1137,7 +1131,7 @@ value_contents_for_printing_const (const struct value= *value) { gdb_assert (!value->m_lazy); =20 - ULONGEST length =3D value_enclosing_type (value)->length (); + ULONGEST length =3D value->enclosing_type ()->length (); return gdb::make_array_view (value->m_contents.get (), length); } =20 @@ -1614,7 +1608,7 @@ value_release_to_mark (const struct value *mark) struct value * value_copy (const value *arg) { - struct type *encl_type =3D value_enclosing_type (arg); + struct type *encl_type =3D arg->enclosing_type (); struct value *val; =20 val =3D allocate_value_lazy (encl_type); @@ -1643,7 +1637,7 @@ value_copy (const value *arg) { ULONGEST length =3D val->m_limited_length; if (length =3D=3D 0) - length =3D value_enclosing_type (val)->length (); + length =3D val->enclosing_type ()->length (); =20 gdb_assert (arg->m_contents !=3D nullptr); const auto &arg_view @@ -1676,12 +1670,11 @@ struct value * make_cv_value (int cnst, int voltl, struct value *v) { struct type *val_type =3D v->type (); - struct type *m_enclosing_type =3D value_enclosing_type (v); + struct type *m_enclosing_type =3D v->enclosing_type (); struct value *cv_val =3D value_copy (v); =20 cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL)); - set_value_enclosing_type (cv_val, - make_cv_type (cnst, voltl, m_enclosing_type, NULL)); + cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type,= NULL)); =20 return cv_val; } @@ -1693,7 +1686,7 @@ value_non_lval (struct value *arg) { if (VALUE_LVAL (arg) !=3D not_lval) { - struct type *enc_type =3D value_enclosing_type (arg); + struct type *enc_type =3D arg->enclosing_type (); struct value *val =3D allocate_value (enc_type); =20 copy (value_contents_all (arg), value_contents_all_raw (val)); @@ -1788,7 +1781,7 @@ set_value_component_location (struct value *component, int record_latest_value (struct value *val) { - struct type *enclosing_type =3D value_enclosing_type (val); + struct type *enclosing_type =3D val->enclosing_type (); struct type *type =3D val->type (); =20 /* We don't want this value to have anything to do with the inferior any= more. @@ -2972,17 +2965,16 @@ value_static_field (struct type *type, int fieldno) data. */ =20 void -set_value_enclosing_type (struct value *val, struct type *new_encl_type) +value::set_enclosing_type (struct type *new_encl_type) { - if (new_encl_type->length () > value_enclosing_type (val)->length ()) + if (new_encl_type->length () > enclosing_type ()->length ()) { check_type_length_before_alloc (new_encl_type); - val->m_contents - .reset ((gdb_byte *) xrealloc (val->m_contents.release (), - new_encl_type->length ())); + m_contents.reset ((gdb_byte *) xrealloc (m_contents.release (), + new_encl_type->length ())); } =20 - val->m_enclosing_type =3D new_encl_type; + m_enclosing_type =3D new_encl_type; } =20 /* Given a value ARG1 (offset by OFFSET bytes) @@ -3062,12 +3054,12 @@ value_primitive_field (struct value *arg1, LONGEST = offset, boffset =3D arg_type->field (fieldno).loc_bitpos () / 8; =20 if (value_lazy (arg1)) - v =3D allocate_value_lazy (value_enclosing_type (arg1)); + v =3D allocate_value_lazy (arg1->enclosing_type ()); else { - v =3D allocate_value (value_enclosing_type (arg1)); + v =3D allocate_value (arg1->enclosing_type ()); value_contents_copy_raw (v, 0, arg1, 0, - value_enclosing_type (arg1)->length ()); + arg1->enclosing_type ()->length ()); } v->m_type =3D type; v->m_offset =3D arg1->offset (); @@ -3780,7 +3772,7 @@ readjust_indirect_value_type (struct value *value, st= ruct type *enc_type, value->deprecated_set_type (resolved_original_target_type); =20 /* Add embedding info. */ - set_value_enclosing_type (value, enc_type); + value->set_enclosing_type (enc_type); set_value_embedded_offset (value, value_pointed_to_offset (original_valu= e)); =20 /* We may be pointing to an object of some derived type. */ @@ -3801,7 +3793,7 @@ coerce_ref (struct value *arg) if (!TYPE_IS_REFERENCE (value_type_arg_tmp)) return arg; =20 - enc_type =3D check_typedef (value_enclosing_type (arg)); + enc_type =3D check_typedef (arg->enclosing_type ()); enc_type =3D enc_type->target_type (); =20 CORE_ADDR addr =3D unpack_pointer (arg->type (), value_contents (arg).da= ta ()); @@ -3913,7 +3905,7 @@ value_fetch_lazy_memory (struct value *val) gdb_assert (VALUE_LVAL (val) =3D=3D lval_memory); =20 CORE_ADDR addr =3D value_address (val); - struct type *type =3D check_typedef (value_enclosing_type (val)); + struct type *type =3D check_typedef (val->enclosing_type ()); =20 /* Figure out how much we should copy from memory. Usually, this is just the size of the type, but, for arrays, we might only be loading a diff --git a/gdb/value.h b/gdb/value.h index befd41789ee..a3d07c0b5fd 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -215,6 +215,52 @@ struct value int deprecated_modifiable () const { return m_modifiable; } =20 + /* If a value represents a C++ object, then the `type' field gives the + object's compile-time type. If the object actually belongs to some + class derived from `type', perhaps with other base classes and + additional members, then `type' is just a subobject of the real + thing, and the full object is probably larger than `type' would + suggest. + + If `type' is a dynamic class (i.e. one with a vtable), then GDB can + actually determine the object's run-time type by looking at the + run-time type information in the vtable. When this information is + available, we may elect to read in the entire object, for several + reasons: + + - When printing the value, the user would probably rather see the + full object, not just the limited portion apparent from the + compile-time type. + + - If `type' has virtual base classes, then even printing `type' + alone may require reaching outside the `type' portion of the + object to wherever the virtual base class has been stored. + + When we store the entire object, `enclosing_type' is the run-time + type -- the complete object -- and `embedded_offset' is the offset + of `type' within that larger type, in bytes. The value_contents() + macro takes `embedded_offset' into account, so most GDB code + continues to see the `type' portion of the value, just as the + inferior would. + + If `type' is a pointer to an object, then `enclosing_type' is a + pointer to the object's run-time type, and `pointed_to_offset' is + the offset in bytes from the full object to the pointed-to object + -- that is, the value `embedded_offset' would have if we followed + the pointer and fetched the complete object. (I don't really see + the point. Why not just determine the run-time type when you + indirect, and avoid the special case? The contents don't matter + until you indirect anyway.) + + If we're not doing anything fancy, `enclosing_type' is equal to + `type', and `embedded_offset' is zero, so everything works + normally. */ + + struct type *enclosing_type () const + { return m_enclosing_type; } + + void set_enclosing_type (struct type *new_type); + =20 /* Type of value; either not an lval, or one of the various different possible kinds of lval. */ @@ -393,51 +439,6 @@ struct value ULONGEST m_limited_length =3D 0; }; =20 -/* If a value represents a C++ object, then the `type' field gives the - object's compile-time type. If the object actually belongs to some - class derived from `type', perhaps with other base classes and - additional members, then `type' is just a subobject of the real - thing, and the full object is probably larger than `type' would - suggest. - - If `type' is a dynamic class (i.e. one with a vtable), then GDB can - actually determine the object's run-time type by looking at the - run-time type information in the vtable. When this information is - available, we may elect to read in the entire object, for several - reasons: - - - When printing the value, the user would probably rather see the - full object, not just the limited portion apparent from the - compile-time type. - - - If `type' has virtual base classes, then even printing `type' - alone may require reaching outside the `type' portion of the - object to wherever the virtual base class has been stored. - - When we store the entire object, `enclosing_type' is the run-time - type -- the complete object -- and `embedded_offset' is the offset - of `type' within that larger type, in bytes. The value_contents() - macro takes `embedded_offset' into account, so most GDB code - continues to see the `type' portion of the value, just as the - inferior would. - - If `type' is a pointer to an object, then `enclosing_type' is a - pointer to the object's run-time type, and `pointed_to_offset' is - the offset in bytes from the full object to the pointed-to object - -- that is, the value `embedded_offset' would have if we followed - the pointer and fetched the complete object. (I don't really see - the point. Why not just determine the run-time type when you - indirect, and avoid the special case? The contents don't matter - until you indirect anyway.) - - If we're not doing anything fancy, `enclosing_type' is equal to - `type', and `embedded_offset' is zero, so everything works - normally. */ - -extern struct type *value_enclosing_type (const struct value *); -extern void set_value_enclosing_type (struct value *val, - struct type *new_type); - /* Returns value_type or value_enclosing_type depending on value_print_options.objectprint. =20 @@ -768,7 +769,7 @@ extern void mark_value_bits_unavailable (struct value *= value, example, to compare a complete object value with itself, including its enclosing type chunk, you'd do: =20 - int len =3D check_typedef (value_enclosing_type (val))->length (); + int len =3D check_typedef (val->enclosing_type ())->length (); value_contents_eq (val, 0, val, 0, len); =20 Returns true iff the set of available/valid contents match. diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c index c229e660423..c46010d0b13 100644 --- a/gdb/vax-tdep.c +++ b/gdb/vax-tdep.c @@ -117,7 +117,7 @@ vax_store_arguments (struct regcache *regcache, int nar= gs, /* Push arguments in reverse order. */ for (i =3D nargs - 1; i >=3D 0; i--) { - int len =3D value_enclosing_type (args[i])->length (); + int len =3D args[i]->enclosing_type ()->length (); =20 sp -=3D (len + 3) & ~3; count +=3D (len + 3) / 4; diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 0c33b9a7554..c12d83213ae 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -247,7 +247,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, would fit in the remaining unused registers. */ for (i =3D 0; i < nargs && argreg <=3D E_LST_ARG_REGNUM; i++) { - typelen =3D value_enclosing_type (args[i])->length (); + typelen =3D args[i]->enclosing_type ()->length (); if (typelen > E_MAX_RETTYPE_SIZE (argreg)) break; =20 @@ -272,7 +272,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, { const gdb_byte *bytes =3D value_contents (args[j]).data (); =20 - typelen =3D value_enclosing_type (args[j])->length (); + typelen =3D args[j]->enclosing_type ()->length (); slacklen =3D typelen & 1; gdb::byte_vector val (typelen + slacklen); memcpy (val.data (), bytes, typelen);