/* Perform non-arithmetic operations on values, for GDB.
- Copyright (C) 1986-2014 Free Software Foundation, Inc.
+ Copyright (C) 1986-2015 Free Software Foundation, Inc.
This file is part of GDB.
#include "cp-support.h"
#include "dfp.h"
#include "tracepoint.h"
-#include <errno.h>
-#include <string.h>
-#include "gdb_assert.h"
#include "observer.h"
#include "objfiles.h"
-#include "exceptions.h"
#include "extension.h"
extern unsigned int overload_debug;
}
if (objf_p)
- *objf_p = SYMBOL_SYMTAB (sym)->objfile;
+ *objf_p = symbol_objfile (sym);
return value_of_variable (sym, NULL);
}
deprecated_set_value_type (v, type);
return v;
}
- }
+ }
/* No superclass found, just change the pointer type. */
arg2 = value_copy (arg2);
&& TYPE_CODE (resolved_type) != TYPE_CODE_REF)
error (_("Argument to dynamic_cast must be a pointer or reference type"));
if (TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_VOID
- && TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_CLASS)
+ && TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_STRUCT)
error (_("Argument to dynamic_cast must be pointer to class or `void *'"));
class_type = check_typedef (TYPE_TARGET_TYPE (resolved_type));
if (TYPE_CODE (arg_type) == TYPE_CODE_PTR)
{
arg_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
- if (TYPE_CODE (arg_type) != TYPE_CODE_CLASS)
+ if (TYPE_CODE (arg_type) != TYPE_CODE_STRUCT)
error (_("Argument to dynamic_cast does "
"not have pointer to class type"));
}
}
else
{
- if (TYPE_CODE (arg_type) != TYPE_CODE_CLASS)
+ if (TYPE_CODE (arg_type) != TYPE_CODE_STRUCT)
error (_("Argument to dynamic_cast does not have class type"));
}
error (_("Value being assigned to is no longer active."));
gdbarch = get_frame_arch (frame);
- if (gdbarch_convert_register_p (gdbarch, VALUE_REGNUM (toval), type))
+
+ if (value_bitsize (toval))
{
- /* If TOVAL is a special machine register requiring
- conversion of program values to a special raw
- format. */
- gdbarch_value_to_register (gdbarch, frame,
- VALUE_REGNUM (toval), type,
- value_contents (fromval));
+ struct value *parent = value_parent (toval);
+ 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)
+ + HOST_CHAR_BIT - 1)
+ / HOST_CHAR_BIT;
+
+ if (changed_len > (int) sizeof (LONGEST))
+ error (_("Can't handle bitfields which "
+ "don't fit in a %d bit word."),
+ (int) sizeof (LONGEST) * HOST_CHAR_BIT);
+
+ if (!get_frame_register_bytes (frame, value_reg, offset,
+ changed_len, buffer,
+ &optim, &unavail))
+ {
+ if (optim)
+ throw_error (OPTIMIZED_OUT_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));
+
+ put_frame_register_bytes (frame, value_reg, offset,
+ changed_len, buffer);
}
else
{
- if (value_bitsize (toval))
+ if (gdbarch_convert_register_p (gdbarch, VALUE_REGNUM (toval),
+ type))
{
- struct value *parent = value_parent (toval);
- 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)
- + HOST_CHAR_BIT - 1)
- / HOST_CHAR_BIT;
-
- if (changed_len > (int) sizeof (LONGEST))
- error (_("Can't handle bitfields which "
- "don't fit in a %d bit word."),
- (int) sizeof (LONGEST) * HOST_CHAR_BIT);
-
- if (!get_frame_register_bytes (frame, value_reg, offset,
- changed_len, buffer,
- &optim, &unavail))
- {
- if (optim)
- throw_error (OPTIMIZED_OUT_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));
-
- put_frame_register_bytes (frame, value_reg, offset,
- changed_len, buffer);
+ /* If TOVAL is a special machine register requiring
+ conversion of program values to a special raw
+ format. */
+ gdbarch_value_to_register (gdbarch, frame,
+ VALUE_REGNUM (toval), type,
+ value_contents (fromval));
}
else
{
}
}
+ observer_notify_register_changed (frame, value_reg);
if (deprecated_register_changed_hook)
deprecated_register_changed_hook (-1);
break;
tt2 = check_typedef (value_type (t2[i]));
if (TYPE_CODE (tt1) == TYPE_CODE_REF
- /* We should be doing hairy argument matching, as below. */
+ /* We should be doing hairy argument matching, as below. */
&& (TYPE_CODE (check_typedef (TYPE_TARGET_TYPE (tt1)))
== TYPE_CODE (tt2)))
{
}
if (t_field_name
- && (t_field_name[0] == '\0'
- || (TYPE_CODE (type) == TYPE_CODE_UNION
- && (strcmp_iw (t_field_name, "else") == 0))))
+ && t_field_name[0] == '\0')
{
struct type *field_type = TYPE_FIELD_TYPE (type, i);
const char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
/* FIXME! May need to check for ARM demangling here. */
- if (strncmp (t_field_name, "__", 2) == 0 ||
- strncmp (t_field_name, "op", 2) == 0 ||
- strncmp (t_field_name, "type", 4) == 0)
+ if (startswith (t_field_name, "__") ||
+ startswith (t_field_name, "op") ||
+ startswith (t_field_name, "type"))
{
if (cplus_demangle_opname (t_field_name, dem_opname, DMGL_ANSI))
t_field_name = dem_opname;
/* The virtual base class pointer might have been
clobbered by the user program. Make sure that it
- still points to a valid memory location. */
+ still points to a valid memory location. */
if (offset < 0 || offset >= TYPE_LENGTH (type))
{
return v;
}
- v = search_struct_method (name, argp, args, 0,
- static_memfuncp, t);
+ v = search_struct_method (name, argp, args, 0,
+ static_memfuncp, t);
if (v == (struct value *) - 1)
{
ADL overload candidates when performing overload resolution for a fully
qualified name.
+ If NOSIDE is EVAL_AVOID_SIDE_EFFECTS, then OBJP's memory cannot be
+ read while picking the best overload match (it may be all zeroes and thus
+ not have a vtable pointer), in which case skip virtual function lookup.
+ This is ok as typically EVAL_AVOID_SIDE_EFFECTS is only used to determine
+ the result type.
+
Note: This function does *not* check the value of
overload_resolution. Caller must check it to see whether overload
resolution is permitted. */
const char *name, enum oload_search_type method,
struct value **objp, struct symbol *fsym,
struct value **valp, struct symbol **symp,
- int *staticp, const int no_adl)
+ int *staticp, const int no_adl,
+ const enum noside noside)
{
struct value *obj = (objp ? *objp : NULL);
struct type *obj_type = obj ? value_type (obj) : NULL;
value_find_oload_method_list above. */
if (fns_ptr)
{
- gdb_assert (TYPE_DOMAIN_TYPE (fns_ptr[0].type) != NULL);
+ gdb_assert (TYPE_SELF_TYPE (fns_ptr[0].type) != NULL);
src_method_oload_champ = find_oload_champ (args, nargs,
num_fns, fns_ptr, NULL,
{
if (src_method_oload_champ >= 0)
{
- if (TYPE_FN_FIELD_VIRTUAL_P (fns_ptr, method_oload_champ))
- *valp = value_virtual_fn_field (&temp, fns_ptr, method_oload_champ,
- basetype, boffset);
+ if (TYPE_FN_FIELD_VIRTUAL_P (fns_ptr, method_oload_champ)
+ && noside != EVAL_AVOID_SIDE_EFFECTS)
+ {
+ *valp = value_virtual_fn_field (&temp, fns_ptr,
+ method_oload_champ, basetype,
+ boffset);
+ }
else
*valp = value_fn_field (&temp, fns_ptr, method_oload_champ,
basetype, boffset);
parm_types[jj] = (fns_ptr != NULL
? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj].type)
: TYPE_FIELD_TYPE (SYMBOL_TYPE (oload_syms[ix]),
- jj));
+ jj));
}
/* Compare parameter types to supplied argument types. Skip
type = check_typedef (value_type (ptr));
gdb_assert (type != NULL
&& TYPE_CODE (type) == TYPE_CODE_MEMBERPTR);
- tmp = lookup_pointer_type (TYPE_DOMAIN_TYPE (type));
+ tmp = lookup_pointer_type (TYPE_SELF_TYPE (type));
v = value_cast_pointers (tmp, v, 1);
mem_offset = value_as_long (ptr);
tmp = lookup_pointer_type (TYPE_TARGET_TYPE (type));
const char *t_field_name = TYPE_FN_FIELDLIST_NAME (t, i);
char dem_opname[64];
- if (strncmp (t_field_name, "__", 2) == 0
- || strncmp (t_field_name, "op", 2) == 0
- || strncmp (t_field_name, "type", 4) == 0)
+ if (startswith (t_field_name, "__")
+ || startswith (t_field_name, "op")
+ || startswith (t_field_name, "type"))
{
if (cplus_demangle_opname (t_field_name,
dem_opname, DMGL_ANSI))
sym = cp_lookup_symbol_namespace (namespace_name, name,
get_selected_block (0), VAR_DOMAIN);
- if (sym == NULL)
- {
- char *concatenated_name = alloca (strlen (namespace_name) + 2
- + strlen (name) + 1);
-
- sprintf (concatenated_name, "%s::%s", namespace_name, name);
- sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
- }
-
if (sym == NULL)
return NULL;
else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
else
result = value_of_variable (sym, get_selected_block (0));
- if (result && want_address)
+ if (want_address)
result = value_addr (result);
return result;
value_rtti_indirect_type (struct value *v, int *full,
int *top, int *using_enc)
{
- struct value *target;
+ struct value *target = NULL;
struct type *type, *real_type, *target_type;
type = value_type (v);
if (TYPE_CODE (type) == TYPE_CODE_REF)
target = coerce_ref (v);
else if (TYPE_CODE (type) == TYPE_CODE_PTR)
- target = value_ind (v);
+ {
+
+ TRY
+ {
+ target = value_ind (v);
+ }
+ CATCH (except, RETURN_MASK_ERROR)
+ {
+ if (except.error == MEMORY_ERROR)
+ {
+ /* value_ind threw a memory error. The pointer is NULL or
+ contains an uninitialized value: we can't determine any
+ type. */
+ return NULL;
+ }
+ throw_exception (except);
+ }
+ END_CATCH
+ }
else
return NULL;
value_of_this_silent (const struct language_defn *lang)
{
struct value *ret = NULL;
- volatile struct gdb_exception except;
- TRY_CATCH (except, RETURN_MASK_ERROR)
+ TRY
{
ret = value_of_this (lang);
}
+ CATCH (except, RETURN_MASK_ERROR)
+ {
+ }
+ END_CATCH
return ret;
}