X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Fvalops.c;h=8fccfe930191c2cbf19c4bee41df5776d741bf64;hb=ba18742c3a1b62ff218db99bee47bb932af6dab9;hp=c1bb93776ad645b2350e505d8354ce7a2c0d7cac;hpb=c973d0aa4a2c737ab527ae44a617f1c357e07364;p=external%2Fbinutils.git diff --git a/gdb/valops.c b/gdb/valops.c index c1bb937..8fccfe9 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1,6 +1,6 @@ /* Perform non-arithmetic operations on values, for GDB. - Copyright (C) 1986-2017 Free Software Foundation, Inc. + Copyright (C) 1986-2018 Free Software Foundation, Inc. This file is part of GDB. @@ -34,7 +34,7 @@ #include "infcall.h" #include "dictionary.h" #include "cp-support.h" -#include "dfp.h" +#include "target-float.h" #include "tracepoint.h" #include "observer.h" #include "objfiles.h" @@ -68,7 +68,8 @@ int find_oload_champ_namespace_loop (struct value **, int, const int no_adl); static int find_oload_champ (struct value **, int, int, - struct fn_field *, VEC (xmethod_worker_ptr) *, + struct fn_field *, + const std::vector *, struct symbol **, struct badness_vector **); static int oload_method_static_p (struct fn_field *, int); @@ -98,11 +99,9 @@ static struct value *cast_into_complex (struct type *, struct value *); static void find_method_list (struct value **, const char *, LONGEST, struct type *, struct fn_field **, int *, - VEC (xmethod_worker_ptr) **, + std::vector *, struct type **, LONGEST *); -void _initialize_valops (void); - #if 0 /* Flag for whether we want to abandon failed expression evals by default. */ @@ -192,7 +191,7 @@ value_allocate_space_in_inferior (int len) struct value *blocklen; blocklen = value_from_longest (builtin_type (gdbarch)->builtin_int, len); - val = call_function_by_hand (val, 1, &blocklen); + val = call_function_by_hand (val, NULL, 1, &blocklen); if (value_logical_not (val)) { if (!target_has_execution) @@ -464,24 +463,21 @@ value_cast (struct type *type, struct value *arg2) return v; } - if (code1 == TYPE_CODE_FLT && scalar) - return value_from_double (to_type, value_as_double (arg2)); - else if (code1 == TYPE_CODE_DECFLOAT && scalar) + if (is_floating_type (type) && scalar) { - enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); - int dec_len = TYPE_LENGTH (type); - gdb_byte dec[16]; + if (is_floating_value (arg2)) + { + struct value *v = allocate_value (to_type); + target_float_convert (value_contents (arg2), type2, + value_contents_raw (v), type); + return v; + } - if (code2 == TYPE_CODE_FLT) - decimal_from_floating (arg2, dec, dec_len, byte_order); - else if (code2 == TYPE_CODE_DECFLOAT) - decimal_convert (value_contents (arg2), TYPE_LENGTH (type2), - byte_order, dec, dec_len, byte_order); + /* The only option left is an integral type. */ + if (TYPE_UNSIGNED (type2)) + return value_from_ulongest (to_type, value_as_long (arg2)); else - /* The only option left is an integral type. */ - decimal_from_integral (arg2, dec, dec_len, byte_order); - - return value_from_decfloat (to_type, dec); + return value_from_longest (to_type, value_as_long (arg2)); } else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM || code1 == TYPE_CODE_RANGE) @@ -865,19 +861,7 @@ value_one (struct type *type) struct type *type1 = check_typedef (type); struct value *val; - if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT) - { - enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); - gdb_byte v[16]; - - decimal_from_string (v, TYPE_LENGTH (type), byte_order, "1"); - val = value_from_decfloat (type, v); - } - else if (TYPE_CODE (type1) == TYPE_CODE_FLT) - { - val = value_from_double (type, (DOUBLEST) 1); - } - else if (is_integral_type (type1)) + if (is_integral_type (type1) || is_floating_type (type1)) { val = value_from_longest (type, (LONGEST) 1); } @@ -2299,12 +2283,11 @@ static void find_method_list (struct value **argp, const char *method, LONGEST offset, struct type *type, struct fn_field **fn_list, int *num_fns, - VEC (xmethod_worker_ptr) **xm_worker_vec, + std::vector *xm_worker_vec, struct type **basetype, LONGEST *boffset) { int i; struct fn_field *f = NULL; - VEC (xmethod_worker_ptr) *worker_vec = NULL, *new_vec = NULL; gdb_assert (fn_list != NULL && xm_worker_vec != NULL); type = check_typedef (type); @@ -2345,12 +2328,7 @@ find_method_list (struct value **argp, const char *method, and hence there is no point restricting them with something like method hiding. Moreover, if hiding is done for xmethods as well, then we will have to provide a mechanism to un-hide (like the 'using' construct). */ - worker_vec = get_matching_xmethod_workers (type, method); - new_vec = VEC_merge (xmethod_worker_ptr, *xm_worker_vec, worker_vec); - - VEC_free (xmethod_worker_ptr, *xm_worker_vec); - VEC_free (xmethod_worker_ptr, worker_vec); - *xm_worker_vec = new_vec; + get_matching_xmethod_workers (type, method, xm_worker_vec); /* If source methods are not found in current class, look for them in the base classes. We also have to go through the base classes to gather @@ -2399,7 +2377,7 @@ static void value_find_oload_method_list (struct value **argp, const char *method, LONGEST offset, struct fn_field **fn_list, int *num_fns, - VEC (xmethod_worker_ptr) **xm_worker_vec, + std::vector *xm_worker_vec, struct type **basetype, LONGEST *boffset) { struct type *t; @@ -2426,7 +2404,7 @@ value_find_oload_method_list (struct value **argp, const char *method, /* Clear the lists. */ *fn_list = NULL; *num_fns = 0; - *xm_worker_vec = NULL; + xm_worker_vec->clear (); find_method_list (argp, method, 0, t, fn_list, num_fns, xm_worker_vec, basetype, boffset); @@ -2505,8 +2483,8 @@ find_overload_match (struct value **args, int nargs, struct fn_field *fns_ptr = NULL; /* For non-methods, the list of overloaded function symbols. */ struct symbol **oload_syms = NULL; - /* For xmethods, the VEC of xmethod workers. */ - VEC (xmethod_worker_ptr) *xm_worker_vec = NULL; + /* For xmethods, the vector of xmethod workers. */ + std::vector xm_worker_vec; /* Number of overloaded instances being considered. */ int num_fns = 0; struct type *basetype = NULL; @@ -2551,8 +2529,8 @@ find_overload_match (struct value **args, int nargs, value_find_oload_method_list (&temp, name, 0, &fns_ptr, &num_fns, &xm_worker_vec, &basetype, &boffset); /* If this is a method only search, and no methods were found - the search has faild. */ - if (method == METHOD && (!fns_ptr || !num_fns) && !xm_worker_vec) + the search has failed. */ + if (method == METHOD && (!fns_ptr || !num_fns) && xm_worker_vec.empty ()) error (_("Couldn't find method %s%s%s"), obj_type_name, (obj_type_name && *obj_type_name) ? "::" : "", @@ -2575,15 +2553,14 @@ find_overload_match (struct value **args, int nargs, make_cleanup (xfree, src_method_badness); } - if (VEC_length (xmethod_worker_ptr, xm_worker_vec) > 0) + if (!xm_worker_vec.empty ()) { ext_method_oload_champ = find_oload_champ (args, nargs, - 0, NULL, xm_worker_vec, + 0, NULL, &xm_worker_vec, NULL, &ext_method_badness); ext_method_match_quality = classify_oload_match (ext_method_badness, nargs, 0); make_cleanup (xfree, ext_method_badness); - make_cleanup (free_xmethod_worker_vec, xm_worker_vec); } if (src_method_oload_champ >= 0 && ext_method_oload_champ >= 0) @@ -2800,11 +2777,8 @@ find_overload_match (struct value **args, int nargs, basetype, boffset); } else - { - *valp = value_of_xmethod (clone_xmethod_worker - (VEC_index (xmethod_worker_ptr, xm_worker_vec, - ext_method_oload_champ))); - } + *valp = value_from_xmethod + (xm_worker_vec[ext_method_oload_champ]->clone ()); } else *symp = oload_syms[func_oload_champ]; @@ -3009,12 +2983,11 @@ find_oload_champ_namespace_loop (struct value **args, int nargs, static int find_oload_champ (struct value **args, int nargs, int num_fns, struct fn_field *fns_ptr, - VEC (xmethod_worker_ptr) *xm_worker_vec, + const std::vector *xm_worker_vec, struct symbol **oload_syms, struct badness_vector **oload_champ_bv) { int ix; - int fn_count; /* A measure of how good an overloaded instance is. */ struct badness_vector *bv; /* Index of best overloaded function. */ @@ -3031,9 +3004,8 @@ find_oload_champ (struct value **args, int nargs, *oload_champ_bv = NULL; - fn_count = (xm_worker_vec != NULL - ? VEC_length (xmethod_worker_ptr, xm_worker_vec) - : num_fns); + int fn_count = xm_worker_vec != NULL ? xm_worker_vec->size () : num_fns; + /* Consider each candidate in turn. */ for (ix = 0; ix < fn_count; ix++) { @@ -3041,12 +3013,11 @@ find_oload_champ (struct value **args, int nargs, int static_offset = 0; int nparms; struct type **parm_types; - struct xmethod_worker *worker = NULL; if (xm_worker_vec != NULL) { - worker = VEC_index (xmethod_worker_ptr, xm_worker_vec, ix); - parm_types = get_xmethod_arg_types (worker, &nparms); + xmethod_worker *worker = (*xm_worker_vec)[ix].get (); + parm_types = worker->get_arg_types (&nparms); } else { @@ -3424,6 +3395,11 @@ value_struct_elt_for_reference (struct type *domain, int offset, { for (j = 0; j < len; ++j) { + if (TYPE_CONST (intype) != TYPE_FN_FIELD_CONST (f, j)) + continue; + if (TYPE_VOLATILE (intype) != TYPE_FN_FIELD_VOLATILE (f, j)) + continue; + if (compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype, 0) || compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype, 1))