static int
dynamic_cast_check_1 (struct type *desired_type,
- const bfd_byte *contents,
+ const gdb_byte *valaddr,
+ int embedded_offset,
CORE_ADDR address,
+ struct value *val,
struct type *search_type,
CORE_ADDR arg_addr,
struct type *arg_type,
for (i = 0; i < TYPE_N_BASECLASSES (search_type) && result_count < 2; ++i)
{
- int offset = baseclass_offset (search_type, i, contents, address);
+ int offset = baseclass_offset (search_type, i, valaddr, embedded_offset,
+ address, val);
- if (offset == -1)
- error (_("virtual baseclass botch"));
if (class_types_same_p (desired_type, TYPE_BASECLASS (search_type, i)))
{
- if (address + offset >= arg_addr
- && address + offset < arg_addr + TYPE_LENGTH (arg_type))
+ if (address + embedded_offset + offset >= arg_addr
+ && address + embedded_offset + offset < arg_addr + TYPE_LENGTH (arg_type))
{
++result_count;
if (!*result)
*result = value_at_lazy (TYPE_BASECLASS (search_type, i),
- address + offset);
+ address + embedded_offset + offset);
}
}
else
result_count += dynamic_cast_check_1 (desired_type,
- contents + offset,
- address + offset,
+ valaddr,
+ embedded_offset + offset,
+ address, val,
TYPE_BASECLASS (search_type, i),
arg_addr,
arg_type,
static int
dynamic_cast_check_2 (struct type *desired_type,
- const bfd_byte *contents,
+ const gdb_byte *valaddr,
+ int embedded_offset,
CORE_ADDR address,
+ struct value *val,
struct type *search_type,
struct value **result)
{
if (! BASETYPE_VIA_PUBLIC (search_type, i))
continue;
- offset = baseclass_offset (search_type, i, contents, address);
- if (offset == -1)
- error (_("virtual baseclass botch"));
+ offset = baseclass_offset (search_type, i, valaddr, embedded_offset,
+ address, val);
if (class_types_same_p (desired_type, TYPE_BASECLASS (search_type, i)))
{
++result_count;
if (*result == NULL)
*result = value_at_lazy (TYPE_BASECLASS (search_type, i),
- address + offset);
+ address + embedded_offset + offset);
}
else
result_count += dynamic_cast_check_2 (desired_type,
- contents + offset,
- address + offset,
+ valaddr,
+ embedded_offset + offset,
+ address, val,
TYPE_BASECLASS (search_type, i),
result);
}
return tem;
result = NULL;
if (dynamic_cast_check_1 (TYPE_TARGET_TYPE (resolved_type),
- value_contents (tem), value_address (tem),
+ value_contents_for_printing (tem),
+ value_embedded_offset (tem),
+ value_address (tem), tem,
rtti_type, addr,
arg_type,
&result) == 1)
result = NULL;
if (is_public_ancestor (arg_type, rtti_type)
&& dynamic_cast_check_2 (TYPE_TARGET_TYPE (resolved_type),
- value_contents (tem), value_address (tem),
+ value_contents_for_printing (tem),
+ value_embedded_offset (tem),
+ value_address (tem), tem,
rtti_type, &result) == 1)
return value_cast (type,
is_ref ? value_ref (result) : value_addr (result));
{
struct value *val = allocate_value (type);
- VALUE_LVAL (val) = lv;
+ VALUE_LVAL (val) = (lv == lval_computed ? not_lval : lv);
return val;
}
int offset = value_offset (parent) + value_offset (toval);
int changed_len;
gdb_byte buffer[sizeof (LONGEST)];
+ int optim, unavail;
changed_len = (value_bitpos (toval)
+ value_bitsize (toval)
"don't fit in a %d bit word."),
(int) sizeof (LONGEST) * HOST_CHAR_BIT);
- get_frame_register_bytes (frame, value_reg, offset,
- changed_len, buffer);
+ if (!get_frame_register_bytes (frame, value_reg, offset,
+ changed_len, buffer,
+ &optim, &unavail))
+ {
+ if (optim)
+ error (_("value has been optimized out"));
+ if (unavail)
+ throw_error (NOT_AVAILABLE_ERROR,
+ _("value is not available"));
+ }
modify_field (type, buffer, value_as_long (fromval),
value_bitpos (toval), value_bitsize (toval));
case lval_computed:
{
- struct lval_funcs *funcs = value_computed_funcs (toval);
+ const struct lval_funcs *funcs = value_computed_funcs (toval);
funcs->write (toval, fromval);
}
if (VALUE_LVAL (arg1) == lval_computed)
{
- struct lval_funcs *funcs = value_computed_funcs (arg1);
+ const struct lval_funcs *funcs = value_computed_funcs (arg1);
if (funcs->indirect)
{
struct value *v2;
boffset = baseclass_offset (type, i,
- value_contents (arg1) + offset,
- value_address (arg1)
- + value_embedded_offset (arg1)
- + offset);
- if (boffset == -1)
- error (_("virtual baseclass botch"));
+ value_contents_for_printing (arg1),
+ value_embedded_offset (arg1) + offset,
+ value_address (arg1),
+ arg1);
/* The virtual base class pointer might have been clobbered
by the user program. Make sure that it still points to a
for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
{
int base_offset;
+ int skip = 0;
+ int this_offset;
if (BASETYPE_VIA_VIRTUAL (type, i))
{
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
+ struct value *base_val;
const gdb_byte *base_valaddr;
/* The virtual base class pointer might have been
if (offset < 0 || offset >= TYPE_LENGTH (type))
{
gdb_byte *tmp = alloca (TYPE_LENGTH (baseclass));
+ CORE_ADDR address = value_address (*arg1p);
- if (target_read_memory (value_address (*arg1p) + offset,
+ if (target_read_memory (address + offset,
tmp, TYPE_LENGTH (baseclass)) != 0)
error (_("virtual baseclass botch"));
- base_valaddr = tmp;
+
+ base_val = value_from_contents_and_address (baseclass,
+ tmp,
+ address + offset);
+ base_valaddr = value_contents_for_printing (base_val);
+ this_offset = 0;
}
else
- base_valaddr = value_contents (*arg1p) + offset;
+ {
+ base_val = *arg1p;
+ base_valaddr = value_contents_for_printing (*arg1p);
+ this_offset = offset;
+ }
base_offset = baseclass_offset (type, i, base_valaddr,
- value_address (*arg1p) + offset);
- if (base_offset == -1)
- error (_("virtual baseclass botch"));
+ this_offset, value_address (base_val),
+ base_val);
}
else
{
if (BASETYPE_VIA_VIRTUAL (type, i))
{
- base_offset = value_offset (*argp) + offset;
base_offset = baseclass_offset (type, i,
- value_contents (*argp) + base_offset,
- value_address (*argp) + base_offset);
- if (base_offset == -1)
- error (_("virtual baseclass botch"));
+ value_contents_for_printing (*argp),
+ value_offset (*argp) + offset,
+ value_address (*argp), *argp);
}
else /* Non-virtual base, simply use bit position from debug
info. */
if (*valp)
{
*staticp = 1;
+ do_cleanups (all_cleanups);
return 0;
}
}
{
const char *qualified_name = NULL;
- /* If the the overload match is being search for both
- as a method and non member function, the first argument
- must now be dereferenced. */
+ /* If the overload match is being search for both as a method
+ and non member function, the first argument must now be
+ dereferenced. */
if (method == BOTH)
arg_types[0] = TYPE_TARGET_TYPE (arg_types[0]);
if (func_name == NULL)
{
*symp = fsym;
+ do_cleanups (all_cleanups);
return 0;
}
switch (compare_badness (func_badness, method_badness))
{
case 0: /* Top two contenders are equally good. */
- /* FIXME: GDB does not support the general ambiguous
- case. All candidates should be collected and presented
- the the user. */
+ /* FIXME: GDB does not support the general ambiguous case.
+ All candidates should be collected and presented the
+ user. */
error (_("Ambiguous overload resolution"));
break;
case 1: /* Incomparable top contenders. */
/* C++: return 1 is NAME is a legitimate name for the destructor of
type TYPE. If TYPE does not have a destructor, or if NAME is
- inappropriate for TYPE, an error is signaled. */
+ inappropriate for TYPE, an error is signaled. Parameter TYPE should not yet
+ have CHECK_TYPEDEF applied, this function will apply it itself. */
+
int
-destructor_name_p (const char *name, const struct type *type)
+destructor_name_p (const char *name, struct type *type)
{
if (name[0] == '~')
{
- char *dname = type_name_no_tag (type);
- char *cp = strchr (dname, '<');
+ const char *dname = type_name_no_tag_or_error (type);
+ const char *cp = strchr (dname, '<');
unsigned int len;
/* Do not compare the template part for template classes. */
}
/* Compares the two method/function types T1 and T2 for "equality"
- with respect to the the methods' parameters. If the types of the
+ with respect to the methods' parameters. If the types of the
two parameter lists are the same, returns 1; 0 otherwise. This
comparison may ignore any artificial parameters in T1 if
SKIP_ARTIFICIAL is non-zero. This function will ALWAYS skip
int ii;
j = -1;
- for (ii = 0; ii < TYPE_FN_FIELDLIST_LENGTH (t, i);
- ++ii)
+ for (ii = 0; ii < len; ++ii)
{
/* Skip artificial methods. This is necessary if,
for example, the user wants to "print
subclass::subclass" with only one user-defined
- constructor. There is no ambiguity in this
- case. */
+ constructor. There is no ambiguity in this case.
+ We are careful here to allow artificial methods
+ if they are the unique result. */
if (TYPE_FN_FIELD_ARTIFICIAL (f, ii))
- continue;
+ {
+ if (j == -1)
+ j = ii;
+ continue;
+ }
/* Desired method is ambiguous if more than one
method is defined. */
- if (j != -1)
+ if (j != -1 && !TYPE_FN_FIELD_ARTIFICIAL (f, j))
error (_("non-unique member `%s' requires "
"type instantiation"), name);
j = ii;
}
+
+ if (j == -1)
+ error (_("no matching member function"));
}
if (TYPE_FN_FIELD_STATIC_P (f, j))
inappropriate context. */
struct value *
-value_of_local (const char *name, int complain)
+value_of_this (const struct language_defn *lang, int complain)
{
- struct symbol *func, *sym;
+ struct symbol *sym;
struct block *b;
struct value * ret;
struct frame_info *frame;
+ if (!lang->la_name_of_this)
+ {
+ if (complain)
+ error (_("no `this' in current language"));
+ return 0;
+ }
+
if (complain)
frame = get_selected_frame (_("no frame selected"));
else
return 0;
}
- func = get_frame_function (frame);
- if (!func)
- {
- if (complain)
- error (_("no `%s' in nameless context"), name);
- else
- return 0;
- }
-
- b = SYMBOL_BLOCK_VALUE (func);
- if (dict_empty (BLOCK_DICT (b)))
- {
- if (complain)
- error (_("no args, no `%s'"), name);
- else
- return 0;
- }
+ b = get_frame_block (frame, NULL);
- /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
- symbol instead of the LOC_ARG one (if both exist). */
- sym = lookup_block_symbol (b, name, VAR_DOMAIN);
+ sym = lookup_language_this (lang, b);
if (sym == NULL)
{
if (complain)
error (_("current stack frame does not contain a variable named `%s'"),
- name);
+ lang->la_name_of_this);
else
return NULL;
}
ret = read_var_value (sym, frame);
if (ret == 0 && complain)
- error (_("`%s' argument unreadable"), name);
+ error (_("`%s' argument unreadable"), lang->la_name_of_this);
return ret;
}
-/* C++/Objective-C: return the value of the class instance variable,
- if one exists. Flag COMPLAIN signals an error if the request is
- made in an inappropriate context. */
-
-struct value *
-value_of_this (int complain)
-{
- if (!current_language->la_name_of_this)
- return 0;
- return value_of_local (current_language->la_name_of_this, complain);
-}
-
/* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH
elements long, starting at LOWBOUND. The result has the same lower
bound as the original ARRAY. */