struct value **,
int, int *, struct type *);
-static int find_oload_champ_namespace (struct type **, int,
+static int find_oload_champ_namespace (struct value **, int,
const char *, const char *,
struct symbol ***,
struct badness_vector **,
const int no_adl);
static
-int find_oload_champ_namespace_loop (struct type **, int,
+int find_oload_champ_namespace_loop (struct value **, int,
const char *, const char *,
int, struct symbol ***,
struct badness_vector **, int *,
const int no_adl);
-static int find_oload_champ (struct type **, int, int, int,
+static int find_oload_champ (struct value **, int, int, int,
struct fn_field *, struct symbol **,
struct badness_vector **);
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;
}
-/* Create a value of numeric type TYPE that is one, and return it. */
+/* Create a not_lval value of numeric type TYPE that is one, and return it. */
struct value *
-value_one (struct type *type, enum lval_type lv)
+value_one (struct type *type)
{
struct type *type1 = check_typedef (type);
struct value *val;
val = allocate_value (type);
for (i = 0; i < high_bound - low_bound + 1; i++)
{
- tmp = value_one (eltype, lv);
+ tmp = value_one (eltype);
memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype),
value_contents_all (tmp), TYPE_LENGTH (eltype));
}
error (_("Not a numeric type."));
}
- VALUE_LVAL (val) = lv;
+ /* value_one result is never used for assignments to. */
+ gdb_assert (VALUE_LVAL (val) == not_lval);
+
return val;
}
watchpoints from trying to watch the saved frame pointer. */
value_free_to_mark (mark);
}
- else if (VALUE_LVAL (val) == lval_computed)
+ else if (VALUE_LVAL (val) == lval_computed
+ && value_computed_funcs (val)->read != NULL)
value_computed_funcs (val)->read (val);
else if (value_optimized_out (val))
/* Keep it optimized out. */;
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 (funcs->write != NULL)
+ {
+ funcs->write (toval, fromval);
+ break;
+ }
}
- break;
+ /* Fall through. */
default:
error (_("Left operand of assignment is not an lvalue."));
val = allocate_repeat_value (value_enclosing_type (arg1), count);
- read_memory (value_address (arg1),
- value_contents_all_raw (val),
- TYPE_LENGTH (value_enclosing_type (val)));
VALUE_LVAL (val) = lval_memory;
set_value_address (val, value_address (arg1));
+ read_value_memory (val, 0, value_stack (val), value_address (val),
+ value_contents_all_raw (val),
+ TYPE_LENGTH (value_enclosing_type (val)));
+
return val;
}
struct value *
-value_of_variable (struct symbol *var, struct block *b)
+value_of_variable (struct symbol *var, const struct block *b)
{
- struct value *val;
struct frame_info *frame;
if (!symbol_read_needs_frame (var))
}
}
- val = read_var_value (var, frame);
- if (!val)
- error (_("Address of symbol \"%s\" is unknown."), SYMBOL_PRINT_NAME (var));
-
- return val;
+ return read_var_value (var, frame);
}
struct value *
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. */
basetype, boffset);
}
-/* Given an array of argument types (ARGTYPES) (which includes an
+/* Given an array of arguments (ARGS) (which includes an
entry for "this" in the case of C++ methods), the number of
arguments NARGS, the NAME of a function whether it's a method or
not (METHOD), and the degree of laxness (LAX) in conforming to
resolution is permitted. */
int
-find_overload_match (struct type **arg_types, int nargs,
+find_overload_match (struct value **args, int nargs,
const char *name, enum oload_search_type method,
int lax, struct value **objp, struct symbol *fsym,
struct value **valp, struct symbol **symp,
int *staticp, const int no_adl)
{
struct value *obj = (objp ? *objp : NULL);
+ struct type *obj_type = obj ? value_type (obj) : NULL;
/* Index of best overloaded function. */
int func_oload_champ = -1;
int method_oload_champ = -1;
if (*valp)
{
*staticp = 1;
+ do_cleanups (all_cleanups);
return 0;
}
}
if (fns_ptr)
{
gdb_assert (TYPE_DOMAIN_TYPE (fns_ptr[0].type) != NULL);
- method_oload_champ = find_oload_champ (arg_types, nargs, method,
+ method_oload_champ = find_oload_champ (args, nargs, method,
num_fns, fns_ptr,
oload_syms, &method_badness);
{
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]);
+ deprecated_set_value_type (args[0],
+ TYPE_TARGET_TYPE (value_type (args[0])));
if (fsym)
{
if (func_name == NULL)
{
*symp = fsym;
+ do_cleanups (all_cleanups);
return 0;
}
- func_oload_champ = find_oload_champ_namespace (arg_types, nargs,
+ func_oload_champ = find_oload_champ_namespace (args, nargs,
func_name,
qualified_name,
&oload_syms,
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. */
if (objp)
{
struct type *temp_type = check_typedef (value_type (temp));
- struct type *obj_type = check_typedef (value_type (*objp));
+ struct type *objtype = check_typedef (obj_type);
if (TYPE_CODE (temp_type) != TYPE_CODE_PTR
- && (TYPE_CODE (obj_type) == TYPE_CODE_PTR
- || TYPE_CODE (obj_type) == TYPE_CODE_REF))
+ && (TYPE_CODE (objtype) == TYPE_CODE_PTR
+ || TYPE_CODE (objtype) == TYPE_CODE_REF))
{
temp = value_addr (temp);
}
performned. */
static int
-find_oload_champ_namespace (struct type **arg_types, int nargs,
+find_oload_champ_namespace (struct value **args, int nargs,
const char *func_name,
const char *qualified_name,
struct symbol ***oload_syms,
{
int oload_champ;
- find_oload_champ_namespace_loop (arg_types, nargs,
+ find_oload_champ_namespace_loop (args, nargs,
func_name,
qualified_name, 0,
oload_syms, oload_champ_bv,
*OLOAD_CHAMP_BV. */
static int
-find_oload_champ_namespace_loop (struct type **arg_types, int nargs,
+find_oload_champ_namespace_loop (struct value **args, int nargs,
const char *func_name,
const char *qualified_name,
int namespace_len,
{
searched_deeper = 1;
- if (find_oload_champ_namespace_loop (arg_types, nargs,
+ if (find_oload_champ_namespace_loop (args, nargs,
func_name, qualified_name,
next_namespace_len,
oload_syms, oload_champ_bv,
/* If we have reached the deepest level perform argument
determined lookup. */
if (!searched_deeper && !no_adl)
- make_symbol_overload_list_adl (arg_types, nargs, func_name);
+ {
+ int ix;
+ struct type **arg_types;
+
+ /* Prepare list of argument types for overload resolution. */
+ arg_types = (struct type **)
+ alloca (nargs * (sizeof (struct type *)));
+ for (ix = 0; ix < nargs; ix++)
+ arg_types[ix] = value_type (args[ix]);
+ make_symbol_overload_list_adl (arg_types, nargs, func_name);
+ }
while (new_oload_syms[num_fns])
++num_fns;
- new_oload_champ = find_oload_champ (arg_types, nargs, 0, num_fns,
+ new_oload_champ = find_oload_champ (args, nargs, 0, num_fns,
NULL, new_oload_syms,
&new_oload_champ_bv);
}
}
-/* Look for a function to take NARGS args of types ARG_TYPES. Find
+/* Look for a function to take NARGS args of ARGS. Find
the best match from among the overloaded methods or functions
(depending on METHOD) given by FNS_PTR or OLOAD_SYMS, respectively.
The number of methods/functions in the list is given by NUM_FNS.
It is the caller's responsibility to free *OLOAD_CHAMP_BV. */
static int
-find_oload_champ (struct type **arg_types, int nargs, int method,
+find_oload_champ (struct value **args, int nargs, int method,
int num_fns, struct fn_field *fns_ptr,
struct symbol **oload_syms,
struct badness_vector **oload_champ_bv)
/* Compare parameter types to supplied argument types. Skip
THIS for static methods. */
bv = rank_function (parm_types, nparms,
- arg_types + static_offset,
+ args + static_offset,
nargs - static_offset);
if (!*oload_champ_bv)
int static_offset)
{
int ix;
+ enum oload_classification worst = STANDARD;
for (ix = 1; ix <= nargs - static_offset; ix++)
{
NS_POINTER_CONVERSION_BADNESS or worse return NON_STANDARD. */
else if (compare_ranks (oload_champ_bv->rank[ix],
NS_POINTER_CONVERSION_BADNESS) <= 0)
- return NON_STANDARD; /* Non-standard type conversions
+ worst = NON_STANDARD; /* Non-standard type conversions
needed. */
}
- return STANDARD; /* Only standard conversions needed. */
+ /* If no INCOMPATIBLE classification was found, return the worst one
+ that was found (if any). */
+ return worst;
}
/* 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
for (i = 0; i < TYPE_NFIELDS (t2); ++i)
{
if (compare_ranks (rank_one_type (TYPE_FIELD_TYPE (t1, start + i),
- TYPE_FIELD_TYPE (t2, i)),
+ TYPE_FIELD_TYPE (t2, i), NULL),
EXACT_MATCH_BADNESS) != 0)
return 0;
}
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))
}
-/* Return the value of the local variable, if one exists.
- Flag COMPLAIN signals an error if the request is made in an
- inappropriate context. */
+/* Return the value of the local variable, if one exists. Throw error
+ otherwise, such as if the request is made in an inappropriate context. */
struct value *
-value_of_local (const char *name, int complain)
+value_of_this (const struct language_defn *lang)
{
- struct symbol *func, *sym;
+ struct symbol *sym;
struct block *b;
- struct value * ret;
struct frame_info *frame;
- if (complain)
- frame = get_selected_frame (_("no frame selected"));
- else
- {
- frame = deprecated_safe_get_selected_frame ();
- if (frame == 0)
- return 0;
- }
+ if (!lang->la_name_of_this)
+ error (_("no `this' in current language"));
- func = get_frame_function (frame);
- if (!func)
- {
- if (complain)
- error (_("no `%s' in nameless context"), name);
- else
- return 0;
- }
+ frame = get_selected_frame (_("no frame selected"));
- 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);
- else
- return NULL;
- }
+ error (_("current stack frame does not contain a variable named `%s'"),
+ lang->la_name_of_this);
- ret = read_var_value (sym, frame);
- if (ret == 0 && complain)
- error (_("`%s' argument unreadable"), name);
- return ret;
+ return read_var_value (sym, frame);
}
-/* 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. */
+/* Return the value of the local variable, if one exists. Return NULL
+ otherwise. Never throw error. */
struct value *
-value_of_this (int complain)
+value_of_this_silent (const struct language_defn *lang)
{
- if (!current_language->la_name_of_this)
- return 0;
- return value_of_local (current_language->la_name_of_this, complain);
+ struct value *ret = NULL;
+ volatile struct gdb_exception except;
+
+ TRY_CATCH (except, RETURN_MASK_ERROR)
+ {
+ ret = value_of_this (lang);
+ }
+
+ return ret;
}
/* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH