1999-04-16 03:35:26 +02:00
|
|
|
|
/* Perform non-arithmetic operations on values, for GDB.
|
2005-02-02 01:20:07 +01:00
|
|
|
|
|
2018-01-01 05:43:02 +01:00
|
|
|
|
Copyright (C) 1986-2018 Free Software Foundation, Inc.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-07 22:19:36 +02:00
|
|
|
|
(at your option) any later version.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
|
#include "value.h"
|
|
|
|
|
#include "frame.h"
|
|
|
|
|
#include "inferior.h"
|
|
|
|
|
#include "gdbcore.h"
|
|
|
|
|
#include "target.h"
|
|
|
|
|
#include "demangle.h"
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "gdbcmd.h"
|
2001-03-01 02:39:22 +01:00
|
|
|
|
#include "regcache.h"
|
(Changes from Daniel Berlin, with revisions by Jim Blandy.)
Abstract out operations specific to particular C++ ABI's, and
invoke them through a function table. This removes the C++ ABI
dependencies scattered throughout the code, and allows us to
cleanly add support for new C++ ABI's.
* cp-abi.h, cp-abi.h, gnu-v2-abi.c, hpacc-abi.c: New files.
* c-typeprint.c, c-valprint.c, dbxread.c, eval.c, gdbtypes.c,
jv-typeprint.c, linespec.c, symtab.c, typeprint.c, valops.c:
#include "cp-abi.h". These files all use functions now declared
there.
* symtab.h (OPNAME_PREFIX_P, VTBL_PREFIX_P, DESTRUCTOR_PREFIX_P):
Deleted. These services are now provided by functions declared in
cp-abi.h.
* value.h (value_rtti_type, value_virtual_fn_field): Same.
* values.c (value_virtual_fn_field): Same, for this definition.
* valops.c (value_rtti_type): Same.
* c-typeprint.c (c_type_print_base): Use the functions from
"cp-abi.h", instead of the old macros, or hard-coded ABI-specific
tests.
* dbxread.c (record_minimal_symbol): Same.
* gdbtypes.c (get_destructor_fn_field, virtual_base_index,
virtual_base_index_skip_primaries): Same.
* jv-typeprint.c (java_type_print_base): Same.
* linespec.c (find_methods, decode_line_1): Same.
* symtab.c (gdb_mangle_name): Same.
* Makefile.in (SFILES): Add the new .c files mentioned above.
(cp_abi_h): New variable.
(COMMON_OBS): Add gnu-v2-abi.o, hpacc-abi.o, and cp-abi.o.
(cp-abi.o, gnu-v2-abi.o, hpacc-abi.o): New targets.
(c-typeprint.o, c-valprint.o, dbxread.o, eval.o, gdbtypes.o,
jv-typeprint.o, symtab.o, linespec.o, typeprint.o, valops.o): Add
dependency on $(cp_abi_h).
2001-04-27 02:19:09 +02:00
|
|
|
|
#include "cp-abi.h"
|
2003-02-19 David Carlton <carlton@math.stanford.edu>
* Makefile.in (SFILES): Add block.c.
(block_h): New.
(COMMON_OBS): Add block.o.
(block.o): New.
(x86-64-tdep.o): Add $(block_h).
(values.o, valops.o, tracepoint.o, symtab.o, symmisc.o, symfile.o)
(stack.o, printcmd.o, p-exp.tab.o, parse.o, objfiles.o)
(objc-exp.tab.o, objc-lang.o, nlmread.o, mips-tdep.o, mdebugread.o)
(m2-exp.tab.o, linespec.o, jv-lang.o, jv-exp.tab.o, infcmd.o)
(f-valprint.o, findvar.o, f-exp.tab.o, expprint.o, coffread.o)
(c-exp.tab.o, buildsym.o, breakpoint.o, blockframe.o, ax-gdb.o)
(alpha-tdep.o, ada-lang.o, ada-exp.tab.o, mi-cmd-stack.o): Ditto.
* value.h: Add opaque declaration for struct block.
* parser-defs.h, objc-lang.h, buildsym.h, breakpoint.h: Ditto.
* ada-lang.h: Ditto.
* x86-64-tdep.c: #include "block.h"
* values.c, valops.c, tracepoint.c, symtab.c, symmisc.c: Ditto.
* symfile.c, stack.c, printcmd.c, p-exp.y, parse.c: Ditto.
* objfiles.c, objc-exp.y, objc-lang.c, nlmread.c: Ditto.
* mips-tdep.c, mdebugread.c, m2-exp.y, linespec.c: Ditto.
* jv-lang.c, jv-exp.y, infcmd.c, f-valprint.c: Ditto.
* findvar.c, f-exp.y, expprint.c, coffread.c, c-exp.y: Ditto.
* buildsym.c, breakpoint.c, blockframe.c, ax-gdb.c: Ditto.
* alpha-tdep.c, ada-lang.c, ada-exp.y: Ditto.
* blockframe.c (blockvector_for_pc_sect): Move to "block.c".
(blockvector_for_pc, block_for_pc_sect, block_for_pc): Ditto.
* symtab.c (block_function): Ditto.
(contained_in): Ditto.
* frame.h: Move block_for_pc and block_for_pc_sect declarations to
block.h. Add opaque declaration for struct block.
* symtab.h: Move block_function and contained_in declarations to
block.h. Add opaque declarations for struct block, struct
blockvector.
(struct block): Move to block.h.
(struct blockvector): Ditto.
(BLOCK_START, BLOCK_END, BLOCK_FUNCTION, BLOCK_SUPERBLOCK)
(BLOCK_GCC_COMPILED, BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM)
(BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE)
(ALL_BLOCK_SYMBOLS, BLOCK_SHOULD_SORT, BLOCKVECTOR_NBLOCKS)
(BLOCKVECTOR_BLOCK, GLOBAL_BLOCK, STATIC_BLOCK, FIRST_LOCAL_BLOCK):
Ditto.
* block.c: New file.
* block.h: New file.
2003-02-19 David Carlton <carlton@math.stanford.edu>
* mi-cmd-stack.c: #include "block.h"
2003-02-20 01:01:07 +01:00
|
|
|
|
#include "block.h"
|
2003-04-21 Andrew Cagney <cagney@redhat.com>
* infcall.c: New file.
* infcall.h: New file.
* valarith.c: Include "infcall.h".
* scm-lang.c, objc-lang.cm, hppa-tdep.c, gcore.c: Ditto.
* eval.c, ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (valarith.o, scm-lang.o): Update dependencies.
(objc-lang.o, hppa-tdep.o, gcore.o): Update dependencies.
(eval.o, ada-valprint.o, ada-lang.o): Update dependencies.
(SFILES): Add "infcall.c"
(COMMON_OBS): Add "infcall.o".
(infcall.o): Specify dependencies.
* value.h (call_function_by_hand): Delete declaration.
* inferior.h (run_stack_dummy): Delete declaration.
* infcmd.c (breakpoint_auto_delete_contents): Move to "infcall.c".
(run_stack_dummy): Move to "infcall.c", merged into
call_function_by_hand.
* valops.c (call_function_by_hand): Moved to "infcall.c".
(find_function_addr, value_arg_coerce): Ditto.
(unwindonsignal_p, coerce_float_to_double): Ditto.
(_initialize_valops): Move "set/show coerce-float-to-double", and
"set/show unwindonsignal" commands to "infcall.c".
* v850-tdep.c, target.h: Update comments.
* sparc-tdep.c (sparc_fix_call_dummy): Update comments.
* sh-tdep.c (sh_init_extra_frame_info): Update comments.
(sh64_init_extra_frame_info): Update comments.
* mn10300-tdep.c: Update comments.
* mcore-tdep.c (mcore_init_extra_frame_info): Update comments.
* config/sparc/tm-sparc.h: Update comments.
* breakpoint.h: Update comments.
* avr-tdep.c (avr_init_extra_frame_info): Update comments.
* arm-tdep.c: Update comment.
2003-04-21 18:48:41 +02:00
|
|
|
|
#include "infcall.h"
|
2003-06-11 David Carlton <carlton@bactrian.org>
* dictionary.h: New.
* dictionary.c: New.
* block.h: Add opaque declaration for struct dictionary.
(struct block): Add 'dict' member; delete 'hashtable', 'nsyms',
'sym' members.
(BLOCK_DICT): New macro.
Delete macros BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM,
BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE,
BLOCK_SHOULD_SORT.
(ALL_BLOCK_SYMBOLS): Update definition.
* Makefile.in (SFILES): Add dictionary.c.
(dictionary_h): New.
(COMMON_OBS): Add dictionary.o.
(dictionary.o): New.
(ada-lang.o): Depend on dictionary_h.
(buildsym.o, coffread.o, jv-lang.o, mdebugread.o, objfiles.o)
(stack.o, symmisc.o, symtab.o, tracepoint.o, valops.o)
(mi-cmd-stack.o): Ditto.
(gdbtk-cmds.o): Update dependencies.
(gdbtk-stack.o): Ditto.
* ada-lang.c: Include dictionary.h.
(symtab_for_sym): Update uses of ALL_BLOCK_SYMBOLS.
(fill_in_ada_prototype, debug_print_block): Ditto.
(ada_add_block_symbols): Update uses of ALL_BLOCK_SYMBOLS; replace
explicit iteration by use of ALL_BLOCK_SYMBOLS. Delete variable
'is_sorted'.
* mdebugread.c: Include dictionary.h.
(struct parse_stack): Delete 'maxsyms' member.
(parse_symbol): Update calls to new_block. Delete calls to
shrink_block. Use dictionary methods.
(psymtab_to_symtab_1): Delete calls to sort_symtab_syms.
Update calls to new_symtab. Don't maintain maxsyms data.
(mylookup_symbol): Update use of ALL_BLOCK_SYMBOLS.
(add_symbol): Just call dict_add_symbol.
(new_symtab): Delete 'maxsyms' argument.
(new_symtab): Update calls to new_block.
(new_block): Delete 'maxsyms' argument; add 'function' argument.
(shrink_block): Delete function.
(fixup_sigtramp): Update call to new_block. Add symbol via
dict_add_symbol.
* jv-lang.c: Include dictionary.h.
(get_java_class_symtab): Set the BLOCK_DICT of the blocks
appropriately. Set class_symtab->free_func. Make sure the
blockvector is big enough to hold two blocks.
(add_class_symtab_symbol): Use dictionary methods.
(free_class_block): New function.
(type_from_class): Replace explicit iteration by
ALL_BLOCK_SYMBOLS.
* symtab.h (struct symtab): Replace 'free_ptr' method by
'free_func'.
* dwarf2read.c (psymtab_to_symtab_1): Delete call to
sort_symtab_syms.
* dwarfread.c (psymtab_to_symtab_1): Delete call to
sort_symtab_syms.
* coffread.c (coff_symfile_read): Delete call to sort_symtab_syms.
Include dictionary.h.
(patch_opaque_types): Update use of ALL_BLOCK_SYMBOLS.
* dbxread.c (dbx_psymtab_to_symtab_1): Delete call to
sort_symtab_syms.
* objfiles.c: Include dictionary.h.
(objfile_relocate): Update use of ALL_BLOCK_SYMBOLS.
* buildsym.c: Include dictionary.h.
(finish_block): Use dictionary methods.
(end_symtab): Set free_func to NULL, not free_ptr.
* tracepoint.c: Include dictionary.h.
(add_local_symbols): Update use of ALL_BLOCK_SYMBOLS.
(scope_info): Ditto.
* stack.c: Include dictionary.h.
(print_block_frame_locals): Update use of ALL_BLOCK_SYMBOLS.
(print_block_frame_labels, print_frame_arg_vars)
(print_frame_args): Ditto.
* symmisc.c (free_symtab_block): Use dictionary methods.
(dump_symtab): Ditto.
(free_symtab): Replace use of 'free_ptr' by 'free_func'.
Include dictionary.h.
* symfile.h: Delete declarations of sort_block_syms,
sort_symtab_syms.
* symfile.c (sort_block_syms): Delete.
(sort_symtab_syms): Delete.
* symtab.c: Include dictionary.h.
(lookup_block_symbol): Use dictionary iterators.
(find_pc_sect_symtab): Update use of ALL_BLOCK_SYMBOLS.
(search_symbols, make_symbol_completion_list): Ditto.
(make_symbol_overload_list): Ditto.
* valops.c (value_of_local): Use dict_empty.
Include dictionary.h.
2003-06-11 David Carlton <carlton@bactrian.org>
* generic/gdbtk-stack.c: Include dictionary.h.
(gdb_block_vars): Update use of ALL_BLOCK_SYMBOLS.
(gdb_get_blocks, gdb_get_vars_command): Ditto.
* generic/gdbtk-cmds.c: Include dictionary.h.
(gdb_listfuncs): Update use of ALL_BLOCK_SYMBOLS.
2003-06-11 David Carlton <carlton@bactrian.org>
* mi-cmd-stack.c: Include dictionary.h.
(list_args_or_locals): Update use of ALL_BLOCK_SYMBOLS.
2003-06-12 01:29:49 +02:00
|
|
|
|
#include "dictionary.h"
|
2003-06-12 David Carlton <carlton@bactrian.org>
* symtab.h: Delete declaration of make_symbol_overload_list.
Add declaration of lookup_partial_symbol.
* symtab.c (remove_params): Move to cp-support.c.
(overload_list_add_symbol, make_symbol_overload_list)
(sym_return_val_size, sym_return_val_index): Ditto.
(lookup_partial_symbol): Make extern.
* cp-support.h: Add declaration of make_symbol_overload_list.
* cp-support.c: Include dictionary.h, objfiles.h, frame.h,
symtab.h, and block.h.
(remove_params): Move here from symtab.c.
(overload_list_add_symbol, make_symbol_overload_list)
(sym_return_val_size, sym_return_val_index): Ditto.
* valops.c: Include cp-support.h.
* Makefile.in (cp-support.o): Depend on dictionary_h, objfiles_h,
frame_h, and block_h.
(valops.o): Depend on cp_support_h.
2003-06-12 17:33:45 +02:00
|
|
|
|
#include "cp-support.h"
|
Target FP: Add conversion routines to target-float.{c,h}
This patch adds the following conversion routines:
- target_float_to_longest
- target_float_from_longest
- target_float_from_ulongest
- target_float_convert
which call the equivalent decimal_ routines to handle decimal FP,
and call helper routines that currently still go via DOUBLEST to
handle binary FP.
The target_float_convert routine not only handles BFP<->BFP and
DFP<->DFP conversions, but also BFP<->DFP, which are implemented
by converting to a string and back.
These helpers are used in particular to implement conversion
from and to FP in value_cast, without going through DOUBLEST there.
In order to implement this for the FP<-integer case, the
pack_long / pack_unsigned_long routines are extended to support
floating-point values as output (thereby allowing use of
value_from_[u]longest with a floating-point target type).
This latter change also allows simplification of value_one.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (floatformat_to_longest): New function.
(floatformat_from_longest, floatformat_from_ulongest): Likewise.
(floatformat_convert): Likewise.
(target_float_to_longest): Likewise.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* target-float.h (target_float_to_longest): Add prototype.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* value.c (unpack_long): Use target_float_to_longest.
(pack_long): Allow FP types. Use target_float_from_longest.
(pack_unsigned_long): Likewise using target_float_from_ulongest.
* valops.c: Include "target-float.h". Do not include "dfp.h".
(value_cast): Handle conversions to FP using target_float_convert,
value_from_ulongest, and value_from_longest.
(value_one): Use value_from_longest for FP types as well.
2017-11-06 15:57:31 +01:00
|
|
|
|
#include "target-float.h"
|
2011-02-14 12:21:25 +01:00
|
|
|
|
#include "tracepoint.h"
|
2004-04-26 11:49:36 +02:00
|
|
|
|
#include "observer.h"
|
2008-09-11 16:27:34 +02:00
|
|
|
|
#include "objfiles.h"
|
2014-05-20 15:41:39 +02:00
|
|
|
|
#include "extension.h"
|
2017-04-29 07:34:32 +02:00
|
|
|
|
#include "byte-vector.h"
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2012-08-02 11:36:40 +02:00
|
|
|
|
extern unsigned int overload_debug;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* Local functions. */
|
|
|
|
|
|
2002-06-14 16:34:26 +02:00
|
|
|
|
static int typecmp (int staticp, int varargs, int nargs,
|
|
|
|
|
struct field t1[], struct value *t2[]);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-02-08 21:55:43 +01:00
|
|
|
|
static struct value *search_struct_field (const char *, struct value *,
|
2015-07-06 19:10:56 +02:00
|
|
|
|
struct type *, int);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-02-08 21:55:43 +01:00
|
|
|
|
static struct value *search_struct_method (const char *, struct value **,
|
|
|
|
|
struct value **,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST, int *, struct type *);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2011-10-14 22:22:17 +02:00
|
|
|
|
static int find_oload_champ_namespace (struct value **, int,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
const char *, const char *,
|
|
|
|
|
struct symbol ***,
|
2010-05-07 16:46:28 +02:00
|
|
|
|
struct badness_vector **,
|
|
|
|
|
const int no_adl);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
static
|
2011-10-14 22:22:17 +02:00
|
|
|
|
int find_oload_champ_namespace_loop (struct value **, int,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
const char *, const char *,
|
|
|
|
|
int, struct symbol ***,
|
2010-05-07 16:46:28 +02:00
|
|
|
|
struct badness_vector **, int *,
|
|
|
|
|
const int no_adl);
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
2014-02-27 14:51:46 +01:00
|
|
|
|
static int find_oload_champ (struct value **, int, int,
|
2014-05-20 15:41:39 +02:00
|
|
|
|
struct fn_field *, VEC (xmethod_worker_ptr) *,
|
|
|
|
|
struct symbol **, struct badness_vector **);
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
2014-03-03 14:08:47 +01:00
|
|
|
|
static int oload_method_static_p (struct fn_field *, int);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
enum oload_classification { STANDARD, NON_STANDARD, INCOMPATIBLE };
|
|
|
|
|
|
|
|
|
|
static enum
|
2007-08-14 02:31:40 +02:00
|
|
|
|
oload_classification classify_oload_match (struct badness_vector *,
|
|
|
|
|
int, int);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
static struct value *value_struct_elt_for_reference (struct type *,
|
|
|
|
|
int, struct type *,
|
2014-03-27 19:16:38 +01:00
|
|
|
|
const char *,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
struct type *,
|
|
|
|
|
int, enum noside);
|
2003-09-25 18:39:39 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
static struct value *value_namespace_elt (const struct type *,
|
2014-03-27 19:16:38 +01:00
|
|
|
|
const char *, int , enum noside);
|
2003-09-25 18:39:39 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
static struct value *value_maybe_namespace_elt (const struct type *,
|
2014-03-27 19:16:38 +01:00
|
|
|
|
const char *, int,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
enum noside);
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
|
2000-05-28 03:12:42 +02:00
|
|
|
|
static CORE_ADDR allocate_space_in_inferior (int);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
static struct value *cast_into_complex (struct type *, struct value *);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
static void find_method_list (struct value **, const char *,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST, struct type *, struct fn_field **, int *,
|
2014-05-20 15:41:39 +02:00
|
|
|
|
VEC (xmethod_worker_ptr) **,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
struct type **, LONGEST *);
|
1999-04-26 20:34:20 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
#if 0
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Flag for whether we want to abandon failed expression evals by
|
|
|
|
|
default. */
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
static int auto_abandon = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int overload_resolution = 0;
|
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
|
|
|
|
static void
|
|
|
|
|
show_overload_resolution (struct ui_file *file, int from_tty,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
struct cmd_list_element *c,
|
|
|
|
|
const char *value)
|
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
|
|
|
|
{
|
2011-01-05 23:22:53 +01:00
|
|
|
|
fprintf_filtered (file, _("Overload resolution in evaluating "
|
|
|
|
|
"C++ functions is %s.\n"),
|
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
|
|
|
|
value);
|
|
|
|
|
}
|
2000-02-23 16:53:33 +01:00
|
|
|
|
|
2008-09-11 16:27:34 +02:00
|
|
|
|
/* Find the address of function name NAME in the inferior. If OBJF_P
|
|
|
|
|
is non-NULL, *OBJF_P will be set to the OBJFILE where the function
|
|
|
|
|
is defined. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2008-09-11 16:27:34 +02:00
|
|
|
|
find_function_in_inferior (const char *name, struct objfile **objf_p)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
struct block_symbol sym;
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
* symtab.h (lookup_symbol_in_language): Remove SYMTAB parameter.
(lookup_symbol): Likewise.
* symtab.c (lookup_symbol_in_language): Remove SYMTAB parameter.
(lookup_symbol): Likewise.
(search_symbols): Update.
* linespec.c (find_methods, collect_methods): Update.
(add_matching_methods, add_constructors): Update.
(decode_compound, decode_dollar, decode_variable): Update.
(lookup_prefix_sym): Update.
(symbol_found): Remove SYM_SYMTAB parameter.
Use SYMBOL_SYMTAB (sym) instead.
* gdbtypes.c (lookup_typename): Update.
(lookup_struct, lookup_union, lookup_enum): Update.
(lookup_template_type): Update.
(check_typedef): Update.
* language.c (lang_bool_type): Update.
* mdebugread.c (parse_procedure): Update.
* mi/mi-cmd-stack.c (list_args_or_locals): Update.
* parse.c (write_dollar_variable): Update.
* printcmd.c (address_info): Update.
* source.c (select_source_symtab): Update.
* stack.c (print_frame_args, print_frame_arg_vars): Update.
* valops.c (find_function_in_inferior): Update.
(value_struct_elt_for_reference): Update.
* value.c (value_static_field, value_fn_field): Update.
* alpha-mdebug-tdep.c (find_proc_desc): Update.
* arm-tdep.c (arm_skip_prologue): Update.
* mt-tdep.c (mt_skip_prologue): Update.
* xstormy16-tdep.c (xstormy16_skip_prologue): Update.
* ada-lang.h (struct ada_symbol_info): Remove SYMTAB member.
* ada-lang.c (ada_add_block_symbols): Remove SYMTAB parameter.
(add_defn_to_vec): Likewise.
(ada_add_block_symbols): Likewise.
(lookup_cached_symbol, cache_symbol): Likewise.
(standard_lookup): Update.
(ada_lookup_symbol_list): Update.
* c-valprint.c (c_val_print): Update.
* cp-support.c (cp_lookup_rtti_type): Update.
* jv-lang.c (java_lookup_class, get_java_object_type): Update.
* objc-lang.c (lookup_struct_typedef, find_imps): Update.
* p-valprint.c (pascal_val_print): Update.
* scm-lang.c (scm_lookup_name): Update.
* c-exp.y: Update.
* f-exp.y: Update.
* jv-exp.y: Update.
* m2-exp.y: Update.
* objc-exp.y: Update.
* p-exp.y: Update.
2008-05-19 17:50:10 +02:00
|
|
|
|
sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
if (sym.symbol != NULL)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
if (SYMBOL_CLASS (sym.symbol) != LOC_BLOCK)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("\"%s\" exists in this program but is not a function."),
|
1999-04-16 03:35:26 +02:00
|
|
|
|
name);
|
|
|
|
|
}
|
2008-09-11 16:27:34 +02:00
|
|
|
|
|
|
|
|
|
if (objf_p)
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
*objf_p = symbol_objfile (sym.symbol);
|
2008-09-11 16:27:34 +02:00
|
|
|
|
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
return value_of_variable (sym.symbol, sym.block);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-08-05 17:51:02 +02:00
|
|
|
|
struct bound_minimal_symbol msymbol =
|
|
|
|
|
lookup_bound_minimal_symbol (name);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2013-08-05 17:51:02 +02:00
|
|
|
|
if (msymbol.minsym != NULL)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2013-08-05 17:51:02 +02:00
|
|
|
|
struct objfile *objfile = msymbol.objfile;
|
2008-09-11 16:27:34 +02:00
|
|
|
|
struct gdbarch *gdbarch = get_objfile_arch (objfile);
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
struct type *type;
|
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new
functions which architectures can redefine, defaulting to
generic_pointer_to_address and generic_address_to_pointer.
* findvar.c (extract_typed_address, store_typed_address,
generic_pointer_to_address, generic_address_to_pointer): New
functions.
(POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default
definitions.
(extract_address, store_address): Doc fixes.
* values.c (value_as_pointer): Doc fix.
(value_from_pointer): New function.
* defs.h (extract_typed_address, store_typed_address): New
declarations.
* inferior.h (generic_address_to_pointer,
generic_pointer_to_address): New declarations.
* value.h (value_from_pointer): New declaration.
* ax-gdb.c (const_var_ref): Use value_from_pointer, not
value_from_longest.
* blockframe.c (generic_push_dummy_frame): Use read_pc and
read_sp, not read_register.
* c-valprint.c (c_val_print): Use extract_typed_address instead of
extract_address to extract vtable entries and references.
* cp-valprint.c (cp_print_value_fields): Use value_from_pointer
instead of value_from_longest to extract the vtable's address.
* eval.c (evaluate_subexp_standard): Use value_from_pointer
instead of value_from_longest to compute `this', and for doing
pointer-to-member dereferencing.
* findvar.c (read_register): Use extract_unsigned_integer, not
extract_address.
(read_var_value): Use store_typed_address instead of store_address
for building label values.
(locate_var_value): Use value_from_pointer instead of
value_from_longest.
* hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer,
instead of value_from_longest, to build arguments to __d_shl_get.
* printcmd.c (set_next_address): Use value_from_pointer, not
value_from_longest.
(x_command): Use value_from_pointer, not value_from_longest.
* tracepoint.c (set_traceframe_context): Use value_from_pointer,
not value_from_longest.
* valarith.c (value_add, value_sub): Use value_from_pointer, not
value_from_longest.
* valops.c (find_function_in_inferior, value_coerce_array,
value_coerce_function, value_addr, hand_function_call): Same.
* value.h (COERCE_REF): Use unpack_pointer, not unpack_long.
* values.c (unpack_long): Use extract_typed_address to produce
addresses from pointers and references, not extract_address.
(value_from_longest): Use store_typed_address instead of
store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
|
|
|
|
CORE_ADDR maddr;
|
2008-09-11 16:27:34 +02:00
|
|
|
|
type = lookup_pointer_type (builtin_type (gdbarch)->builtin_char);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
type = lookup_function_type (type);
|
|
|
|
|
type = lookup_pointer_type (type);
|
start change to progspace independence
This patch starts changing minimal symbols to be independent of the
program space.
Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS
and changes all the code to use it. This is needed so we can change
gdb to apply the section offset when a minsym's address is computed,
as opposed to baking the offsets into the symbol itself.
A few spots still need the unrelocated address. For these, we
introduce MSYMBOL_VALUE_RAW_ADDRESS.
As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS,
which computes the address of a bound minimal symbol. This just does
the obvious thing with the fields.
Note that this change does not actually enable program space
independence. That requires more changes to gdb. However, to ensure
that these changes compile properly, this patch does add the needed
section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has
no effect at runtime by multiplying the offset by 0.
2014-02-26 Tom Tromey <tromey@redhat.com>
* ada-lang.c (ada_main_name): Update.
(ada_add_standard_exceptions): Update.
* ada-tasks.c (ada_tasks_inferior_data_sniffer): Update.
* aix-thread.c (pdc_symbol_addrs, pd_enable): Update.
* arm-tdep.c (skip_prologue_function, arm_skip_stub): Update.
* auxv.c (ld_so_xfer_auxv): Update.
* avr-tdep.c (avr_scan_prologue): Update.
* ax-gdb.c (gen_var_ref): Update.
* blockframe.c (get_pc_function_start)
(find_pc_partial_function_gnu_ifunc): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Update.
* bsd-uthread.c (bsd_uthread_lookup_address): Update.
* c-valprint.c (c_val_print): Update.
* coff-pe-read.c (add_pe_forwarded_sym): Update.
* common/agent.c (agent_look_up_symbols): Update.
* dbxread.c (find_stab_function_addr, end_psymtab): Update.
* dwarf2loc.c (call_site_to_target_addr): Update.
* dwarf2read.c (dw2_find_pc_sect_symtab): Update.
* elfread.c (elf_gnu_ifunc_record_cache)
(elf_gnu_ifunc_resolve_by_got): Update.
* findvar.c (default_read_var_value): Update.
* frame.c (inside_main_func): Update.
* frv-tdep.c (frv_frame_this_id): Update.
* glibc-tdep.c (glibc_skip_solib_resolver): Update.
* gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline):
Update.
* hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence)
(hppa_hpux_find_dummy_bpaddr): Update.
* hppa-tdep.c (hppa_symbol_address): Update.
* infcmd.c (until_next_command): Update.
* jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal):
Update.
* linespec.c (minsym_found, add_minsym): Update.
* linux-nat.c (get_signo): Update.
* linux-thread-db.c (inferior_has_bug): Update.
* m32c-tdep.c (m32c_return_value)
(m32c_m16c_address_to_pointer): Update.
* m32r-tdep.c (m32r_frame_this_id): Update.
* m68hc11-tdep.c (m68hc11_get_register_info): Update.
* machoread.c (macho_resolve_oso_sym_with_minsym): Update.
* maint.c (maintenance_translate_address): Update.
* minsyms.c (lookup_minimal_symbol_by_pc_name): Update.
(frob_address): New function.
(lookup_minimal_symbol_by_pc_section_1): Use raw addresses,
frob_address. Rename parameter to "pc_in".
(compare_minimal_symbols, compact_minimal_symbols): Use raw
addresses.
(find_solib_trampoline_target, minimal_symbol_upper_bound):
Update.
* mips-linux-tdep.c (mips_linux_skip_resolver): Update.
* mips-tdep.c (mips_skip_pic_trampoline_code): Update.
* objc-lang.c (find_objc_msgsend): Update.
* objfiles.c (objfile_relocate1): Update.
* obsd-tdep.c (obsd_skip_solib_resolver): Update.
* p-valprint.c (pascal_val_print): Update.
* parse.c (write_exp_msymbol): Update.
* ppc-linux-tdep.c (ppc_linux_spe_context_lookup)
(ppc_elfv2_skip_entrypoint): Update.
* ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update.
* printcmd.c (build_address_symbolic, msym_info)
(address_info): Update.
* proc-service.c (ps_pglobal_lookup): Update.
* psymtab.c (find_pc_sect_psymtab_closer)
(find_pc_sect_psymtab, find_pc_sect_symtab_from_partial):
Change msymbol parameter to bound_minimal_symbol.
* ravenscar-thread.c (get_running_thread_id): Update.
* remote.c (remote_check_symbols): Update.
* sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw
address.
* sol2-tdep.c (sol2_skip_solib_resolver): Update.
* solib-dsbt.c (lm_base): Update.
* solib-frv.c (lm_base, main_got): Update.
* solib-irix.c (locate_base): Update.
* solib-som.c (som_solib_create_inferior_hook)
(link_map_start): Update.
* solib-spu.c (spu_enable_break, ocl_enable_break): Update.
* solib-svr4.c (elf_locate_base, enable_break): Update.
* spu-tdep.c (spu_get_overlay_table, spu_catch_start)
(flush_ea_cache): Update.
* stabsread.c (define_symbol, scan_file_globals): Update.
* stack.c (find_frame_funname): Update.
* symfile-debug.c (debug_qf_expand_symtabs_matching)
(debug_qf_find_pc_sect_symtab): Update.
* symfile.c (simple_read_overlay_table)
(simple_overlay_update): Update.
* symfile.h (struct quick_symbol_functions)
<find_pc_sect_symtab>: Change type of msymbol to
bound_minimal_symbol.
* symmisc.c (dump_msymbols): Update.
* symtab.c (find_pc_sect_symtab_via_partial)
(find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal)
(search_symbols, print_msymbol_info): Update.
* symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro.
(MSYMBOL_VALUE_ADDRESS): Redefine.
(BMSYMBOL_VALUE_ADDRESS): New macro.
* tracepoint.c (scope_info): Update.
* tui/tui-disasm.c (tui_find_disassembly_address)
(tui_get_begin_asm_address): Update.
* valops.c (find_function_in_inferior): Update.
* value.c (value_static_field, value_fn_field): Update.
2013-08-15 16:46:35 +02:00
|
|
|
|
maddr = BMSYMBOL_VALUE_ADDRESS (msymbol);
|
2008-09-11 16:27:34 +02:00
|
|
|
|
|
|
|
|
|
if (objf_p)
|
|
|
|
|
*objf_p = objfile;
|
|
|
|
|
|
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new
functions which architectures can redefine, defaulting to
generic_pointer_to_address and generic_address_to_pointer.
* findvar.c (extract_typed_address, store_typed_address,
generic_pointer_to_address, generic_address_to_pointer): New
functions.
(POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default
definitions.
(extract_address, store_address): Doc fixes.
* values.c (value_as_pointer): Doc fix.
(value_from_pointer): New function.
* defs.h (extract_typed_address, store_typed_address): New
declarations.
* inferior.h (generic_address_to_pointer,
generic_pointer_to_address): New declarations.
* value.h (value_from_pointer): New declaration.
* ax-gdb.c (const_var_ref): Use value_from_pointer, not
value_from_longest.
* blockframe.c (generic_push_dummy_frame): Use read_pc and
read_sp, not read_register.
* c-valprint.c (c_val_print): Use extract_typed_address instead of
extract_address to extract vtable entries and references.
* cp-valprint.c (cp_print_value_fields): Use value_from_pointer
instead of value_from_longest to extract the vtable's address.
* eval.c (evaluate_subexp_standard): Use value_from_pointer
instead of value_from_longest to compute `this', and for doing
pointer-to-member dereferencing.
* findvar.c (read_register): Use extract_unsigned_integer, not
extract_address.
(read_var_value): Use store_typed_address instead of store_address
for building label values.
(locate_var_value): Use value_from_pointer instead of
value_from_longest.
* hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer,
instead of value_from_longest, to build arguments to __d_shl_get.
* printcmd.c (set_next_address): Use value_from_pointer, not
value_from_longest.
(x_command): Use value_from_pointer, not value_from_longest.
* tracepoint.c (set_traceframe_context): Use value_from_pointer,
not value_from_longest.
* valarith.c (value_add, value_sub): Use value_from_pointer, not
value_from_longest.
* valops.c (find_function_in_inferior, value_coerce_array,
value_coerce_function, value_addr, hand_function_call): Same.
* value.h (COERCE_REF): Use unpack_pointer, not unpack_long.
* values.c (unpack_long): Use extract_typed_address to produce
addresses from pointers and references, not extract_address.
(value_from_longest): Use store_typed_address instead of
store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
|
|
|
|
return value_from_pointer (type, maddr);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (!target_has_execution)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("evaluation of this expression "
|
|
|
|
|
"requires the target program to be active"));
|
1999-07-07 22:19:36 +02:00
|
|
|
|
else
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("evaluation of this expression requires the "
|
|
|
|
|
"program to have a function \"%s\"."),
|
|
|
|
|
name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Allocate NBYTES of space in the inferior using the inferior's
|
|
|
|
|
malloc and return a value that is a pointer to the allocated
|
|
|
|
|
space. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
value_allocate_space_in_inferior (int len)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2008-09-11 16:27:34 +02:00
|
|
|
|
struct objfile *objf;
|
|
|
|
|
struct value *val = find_function_in_inferior ("malloc", &objf);
|
|
|
|
|
struct gdbarch *gdbarch = get_objfile_arch (objf);
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *blocklen;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2008-09-11 16:27:34 +02:00
|
|
|
|
blocklen = value_from_longest (builtin_type (gdbarch)->builtin_int, len);
|
Stop assuming no-debug-info functions return int
The fact that GDB defaults to assuming that functions return int, when
it has no debug info for the function has been a recurring source of
user confusion. Recently this came up on the errno pretty printer
discussions. Shortly after, it came up again on IRC, with someone
wondering why does getenv() in GDB return a negative int:
(gdb) p getenv("PATH")
$1 = -6185
This question (with s/getenv/random-other-C-runtime-function) is a FAQ
on IRC.
The reason for the above is:
(gdb) p getenv
$2 = {<text variable, no debug info>} 0x7ffff7751d80 <getenv>
(gdb) ptype getenv
type = int ()
... which means that GDB truncated the 64-bit pointer that is actually
returned from getent to 32-bit, and then sign-extended it:
(gdb) p /x -6185
$6 = 0xffffe7d7
The workaround is to cast the function to the right type, like:
(gdb) p ((char *(*) (const char *)) getenv) ("PATH")
$3 = 0x7fffffffe7d7 "/usr/local/bin:/"...
IMO, we should do better than this.
I see the "assume-int" issue the same way I see printing bogus values
for optimized-out variables instead of "<optimized out>" -- I'd much
rather that the debugger tells me "I don't know" and tells me how to
fix it than showing me bogus misleading results, making me go around
tilting at windmills.
If GDB prints a signed integer when you're expecting a pointer or
aggregate, you at least have some sense that something is off, but
consider the case of the function actually returning a 64-bit integer.
For example, compile this without debug info:
unsigned long long
function ()
{
return 0x7fffffffffffffff;
}
Currently, with pristine GDB, you get:
(gdb) p function ()
$1 = -1 # incorrect
(gdb) p /x function ()
$2 = 0xffffffff # incorrect
maybe after spending a few hours debugging you suspect something is
wrong with that -1, and do:
(gdb) ptype function
type = int ()
and maybe, just maybe, you realize that the function actually returns
unsigned long long. And you try to fix it with:
(gdb) p /x (unsigned long long) function ()
$3 = 0xffffffffffffffff # incorrect
... which still produces the wrong result, because GDB simply applied
int to unsigned long long conversion. Meaning, it sign-extended the
integer that it extracted from the return of the function, to 64-bits.
and then maybe, after asking around on IRC, you realize you have to
cast the function to a pointer of the right type, and call that. It
won't be easy, but after a few missteps, you'll get to it:
..... (gdb) p /x ((unsigned long long(*) ()) function) ()
$666 = 0x7fffffffffffffff # finally! :-)
So to improve on the user experience, this patch does the following
(interrelated) things:
- makes no-debug-info functions no longer default to "int" as return
type. Instead, they're left with NULL/"<unknown return type>"
return type.
(gdb) ptype getenv
type = <unknown return type> ()
- makes calling a function with unknown return type an error.
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
- and then to make it easier to call the function, makes it possible
to _only_ cast the return of the function to the right type,
instead of having to cast the function to a function pointer:
(gdb) p (char *) getenv ("PATH") # now Just Works
$3 = 0x7fffffffe7d7 "/usr/local/bin:/"...
(gdb) p ((char *(*) (const char *)) getenv) ("PATH") # continues working
$4 = 0x7fffffffe7d7 "/usr/local/bin:/"...
I.e., it makes GDB default the function's return type to the type
of the cast, and the function's parameters to the type of the
arguments passed down.
After this patch, here's what you'll get for the "unsigned long long"
example above:
(gdb) p function ()
'function' has unknown return type; cast the call to its declared return type
(gdb) p /x (unsigned long long) function ()
$4 = 0x7fffffffffffffff # correct!
Note that while with "print" GDB shows the name of the function that
has the problem:
(gdb) p getenv ("PATH")
'getenv' has unknown return type; cast the call to its declared return type
which can by handy in more complicated expressions, "ptype" does not:
(gdb) ptype getenv ("PATH")
function has unknown return type; cast the call to its declared return type
This will be fixed in the next patch.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_evaluate_subexp) <TYPE_CODE_FUNC>: Don't handle
TYPE_GNU_IFUNC specially here. Throw error if return type is
unknown.
* ada-typeprint.c (print_func_type): Handle functions with unknown
return type.
* c-typeprint.c (c_type_print_base): Handle functions and methods
with unknown return type.
* compile/compile-c-symbols.c (convert_symbol_bmsym)
<mst_text_gnu_ifunc>: Use nodebug_text_gnu_ifunc_symbol.
* compile/compile-c-types.c: Include "objfiles.h".
(convert_func): For functions with unknown return type, warn and
default to int.
* compile/compile-object-run.c (compile_object_run): Adjust call
to call_function_by_hand_dummy.
* elfread.c (elf_gnu_ifunc_resolve_addr): Adjust call to
call_function_by_hand.
* eval.c (evaluate_subexp_standard): Adjust calls to
call_function_by_hand. Handle functions and methods with unknown
return type. Pass expect_type to call_function_by_hand.
* f-typeprint.c (f_type_print_base): Handle functions with unknown
return type.
* gcore.c (call_target_sbrk): Adjust call to
call_function_by_hand.
* gdbtypes.c (objfile_type): Leave nodebug text symbol with NULL
return type instead of int. Make nodebug_text_gnu_ifunc_symbol be
an integer address type instead of nodebug.
* guile/scm-value.c (gdbscm_value_call): Adjust call to
call_function_by_hand.
* infcall.c (error_call_unknown_return_type): New function.
(call_function_by_hand): New "default_return_type" parameter.
Pass it down.
(call_function_by_hand_dummy): New "default_return_type"
parameter. Use it instead of defaulting to int. If there's no
default and the return type is unknown, throw an error. If
there's a default return type, and the called function has no
debug info, then assume the function is prototyped.
* infcall.h (call_function_by_hand, call_function_by_hand_dummy):
New "default_return_type" parameter.
(error_call_unknown_return_type): New declaration.
* linux-fork.c (call_lseek): Cast return type of lseek.
(inferior_call_waitpid, checkpoint_command): Adjust calls to
call_function_by_hand.
* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap): Adjust
calls to call_function_by_hand.
* m2-typeprint.c (m2_procedure): Handle functions with unknown
return type.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(value_nsstring, print_object_command): Adjust calls to
call_function_by_hand.
* p-typeprint.c (pascal_type_print_varspec_prefix): Handle
functions with unknown return type.
(pascal_type_print_func_varspec_suffix): New function.
(pascal_type_print_varspec_suffix) <TYPE_CODE_FUNC,
TYPE_CODE_METHOD>: Use it.
* python/py-value.c (valpy_call): Adjust call to
call_function_by_hand.
* rust-lang.c (rust_evaluate_funcall): Adjust call to
call_function_by_hand.
* valarith.c (value_x_binop, value_x_unop): Adjust calls to
call_function_by_hand.
* valops.c (value_allocate_space_in_inferior): Adjust call to
call_function_by_hand.
* typeprint.c (type_print_unknown_return_type): New function.
* typeprint.h (type_print_unknown_return_type): New declaration.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast
return type of munmap in infcall.
* gdb.base/break-probes.exp: Cast return type of foo in infcall.
* gdb.base/checkpoint.exp: Simplify using for loop. Cast return
type of ftell in infcall.
* gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return
type of getpid in infcall.
* gdb.base/infcall-exec.exp: Cast return type of execlp in
infcall.
* gdb.base/info-os.exp: Cast return type of getpid in infcall.
Bail on failure to extract the pid.
* gdb.base/nodebug.c: #include <stdint.h>.
(multf, multf_noproto, mult, mult_noproto, add8, add8_noproto):
New functions.
* gdb.base/nodebug.exp (test_call_promotion): New procedure.
Change expected output of print/whatis/ptype with functions with
no debug info. Test all supported languages. Call
test_call_promotion.
* gdb.compile/compile.exp: Adjust expected output to expect
warning.
* gdb.threads/siginfo-threads.exp: Likewise.
2017-09-04 21:21:13 +02:00
|
|
|
|
val = call_function_by_hand (val, NULL, 1, &blocklen);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (value_logical_not (val))
|
|
|
|
|
{
|
|
|
|
|
if (!target_has_execution)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("No memory available to program now: "
|
|
|
|
|
"you need to start the target first"));
|
1999-07-07 22:19:36 +02:00
|
|
|
|
else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("No memory available to program: call to malloc failed"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static CORE_ADDR
|
2000-07-30 03:48:28 +02:00
|
|
|
|
allocate_space_in_inferior (int len)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
return value_as_long (value_allocate_space_in_inferior (len));
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-01 18:12:49 +02:00
|
|
|
|
/* Cast struct value VAL to type TYPE and return as a value.
|
|
|
|
|
Both type and val must be of TYPE_CODE_STRUCT or TYPE_CODE_UNION
|
2008-09-09 00:16:51 +02:00
|
|
|
|
for this to work. Typedef to one of the codes is permitted.
|
|
|
|
|
Returns NULL if the cast is neither an upcast nor a downcast. */
|
2008-04-01 18:12:49 +02:00
|
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
|
value_cast_structs (struct type *type, struct value *v2)
|
|
|
|
|
{
|
|
|
|
|
struct type *t1;
|
|
|
|
|
struct type *t2;
|
|
|
|
|
struct value *v;
|
|
|
|
|
|
|
|
|
|
gdb_assert (type != NULL && v2 != NULL);
|
|
|
|
|
|
|
|
|
|
t1 = check_typedef (type);
|
|
|
|
|
t2 = check_typedef (value_type (v2));
|
|
|
|
|
|
|
|
|
|
/* Check preconditions. */
|
|
|
|
|
gdb_assert ((TYPE_CODE (t1) == TYPE_CODE_STRUCT
|
|
|
|
|
|| TYPE_CODE (t1) == TYPE_CODE_UNION)
|
|
|
|
|
&& !!"Precondition is that type is of STRUCT or UNION kind.");
|
|
|
|
|
gdb_assert ((TYPE_CODE (t2) == TYPE_CODE_STRUCT
|
|
|
|
|
|| TYPE_CODE (t2) == TYPE_CODE_UNION)
|
|
|
|
|
&& !!"Precondition is that value is of STRUCT or UNION kind");
|
|
|
|
|
|
2009-12-10 21:57:10 +01:00
|
|
|
|
if (TYPE_NAME (t1) != NULL
|
|
|
|
|
&& TYPE_NAME (t2) != NULL
|
|
|
|
|
&& !strcmp (TYPE_NAME (t1), TYPE_NAME (t2)))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2008-04-01 18:12:49 +02:00
|
|
|
|
/* Upcasting: look in the type of the source to see if it contains the
|
|
|
|
|
type of the target as a superclass. If so, we'll need to
|
|
|
|
|
offset the pointer rather than just change its type. */
|
|
|
|
|
if (TYPE_NAME (t1) != NULL)
|
|
|
|
|
{
|
|
|
|
|
v = search_struct_field (type_name_no_tag (t1),
|
2015-07-06 19:10:56 +02:00
|
|
|
|
v2, t2, 1);
|
2008-04-01 18:12:49 +02:00
|
|
|
|
if (v)
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Downcasting: look in the type of the target to see if it contains the
|
|
|
|
|
type of the source as a superclass. If so, we'll need to
|
2010-02-03 00:40:28 +01:00
|
|
|
|
offset the pointer rather than just change its type. */
|
2008-04-01 18:12:49 +02:00
|
|
|
|
if (TYPE_NAME (t2) != NULL)
|
|
|
|
|
{
|
2010-02-03 00:40:28 +01:00
|
|
|
|
/* Try downcasting using the run-time type of the value. */
|
2016-04-12 21:02:57 +02:00
|
|
|
|
int full, using_enc;
|
|
|
|
|
LONGEST top;
|
2010-02-03 00:40:28 +01:00
|
|
|
|
struct type *real_type;
|
|
|
|
|
|
|
|
|
|
real_type = value_rtti_type (v2, &full, &top, &using_enc);
|
|
|
|
|
if (real_type)
|
|
|
|
|
{
|
|
|
|
|
v = value_full_object (v2, real_type, full, top, using_enc);
|
|
|
|
|
v = value_at_lazy (real_type, value_address (v));
|
2013-10-14 09:36:13 +02:00
|
|
|
|
real_type = value_type (v);
|
2010-02-03 00:40:28 +01:00
|
|
|
|
|
|
|
|
|
/* We might be trying to cast to the outermost enclosing
|
|
|
|
|
type, in which case search_struct_field won't work. */
|
|
|
|
|
if (TYPE_NAME (real_type) != NULL
|
|
|
|
|
&& !strcmp (TYPE_NAME (real_type), TYPE_NAME (t1)))
|
|
|
|
|
return v;
|
|
|
|
|
|
2015-07-06 19:10:56 +02:00
|
|
|
|
v = search_struct_field (type_name_no_tag (t2), v, real_type, 1);
|
2010-02-03 00:40:28 +01:00
|
|
|
|
if (v)
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Try downcasting using information from the destination type
|
|
|
|
|
T2. This wouldn't work properly for classes with virtual
|
|
|
|
|
bases, but those were handled above. */
|
2008-04-01 18:12:49 +02:00
|
|
|
|
v = search_struct_field (type_name_no_tag (t2),
|
2015-07-06 19:10:56 +02:00
|
|
|
|
value_zero (t1, not_lval), t1, 1);
|
2008-04-01 18:12:49 +02:00
|
|
|
|
if (v)
|
|
|
|
|
{
|
|
|
|
|
/* Downcasting is possible (t1 is superclass of v2). */
|
2009-05-28 02:53:52 +02:00
|
|
|
|
CORE_ADDR addr2 = value_address (v2);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2009-05-28 02:53:52 +02:00
|
|
|
|
addr2 -= value_address (v) + value_embedded_offset (v);
|
2008-04-01 18:12:49 +02:00
|
|
|
|
return value_at (type, addr2);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-09 00:16:51 +02:00
|
|
|
|
|
|
|
|
|
return NULL;
|
2008-04-01 18:12:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
2006-07-13 06:31:42 +02:00
|
|
|
|
/* Cast one pointer or reference type to another. Both TYPE and
|
|
|
|
|
the type of ARG2 should be pointer types, or else both should be
|
2012-05-21 21:47:54 +02:00
|
|
|
|
reference types. If SUBCLASS_CHECK is non-zero, this will force a
|
|
|
|
|
check to see whether TYPE is a superclass of ARG2's type. If
|
|
|
|
|
SUBCLASS_CHECK is zero, then the subclass check is done only when
|
|
|
|
|
ARG2 is itself non-zero. Returns the new pointer or reference. */
|
2006-07-13 06:31:42 +02:00
|
|
|
|
|
|
|
|
|
struct value *
|
2012-05-21 21:47:54 +02:00
|
|
|
|
value_cast_pointers (struct type *type, struct value *arg2,
|
|
|
|
|
int subclass_check)
|
2006-07-13 06:31:42 +02:00
|
|
|
|
{
|
2010-05-07 20:49:27 +02:00
|
|
|
|
struct type *type1 = check_typedef (type);
|
2006-07-13 06:31:42 +02:00
|
|
|
|
struct type *type2 = check_typedef (value_type (arg2));
|
2010-05-07 20:49:27 +02:00
|
|
|
|
struct type *t1 = check_typedef (TYPE_TARGET_TYPE (type1));
|
2006-07-13 06:31:42 +02:00
|
|
|
|
struct type *t2 = check_typedef (TYPE_TARGET_TYPE (type2));
|
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (t1) == TYPE_CODE_STRUCT
|
|
|
|
|
&& TYPE_CODE (t2) == TYPE_CODE_STRUCT
|
2012-05-21 21:47:54 +02:00
|
|
|
|
&& (subclass_check || !value_logical_not (arg2)))
|
2006-07-13 06:31:42 +02:00
|
|
|
|
{
|
2008-04-01 18:12:49 +02:00
|
|
|
|
struct value *v2;
|
2006-07-13 06:31:42 +02:00
|
|
|
|
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
if (TYPE_IS_REFERENCE (type2))
|
2008-04-01 18:12:49 +02:00
|
|
|
|
v2 = coerce_ref (arg2);
|
|
|
|
|
else
|
|
|
|
|
v2 = value_ind (arg2);
|
2011-01-05 23:22:53 +01:00
|
|
|
|
gdb_assert (TYPE_CODE (check_typedef (value_type (v2)))
|
|
|
|
|
== TYPE_CODE_STRUCT && !!"Why did coercion fail?");
|
2008-04-01 18:12:49 +02:00
|
|
|
|
v2 = value_cast_structs (t1, v2);
|
|
|
|
|
/* At this point we have what we can have, un-dereference if needed. */
|
|
|
|
|
if (v2)
|
2006-07-13 06:31:42 +02:00
|
|
|
|
{
|
2008-04-01 18:12:49 +02:00
|
|
|
|
struct value *v = value_addr (v2);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2008-04-01 18:12:49 +02:00
|
|
|
|
deprecated_set_value_type (v, type);
|
|
|
|
|
return v;
|
2006-07-13 06:31:42 +02:00
|
|
|
|
}
|
2014-11-01 04:20:48 +01:00
|
|
|
|
}
|
2006-07-13 06:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* No superclass found, just change the pointer type. */
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
arg2 = value_copy (arg2);
|
2006-07-13 06:31:42 +02:00
|
|
|
|
deprecated_set_value_type (arg2, type);
|
2010-11-10 18:47:23 +01:00
|
|
|
|
set_value_enclosing_type (arg2, type);
|
2006-07-13 06:31:42 +02:00
|
|
|
|
set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */
|
|
|
|
|
return arg2;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* Cast value ARG2 to type TYPE and return as a value.
|
|
|
|
|
More general than a C cast: accepts any two types of the same length,
|
|
|
|
|
and if ARG2 is an lvalue it can be cast into anything at all. */
|
|
|
|
|
/* In C++, casts may change pointer or object representations. */
|
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_cast (struct type *type, struct value *arg2)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
enum type_code code1;
|
|
|
|
|
enum type_code code2;
|
|
|
|
|
int scalar;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
struct type *type2;
|
|
|
|
|
|
|
|
|
|
int convert_to_boolean = 0;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
if (value_type (arg2) == type)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return arg2;
|
|
|
|
|
|
2008-04-01 18:12:49 +02:00
|
|
|
|
/* Check if we are casting struct reference to struct reference. */
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
if (TYPE_IS_REFERENCE (check_typedef (type)))
|
2008-04-01 18:12:49 +02:00
|
|
|
|
{
|
|
|
|
|
/* We dereference type; then we recurse and finally
|
2011-01-12 02:23:29 +01:00
|
|
|
|
we generate value of the given reference. Nothing wrong with
|
2008-04-01 18:12:49 +02:00
|
|
|
|
that. */
|
|
|
|
|
struct type *t1 = check_typedef (type);
|
|
|
|
|
struct type *dereftype = check_typedef (TYPE_TARGET_TYPE (t1));
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
struct value *val = value_cast (dereftype, arg2);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2017-03-20 21:47:41 +01:00
|
|
|
|
return value_ref (val, TYPE_CODE (t1));
|
2008-04-01 18:12:49 +02:00
|
|
|
|
}
|
|
|
|
|
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
if (TYPE_IS_REFERENCE (check_typedef (value_type (arg2))))
|
2008-04-01 18:12:49 +02:00
|
|
|
|
/* We deref the value and then do the cast. */
|
|
|
|
|
return value_cast (type, coerce_ref (arg2));
|
|
|
|
|
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
/* Strip typedefs / resolve stubs in order to get at the type's
|
|
|
|
|
code/length, but remember the original type, to use as the
|
|
|
|
|
resulting type of the cast, in case it was a typedef. */
|
|
|
|
|
struct type *to_type = type;
|
|
|
|
|
|
2015-07-06 22:05:06 +02:00
|
|
|
|
type = check_typedef (type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
code1 = TYPE_CODE (type);
|
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
2004-11-10 19:52:25 +01:00
|
|
|
|
arg2 = coerce_ref (arg2);
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
type2 = check_typedef (value_type (arg2));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2006-07-13 06:31:42 +02:00
|
|
|
|
/* You can't cast to a reference type. See value_cast_pointers
|
|
|
|
|
instead. */
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
gdb_assert (!TYPE_IS_REFERENCE (type));
|
2006-07-13 06:31:42 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* A cast to an undetermined-length array_type, such as
|
|
|
|
|
(TYPE [])OBJECT, is treated like a cast to (TYPE [N])OBJECT,
|
|
|
|
|
where N is sizeof(OBJECT)/sizeof(TYPE). */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (code1 == TYPE_CODE_ARRAY)
|
|
|
|
|
{
|
|
|
|
|
struct type *element_type = TYPE_TARGET_TYPE (type);
|
|
|
|
|
unsigned element_length = TYPE_LENGTH (check_typedef (element_type));
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
gdb/
Replace TYPE_ARRAY_{UPPER,LOWER}_BOUND_TYPE by a bit if {un,}defined.
* c-typeprint.c (c_type_print_varspec_suffix), m2-typeprint.c
(m2_array), p-typeprint.c (pascal_type_print_varspec_prefix),
valops.c (value_cast), varobj.c (c_number_of_children): Replace
TYPE_ARRAY_UPPER_BOUND_TYPE compared to BOUND_CANNOT_BE_DETERMINED by
TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED.
* parse.c (follow_types): Use TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED.
* f-valprint.c (f77_get_dynamic_upperbound): Replace with ...
(f77_get_upperbound): ... this function handling now only
TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED.
(f77_get_dynamic_lowerbound): Replace with ...
(f77_get_lowerbound): ... this function handling now only
TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED.
(f77_get_dynamic_length_of_aggregate, f77_create_arrayprint_offset_tbl):
Update their callers.
* eval.c (evaluate_subexp_standard): Update their callers.
* f-lang.h (f77_get_dynamic_upperbound, f77_get_upperbound)
(f77_get_dynamic_lowerbound, f77_get_lowerbound): Update their
prototypes.
(BOUND_FETCH_OK, BOUND_FETCH_ERROR): Remove.
* f-typeprint.c (f_type_print_varspec_suffix, f_type_print_base): Remove
the lower_bound_was_default variable. Update the
f77_get_dynamic_upperbound, f77_get_upperbound and
TYPE_ARRAY_UPPER_BOUND_TYPE calls.
* gdbtypes.c (print_bound_type): Remove the function.
(recursive_dump_type): Remove its calls printing UPPER_BOUND_TYPE and
LOWER_BOUND_TYPE.
* gdbtypes.h (enum array_bound_type): Remove.
(struct main_type): Remove the fields upper_bound_type and
lower_bound_type. Comment the new overload of the field artificial.
(TYPE_ARRAY_UPPER_BOUND_TYPE): Replace by ...
(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED): ... this macro.
(TYPE_ARRAY_LOWER_BOUND_TYPE): Replace by ...
(TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED): ... this macro.
gdb/testsuite/
* gdb.base/maint.exp (maint print type): Remove printing
UPPER_BOUND_TYPE and LOWER_BOUND_TYPE.
2008-10-03 00:06:08 +02:00
|
|
|
|
if (element_length > 0 && TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
struct type *range_type = TYPE_INDEX_TYPE (type);
|
|
|
|
|
int val_length = TYPE_LENGTH (type2);
|
|
|
|
|
LONGEST low_bound, high_bound, new_length;
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
|
|
|
|
|
low_bound = 0, high_bound = 0;
|
|
|
|
|
new_length = val_length / element_length;
|
|
|
|
|
if (val_length % element_length != 0)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
warning (_("array element type size does not "
|
|
|
|
|
"divide object size in cast"));
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* FIXME-type-allocation: need a way to free this type when
|
|
|
|
|
we are done with it. */
|
2013-12-19 09:31:17 +01:00
|
|
|
|
range_type = create_static_range_type ((struct type *) NULL,
|
|
|
|
|
TYPE_TARGET_TYPE (range_type),
|
|
|
|
|
low_bound,
|
|
|
|
|
new_length + low_bound - 1);
|
2007-08-14 02:31:40 +02:00
|
|
|
|
deprecated_set_value_type (arg2,
|
|
|
|
|
create_array_type ((struct type *) NULL,
|
|
|
|
|
element_type,
|
|
|
|
|
range_type));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return arg2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (current_language->c_style_arrays
|
2010-10-08 18:50:55 +02:00
|
|
|
|
&& TYPE_CODE (type2) == TYPE_CODE_ARRAY
|
|
|
|
|
&& !TYPE_VECTOR (type2))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
arg2 = value_coerce_array (arg2);
|
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (type2) == TYPE_CODE_FUNC)
|
|
|
|
|
arg2 = value_coerce_function (arg2);
|
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
type2 = check_typedef (value_type (arg2));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
code2 = TYPE_CODE (type2);
|
|
|
|
|
|
|
|
|
|
if (code1 == TYPE_CODE_COMPLEX)
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
return cast_into_complex (to_type, arg2);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (code1 == TYPE_CODE_BOOL)
|
|
|
|
|
{
|
|
|
|
|
code1 = TYPE_CODE_INT;
|
|
|
|
|
convert_to_boolean = 1;
|
|
|
|
|
}
|
|
|
|
|
if (code1 == TYPE_CODE_CHAR)
|
|
|
|
|
code1 = TYPE_CODE_INT;
|
|
|
|
|
if (code2 == TYPE_CODE_BOOL || code2 == TYPE_CODE_CHAR)
|
|
|
|
|
code2 = TYPE_CODE_INT;
|
|
|
|
|
|
|
|
|
|
scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_FLT
|
2008-01-07 23:33:57 +01:00
|
|
|
|
|| code2 == TYPE_CODE_DECFLOAT || code2 == TYPE_CODE_ENUM
|
|
|
|
|
|| code2 == TYPE_CODE_RANGE);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2008-04-01 18:12:49 +02:00
|
|
|
|
if ((code1 == TYPE_CODE_STRUCT || code1 == TYPE_CODE_UNION)
|
|
|
|
|
&& (code2 == TYPE_CODE_STRUCT || code2 == TYPE_CODE_UNION)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
&& TYPE_NAME (type) != 0)
|
2008-09-09 00:16:51 +02:00
|
|
|
|
{
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
struct value *v = value_cast_structs (to_type, arg2);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2008-09-09 00:16:51 +02:00
|
|
|
|
if (v)
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
Target FP: Add conversion routines to target-float.{c,h}
This patch adds the following conversion routines:
- target_float_to_longest
- target_float_from_longest
- target_float_from_ulongest
- target_float_convert
which call the equivalent decimal_ routines to handle decimal FP,
and call helper routines that currently still go via DOUBLEST to
handle binary FP.
The target_float_convert routine not only handles BFP<->BFP and
DFP<->DFP conversions, but also BFP<->DFP, which are implemented
by converting to a string and back.
These helpers are used in particular to implement conversion
from and to FP in value_cast, without going through DOUBLEST there.
In order to implement this for the FP<-integer case, the
pack_long / pack_unsigned_long routines are extended to support
floating-point values as output (thereby allowing use of
value_from_[u]longest with a floating-point target type).
This latter change also allows simplification of value_one.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (floatformat_to_longest): New function.
(floatformat_from_longest, floatformat_from_ulongest): Likewise.
(floatformat_convert): Likewise.
(target_float_to_longest): Likewise.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* target-float.h (target_float_to_longest): Add prototype.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* value.c (unpack_long): Use target_float_to_longest.
(pack_long): Allow FP types. Use target_float_from_longest.
(pack_unsigned_long): Likewise using target_float_from_ulongest.
* valops.c: Include "target-float.h". Do not include "dfp.h".
(value_cast): Handle conversions to FP using target_float_convert,
value_from_ulongest, and value_from_longest.
(value_one): Use value_from_longest for FP types as well.
2017-11-06 15:57:31 +01:00
|
|
|
|
if (is_floating_type (type) && scalar)
|
2008-01-07 23:33:57 +01:00
|
|
|
|
{
|
Target FP: Add conversion routines to target-float.{c,h}
This patch adds the following conversion routines:
- target_float_to_longest
- target_float_from_longest
- target_float_from_ulongest
- target_float_convert
which call the equivalent decimal_ routines to handle decimal FP,
and call helper routines that currently still go via DOUBLEST to
handle binary FP.
The target_float_convert routine not only handles BFP<->BFP and
DFP<->DFP conversions, but also BFP<->DFP, which are implemented
by converting to a string and back.
These helpers are used in particular to implement conversion
from and to FP in value_cast, without going through DOUBLEST there.
In order to implement this for the FP<-integer case, the
pack_long / pack_unsigned_long routines are extended to support
floating-point values as output (thereby allowing use of
value_from_[u]longest with a floating-point target type).
This latter change also allows simplification of value_one.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (floatformat_to_longest): New function.
(floatformat_from_longest, floatformat_from_ulongest): Likewise.
(floatformat_convert): Likewise.
(target_float_to_longest): Likewise.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* target-float.h (target_float_to_longest): Add prototype.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* value.c (unpack_long): Use target_float_to_longest.
(pack_long): Allow FP types. Use target_float_from_longest.
(pack_unsigned_long): Likewise using target_float_from_ulongest.
* valops.c: Include "target-float.h". Do not include "dfp.h".
(value_cast): Handle conversions to FP using target_float_convert,
value_from_ulongest, and value_from_longest.
(value_one): Use value_from_longest for FP types as well.
2017-11-06 15:57:31 +01:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
Clean up some DFP interfaces
This cleans up a number of interfaces in dfp.c / dfp.h. Specifically:
- The decimal_from_string / decimal_to_string routines are C++-ified
to operate on std::string instead of character buffers. In the
decimal_from_string, the boolean return value now actually is bool
instead of an int.
- The decimal_from_integral and decimal_from_doublest routines take
an struct value as input. This is not really appropriate at the low
level the DFP routines sit, so this replaced them with new routines
decimal_from_longest / decimal_from_ulongest / decimal_from_doublest
that operate on contents instead.
- To mirror the decimal_from_[u]longest, a new decimal_to_longest
routine is added as well, which can be used in unpack_long to
avoid an unnecessary conversion via DOUBLEST.
Note that the decimal_from_longest / decimal_from_ulongest routines
are actually more powerful than decimal_from_integral: the old routine
would only accept integer *types* of at most four bytes size, while
the new routines accept all integer *values* that fit in an [u]int32_t,
no matter which type they came from. The DFP tests are updated to
allow for this larger range of integers that can be converted.
gdb/ChangeLog:
2017-10-05 Ulrich Weigand <uweigand@de.ibm.com>
* dfp.h (MAX_DECIMAL_STRING): Move to dfp.c.
(decimal_to_string): Return std::string object.
(decimal_from_string): Accept std::string object. Return bool.
(decimal_from_integral, decimal_from_doublest): Remove.
(decimal_from_longest): Add prototype.
(decimal_from_ulongest): Likewise.
(decimal_to_longest): Likewise.
(decimal_from_doublest): Likewise.
* dfp.c: Do not include "gdbtypes.h" or "value.h".
(MAX_DECIMAL_STRING): Move here.
(decimal_to_string): Return std::string object.
(decimal_from_string): Accept std::string object. Return bool.
(decimal_from_integral): Remove, replace by ...
(decimal_from_longest, decimal_from_ulongest): ... these new functions.
(decimal_to_longest): New function.
(decimal_from_floating): Remove, replace by ...
(decimal_from_doublest): ... this new function.
(decimal_to_doublest): Update to new decimal_to_string interface.
* value.c (unpack_long): Use decimal_to_longest.
* valops.c (value_cast): Use decimal_from_doublest instead of
decimal_from_floating. Use decimal_from_[u]longest isntead of
decimal_from_integral.
* valarith.c (value_args_as_decimal): Likewise.
* valprint.c (print_decimal_floating): Update to new
decimal_to_string interface.
* printcmd.c (printf_decfloat): Likewise.
* c-exp.y (parse_number): Update to new decimal_from_string interface.
gdb/testsuite/ChangeLog:
2017-10-05 Ulrich Weigand <uweigand@de.ibm.com>
* gdb.base/dfp-exprs.exp: Update tests to larger range of supported
integer-to-dfp conversion.
* gdb.base/dfp-test.exp: Likewise.
2017-10-05 19:14:08 +02:00
|
|
|
|
/* The only option left is an integral type. */
|
Target FP: Add conversion routines to target-float.{c,h}
This patch adds the following conversion routines:
- target_float_to_longest
- target_float_from_longest
- target_float_from_ulongest
- target_float_convert
which call the equivalent decimal_ routines to handle decimal FP,
and call helper routines that currently still go via DOUBLEST to
handle binary FP.
The target_float_convert routine not only handles BFP<->BFP and
DFP<->DFP conversions, but also BFP<->DFP, which are implemented
by converting to a string and back.
These helpers are used in particular to implement conversion
from and to FP in value_cast, without going through DOUBLEST there.
In order to implement this for the FP<-integer case, the
pack_long / pack_unsigned_long routines are extended to support
floating-point values as output (thereby allowing use of
value_from_[u]longest with a floating-point target type).
This latter change also allows simplification of value_one.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (floatformat_to_longest): New function.
(floatformat_from_longest, floatformat_from_ulongest): Likewise.
(floatformat_convert): Likewise.
(target_float_to_longest): Likewise.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* target-float.h (target_float_to_longest): Add prototype.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* value.c (unpack_long): Use target_float_to_longest.
(pack_long): Allow FP types. Use target_float_from_longest.
(pack_unsigned_long): Likewise using target_float_from_ulongest.
* valops.c: Include "target-float.h". Do not include "dfp.h".
(value_cast): Handle conversions to FP using target_float_convert,
value_from_ulongest, and value_from_longest.
(value_one): Use value_from_longest for FP types as well.
2017-11-06 15:57:31 +01:00
|
|
|
|
if (TYPE_UNSIGNED (type2))
|
|
|
|
|
return value_from_ulongest (to_type, value_as_long (arg2));
|
2008-01-07 23:33:57 +01:00
|
|
|
|
else
|
Target FP: Add conversion routines to target-float.{c,h}
This patch adds the following conversion routines:
- target_float_to_longest
- target_float_from_longest
- target_float_from_ulongest
- target_float_convert
which call the equivalent decimal_ routines to handle decimal FP,
and call helper routines that currently still go via DOUBLEST to
handle binary FP.
The target_float_convert routine not only handles BFP<->BFP and
DFP<->DFP conversions, but also BFP<->DFP, which are implemented
by converting to a string and back.
These helpers are used in particular to implement conversion
from and to FP in value_cast, without going through DOUBLEST there.
In order to implement this for the FP<-integer case, the
pack_long / pack_unsigned_long routines are extended to support
floating-point values as output (thereby allowing use of
value_from_[u]longest with a floating-point target type).
This latter change also allows simplification of value_one.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (floatformat_to_longest): New function.
(floatformat_from_longest, floatformat_from_ulongest): Likewise.
(floatformat_convert): Likewise.
(target_float_to_longest): Likewise.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* target-float.h (target_float_to_longest): Add prototype.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* value.c (unpack_long): Use target_float_to_longest.
(pack_long): Allow FP types. Use target_float_from_longest.
(pack_unsigned_long): Likewise using target_float_from_ulongest.
* valops.c: Include "target-float.h". Do not include "dfp.h".
(value_cast): Handle conversions to FP using target_float_convert,
value_from_ulongest, and value_from_longest.
(value_one): Use value_from_longest for FP types as well.
2017-11-06 15:57:31 +01:00
|
|
|
|
return value_from_longest (to_type, value_as_long (arg2));
|
2008-01-07 23:33:57 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM
|
|
|
|
|
|| code1 == TYPE_CODE_RANGE)
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
&& (scalar || code2 == TYPE_CODE_PTR
|
|
|
|
|
|| code2 == TYPE_CODE_MEMBERPTR))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
LONGEST longest;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2001-07-10 23:15:28 +02:00
|
|
|
|
/* When we cast pointers to integers, we mustn't use
|
2007-06-06 17:23:06 +02:00
|
|
|
|
gdbarch_pointer_to_address to find the address the pointer
|
2001-07-10 23:15:28 +02:00
|
|
|
|
represents, as value_as_long would. GDB should evaluate
|
|
|
|
|
expressions just as the compiler would --- and the compiler
|
|
|
|
|
sees a cast as a simple reinterpretation of the pointer's
|
|
|
|
|
bits. */
|
|
|
|
|
if (code2 == TYPE_CODE_PTR)
|
* defs.h (extract_signed_integer, extract_unsigned_integer,
extract_long_unsigned_integer, store_signed_integer,
store_unsigned_integer): Add BYTE_ORDER parameter.
* findvar.c (extract_signed_integer, extract_unsigned_integer,
extract_long_unsigned_integer, store_signed_integer,
store_unsigned_integer): Add BYTE_ORDER parameter. Use it
instead of current_gdbarch.
* gdbcore.h (read_memory_integer, safe_read_memory_integer,
read_memory_unsigned_integer, write_memory_signed_integer,
write_memory_unsigned_integer): Add BYTE_ORDER parameter.
* corefile.c (struct captured_read_memory_integer_arguments): Add
BYTE_ORDER member.
(safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into
struct captured_read_memory_integer_arguments.
(do_captured_read_memory_integer): Pass it to read_memory_integer.
(read_memory_integer): Add BYTE_ORDER parameter. Pass it to
extract_signed_integer.
(read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to
extract_unsigned_integer.
(write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it
to store_signed_integer.
(write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it
to store_unsigned_integer.
* target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter.
* target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter.
Pass it to extract_unsigned_integer.
Update calls to extract_signed_integer, extract_unsigned_integer,
extract_long_unsigned_integer, store_signed_integer,
store_unsigned_integer, read_memory_integer,
read_memory_unsigned_integer, safe_read_memory_integer,
write_memory_signed_integer, write_memory_unsigned_integer, and
get_target_memory_unsigned to pass byte order:
* ada-lang.c (ada_value_binop): Update.
* ada-valprint.c (char_at): Update.
* alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update.
* alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call,
alpha_extract_return_value, alpha_read_insn,
alpha_get_longjmp_target): Update.
* amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update.
* amd64obsd-tdep.c (amd64obsd_supply_uthread,
amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update.
* amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue,
amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel,
amd64_displaced_step_fixup): Update.
* arm-linux-tdep.c (arm_linux_sigreturn_init,
arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue,
arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc,
arm_get_next_pc, arm_extract_return_value, arm_store_return_value,
arm_return_value): Update.
* arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update.
* auxv.c (default_auxv_parse): Update.
* avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address,
avr_scan_prologue, avr_extract_return_value,
avr_frame_prev_register, avr_push_dummy_call): Update.
* bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset,
bsd_uthread_wait, bsd_uthread_thread_alive,
bsd_uthread_extra_thread_info): Update.
* c-lang.c (c_printstr, print_wchar): Update.
* cp-valprint.c (cp_print_class_member): Update.
* cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache,
cris_push_dummy_call, cris_scan_prologue, cris_store_return_value,
cris_extract_return_value, find_step_target, dip_prefix,
sixteen_bit_offset_branch_op, none_reg_mode_jump_op,
move_mem_to_reg_movem_op, get_data_from_address): Update.
* dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update.
* dwarf2-frame.c (execute_cfa_program): Update.
* dwarf2loc.c (find_location_expression): Update.
* dwarf2read.c (dwarf2_const_value): Update.
* expprint.c (print_subexp_standard): Update.
* findvar.c (unsigned_pointer_to_address, signed_pointer_to_address,
unsigned_address_to_pointer, address_to_signed_pointer,
read_var_value): Update.
* frame.c (frame_unwind_register_signed,
frame_unwind_register_unsigned, get_frame_memory_signed,
get_frame_memory_unsigned): Update.
* frame-unwind.c (frame_unwind_got_constant): Update.
* frv-linux-tdep.c (frv_linux_pc_in_sigtramp,
frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache):
Update.
* frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue,
frv_extract_return_value, find_func_descr,
frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update.
* f-valprint.c (f_val_print): Update.
* gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr):
Update.
* h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue,
h8300_push_dummy_call, h8300_extract_return_value,
h8300h_extract_return_value, h8300_store_return_value,
h8300h_store_return_value): Update.
* hppabsd-tdep.c (hppabsd_find_global_pointer): Update.
* hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register):
Update.
* hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline,
hppa64_hpux_in_solib_call_trampoline,
hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code,
hppa_hpux_sigtramp_frame_unwind_cache,
hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer,
hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern,
hppa32_hpux_search_dummy_call_sequence,
hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state,
hppa_hpux_unwind_adjust_stub): Update.
* hppa-linux-tdep.c (insns_match_pattern,
hppa_linux_find_global_pointer): Update.
* hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call,
hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call,
skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache,
hppa_pseudo_register_read, hppa_frame_prev_register_helper,
hppa_match_insns): Update.
* hpux-thread.c (hpux_thread_fetch_registers): Update.
* i386-tdep.c (i386bsd_sigcontext_addr): Update.
* i386-cygwin-tdep.c (core_process_module_section): Update.
* i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn,
amd64_darwin_sstep_at_sigreturn): Update.
* i386-darwin-tdep.c (i386_darwin_sigcontext_addr,
amd64_darwin_sigcontext_addr): Likewise.
* i386-linux-nat.c (i386_linux_sigcontext_addr): Update.
* i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update.
* i386-nto-tdep.c (i386nto_sigcontext_addr): Update.
* i386obsd-nat.c (i386obsd_supply_pcb): Update.
* i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread,
i386obsd_trapframe_cache): Update.
* i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump,
i386_analyze_frame_setup, i386_analyze_prologue,
i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache,
i386_get_longjmp_target, i386_push_dummy_call,
i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr,
i386_fetch_pointer_argument): Update.
* i387-tdep.c (i387_supply_fsave): Update.
* ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update.
* ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write,
examine_prologue, ia64_frame_cache, ia64_frame_prev_register,
ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register,
ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id,
ia64_libunwind_frame_prev_register,
ia64_libunwind_sigtramp_frame_this_id,
ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer,
find_extant_func_descr, find_func_descr,
ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id,
ia64_unwind_pc): Update.
* iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer,
iq2000_scan_prologue, iq2000_extract_return_value,
iq2000_push_dummy_call): Update.
* irix5nat.c (fill_gregset): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* jv-valprint.c (java_value_print): Update.
* lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call,
lm32_extract_return_value, lm32_store_return_value): Update.
* m32c-tdep.c (m32c_push_dummy_call, m32c_return_value,
m32c_skip_trampoline_code, m32c_m16c_address_to_pointer,
m32c_m16c_pointer_to_address): Update.
* m32r-tdep.c (m32r_store_return_value, decode_prologue,
m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value):
Update.
* m68hc11-tdep.c (m68hc11_pseudo_register_read,
m68hc11_pseudo_register_write, m68hc11_analyze_instruction,
m68hc11_push_dummy_call): Update.
* m68linux-tdep.c (m68k_linux_pc_in_sigtramp,
m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache):
Update.
* m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup,
m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache,
m68k_get_longjmp_target): Update.
* m88k-tdep.c (m88k_fetch_instruction): Update.
* mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write,
mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update.
* mi/mi-main.c (mi_cmd_data_write_memory): Update.
* mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg,
mips64_linux_get_longjmp_target, mips64_fill_gregset,
mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update.
* mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update.
* mips-tdep.c (mips_fetch_instruction, fetch_mips_16,
mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call,
mips_o32_push_dummy_call, mips_o64_push_dummy_call,
mips_single_step_through_delay, mips_skip_pic_trampoline_code,
mips_integer_to_address): Update.
* mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call):
Update.
* monitor.c (monitor_supply_register, monitor_write_memory,
monitor_read_memory_single): Update.
* moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value,
moxie_analyze_prologue): Update.
* mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor,
mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info,
mt_push_dummy_call): Update.
* objc-lang.c (read_objc_method, read_objc_methlist_nmethods,
read_objc_methlist_method, read_objc_object, read_objc_super,
read_objc_class, find_implementation_from_class): Update.
* ppc64-linux-tdep.c (ppc64_desc_entry_point,
ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache):
Update.
* ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer,
ppcobsd_sigtramp_frame_cache): Update.
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call,
do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call,
ppc64_sysv_abi_return_value): Update.
* ppc-linux-nat.c (ppc_linux_auxv_parse): Update.
* procfs.c (procfs_auxv_parse): Update.
* p-valprint.c (pascal_val_print): Update.
* regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned,
regcache_raw_write_signed, regcache_raw_write_unsigned,
regcache_cooked_read_signed, regcache_cooked_read_unsigned,
regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update.
* remote-m32r-sdi.c (m32r_fetch_register): Update.
* remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory):
Update.
* rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value,
rs6000_convert_from_func_ptr_addr, branch_dest,
rs6000_software_single_step): Update.
* rs6000-tdep.c (rs6000_in_function_epilogue_p,
ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence,
bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue,
rs6000_skip_main_prologue, rs6000_skip_trampoline_code,
rs6000_frame_cache): Update.
* s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write,
s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load,
s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache,
extend_simple_arg, s390_push_dummy_call, s390_return_value): Update.
* scm-exp.c (scm_lreadr): Update.
* scm-lang.c (scm_get_field, scm_unpack): Update.
* scm-valprint.c (scm_val_print): Update.
* score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call,
score_fetch_inst): Update.
* sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way,
sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value,
sh64_pseudo_register_read, sh64_pseudo_register_write,
sh64_frame_prev_register): Update:
* sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu,
sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu,
sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update.
* solib-darwin.c (darwin_load_image_infos): Update.
* solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2,
find_canonical_descriptor_in_load_object): Update.
* solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos,
irix_open_symbol_file_object): Update.
* solib-som.c (som_solib_create_inferior_hook, link_map_start,
som_current_sos, som_open_symbol_file_object): Update.
* solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME):
Update.
* solib-svr4.c (read_program_header, scan_dyntag_auxv,
solib_svr4_r_ldsomap): Update.
* sparc64-linux-tdep.c (sparc64_linux_step_trap): Update.
* sparc64obsd-tdep.c (sparc64obsd_supply_uthread,
sparc64obsd_collect_uthread): Update.
* sparc64-tdep.c (sparc64_pseudo_register_read,
sparc64_pseudo_register_write, sparc64_supply_gregset,
sparc64_collect_gregset): Update.
* sparc-linux-tdep.c (sparc32_linux_step_trap): Update.
* sparcobsd-tdep.c (sparc32obsd_supply_uthread,
sparc32obsd_collect_uthread): Update.
* sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code,
sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow,
sparc_collect_rwindow): Update.
* spu-linux-nat.c (parse_spufs_run): Update.
* spu-tdep.c (spu_pseudo_register_read_spu,
spu_pseudo_register_write_spu, spu_pointer_to_address,
spu_analyze_prologue, spu_in_function_epilogue_p,
spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step,
spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect,
info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist,
info_spu_dma_command, info_spu_proxydma_command): Update.
* stack.c (print_frame_nameless_args, frame_info): Update.
* symfile.c (read_target_long_array, simple_read_overlay_table,
simple_read_overlay_region_table): Update.
* target.c (debug_print_register): Update.
* tramp-frame.c (tramp_frame_start): Update.
* v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call,
v850_extract_return_value, v850_store_return_value,
* valarith.c (value_binop, value_bit_index): Update.
* valops.c (value_cast): Update.
* valprint.c (val_print_type_code_int, val_print_string,
read_string): Update.
* value.c (unpack_long, unpack_double, unpack_field_as_long,
modify_field, pack_long): Update.
* vax-tdep.c (vax_store_arguments, vax_push_dummy_call,
vax_skip_prologue): Update.
* xstormy16-tdep.c (xstormy16_push_dummy_call,
xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p,
xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry,
xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update.
* xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read,
xtensa_pseudo_register_write, xtensa_frame_cache,
xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update.
* dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral,
decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add
BYTE_ORDER parameter.
(decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT
parameters.
(decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters.
(decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters.
* dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it
instead of current_gdbarch.
(decimal_to_string, decimal_from_integral, decimal_from_floating,
decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter.
Pass it to match_endianness.
(decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT
parameters. Pass them to match_endianness.
(decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters.
Pass them to match_endianness.
(decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters.
Pass them to match_endianness.
* valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and
BYTE_ORDER_Y output parameters.
(value_binop): Update call to value_args_as_decimal.
Update calls to decimal_to_string, decimal_from_string,
decimal_from_integral, decimal_from_floating, decimal_to_doublest,
decimal_is_zero, decimal_binop, decimal_compare and decimal_convert
to pass/receive byte order:
* c-exp.y (parse_number): Update.
* printcmd.c (printf_command): Update.
* valarith.c (value_args_as_decimal, value_binop, value_logical_not,
value_equal, value_less): Update.
* valops.c (value_cast, value_one): Update.
* valprint.c (print_decimal_floating): Update.
* value.c (unpack_long, unpack_double): Update.
* python/python-value.c (valpy_nonzero): Update.
* ada-valprint.c (char_at): Add BYTE_ORDER parameter.
(printstr): Update calls to char_at.
(ada_val_print_array): Likewise.
* valprint.c (read_string): Add BYTE_ORDER parameter.
(val_print_string): Update call to read_string.
* c-lang.c (c_get_string): Likewise.
* charset.h (target_wide_charset): Add BYTE_ORDER parameter.
* charset.c (target_wide_charset): Add BYTE_ORDER parameter.
Use it instead of current_gdbarch.
* printcmd.c (printf_command): Update calls to target_wide_charset.
* c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter.
Pass to target_wide_charset. Use it instead of current_gdbarch.
(classify_type): Add BYTE_ORDER parameter. Pass to
charset_for_string_type. Allow NULL encoding pointer.
(print_wchar): Add BYTE_ORDER parameter.
(c_emit_char): Update calls to classify_type and print_wchar.
(c_printchar, c_printstr): Likewise.
* gdbarch.sh (in_solib_return_trampoline): Convert to type "m".
* gdbarch.c, gdbarch.h: Regenerate.
* arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH
parameter.
* arch-utils.c (generic_in_solib_return_trampoline): Likewise.
* hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise.
* rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise.
(rs6000_skip_trampoline_code): Update call.
* alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to
dynamic_sigtramp_offset and pc_in_sigtramp callbacks.
(alpha_read_insn): Add GDBARCH parameter.
* alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter.
(alpha_register_to_value): Pass architecture to alpha_sts.
(alpha_extract_return_value): Likewise.
(alpha_value_to_register): Pass architecture to alpha_lds.
(alpha_store_return_value): Likewise.
(alpha_read_insn): Add GDBARCH parameter.
(alpha_skip_prologue): Pass architecture to alpha_read_insn.
(alpha_heuristic_proc_start): Likewise.
(alpha_heuristic_frame_unwind_cache): Likewise.
(alpha_next_pc): Likewise.
(alpha_sigtramp_frame_this_id): Pass architecture to
tdep->dynamic_sigtramp_offset callback.
(alpha_sigtramp_frame_sniffer): Pass architecture to
tdep->pc_in_sigtramp callback.
* alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter.
(alphafbsd_sigtramp_offset): Likewise.
* alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH
parameter. Pass to alpha_read_insn.
(alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to
alpha_linux_sigtramp_offset_1.
(alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to
alpha_linux_sigtramp_offset.
(alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn
and alpha_linux_sigtramp_offset.
* alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter.
(alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to
alphanbsd_sigtramp_offset.
* alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter.
(alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to
alpha_read_insn.
(alphaobsd_sigcontext_addr): Pass architecture to
alphaobsd_sigtramp_offset.
* alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH
parameter.
* amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter.
(amd64_skip_prologue): Pass architecture to amd64_analyze_prologue.
(amd64_frame_cache): Likewise.
* arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove.
(thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue,
thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros.
* arm-wince-tdep.c: Include "frame.h".
* avr-tdep.c (EXTRACT_INSN): Remove.
(avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN.
(avr_skip_prologue): Pass architecture to avr_scan_prologue.
(avr_frame_unwind_cache): Likewise.
* cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member.
(find_step_target): Initialize it.
(get_data_from_address): Add BYTE_ORDER parameter.
(bdap_prefix): Pass byte order to get_data_from_address.
(handle_prefix_assign_mode_for_aritm_op): Likewise.
(three_operand_add_sub_cmp_and_or_op): Likewise.
(handle_inc_and_index_mode_for_aritm_op): Likewise.
* frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter.
(frv_linux_sigcontext_reg_addr): Pass architecture to
frv_linux_pc_in_sigtramp.
(frv_linux_sigtramp_frame_sniffer): Likewise.
* h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter.
(h8300_analyze_prologue): Add GDBARCH parameter. Pass to
h8300_is_argument_spill.
(h8300_frame_cache, h8300_skip_prologue): Pass architecture
to h8300_analyze_prologue.
* hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to
in_solib_call_trampoline callback.
(hppa_in_solib_call_trampoline): Add GDBARCH parameter.
* hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH
parameter.
(hppa64_push_dummy_call): Pass architecture to
hppa64_convert_code_addr_to_fptr.
(hppa_match_insns): Add GDBARCH parameter.
(hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to
hppa_match_insns.
(hppa_skip_trampoline_code): Pass architecture to hppa_match_insns.
(hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to
hppa_match_insns_relaxed.
(hppa_stub_unwind_sniffer): Pass architecture to
tdep->in_solib_call_trampoline callback.
* hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter.
(hppa32_hpux_search_dummy_call_sequence): Pass architecture to
hppa_hpux_search_pattern.
* hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter.
(hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter.
Pass to insns_match_pattern.
(hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to
hppa_linux_sigtramp_find_sigcontext.
(hppa_linux_sigtramp_frame_sniffer): Likewise.
(hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter.
(hppa64_hpux_in_solib_call_trampoline): Likewise.
* i386-tdep.c (i386_follow_jump): Add GDBARCH parameter.
(i386_analyze_frame_setup): Add GDBARCH parameter.
(i386_analyze_prologue): Add GDBARCH parameter. Pass to
i386_follow_jump and i386_analyze_frame_setup.
(i386_skip_prologue): Pass architecture to i386_analyze_prologue
and i386_follow_jump.
(i386_frame_cache): Pass architecture to i386_analyze_prologue.
(i386_pe_skip_trampoline_code): Add FRAME parameter.
* i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter.
* i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass
frame to i386_pe_skip_trampoline_code.
* ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter
to sigcontext_register_address callback.
* ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter.
(ia64_find_unwind_table): Pass architecture to
ia64_find_global_pointer.
(find_extant_func_descr): Add GDBARCH parameter.
(find_func_descr): Pass architecture to find_extant_func_descr
and ia64_find_global_pointer.
(ia64_sigtramp_frame_init_saved_regs): Pass architecture to
tdep->sigcontext_register_address callback.
* ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add
GDBARCH parameter.
* iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter.
(iq2000_frame_cache): Pass architecture to iq2000_scan_prologue.
* lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter.
(lm32_skip_prologue, lm32_frame_cache): Pass architecture to
lm32_analyze_prologue.
* m32r-tdep.c (decode_prologue): Add GDBARCH parameter.
(m32r_skip_prologue): Pass architecture to decode_prologue.
* m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter.
(m68hc11_scan_prologue): Pass architecture to
m68hc11_analyze_instruction.
* m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter.
(m68k_analyze_prologue): Pass architecture to
m68k_analyze_frame_setup.
* m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter.
(m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order
to m88k_fetch_instruction.
(m88k_skip_prologue): Pass architecture to m88k_analyze_prologue.
(m88k_frame_cache): Likewise.
* mep-tdep.c (mep_get_insn): Add GDBARCH parameter.
(mep_analyze_prologue): Pass architecture to mep_get_insn.
* mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter.
(mips32_next_pc): Pass architecture to mips_fetch_instruction.
(deal_with_atomic_sequence): Likewise.
(unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction.
(mips16_scan_prologue): Likewise.
(mips32_scan_prologue): Likewise.
(mips16_in_function_epilogue_p): Likewise.
(mips32_in_function_epilogue_p): Likewise.
(mips_about_to_return): Likewise.
(mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue.
(mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue.
(mips_skip_prologue): Pass architecture to mips16_scan_prologue
and mips32_scan_prologue.
(mips_in_function_epilogue_p): Pass architecture to
mips16_in_function_epilogue_p and
mips32_in_function_epilogue_p.
(heuristic_proc_start): Pass architecture to mips_fetch_instruction
and mips_about_to_return.
(mips_skip_mips16_trampoline_code): Pass architecture to
mips_fetch_instruction.
(fetch_mips_16): Add GDBARCH parameter.
(mips16_next_pc): Pass architecture to fetch_mips_16.
(extended_mips16_next_pc): Pass architecture to unpack_mips16 and
fetch_mips_16.
* objc-lang.c (read_objc_method, read_objc_methlist_nmethods,
read_objc_methlist_method, read_objc_object, read_objc_super,
read_objc_class): Add GDBARCH parameter.
(find_implementation_from_class): Add GDBARCH parameter, pass
to read_objc_class, read_objc_methlist_nmethods, and
read_objc_methlist_method.
(find_implementation): Add GDBARCH parameter, pass to
read_objc_object and find_implementation_from_class.
(resolve_msgsend, resolve_msgsend_stret): Pass architecture
to find_implementation.
(resolve_msgsend_super, resolve_msgsend_super_stret): Pass
architecture to read_objc_super and find_implementation_from_class.
* ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter.
(ppc64_standard_linkage1_target, ppc64_standard_linkage2_target,
ppc64_standard_linkage3_target): Pass architecture to
ppc64_desc_entry_point.
* rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter.
(skip_prologue): Pass byte order to bl_to_blrl_insn_p.
(rs6000_fetch_instruction): Add GDBARCH parameter.
(rs6000_skip_stack_check): Add GDBARCH parameter, pass to
rs6000_fetch_instruction.
(skip_prologue): Pass architecture to rs6000_fetch_instruction.
* remote-mips.c (mips_store_word): Return old_contents as host
integer value instead of target bytes.
* s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member.
(s390_analyze_prologue): Initialize it.
(extend_simple_arg): Add GDBARCH parameter.
(s390_push_dummy_call): Pass architecture to extend_simple_arg.
* scm-lang.c (scm_get_field): Add BYTE_ORDER parameter.
* scm-lang.h (scm_get_field): Add BYTE_ORDER parameter.
(SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field.
* scm-valprint.c (scm_scmval_print): Likewise.
(scm_scmlist_print, scm_ipruk, scm_scmval_print): Define
SCM_BYTE_ORDER.
* sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter.
(sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to
look_for_args_moves.
(sh64_skip_prologue): Pass architecture to
sh64_skip_prologue_hard_way.
* sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter.
(sh_skip_prologue): Pass architecture to sh_analyze_prologue.
(sh_frame_cache): Likewise.
* solib-irix.c (extract_mips_address): Add GDBARCH parameter.
(fetch_lm_info, irix_current_sos, irix_open_symbol_file_object):
Pass architecture to extract_mips_address.
* sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter.
* sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter.
(sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture
to sparc_fetch_wcookie.
(sparc32_frame_prev_register): Likewise.
* sparc64-tdep.c (sparc64_frame_prev_register): Likewise.
* sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise.
* sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise.
* spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter.
(spu_skip_prologue): Pass architecture to spu_analyze_prologue.
(spu_virtual_frame_pointer): Likewise.
(spu_frame_unwind_cache): Likewise.
(info_spu_mailbox_list): Add BYTE_ORER parameter.
(info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list.
(info_spu_dma_cmdlist): Add BYTE_ORER parameter.
(info_spu_dma_command, info_spu_proxydma_command): Pass byte order
to info_spu_dma_cmdlist.
* symfile.c (read_target_long_array): Add GDBARCH parameter.
(simple_read_overlay_table, simple_read_overlay_region_table,
simple_overlay_update_1): Pass architecture to read_target_long_array.
* v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter.
(v850_frame_cache): Pass architecture to v850_analyze_prologue.
* xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH
parameter.
(xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture
to xstormy16_analyze_prologue.
(xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter.
(xstormy16_find_jmp_table_entry): Likewise.
(xstormy16_skip_trampoline_code): Pass architecture to
xstormy16_resolve_jmp_table_entry.
(xstormy16_pointer_to_address): Likewise.
(xstormy16_address_to_pointer): Pass architecture to
xstormy16_find_jmp_table_entry.
* xtensa-tdep.c (call0_track_op): Add GDBARCH parameter.
(call0_analyze_prologue): Add GDBARCH parameter, pass to
call0_track_op.
(call0_frame_cache): Pass architecture to call0_analyze_prologue.
(xtensa_skip_prologue): Likewise.
2009-07-02 19:25:59 +02:00
|
|
|
|
longest = extract_unsigned_integer
|
|
|
|
|
(value_contents (arg2), TYPE_LENGTH (type2),
|
|
|
|
|
gdbarch_byte_order (get_type_arch (type2)));
|
2001-07-10 23:15:28 +02:00
|
|
|
|
else
|
|
|
|
|
longest = value_as_long (arg2);
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
return value_from_longest (to_type, convert_to_boolean ?
|
2000-06-15 20:54:48 +02:00
|
|
|
|
(LONGEST) (longest ? 1 : 0) : longest);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2007-08-14 02:31:40 +02:00
|
|
|
|
else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT
|
|
|
|
|
|| code2 == TYPE_CODE_ENUM
|
|
|
|
|
|| code2 == TYPE_CODE_RANGE))
|
2000-07-12 10:31:49 +02:00
|
|
|
|
{
|
2001-02-06 19:07:48 +01:00
|
|
|
|
/* TYPE_LENGTH (type) is the length of a pointer, but we really
|
|
|
|
|
want the length of an address! -- we are really dealing with
|
|
|
|
|
addresses (i.e., gdb representations) not pointers (i.e.,
|
|
|
|
|
target representations) here.
|
|
|
|
|
|
|
|
|
|
This allows things like "print *(int *)0x01000234" to work
|
|
|
|
|
without printing a misleading message -- which would
|
|
|
|
|
otherwise occur when dealing with a target having two byte
|
|
|
|
|
pointers and four byte addresses. */
|
|
|
|
|
|
* gdbtypes.c (make_pointer_type, make_reference_type,
smash_to_memberptr_type, lookup_array_range_type, check_stub_method):
Use type architecture instead of current_gdbarch.
* gdbtypes.h (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH paramter.
* gdbtypes.c (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH parameter. Use it instead of current_gdbarch.
* c-typeprint.c (c_type_print_modifier): Update call.
* parse.c (push_type_address_space): Likewise.
* findvar.c (extract_typed_address, store_typed_address): Use type
architecture instead of current_gdbarch.
* value.c (value_as_address, unpack_field_as_long): Use type architecture
instead of current_gdbarch.
* doublest.c (floatformat_from_length): Add GDBARCH argument. Use it
instead of current_gdbarch.
(floatformat_from_type): Pass type architecture.
* infcall.c (find_function_addr): Use type architecture instead
of current_gdbarch.
* valarith.c (value_bitstring_subscript, value_x_binop, value_neg,
value_bit_index): Use type architecture instead of current_gdbarch.
* valops.c (value_cast, value_slice): Likewise.
* value.h (modify_field): Add TYPE argument.
* value.c (modify_field): Add TYPE argument. Use type architecture
instead of current_gdbarch.
(set_internalvar_component): Likewise.
* eval.c (evaluate_struct_tuple): Update call.
* valops.c (value_assign): Likewise.
* ada-lang.c (modify_general_field): Likewise. Add TYPE argument.
(make_array_descriptor): Update calls.
(move_bits): Add BITS_BIG_ENDIAN_P argument. Use it instead of
current_gdbarch.
(ada_value_assign, value_assign_to_component): Update calls.
(decode_packed_array, ada_value_primitive_packed_val, ada_value_assign,
value_assign_to_component): Use type arch instead of current_gdbarch.
* printcmd.c (float_type_from_length): Remove GDBARCH argument,
use type architecture instead.
(print_scalar_formatted, printf_command): Update calls. Use type
architecture instead of current_gdbarch.
* valprint.c (val_print_type_code_int): Use type architecture
instead of current_gdbarch.
* varobj.c (value_get_print_value): Likewise.
* python/python-prettyprint.c (print_string_repr): Add GDBARCH
argument. Use it instead of current_gdbarch.
(apply_val_pretty_printer): Update call.
* ada-valprint.c (ada_val_print_1): Use type architecture instead
of current_gdbarch.
* c-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(c_val_print): Update calls passing type architecture.
* f-valprint.c (f_val_print): Use type architecture instead of
current_gdbarch.
* jv-valprint (java_value_print): Likewise.
* m2-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(print_unpacked_pointer): Update calls passing type architecture.
* scm-valprint.c (scm_scmval_print): Use type architecture instead of
current_gdbarch.
* gnu-v3-abi.c (get_class_arch): Remove.
(gnuv3_rtti_type): Use get_type_arch instead of get_class_arch. Remove
special-case check for Java classes.
(gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr,
gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value):
Use get_type_arch instead of get_class_arch.
2009-07-02 14:57:14 +02:00
|
|
|
|
int addr_bit = gdbarch_addr_bit (get_type_arch (type2));
|
2000-07-12 10:31:49 +02:00
|
|
|
|
LONGEST longest = value_as_long (arg2);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2001-02-06 19:07:48 +01:00
|
|
|
|
if (addr_bit < sizeof (LONGEST) * HOST_CHAR_BIT)
|
2000-07-12 10:31:49 +02:00
|
|
|
|
{
|
2001-02-06 19:07:48 +01:00
|
|
|
|
if (longest >= ((LONGEST) 1 << addr_bit)
|
|
|
|
|
|| longest <= -((LONGEST) 1 << addr_bit))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
warning (_("value truncated"));
|
2000-07-12 10:31:49 +02:00
|
|
|
|
}
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
return value_from_longest (to_type, longest);
|
2000-07-12 10:31:49 +02:00
|
|
|
|
}
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
else if (code1 == TYPE_CODE_METHODPTR && code2 == TYPE_CODE_INT
|
|
|
|
|
&& value_as_long (arg2) == 0)
|
|
|
|
|
{
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
struct value *result = allocate_value (to_type);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
cplus_make_method_ptr (to_type, value_contents_writeable (result), 0, 0);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
else if (code1 == TYPE_CODE_MEMBERPTR && code2 == TYPE_CODE_INT
|
|
|
|
|
&& value_as_long (arg2) == 0)
|
|
|
|
|
{
|
|
|
|
|
/* The Itanium C++ ABI represents NULL pointers to members as
|
|
|
|
|
minus one, instead of biasing the normal case. */
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
return value_from_longest (to_type, -1);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
}
|
2013-01-25 18:16:43 +01:00
|
|
|
|
else if (code1 == TYPE_CODE_ARRAY && TYPE_VECTOR (type)
|
|
|
|
|
&& code2 == TYPE_CODE_ARRAY && TYPE_VECTOR (type2)
|
|
|
|
|
&& TYPE_LENGTH (type) != TYPE_LENGTH (type2))
|
|
|
|
|
error (_("Cannot convert between vector values of different sizes"));
|
|
|
|
|
else if (code1 == TYPE_CODE_ARRAY && TYPE_VECTOR (type) && scalar
|
|
|
|
|
&& TYPE_LENGTH (type) != TYPE_LENGTH (type2))
|
|
|
|
|
error (_("can only cast scalar to vector of same size"));
|
2012-12-06 22:41:07 +01:00
|
|
|
|
else if (code1 == TYPE_CODE_VOID)
|
|
|
|
|
{
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
return value_zero (to_type, not_lval);
|
2012-12-06 22:41:07 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else if (TYPE_LENGTH (type) == TYPE_LENGTH (type2))
|
|
|
|
|
{
|
|
|
|
|
if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
return value_cast_pointers (to_type, arg2, 0);
|
2006-07-13 06:31:42 +02:00
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
arg2 = value_copy (arg2);
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
deprecated_set_value_type (arg2, to_type);
|
|
|
|
|
set_value_enclosing_type (arg2, to_type);
|
2005-02-07 21:17:28 +01:00
|
|
|
|
set_value_pointed_to_offset (arg2, 0); /* pai: chk_val */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return arg2;
|
|
|
|
|
}
|
|
|
|
|
else if (VALUE_LVAL (arg2) == lval_memory)
|
Fix type casts losing typedefs and reimplement "whatis" typedef stripping
(Ref: https://sourceware.org/ml/gdb/2017-06/msg00020.html)
Assuming int_t is a typedef to int:
typedef int int_t;
gdb currently loses this expression's typedef:
(gdb) p (int_t) 0
$1 = 0
(gdb) whatis $1
type = int
or:
(gdb) whatis (int_t) 0
type = int
or, to get "whatis" out of the way:
(gdb) maint print type (int_t) 0
...
name 'int'
code 0x8 (TYPE_CODE_INT)
...
This prevents a type printer for "int_t" kicking in, with e.g.:
(gdb) p (int_t) 0
From the manual, we can see that that "whatis (int_t) 0" command
invocation should have printed "type = int_t":
If @var{arg} is a variable or an expression, @code{whatis} prints its
literal type as it is used in the source code. If the type was
defined using a @code{typedef}, @code{whatis} will @emph{not} print
the data type underlying the @code{typedef}.
(...)
If @var{arg} is a type name that was defined using @code{typedef},
@code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
That one-level stripping is currently done here, in
gdb/eval.c:evaluate_subexp_standard, handling OP_TYPE:
...
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = exp->elts[pc + 1].type;
/* If this is a typedef, then find its immediate target. We
use check_typedef to resolve stubs, but we ignore its
result because we do not want to dig past all
typedefs. */
check_typedef (type);
if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
type = TYPE_TARGET_TYPE (type);
return allocate_value (type);
}
However, this stripping is reachable in both:
#1 - (gdb) whatis (int_t)0 # ARG is an expression with a cast to
# typedef type.
#2 - (gdb) whatis int_t # ARG is a type name.
while only case #2 should strip the typedef. Removing that code from
evaluate_subexp_standard is part of the fix. Instead, we make the
"whatis" command implementation itself strip one level of typedefs
when the command argument is a type name.
We then run into another problem, also fixed by this commit:
value_cast always drops any typedefs of the destination type.
With all that fixed, "whatis (int_t) 0" now works as expected:
(gdb) whatis int_t
type = int
(gdb) whatis (int_t)0
type = int_t
value_cast has many different exit/convertion paths, for handling many
different kinds of casts/conversions, and most of them had to be
tweaked to construct the value of the right "to" type. The new tests
try to exercise most of it, by trying castin of many different
combinations of types. With:
$ make check TESTS="*/whatis-ptype*.exp */gnu_vector.exp */dfp-test.exp"
... due to combinatorial explosion, the testsuite results for the
tests above alone grow like:
- # of expected passes 246
+ # of expected passes 3811
You'll note that the tests exposed one GCC buglet, filed here:
Missing DW_AT_type in DW_TAG_typedef of "typedef of typedef of void"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267
gdb/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* eval.c (evaluate_subexp_standard) <OP_TYPE>: Don't dig past
typedefs.
* typeprint.c (whatis_exp): If handling "whatis", and expression
is OP_TYPE, strip one typedef level. Otherwise don't strip
typedefs here.
* valops.c (value_cast): Save "to" type before resolving
stubs/typedefs. Use that type as resulting value's type.
gdb/testsuite/ChangeLog:
2017-08-21 Pedro Alves <palves@redhat.com>
* gdb.base/dfp-test.c
(d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
(v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
* gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
* gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
* gdb.base/whatis-ptype-typedefs.c: New.
* gdb.base/whatis-ptype-typedefs.exp: New.
* gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
(an_int, an_int_type, an_int_type2): New globals.
* gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
involving typedefs and cast expressions.
* gdb.python/py-prettyprint.py (class pp_int_typedef): New.
(lookup_typedefs_function): New.
(typedefs_pretty_printers_dict): New.
(top level): Register lookup_typedefs_function in
gdb.pretty_printers.
2017-08-21 12:34:32 +02:00
|
|
|
|
return value_at_lazy (to_type, value_address (arg2));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Invalid cast."));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 21:54:35 +01:00
|
|
|
|
/* The C++ reinterpret_cast operator. */
|
|
|
|
|
|
|
|
|
|
struct value *
|
|
|
|
|
value_reinterpret_cast (struct type *type, struct value *arg)
|
|
|
|
|
{
|
|
|
|
|
struct value *result;
|
|
|
|
|
struct type *real_type = check_typedef (type);
|
|
|
|
|
struct type *arg_type, *dest_type;
|
|
|
|
|
int is_ref = 0;
|
|
|
|
|
enum type_code dest_code, arg_code;
|
|
|
|
|
|
|
|
|
|
/* Do reference, function, and array conversion. */
|
|
|
|
|
arg = coerce_array (arg);
|
|
|
|
|
|
|
|
|
|
/* Attempt to preserve the type the user asked for. */
|
|
|
|
|
dest_type = type;
|
|
|
|
|
|
|
|
|
|
/* If we are casting to a reference type, transform
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
reinterpret_cast<T&[&]>(V) to *reinterpret_cast<T*>(&V). */
|
|
|
|
|
if (TYPE_IS_REFERENCE (real_type))
|
2010-01-18 21:54:35 +01:00
|
|
|
|
{
|
|
|
|
|
is_ref = 1;
|
|
|
|
|
arg = value_addr (arg);
|
|
|
|
|
dest_type = lookup_pointer_type (TYPE_TARGET_TYPE (dest_type));
|
|
|
|
|
real_type = lookup_pointer_type (real_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
arg_type = value_type (arg);
|
|
|
|
|
|
|
|
|
|
dest_code = TYPE_CODE (real_type);
|
|
|
|
|
arg_code = TYPE_CODE (arg_type);
|
|
|
|
|
|
|
|
|
|
/* We can convert pointer types, or any pointer type to int, or int
|
|
|
|
|
type to pointer. */
|
|
|
|
|
if ((dest_code == TYPE_CODE_PTR && arg_code == TYPE_CODE_INT)
|
|
|
|
|
|| (dest_code == TYPE_CODE_INT && arg_code == TYPE_CODE_PTR)
|
|
|
|
|
|| (dest_code == TYPE_CODE_METHODPTR && arg_code == TYPE_CODE_INT)
|
|
|
|
|
|| (dest_code == TYPE_CODE_INT && arg_code == TYPE_CODE_METHODPTR)
|
|
|
|
|
|| (dest_code == TYPE_CODE_MEMBERPTR && arg_code == TYPE_CODE_INT)
|
|
|
|
|
|| (dest_code == TYPE_CODE_INT && arg_code == TYPE_CODE_MEMBERPTR)
|
|
|
|
|
|| (dest_code == arg_code
|
|
|
|
|
&& (dest_code == TYPE_CODE_PTR
|
|
|
|
|
|| dest_code == TYPE_CODE_METHODPTR
|
|
|
|
|
|| dest_code == TYPE_CODE_MEMBERPTR)))
|
|
|
|
|
result = value_cast (dest_type, arg);
|
|
|
|
|
else
|
|
|
|
|
error (_("Invalid reinterpret_cast"));
|
|
|
|
|
|
|
|
|
|
if (is_ref)
|
2017-03-20 21:47:41 +01:00
|
|
|
|
result = value_cast (type, value_ref (value_ind (result),
|
|
|
|
|
TYPE_CODE (type)));
|
2010-01-18 21:54:35 +01:00
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper for value_dynamic_cast. This implements the first of two
|
|
|
|
|
runtime checks: we iterate over all the base classes of the value's
|
|
|
|
|
class which are equal to the desired class; if only one of these
|
|
|
|
|
holds the value, then it is the answer. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
dynamic_cast_check_1 (struct type *desired_type,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
const gdb_byte *valaddr,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST embedded_offset,
|
2010-01-18 21:54:35 +01:00
|
|
|
|
CORE_ADDR address,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
struct value *val,
|
2010-01-18 21:54:35 +01:00
|
|
|
|
struct type *search_type,
|
|
|
|
|
CORE_ADDR arg_addr,
|
|
|
|
|
struct type *arg_type,
|
|
|
|
|
struct value **result)
|
|
|
|
|
{
|
|
|
|
|
int i, result_count = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < TYPE_N_BASECLASSES (search_type) && result_count < 2; ++i)
|
|
|
|
|
{
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST offset = baseclass_offset (search_type, i, valaddr,
|
|
|
|
|
embedded_offset,
|
|
|
|
|
address, val);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2010-01-18 21:54:35 +01:00
|
|
|
|
if (class_types_same_p (desired_type, TYPE_BASECLASS (search_type, i)))
|
|
|
|
|
{
|
2011-02-14 12:35:45 +01:00
|
|
|
|
if (address + embedded_offset + offset >= arg_addr
|
|
|
|
|
&& address + embedded_offset + offset < arg_addr + TYPE_LENGTH (arg_type))
|
2010-01-18 21:54:35 +01:00
|
|
|
|
{
|
|
|
|
|
++result_count;
|
|
|
|
|
if (!*result)
|
|
|
|
|
*result = value_at_lazy (TYPE_BASECLASS (search_type, i),
|
2011-02-14 12:35:45 +01:00
|
|
|
|
address + embedded_offset + offset);
|
2010-01-18 21:54:35 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
result_count += dynamic_cast_check_1 (desired_type,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
valaddr,
|
|
|
|
|
embedded_offset + offset,
|
|
|
|
|
address, val,
|
2010-01-18 21:54:35 +01:00
|
|
|
|
TYPE_BASECLASS (search_type, i),
|
|
|
|
|
arg_addr,
|
|
|
|
|
arg_type,
|
|
|
|
|
result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper for value_dynamic_cast. This implements the second of two
|
|
|
|
|
runtime checks: we look for a unique public sibling class of the
|
|
|
|
|
argument's declared class. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
dynamic_cast_check_2 (struct type *desired_type,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
const gdb_byte *valaddr,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST embedded_offset,
|
2010-01-18 21:54:35 +01:00
|
|
|
|
CORE_ADDR address,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
struct value *val,
|
2010-01-18 21:54:35 +01:00
|
|
|
|
struct type *search_type,
|
|
|
|
|
struct value **result)
|
|
|
|
|
{
|
|
|
|
|
int i, result_count = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < TYPE_N_BASECLASSES (search_type) && result_count < 2; ++i)
|
|
|
|
|
{
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST offset;
|
2010-01-18 21:54:35 +01:00
|
|
|
|
|
|
|
|
|
if (! BASETYPE_VIA_PUBLIC (search_type, i))
|
|
|
|
|
continue;
|
|
|
|
|
|
2011-02-14 12:35:45 +01:00
|
|
|
|
offset = baseclass_offset (search_type, i, valaddr, embedded_offset,
|
|
|
|
|
address, val);
|
2010-01-18 21:54:35 +01:00
|
|
|
|
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),
|
2011-02-14 12:35:45 +01:00
|
|
|
|
address + embedded_offset + offset);
|
2010-01-18 21:54:35 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
result_count += dynamic_cast_check_2 (desired_type,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
valaddr,
|
|
|
|
|
embedded_offset + offset,
|
|
|
|
|
address, val,
|
2010-01-18 21:54:35 +01:00
|
|
|
|
TYPE_BASECLASS (search_type, i),
|
|
|
|
|
result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The C++ dynamic_cast operator. */
|
|
|
|
|
|
|
|
|
|
struct value *
|
|
|
|
|
value_dynamic_cast (struct type *type, struct value *arg)
|
|
|
|
|
{
|
2016-04-12 21:02:57 +02:00
|
|
|
|
int full, using_enc;
|
|
|
|
|
LONGEST top;
|
2010-01-18 21:54:35 +01:00
|
|
|
|
struct type *resolved_type = check_typedef (type);
|
|
|
|
|
struct type *arg_type = check_typedef (value_type (arg));
|
|
|
|
|
struct type *class_type, *rtti_type;
|
|
|
|
|
struct value *result, *tem, *original_arg = arg;
|
|
|
|
|
CORE_ADDR addr;
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
int is_ref = TYPE_IS_REFERENCE (resolved_type);
|
2010-01-18 21:54:35 +01:00
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (resolved_type) != TYPE_CODE_PTR
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
&& !TYPE_IS_REFERENCE (resolved_type))
|
2010-01-18 21:54:35 +01:00
|
|
|
|
error (_("Argument to dynamic_cast must be a pointer or reference type"));
|
|
|
|
|
if (TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_VOID
|
2014-11-07 02:19:06 +01:00
|
|
|
|
&& TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) != TYPE_CODE_STRUCT)
|
2010-01-18 21:54:35 +01:00
|
|
|
|
error (_("Argument to dynamic_cast must be pointer to class or `void *'"));
|
|
|
|
|
|
|
|
|
|
class_type = check_typedef (TYPE_TARGET_TYPE (resolved_type));
|
|
|
|
|
if (TYPE_CODE (resolved_type) == TYPE_CODE_PTR)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_CODE (arg_type) != TYPE_CODE_PTR
|
|
|
|
|
&& ! (TYPE_CODE (arg_type) == TYPE_CODE_INT
|
|
|
|
|
&& value_as_long (arg) == 0))
|
|
|
|
|
error (_("Argument to dynamic_cast does not have pointer type"));
|
|
|
|
|
if (TYPE_CODE (arg_type) == TYPE_CODE_PTR)
|
|
|
|
|
{
|
|
|
|
|
arg_type = check_typedef (TYPE_TARGET_TYPE (arg_type));
|
2014-11-07 02:19:06 +01:00
|
|
|
|
if (TYPE_CODE (arg_type) != TYPE_CODE_STRUCT)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("Argument to dynamic_cast does "
|
|
|
|
|
"not have pointer to class type"));
|
2010-01-18 21:54:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle NULL pointers. */
|
|
|
|
|
if (value_as_long (arg) == 0)
|
|
|
|
|
return value_zero (type, not_lval);
|
|
|
|
|
|
|
|
|
|
arg = value_ind (arg);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-11-07 02:19:06 +01:00
|
|
|
|
if (TYPE_CODE (arg_type) != TYPE_CODE_STRUCT)
|
2010-01-18 21:54:35 +01:00
|
|
|
|
error (_("Argument to dynamic_cast does not have class type"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the classes are the same, just return the argument. */
|
|
|
|
|
if (class_types_same_p (class_type, arg_type))
|
|
|
|
|
return value_cast (type, arg);
|
|
|
|
|
|
|
|
|
|
/* If the target type is a unique base class of the argument's
|
|
|
|
|
declared type, just cast it. */
|
|
|
|
|
if (is_ancestor (class_type, arg_type))
|
|
|
|
|
{
|
|
|
|
|
if (is_unique_ancestor (class_type, arg))
|
|
|
|
|
return value_cast (type, original_arg);
|
|
|
|
|
error (_("Ambiguous dynamic_cast"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rtti_type = value_rtti_type (arg, &full, &top, &using_enc);
|
|
|
|
|
if (! rtti_type)
|
|
|
|
|
error (_("Couldn't determine value's most derived type for dynamic_cast"));
|
|
|
|
|
|
|
|
|
|
/* Compute the most derived object's address. */
|
|
|
|
|
addr = value_address (arg);
|
|
|
|
|
if (full)
|
|
|
|
|
{
|
|
|
|
|
/* Done. */
|
|
|
|
|
}
|
|
|
|
|
else if (using_enc)
|
|
|
|
|
addr += top;
|
|
|
|
|
else
|
|
|
|
|
addr += top + value_embedded_offset (arg);
|
|
|
|
|
|
|
|
|
|
/* dynamic_cast<void *> means to return a pointer to the
|
|
|
|
|
most-derived object. */
|
|
|
|
|
if (TYPE_CODE (resolved_type) == TYPE_CODE_PTR
|
|
|
|
|
&& TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) == TYPE_CODE_VOID)
|
|
|
|
|
return value_at_lazy (type, addr);
|
|
|
|
|
|
|
|
|
|
tem = value_at (type, addr);
|
2013-10-14 09:36:13 +02:00
|
|
|
|
type = value_type (tem);
|
2010-01-18 21:54:35 +01:00
|
|
|
|
|
|
|
|
|
/* The first dynamic check specified in 5.2.7. */
|
|
|
|
|
if (is_public_ancestor (arg_type, TYPE_TARGET_TYPE (resolved_type)))
|
|
|
|
|
{
|
|
|
|
|
if (class_types_same_p (rtti_type, TYPE_TARGET_TYPE (resolved_type)))
|
|
|
|
|
return tem;
|
|
|
|
|
result = NULL;
|
|
|
|
|
if (dynamic_cast_check_1 (TYPE_TARGET_TYPE (resolved_type),
|
2011-02-14 12:35:45 +01:00
|
|
|
|
value_contents_for_printing (tem),
|
|
|
|
|
value_embedded_offset (tem),
|
|
|
|
|
value_address (tem), tem,
|
2010-01-18 21:54:35 +01:00
|
|
|
|
rtti_type, addr,
|
|
|
|
|
arg_type,
|
|
|
|
|
&result) == 1)
|
|
|
|
|
return value_cast (type,
|
2017-03-20 21:47:41 +01:00
|
|
|
|
is_ref
|
|
|
|
|
? value_ref (result, TYPE_CODE (resolved_type))
|
|
|
|
|
: value_addr (result));
|
2010-01-18 21:54:35 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The second dynamic check specified in 5.2.7. */
|
|
|
|
|
result = NULL;
|
|
|
|
|
if (is_public_ancestor (arg_type, rtti_type)
|
|
|
|
|
&& dynamic_cast_check_2 (TYPE_TARGET_TYPE (resolved_type),
|
2011-02-14 12:35:45 +01:00
|
|
|
|
value_contents_for_printing (tem),
|
|
|
|
|
value_embedded_offset (tem),
|
|
|
|
|
value_address (tem), tem,
|
2010-01-18 21:54:35 +01:00
|
|
|
|
rtti_type, &result) == 1)
|
|
|
|
|
return value_cast (type,
|
2017-03-20 21:47:41 +01:00
|
|
|
|
is_ref
|
|
|
|
|
? value_ref (result, TYPE_CODE (resolved_type))
|
|
|
|
|
: value_addr (result));
|
2010-01-18 21:54:35 +01:00
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (resolved_type) == TYPE_CODE_PTR)
|
|
|
|
|
return value_zero (type, not_lval);
|
|
|
|
|
|
|
|
|
|
error (_("dynamic_cast failed"));
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* Create a value of type TYPE that is zero, and return it. */
|
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
value_zero (struct type *type, enum lval_type lv)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *val = allocate_value (type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2011-07-27 21:25:56 +02:00
|
|
|
|
VALUE_LVAL (val) = (lv == lval_computed ? not_lval : lv);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-27 21:31:30 +02:00
|
|
|
|
/* Create a not_lval value of numeric type TYPE that is one, and return it. */
|
2008-02-04 01:23:05 +01:00
|
|
|
|
|
|
|
|
|
struct value *
|
2011-07-27 21:31:30 +02:00
|
|
|
|
value_one (struct type *type)
|
2008-02-04 01:23:05 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type1 = check_typedef (type);
|
2009-06-24 18:51:57 +02:00
|
|
|
|
struct value *val;
|
2008-02-04 01:23:05 +01:00
|
|
|
|
|
Target FP: Add conversion routines to target-float.{c,h}
This patch adds the following conversion routines:
- target_float_to_longest
- target_float_from_longest
- target_float_from_ulongest
- target_float_convert
which call the equivalent decimal_ routines to handle decimal FP,
and call helper routines that currently still go via DOUBLEST to
handle binary FP.
The target_float_convert routine not only handles BFP<->BFP and
DFP<->DFP conversions, but also BFP<->DFP, which are implemented
by converting to a string and back.
These helpers are used in particular to implement conversion
from and to FP in value_cast, without going through DOUBLEST there.
In order to implement this for the FP<-integer case, the
pack_long / pack_unsigned_long routines are extended to support
floating-point values as output (thereby allowing use of
value_from_[u]longest with a floating-point target type).
This latter change also allows simplification of value_one.
gdb/ChangeLog:
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* target-float.c (floatformat_to_longest): New function.
(floatformat_from_longest, floatformat_from_ulongest): Likewise.
(floatformat_convert): Likewise.
(target_float_to_longest): Likewise.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* target-float.h (target_float_to_longest): Add prototype.
(target_float_from_longest, target_float_from_ulongest): Likewise.
(target_float_convert): Likewise.
* value.c (unpack_long): Use target_float_to_longest.
(pack_long): Allow FP types. Use target_float_from_longest.
(pack_unsigned_long): Likewise using target_float_from_ulongest.
* valops.c: Include "target-float.h". Do not include "dfp.h".
(value_cast): Handle conversions to FP using target_float_convert,
value_from_ulongest, and value_from_longest.
(value_one): Use value_from_longest for FP types as well.
2017-11-06 15:57:31 +01:00
|
|
|
|
if (is_integral_type (type1) || is_floating_type (type1))
|
2008-02-04 01:23:05 +01:00
|
|
|
|
{
|
|
|
|
|
val = value_from_longest (type, (LONGEST) 1);
|
|
|
|
|
}
|
2010-11-03 15:06:27 +01:00
|
|
|
|
else if (TYPE_CODE (type1) == TYPE_CODE_ARRAY && TYPE_VECTOR (type1))
|
|
|
|
|
{
|
|
|
|
|
struct type *eltype = check_typedef (TYPE_TARGET_TYPE (type1));
|
2010-12-14 11:23:41 +01:00
|
|
|
|
int i;
|
|
|
|
|
LONGEST low_bound, high_bound;
|
2010-11-03 15:06:27 +01:00
|
|
|
|
struct value *tmp;
|
|
|
|
|
|
2010-12-14 11:23:41 +01:00
|
|
|
|
if (!get_array_bounds (type1, &low_bound, &high_bound))
|
|
|
|
|
error (_("Could not determine the vector bounds"));
|
|
|
|
|
|
2010-11-03 15:06:27 +01:00
|
|
|
|
val = allocate_value (type);
|
2010-12-14 11:23:41 +01:00
|
|
|
|
for (i = 0; i < high_bound - low_bound + 1; i++)
|
2010-11-03 15:06:27 +01:00
|
|
|
|
{
|
2011-07-27 21:31:30 +02:00
|
|
|
|
tmp = value_one (eltype);
|
2010-11-03 15:06:27 +01:00
|
|
|
|
memcpy (value_contents_writeable (val) + i * TYPE_LENGTH (eltype),
|
|
|
|
|
value_contents_all (tmp), TYPE_LENGTH (eltype));
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-02-04 01:23:05 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
error (_("Not a numeric type."));
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-27 21:31:30 +02:00
|
|
|
|
/* value_one result is never used for assignments to. */
|
|
|
|
|
gdb_assert (VALUE_LVAL (val) == not_lval);
|
|
|
|
|
|
2008-02-04 01:23:05 +01:00
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-09 16:28:22 +02:00
|
|
|
|
/* Helper function for value_at, value_at_lazy, and value_at_lazy_stack.
|
|
|
|
|
The type of the created value may differ from the passed type TYPE.
|
|
|
|
|
Make sure to retrieve the returned values's new type after this call
|
|
|
|
|
e.g. in case the type is a variable length array. */
|
2009-08-31 22:18:46 +02:00
|
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
|
get_value_at (struct type *type, CORE_ADDR addr, int lazy)
|
|
|
|
|
{
|
|
|
|
|
struct value *val;
|
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID)
|
|
|
|
|
error (_("Attempt to dereference a generic pointer."));
|
|
|
|
|
|
2011-02-14 12:27:36 +01:00
|
|
|
|
val = value_from_contents_and_address (type, NULL, addr);
|
2009-08-31 22:18:46 +02:00
|
|
|
|
|
2011-02-14 12:27:36 +01:00
|
|
|
|
if (!lazy)
|
|
|
|
|
value_fetch_lazy (val);
|
2009-08-31 22:18:46 +02:00
|
|
|
|
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-04 06:53:50 +02:00
|
|
|
|
/* Return a value with type TYPE located at ADDR.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
Call value_at only if the data needs to be fetched immediately;
|
|
|
|
|
if we can be 'lazy' and defer the fetch, perhaps indefinately, call
|
|
|
|
|
value_at_lazy instead. value_at_lazy simply records the address of
|
2000-04-04 06:53:50 +02:00
|
|
|
|
the data and sets the lazy-evaluation-required flag. The lazy flag
|
2005-02-06 Andrew Cagney <cagney@gnu.org>
* value.c (value_contents, value_contents_writeable): New
functions.
* value.h (VALUE_CONTENTS): Delete macro.
(value_contents, value_contents_writeable): Declare.
* xstormy16-tdep.c, value.c, valops.c, valarith.c: Update.
* stack.c, sparc-tdep.c, sparc64-tdep.c, sh-tdep.c: Update.
* sh64-tdep.c, scm-valprint.c, scm-exp.c, s390-tdep.c: Update.
* rs6000-tdep.c, p-valprint.c, printcmd.c: Update.
* ppc-sysv-tdep.c, mips-tdep.c, mi/mi-main.c: Update.
* m88k-tdep.c, m68hc11-tdep.c, m32r-tdep.c: Update.
* jv-valprint.c, ia64-tdep.c, hppa-tdep.c: Update.
* hpacc-abi.c, f-valprint.c, frv-tdep.c, eval.c: Update.
* c-valprint.c, cris-tdep.c, cp-valprint.c: Update.
* cli/cli-dump.c, breakpoint.c, avr-tdep.c, arm-tdep.c: Update.
* arm-linux-tdep.c, amd64-tdep.c, alpha-tdep.c: Update.
* ada-valprint.c, ada-lang.c: Update.
2005-02-07 01:09:56 +01:00
|
|
|
|
is tested in the value_contents macro, which is used if and when
|
2013-10-09 16:28:22 +02:00
|
|
|
|
the contents are actually required. The type of the created value
|
|
|
|
|
may differ from the passed type TYPE. Make sure to retrieve the
|
|
|
|
|
returned values's new type after this call e.g. in case the type
|
|
|
|
|
is a variable length array.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
Note: value_at does *NOT* handle embedded offsets; perform such
|
2007-08-14 02:31:40 +02:00
|
|
|
|
adjustments before or after calling it. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2004-11-09 Andrew Cagney <cagney@gnu.org>
* value.h (struct value): Delete field bfd_section.
(VALUE_BFD_SECTION): Delete macro.
(COERCE_REF): Update.
(value_at, value_at_lazy): Delete asection parameter.
* printcmd.c (print_formatted, x_command): Update.
(do_examine): Delete asection parameter.
(next_section): Delete variable.
* valops.c (value_cast, value_at, value_at_lazy)
(value_coerce_function, value_addr, value_ind, value_string)
(find_rt_vbase_offset, value_full_object): Update.
* hpacc-abi.c (hpacc_virtual_fn_field)
(hpacc_value_rtti_type): Update.
* gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_virtual_fn_field)
(gnuv3_baseclass_offset): Update.
* f-valprint.c (f_val_print): Update.
* c-valprint.c (c_val_print): Update.
* p-valprint.c (pascal_val_print): Update.
* jv-valprint.c (java_value_print): Update.
* jv-lang.c (java_class_from_object, evaluate_subexp_java): Update.
* ada-lang.c (ada_value_primitive_packed_val)
(ada_evaluate_subexp): Update.
* dwarf2loc.c (dwarf2_evaluate_loc_desc): Update.
* expprint.c (print_subexp_standard): Update.
* infcall.c (call_function_by_hand): Update.
* valarith.c (value_add): Update.
* eval.c (evaluate_subexp_standard): Update.
* values.c (allocate_value, value_copy, value_static_field): Update.
* findvar.c (read_var_value, locate_var_value): Update.
2004-11-09 15:43:27 +01:00
|
|
|
|
value_at (struct type *type, CORE_ADDR addr)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2009-08-31 22:18:46 +02:00
|
|
|
|
return get_value_at (type, addr, 0);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-09 16:28:22 +02:00
|
|
|
|
/* Return a lazy value with type TYPE located at ADDR (cf. value_at).
|
|
|
|
|
The type of the created value may differ from the passed type TYPE.
|
|
|
|
|
Make sure to retrieve the returned values's new type after this call
|
|
|
|
|
e.g. in case the type is a variable length array. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2004-11-09 Andrew Cagney <cagney@gnu.org>
* value.h (struct value): Delete field bfd_section.
(VALUE_BFD_SECTION): Delete macro.
(COERCE_REF): Update.
(value_at, value_at_lazy): Delete asection parameter.
* printcmd.c (print_formatted, x_command): Update.
(do_examine): Delete asection parameter.
(next_section): Delete variable.
* valops.c (value_cast, value_at, value_at_lazy)
(value_coerce_function, value_addr, value_ind, value_string)
(find_rt_vbase_offset, value_full_object): Update.
* hpacc-abi.c (hpacc_virtual_fn_field)
(hpacc_value_rtti_type): Update.
* gnu-v3-abi.c (gnuv3_rtti_type, gnuv3_virtual_fn_field)
(gnuv3_baseclass_offset): Update.
* f-valprint.c (f_val_print): Update.
* c-valprint.c (c_val_print): Update.
* p-valprint.c (pascal_val_print): Update.
* jv-valprint.c (java_value_print): Update.
* jv-lang.c (java_class_from_object, evaluate_subexp_java): Update.
* ada-lang.c (ada_value_primitive_packed_val)
(ada_evaluate_subexp): Update.
* dwarf2loc.c (dwarf2_evaluate_loc_desc): Update.
* expprint.c (print_subexp_standard): Update.
* infcall.c (call_function_by_hand): Update.
* valarith.c (value_add): Update.
* eval.c (evaluate_subexp_standard): Update.
* values.c (allocate_value, value_copy, value_static_field): Update.
* findvar.c (read_var_value, locate_var_value): Update.
2004-11-09 15:43:27 +01:00
|
|
|
|
value_at_lazy (struct type *type, CORE_ADDR addr)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2009-08-31 22:18:46 +02:00
|
|
|
|
return get_value_at (type, addr, 1);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 12:21:25 +01:00
|
|
|
|
void
|
2017-06-13 15:20:31 +02:00
|
|
|
|
read_value_memory (struct value *val, LONGEST bit_offset,
|
2011-02-14 12:21:25 +01:00
|
|
|
|
int stack, CORE_ADDR memaddr,
|
|
|
|
|
gdb_byte *buffer, size_t length)
|
|
|
|
|
{
|
2015-07-28 17:01:50 +02:00
|
|
|
|
ULONGEST xfered_total = 0;
|
|
|
|
|
struct gdbarch *arch = get_value_arch (val);
|
|
|
|
|
int unit_size = gdbarch_addressable_memory_unit_size (arch);
|
2016-04-22 18:18:31 +02:00
|
|
|
|
enum target_object object;
|
|
|
|
|
|
|
|
|
|
object = stack ? TARGET_OBJECT_STACK_MEMORY : TARGET_OBJECT_MEMORY;
|
2013-11-05 02:50:21 +01:00
|
|
|
|
|
2015-07-28 17:01:50 +02:00
|
|
|
|
while (xfered_total < length)
|
2013-11-05 02:50:21 +01:00
|
|
|
|
{
|
|
|
|
|
enum target_xfer_status status;
|
2015-07-28 17:01:50 +02:00
|
|
|
|
ULONGEST xfered_partial;
|
2013-11-05 02:50:21 +01:00
|
|
|
|
|
|
|
|
|
status = target_xfer_partial (current_target.beneath,
|
2016-04-22 18:18:31 +02:00
|
|
|
|
object, NULL,
|
2015-07-28 17:01:50 +02:00
|
|
|
|
buffer + xfered_total * unit_size, NULL,
|
|
|
|
|
memaddr + xfered_total,
|
|
|
|
|
length - xfered_total,
|
|
|
|
|
&xfered_partial);
|
2013-11-05 02:50:21 +01:00
|
|
|
|
|
|
|
|
|
if (status == TARGET_XFER_OK)
|
|
|
|
|
/* nothing */;
|
2014-02-23 07:34:29 +01:00
|
|
|
|
else if (status == TARGET_XFER_UNAVAILABLE)
|
2017-06-13 15:20:31 +02:00
|
|
|
|
mark_value_bits_unavailable (val, (xfered_total * HOST_CHAR_BIT
|
|
|
|
|
+ bit_offset),
|
|
|
|
|
xfered_partial * HOST_CHAR_BIT);
|
2013-11-05 02:50:21 +01:00
|
|
|
|
else if (status == TARGET_XFER_EOF)
|
2015-07-28 17:01:50 +02:00
|
|
|
|
memory_error (TARGET_XFER_E_IO, memaddr + xfered_total);
|
2011-02-14 12:21:25 +01:00
|
|
|
|
else
|
2015-07-28 17:01:50 +02:00
|
|
|
|
memory_error (status, memaddr + xfered_total);
|
2011-02-14 12:21:25 +01:00
|
|
|
|
|
2015-07-28 17:01:50 +02:00
|
|
|
|
xfered_total += xfered_partial;
|
2013-11-05 02:50:21 +01:00
|
|
|
|
QUIT;
|
2011-02-14 12:21:25 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
/* Store the contents of FROMVAL into the location of TOVAL.
|
|
|
|
|
Return a new value with the location of TOVAL and contents of FROMVAL. */
|
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_assign (struct value *toval, struct value *fromval)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
struct type *type;
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *val;
|
2003-01-30 17:44:20 +01:00
|
|
|
|
struct frame_id old_frame;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2005-02-08 01:25:31 +01:00
|
|
|
|
if (!deprecated_value_modifiable (toval))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Left operand of assignment is not a modifiable lvalue."));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
2004-11-10 19:52:25 +01:00
|
|
|
|
toval = coerce_ref (toval);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
type = value_type (toval);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (VALUE_LVAL (toval) != lval_internalvar)
|
2010-07-14 16:54:58 +02:00
|
|
|
|
fromval = value_cast (type, fromval);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
2008-03-21 16:02:38 +01:00
|
|
|
|
{
|
|
|
|
|
/* Coerce arrays and functions to pointers, except for arrays
|
|
|
|
|
which only live in GDB's storage. */
|
|
|
|
|
if (!value_must_coerce_to_target (fromval))
|
|
|
|
|
fromval = coerce_array (fromval);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-06 22:05:06 +02:00
|
|
|
|
type = check_typedef (type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Since modifying a register can trash the frame chain, and
|
|
|
|
|
modifying memory can trash the frame cache, we save the old frame
|
|
|
|
|
and then restore the new frame afterwards. */
|
* frame.c (deprecated_selected_frame): Rename to...
(selected_frame): ...this. Make static.
(get_selected_frame, select_frame): Update.
* frame.h (deprected_select_frame): Delete.
(deprecated_safe_get_selected_frame): Update comments.
* breakpoint.c, cli/cli-cmds.c, f-valprint.c, infcmd.c, inflow.c,
infrun.c, stack.c, tui/tui-disasm.c, tui/tui-source.c,
tui/tui-winsource.c, valops.c, varobj.c, findvar.c, macroscope.c,
parse.c, regcache.h, sh64-tdep.c, tui/tui-hooks.c, tui/tui-win.c,
tui/tui.c: Replace references to deprecated_selected_frame.
2007-02-27 20:46:04 +01:00
|
|
|
|
old_frame = get_frame_id (deprecated_safe_get_selected_frame ());
|
2003-01-30 17:44:20 +01:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
switch (VALUE_LVAL (toval))
|
|
|
|
|
{
|
|
|
|
|
case lval_internalvar:
|
|
|
|
|
set_internalvar (VALUE_INTERNALVAR (toval), fromval);
|
2010-12-01 17:49:41 +01:00
|
|
|
|
return value_of_internalvar (get_type_arch (type),
|
|
|
|
|
VALUE_INTERNALVAR (toval));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
case lval_internalvar_component:
|
2013-02-11 19:05:35 +01:00
|
|
|
|
{
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST offset = value_offset (toval);
|
2013-02-11 19:05:35 +01:00
|
|
|
|
|
|
|
|
|
/* Are we dealing with a bitfield?
|
|
|
|
|
|
|
|
|
|
It is important to mention that `value_parent (toval)' is
|
|
|
|
|
non-NULL iff `value_bitsize (toval)' is non-zero. */
|
|
|
|
|
if (value_bitsize (toval))
|
|
|
|
|
{
|
|
|
|
|
/* VALUE_INTERNALVAR below refers to the parent value, while
|
|
|
|
|
the offset is relative to this parent value. */
|
|
|
|
|
gdb_assert (value_parent (value_parent (toval)) == NULL);
|
|
|
|
|
offset += value_offset (value_parent (toval));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_internalvar_component (VALUE_INTERNALVAR (toval),
|
|
|
|
|
offset,
|
|
|
|
|
value_bitpos (toval),
|
|
|
|
|
value_bitsize (toval),
|
|
|
|
|
fromval);
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case lval_memory:
|
|
|
|
|
{
|
2005-05-09 Andrew Cagney <cagney@gnu.org>
Use gdb_byte in preference to bfd_byte.
* gdbarch.sh: Update.
* gdbarch.h, gdbarch.c: Re-generate.
* ada-lang.c, ada-lang.h, ada-valprint.c, arch-utils.c: Update.
* c-lang.c, c-lang.h, c-valprint.c, cp-valprint.c: Update.
* f-lang.c, f-lang.h, f-valprint.c, gdbcore.h, jv-lang.h: Update.
* jv-valprint.c, language.c, language.h, m2-lang.c: Update.
* m2-lang.h, m2-valprint.c, objc-lang.c, p-lang.c: Update.
* p-lang.h, p-valprint.c, regcache.c, scm-lang.c: Update.
* scm-lang.h, scm-valprint.c, target.c, target.h: Update.
* tramp-frame.c, valarith.c, valops.c, valprint.c: Update.
* valprint.h, value.c, value.h: Update.
2005-05-09 23:20:35 +02:00
|
|
|
|
const gdb_byte *dest_buffer;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
CORE_ADDR changed_addr;
|
|
|
|
|
int changed_len;
|
2005-05-22 Andrew Cagney <cagney@gnu.org>
* frame.h (frame_register_unwind, frame_unwind_register)
(get_frame_register, frame_register, put_frame_register)
(get_frame_memory, safe_frame_unwind_memory)
(frame_register_read): Use gdb_byte for byte buffer parameters.
* trad-frame.h (trad_frame_get_register)
(frame_get_prev_register): Ditto.
* frame-unwind.h (frame_prev_register_ftype): Ditto.
* frame.c (frame_pop, frame_register, frame_unwind_register)
(get_frame_register, frame_unwind_register_signed)
(frame_unwind_register_unsigned, frame_unwind_unsigned_register)
(frame_register_read, get_frame_memory): Update.
* trad-frame.c (trad_frame_get_prev_register): Update.
(trad_frame_get_register): Update.
* gdbcore.h (deprecated_read_memory_nobpt, read_memory): Ditto.
* breakpoint.c (deprecated_read_memory_nobpt): Update.
* corefile.c (read_memory): Update.
* tramp-frame.c (tramp_frame_prev_register): Update.
* valops.c (value_assign): Update.
* sentinel-frame.c (sentinel_frame_prev_register): Update.
* std-regs.c (value_of_builtin_frame_fp_reg)
(value_of_builtin_frame_pc_reg): Update.
* infcmd.c (default_print_registers_info): Update
* dummy-frame.c (dummy_frame_prev_register): Update.
* findvar.c (value_of_register, value_from_register): Update.
* tui/tui-regs.c (tui_register_format, tui_get_register): Update.
* mi/mi-main.c (register_changed_p, get_register): Update.
2005-05-22 16:53:35 +02:00
|
|
|
|
gdb_byte buffer[sizeof (LONGEST)];
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
if (value_bitsize (toval))
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
2009-09-28 11:16:15 +02:00
|
|
|
|
struct value *parent = value_parent (toval);
|
|
|
|
|
|
2010-05-17 20:48:52 +02:00
|
|
|
|
changed_addr = value_address (parent) + value_offset (toval);
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
changed_len = (value_bitpos (toval)
|
|
|
|
|
+ value_bitsize (toval)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
+ HOST_CHAR_BIT - 1)
|
|
|
|
|
/ HOST_CHAR_BIT;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2009-07-21 20:15:32 +02:00
|
|
|
|
/* If we can read-modify-write exactly the size of the
|
|
|
|
|
containing type (e.g. short or int) then do so. This
|
|
|
|
|
is safer for volatile bitfields mapped to hardware
|
|
|
|
|
registers. */
|
|
|
|
|
if (changed_len < TYPE_LENGTH (type)
|
|
|
|
|
&& TYPE_LENGTH (type) <= (int) sizeof (LONGEST)
|
2009-09-28 11:16:15 +02:00
|
|
|
|
&& ((LONGEST) changed_addr % TYPE_LENGTH (type)) == 0)
|
2009-07-21 20:15:32 +02:00
|
|
|
|
changed_len = TYPE_LENGTH (type);
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (changed_len > (int) sizeof (LONGEST))
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("Can't handle bitfields which "
|
|
|
|
|
"don't fit in a %d bit word."),
|
2002-04-23 05:00:57 +02:00
|
|
|
|
(int) sizeof (LONGEST) * HOST_CHAR_BIT);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2009-09-28 11:16:15 +02:00
|
|
|
|
read_memory (changed_addr, buffer, changed_len);
|
* gdbtypes.c (make_pointer_type, make_reference_type,
smash_to_memberptr_type, lookup_array_range_type, check_stub_method):
Use type architecture instead of current_gdbarch.
* gdbtypes.h (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH paramter.
* gdbtypes.c (address_space_name_to_int, address_space_int_to_name):
Add GDBARCH parameter. Use it instead of current_gdbarch.
* c-typeprint.c (c_type_print_modifier): Update call.
* parse.c (push_type_address_space): Likewise.
* findvar.c (extract_typed_address, store_typed_address): Use type
architecture instead of current_gdbarch.
* value.c (value_as_address, unpack_field_as_long): Use type architecture
instead of current_gdbarch.
* doublest.c (floatformat_from_length): Add GDBARCH argument. Use it
instead of current_gdbarch.
(floatformat_from_type): Pass type architecture.
* infcall.c (find_function_addr): Use type architecture instead
of current_gdbarch.
* valarith.c (value_bitstring_subscript, value_x_binop, value_neg,
value_bit_index): Use type architecture instead of current_gdbarch.
* valops.c (value_cast, value_slice): Likewise.
* value.h (modify_field): Add TYPE argument.
* value.c (modify_field): Add TYPE argument. Use type architecture
instead of current_gdbarch.
(set_internalvar_component): Likewise.
* eval.c (evaluate_struct_tuple): Update call.
* valops.c (value_assign): Likewise.
* ada-lang.c (modify_general_field): Likewise. Add TYPE argument.
(make_array_descriptor): Update calls.
(move_bits): Add BITS_BIG_ENDIAN_P argument. Use it instead of
current_gdbarch.
(ada_value_assign, value_assign_to_component): Update calls.
(decode_packed_array, ada_value_primitive_packed_val, ada_value_assign,
value_assign_to_component): Use type arch instead of current_gdbarch.
* printcmd.c (float_type_from_length): Remove GDBARCH argument,
use type architecture instead.
(print_scalar_formatted, printf_command): Update calls. Use type
architecture instead of current_gdbarch.
* valprint.c (val_print_type_code_int): Use type architecture
instead of current_gdbarch.
* varobj.c (value_get_print_value): Likewise.
* python/python-prettyprint.c (print_string_repr): Add GDBARCH
argument. Use it instead of current_gdbarch.
(apply_val_pretty_printer): Update call.
* ada-valprint.c (ada_val_print_1): Use type architecture instead
of current_gdbarch.
* c-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(c_val_print): Update calls passing type architecture.
* f-valprint.c (f_val_print): Use type architecture instead of
current_gdbarch.
* jv-valprint (java_value_print): Likewise.
* m2-valprint.c (print_function_pointer_address): Add GDBARCH argument.
Use it instead of current_gdbarch.
(print_unpacked_pointer): Update calls passing type architecture.
* scm-valprint.c (scm_scmval_print): Use type architecture instead of
current_gdbarch.
* gnu-v3-abi.c (get_class_arch): Remove.
(gnuv3_rtti_type): Use get_type_arch instead of get_class_arch. Remove
special-case check for Java classes.
(gnuv3_virtual_fn_field, gnuv3_baseclass_offset, gnuv3_print_method_ptr,
gnuv3_method_ptr_size, gnuv3_make_method_ptr, gnuv3_method_ptr_to_value):
Use get_type_arch instead of get_class_arch.
2009-07-02 14:57:14 +02:00
|
|
|
|
modify_field (type, buffer, value_as_long (fromval),
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
value_bitpos (toval), value_bitsize (toval));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
dest_buffer = buffer;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-05-28 02:53:52 +02:00
|
|
|
|
changed_addr = value_address (toval);
|
2015-07-28 17:01:50 +02:00
|
|
|
|
changed_len = type_length_units (type);
|
2005-02-06 Andrew Cagney <cagney@gnu.org>
* value.c (value_contents, value_contents_writeable): New
functions.
* value.h (VALUE_CONTENTS): Delete macro.
(value_contents, value_contents_writeable): Declare.
* xstormy16-tdep.c, value.c, valops.c, valarith.c: Update.
* stack.c, sparc-tdep.c, sparc64-tdep.c, sh-tdep.c: Update.
* sh64-tdep.c, scm-valprint.c, scm-exp.c, s390-tdep.c: Update.
* rs6000-tdep.c, p-valprint.c, printcmd.c: Update.
* ppc-sysv-tdep.c, mips-tdep.c, mi/mi-main.c: Update.
* m88k-tdep.c, m68hc11-tdep.c, m32r-tdep.c: Update.
* jv-valprint.c, ia64-tdep.c, hppa-tdep.c: Update.
* hpacc-abi.c, f-valprint.c, frv-tdep.c, eval.c: Update.
* c-valprint.c, cris-tdep.c, cp-valprint.c: Update.
* cli/cli-dump.c, breakpoint.c, avr-tdep.c, arm-tdep.c: Update.
* arm-linux-tdep.c, amd64-tdep.c, alpha-tdep.c: Update.
* ada-valprint.c, ada-lang.c: Update.
2005-02-07 01:09:56 +01:00
|
|
|
|
dest_buffer = value_contents (fromval);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-24 09:28:10 +02:00
|
|
|
|
write_memory_with_notification (changed_addr, dest_buffer, changed_len);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2002-11-07 03:45:27 +01:00
|
|
|
|
case lval_register:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
struct frame_info *frame;
|
2009-06-17 20:43:24 +02:00
|
|
|
|
struct gdbarch *gdbarch;
|
2003-06-14 Andrew Cagney <cagney@redhat.com>
Mark Kettenis <kettenis@gnu.org>
* gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter.
(REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer
parameter with "frame".
* gdbarch.h, gdbarch.c: Re-generate.
* frame.h (put_frame_register): Declare.
* frame.c (put_frame_register): New function.
* arch-utils.c (legacy_convert_register_p): Add "type" parameter.
(legacy_register_to_value): Rewrite, use "frame" to get the
register value.
(legacy_value_to_register): Rewrite, use "frame" to find the
register's location before storing.
* arch-utils.h (legacy_convert_register_p): Update.
(legacy_register_to_value, legacy_value_to_register): Update.
* findvar.c (value_from_register): Rewrite, eliminate use of
REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass
"frame" to REGISTER_TO_VALUE.
* valops.c (value_assign): Move the CONVERT_REGISTER code to the
lval_reg_frame_relative + lval_register branch of the switch. Do
not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register.
* i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM,
I386_EDI_REGNUM): New defines.
(i386_next_regnum, i386_convert_register_p,
i386_register_to_value, i386_value_to_register): New functions.
(i386_register_convertible, i386_register_convert_to_virtual,
i386_convert_to_raw): Remove functions.
(i386_gdbarch_init): Set convert_register_p, register_to_value and
value_to_register instead of register_convertible,
register_convert_to_virtual and register_convert_to_raw.
* mips-tdep.c (mips_convert_register_p): New function.
(mips_value_to_register): Replace mips_register_convert_from_type.
(mips_register_to_value): Replace mips_register_convert_to_type.
(mips_gdbarch_init): Set conver_register_p, value_to_register and
register_to_value.
* alpha-tdep.c (alpha_convert_register_p): Update.
(alpha_value_to_register): Update, store the register.
(alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
|
|
|
|
int value_reg;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID
The VALUE_FRAME_ID macro provides access to a member in struct value
that's used to hold the frame id that's used when determining a
register's value or when assigning to a register. The underlying
member has a long and obscure name. I won't refer to it here, but
will simply refer to VALUE_FRAME_ID as if it's the struct value member
instead of being a convenient macro.
At the moment, without this patch in place, VALUE_FRAME_ID is set in
value_of_register_lazy() and several other locations to hold the frame
id of the frame passed to those functions.
VALUE_FRAME_ID is used in the lval_register case of
value_fetch_lazy(). To fetch the register's value, it calls
get_frame_register_value() which, in turn, calls
frame_unwind_register_value() with frame->next.
A python based unwinder may wish to determine the value of a register
or evaluate an expression containing a register. When it does this,
value_fetch_lazy() will be called under some circumstances. It will
attempt to determine the frame id associated with the frame passed to
it. In so doing, it will end up back in the frame sniffer of the very
same python unwinder that's attempting to learn the value of a
register as part of the sniffing operation. This recursion is not
desirable.
As noted above, when value_fetch_lazy() wants to fetch a register's
value, it does so (indirectly) by unwinding from frame->next.
With this in mind, a solution suggests itself: Change VALUE_FRAME_ID
to hold the frame id associated with the next frame. Then, when it
comes time to obtain the value associated with the register, we can
simply unwind from the frame corresponding to the frame id stored in
VALUE_FRAME_ID. This neatly avoids the python unwinder recursion
problem by changing when the "next" operation occurs. Instead of the
"next" operation occuring when the register value is fetched, it
occurs earlier on when assigning a frame id to VALUE_FRAME_ID.
(Thanks to Pedro for this suggestion.)
This patch implements this idea.
It builds on the patch "Distinguish sentinel frame from null frame".
Without that work in place, it's necessary to check for null_id at
several places and then obtain the sentinel frame.
It also renames most occurences of VALUE_FRAME_ID to
VALUE_NEXT_FRAME_ID to reflect the new meaning of this field.
There are several uses of VALUE_FRAME_ID which were not changed. In
each case, the original meaning of VALUE_FRAME_ID is required to get
correct results. In all but one of these uses, either
put_frame_register_bytes() or get_frame_register_bytes() is being
called with the frame value obtained from VALUE_FRAME_ID. Both of
these functions perform some unwinding by performing a "->next"
operation on the frame passed to it. If we were to use the new
VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next"
operations, which is not what we want.
The VALUE_FRAME_ID macro has been redefined in terms of
VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id,
providing this id as the value of the macro.
gdb/ChangeLog:
* value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update
comment. Create new VALUE_FRAME_ID which is defined in terms of
VALUE_NEXT_FRAME_ID.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
* dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c,
valarith.c, valops.c, value.c: Adjust nearly all occurences of
VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those
which did not change.
* value.c (struct value): Rename frame_id field to next_frame_id.
Update comment.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
(value_fetch_lazy): Call frame_unwind_register_value()
instead of get_frame_register_value().
* frame.c (get_prev_frame_id_by_id): New function.
* frame.h (get_prev_frame_id_by_id): Declare.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make
VALUE_NEXT_FRAME_ID refer to the next frame.
* findvar.c (value_of_register_lazy): Likewise.
(default_value_from_register): Likewise.
(value_from_register): Likewise.
* frame_unwind.c (frame_unwind_got_optimized): Likewise.
* sentinel-frame.c (sentinel_frame_prev_register): Likewise.
* value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
|
|
|
|
/* Figure out which frame this is in currently.
|
|
|
|
|
|
|
|
|
|
We use VALUE_FRAME_ID for obtaining the value's frame id instead of
|
|
|
|
|
VALUE_NEXT_FRAME_ID due to requiring a frame which may be passed to
|
|
|
|
|
put_frame_register_bytes() below. That function will (eventually)
|
|
|
|
|
perform the necessary unwind operation by first obtaining the next
|
|
|
|
|
frame. */
|
2004-11-15 23:17:59 +01:00
|
|
|
|
frame = frame_find_by_id (VALUE_FRAME_ID (toval));
|
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID
The VALUE_FRAME_ID macro provides access to a member in struct value
that's used to hold the frame id that's used when determining a
register's value or when assigning to a register. The underlying
member has a long and obscure name. I won't refer to it here, but
will simply refer to VALUE_FRAME_ID as if it's the struct value member
instead of being a convenient macro.
At the moment, without this patch in place, VALUE_FRAME_ID is set in
value_of_register_lazy() and several other locations to hold the frame
id of the frame passed to those functions.
VALUE_FRAME_ID is used in the lval_register case of
value_fetch_lazy(). To fetch the register's value, it calls
get_frame_register_value() which, in turn, calls
frame_unwind_register_value() with frame->next.
A python based unwinder may wish to determine the value of a register
or evaluate an expression containing a register. When it does this,
value_fetch_lazy() will be called under some circumstances. It will
attempt to determine the frame id associated with the frame passed to
it. In so doing, it will end up back in the frame sniffer of the very
same python unwinder that's attempting to learn the value of a
register as part of the sniffing operation. This recursion is not
desirable.
As noted above, when value_fetch_lazy() wants to fetch a register's
value, it does so (indirectly) by unwinding from frame->next.
With this in mind, a solution suggests itself: Change VALUE_FRAME_ID
to hold the frame id associated with the next frame. Then, when it
comes time to obtain the value associated with the register, we can
simply unwind from the frame corresponding to the frame id stored in
VALUE_FRAME_ID. This neatly avoids the python unwinder recursion
problem by changing when the "next" operation occurs. Instead of the
"next" operation occuring when the register value is fetched, it
occurs earlier on when assigning a frame id to VALUE_FRAME_ID.
(Thanks to Pedro for this suggestion.)
This patch implements this idea.
It builds on the patch "Distinguish sentinel frame from null frame".
Without that work in place, it's necessary to check for null_id at
several places and then obtain the sentinel frame.
It also renames most occurences of VALUE_FRAME_ID to
VALUE_NEXT_FRAME_ID to reflect the new meaning of this field.
There are several uses of VALUE_FRAME_ID which were not changed. In
each case, the original meaning of VALUE_FRAME_ID is required to get
correct results. In all but one of these uses, either
put_frame_register_bytes() or get_frame_register_bytes() is being
called with the frame value obtained from VALUE_FRAME_ID. Both of
these functions perform some unwinding by performing a "->next"
operation on the frame passed to it. If we were to use the new
VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next"
operations, which is not what we want.
The VALUE_FRAME_ID macro has been redefined in terms of
VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id,
providing this id as the value of the macro.
gdb/ChangeLog:
* value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update
comment. Create new VALUE_FRAME_ID which is defined in terms of
VALUE_NEXT_FRAME_ID.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
* dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c,
valarith.c, valops.c, value.c: Adjust nearly all occurences of
VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those
which did not change.
* value.c (struct value): Rename frame_id field to next_frame_id.
Update comment.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
(value_fetch_lazy): Call frame_unwind_register_value()
instead of get_frame_register_value().
* frame.c (get_prev_frame_id_by_id): New function.
* frame.h (get_prev_frame_id_by_id): Declare.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make
VALUE_NEXT_FRAME_ID refer to the next frame.
* findvar.c (value_of_register_lazy): Likewise.
(default_value_from_register): Likewise.
(value_from_register): Likewise.
* frame_unwind.c (frame_unwind_got_optimized): Likewise.
* sentinel-frame.c (sentinel_frame_prev_register): Likewise.
* value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
|
|
|
|
|
2004-11-15 23:17:59 +01:00
|
|
|
|
value_reg = VALUE_REGNUM (toval);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (!frame)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Value being assigned to is no longer active."));
|
2009-06-17 20:43:24 +02:00
|
|
|
|
|
|
|
|
|
gdbarch = get_frame_arch (frame);
|
2014-10-03 13:21:33 +02:00
|
|
|
|
|
|
|
|
|
if (value_bitsize (toval))
|
2002-11-07 03:45:27 +01:00
|
|
|
|
{
|
2014-10-03 13:21:33 +02:00
|
|
|
|
struct value *parent = value_parent (toval);
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST offset = value_offset (parent) + value_offset (toval);
|
2014-10-03 13:21:33 +02:00
|
|
|
|
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);
|
2002-11-07 03:45:27 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
2002-11-07 03:45:27 +01:00
|
|
|
|
{
|
2014-10-03 13:21:33 +02:00
|
|
|
|
if (gdbarch_convert_register_p (gdbarch, VALUE_REGNUM (toval),
|
|
|
|
|
type))
|
2007-01-08 18:34:12 +01:00
|
|
|
|
{
|
2014-10-03 13:21:33 +02:00
|
|
|
|
/* 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));
|
2007-01-08 18:34:12 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
2007-01-08 18:34:12 +01:00
|
|
|
|
{
|
|
|
|
|
put_frame_register_bytes (frame, value_reg,
|
|
|
|
|
value_offset (toval),
|
|
|
|
|
TYPE_LENGTH (type),
|
|
|
|
|
value_contents (fromval));
|
|
|
|
|
}
|
2003-06-14 Andrew Cagney <cagney@redhat.com>
Mark Kettenis <kettenis@gnu.org>
* gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter.
(REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer
parameter with "frame".
* gdbarch.h, gdbarch.c: Re-generate.
* frame.h (put_frame_register): Declare.
* frame.c (put_frame_register): New function.
* arch-utils.c (legacy_convert_register_p): Add "type" parameter.
(legacy_register_to_value): Rewrite, use "frame" to get the
register value.
(legacy_value_to_register): Rewrite, use "frame" to find the
register's location before storing.
* arch-utils.h (legacy_convert_register_p): Update.
(legacy_register_to_value, legacy_value_to_register): Update.
* findvar.c (value_from_register): Rewrite, eliminate use of
REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass
"frame" to REGISTER_TO_VALUE.
* valops.c (value_assign): Move the CONVERT_REGISTER code to the
lval_reg_frame_relative + lval_register branch of the switch. Do
not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register.
* i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM,
I386_EDI_REGNUM): New defines.
(i386_next_regnum, i386_convert_register_p,
i386_register_to_value, i386_value_to_register): New functions.
(i386_register_convertible, i386_register_convert_to_virtual,
i386_convert_to_raw): Remove functions.
(i386_gdbarch_init): Set convert_register_p, register_to_value and
value_to_register instead of register_convertible,
register_convert_to_virtual and register_convert_to_raw.
* mips-tdep.c (mips_convert_register_p): New function.
(mips_value_to_register): Replace mips_register_convert_from_type.
(mips_register_to_value): Replace mips_register_convert_to_type.
(mips_gdbarch_init): Set conver_register_p, value_to_register and
register_to_value.
* alpha-tdep.c (alpha_convert_register_p): Update.
(alpha_value_to_register): Update, store the register.
(alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
|
|
|
|
}
|
2007-01-08 18:34:12 +01:00
|
|
|
|
|
New python events: inferior call, register/memory changed.
gdb/ChangeLog:
* NEWS: Mention new Python events.
* Makefile.in (SUBDIR_PYTHON_OBS): Add py-infevents.o.
(SUBDIR_PYTHON_SRCS): Add py-infevents.c.
(py-infevents.o): New rule.
* doc/observer.texi (inferior_call_pre, inferior_call_post)
(memory_changed, register_changed): New observers.
* infcall.c (call_function_by_hand): Notify observer before and
after inferior call.
* python/py-event.h (inferior_call_kind): New enum.
(emit_inferior_call_event): New prototype.
(emit_register_changed_event): New prototype.
(emit_memory_changed_event): New prototype.
* python/py-events.h (events_object): New registries
inferior_call, memory_changed and register_changed.
* python/py-evts.c (gdbpy_initialize_py_events): Add the
inferior_call, memory_changed and register_changed registries.
* python/py-infevents.c: New.
* python/py-inferior.c (python_on_inferior_call_pre)
(python_on_inferior_call_post, python_on_register_change)
(python_on_memory_change): New functions.
(gdbpy_initialize_inferior): Attach python handler to new
observers.
* python/py-infthread.c(gdbpy_create_ptid_object): New.
(thpy_get_ptid) Use gdbpy_create_ptid_object.
* python/python-internal.h:
(gdbpy_create_ptid_object)
(gdbpy_initialize_inferior_call_pre_event)
(gdbpy_initialize_inferior_call_post_event)
(gdbpy_initialize_register_changed_event)
(gdbpy_initialize_memory_changed_event): New prototypes.
* python/python.c (_initialize_python): Initialize new events.
* valops.c (value_assign): Notify register_changed observer.
gdb/doc/ChangeLog:
* python.texi (Events In Python): Document new events
InferiorCallPreEvent, InferiorCallPostEvent, MemoryChangedEvent
and RegisterChangedEvent.
gdb/testsuite/ChangeLog:
* gdb.python/py-events.py (inferior_call_handler): New.
(register_changed_handler, memory_changed_handler): New.
(test_events.invoke): Register new handlers.
* gdb.python/py-events.exp: Add tests for inferior call,
memory_changed and register_changed events.
2014-12-02 20:15:29 +01:00
|
|
|
|
observer_notify_register_changed (frame, value_reg);
|
2003-06-14 Andrew Cagney <cagney@redhat.com>
Mark Kettenis <kettenis@gnu.org>
* gdbarch.sh (CONVERT_REGISTER_P): Add "type" parameter.
(REGISTER_TO_VALUE, VALUE_TO_REGISTER): Replace raw buffer
parameter with "frame".
* gdbarch.h, gdbarch.c: Re-generate.
* frame.h (put_frame_register): Declare.
* frame.c (put_frame_register): New function.
* arch-utils.c (legacy_convert_register_p): Add "type" parameter.
(legacy_register_to_value): Rewrite, use "frame" to get the
register value.
(legacy_value_to_register): Rewrite, use "frame" to find the
register's location before storing.
* arch-utils.h (legacy_convert_register_p): Update.
(legacy_register_to_value, legacy_value_to_register): Update.
* findvar.c (value_from_register): Rewrite, eliminate use of
REGISTER_CONVERT_TO_TYPE, pass "type" to CONVERT_REGISTER_P, pass
"frame" to REGISTER_TO_VALUE.
* valops.c (value_assign): Move the CONVERT_REGISTER code to the
lval_reg_frame_relative + lval_register branch of the switch. Do
not use REGISTER_CONVERT_FROM_TYPE. Use put_frame_register.
* i386-tdep.c (I386_EBX_REGNUM, I386_ECX_REGNUM, I386_ESI_REGNUM,
I386_EDI_REGNUM): New defines.
(i386_next_regnum, i386_convert_register_p,
i386_register_to_value, i386_value_to_register): New functions.
(i386_register_convertible, i386_register_convert_to_virtual,
i386_convert_to_raw): Remove functions.
(i386_gdbarch_init): Set convert_register_p, register_to_value and
value_to_register instead of register_convertible,
register_convert_to_virtual and register_convert_to_raw.
* mips-tdep.c (mips_convert_register_p): New function.
(mips_value_to_register): Replace mips_register_convert_from_type.
(mips_register_to_value): Replace mips_register_convert_to_type.
(mips_gdbarch_init): Set conver_register_p, value_to_register and
register_to_value.
* alpha-tdep.c (alpha_convert_register_p): Update.
(alpha_value_to_register): Update, store the register.
(alpha_register_to_value): Update, fetch the register.
2003-06-15 00:35:25 +02:00
|
|
|
|
break;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2009-02-06 23:50:52 +01:00
|
|
|
|
|
|
|
|
|
case lval_computed:
|
|
|
|
|
{
|
2011-07-14 17:00:20 +02:00
|
|
|
|
const struct lval_funcs *funcs = value_computed_funcs (toval);
|
2009-02-06 23:50:52 +01:00
|
|
|
|
|
2011-10-09 21:36:06 +02:00
|
|
|
|
if (funcs->write != NULL)
|
|
|
|
|
{
|
|
|
|
|
funcs->write (toval, fromval);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-02-06 23:50:52 +01:00
|
|
|
|
}
|
2011-10-09 21:36:06 +02:00
|
|
|
|
/* Fall through. */
|
2009-02-06 23:50:52 +01:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
default:
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Left operand of assignment is not an lvalue."));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2003-01-30 17:44:20 +01:00
|
|
|
|
/* Assigning to the stack pointer, frame pointer, and other
|
|
|
|
|
(architecture and calling convention specific) registers may
|
2012-09-14 02:54:58 +02:00
|
|
|
|
cause the frame cache and regcache to be out of date. Assigning to memory
|
2003-01-30 17:44:20 +01:00
|
|
|
|
also can. We just do this on all assignments to registers or
|
|
|
|
|
memory, for simplicity's sake; I doubt the slowdown matters. */
|
|
|
|
|
switch (VALUE_LVAL (toval))
|
|
|
|
|
{
|
|
|
|
|
case lval_memory:
|
|
|
|
|
case lval_register:
|
2010-06-11 17:36:10 +02:00
|
|
|
|
case lval_computed:
|
2003-01-30 17:44:20 +01:00
|
|
|
|
|
2012-09-14 02:54:58 +02:00
|
|
|
|
observer_notify_target_changed (¤t_target);
|
2003-01-30 17:44:20 +01:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Having destroyed the frame cache, restore the selected
|
|
|
|
|
frame. */
|
2003-01-30 17:44:20 +01:00
|
|
|
|
|
|
|
|
|
/* FIXME: cagney/2002-11-02: There has to be a better way of
|
|
|
|
|
doing this. Instead of constantly saving/restoring the
|
|
|
|
|
frame. Why not create a get_selected_frame() function that,
|
|
|
|
|
having saved the selected frame's ID can automatically
|
|
|
|
|
re-find the previously selected frame automatically. */
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
struct frame_info *fi = frame_find_by_id (old_frame);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2003-01-30 17:44:20 +01:00
|
|
|
|
if (fi != NULL)
|
|
|
|
|
select_frame (fi);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* If the field does not entirely fill a LONGEST, then zero the sign
|
|
|
|
|
bits. If the field is signed, and is negative, then sign
|
|
|
|
|
extend. */
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
if ((value_bitsize (toval) > 0)
|
|
|
|
|
&& (value_bitsize (toval) < 8 * (int) sizeof (LONGEST)))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
LONGEST fieldval = value_as_long (fromval);
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
LONGEST valmask = (((ULONGEST) 1) << value_bitsize (toval)) - 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
fieldval &= valmask;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
if (!TYPE_UNSIGNED (type)
|
|
|
|
|
&& (fieldval & (valmask ^ (valmask >> 1))))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
fieldval |= ~valmask;
|
|
|
|
|
|
|
|
|
|
fromval = value_from_longest (type, fieldval);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 17:49:41 +01:00
|
|
|
|
/* The return value is a copy of TOVAL so it shares its location
|
|
|
|
|
information, but its contents are updated from FROMVAL. This
|
|
|
|
|
implies the returned value is not lazy, even if TOVAL was. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
val = value_copy (toval);
|
2010-12-01 17:49:41 +01:00
|
|
|
|
set_value_lazy (val, 0);
|
2005-02-06 Andrew Cagney <cagney@gnu.org>
* value.c (value_contents, value_contents_writeable): New
functions.
* value.h (VALUE_CONTENTS): Delete macro.
(value_contents, value_contents_writeable): Declare.
* xstormy16-tdep.c, value.c, valops.c, valarith.c: Update.
* stack.c, sparc-tdep.c, sparc64-tdep.c, sh-tdep.c: Update.
* sh64-tdep.c, scm-valprint.c, scm-exp.c, s390-tdep.c: Update.
* rs6000-tdep.c, p-valprint.c, printcmd.c: Update.
* ppc-sysv-tdep.c, mips-tdep.c, mi/mi-main.c: Update.
* m88k-tdep.c, m68hc11-tdep.c, m32r-tdep.c: Update.
* jv-valprint.c, ia64-tdep.c, hppa-tdep.c: Update.
* hpacc-abi.c, f-valprint.c, frv-tdep.c, eval.c: Update.
* c-valprint.c, cris-tdep.c, cp-valprint.c: Update.
* cli/cli-dump.c, breakpoint.c, avr-tdep.c, arm-tdep.c: Update.
* arm-linux-tdep.c, amd64-tdep.c, alpha-tdep.c: Update.
* ada-valprint.c, ada-lang.c: Update.
2005-02-07 01:09:56 +01:00
|
|
|
|
memcpy (value_contents_raw (val), value_contents (fromval),
|
1999-04-16 03:35:26 +02:00
|
|
|
|
TYPE_LENGTH (type));
|
2010-12-01 17:49:41 +01:00
|
|
|
|
|
|
|
|
|
/* We copy over the enclosing type and pointed-to offset from FROMVAL
|
|
|
|
|
in the case of pointer types. For object types, the enclosing type
|
|
|
|
|
and embedded offset must *not* be copied: the target object refered
|
|
|
|
|
to by TOVAL retains its original dynamic type after assignment. */
|
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_PTR)
|
|
|
|
|
{
|
|
|
|
|
set_value_enclosing_type (val, value_enclosing_type (fromval));
|
|
|
|
|
set_value_pointed_to_offset (val, value_pointed_to_offset (fromval));
|
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Extend a value VAL to COUNT repetitions of its type. */
|
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_repeat (struct value *arg1, int count)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *val;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (VALUE_LVAL (arg1) != lval_memory)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Only values in memory can be extended with '@'."));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (count < 1)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Invalid number %d of repetitions."), count);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2005-02-02 21:31:35 +01:00
|
|
|
|
val = allocate_repeat_value (value_enclosing_type (arg1), count);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
VALUE_LVAL (val) = lval_memory;
|
2009-05-28 02:53:52 +02:00
|
|
|
|
set_value_address (val, value_address (arg1));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2011-02-14 12:32:17 +01:00
|
|
|
|
read_value_memory (val, 0, value_stack (val), value_address (val),
|
|
|
|
|
value_contents_all_raw (val),
|
2015-07-28 17:01:50 +02:00
|
|
|
|
type_length_units (value_enclosing_type (val)));
|
2011-02-14 12:32:17 +01:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2011-10-20 14:31:30 +02:00
|
|
|
|
value_of_variable (struct symbol *var, const struct block *b)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2015-02-05 17:00:06 +01:00
|
|
|
|
struct frame_info *frame = NULL;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2015-02-05 17:00:06 +01:00
|
|
|
|
if (symbol_read_needs_frame (var))
|
2009-01-15 16:38:07 +01:00
|
|
|
|
frame = get_selected_frame (_("No frame selected."));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2015-02-05 17:00:06 +01:00
|
|
|
|
return read_var_value (var, b, frame);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-15 16:38:07 +01:00
|
|
|
|
struct value *
|
* ada-exp.y (write_object_renaming, write_var_or_type)
(write_ambiguous_var, write_var_from_sym): Make blocks const.
* ada-lang.c (replace_operator_with_call)
(find_old_style_renaming_symbol): Make blocks const.
* ada-lang.h (ada_find_renaming_symbol): Update.
(struct ada_symbol_info) <block>: Now const.
* breakpoint.c (watch_command_1): Update.
* breakpoint.h (struct watchpoint) <exp_valid_block,
cond_exp_valid_block>: Now const.
* c-exp.y (classify_inner_name, classify_name): Make block
argument const.
* expprint.c (print_subexp_standard) <OP_VAR_VALUE>: Make 'b'
const.
* expression.h (innermost_block, parse_exp_1): Update.
(union exp_element) <block>: Now const.
* gdbtypes.c (lookup_template_type, lookup_enum, lookup_union)
(lookup_struct): Make block argument const.
* gdbtypes.h (lookup_template_type): Update.
* go-exp.y (classify_name, classify_packaged_name)
(package_name_p): Make block argument const.
* objc-lang.c (lookup_struct_typedef): Make block argument const.
* objc-lang.h (lookup_struct_typedef): Update.
* parse.c (parse_exp_in_context, parse_exp_1)
(write_exp_elt_block): Make block arguments const.
(expression_context_block, innermost_block): Now const.
* parser-defs.h (write_exp_elt_block): Update.
(expression_context_block, innermost_block, block_found): Now
const.
* printcmd.c (struct display) <block>: Now const.
* symtab.h (lookup_struct, lookup_union, lookup_enum): Update.
* valops.c (address_of_variable): Make block argument const.
* value.h (value_of_variable): Update.
* varobj.c (struct varobj_root) <valid_block>: Now const.
2012-12-03 20:59:14 +01:00
|
|
|
|
address_of_variable (struct symbol *var, const struct block *b)
|
2009-01-15 16:38:07 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *type = SYMBOL_TYPE (var);
|
|
|
|
|
struct value *val;
|
|
|
|
|
|
|
|
|
|
/* Evaluate it first; if the result is a memory address, we're fine.
|
2011-01-12 02:23:29 +01:00
|
|
|
|
Lazy evaluation pays off here. */
|
2009-01-15 16:38:07 +01:00
|
|
|
|
|
|
|
|
|
val = value_of_variable (var, b);
|
2013-10-14 09:36:13 +02:00
|
|
|
|
type = value_type (val);
|
2009-01-15 16:38:07 +01:00
|
|
|
|
|
|
|
|
|
if ((VALUE_LVAL (val) == lval_memory && value_lazy (val))
|
|
|
|
|
|| TYPE_CODE (type) == TYPE_CODE_FUNC)
|
|
|
|
|
{
|
2009-05-28 02:53:52 +02:00
|
|
|
|
CORE_ADDR addr = value_address (val);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2009-01-15 16:38:07 +01:00
|
|
|
|
return value_from_pointer (lookup_pointer_type (type), addr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Not a memory address; check what the problem was. */
|
|
|
|
|
switch (VALUE_LVAL (val))
|
|
|
|
|
{
|
|
|
|
|
case lval_register:
|
|
|
|
|
{
|
|
|
|
|
struct frame_info *frame;
|
|
|
|
|
const char *regname;
|
|
|
|
|
|
Change meaning of VALUE_FRAME_ID; rename to VALUE_NEXT_FRAME_ID
The VALUE_FRAME_ID macro provides access to a member in struct value
that's used to hold the frame id that's used when determining a
register's value or when assigning to a register. The underlying
member has a long and obscure name. I won't refer to it here, but
will simply refer to VALUE_FRAME_ID as if it's the struct value member
instead of being a convenient macro.
At the moment, without this patch in place, VALUE_FRAME_ID is set in
value_of_register_lazy() and several other locations to hold the frame
id of the frame passed to those functions.
VALUE_FRAME_ID is used in the lval_register case of
value_fetch_lazy(). To fetch the register's value, it calls
get_frame_register_value() which, in turn, calls
frame_unwind_register_value() with frame->next.
A python based unwinder may wish to determine the value of a register
or evaluate an expression containing a register. When it does this,
value_fetch_lazy() will be called under some circumstances. It will
attempt to determine the frame id associated with the frame passed to
it. In so doing, it will end up back in the frame sniffer of the very
same python unwinder that's attempting to learn the value of a
register as part of the sniffing operation. This recursion is not
desirable.
As noted above, when value_fetch_lazy() wants to fetch a register's
value, it does so (indirectly) by unwinding from frame->next.
With this in mind, a solution suggests itself: Change VALUE_FRAME_ID
to hold the frame id associated with the next frame. Then, when it
comes time to obtain the value associated with the register, we can
simply unwind from the frame corresponding to the frame id stored in
VALUE_FRAME_ID. This neatly avoids the python unwinder recursion
problem by changing when the "next" operation occurs. Instead of the
"next" operation occuring when the register value is fetched, it
occurs earlier on when assigning a frame id to VALUE_FRAME_ID.
(Thanks to Pedro for this suggestion.)
This patch implements this idea.
It builds on the patch "Distinguish sentinel frame from null frame".
Without that work in place, it's necessary to check for null_id at
several places and then obtain the sentinel frame.
It also renames most occurences of VALUE_FRAME_ID to
VALUE_NEXT_FRAME_ID to reflect the new meaning of this field.
There are several uses of VALUE_FRAME_ID which were not changed. In
each case, the original meaning of VALUE_FRAME_ID is required to get
correct results. In all but one of these uses, either
put_frame_register_bytes() or get_frame_register_bytes() is being
called with the frame value obtained from VALUE_FRAME_ID. Both of
these functions perform some unwinding by performing a "->next"
operation on the frame passed to it. If we were to use the new
VALUE_NEXT_FRAME_ID macro, this would effectively do two "->next"
operations, which is not what we want.
The VALUE_FRAME_ID macro has been redefined in terms of
VALUE_NEXT_FRAME_ID. It simply fetches the previous frame's id,
providing this id as the value of the macro.
gdb/ChangeLog:
* value.h (VALUE_FRAME_ID): Rename to VALUE_NEXT_FRAME_ID. Update
comment. Create new VALUE_FRAME_ID which is defined in terms of
VALUE_NEXT_FRAME_ID.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
* dwarf2loc.c, findvar.c, frame-unwind.c, sentinel-frame.c,
valarith.c, valops.c, value.c: Adjust nearly all occurences of
VALUE_FRAME_ID to VALUE_NEXT_FRAME_ID. Add comments for those
which did not change.
* value.c (struct value): Rename frame_id field to next_frame_id.
Update comment.
(deprecated_value_frame_id_hack): Rename to
deprecated_value_next_frame_id_hack.
(value_fetch_lazy): Call frame_unwind_register_value()
instead of get_frame_register_value().
* frame.c (get_prev_frame_id_by_id): New function.
* frame.h (get_prev_frame_id_by_id): Declare.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full): Make
VALUE_NEXT_FRAME_ID refer to the next frame.
* findvar.c (value_of_register_lazy): Likewise.
(default_value_from_register): Likewise.
(value_from_register): Likewise.
* frame_unwind.c (frame_unwind_got_optimized): Likewise.
* sentinel-frame.c (sentinel_frame_prev_register): Likewise.
* value.h (VALUE_FRAME_ID): Update comment describing this macro.
2016-09-28 06:18:44 +02:00
|
|
|
|
frame = frame_find_by_id (VALUE_NEXT_FRAME_ID (val));
|
2009-01-15 16:38:07 +01:00
|
|
|
|
gdb_assert (frame);
|
|
|
|
|
|
|
|
|
|
regname = gdbarch_register_name (get_frame_arch (frame),
|
|
|
|
|
VALUE_REGNUM (val));
|
|
|
|
|
gdb_assert (regname && *regname);
|
|
|
|
|
|
|
|
|
|
error (_("Address requested for identifier "
|
|
|
|
|
"\"%s\" which is in register $%s"),
|
|
|
|
|
SYMBOL_PRINT_NAME (var), regname);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
error (_("Can't take address of \"%s\" which isn't an lvalue."),
|
|
|
|
|
SYMBOL_PRINT_NAME (var));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-21 16:02:38 +01:00
|
|
|
|
/* Return one if VAL does not live in target memory, but should in order
|
|
|
|
|
to operate on it. Otherwise return zero. */
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
value_must_coerce_to_target (struct value *val)
|
|
|
|
|
{
|
|
|
|
|
struct type *valtype;
|
|
|
|
|
|
|
|
|
|
/* The only lval kinds which do not live in target memory. */
|
|
|
|
|
if (VALUE_LVAL (val) != not_lval
|
2014-05-20 15:30:29 +02:00
|
|
|
|
&& VALUE_LVAL (val) != lval_internalvar
|
|
|
|
|
&& VALUE_LVAL (val) != lval_xcallable)
|
2008-03-21 16:02:38 +01:00
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
valtype = check_typedef (value_type (val));
|
|
|
|
|
|
|
|
|
|
switch (TYPE_CODE (valtype))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
2010-07-14 16:54:58 +02:00
|
|
|
|
return TYPE_VECTOR (valtype) ? 0 : 1;
|
2008-03-21 16:02:38 +01:00
|
|
|
|
case TYPE_CODE_STRING:
|
|
|
|
|
return 1;
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-05 23:22:53 +01:00
|
|
|
|
/* Make sure that VAL lives in target memory if it's supposed to. For
|
|
|
|
|
instance, strings are constructed as character arrays in GDB's
|
|
|
|
|
storage, and this function copies them to the target. */
|
2008-03-21 16:02:38 +01:00
|
|
|
|
|
|
|
|
|
struct value *
|
|
|
|
|
value_coerce_to_target (struct value *val)
|
|
|
|
|
{
|
|
|
|
|
LONGEST length;
|
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
|
|
if (!value_must_coerce_to_target (val))
|
|
|
|
|
return val;
|
|
|
|
|
|
|
|
|
|
length = TYPE_LENGTH (check_typedef (value_type (val)));
|
|
|
|
|
addr = allocate_space_in_inferior (length);
|
|
|
|
|
write_memory (addr, value_contents (val), length);
|
|
|
|
|
return value_at_lazy (value_type (val), addr);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Given a value which is an array, return a value which is a pointer
|
|
|
|
|
to its first element, regardless of whether or not the array has a
|
|
|
|
|
nonzero lower bound.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
FIXME: A previous comment here indicated that this routine should
|
|
|
|
|
be substracting the array's lower bound. It's not clear to me that
|
|
|
|
|
this is correct. Given an array subscripting operation, it would
|
|
|
|
|
certainly work to do the adjustment here, essentially computing:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
(&array[0] - (lowerbound * sizeof array[0])) + (index * sizeof array[0])
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
However I believe a more appropriate and logical place to account
|
|
|
|
|
for the lower bound is to do so in value_subscript, essentially
|
|
|
|
|
computing:
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
(&array[0] + ((index - lowerbound) * sizeof array[0]))
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
As further evidence consider what would happen with operations
|
|
|
|
|
other than array subscripting, where the caller would get back a
|
|
|
|
|
value that had an address somewhere before the actual first element
|
|
|
|
|
of the array, and the information about the lower bound would be
|
2011-01-12 02:23:29 +01:00
|
|
|
|
lost because of the coercion to pointer type. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_coerce_array (struct value *arg1)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
struct type *type = check_typedef (value_type (arg1));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2008-03-21 16:02:38 +01:00
|
|
|
|
/* If the user tries to do something requiring a pointer with an
|
|
|
|
|
array that has not yet been pushed to the target, then this would
|
|
|
|
|
be a good time to do so. */
|
|
|
|
|
arg1 = value_coerce_to_target (arg1);
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (VALUE_LVAL (arg1) != lval_memory)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Attempt to take address of value not located in memory."));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
* gdbarch.sh (POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Two new
functions which architectures can redefine, defaulting to
generic_pointer_to_address and generic_address_to_pointer.
* findvar.c (extract_typed_address, store_typed_address,
generic_pointer_to_address, generic_address_to_pointer): New
functions.
(POINTER_TO_ADDRESS, ADDRESS_TO_POINTER): Provide default
definitions.
(extract_address, store_address): Doc fixes.
* values.c (value_as_pointer): Doc fix.
(value_from_pointer): New function.
* defs.h (extract_typed_address, store_typed_address): New
declarations.
* inferior.h (generic_address_to_pointer,
generic_pointer_to_address): New declarations.
* value.h (value_from_pointer): New declaration.
* ax-gdb.c (const_var_ref): Use value_from_pointer, not
value_from_longest.
* blockframe.c (generic_push_dummy_frame): Use read_pc and
read_sp, not read_register.
* c-valprint.c (c_val_print): Use extract_typed_address instead of
extract_address to extract vtable entries and references.
* cp-valprint.c (cp_print_value_fields): Use value_from_pointer
instead of value_from_longest to extract the vtable's address.
* eval.c (evaluate_subexp_standard): Use value_from_pointer
instead of value_from_longest to compute `this', and for doing
pointer-to-member dereferencing.
* findvar.c (read_register): Use extract_unsigned_integer, not
extract_address.
(read_var_value): Use store_typed_address instead of store_address
for building label values.
(locate_var_value): Use value_from_pointer instead of
value_from_longest.
* hppa-tdep.c (find_stub_with_shl_get): Use value_from_pointer,
instead of value_from_longest, to build arguments to __d_shl_get.
* printcmd.c (set_next_address): Use value_from_pointer, not
value_from_longest.
(x_command): Use value_from_pointer, not value_from_longest.
* tracepoint.c (set_traceframe_context): Use value_from_pointer,
not value_from_longest.
* valarith.c (value_add, value_sub): Use value_from_pointer, not
value_from_longest.
* valops.c (find_function_in_inferior, value_coerce_array,
value_coerce_function, value_addr, hand_function_call): Same.
* value.h (COERCE_REF): Use unpack_pointer, not unpack_long.
* values.c (unpack_long): Use extract_typed_address to produce
addresses from pointers and references, not extract_address.
(value_from_longest): Use store_typed_address instead of
store_address to produce pointer and reference values.
2000-04-14 20:43:41 +02:00
|
|
|
|
return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
|
2009-05-28 02:53:52 +02:00
|
|
|
|
value_address (arg1));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given a value which is a function, return a value which is a pointer
|
|
|
|
|
to it. */
|
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_coerce_function (struct value *arg1)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *retval;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (VALUE_LVAL (arg1) != lval_memory)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Attempt to take address of value not located in memory."));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
retval = value_from_pointer (lookup_pointer_type (value_type (arg1)),
|
2009-05-28 02:53:52 +02:00
|
|
|
|
value_address (arg1));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return retval;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Return a pointer value for the object for which ARG1 is the
|
|
|
|
|
contents. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_addr (struct value *arg1)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *arg2;
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
struct type *type = check_typedef (value_type (arg1));
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
if (TYPE_IS_REFERENCE (type))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
[PR gdb/19893] Fix handling of synthetic C++ references
https://sourceware.org/bugzilla/show_bug.cgi?id=19893
I've traced the main source of the problem to pieced_value_funcs.coerce_ref not being
implemented. Since gdb always assumes references are implemented as pointers, this
causes it to think that it's dealing with a NULL pointer, thus breaking any operations
involving synthetic references.
What I did here was implementing pieced_value_funcs.coerce_ref using some of the synthetic
pointer handling code from indirect_pieced_value, as Pedro suggested. I also made a few
adjustments to the reference printing code so that it correctly shows either the address
of the referenced value or (if it's non-addressable) the "<synthetic pointer>" string.
I also wrote some unit tests based on Dwarf::assemble; these took a while to make
because in most cases I needed a synthetic reference to a physical variable. Additionally,
I started working on a unit test for classes that have a vtable, but ran into a few issues
so that'll probably go in a future patch. One thing that should definitely be fixed is that
proc function_range (called for MACRO_AT_func) will always try to compile/link using gcc
with the default options instead of g++, thus breaking C++ compilations that require e.g. libstdc++.
gdb/ChangeLog:
* dwarf2loc.c (coerce_pieced_ref, indirect_synthetic_pointer,
fetch_const_value_from_synthetic_pointer): New functions.
(indirect_pieced_value): Move lower half to indirect_synthetic_pointer.
(pieced_value_funcs): Implement coerce_ref.
* valops.c (value_addr): Call coerce_ref for synthetic references.
* valprint.c (valprint_check_validity): Return true for synthetic
references. Also, don't show "<synthetic pointer>" if they reference
addressable values.
(generic_val_print_ref): Handle synthetic references. Also move some
code to print_ref_address.
(print_ref_address, get_value_addr_contents): New functions.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/implref.exp: Rename to...
* gdb.dwarf2/implref-const.exp: ...this. Also add more test statements.
* gdb.dwarf2/implref-array.c: New file.
* gdb.dwarf2/implref-array.exp: Likewise.
* gdb.dwarf2/implref-global.c: Likewise.
* gdb.dwarf2/implref-global.exp: Likewise.
* gdb.dwarf2/implref-struct.c: Likewise.
* gdb.dwarf2/implref-struct.exp: Likewise.
2016-05-31 20:54:01 +02:00
|
|
|
|
if (value_bits_synthetic_pointer (arg1, value_embedded_offset (arg1),
|
|
|
|
|
TARGET_CHAR_BIT * TYPE_LENGTH (type)))
|
|
|
|
|
arg1 = coerce_ref (arg1);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Copy the value, but change the type from (T&) to (T*). We
|
|
|
|
|
keep the same location information, which is efficient, and
|
|
|
|
|
allows &(&X) to get the location containing the reference.
|
|
|
|
|
Do the same to its enclosing type for consistency. */
|
|
|
|
|
struct type *type_ptr
|
|
|
|
|
= lookup_pointer_type (TYPE_TARGET_TYPE (type));
|
|
|
|
|
struct type *enclosing_type
|
|
|
|
|
= check_typedef (value_enclosing_type (arg1));
|
|
|
|
|
struct type *enclosing_type_ptr
|
|
|
|
|
= lookup_pointer_type (TYPE_TARGET_TYPE (enclosing_type));
|
|
|
|
|
|
|
|
|
|
arg2 = value_copy (arg1);
|
|
|
|
|
deprecated_set_value_type (arg2, type_ptr);
|
|
|
|
|
set_value_enclosing_type (arg2, enclosing_type_ptr);
|
2016-04-18 15:58:14 +02:00
|
|
|
|
|
[PR gdb/19893] Fix handling of synthetic C++ references
https://sourceware.org/bugzilla/show_bug.cgi?id=19893
I've traced the main source of the problem to pieced_value_funcs.coerce_ref not being
implemented. Since gdb always assumes references are implemented as pointers, this
causes it to think that it's dealing with a NULL pointer, thus breaking any operations
involving synthetic references.
What I did here was implementing pieced_value_funcs.coerce_ref using some of the synthetic
pointer handling code from indirect_pieced_value, as Pedro suggested. I also made a few
adjustments to the reference printing code so that it correctly shows either the address
of the referenced value or (if it's non-addressable) the "<synthetic pointer>" string.
I also wrote some unit tests based on Dwarf::assemble; these took a while to make
because in most cases I needed a synthetic reference to a physical variable. Additionally,
I started working on a unit test for classes that have a vtable, but ran into a few issues
so that'll probably go in a future patch. One thing that should definitely be fixed is that
proc function_range (called for MACRO_AT_func) will always try to compile/link using gcc
with the default options instead of g++, thus breaking C++ compilations that require e.g. libstdc++.
gdb/ChangeLog:
* dwarf2loc.c (coerce_pieced_ref, indirect_synthetic_pointer,
fetch_const_value_from_synthetic_pointer): New functions.
(indirect_pieced_value): Move lower half to indirect_synthetic_pointer.
(pieced_value_funcs): Implement coerce_ref.
* valops.c (value_addr): Call coerce_ref for synthetic references.
* valprint.c (valprint_check_validity): Return true for synthetic
references. Also, don't show "<synthetic pointer>" if they reference
addressable values.
(generic_val_print_ref): Handle synthetic references. Also move some
code to print_ref_address.
(print_ref_address, get_value_addr_contents): New functions.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/implref.exp: Rename to...
* gdb.dwarf2/implref-const.exp: ...this. Also add more test statements.
* gdb.dwarf2/implref-array.c: New file.
* gdb.dwarf2/implref-array.exp: Likewise.
* gdb.dwarf2/implref-global.c: Likewise.
* gdb.dwarf2/implref-global.exp: Likewise.
* gdb.dwarf2/implref-struct.c: Likewise.
* gdb.dwarf2/implref-struct.exp: Likewise.
2016-05-31 20:54:01 +02:00
|
|
|
|
return arg2;
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_FUNC)
|
|
|
|
|
return value_coerce_function (arg1);
|
|
|
|
|
|
2008-03-21 16:02:38 +01:00
|
|
|
|
/* If this is an array that has not yet been pushed to the target,
|
|
|
|
|
then this would be a good time to force it to memory. */
|
|
|
|
|
arg1 = value_coerce_to_target (arg1);
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (VALUE_LVAL (arg1) != lval_memory)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Attempt to take address of value not located in memory."));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2011-01-12 02:23:29 +01:00
|
|
|
|
/* Get target memory address. */
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
arg2 = value_from_pointer (lookup_pointer_type (value_type (arg1)),
|
2009-05-28 02:53:52 +02:00
|
|
|
|
(value_address (arg1)
|
2005-02-07 18:06:29 +01:00
|
|
|
|
+ value_embedded_offset (arg1)));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
/* This may be a pointer to a base subobject; so remember the
|
2007-08-14 02:31:40 +02:00
|
|
|
|
full derived object's type ... */
|
2010-11-10 18:47:23 +01:00
|
|
|
|
set_value_enclosing_type (arg2,
|
|
|
|
|
lookup_pointer_type (value_enclosing_type (arg1)));
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* ... and also the relative position of the subobject in the full
|
|
|
|
|
object. */
|
2005-02-07 21:17:28 +01:00
|
|
|
|
set_value_pointed_to_offset (arg2, value_embedded_offset (arg1));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return arg2;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Return a reference value for the object for which ARG1 is the
|
|
|
|
|
contents. */
|
2006-07-13 06:31:42 +02:00
|
|
|
|
|
|
|
|
|
struct value *
|
2017-03-20 21:47:41 +01:00
|
|
|
|
value_ref (struct value *arg1, enum type_code refcode)
|
2006-07-13 06:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
struct value *arg2;
|
|
|
|
|
struct type *type = check_typedef (value_type (arg1));
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2017-03-20 21:47:41 +01:00
|
|
|
|
gdb_assert (refcode == TYPE_CODE_REF || refcode == TYPE_CODE_RVALUE_REF);
|
|
|
|
|
|
|
|
|
|
if ((TYPE_CODE (type) == TYPE_CODE_REF
|
|
|
|
|
|| TYPE_CODE (type) == TYPE_CODE_RVALUE_REF)
|
|
|
|
|
&& TYPE_CODE (type) == refcode)
|
2006-07-13 06:31:42 +02:00
|
|
|
|
return arg1;
|
|
|
|
|
|
|
|
|
|
arg2 = value_addr (arg1);
|
2017-03-20 21:47:41 +01:00
|
|
|
|
deprecated_set_value_type (arg2, lookup_reference_type (type, refcode));
|
2006-07-13 06:31:42 +02:00
|
|
|
|
return arg2;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Given a value of a pointer type, apply the C unary * operator to
|
|
|
|
|
it. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_ind (struct value *arg1)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
struct type *base_type;
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *arg2;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
2004-11-10 19:52:25 +01:00
|
|
|
|
arg1 = coerce_array (arg1);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
base_type = check_typedef (value_type (arg1));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-11-29 22:18:16 +01:00
|
|
|
|
if (VALUE_LVAL (arg1) == lval_computed)
|
|
|
|
|
{
|
2011-07-14 17:00:20 +02:00
|
|
|
|
const struct lval_funcs *funcs = value_computed_funcs (arg1);
|
2010-11-29 22:18:16 +01:00
|
|
|
|
|
|
|
|
|
if (funcs->indirect)
|
|
|
|
|
{
|
|
|
|
|
struct value *result = funcs->indirect (arg1);
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-11 16:17:58 +02:00
|
|
|
|
if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
struct type *enc_type;
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* We may be pointing to something embedded in a larger object.
|
|
|
|
|
Get the real type of the enclosing object. */
|
2005-02-02 21:31:35 +01:00
|
|
|
|
enc_type = check_typedef (value_enclosing_type (arg1));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
enc_type = TYPE_TARGET_TYPE (enc_type);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (check_typedef (enc_type)) == TYPE_CODE_FUNC
|
|
|
|
|
|| TYPE_CODE (check_typedef (enc_type)) == TYPE_CODE_METHOD)
|
|
|
|
|
/* For functions, go through find_function_addr, which knows
|
|
|
|
|
how to handle function descriptors. */
|
2007-08-14 02:31:40 +02:00
|
|
|
|
arg2 = value_at_lazy (enc_type,
|
|
|
|
|
find_function_addr (arg1, NULL));
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
else
|
2011-01-12 02:23:29 +01:00
|
|
|
|
/* Retrieve the enclosing object pointed to. */
|
2007-08-14 02:31:40 +02:00
|
|
|
|
arg2 = value_at_lazy (enc_type,
|
|
|
|
|
(value_as_address (arg1)
|
|
|
|
|
- value_pointed_to_offset (arg1)));
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
|
2013-10-14 09:36:13 +02:00
|
|
|
|
enc_type = value_type (arg2);
|
2012-02-21 14:48:59 +01:00
|
|
|
|
return readjust_indirect_value_type (arg2, enc_type, base_type, arg1);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Attempt to take contents of a non-pointer value."));
|
2007-08-14 02:31:40 +02:00
|
|
|
|
return 0; /* For lint -- never reached. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 12:30:37 +01:00
|
|
|
|
/* Create a value for an array by allocating space in GDB, copying the
|
|
|
|
|
data into that space, and then setting up an array value.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
The array bounds are set from LOWBOUND and HIGHBOUND, and the array
|
|
|
|
|
is populated from the values passed in ELEMVEC.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
The element type of the array is inherited from the type of the
|
|
|
|
|
first element, and all elements must have the same size (though we
|
2007-08-14 02:31:40 +02:00
|
|
|
|
don't currently enforce any restriction on their types). */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_array (int lowbound, int highbound, struct value **elemvec)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
int nelem;
|
|
|
|
|
int idx;
|
2016-04-12 21:02:57 +02:00
|
|
|
|
ULONGEST typelength;
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *val;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
struct type *arraytype;
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Validate that the bounds are reasonable and that each of the
|
|
|
|
|
elements have the same size. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
nelem = highbound - lowbound + 1;
|
|
|
|
|
if (nelem <= 0)
|
|
|
|
|
{
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("bad array bounds (%d, %d)"), lowbound, highbound);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2015-07-28 17:01:50 +02:00
|
|
|
|
typelength = type_length_units (value_enclosing_type (elemvec[0]));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
for (idx = 1; idx < nelem; idx++)
|
|
|
|
|
{
|
2015-07-28 17:01:50 +02:00
|
|
|
|
if (type_length_units (value_enclosing_type (elemvec[idx]))
|
|
|
|
|
!= typelength)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("array elements must all be the same size"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-02 14:18:46 +02:00
|
|
|
|
arraytype = lookup_array_range_type (value_enclosing_type (elemvec[0]),
|
|
|
|
|
lowbound, highbound);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (!current_language->c_style_arrays)
|
|
|
|
|
{
|
|
|
|
|
val = allocate_value (arraytype);
|
|
|
|
|
for (idx = 0; idx < nelem; idx++)
|
2011-02-14 12:30:37 +01:00
|
|
|
|
value_contents_copy (val, idx * typelength, elemvec[idx], 0,
|
|
|
|
|
typelength);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-21 16:02:38 +01:00
|
|
|
|
/* Allocate space to store the array, and then initialize it by
|
|
|
|
|
copying in each element. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2008-03-21 16:02:38 +01:00
|
|
|
|
val = allocate_value (arraytype);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
for (idx = 0; idx < nelem; idx++)
|
2011-02-14 12:30:37 +01:00
|
|
|
|
value_contents_copy (val, idx * typelength, elemvec[idx], 0, typelength);
|
2008-03-21 16:02:38 +01:00
|
|
|
|
return val;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 00:04:40 +01:00
|
|
|
|
struct value *
|
2015-11-18 16:51:17 +01:00
|
|
|
|
value_cstring (const char *ptr, ssize_t len, struct type *char_type)
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 00:04:40 +01:00
|
|
|
|
{
|
|
|
|
|
struct value *val;
|
|
|
|
|
int lowbound = current_language->string_lower_bound;
|
2012-09-27 10:57:16 +02:00
|
|
|
|
ssize_t highbound = len / TYPE_LENGTH (char_type);
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 00:04:40 +01:00
|
|
|
|
struct type *stringtype
|
2009-07-02 14:18:46 +02:00
|
|
|
|
= lookup_array_range_type (char_type, lowbound, highbound + lowbound - 1);
|
gdb:
2009-03-19 Tom Tromey <tromey@redhat.com>
Julian Brown <julian@codesourcery.com>
PR i18n/7220, PR i18n/7821, PR exp/8815, PR exp/9103,
PR i18n/9401, PR exp/9613:
* NEWS: Update
* value.h (value_typed_string): Declare.
(val_print_string): Update.
* valprint.h (print_char_chars): Update.
* valprint.c (print_char_chars): Add type argument. Update.
(val_print_string): Likewise.
* valops.c (value_typed_string): New function.
* utils.c (host_char_to_target): New function.
(parse_escape): Use host_char_to_target, host_hex_value. Update.
Remove '^' case.
(no_control_char_error): Remove.
* typeprint.c (print_type_scalar): Update.
* scm-valprint.c (scm_scmval_print): Update.
* scm-lang.h (scm_printchar, scm_printstr): Update.
* scm-lang.c (scm_printchar): Add type argument.
(scm_printstr): Likewise.
* printcmd.c (print_formatted): Update.
(print_scalar_formatted): Update.
(printf_command) <wide_string_arg, wide_char_arg>: New constants.
Handle '%lc' and '%ls'.
* parser-defs.h (struct typed_stoken): New type.
(struct stoken_vector): Likewise.
(write_exp_string_vector): Declare.
* parse.c (write_exp_string_vector): New function.
* p-valprint.c (pascal_val_print): Update.
* p-lang.h (is_pascal_string_type, pascal_printchar,
pascal_printstr): Update.
* p-lang.c (is_pascal_string_type): Remove 'char_size' argument.
Add 'char_type' argument.
(pascal_emit_char): Add type argument.
(pascal_printchar): Likewise.
(pascal_printstr): Likewise.
* objc-lang.c (objc_emit_char): Add type argument.
(objc_printchar): Likewise.
(objc_printstr): Likewise.
* macroexp.c (get_character_constant): Handle unicode characters.
Use c_parse_escape.
(get_string_literal): Handle unicode strings. Use
c_parse_escape.
* m2-valprint.c (print_unpacked_pointer): Update.
(m2_print_array_contents): Update.
(m2_val_print): Update.
* m2-lang.c (m2_emit_char): Add type argument.
(m2_printchar): Likewise.
(m2_printstr): Likewise.
* language.h (struct language_defn) <la_printchar>: Add type
argument.
<la_printstr, la_emitchar>: Likewise.
(LA_PRINT_CHAR): Likewise.
(LA_PRINT_STRING): Likewise.
(LA_EMIT_CHAR): Likewise.
* language.c (unk_lang_emit_char): Add type argument.
(unk_lang_printchar): Likewise.
(unk_lang_printstr): Likewise.
* jv-valprint.c (java_val_print): Update.
* jv-lang.c (java_emit_char): Add type argument.
* f-valprint.c (f_val_print): Update.
* f-lang.c (f_emit_char): Add type argument.
(f_printchar): Likewise.
(f_printstr): Likewise.
* expprint.c (print_subexp_standard): Update.
* charset.h (target_wide_charset): Declare.
(c_target_char_has_backslash_escape, c_parse_backslash,
host_char_print_literally, host_char_to_target,
target_char_to_host, target_char_to_control_char): Remove.
(enum transliterations): New type.
(convert_between_encodings): Declare.
(HOST_ESCAPE_CHAR): New define.
(host_letter_to_control_character, host_hex_value): Declare.
(enum wchar_iterate_result): New enum.
(struct wchar_iterator): Declare.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): Declare.
* charset-list.h: New file.
* c-valprint.c (textual_name): New function.
(textual_element_type): Handle wide character types.
(c_val_print): Pass original type to textual_element_type. Handle
wide character types.
(c_value_print): Use textual_element_type. Pass original type of
value to val_print.
* c-lang.h (enum c_string_type): New type.
(c_printchar, c_printstr): Update.
* c-lang.c (classify_type): New function.
(print_wchar): Likewise.
(c_emit_char): Add type argument. Handle wide characters.
(c_printchar): Likewise.
(c_printstr): Add type argument. Handle wide and multibyte
character sets.
(convert_ucn): New function.
(emit_numeric_character): Likewise.
(convert_octal): Likewise.
(convert_hex): Likewise.
(ADVANCE): New macro.
(convert_escape): New function.
(parse_one_string): Likewise.
(evaluate_subexp_c): Likewise.
(exp_descriptor_c): New global.
(c_language_defn): Use exp_descriptor_c.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
(charset_for_string_type): New function.
* c-exp.y (%union): Add 'svec' and 'tsval'.
(CHAR): New token.
(exp): Add CHAR production.
(string_exp): Rewrite.
(exp) <string_exp>: Rewrite.
(tempbuf): Now global.
(tempbuf_init): New global.
(parse_string_or_char): New function.
(yylex) <tempbuf>: Now global.
<tokptr, tempbufindex, tempbufsize, token_string, class_prefix>:
Remove.
Handle 'u', 'U', and 'L' prefixes. Call parse_string_or_char.
(c_parse_escape): New function.
* auxv.c (fprint_target_auxv): Update.
* ada-valprint.c (ada_emit_char): Add type argument.
(ada_printchar): Likewise.
(ada_print_scalar): Update.
(printstr): Add type argument. Update calls to ada_emit_char.
(ada_printstr): Add type argument.
(ada_val_print_array): Update.
(ada_val_print_1): Likewise.
* ada-lang.c (emit_char): Add type argument.
* ada-lang.h (ada_emit_char, ada_printchar, ada_printstr): Add
type arguments.
* gdb_locale.h: Include langinfo.h.
* charset.c (_initialize_charset): Set default host charset from
the locale. Don't register charsets. Add target-wide-charset
commands. Call find_charset_names.
(struct charset, struct translation): Remove.
(GDB_DEFAULT_HOST_CHARSET): Remove.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): New define.
(target_wide_charset_name): New global.
(show_host_charset_name): Handle "auto".
(show_target_wide_charset_name): New function.
(host_charset_enum, target_charset_enum): Remove.
(charset_enum): New global.
(all_charsets, register_charset, lookup_charset, all_translations,
register_translation, lookup_translation): Remove.
(simple_charset, ascii_print_literally, ascii_to_control): Remove.
(iso_8859_print_literally, iso_8859_to_control,
iso_8859_family_charset): Remove.
(ebcdic_print_literally, ebcdic_to_control,
ebcdic_family_charset): Remove.
(struct cached_iconv, check_iconv_cache, cached_iconv_convert,
register_iconv_charsets): Remove.
(target_wide_charset_be_name, target_wide_charset_le_name): New
globals.
(identity_either_char_to_other): Remove.
(set_be_le_names, validate): New functions.
(backslashable, backslashed, represented): Remove.
(default_c_target_char_has_backslash_escape): Remove.
(default_c_parse_backslash, iconv_convert): Remove.
(ascii_to_iso_8859_1_table, ascii_to_ebcdic_us_table,
ascii_to_ibm1047_table, iso_8859_1_to_ascii_table,
iso_8859_1_to_ebcdic_us_table, iso_8859_1_to_ibm1047_table,
ebcdic_us_to_ascii_table, ebcdic_us_to_iso_8859_1_table,
ebcdic_us_to_ibm1047_table, ibm1047_to_ascii_table,
ibm1047_to_iso_8859_1_table, ibm1047_to_ebcdic_us_table): Remove.
(table_convert_char, table_translation, simple_table_translation):
Remove.
(current_host_charset, current_target_charset,
c_target_char_has_backslash_escape_func,
c_target_char_has_backslash_escape_baton): Remove.
(c_parse_backslash_func, c_parse_backslash_baton): Remove.
(host_char_to_target_func, host_char_to_target_baton): Remove.
(target_char_to_host_func, target_char_to_host_baton): Remove.
(cached_iconv_host_to_target, cached_iconv_target_to_host):
Remove.
(lookup_charset_or_error, check_valid_host_charset): Remove.
(set_host_and_target_charsets): Remove.
(set_host_charset, set_target_charset): Remove.
(set_host_charset_sfunc, set_target_charset_sfunc): Rewrite.
(set_target_wide_charset_sfunc): New function.
(show_charset): Print target wide character set.
(host_charset, target_charset): Rewrite.
(target_wide_charset): New function.
(c_target_char_has_backslash_escape): Remove.
(c_parse_backslash): Remove.
(host_letter_to_control_character): New function.
(host_char_print_literally): Remove.
(host_hex_value): New function.
(target_char_to_control_char): Remove.
(cleanup_iconv): New function.
(convert_between_encodings): New function.
(target_char_to_host): Remove.
(struct wchar_iterator): Define.
(make_wchar_iterator, make_cleanup_wchar_iterator, wchar_iterator,
wchar_push_back): New functions.
(do_cleanup_iterator): New function.
(char_ptr): New typedef.
(charsets): New global.
(add_one, find_charset_names): New functions.
(default_charset_names): New global.
(auto_host_charset_name): Likewise.
* aclocal.m4, config.in, configure: Rebuild.
* configure.ac: Call AM_LANGINFO_CODESET.
(GDB_DEFAULT_HOST_CHARSET): Default to UTF-8.
(AM_ICONV): Invoke earlier.
* acinclude.m4: Include codeset.m4. Subst LIBICONV_INCLUDE and
LIBICONV_LIBDIR. Check for libiconv in build tree.
* Makefile.in (LIBICONV_LIBDIR, LIBICONV_INCLUDE): New macros.
(INTERNAL_CFLAGS_BASE): Add LIBICONV_INCLUDE.
(INTERNAL_LDFLAGS): Add LIBICONV_LIBDIR.
* gdb_obstack.h (obstack_grow_wstr): New define.
* gdb_wchar.h: New file.
* defs.h: Include it.
gdb/testsuite:
* gdb.base/store.exp: Update for change to escape output.
* gdb.base/callfuncs.exp (fetch_all_registers): Update for change
to escape output.
* gdb.base/pointers.exp: Update for change to escape output.
* gdb.base/long_long.exp (gdb_test_long_long): Update for change
to escape output.
* gdb.base/constvars.exp (do_constvar_tests): Update for change to
escape output.
* gdb.base/call-rt-st.exp (print_struct_call): Update for change
to escape output.
* gdb.cp/ref-types.exp (gdb_start_again): Update for change to
escape output.
* gdb.base/setvar.exp: Update for change to escape output.
* lib/gdb.exp (default_gdb_start): Set LC_CTYPE to C.
* gdb.base/printcmds.exp (test_print_all_chars): Update for change
to escape output.
(test_print_string_constants): Likewise.
* gdb.base/charset.exp (valid_host_charset): Check size of
wchar_t. Handle UCS-2 and UCS-4. Add tests for wide and unicode
cases. Handle "auto"-related output.
* gdb.base/charset.c (char16_t, char32_t): New typedefs.
(uvar, Uvar): New globals.
gdb/doc:
* gdb.texinfo (Character Sets): Remove obsolete text. Document
set target-wide-charset.
(Requirements): Mention iconv.
2009-03-21 00:04:40 +01:00
|
|
|
|
|
|
|
|
|
val = allocate_value (stringtype);
|
|
|
|
|
memcpy (value_contents_raw (val), ptr, len);
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Create a value for a string constant by allocating space in the
|
|
|
|
|
inferior, copying the data into that space, and returning the
|
|
|
|
|
address with type TYPE_CODE_STRING. PTR points to the string
|
|
|
|
|
constant data; LEN is number of characters.
|
|
|
|
|
|
|
|
|
|
Note that string types are like array of char types with a lower
|
|
|
|
|
bound of zero and an upper bound of LEN - 1. Also note that the
|
|
|
|
|
string may contain embedded null bytes. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2015-11-18 17:20:22 +01:00
|
|
|
|
value_string (const char *ptr, ssize_t len, struct type *char_type)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *val;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int lowbound = current_language->string_lower_bound;
|
2012-09-27 10:57:16 +02:00
|
|
|
|
ssize_t highbound = len / TYPE_LENGTH (char_type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
struct type *stringtype
|
2009-07-02 14:18:46 +02:00
|
|
|
|
= lookup_string_range_type (char_type, lowbound, highbound + lowbound - 1);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2009-06-17 20:47:35 +02:00
|
|
|
|
val = allocate_value (stringtype);
|
|
|
|
|
memcpy (value_contents_raw (val), ptr, len);
|
|
|
|
|
return val;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* See if we can pass arguments in T2 to a function which takes
|
|
|
|
|
arguments of types T1. T1 is a list of NARGS arguments, and T2 is
|
|
|
|
|
a NULL-terminated vector. If some arguments need coercion of some
|
|
|
|
|
sort, then the coerced values are written into T2. Return value is
|
|
|
|
|
0 if the arguments could be matched, or the position at which they
|
|
|
|
|
differ if not.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
STATICP is nonzero if the T1 argument list came from a static
|
|
|
|
|
member function. T2 will still include the ``this'' pointer, but
|
|
|
|
|
it will be skipped.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
For non-static member functions, we ignore the first argument,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
which is the type of the instance variable. This is because we
|
|
|
|
|
want to handle calls with objects from derived classes. This is
|
|
|
|
|
not entirely correct: we should actually check to make sure that a
|
1999-04-16 03:35:26 +02:00
|
|
|
|
requested operation is type secure, shouldn't we? FIXME. */
|
|
|
|
|
|
|
|
|
|
static int
|
2002-06-14 16:34:26 +02:00
|
|
|
|
typecmp (int staticp, int varargs, int nargs,
|
|
|
|
|
struct field t1[], struct value *t2[])
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (t2 == 0)
|
2007-08-14 02:31:40 +02:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
|
|
|
|
_("typecmp: no argument list"));
|
2002-06-14 16:34:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Skip ``this'' argument if applicable. T2 will always include
|
|
|
|
|
THIS. */
|
2002-05-12 04:20:38 +02:00
|
|
|
|
if (staticp)
|
2002-06-14 16:34:26 +02:00
|
|
|
|
t2 ++;
|
|
|
|
|
|
|
|
|
|
for (i = 0;
|
|
|
|
|
(i < nargs) && TYPE_CODE (t1[i].type) != TYPE_CODE_VOID;
|
|
|
|
|
i++)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
1999-07-07 22:19:36 +02:00
|
|
|
|
struct type *tt1, *tt2;
|
2002-06-14 16:34:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (!t2[i])
|
|
|
|
|
return i + 1;
|
2002-06-14 16:34:26 +02:00
|
|
|
|
|
|
|
|
|
tt1 = check_typedef (t1[i].type);
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
tt2 = check_typedef (value_type (t2[i]));
|
2002-06-14 16:34:26 +02:00
|
|
|
|
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
if (TYPE_IS_REFERENCE (tt1)
|
2014-11-01 04:20:48 +01:00
|
|
|
|
/* We should be doing hairy argument matching, as below. */
|
2011-01-05 23:22:53 +01:00
|
|
|
|
&& (TYPE_CODE (check_typedef (TYPE_TARGET_TYPE (tt1)))
|
|
|
|
|
== TYPE_CODE (tt2)))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
if (TYPE_CODE (tt2) == TYPE_CODE_ARRAY)
|
|
|
|
|
t2[i] = value_coerce_array (t2[i]);
|
|
|
|
|
else
|
2017-03-20 21:47:41 +01:00
|
|
|
|
t2[i] = value_ref (t2[i], TYPE_CODE (tt1));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-15 19:40:30 +02:00
|
|
|
|
/* djb - 20000715 - Until the new type structure is in the
|
|
|
|
|
place, and we can attempt things like implicit conversions,
|
|
|
|
|
we need to do this so you can take something like a map<const
|
|
|
|
|
char *>, and properly access map["hello"], because the
|
|
|
|
|
argument to [] will be a reference to a pointer to a char,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
and the argument will be a pointer to a char. */
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
while (TYPE_IS_REFERENCE (tt1) || TYPE_CODE (tt1) == TYPE_CODE_PTR)
|
2000-07-15 19:40:30 +02:00
|
|
|
|
{
|
|
|
|
|
tt1 = check_typedef( TYPE_TARGET_TYPE(tt1) );
|
|
|
|
|
}
|
2007-08-14 02:31:40 +02:00
|
|
|
|
while (TYPE_CODE(tt2) == TYPE_CODE_ARRAY
|
|
|
|
|
|| TYPE_CODE(tt2) == TYPE_CODE_PTR
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
|| TYPE_IS_REFERENCE (tt2))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2007-08-14 02:31:40 +02:00
|
|
|
|
tt2 = check_typedef (TYPE_TARGET_TYPE(tt2));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (TYPE_CODE (tt1) == TYPE_CODE (tt2))
|
|
|
|
|
continue;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Array to pointer is a `trivial conversion' according to the
|
|
|
|
|
ARM. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* We should be doing much hairier argument matching (see
|
|
|
|
|
section 13.2 of the ARM), but as a quick kludge, just check
|
|
|
|
|
for the same type code. */
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
if (TYPE_CODE (t1[i].type) != TYPE_CODE (value_type (t2[i])))
|
1999-07-07 22:19:36 +02:00
|
|
|
|
return i + 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2002-06-14 16:34:26 +02:00
|
|
|
|
if (varargs || t2[i] == NULL)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
return 0;
|
2002-06-14 16:34:26 +02:00
|
|
|
|
return i + 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-21 21:47:54 +02:00
|
|
|
|
/* Helper class for do_search_struct_field that updates *RESULT_PTR
|
|
|
|
|
and *LAST_BOFFSET, and possibly throws an exception if the field
|
|
|
|
|
search has yielded ambiguous results. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2012-05-21 21:47:54 +02:00
|
|
|
|
static void
|
|
|
|
|
update_search_result (struct value **result_ptr, struct value *v,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST *last_boffset, LONGEST boffset,
|
2012-05-21 21:47:54 +02:00
|
|
|
|
const char *name, struct type *type)
|
|
|
|
|
{
|
|
|
|
|
if (v != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (*result_ptr != NULL
|
|
|
|
|
/* The result is not ambiguous if all the classes that are
|
|
|
|
|
found occupy the same space. */
|
|
|
|
|
&& *last_boffset != boffset)
|
|
|
|
|
error (_("base class '%s' is ambiguous in type '%s'"),
|
|
|
|
|
name, TYPE_SAFE_NAME (type));
|
|
|
|
|
*result_ptr = v;
|
|
|
|
|
*last_boffset = boffset;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2012-05-21 21:47:54 +02:00
|
|
|
|
/* A helper for search_struct_field. This does all the work; most
|
|
|
|
|
arguments are as passed to search_struct_field. The result is
|
|
|
|
|
stored in *RESULT_PTR, which must be initialized to NULL.
|
|
|
|
|
OUTERMOST_TYPE is the type of the initial type passed to
|
|
|
|
|
search_struct_field; this is used for error reporting when the
|
|
|
|
|
lookup is ambiguous. */
|
|
|
|
|
|
|
|
|
|
static void
|
2016-04-12 21:02:57 +02:00
|
|
|
|
do_search_struct_field (const char *name, struct value *arg1, LONGEST offset,
|
2012-05-21 21:47:54 +02:00
|
|
|
|
struct type *type, int looking_for_baseclass,
|
|
|
|
|
struct value **result_ptr,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST *last_boffset,
|
2012-05-21 21:47:54 +02:00
|
|
|
|
struct type *outermost_type)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2010-02-02 17:45:17 +01:00
|
|
|
|
int nbases;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2015-07-06 22:05:06 +02:00
|
|
|
|
type = check_typedef (type);
|
2010-02-02 17:45:17 +01:00
|
|
|
|
nbases = TYPE_N_BASECLASSES (type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (!looking_for_baseclass)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--)
|
|
|
|
|
{
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
|
|
|
|
const char *t_field_name = TYPE_FIELD_NAME (type, i);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2000-03-13 11:01:23 +01:00
|
|
|
|
if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *v;
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
Convert static_kind into loc_kind enum.
* gdbtypes.h (enum field_loc_kind): New.
(union field_location): New field dwarf_block.
(struct field): Rename static_kind as loc_kind.
(FIELD_STATIC_KIND): Rename to ...
(FIELD_LOC_KIND): ... here.
(TYPE_FIELD_STATIC_KIND): Rename to ...
(TYPE_FIELD_LOC_KIND): ... here and use there now new FIELD_LOC_KIND.
(TYPE_FIELD_STATIC_HAS_ADDR): Remove.
(TYPE_FIELD_STATIC): Remove.
(TYPE_FIELD_BITPOS): Reformat.
(SET_FIELD_BITPOS): New.
(FIELD_PHYSADDR): Rename to ...
(FIELD_STATIC_PHYSADDR): ... here.
(TYPE_FIELD_STATIC_PHYSADDR): Follow the FIELD_PHYSADDR rename.
(SET_FIELD_PHYSADDR): Use new FIELD_LOC_KIND.
(FIELD_PHYSNAME): Rename to ...
(FIELD_STATIC_PHYSNAME): ... here.
(TYPE_FIELD_STATIC_PHYSNAME): Follow the FIELD_PHYSNAME rename.
(SET_FIELD_PHYSNAME): Use new FIELD_LOC_KIND.
(FIELD_DWARF_BLOCK, TYPE_FIELD_DWARF_BLOCK, SET_FIELD_DWARF_BLOCK): New.
(field_is_static): New declaration.
* gdbtypes.c (field_is_static): New function.
(copy_type_recursive): Update throughout.
* amd64-tdep.c, c-typeprint.c, coffread.c, cp-valprint.c, dwarf2read.c,
eval.c, jv-typeprint.c, jv-valprint.c, mdebugread.c, p-typeprint.c,
p-valprint.c, valops.c, value.c, varobj.c: Update throughout.
2008-10-08 14:49:13 +02:00
|
|
|
|
if (field_is_static (&TYPE_FIELD (type, i)))
|
2013-10-25 12:37:13 +02:00
|
|
|
|
v = value_static_field (type, i);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
2012-05-21 21:47:54 +02:00
|
|
|
|
v = value_primitive_field (arg1, offset, i, type);
|
|
|
|
|
*result_ptr = v;
|
|
|
|
|
return;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (t_field_name
|
2014-12-03 01:15:53 +01:00
|
|
|
|
&& t_field_name[0] == '\0')
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
struct type *field_type = TYPE_FIELD_TYPE (type, i);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (TYPE_CODE (field_type) == TYPE_CODE_UNION
|
|
|
|
|
|| TYPE_CODE (field_type) == TYPE_CODE_STRUCT)
|
|
|
|
|
{
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Look for a match through the fields of an anonymous
|
|
|
|
|
union, or anonymous struct. C++ provides anonymous
|
|
|
|
|
unions.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2003-01-02 Andrew Cagney <ac131313@redhat.com>
* valarith.c (value_binop): Delete obsolete code and comments.
* configure.host: Ditto.
* buildsym.h (make_blockvector): Ditto.
* buildsym.c (make_blockvector): Ditto.
* defs.h (enum language): Ditto.
(chill_demangle): Ditto.
* elfread.c (elf_symtab_read): Ditto.
* dwarfread.c (CHILL_PRODUCER): Ditto.
(set_cu_language): Ditto.
(handle_producer): Ditto.
* expprint.c (print_subexp): Ditto.
* gdbtypes.c (chill_varying_type): Ditto.
* gdbtypes.h (builtin_type_chill_bool): Ditto.
(builtin_type_chill_char, builtin_type_chill_long): Ditto.
(builtin_type_chill_ulong, builtin_type_chill_real): Ditto.
(chill_varying_type): Ditto.
* language.h (_LANG_chill): Ditto.
* language.c (binop_result_type, integral_type): Ditto.
(character_type, string_type, structured_type): Ditto.
(lang_bool_type, binop_type_check): Ditto.
* stabsread.h (os9k_stabs): Ditto.
* stabsread.c (os9k_type_vector, dbx_lookup_type): Ditto.
(define_symbol, read_type, read_struct_fields): Ditto.
(read_array_type, read_enum_type, read_huge_number): Ditto.
(read_range_type, start_stabs): Ditto.
* symfile.c (init_filename_language_table): Ditto.
(add_psymbol_with_dem_name_to_list): Ditto.
* symtab.c (symbol_init_language_specific): Ditto.
(symbol_init_demangled_name, symbol_demangled_name): Ditto.
* symtab.h (struct general_symbol_info): Ditto.
(SYMBOL_CHILL_DEMANGLED_NAME): Ditto.
* typeprint.c (typedef_print): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* valops.c (value_cast, search_struct_field, value_slice): Delete
obsolete code.
(varying_to_slice): Delete function.
* value.h (COERCE_VARYING_ARRAY): Delete obsolete macro contents.
(varying_to_slice): Delete declaration.
* MAINTAINERS: Update.
2003-01-02 15:27:27 +01:00
|
|
|
|
In the GNU Chill (now deleted from GDB)
|
|
|
|
|
implementation of variant record types, each
|
|
|
|
|
<alternative field> has an (anonymous) union type,
|
|
|
|
|
each member of the union represents a <variant
|
|
|
|
|
alternative>. Each <variant alternative> is
|
|
|
|
|
represented as a struct, with a member for each
|
|
|
|
|
<variant field>. */
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2012-05-21 21:47:54 +02:00
|
|
|
|
struct value *v = NULL;
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST new_offset = offset;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-08-01 Andrew Cagney <cagney@redhat.com>
* NEWS: Menion that CHILL has been made obsolete.
* gdbtypes.c (chill_varying_type): Make chill references obsolete.
* gdbserver/Makefile.in: Ditto.
* stabsread.c (read_range_type): Ditto.
* gdbtypes.h: Ditto.
* language.c (binop_type_check): Ditto.
(binop_result_type): Ditto.
(integral_type): Ditto.
(character_type): Ditto.
(string_type): Ditto.
(boolean_type): Ditto.
(structured_type): Ditto.
(lang_bool_type): Ditto.
(binop_type_check): Ditto.
* language.h (_LANG_chill): Ditto.
* dwarfread.c (set_cu_language): Ditto.
* dwarfread.c (CHILL_PRODUCER): Ditto.
* dwarfread.c (handle_producer): Ditto.
* expression.h (enum exp_opcode): Ditto.
* eval.c: Ditto for comments.
* typeprint.c (typedef_print) [_LANG_chill]: Ditto.
* expprint.c (print_subexp): Ditto.
(print_subexp): Ditto.
* valops.c (value_cast): Ditto.
(search_struct_field): Ditto.
* value.h (COERCE_VARYING_ARRAY): Ditto.
* symfile.c (init_filename_language_table): Ditto.
(add_psymbol_with_dem_name_to_list): Ditto.
* valarith.c (value_binop): Ditto.
(value_neg): Ditto.
* valops.c (value_slice): Ditto.
* symtab.h (union language_specific): Ditto.
(SYMBOL_INIT_LANGUAGE_SPECIFIC): Ditto.
(SYMBOL_DEMANGLED_NAME): Ditto.
(SYMBOL_CHILL_DEMANGLED_NAME): Ditto.
* defs.h (enum language): Ditto.
* symtab.c (got_symtab): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* ch-typeprint.c: Make file obsolete.
* ch-valprint.c: Make file obsolete.
* ch-lang.h: Make file obsolete.
* ch-exp.c: Make file obsolete.
* ch-lang.c: Make file obsolete.
* Makefile.in (FLAGS_TO_PASS): Do not pass CHILL or CHILLFLAGS or
CHILL_LIB.
(TARGET_FLAGS_TO_PASS): Ditto.
(CHILLFLAGS): Obsolete.
(CHILL): Obsolete.
(CHILL_FOR_TARGET): Obsolete.
(CHILL_LIB): Obsolete.
(SFILES): Remove ch-exp.c, ch-lang.c, ch-typeprint.c and
ch-valprint.c.
(HFILES_NO_SRCDIR): Remove ch-lang.h.
(COMMON_OBS): Remove ch-valprint.o, ch-typeprint.o, ch-exp.o and
ch-lang.o.
(ch-exp.o, ch-lang.o, ch-typeprint.o, ch-valprint.o): Delete
targets.
2002-08-01 Andrew Cagney <cagney@redhat.com>
* stabs.texinfo, gdb.texinfo, gdbint.texinfo: Obsolete references
to CHILL.
2002-08-01 Andrew Cagney <cagney@redhat.com>
* Makefile.in (TARGET_FLAGS_TO_PASS): Remove CHILLFLAGS, CHILL,
CHILL_FOR_TARGET and CHILL_LIB.
* configure.in (configdirs): Remove gdb.chill.
* configure: Regenerate.
* lib/gdb.exp: Obsolete references to chill.
* gdb.fortran/types.exp: Ditto.
* gdb.fortran/exprs.exp: Ditto.
2002-08-01 19:18:35 +02:00
|
|
|
|
/* This is pretty gross. In G++, the offset in an
|
|
|
|
|
anonymous union is relative to the beginning of the
|
2003-01-02 Andrew Cagney <ac131313@redhat.com>
* valarith.c (value_binop): Delete obsolete code and comments.
* configure.host: Ditto.
* buildsym.h (make_blockvector): Ditto.
* buildsym.c (make_blockvector): Ditto.
* defs.h (enum language): Ditto.
(chill_demangle): Ditto.
* elfread.c (elf_symtab_read): Ditto.
* dwarfread.c (CHILL_PRODUCER): Ditto.
(set_cu_language): Ditto.
(handle_producer): Ditto.
* expprint.c (print_subexp): Ditto.
* gdbtypes.c (chill_varying_type): Ditto.
* gdbtypes.h (builtin_type_chill_bool): Ditto.
(builtin_type_chill_char, builtin_type_chill_long): Ditto.
(builtin_type_chill_ulong, builtin_type_chill_real): Ditto.
(chill_varying_type): Ditto.
* language.h (_LANG_chill): Ditto.
* language.c (binop_result_type, integral_type): Ditto.
(character_type, string_type, structured_type): Ditto.
(lang_bool_type, binop_type_check): Ditto.
* stabsread.h (os9k_stabs): Ditto.
* stabsread.c (os9k_type_vector, dbx_lookup_type): Ditto.
(define_symbol, read_type, read_struct_fields): Ditto.
(read_array_type, read_enum_type, read_huge_number): Ditto.
(read_range_type, start_stabs): Ditto.
* symfile.c (init_filename_language_table): Ditto.
(add_psymbol_with_dem_name_to_list): Ditto.
* symtab.c (symbol_init_language_specific): Ditto.
(symbol_init_demangled_name, symbol_demangled_name): Ditto.
* symtab.h (struct general_symbol_info): Ditto.
(SYMBOL_CHILL_DEMANGLED_NAME): Ditto.
* typeprint.c (typedef_print): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* valops.c (value_cast, search_struct_field, value_slice): Delete
obsolete code.
(varying_to_slice): Delete function.
* value.h (COERCE_VARYING_ARRAY): Delete obsolete macro contents.
(varying_to_slice): Delete declaration.
* MAINTAINERS: Update.
2003-01-02 15:27:27 +01:00
|
|
|
|
enclosing struct. In the GNU Chill (now deleted
|
|
|
|
|
from GDB) implementation of variant records, the
|
|
|
|
|
bitpos is zero in an anonymous union field, so we
|
2007-08-14 02:31:40 +02:00
|
|
|
|
have to add the offset of the union here. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (TYPE_CODE (field_type) == TYPE_CODE_STRUCT
|
|
|
|
|
|| (TYPE_NFIELDS (field_type) > 0
|
|
|
|
|
&& TYPE_FIELD_BITPOS (field_type, 0) == 0))
|
|
|
|
|
new_offset += TYPE_FIELD_BITPOS (type, i) / 8;
|
|
|
|
|
|
2012-05-21 21:47:54 +02:00
|
|
|
|
do_search_struct_field (name, arg1, new_offset,
|
|
|
|
|
field_type,
|
|
|
|
|
looking_for_baseclass, &v,
|
|
|
|
|
last_boffset,
|
|
|
|
|
outermost_type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (v)
|
2012-05-21 21:47:54 +02:00
|
|
|
|
{
|
|
|
|
|
*result_ptr = v;
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
for (i = 0; i < nbases; i++)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2012-05-21 21:47:54 +02:00
|
|
|
|
struct value *v = NULL;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
struct type *basetype = check_typedef (TYPE_BASECLASS (type, i));
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* If we are looking for baseclasses, this is what we get when
|
|
|
|
|
we hit them. But it could happen that the base part's member
|
|
|
|
|
name is not yet filled in. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int found_baseclass = (looking_for_baseclass
|
|
|
|
|
&& TYPE_BASECLASS_NAME (type, i) != NULL
|
2007-08-14 02:31:40 +02:00
|
|
|
|
&& (strcmp_iw (name,
|
|
|
|
|
TYPE_BASECLASS_NAME (type,
|
|
|
|
|
i)) == 0));
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST boffset = value_embedded_offset (arg1) + offset;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (BASETYPE_VIA_VIRTUAL (type, i))
|
|
|
|
|
{
|
2008-11-26 17:27:28 +01:00
|
|
|
|
struct value *v2;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
boffset = baseclass_offset (type, i,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
value_contents_for_printing (arg1),
|
|
|
|
|
value_embedded_offset (arg1) + offset,
|
|
|
|
|
value_address (arg1),
|
|
|
|
|
arg1);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* The virtual base class pointer might have been clobbered
|
2011-01-12 02:23:29 +01:00
|
|
|
|
by the user program. Make sure that it still points to a
|
2007-08-14 02:31:40 +02:00
|
|
|
|
valid memory location. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-02-04 22:04:30 +01:00
|
|
|
|
boffset += value_embedded_offset (arg1) + offset;
|
|
|
|
|
if (boffset < 0
|
|
|
|
|
|| boffset >= TYPE_LENGTH (value_enclosing_type (arg1)))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
CORE_ADDR base_addr;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2009-05-28 02:53:52 +02:00
|
|
|
|
base_addr = value_address (arg1) + boffset;
|
2013-08-29 14:25:03 +02:00
|
|
|
|
v2 = value_at_lazy (basetype, base_addr);
|
2007-08-14 02:31:40 +02:00
|
|
|
|
if (target_read_memory (base_addr,
|
|
|
|
|
value_contents_raw (v2),
|
2013-08-29 16:25:22 +02:00
|
|
|
|
TYPE_LENGTH (value_type (v2))) != 0)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("virtual baseclass botch"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-02-04 22:04:30 +01:00
|
|
|
|
v2 = value_copy (arg1);
|
|
|
|
|
deprecated_set_value_type (v2, basetype);
|
|
|
|
|
set_value_embedded_offset (v2, boffset);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found_baseclass)
|
2012-05-21 21:47:54 +02:00
|
|
|
|
v = v2;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
do_search_struct_field (name, v2, 0,
|
|
|
|
|
TYPE_BASECLASS (type, i),
|
|
|
|
|
looking_for_baseclass,
|
|
|
|
|
result_ptr, last_boffset,
|
|
|
|
|
outermost_type);
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
else if (found_baseclass)
|
|
|
|
|
v = value_primitive_field (arg1, offset, i, type);
|
|
|
|
|
else
|
2012-05-21 21:47:54 +02:00
|
|
|
|
{
|
|
|
|
|
do_search_struct_field (name, arg1,
|
|
|
|
|
offset + TYPE_BASECLASS_BITPOS (type,
|
|
|
|
|
i) / 8,
|
|
|
|
|
basetype, looking_for_baseclass,
|
|
|
|
|
result_ptr, last_boffset,
|
|
|
|
|
outermost_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_search_result (result_ptr, v, last_boffset,
|
|
|
|
|
boffset, name, outermost_type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2012-05-21 21:47:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function used by value_struct_elt to recurse through
|
2015-07-06 19:10:56 +02:00
|
|
|
|
baseclasses. Look for a field NAME in ARG1. Search in it assuming
|
|
|
|
|
it has (class) type TYPE. If found, return value, else return NULL.
|
2012-05-21 21:47:54 +02:00
|
|
|
|
|
|
|
|
|
If LOOKING_FOR_BASECLASS, then instead of looking for struct
|
|
|
|
|
fields, look for a baseclass named NAME. */
|
|
|
|
|
|
|
|
|
|
static struct value *
|
2015-07-06 19:10:56 +02:00
|
|
|
|
search_struct_field (const char *name, struct value *arg1,
|
2012-05-21 21:47:54 +02:00
|
|
|
|
struct type *type, int looking_for_baseclass)
|
|
|
|
|
{
|
|
|
|
|
struct value *result = NULL;
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST boffset = 0;
|
2012-05-21 21:47:54 +02:00
|
|
|
|
|
2015-07-06 19:10:56 +02:00
|
|
|
|
do_search_struct_field (name, arg1, 0, type, looking_for_baseclass,
|
2012-05-21 21:47:54 +02:00
|
|
|
|
&result, &boffset, type);
|
|
|
|
|
return result;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Helper function used by value_struct_elt to recurse through
|
2011-01-12 02:23:29 +01:00
|
|
|
|
baseclasses. Look for a field NAME in ARG1. Adjust the address of
|
2007-08-14 02:31:40 +02:00
|
|
|
|
ARG1 by OFFSET bytes, and search in it assuming it has (class) type
|
|
|
|
|
TYPE.
|
|
|
|
|
|
|
|
|
|
If found, return value, else if name matched and args not return
|
|
|
|
|
(value) -1, else return NULL. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
static struct value *
|
2010-02-08 21:55:43 +01:00
|
|
|
|
search_struct_method (const char *name, struct value **arg1p,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
struct value **args, LONGEST offset,
|
2003-09-16 Andrew Cagney <cagney@redhat.com>
* buildsym.c: Remove more occurances of "register".
* coffread.c, dbxread.c, dcache.c, dwarf2read.c: Ditto.
* environ.c, eval.c, f-valprint.c, findvar.c: Ditto.
* gdbtypes.c, gnu-v2-abi.c, h8300-tdep.c, hppa-tdep.c: Ditto.
* infcmd.c, mdebugread.c, minsyms.c, mips-tdep.c: Ditto.
* printcmd.c, remote-vx.c, sh-stub.c, sh-tdep.c: Ditto.
* sh64-tdep.c, source.c, stabsread.c, stack.c: Ditto.
* standalone.c, symfile.c, symmisc.c, symtab.c: Ditto.
* utils.c, valops.c, values.c, xcoffread.c: Ditto.
2003-09-16 20:56:35 +02:00
|
|
|
|
int *static_memfuncp, struct type *type)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *v;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int name_matched = 0;
|
|
|
|
|
char dem_opname[64];
|
|
|
|
|
|
2015-07-06 22:05:06 +02:00
|
|
|
|
type = check_typedef (type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--)
|
|
|
|
|
{
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
|
|
|
|
const char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2011-01-12 02:23:29 +01:00
|
|
|
|
/* FIXME! May need to check for ARM demangling here. */
|
2015-03-06 10:42:06 +01:00
|
|
|
|
if (startswith (t_field_name, "__") ||
|
|
|
|
|
startswith (t_field_name, "op") ||
|
|
|
|
|
startswith (t_field_name, "type"))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (cplus_demangle_opname (t_field_name, dem_opname, DMGL_ANSI))
|
|
|
|
|
t_field_name = dem_opname;
|
|
|
|
|
else if (cplus_demangle_opname (t_field_name, dem_opname, 0))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
t_field_name = dem_opname;
|
|
|
|
|
}
|
2000-03-13 11:01:23 +01:00
|
|
|
|
if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
int j = TYPE_FN_FIELDLIST_LENGTH (type, i) - 1;
|
|
|
|
|
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
|
|
|
|
|
|
2010-05-17 20:48:52 +02:00
|
|
|
|
name_matched = 1;
|
2002-09-14 04:09:39 +02:00
|
|
|
|
check_stub_method_group (type, i);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (j > 0 && args == 0)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("cannot resolve overloaded method "
|
|
|
|
|
"`%s': no arguments supplied"), name);
|
2002-02-04 03:14:46 +01:00
|
|
|
|
else if (j == 0 && args == 0)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-02-04 03:14:46 +01:00
|
|
|
|
v = value_fn_field (arg1p, f, j, type, offset);
|
|
|
|
|
if (v != NULL)
|
|
|
|
|
return v;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2002-02-04 03:14:46 +01:00
|
|
|
|
else
|
|
|
|
|
while (j >= 0)
|
|
|
|
|
{
|
|
|
|
|
if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j),
|
2002-06-14 16:34:26 +02:00
|
|
|
|
TYPE_VARARGS (TYPE_FN_FIELD_TYPE (f, j)),
|
|
|
|
|
TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, j)),
|
2002-02-04 03:14:46 +01:00
|
|
|
|
TYPE_FN_FIELD_ARGS (f, j), args))
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
|
2007-08-14 02:31:40 +02:00
|
|
|
|
return value_virtual_fn_field (arg1p, f, j,
|
|
|
|
|
type, offset);
|
|
|
|
|
if (TYPE_FN_FIELD_STATIC_P (f, j)
|
|
|
|
|
&& static_memfuncp)
|
2002-02-04 03:14:46 +01:00
|
|
|
|
*static_memfuncp = 1;
|
|
|
|
|
v = value_fn_field (arg1p, f, j, type, offset);
|
|
|
|
|
if (v != NULL)
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
j--;
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
|
|
|
|
|
{
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST base_offset;
|
|
|
|
|
LONGEST this_offset;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (BASETYPE_VIA_VIRTUAL (type, i))
|
|
|
|
|
{
|
* gdbtypes.h (struct cplus_struct_type): Remove runtime_ptr member.
(TYPE_RUNTIME_PTR, TYPE_VTABLE, TYPE_HAS_VTABLE,
TYPE_PRIMARY_BASE, TYPE_VIRTUAL_BASE_LIST): Remove macros.
(HP_ACC_VFUNC_START, HP_ACC_VBASE_START, HP_ACC_TYPEINFO_OFFSET,
HP_ACC_TOP_OFFSET_OFFSET): Likewise.
(has_vtable, primary_base_class, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove prototypes.
* gdbtypes.c (has_vtable, primary_base_class, current_vbase_list,
virtual_base_list_aux, virtual_base_list, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove.
* cp-valprint.c (cp_print_hpacc_virtual_table_entries): Remove.
(hpacc_vtbl_ptr_name, hpacc_vtbl_ptr_type_name): Remove.
(cp_print_value_fields): Remove support for HP aCC vtables.
(cp_print_value): Likewise.
* c-typeprint.c (c_type_print_base): Likewise.
* value.h (find_rt_vbase_offset): Remove prototype.
* valops.c (find_rt_vbase_offset): Remove.
(search_struct_method): Remove support for HP aCC vtables.
(find_method_list): Likewise.
2007-11-02 20:35:19 +01:00
|
|
|
|
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
|
2011-02-14 12:35:45 +01:00
|
|
|
|
struct value *base_val;
|
* gdbtypes.h (struct cplus_struct_type): Remove runtime_ptr member.
(TYPE_RUNTIME_PTR, TYPE_VTABLE, TYPE_HAS_VTABLE,
TYPE_PRIMARY_BASE, TYPE_VIRTUAL_BASE_LIST): Remove macros.
(HP_ACC_VFUNC_START, HP_ACC_VBASE_START, HP_ACC_TYPEINFO_OFFSET,
HP_ACC_TOP_OFFSET_OFFSET): Likewise.
(has_vtable, primary_base_class, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove prototypes.
* gdbtypes.c (has_vtable, primary_base_class, current_vbase_list,
virtual_base_list_aux, virtual_base_list, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove.
* cp-valprint.c (cp_print_hpacc_virtual_table_entries): Remove.
(hpacc_vtbl_ptr_name, hpacc_vtbl_ptr_type_name): Remove.
(cp_print_value_fields): Remove support for HP aCC vtables.
(cp_print_value): Likewise.
* c-typeprint.c (c_type_print_base): Likewise.
* value.h (find_rt_vbase_offset): Remove prototype.
* valops.c (find_rt_vbase_offset): Remove.
(search_struct_method): Remove support for HP aCC vtables.
(find_method_list): Likewise.
2007-11-02 20:35:19 +01:00
|
|
|
|
const gdb_byte *base_valaddr;
|
|
|
|
|
|
|
|
|
|
/* The virtual base class pointer might have been
|
2011-01-12 02:23:29 +01:00
|
|
|
|
clobbered by the user program. Make sure that it
|
2014-11-01 04:20:48 +01:00
|
|
|
|
still points to a valid memory location. */
|
* gdbtypes.h (struct cplus_struct_type): Remove runtime_ptr member.
(TYPE_RUNTIME_PTR, TYPE_VTABLE, TYPE_HAS_VTABLE,
TYPE_PRIMARY_BASE, TYPE_VIRTUAL_BASE_LIST): Remove macros.
(HP_ACC_VFUNC_START, HP_ACC_VBASE_START, HP_ACC_TYPEINFO_OFFSET,
HP_ACC_TOP_OFFSET_OFFSET): Likewise.
(has_vtable, primary_base_class, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove prototypes.
* gdbtypes.c (has_vtable, primary_base_class, current_vbase_list,
virtual_base_list_aux, virtual_base_list, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove.
* cp-valprint.c (cp_print_hpacc_virtual_table_entries): Remove.
(hpacc_vtbl_ptr_name, hpacc_vtbl_ptr_type_name): Remove.
(cp_print_value_fields): Remove support for HP aCC vtables.
(cp_print_value): Likewise.
* c-typeprint.c (c_type_print_base): Likewise.
* value.h (find_rt_vbase_offset): Remove prototype.
* valops.c (find_rt_vbase_offset): Remove.
(search_struct_method): Remove support for HP aCC vtables.
(find_method_list): Likewise.
2007-11-02 20:35:19 +01:00
|
|
|
|
|
|
|
|
|
if (offset < 0 || offset >= TYPE_LENGTH (type))
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
2012-07-23 20:08:29 +02:00
|
|
|
|
CORE_ADDR address;
|
|
|
|
|
|
2017-04-29 07:34:32 +02:00
|
|
|
|
gdb::byte_vector tmp (TYPE_LENGTH (baseclass));
|
2012-07-23 20:08:29 +02:00
|
|
|
|
address = value_address (*arg1p);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2011-02-14 12:35:45 +01:00
|
|
|
|
if (target_read_memory (address + offset,
|
2017-04-29 07:34:32 +02:00
|
|
|
|
tmp.data (), TYPE_LENGTH (baseclass)) != 0)
|
* gdbtypes.h (struct cplus_struct_type): Remove runtime_ptr member.
(TYPE_RUNTIME_PTR, TYPE_VTABLE, TYPE_HAS_VTABLE,
TYPE_PRIMARY_BASE, TYPE_VIRTUAL_BASE_LIST): Remove macros.
(HP_ACC_VFUNC_START, HP_ACC_VBASE_START, HP_ACC_TYPEINFO_OFFSET,
HP_ACC_TOP_OFFSET_OFFSET): Likewise.
(has_vtable, primary_base_class, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove prototypes.
* gdbtypes.c (has_vtable, primary_base_class, current_vbase_list,
virtual_base_list_aux, virtual_base_list, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove.
* cp-valprint.c (cp_print_hpacc_virtual_table_entries): Remove.
(hpacc_vtbl_ptr_name, hpacc_vtbl_ptr_type_name): Remove.
(cp_print_value_fields): Remove support for HP aCC vtables.
(cp_print_value): Likewise.
* c-typeprint.c (c_type_print_base): Likewise.
* value.h (find_rt_vbase_offset): Remove prototype.
* valops.c (find_rt_vbase_offset): Remove.
(search_struct_method): Remove support for HP aCC vtables.
(find_method_list): Likewise.
2007-11-02 20:35:19 +01:00
|
|
|
|
error (_("virtual baseclass botch"));
|
2011-02-14 12:35:45 +01:00
|
|
|
|
|
|
|
|
|
base_val = value_from_contents_and_address (baseclass,
|
2017-04-29 07:34:32 +02:00
|
|
|
|
tmp.data (),
|
2011-02-14 12:35:45 +01:00
|
|
|
|
address + offset);
|
|
|
|
|
base_valaddr = value_contents_for_printing (base_val);
|
|
|
|
|
this_offset = 0;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
2011-02-14 12:35:45 +01:00
|
|
|
|
{
|
|
|
|
|
base_val = *arg1p;
|
|
|
|
|
base_valaddr = value_contents_for_printing (*arg1p);
|
|
|
|
|
this_offset = offset;
|
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
* gdbtypes.h (struct cplus_struct_type): Remove runtime_ptr member.
(TYPE_RUNTIME_PTR, TYPE_VTABLE, TYPE_HAS_VTABLE,
TYPE_PRIMARY_BASE, TYPE_VIRTUAL_BASE_LIST): Remove macros.
(HP_ACC_VFUNC_START, HP_ACC_VBASE_START, HP_ACC_TYPEINFO_OFFSET,
HP_ACC_TOP_OFFSET_OFFSET): Likewise.
(has_vtable, primary_base_class, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove prototypes.
* gdbtypes.c (has_vtable, primary_base_class, current_vbase_list,
virtual_base_list_aux, virtual_base_list, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove.
* cp-valprint.c (cp_print_hpacc_virtual_table_entries): Remove.
(hpacc_vtbl_ptr_name, hpacc_vtbl_ptr_type_name): Remove.
(cp_print_value_fields): Remove support for HP aCC vtables.
(cp_print_value): Likewise.
* c-typeprint.c (c_type_print_base): Likewise.
* value.h (find_rt_vbase_offset): Remove prototype.
* valops.c (find_rt_vbase_offset): Remove.
(search_struct_method): Remove support for HP aCC vtables.
(find_method_list): Likewise.
2007-11-02 20:35:19 +01:00
|
|
|
|
base_offset = baseclass_offset (type, i, base_valaddr,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
this_offset, value_address (base_val),
|
|
|
|
|
base_val);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
base_offset = TYPE_BASECLASS_BITPOS (type, i) / 8;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
v = search_struct_method (name, arg1p, args, base_offset + offset,
|
|
|
|
|
static_memfuncp, TYPE_BASECLASS (type, i));
|
2002-01-04 06:20:09 +01:00
|
|
|
|
if (v == (struct value *) - 1)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
name_matched = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (v)
|
|
|
|
|
{
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* FIXME-bothner: Why is this commented out? Why is it here? */
|
|
|
|
|
/* *arg1p = arg1_tmp; */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return v;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (name_matched)
|
2002-01-04 06:20:09 +01:00
|
|
|
|
return (struct value *) - 1;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
else
|
|
|
|
|
return NULL;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given *ARGP, a value of type (pointer to a)* structure/union,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
extract the component named NAME from the ultimate target
|
|
|
|
|
structure/union and return it as a value with its appropriate type.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
ERR is used in the error message if *ARGP's type is wrong.
|
|
|
|
|
|
|
|
|
|
C++: ARGS is a list of argument types to aid in the selection of
|
2011-01-12 02:23:29 +01:00
|
|
|
|
an appropriate method. Also, handle derived types.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
STATIC_MEMFUNCP, if non-NULL, points to a caller-supplied location
|
|
|
|
|
where the truthvalue of whether the function that was resolved was
|
|
|
|
|
a static member function or not is stored.
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
ERR is an error message to be printed in case the field is not
|
|
|
|
|
found. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_struct_elt (struct value **argp, struct value **args,
|
2010-02-08 21:55:43 +01:00
|
|
|
|
const char *name, int *static_memfuncp, const char *err)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
struct type *t;
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *v;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
2004-11-10 19:52:25 +01:00
|
|
|
|
*argp = coerce_array (*argp);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
t = check_typedef (value_type (*argp));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
/* Follow pointers until we get to a non-pointer. */
|
|
|
|
|
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_IS_REFERENCE (t))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
*argp = value_ind (*argp);
|
|
|
|
|
/* Don't coerce fn pointer to fn and then back again! */
|
2013-08-02 01:59:48 +02:00
|
|
|
|
if (TYPE_CODE (check_typedef (value_type (*argp))) != TYPE_CODE_FUNC)
|
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
2004-11-10 19:52:25 +01:00
|
|
|
|
*argp = coerce_array (*argp);
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
t = check_typedef (value_type (*argp));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (TYPE_CODE (t) != TYPE_CODE_STRUCT
|
1999-04-16 03:35:26 +02:00
|
|
|
|
&& TYPE_CODE (t) != TYPE_CODE_UNION)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("Attempt to extract a component of a value that is not a %s."),
|
|
|
|
|
err);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
/* Assume it's not, unless we see that it is. */
|
|
|
|
|
if (static_memfuncp)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
*static_memfuncp = 0;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (!args)
|
|
|
|
|
{
|
|
|
|
|
/* if there are no arguments ...do this... */
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Try as a field first, because if we succeed, there is less
|
|
|
|
|
work to be done. */
|
2015-07-06 19:10:56 +02:00
|
|
|
|
v = search_struct_field (name, *argp, t, 0);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (v)
|
|
|
|
|
return v;
|
|
|
|
|
|
|
|
|
|
/* C++: If it was not found as a data field, then try to
|
2000-03-13 08:30:00 +01:00
|
|
|
|
return it as a pointer to a method. */
|
2007-08-14 02:31:40 +02:00
|
|
|
|
v = search_struct_method (name, argp, args, 0,
|
|
|
|
|
static_memfuncp, t);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
if (v == (struct value *) - 1)
|
2005-12-08 00:07:54 +01:00
|
|
|
|
error (_("Cannot take address of method %s."), name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else if (v == 0)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_NFN_FIELDS (t))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("There is no member or method named %s."), name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("There is no member named %s."), name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-01 04:20:48 +01:00
|
|
|
|
v = search_struct_method (name, argp, args, 0,
|
|
|
|
|
static_memfuncp, t);
|
2000-07-17 21:41:10 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
if (v == (struct value *) - 1)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("One of the arguments you tried to pass to %s could not "
|
|
|
|
|
"be converted to what the function wants."), name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
else if (v == 0)
|
|
|
|
|
{
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* See if user tried to invoke data as function. If so, hand it
|
|
|
|
|
back. If it's not callable (i.e., a pointer to function),
|
2000-03-13 08:30:00 +01:00
|
|
|
|
gdb should give an error. */
|
2015-07-06 19:10:56 +02:00
|
|
|
|
v = search_struct_field (name, *argp, t, 0);
|
2008-07-27 04:00:04 +02:00
|
|
|
|
/* If we found an ordinary field, then it is not a method call.
|
|
|
|
|
So, treat it as if it were a static member function. */
|
|
|
|
|
if (v && static_memfuncp)
|
|
|
|
|
*static_memfuncp = 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!v)
|
2010-10-19 22:53:15 +02:00
|
|
|
|
throw_error (NOT_FOUND_ERROR,
|
|
|
|
|
_("Structure has no component named %s."), name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 21:20:59 +01:00
|
|
|
|
/* Given *ARGP, a value of type structure or union, or a pointer/reference
|
|
|
|
|
to a structure or union, extract and return its component (field) of
|
|
|
|
|
type FTYPE at the specified BITPOS.
|
|
|
|
|
Throw an exception on error. */
|
|
|
|
|
|
|
|
|
|
struct value *
|
|
|
|
|
value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype,
|
|
|
|
|
const char *err)
|
|
|
|
|
{
|
|
|
|
|
struct type *t;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
*argp = coerce_array (*argp);
|
|
|
|
|
|
|
|
|
|
t = check_typedef (value_type (*argp));
|
|
|
|
|
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_IS_REFERENCE (t))
|
2013-12-27 21:20:59 +01:00
|
|
|
|
{
|
|
|
|
|
*argp = value_ind (*argp);
|
|
|
|
|
if (TYPE_CODE (check_typedef (value_type (*argp))) != TYPE_CODE_FUNC)
|
|
|
|
|
*argp = coerce_array (*argp);
|
|
|
|
|
t = check_typedef (value_type (*argp));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (t) != TYPE_CODE_STRUCT
|
|
|
|
|
&& TYPE_CODE (t) != TYPE_CODE_UNION)
|
|
|
|
|
error (_("Attempt to extract a component of a value that is not a %s."),
|
|
|
|
|
err);
|
|
|
|
|
|
|
|
|
|
for (i = TYPE_N_BASECLASSES (t); i < TYPE_NFIELDS (t); i++)
|
|
|
|
|
{
|
|
|
|
|
if (!field_is_static (&TYPE_FIELD (t, i))
|
|
|
|
|
&& bitpos == TYPE_FIELD_BITPOS (t, i)
|
|
|
|
|
&& types_equal (ftype, TYPE_FIELD_TYPE (t, i)))
|
|
|
|
|
return value_primitive_field (*argp, 0, i, t);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error (_("No field with matching bitpos and type."));
|
|
|
|
|
|
|
|
|
|
/* Never hit. */
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Search through the methods of an object (and its bases) to find a
|
2014-05-20 15:41:39 +02:00
|
|
|
|
specified method. Return the pointer to the fn_field list FN_LIST of
|
|
|
|
|
overloaded instances defined in the source language. If available
|
|
|
|
|
and matching, a vector of matching xmethods defined in extension
|
|
|
|
|
languages are also returned in XM_WORKER_VEC
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
|
|
|
|
Helper function for value_find_oload_list.
|
|
|
|
|
ARGP is a pointer to a pointer to a value (the object).
|
|
|
|
|
METHOD is a string containing the method name.
|
|
|
|
|
OFFSET is the offset within the value.
|
|
|
|
|
TYPE is the assumed type of the object.
|
2014-05-20 15:41:39 +02:00
|
|
|
|
FN_LIST is the pointer to matching overloaded instances defined in
|
|
|
|
|
source language. Since this is a recursive function, *FN_LIST
|
|
|
|
|
should be set to NULL when calling this function.
|
|
|
|
|
NUM_FNS is the number of overloaded instances. *NUM_FNS should be set to
|
|
|
|
|
0 when calling this function.
|
|
|
|
|
XM_WORKER_VEC is the vector of matching xmethod workers. *XM_WORKER_VEC
|
|
|
|
|
should also be set to NULL when calling this function.
|
2007-08-14 02:31:40 +02:00
|
|
|
|
BASETYPE is set to the actual type of the subobject where the
|
|
|
|
|
method is found.
|
2011-01-12 02:23:29 +01:00
|
|
|
|
BOFFSET is the offset of the base subobject where the method is found. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
static void
|
2010-02-08 21:55:43 +01:00
|
|
|
|
find_method_list (struct value **argp, const char *method,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST offset, struct type *type,
|
2014-05-20 15:41:39 +02:00
|
|
|
|
struct fn_field **fn_list, int *num_fns,
|
|
|
|
|
VEC (xmethod_worker_ptr) **xm_worker_vec,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
struct type **basetype, LONGEST *boffset)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2014-05-20 15:41:39 +02:00
|
|
|
|
struct fn_field *f = NULL;
|
|
|
|
|
VEC (xmethod_worker_ptr) *worker_vec = NULL, *new_vec = NULL;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
gdb_assert (fn_list != NULL && xm_worker_vec != NULL);
|
2015-07-06 22:05:06 +02:00
|
|
|
|
type = check_typedef (type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
/* First check in object itself.
|
|
|
|
|
This function is called recursively to search through base classes.
|
|
|
|
|
If there is a source method match found at some stage, then we need not
|
|
|
|
|
look for source methods in consequent recursive calls. */
|
|
|
|
|
if ((*fn_list) == NULL)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2014-05-20 15:41:39 +02:00
|
|
|
|
for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
2014-05-20 15:41:39 +02:00
|
|
|
|
/* pai: FIXME What about operators and type conversions? */
|
|
|
|
|
const char *fn_field_name = TYPE_FN_FIELDLIST_NAME (type, i);
|
|
|
|
|
|
|
|
|
|
if (fn_field_name && (strcmp_iw (fn_field_name, method) == 0))
|
|
|
|
|
{
|
|
|
|
|
int len = TYPE_FN_FIELDLIST_LENGTH (type, i);
|
|
|
|
|
f = TYPE_FN_FIELDLIST1 (type, i);
|
|
|
|
|
*fn_list = f;
|
2002-05-12 04:20:38 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
*num_fns = len;
|
|
|
|
|
*basetype = type;
|
|
|
|
|
*boffset = offset;
|
2002-05-12 04:20:38 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
/* Resolve any stub methods. */
|
|
|
|
|
check_stub_method_group (type, i);
|
2002-05-12 04:20:38 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
/* Unlike source methods, xmethods can be accumulated over successive
|
|
|
|
|
recursive calls. In other words, an xmethod named 'm' in a class
|
|
|
|
|
will not hide an xmethod named 'm' in its base class(es). We want
|
|
|
|
|
it to be this way because xmethods are after all convenience functions
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
extension methods. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
|
|
|
|
|
{
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST base_offset;
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (BASETYPE_VIA_VIRTUAL (type, i))
|
|
|
|
|
{
|
* gdbtypes.h (struct cplus_struct_type): Remove runtime_ptr member.
(TYPE_RUNTIME_PTR, TYPE_VTABLE, TYPE_HAS_VTABLE,
TYPE_PRIMARY_BASE, TYPE_VIRTUAL_BASE_LIST): Remove macros.
(HP_ACC_VFUNC_START, HP_ACC_VBASE_START, HP_ACC_TYPEINFO_OFFSET,
HP_ACC_TOP_OFFSET_OFFSET): Likewise.
(has_vtable, primary_base_class, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove prototypes.
* gdbtypes.c (has_vtable, primary_base_class, current_vbase_list,
virtual_base_list_aux, virtual_base_list, virtual_base_list_length,
virtual_base_list_length_skip_primaries, virtual_base_index,
virtual_base_index_skip_primaries, class_index_in_primary_list,
count_virtual_fns): Remove.
* cp-valprint.c (cp_print_hpacc_virtual_table_entries): Remove.
(hpacc_vtbl_ptr_name, hpacc_vtbl_ptr_type_name): Remove.
(cp_print_value_fields): Remove support for HP aCC vtables.
(cp_print_value): Likewise.
* c-typeprint.c (c_type_print_base): Likewise.
* value.h (find_rt_vbase_offset): Remove prototype.
* valops.c (find_rt_vbase_offset): Remove.
(search_struct_method): Remove support for HP aCC vtables.
(find_method_list): Likewise.
2007-11-02 20:35:19 +01:00
|
|
|
|
base_offset = baseclass_offset (type, i,
|
2011-02-14 12:35:45 +01:00
|
|
|
|
value_contents_for_printing (*argp),
|
|
|
|
|
value_offset (*argp) + offset,
|
|
|
|
|
value_address (*argp), *argp);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
2007-08-14 02:31:40 +02:00
|
|
|
|
else /* Non-virtual base, simply use bit position from debug
|
|
|
|
|
info. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
base_offset = TYPE_BASECLASS_BITPOS (type, i) / 8;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
}
|
2014-05-20 15:41:39 +02:00
|
|
|
|
|
|
|
|
|
find_method_list (argp, method, base_offset + offset,
|
|
|
|
|
TYPE_BASECLASS (type, i), fn_list, num_fns,
|
|
|
|
|
xm_worker_vec, basetype, boffset);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
/* Return the list of overloaded methods of a specified name. The methods
|
|
|
|
|
could be those GDB finds in the binary, or xmethod. Methods found in
|
|
|
|
|
the binary are returned in FN_LIST, and xmethods are returned in
|
|
|
|
|
XM_WORKER_VEC.
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
|
|
|
|
ARGP is a pointer to a pointer to a value (the object).
|
|
|
|
|
METHOD is the method name.
|
|
|
|
|
OFFSET is the offset within the value contents.
|
2014-05-20 15:41:39 +02:00
|
|
|
|
FN_LIST is the pointer to matching overloaded instances defined in
|
|
|
|
|
source language.
|
2007-08-14 02:31:40 +02:00
|
|
|
|
NUM_FNS is the number of overloaded instances.
|
2014-05-20 15:41:39 +02:00
|
|
|
|
XM_WORKER_VEC is the vector of matching xmethod workers defined in
|
|
|
|
|
extension languages.
|
2007-08-14 02:31:40 +02:00
|
|
|
|
BASETYPE is set to the type of the base subobject that defines the
|
|
|
|
|
method.
|
2011-01-12 02:23:29 +01:00
|
|
|
|
BOFFSET is the offset of the base subobject which defines the method. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
static void
|
2010-02-08 21:55:43 +01:00
|
|
|
|
value_find_oload_method_list (struct value **argp, const char *method,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST offset, struct fn_field **fn_list,
|
2014-05-20 15:41:39 +02:00
|
|
|
|
int *num_fns,
|
|
|
|
|
VEC (xmethod_worker_ptr) **xm_worker_vec,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
struct type **basetype, LONGEST *boffset)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
1999-07-07 22:19:36 +02:00
|
|
|
|
struct type *t;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
t = check_typedef (value_type (*argp));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Code snarfed from value_struct_elt. */
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_IS_REFERENCE (t))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
*argp = value_ind (*argp);
|
|
|
|
|
/* Don't coerce fn pointer to fn and then back again! */
|
2013-08-02 01:59:48 +02:00
|
|
|
|
if (TYPE_CODE (check_typedef (value_type (*argp))) != TYPE_CODE_FUNC)
|
2004-11-10 Andrew Cagney <cagney@gnu.org>
* value.h (COERCE_REF, COERCE_ARRAY, COERCE_NUMBER, COERCE_ENUM)
(coerce_ref, coerce_array, coerce_number, coerce_enum): Replace
macros with function declarations.
* value.c (coerce_ref, coerce_array, coerce_number)
(coerce_enum): New functions.
(value_as_long, value_as_address): Update.
* ada-lang.c (ada_coerce_ref, ada_value_binop)
(ada_evaluate_subexp, ada_value_assign, ada_value_struct_elt): Update.
* jv-lang.c (evaluate_subexp_java): Update.
* valarith.c (value_less, value_neg, value_complement)
(value_binop, value_add, value_subscript, value_x_binop)
(value_logical_not, value_sub): Update.
* valops.c (check_field, value_struct_elt, value_ind)
(value_find_oload_method_list, value_cast, value_assign): Update.
* eval.c (evaluate_subexp_standard): Update.
2004-11-10 19:52:25 +01:00
|
|
|
|
*argp = coerce_array (*argp);
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
t = check_typedef (value_type (*argp));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (t) != TYPE_CODE_STRUCT
|
|
|
|
|
&& TYPE_CODE (t) != TYPE_CODE_UNION)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("Attempt to extract a component of a "
|
|
|
|
|
"value that is not a struct or union"));
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
gdb_assert (fn_list != NULL && xm_worker_vec != NULL);
|
|
|
|
|
|
|
|
|
|
/* Clear the lists. */
|
|
|
|
|
*fn_list = NULL;
|
|
|
|
|
*num_fns = 0;
|
|
|
|
|
*xm_worker_vec = NULL;
|
|
|
|
|
|
|
|
|
|
find_method_list (argp, method, 0, t, fn_list, num_fns, xm_worker_vec,
|
|
|
|
|
basetype, boffset);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-14 22:22:17 +02:00
|
|
|
|
/* Given an array of arguments (ARGS) (which includes an
|
1999-04-16 03:35:26 +02:00
|
|
|
|
entry for "this" in the case of C++ methods), the number of
|
2013-01-25 23:31:43 +01:00
|
|
|
|
arguments NARGS, the NAME of a function, and whether it's a method or
|
|
|
|
|
not (METHOD), find the best function that matches on the argument types
|
|
|
|
|
according to the overload resolution rules.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-06-07 18:11:35 +02:00
|
|
|
|
METHOD can be one of three values:
|
|
|
|
|
NON_METHOD for non-member functions.
|
|
|
|
|
METHOD: for member functions.
|
|
|
|
|
BOTH: used for overload resolution of operators where the
|
|
|
|
|
candidates are expected to be either member or non member
|
2011-01-12 02:23:29 +01:00
|
|
|
|
functions. In this case the first argument ARGTYPES
|
2010-06-07 18:11:35 +02:00
|
|
|
|
(representing 'this') is expected to be a reference to the
|
|
|
|
|
target object, and will be dereferenced when attempting the
|
|
|
|
|
non-member search.
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
In the case of class methods, the parameter OBJ is an object value
|
|
|
|
|
in which to search for overloaded methods.
|
|
|
|
|
|
|
|
|
|
In the case of non-method functions, the parameter FSYM is a symbol
|
|
|
|
|
corresponding to one of the overloaded functions.
|
|
|
|
|
|
|
|
|
|
Return value is an integer: 0 -> good match, 10 -> debugger applied
|
|
|
|
|
non-standard coercions, 100 -> incompatible.
|
|
|
|
|
|
|
|
|
|
If a method is being searched for, VALP will hold the value.
|
2007-08-14 02:31:40 +02:00
|
|
|
|
If a non-method is being searched for, SYMP will hold the symbol
|
|
|
|
|
for it.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
If a method is being searched for, and it is a static method,
|
|
|
|
|
then STATICP will point to a non-zero value.
|
|
|
|
|
|
2010-05-07 16:46:28 +02:00
|
|
|
|
If NO_ADL argument dependent lookup is disabled. This is used to prevent
|
|
|
|
|
ADL overload candidates when performing overload resolution for a fully
|
|
|
|
|
qualified name.
|
|
|
|
|
|
2014-07-09 19:25:48 +02:00
|
|
|
|
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.
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
Note: This function does *not* check the value of
|
|
|
|
|
overload_resolution. Caller must check it to see whether overload
|
2011-01-12 02:23:29 +01:00
|
|
|
|
resolution is permitted. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
int
|
2011-10-14 22:22:17 +02:00
|
|
|
|
find_overload_match (struct value **args, int nargs,
|
2010-06-07 18:11:35 +02:00
|
|
|
|
const char *name, enum oload_search_type method,
|
2013-01-25 23:31:43 +01:00
|
|
|
|
struct value **objp, struct symbol *fsym,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
struct value **valp, struct symbol **symp,
|
2014-07-09 19:25:48 +02:00
|
|
|
|
int *staticp, const int no_adl,
|
|
|
|
|
const enum noside noside)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-04 18:51:38 +01:00
|
|
|
|
struct value *obj = (objp ? *objp : NULL);
|
2011-10-14 22:22:17 +02:00
|
|
|
|
struct type *obj_type = obj ? value_type (obj) : NULL;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Index of best overloaded function. */
|
2010-06-07 18:11:35 +02:00
|
|
|
|
int func_oload_champ = -1;
|
|
|
|
|
int method_oload_champ = -1;
|
2014-05-20 15:41:39 +02:00
|
|
|
|
int src_method_oload_champ = -1;
|
|
|
|
|
int ext_method_oload_champ = -1;
|
2010-06-07 18:11:35 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* The measure for the current best match. */
|
2010-06-07 18:11:35 +02:00
|
|
|
|
struct badness_vector *method_badness = NULL;
|
|
|
|
|
struct badness_vector *func_badness = NULL;
|
2014-05-20 15:41:39 +02:00
|
|
|
|
struct badness_vector *ext_method_badness = NULL;
|
|
|
|
|
struct badness_vector *src_method_badness = NULL;
|
2010-06-07 18:11:35 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *temp = obj;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* For methods, the list of overloaded methods. */
|
|
|
|
|
struct fn_field *fns_ptr = NULL;
|
|
|
|
|
/* For non-methods, the list of overloaded function symbols. */
|
|
|
|
|
struct symbol **oload_syms = NULL;
|
2014-05-20 15:41:39 +02:00
|
|
|
|
/* For xmethods, the VEC of xmethod workers. */
|
|
|
|
|
VEC (xmethod_worker_ptr) *xm_worker_vec = NULL;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Number of overloaded instances being considered. */
|
|
|
|
|
int num_fns = 0;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
struct type *basetype = NULL;
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST boffset;
|
2010-05-07 16:46:28 +02:00
|
|
|
|
|
|
|
|
|
struct cleanup *all_cleanups = make_cleanup (null_cleanup, NULL);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
const char *obj_type_name = NULL;
|
2010-05-07 16:46:28 +02:00
|
|
|
|
const char *func_name = NULL;
|
2004-02-02 21:44:53 +01:00
|
|
|
|
enum oload_classification match_quality;
|
2010-06-07 18:11:35 +02:00
|
|
|
|
enum oload_classification method_match_quality = INCOMPATIBLE;
|
2014-05-20 15:41:39 +02:00
|
|
|
|
enum oload_classification src_method_match_quality = INCOMPATIBLE;
|
|
|
|
|
enum oload_classification ext_method_match_quality = INCOMPATIBLE;
|
2010-06-07 18:11:35 +02:00
|
|
|
|
enum oload_classification func_match_quality = INCOMPATIBLE;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Get the list of overloaded methods or functions. */
|
2010-06-07 18:11:35 +02:00
|
|
|
|
if (method == METHOD || method == BOTH)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2007-08-22 03:53:19 +02:00
|
|
|
|
gdb_assert (obj);
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
|
|
|
|
|
/* OBJ may be a pointer value rather than the object itself. */
|
|
|
|
|
obj = coerce_ref (obj);
|
|
|
|
|
while (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_PTR)
|
|
|
|
|
obj = coerce_ref (value_ind (obj));
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
obj_type_name = TYPE_NAME (value_type (obj));
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
|
|
|
|
|
/* First check whether this is a data member, e.g. a pointer to
|
|
|
|
|
a function. */
|
|
|
|
|
if (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_STRUCT)
|
|
|
|
|
{
|
2015-07-06 19:10:56 +02:00
|
|
|
|
*valp = search_struct_field (name, obj,
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
check_typedef (value_type (obj)), 0);
|
|
|
|
|
if (*valp)
|
|
|
|
|
{
|
|
|
|
|
*staticp = 1;
|
2011-06-30 21:29:55 +02:00
|
|
|
|
do_cleanups (all_cleanups);
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2010-06-07 18:11:35 +02:00
|
|
|
|
/* Retrieve the list of methods with the name NAME. */
|
2014-05-20 15:41:39 +02:00
|
|
|
|
value_find_oload_method_list (&temp, name, 0, &fns_ptr, &num_fns,
|
|
|
|
|
&xm_worker_vec, &basetype, &boffset);
|
2010-06-07 18:11:35 +02:00
|
|
|
|
/* If this is a method only search, and no methods were found
|
|
|
|
|
the search has faild. */
|
2014-05-20 15:41:39 +02:00
|
|
|
|
if (method == METHOD && (!fns_ptr || !num_fns) && !xm_worker_vec)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Couldn't find method %s%s%s"),
|
1999-07-07 22:19:36 +02:00
|
|
|
|
obj_type_name,
|
|
|
|
|
(obj_type_name && *obj_type_name) ? "::" : "",
|
|
|
|
|
name);
|
2002-05-12 04:20:38 +02:00
|
|
|
|
/* If we are dealing with stub method types, they should have
|
2007-08-14 02:31:40 +02:00
|
|
|
|
been resolved by find_method_list via
|
|
|
|
|
value_find_oload_method_list above. */
|
2010-06-07 18:11:35 +02:00
|
|
|
|
if (fns_ptr)
|
|
|
|
|
{
|
2015-02-01 06:17:05 +01:00
|
|
|
|
gdb_assert (TYPE_SELF_TYPE (fns_ptr[0].type) != NULL);
|
2010-06-07 18:11:35 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
src_method_oload_champ = find_oload_champ (args, nargs,
|
|
|
|
|
num_fns, fns_ptr, NULL,
|
|
|
|
|
NULL, &src_method_badness);
|
|
|
|
|
|
|
|
|
|
src_method_match_quality = classify_oload_match
|
|
|
|
|
(src_method_badness, nargs,
|
|
|
|
|
oload_method_static_p (fns_ptr, src_method_oload_champ));
|
|
|
|
|
|
|
|
|
|
make_cleanup (xfree, src_method_badness);
|
|
|
|
|
}
|
2010-06-07 18:11:35 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
if (VEC_length (xmethod_worker_ptr, xm_worker_vec) > 0)
|
|
|
|
|
{
|
|
|
|
|
ext_method_oload_champ = find_oload_champ (args, nargs,
|
|
|
|
|
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);
|
2010-06-07 18:11:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
if (src_method_oload_champ >= 0 && ext_method_oload_champ >= 0)
|
|
|
|
|
{
|
|
|
|
|
switch (compare_badness (ext_method_badness, src_method_badness))
|
|
|
|
|
{
|
|
|
|
|
case 0: /* Src method and xmethod are equally good. */
|
|
|
|
|
/* If src method and xmethod are equally good, then
|
|
|
|
|
xmethod should be the winner. Hence, fall through to the
|
|
|
|
|
case where a xmethod is better than the source
|
|
|
|
|
method, except when the xmethod match quality is
|
|
|
|
|
non-standard. */
|
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
case 1: /* Src method and ext method are incompatible. */
|
|
|
|
|
/* If ext method match is not standard, then let source method
|
|
|
|
|
win. Otherwise, fallthrough to let xmethod win. */
|
|
|
|
|
if (ext_method_match_quality != STANDARD)
|
|
|
|
|
{
|
|
|
|
|
method_oload_champ = src_method_oload_champ;
|
|
|
|
|
method_badness = src_method_badness;
|
|
|
|
|
ext_method_oload_champ = -1;
|
|
|
|
|
method_match_quality = src_method_match_quality;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
case 2: /* Ext method is champion. */
|
|
|
|
|
method_oload_champ = ext_method_oload_champ;
|
|
|
|
|
method_badness = ext_method_badness;
|
|
|
|
|
src_method_oload_champ = -1;
|
|
|
|
|
method_match_quality = ext_method_match_quality;
|
|
|
|
|
break;
|
|
|
|
|
case 3: /* Src method is champion. */
|
|
|
|
|
method_oload_champ = src_method_oload_champ;
|
|
|
|
|
method_badness = src_method_badness;
|
|
|
|
|
ext_method_oload_champ = -1;
|
|
|
|
|
method_match_quality = src_method_match_quality;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
gdb_assert_not_reached ("Unexpected overload comparison "
|
|
|
|
|
"result");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (src_method_oload_champ >= 0)
|
|
|
|
|
{
|
|
|
|
|
method_oload_champ = src_method_oload_champ;
|
|
|
|
|
method_badness = src_method_badness;
|
|
|
|
|
method_match_quality = src_method_match_quality;
|
|
|
|
|
}
|
|
|
|
|
else if (ext_method_oload_champ >= 0)
|
|
|
|
|
{
|
|
|
|
|
method_oload_champ = ext_method_oload_champ;
|
|
|
|
|
method_badness = ext_method_badness;
|
|
|
|
|
method_match_quality = ext_method_match_quality;
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2010-06-07 18:11:35 +02:00
|
|
|
|
|
|
|
|
|
if (method == NON_METHOD || method == BOTH)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2010-05-07 16:46:28 +02:00
|
|
|
|
const char *qualified_name = NULL;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2011-02-26 03:07:10 +01:00
|
|
|
|
/* If the overload match is being search for both as a method
|
|
|
|
|
and non member function, the first argument must now be
|
|
|
|
|
dereferenced. */
|
2010-06-07 18:11:35 +02:00
|
|
|
|
if (method == BOTH)
|
2012-06-15 16:35:33 +02:00
|
|
|
|
args[0] = value_ind (args[0]);
|
2010-06-07 18:11:35 +02:00
|
|
|
|
|
2010-05-07 16:46:28 +02:00
|
|
|
|
if (fsym)
|
|
|
|
|
{
|
|
|
|
|
qualified_name = SYMBOL_NATURAL_NAME (fsym);
|
|
|
|
|
|
|
|
|
|
/* If we have a function with a C++ name, try to extract just
|
|
|
|
|
the function part. Do not try this for non-functions (e.g.
|
|
|
|
|
function pointers). */
|
|
|
|
|
if (qualified_name
|
2011-01-05 23:22:53 +01:00
|
|
|
|
&& TYPE_CODE (check_typedef (SYMBOL_TYPE (fsym)))
|
|
|
|
|
== TYPE_CODE_FUNC)
|
2010-05-07 16:46:28 +02:00
|
|
|
|
{
|
|
|
|
|
char *temp;
|
|
|
|
|
|
|
|
|
|
temp = cp_func_name (qualified_name);
|
|
|
|
|
|
|
|
|
|
/* If cp_func_name did not remove anything, the name of the
|
|
|
|
|
symbol did not include scope or argument types - it was
|
|
|
|
|
probably a C-style function. */
|
|
|
|
|
if (temp)
|
|
|
|
|
{
|
|
|
|
|
make_cleanup (xfree, temp);
|
|
|
|
|
if (strcmp (temp, qualified_name) == 0)
|
|
|
|
|
func_name = NULL;
|
|
|
|
|
else
|
|
|
|
|
func_name = temp;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
{
|
2010-05-07 16:46:28 +02:00
|
|
|
|
func_name = name;
|
|
|
|
|
qualified_name = name;
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
}
|
2006-10-09 21:28:14 +02:00
|
|
|
|
|
dwarf2_physname patchset:
Based on work from Daniel Jacobowitz <dan@codesourcery.com>
* c-typeprint.c (cp_type_print_method_args): For non-static methods,
print out const or volatile qualifiers, too.
(c_type_print_args): Add parameters show_artificial and language.
Skip artificial parameters when requested.
Use the appropriate language printer.
(c_type_print_varspec): Tell c_type_print_args to skip artificial
parameters and pass language_c.
* dwarf2read.c (die_list): New file global.
(struct partial_die_info): Update comments for name field.
(pdi_needs_namespace): Renamed to ...
(die_needs_namespace): ... this. Rewrite.
(dwarf2_linkage_name): Remove.
(add_partial_symbol): Do not predicate the call to
partial_die_full_name based on pdi_needs_namespace.
Remove call to cp_check_possible_namespace_symbols and associated
outdated comments.
(guess_structure_name): Do not inspect child subprogram DIEs.
(dwarf2_fullname): Update comments.
Use die_needs_namespace to assist in computing the name.
(read_func_scope): Use dwarf2_name to get the DIE's name.
Use dwarf2_physname to get the "linkage name" of the DIE.
(dwarf2_add_member_field): Use dwarf2_physname instead of
dwarf2_linkage_name.
(read_structure_type): For structs and classes, set TYPE_NAME, too.
(determine_class): Remove.
(read_partial_die): Ignore DW_AT_MIPS_linkage_name for all languages
except Ada.
(new_symbol): Unconditionally call dwarf2_name.
Compute the "linkage name" using dwarf2_physname.
Use dwarf2_name instead of dwarf2_full_name for enumerator DIEs.
When determining to scan for anonymous C++ namespaces, ignore
the linkage name.
(dwarf2_physname): New function.
(dwarf2_full_name): Move content to new function and call
that.
(dwarf2_compute_name): "New" function.
(_initialize_dwarf2_read): Initialize die_list.
* gnu-v3-eabi.c (gnu_v3_find_method_in): Remove unused variable
physname.
(gnu_v3_print_method_ptr): Use the physname for virtual methods
without a demangled name.
Print out type information for non-virtual methods.
* linespec.c (decode_line_1): Force ANY string using "::" (or
"." for java) to use decode_compound, and clean up any stray quoting.
If we found a file symtab, re-evaluate whether the remainder is_quoted.
(decode_compound): Stop consuming at an open parenthesis.
Keep template parameters.
Keep any overload information.
Keep keywords like "const".
Remove paren_pointer.
Move is_quoted check from set_flags to here.
Remove #if 0 code from 2000. Ten years is long enough.
(find_method): Before comparing symbol names, canonicalize the string
from the user.
If a specific overload is requested, find it. Otherwise throw an error.
(find_method_overload_end): New function.
(set_flags): Remove.
(decode_compound): Assume that parentheses are matched.
It's a lot easier.
* symtab.c (symbol_find_demangled_name): Add DMGL_VERBOSE flag
to cplus_demangle.
* linespec.c (decode_line_1): Keep important keywords like
"const" and "volatile".
* symtab.h (SYMBOL_CPLUS_DEMANGLED_NAME): Remove.
* typeprint.h (c_type_print_args): Add declaration.
* ui-file.c (do_ui_file_obsavestring): New function.
(ui_file_obsavestring): New function.
* ui-file.h (ui_file_obsavestring): Add declaration.
* valops.c (find_overload_match): Resolve the object to
a non-pointer type.
If the object is a data member, search the object for the member
and return with staticp set.
Use SYMBOL_NATURAL_NAME instead of SYMBOL_CPLUS_DEMANGLED_NAME.
Do not attempt to extract a function name from non-function types.
If the extracted function name and the original name are the same,
we don't have a C++ method.
From Jan Kratochvil <jan.kratochvil@redhat.com>:
* dwarf2read.c (new_symbol <DW_TAG_enumerator>): Call dwarf2_full_name.
* ada-lang.c (ada_lookup_symbol): Remove linkage_name parameters
and arguments from symbol lookups.
* ax-gdb.c (gen_expr): Likewise.
* cp-namespace.c (cp_lookup_symbol_nonlocal, lookup_namespace_scope,
cp_lookup_symbol_namespace, lookup_symbol_file, lookup_nested_type,
lookup_possible_namespace_symbol): Likewise.
* cp-support.c (read_in_psymtabs): Likewise.
* cp-support.h (cp_lookup_symbol_nonlocal): Likewise.
* language.h (la_lookup_symbol_nonlocal): Likewise.
* scm-valprint.c (scm_inferior_print): Likewise.
* solib-darwin.c (darwin_relocate_section_addresses): Likewise.
* solib-svr.c (elf_lookup_lib): Likewise.
* solib.c (show_auto_solib_add): Likewise.
* solist.h (lookup_lib_global, solib_global_lookup): Likewise.
* symmisc.c (maintenance_check_symtabs): Likewise.
* symtab.c (lookup_symbol_in_language, lookup_symbol_aux,
lookup_symbol_aux_local, lookup_symbol_aux_block,
lookup_symbol_from_objfile, lookup_symbol_aux_symtabs,
lookup_symbol_aux_psymtabs,basic_lookup_symbol_nonlocal,
lookup_symbol_static, lookup_symbol_global, symbol_matches_domain,
basic_lookup_transparent_type, find_main_psymtab,
lookup_block_symbol): Likewise.
* symtab.h (basic_lookp_symbol_nonlocal, lookup_symbol_static,
lookup_symbol_global, lookup_symbol_aux_block,
lookup_symbol_partial_symbol, lookup_block_symbol,
lookup_global_symbol, value_maybe_namespace_elt): Likewise.
2010-03-09 19:09:08 +01:00
|
|
|
|
/* If there was no C++ name, this must be a C-style function or
|
|
|
|
|
not a function at all. Just return the same symbol. Do the
|
|
|
|
|
same if cp_func_name fails for some reason. */
|
2004-02-02 21:44:53 +01:00
|
|
|
|
if (func_name == NULL)
|
2000-03-13 08:30:00 +01:00
|
|
|
|
{
|
1999-10-19 04:47:02 +02:00
|
|
|
|
*symp = fsym;
|
2011-06-27 21:21:51 +02:00
|
|
|
|
do_cleanups (all_cleanups);
|
2000-03-13 08:30:00 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
1999-10-19 04:47:02 +02:00
|
|
|
|
|
2011-10-14 22:22:17 +02:00
|
|
|
|
func_oload_champ = find_oload_champ_namespace (args, nargs,
|
2010-06-07 18:11:35 +02:00
|
|
|
|
func_name,
|
|
|
|
|
qualified_name,
|
|
|
|
|
&oload_syms,
|
|
|
|
|
&func_badness,
|
|
|
|
|
no_adl);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
2010-06-07 18:11:35 +02:00
|
|
|
|
if (func_oload_champ >= 0)
|
|
|
|
|
func_match_quality = classify_oload_match (func_badness, nargs, 0);
|
|
|
|
|
|
|
|
|
|
make_cleanup (xfree, oload_syms);
|
|
|
|
|
make_cleanup (xfree, func_badness);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
}
|
|
|
|
|
|
2010-05-07 16:46:28 +02:00
|
|
|
|
/* Did we find a match ? */
|
2010-06-07 18:11:35 +02:00
|
|
|
|
if (method_oload_champ == -1 && func_oload_champ == -1)
|
2010-10-19 22:53:15 +02:00
|
|
|
|
throw_error (NOT_FOUND_ERROR,
|
|
|
|
|
_("No symbol \"%s\" in current context."),
|
|
|
|
|
name);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
2010-06-07 18:11:35 +02:00
|
|
|
|
/* If we have found both a method match and a function
|
|
|
|
|
match, find out which one is better, and calculate match
|
|
|
|
|
quality. */
|
|
|
|
|
if (method_oload_champ >= 0 && func_oload_champ >= 0)
|
|
|
|
|
{
|
|
|
|
|
switch (compare_badness (func_badness, method_badness))
|
|
|
|
|
{
|
|
|
|
|
case 0: /* Top two contenders are equally good. */
|
2011-02-26 03:07:10 +01:00
|
|
|
|
/* FIXME: GDB does not support the general ambiguous case.
|
|
|
|
|
All candidates should be collected and presented the
|
|
|
|
|
user. */
|
2010-06-07 18:11:35 +02:00
|
|
|
|
error (_("Ambiguous overload resolution"));
|
|
|
|
|
break;
|
|
|
|
|
case 1: /* Incomparable top contenders. */
|
|
|
|
|
/* This is an error incompatible candidates
|
|
|
|
|
should not have been proposed. */
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("Internal error: incompatible "
|
|
|
|
|
"overload candidates proposed"));
|
2010-06-07 18:11:35 +02:00
|
|
|
|
break;
|
|
|
|
|
case 2: /* Function champion. */
|
|
|
|
|
method_oload_champ = -1;
|
|
|
|
|
match_quality = func_match_quality;
|
|
|
|
|
break;
|
|
|
|
|
case 3: /* Method champion. */
|
|
|
|
|
func_oload_champ = -1;
|
|
|
|
|
match_quality = method_match_quality;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
error (_("Internal error: unexpected overload comparison result"));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* We have either a method match or a function match. */
|
|
|
|
|
if (method_oload_champ >= 0)
|
|
|
|
|
match_quality = method_match_quality;
|
|
|
|
|
else
|
|
|
|
|
match_quality = func_match_quality;
|
|
|
|
|
}
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
if (match_quality == INCOMPATIBLE)
|
|
|
|
|
{
|
2010-06-07 18:11:35 +02:00
|
|
|
|
if (method == METHOD)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Cannot resolve method %s%s%s to any overloaded instance"),
|
2004-02-02 21:44:53 +01:00
|
|
|
|
obj_type_name,
|
|
|
|
|
(obj_type_name && *obj_type_name) ? "::" : "",
|
|
|
|
|
name);
|
|
|
|
|
else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("Cannot resolve function %s to any overloaded instance"),
|
2004-02-02 21:44:53 +01:00
|
|
|
|
func_name);
|
|
|
|
|
}
|
|
|
|
|
else if (match_quality == NON_STANDARD)
|
|
|
|
|
{
|
2010-06-07 18:11:35 +02:00
|
|
|
|
if (method == METHOD)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
warning (_("Using non-standard conversion to match "
|
|
|
|
|
"method %s%s%s to supplied arguments"),
|
2004-02-02 21:44:53 +01:00
|
|
|
|
obj_type_name,
|
|
|
|
|
(obj_type_name && *obj_type_name) ? "::" : "",
|
|
|
|
|
name);
|
|
|
|
|
else
|
2011-01-05 23:22:53 +01:00
|
|
|
|
warning (_("Using non-standard conversion to match "
|
|
|
|
|
"function %s to supplied arguments"),
|
2004-02-02 21:44:53 +01:00
|
|
|
|
func_name);
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-07 18:11:35 +02:00
|
|
|
|
if (staticp != NULL)
|
2014-03-03 14:08:47 +01:00
|
|
|
|
*staticp = oload_method_static_p (fns_ptr, method_oload_champ);
|
2010-06-07 18:11:35 +02:00
|
|
|
|
|
|
|
|
|
if (method_oload_champ >= 0)
|
2004-02-02 21:44:53 +01:00
|
|
|
|
{
|
2014-05-20 15:41:39 +02:00
|
|
|
|
if (src_method_oload_champ >= 0)
|
|
|
|
|
{
|
2014-07-09 19:25:48 +02:00
|
|
|
|
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);
|
|
|
|
|
}
|
2014-05-20 15:41:39 +02:00
|
|
|
|
else
|
|
|
|
|
*valp = value_fn_field (&temp, fns_ptr, method_oload_champ,
|
|
|
|
|
basetype, boffset);
|
|
|
|
|
}
|
2004-02-02 21:44:53 +01:00
|
|
|
|
else
|
2014-05-20 15:41:39 +02:00
|
|
|
|
{
|
|
|
|
|
*valp = value_of_xmethod (clone_xmethod_worker
|
|
|
|
|
(VEC_index (xmethod_worker_ptr, xm_worker_vec,
|
|
|
|
|
ext_method_oload_champ)));
|
|
|
|
|
}
|
2004-02-02 21:44:53 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2010-06-07 18:11:35 +02:00
|
|
|
|
*symp = oload_syms[func_oload_champ];
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
if (objp)
|
|
|
|
|
{
|
2009-02-02 22:50:13 +01:00
|
|
|
|
struct type *temp_type = check_typedef (value_type (temp));
|
2011-10-14 22:22:17 +02:00
|
|
|
|
struct type *objtype = check_typedef (obj_type);
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2009-02-02 22:50:13 +01:00
|
|
|
|
if (TYPE_CODE (temp_type) != TYPE_CODE_PTR
|
2011-10-14 22:22:17 +02:00
|
|
|
|
&& (TYPE_CODE (objtype) == TYPE_CODE_PTR
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
|| TYPE_IS_REFERENCE (objtype)))
|
2004-02-02 21:44:53 +01:00
|
|
|
|
{
|
|
|
|
|
temp = value_addr (temp);
|
|
|
|
|
}
|
|
|
|
|
*objp = temp;
|
|
|
|
|
}
|
2010-05-07 16:46:28 +02:00
|
|
|
|
|
|
|
|
|
do_cleanups (all_cleanups);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
switch (match_quality)
|
|
|
|
|
{
|
|
|
|
|
case INCOMPATIBLE:
|
|
|
|
|
return 100;
|
|
|
|
|
case NON_STANDARD:
|
|
|
|
|
return 10;
|
|
|
|
|
default: /* STANDARD */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Find the best overload match, searching for FUNC_NAME in namespaces
|
|
|
|
|
contained in QUALIFIED_NAME until it either finds a good match or
|
|
|
|
|
runs out of namespaces. It stores the overloaded functions in
|
|
|
|
|
*OLOAD_SYMS, and the badness vector in *OLOAD_CHAMP_BV. The
|
|
|
|
|
calling function is responsible for freeing *OLOAD_SYMS and
|
2010-05-07 16:46:28 +02:00
|
|
|
|
*OLOAD_CHAMP_BV. If NO_ADL, argument dependent lookup is not
|
|
|
|
|
performned. */
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
static int
|
2011-10-14 22:22:17 +02:00
|
|
|
|
find_oload_champ_namespace (struct value **args, int nargs,
|
2004-02-02 21:44:53 +01:00
|
|
|
|
const char *func_name,
|
|
|
|
|
const char *qualified_name,
|
|
|
|
|
struct symbol ***oload_syms,
|
2010-05-07 16:46:28 +02:00
|
|
|
|
struct badness_vector **oload_champ_bv,
|
|
|
|
|
const int no_adl)
|
2004-02-02 21:44:53 +01:00
|
|
|
|
{
|
|
|
|
|
int oload_champ;
|
|
|
|
|
|
2011-10-14 22:22:17 +02:00
|
|
|
|
find_oload_champ_namespace_loop (args, nargs,
|
2004-02-02 21:44:53 +01:00
|
|
|
|
func_name,
|
|
|
|
|
qualified_name, 0,
|
|
|
|
|
oload_syms, oload_champ_bv,
|
2010-05-07 16:46:28 +02:00
|
|
|
|
&oload_champ,
|
|
|
|
|
no_adl);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
return oload_champ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper function for find_oload_champ_namespace; NAMESPACE_LEN is
|
|
|
|
|
how deep we've looked for namespaces, and the champ is stored in
|
|
|
|
|
OLOAD_CHAMP. The return value is 1 if the champ is a good one, 0
|
2010-05-07 16:46:28 +02:00
|
|
|
|
if it isn't. Other arguments are the same as in
|
|
|
|
|
find_oload_champ_namespace
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
It is the caller's responsibility to free *OLOAD_SYMS and
|
|
|
|
|
*OLOAD_CHAMP_BV. */
|
|
|
|
|
|
|
|
|
|
static int
|
2011-10-14 22:22:17 +02:00
|
|
|
|
find_oload_champ_namespace_loop (struct value **args, int nargs,
|
2004-02-02 21:44:53 +01:00
|
|
|
|
const char *func_name,
|
|
|
|
|
const char *qualified_name,
|
|
|
|
|
int namespace_len,
|
|
|
|
|
struct symbol ***oload_syms,
|
|
|
|
|
struct badness_vector **oload_champ_bv,
|
2010-05-07 16:46:28 +02:00
|
|
|
|
int *oload_champ,
|
|
|
|
|
const int no_adl)
|
2004-02-02 21:44:53 +01:00
|
|
|
|
{
|
|
|
|
|
int next_namespace_len = namespace_len;
|
|
|
|
|
int searched_deeper = 0;
|
|
|
|
|
int num_fns = 0;
|
|
|
|
|
struct cleanup *old_cleanups;
|
|
|
|
|
int new_oload_champ;
|
|
|
|
|
struct symbol **new_oload_syms;
|
|
|
|
|
struct badness_vector *new_oload_champ_bv;
|
|
|
|
|
char *new_namespace;
|
|
|
|
|
|
|
|
|
|
if (next_namespace_len != 0)
|
|
|
|
|
{
|
|
|
|
|
gdb_assert (qualified_name[next_namespace_len] == ':');
|
|
|
|
|
next_namespace_len += 2;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
2007-08-14 02:31:40 +02:00
|
|
|
|
next_namespace_len +=
|
|
|
|
|
cp_find_first_component (qualified_name + next_namespace_len);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
/* Initialize these to values that can safely be xfree'd. */
|
|
|
|
|
*oload_syms = NULL;
|
|
|
|
|
*oload_champ_bv = NULL;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2011-01-12 02:23:29 +01:00
|
|
|
|
/* First, see if we have a deeper namespace we can search in.
|
2007-08-14 02:31:40 +02:00
|
|
|
|
If we get a good match there, use it. */
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
if (qualified_name[next_namespace_len] == ':')
|
|
|
|
|
{
|
|
|
|
|
searched_deeper = 1;
|
|
|
|
|
|
2011-10-14 22:22:17 +02:00
|
|
|
|
if (find_oload_champ_namespace_loop (args, nargs,
|
2004-02-02 21:44:53 +01:00
|
|
|
|
func_name, qualified_name,
|
|
|
|
|
next_namespace_len,
|
|
|
|
|
oload_syms, oload_champ_bv,
|
2010-05-07 16:46:28 +02:00
|
|
|
|
oload_champ, no_adl))
|
2004-02-02 21:44:53 +01:00
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* If we reach here, either we're in the deepest namespace or we
|
|
|
|
|
didn't find a good match in a deeper namespace. But, in the
|
|
|
|
|
latter case, we still have a bad match in a deeper namespace;
|
|
|
|
|
note that we might not find any match at all in the current
|
|
|
|
|
namespace. (There's always a match in the deepest namespace,
|
|
|
|
|
because this overload mechanism only gets called if there's a
|
|
|
|
|
function symbol to start off with.) */
|
|
|
|
|
|
|
|
|
|
old_cleanups = make_cleanup (xfree, *oload_syms);
|
2010-09-22 17:48:59 +02:00
|
|
|
|
make_cleanup (xfree, *oload_champ_bv);
|
2015-09-25 20:08:06 +02:00
|
|
|
|
new_namespace = (char *) alloca (namespace_len + 1);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
strncpy (new_namespace, qualified_name, namespace_len);
|
|
|
|
|
new_namespace[namespace_len] = '\0';
|
|
|
|
|
new_oload_syms = make_symbol_overload_list (func_name,
|
|
|
|
|
new_namespace);
|
2010-05-07 16:46:28 +02:00
|
|
|
|
|
|
|
|
|
/* If we have reached the deepest level perform argument
|
|
|
|
|
determined lookup. */
|
|
|
|
|
if (!searched_deeper && !no_adl)
|
2011-10-14 22:22:17 +02:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
2010-05-07 16:46:28 +02:00
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
while (new_oload_syms[num_fns])
|
|
|
|
|
++num_fns;
|
|
|
|
|
|
2014-02-27 14:51:46 +01:00
|
|
|
|
new_oload_champ = find_oload_champ (args, nargs, num_fns,
|
2014-05-20 15:41:39 +02:00
|
|
|
|
NULL, NULL, new_oload_syms,
|
2004-02-02 21:44:53 +01:00
|
|
|
|
&new_oload_champ_bv);
|
|
|
|
|
|
|
|
|
|
/* Case 1: We found a good match. Free earlier matches (if any),
|
|
|
|
|
and return it. Case 2: We didn't find a good match, but we're
|
|
|
|
|
not the deepest function. Then go with the bad match that the
|
|
|
|
|
deeper function found. Case 3: We found a bad match, and we're
|
|
|
|
|
the deepest function. Then return what we found, even though
|
|
|
|
|
it's a bad match. */
|
|
|
|
|
|
|
|
|
|
if (new_oload_champ != -1
|
|
|
|
|
&& classify_oload_match (new_oload_champ_bv, nargs, 0) == STANDARD)
|
|
|
|
|
{
|
|
|
|
|
*oload_syms = new_oload_syms;
|
|
|
|
|
*oload_champ = new_oload_champ;
|
|
|
|
|
*oload_champ_bv = new_oload_champ_bv;
|
|
|
|
|
do_cleanups (old_cleanups);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else if (searched_deeper)
|
|
|
|
|
{
|
|
|
|
|
xfree (new_oload_syms);
|
|
|
|
|
xfree (new_oload_champ_bv);
|
|
|
|
|
discard_cleanups (old_cleanups);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*oload_syms = new_oload_syms;
|
|
|
|
|
*oload_champ = new_oload_champ;
|
|
|
|
|
*oload_champ_bv = new_oload_champ_bv;
|
2010-09-24 16:47:53 +02:00
|
|
|
|
do_cleanups (old_cleanups);
|
2004-02-02 21:44:53 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-14 22:22:17 +02:00
|
|
|
|
/* Look for a function to take NARGS args of ARGS. Find
|
2004-02-02 21:44:53 +01:00
|
|
|
|
the best match from among the overloaded methods or functions
|
2014-05-20 15:41:39 +02:00
|
|
|
|
given by FNS_PTR or OLOAD_SYMS or XM_WORKER_VEC, respectively.
|
|
|
|
|
One, and only one of FNS_PTR, OLOAD_SYMS and XM_WORKER_VEC can be
|
|
|
|
|
non-NULL.
|
|
|
|
|
|
|
|
|
|
If XM_WORKER_VEC is NULL, then the length of the arrays FNS_PTR
|
|
|
|
|
or OLOAD_SYMS (whichever is non-NULL) is specified in NUM_FNS.
|
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
Return the index of the best match; store an indication of the
|
|
|
|
|
quality of the match in OLOAD_CHAMP_BV.
|
|
|
|
|
|
|
|
|
|
It is the caller's responsibility to free *OLOAD_CHAMP_BV. */
|
|
|
|
|
|
|
|
|
|
static int
|
2014-02-27 14:51:46 +01:00
|
|
|
|
find_oload_champ (struct value **args, int nargs,
|
2004-02-02 21:44:53 +01:00
|
|
|
|
int num_fns, struct fn_field *fns_ptr,
|
2014-05-20 15:41:39 +02:00
|
|
|
|
VEC (xmethod_worker_ptr) *xm_worker_vec,
|
2004-02-02 21:44:53 +01:00
|
|
|
|
struct symbol **oload_syms,
|
|
|
|
|
struct badness_vector **oload_champ_bv)
|
|
|
|
|
{
|
|
|
|
|
int ix;
|
2014-05-20 15:41:39 +02:00
|
|
|
|
int fn_count;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* A measure of how good an overloaded instance is. */
|
|
|
|
|
struct badness_vector *bv;
|
|
|
|
|
/* Index of best overloaded function. */
|
|
|
|
|
int oload_champ = -1;
|
|
|
|
|
/* Current ambiguity state for overload resolution. */
|
|
|
|
|
int oload_ambiguous = 0;
|
|
|
|
|
/* 0 => no ambiguity, 1 => two good funcs, 2 => incomparable funcs. */
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
2014-02-27 14:51:46 +01:00
|
|
|
|
/* A champion can be found among methods alone, or among functions
|
2014-05-20 15:41:39 +02:00
|
|
|
|
alone, or in xmethods alone, but not in more than one of these
|
|
|
|
|
groups. */
|
|
|
|
|
gdb_assert ((fns_ptr != NULL) + (oload_syms != NULL) + (xm_worker_vec != NULL)
|
|
|
|
|
== 1);
|
2014-02-27 14:51:46 +01:00
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
*oload_champ_bv = NULL;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
fn_count = (xm_worker_vec != NULL
|
|
|
|
|
? VEC_length (xmethod_worker_ptr, xm_worker_vec)
|
|
|
|
|
: num_fns);
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Consider each candidate in turn. */
|
2014-05-20 15:41:39 +02:00
|
|
|
|
for (ix = 0; ix < fn_count; ix++)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2004-02-02 21:44:53 +01:00
|
|
|
|
int jj;
|
2014-05-20 15:41:39 +02:00
|
|
|
|
int static_offset = 0;
|
2004-02-02 21:44:53 +01:00
|
|
|
|
int nparms;
|
|
|
|
|
struct type **parm_types;
|
2014-05-20 15:41:39 +02:00
|
|
|
|
struct xmethod_worker *worker = NULL;
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
2014-05-20 15:41:39 +02:00
|
|
|
|
if (xm_worker_vec != NULL)
|
2000-03-13 11:01:23 +01:00
|
|
|
|
{
|
2014-05-20 15:41:39 +02:00
|
|
|
|
worker = VEC_index (xmethod_worker_ptr, xm_worker_vec, ix);
|
|
|
|
|
parm_types = get_xmethod_arg_types (worker, &nparms);
|
2000-03-13 11:01:23 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-05-20 15:41:39 +02:00
|
|
|
|
if (fns_ptr != NULL)
|
|
|
|
|
{
|
|
|
|
|
nparms = TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (fns_ptr, ix));
|
|
|
|
|
static_offset = oload_method_static_p (fns_ptr, ix);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nparms = TYPE_NFIELDS (SYMBOL_TYPE (oload_syms[ix]));
|
|
|
|
|
|
Replace some xmalloc-family functions with XNEW-family ones
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is
to change some calls to the xmalloc family of functions to calls to the
equivalents in the XNEW family. This avoids adding an explicit cast, so
it keeps the code a bit more readable. Some of them also map relatively
well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be
possible to do scripted replacements if needed.
I only changed calls that were obviously allocating memory for one or
multiple "objects". Allocation of variable sizes (such as strings or
buffer handling) will be for later (and won't use XNEW).
- xmalloc (sizeof (struct foo)) -> XNEW (struct foo)
- xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num)
- xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo)
- xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num)
- xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num)
- obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo)
- obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num)
- alloca (sizeof (struct foo)) -> XALLOCA (struct foo)
- alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num)
Some instances of xmalloc followed by memset to zero the buffer were
replaced by XCNEW or XCNEWVEC.
I regtested on x86-64, Ubuntu 14.04, but the patch touches many
architecture-specific files. For those I'll have to rely on the
buildbot or people complaining that I broke their gdb.
gdb/ChangeLog:
* aarch64-linux-nat.c (aarch64_add_process): Likewise.
* aarch64-tdep.c (aarch64_gdbarch_init): Likewise.
* ada-exp.y (write_ambiguous_var): Likewise.
* ada-lang.c (resolve_subexp): Likewise.
(user_select_syms): Likewise.
(assign_aggregate): Likewise.
(ada_evaluate_subexp): Likewise.
(cache_symbol): Likewise.
* addrmap.c (allocate_key): Likewise.
(addrmap_create_mutable): Likewise.
* aix-thread.c (sync_threadlists): Likewise.
* alpha-tdep.c (alpha_push_dummy_call): Likewise.
(alpha_gdbarch_init): Likewise.
* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
* arm-linux-nat.c (arm_linux_add_process): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* arm-tdep.c (push_stack_item): Likewise.
(arm_displaced_step_copy_insn): Likewise.
(arm_gdbarch_init): Likewise.
(_initialize_arm_tdep): Likewise.
* avr-tdep.c (push_stack_item): Likewise.
* ax-general.c (new_agent_expr): Likewise.
* block.c (block_initialize_namespace): Likewise.
* breakpoint.c (alloc_counted_command_line): Likewise.
(update_dprintf_command_list): Likewise.
(parse_breakpoint_sals): Likewise.
(decode_static_tracepoint_spec): Likewise.
(until_break_command): Likewise.
(clear_command): Likewise.
(update_global_location_list): Likewise.
(get_breakpoint_objfile_data) Likewise.
* btrace.c (ftrace_new_function): Likewise.
(btrace_set_insn_history): Likewise.
(btrace_set_call_history): Likewise.
* buildsym.c (add_symbol_to_list): Likewise.
(record_pending_block): Likewise.
(start_subfile): Likewise.
(start_buildsym_compunit): Likewise.
(push_subfile): Likewise.
(end_symtab_get_static_block): Likewise.
(buildsym_init): Likewise.
* cli/cli-cmds.c (source_command): Likewise.
* cli/cli-decode.c (add_cmd): Likewise.
* cli/cli-script.c (build_command_line): Likewise.
(setup_user_args): Likewise.
(realloc_body_list): Likewise.
(process_next_line): Likewise.
(copy_command_lines): Likewise.
* cli/cli-setshow.c (do_set_command): Likewise.
* coff-pe-read.c (read_pe_exported_syms): Likewise.
* coffread.c (coff_locate_sections): Likewise.
(coff_symtab_read): Likewise.
(coff_read_struct_type): Likewise.
* common/cleanups.c (make_my_cleanup2): Likewise.
* common/common-exceptions.c (throw_it): Likewise.
* common/filestuff.c (make_cleanup_close): Likewise.
* common/format.c (parse_format_string): Likewise.
* common/queue.h (DEFINE_QUEUE_P): Likewise.
* compile/compile-object-load.c (munmap_list_add): Likewise.
(compile_object_load): Likewise.
* compile/compile-object-run.c (compile_object_run): Likewise.
* compile/compile.c (append_args): Likewise.
* corefile.c (specify_exec_file_hook): Likewise.
* cp-support.c (make_symbol_overload_list): Likewise.
* cris-tdep.c (push_stack_item): Likewise.
(cris_gdbarch_init): Likewise.
* ctf.c (ctf_trace_file_writer_new): Likewise.
* dbxread.c (init_header_files): Likewise.
(add_new_header_file): Likewise.
(init_bincl_list): Likewise.
(dbx_end_psymtab): Likewise.
(start_psymtab): Likewise.
(dbx_end_psymtab): Likewise.
* dcache.c (dcache_init): Likewise.
* dictionary.c (dict_create_hashed): Likewise.
(dict_create_hashed_expandable): Likewise.
(dict_create_linear): Likewise.
(dict_create_linear_expandable): Likewise.
* dtrace-probe.c (dtrace_process_dof_probe): Likewise.
* dummy-frame.c (register_dummy_frame_dtor): Likewise.
* dwarf2-frame-tailcall.c (cache_new_ref1): Likewise.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
(decode_frame_entry_1): Likewise.
* dwarf2expr.c (new_dwarf_expr_context): Likewise.
* dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise.
* dwarf2read.c (dwarf2_has_info): Likewise.
(create_signatured_type_table_from_index): Likewise.
(dwarf2_read_index): Likewise.
(dw2_get_file_names_reader): Likewise.
(create_all_type_units): Likewise.
(read_cutu_die_from_dwo): Likewise.
(init_tu_and_read_dwo_dies): Likewise.
(init_cutu_and_read_dies): Likewise.
(create_all_comp_units): Likewise.
(queue_comp_unit): Likewise.
(inherit_abstract_dies): Likewise.
(read_call_site_scope): Likewise.
(dwarf2_add_field): Likewise.
(dwarf2_add_typedef): Likewise.
(dwarf2_add_member_fn): Likewise.
(attr_to_dynamic_prop): Likewise.
(abbrev_table_alloc_abbrev): Likewise.
(abbrev_table_read_table): Likewise.
(add_include_dir): Likewise.
(add_file_name): Likewise.
(dwarf_decode_line_header): Likewise.
(dwarf2_const_value_attr): Likewise.
(dwarf_alloc_block): Likewise.
(parse_macro_definition): Likewise.
(set_die_type): Likewise.
(write_psymtabs_to_index): Likewise.
(create_cus_from_index): Likewise.
(dwarf2_create_include_psymtab): Likewise.
(process_psymtab_comp_unit_reader): Likewise.
(build_type_psymtab_dependencies): Likewise.
(read_comp_units_from_section): Likewise.
(compute_compunit_symtab_includes): Likewise.
(create_dwo_unit_in_dwp_v1): Likewise.
(create_dwo_unit_in_dwp_v2): Likewise.
(read_func_scope): Likewise.
(process_structure_scope): Likewise.
(mark_common_block_symbol_computed): Likewise.
(load_partial_dies): Likewise.
(dwarf2_symbol_mark_computed): Likewise.
* elfread.c (elf_symfile_segments): Likewise.
(elf_read_minimal_symbols): Likewise.
* environ.c (make_environ): Likewise.
* eval.c (evaluate_subexp_standard): Likewise.
* event-loop.c (create_file_handler): Likewise.
(create_async_signal_handler): Likewise.
(create_async_event_handler): Likewise.
(create_timer): Likewise.
* exec.c (build_section_table): Likewise.
* fbsd-nat.c (fbsd_remember_child): Likewise.
* fork-child.c (fork_inferior): Likewise.
* frv-tdep.c (new_variant): Likewise.
* gdbarch.sh (gdbarch_alloc): Likewise.
(append_name): Likewise.
* gdbtypes.c (rank_function): Likewise.
(copy_type_recursive): Likewise.
(add_dyn_prop): Likewise.
* gnu-nat.c (make_proc): Likewise.
(make_inf): Likewise.
(gnu_write_inferior): Likewise.
* gnu-v3-abi.c (build_gdb_vtable_type): Likewise.
(build_std_type_info_type): Likewise.
* guile/scm-param.c (compute_enum_list): Likewise.
* guile/scm-utils.c (gdbscm_parse_function_args): Likewise.
* guile/scm-value.c (gdbscm_value_call): Likewise.
* h8300-tdep.c (h8300_gdbarch_init): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
(read_unwind_info): Likewise.
* ia64-tdep.c (ia64_gdbarch_init): Likewise.
* infcall.c (dummy_frame_context_saver_setup): Likewise.
(call_function_by_hand_dummy): Likewise.
* infcmd.c (step_once): Likewise.
(finish_forward): Likewise.
(attach_command): Likewise.
(notice_new_inferior): Likewise.
* inferior.c (add_inferior_silent): Likewise.
* infrun.c (add_displaced_stepping_state): Likewise.
(save_infcall_control_state): Likewise.
(save_inferior_ptid): Likewise.
(_initialize_infrun): Likewise.
* jit.c (bfd_open_from_target_memory): Likewise.
(jit_gdbarch_data_init): Likewise.
* language.c (add_language): Likewise.
* linespec.c (decode_line_2): Likewise.
* linux-nat.c (add_to_pid_list): Likewise.
(add_initial_lwp): Likewise.
* linux-thread-db.c (add_thread_db_info): Likewise.
(record_thread): Likewise.
(info_auto_load_libthread_db): Likewise.
* m32c-tdep.c (m32c_gdbarch_init): Likewise.
* m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise.
* m68k-tdep.c (m68k_gdbarch_init): Likewise.
* m88k-tdep.c (m88k_analyze_prologue): Likewise.
* macrocmd.c (macro_define_command): Likewise.
* macroexp.c (gather_arguments): Likewise.
* macroscope.c (sal_macro_scope): Likewise.
* macrotab.c (new_macro_table): Likewise.
* mdebugread.c (push_parse_stack): Likewise.
(parse_partial_symbols): Likewise.
(parse_symbol): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_block): Likewise.
(new_psymtab): Likewise.
(mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* mep-tdep.c (mep_gdbarch_init): Likewise.
* mi/mi-main.c (mi_execute_command): Likewise.
* mi/mi-parse.c (mi_parse_argv): Likewise.
* minidebug.c (lzma_open): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* mn10300-tdep.c (mn10300_gdbarch_init): Likewise.
* msp430-tdep.c (msp430_gdbarch_init): Likewise.
* mt-tdep.c (mt_registers_info): Likewise.
* nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise.
* nat/linux-btrace.c (linux_enable_bts): Likewise.
(linux_enable_pt): Likewise.
* nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise.
(linux_xfer_osdata_processgroups): Likewise.
* nios2-tdep.c (nios2_gdbarch_init): Likewise.
* nto-procfs.c (procfs_meminfo): Likewise.
* objc-lang.c (start_msglist): Likewise.
(selectors_info): Likewise.
(classes_info): Likewise.
(find_methods): Likewise.
* objfiles.c (allocate_objfile): Likewise.
(update_section_map): Likewise.
* osabi.c (gdbarch_register_osabi): Likewise.
(gdbarch_register_osabi_sniffer): Likewise.
* parse.c (start_arglist): Likewise.
* ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise.
(hwdebug_insert_point): Likewise.
* printcmd.c (display_command): Likewise.
(ui_printf): Likewise.
* procfs.c (create_procinfo): Likewise.
(load_syscalls): Likewise.
(proc_get_LDT_entry): Likewise.
(proc_update_threads): Likewise.
* prologue-value.c (make_pv_area): Likewise.
(pv_area_store): Likewise.
* psymtab.c (extend_psymbol_list): Likewise.
(init_psymbol_list): Likewise.
(allocate_psymtab): Likewise.
* python/py-inferior.c (add_thread_object): Likewise.
* python/py-param.c (compute_enum_values): Likewise.
* python/py-value.c (valpy_call): Likewise.
* python/py-varobj.c (py_varobj_iter_next): Likewise.
* python/python.c (ensure_python_env): Likewise.
* record-btrace.c (record_btrace_start_replaying): Likewise.
* record-full.c (record_full_reg_alloc): Likewise.
(record_full_mem_alloc): Likewise.
(record_full_end_alloc): Likewise.
(record_full_core_xfer_partial): Likewise.
* regcache.c (get_thread_arch_aspace_regcache): Likewise.
* remote-fileio.c (remote_fileio_init_fd_map): Likewise.
* remote-notif.c (remote_notif_state_allocate): Likewise.
* remote.c (demand_private_info): Likewise.
(remote_notif_stop_alloc_reply): Likewise.
(remote_enable_btrace): Likewise.
* reverse.c (save_bookmark_command): Likewise.
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
* rx-tdep.c (rx_gdbarch_init): Likewise.
* s390-linux-nat.c (s390_insert_watchpoint): Likewise.
* ser-go32.c (dos_get_tty_state): Likewise.
(dos_copy_tty_state): Likewise.
* ser-mingw.c (ser_windows_open): Likewise.
(ser_console_wait_handle): Likewise.
(ser_console_get_tty_state): Likewise.
(make_pipe_state): Likewise.
(net_windows_open): Likewise.
* ser-unix.c (hardwire_get_tty_state): Likewise.
(hardwire_copy_tty_state): Likewise.
* solib-aix.c (solib_aix_new_lm_info): Likewise.
* solib-dsbt.c (dsbt_current_sos): Likewise.
(dsbt_relocate_main_executable): Likewise.
* solib-frv.c (frv_current_sos): Likewise.
(frv_relocate_main_executable): Likewise.
* solib-spu.c (spu_bfd_fopen): Likewise.
* solib-svr4.c (lm_info_read): Likewise.
(svr4_copy_library_list): Likewise.
(svr4_default_sos): Likewise.
* source.c (find_source_lines): Likewise.
(line_info): Likewise.
(add_substitute_path_rule): Likewise.
* spu-linux-nat.c (spu_bfd_open): Likewise.
* spu-tdep.c (info_spu_dma_cmdlist): Likewise.
* stabsread.c (dbx_lookup_type): Likewise.
(read_type): Likewise.
(read_member_functions): Likewise.
(read_struct_fields): Likewise.
(read_baseclasses): Likewise.
(read_args): Likewise.
(_initialize_stabsread): Likewise.
* stack.c (func_command): Likewise.
* stap-probe.c (handle_stap_probe): Likewise.
* symfile.c (addrs_section_sort): Likewise.
(addr_info_make_relative): Likewise.
(load_section_callback): Likewise.
(add_symbol_file_command): Likewise.
(init_filename_language_table): Likewise.
* symtab.c (create_filename_seen_cache): Likewise.
(sort_search_symbols_remove_dups): Likewise.
(search_symbols): Likewise.
* target.c (make_cleanup_restore_target_terminal): Likewise.
* thread.c (new_thread): Likewise.
(enable_thread_stack_temporaries): Likewise.
(make_cleanup_restore_current_thread): Likewise.
(thread_apply_all_command): Likewise.
* tic6x-tdep.c (tic6x_gdbarch_init): Likewise.
* top.c (gdb_readline_wrapper): Likewise.
* tracefile-tfile.c (tfile_trace_file_writer_new): Likewise.
* tracepoint.c (trace_find_line_command): Likewise.
(all_tracepoint_actions_and_cleanup): Likewise.
(make_cleanup_restore_current_traceframe): Likewise.
(get_uploaded_tp): Likewise.
(get_uploaded_tsv): Likewise.
* tui/tui-data.c (tui_alloc_generic_win_info): Likewise.
(tui_alloc_win_info): Likewise.
(tui_alloc_content): Likewise.
(tui_add_content_elements): Likewise.
* tui/tui-disasm.c (tui_find_disassembly_address): Likewise.
(tui_set_disassem_content): Likewise.
* ui-file.c (ui_file_new): Likewise.
(stdio_file_new): Likewise.
(tee_file_new): Likewise.
* utils.c (make_cleanup_restore_integer): Likewise.
(add_internal_problem_command): Likewise.
* v850-tdep.c (v850_gdbarch_init): Likewise.
* valops.c (find_oload_champ): Likewise.
* value.c (allocate_value_lazy): Likewise.
(record_latest_value): Likewise.
(create_internalvar): Likewise.
* varobj.c (install_variable): Likewise.
(new_variable): Likewise.
(new_root_variable): Likewise.
(cppush): Likewise.
(_initialize_varobj): Likewise.
* windows-nat.c (windows_make_so): Likewise.
* x86-nat.c (x86_add_process): Likewise.
* xcoffread.c (arrange_linetable): Likewise.
(allocate_include_entry): Likewise.
(process_linenos): Likewise.
(SYMBOL_DUP): Likewise.
(xcoff_start_psymtab): Likewise.
(xcoff_end_psymtab): Likewise.
* xml-support.c (gdb_xml_parse_attr_ulongest): Likewise.
* xtensa-tdep.c (xtensa_register_type): Likewise.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
gdb/gdbserver/ChangeLog:
* ax.c (gdb_parse_agent_expr): Likewise.
(compile_bytecodes): Likewise.
* dll.c (loaded_dll): Likewise.
* event-loop.c (append_callback_event): Likewise.
(create_file_handler): Likewise.
(create_file_event): Likewise.
* hostio.c (handle_open): Likewise.
* inferiors.c (add_thread): Likewise.
(add_process): Likewise.
* linux-aarch64-low.c (aarch64_linux_new_process): Likewise.
* linux-arm-low.c (arm_new_process): Likewise.
(arm_new_thread): Likewise.
* linux-low.c (add_to_pid_list): Likewise.
(linux_add_process): Likewise.
(handle_extended_wait): Likewise.
(add_lwp): Likewise.
(enqueue_one_deferred_signal): Likewise.
(enqueue_pending_signal): Likewise.
(linux_resume_one_lwp_throw): Likewise.
(linux_resume_one_thread): Likewise.
(linux_read_memory): Likewise.
(linux_write_memory): Likewise.
* linux-mips-low.c (mips_linux_new_process): Likewise.
(mips_linux_new_thread): Likewise.
(mips_add_watchpoint): Likewise.
* linux-x86-low.c (initialize_low_arch): Likewise.
* lynx-low.c (lynx_add_process): Likewise.
* mem-break.c (set_raw_breakpoint_at): Likewise.
(set_breakpoint): Likewise.
(add_condition_to_breakpoint): Likewise.
(add_commands_to_breakpoint): Likewise.
(clone_agent_expr): Likewise.
(clone_one_breakpoint): Likewise.
* regcache.c (new_register_cache): Likewise.
* remote-utils.c (look_up_one_symbol): Likewise.
* server.c (queue_stop_reply): Likewise.
(start_inferior): Likewise.
(queue_stop_reply_callback): Likewise.
(handle_target_event): Likewise.
* spu-low.c (fetch_ppc_memory): Likewise.
(store_ppc_memory): Likewise.
* target.c (set_target_ops): Likewise.
* thread-db.c (thread_db_load_search): Likewise.
(try_thread_db_load_1): Likewise.
* tracepoint.c (add_tracepoint): Likewise.
(add_tracepoint_action): Likewise.
(create_trace_state_variable): Likewise.
(cmd_qtdpsrc): Likewise.
(cmd_qtro): Likewise.
(add_while_stepping_state): Likewise.
* win32-low.c (child_add_thread): Likewise.
(get_image_name): Likewise.
2015-08-26 23:16:07 +02:00
|
|
|
|
parm_types = XNEWVEC (struct type *, nparms);
|
2014-05-20 15:41:39 +02:00
|
|
|
|
for (jj = 0; jj < nparms; jj++)
|
|
|
|
|
parm_types[jj] = (fns_ptr != NULL
|
|
|
|
|
? (TYPE_FN_FIELD_ARGS (fns_ptr, ix)[jj].type)
|
|
|
|
|
: TYPE_FIELD_TYPE (SYMBOL_TYPE (oload_syms[ix]),
|
2014-11-01 04:20:48 +01:00
|
|
|
|
jj));
|
2000-03-13 11:01:23 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Compare parameter types to supplied argument types. Skip
|
|
|
|
|
THIS for static methods. */
|
|
|
|
|
bv = rank_function (parm_types, nparms,
|
2011-10-14 22:22:17 +02:00
|
|
|
|
args + static_offset,
|
2002-05-12 04:20:38 +02:00
|
|
|
|
nargs - static_offset);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
if (!*oload_champ_bv)
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
2004-02-02 21:44:53 +01:00
|
|
|
|
*oload_champ_bv = bv;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
oload_champ = 0;
|
|
|
|
|
}
|
2007-08-14 02:31:40 +02:00
|
|
|
|
else /* See whether current candidate is better or worse than
|
|
|
|
|
previous best. */
|
2004-02-02 21:44:53 +01:00
|
|
|
|
switch (compare_badness (bv, *oload_champ_bv))
|
1999-07-07 22:19:36 +02:00
|
|
|
|
{
|
2007-08-14 02:31:40 +02:00
|
|
|
|
case 0: /* Top two contenders are equally good. */
|
|
|
|
|
oload_ambiguous = 1;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
break;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
case 1: /* Incomparable top contenders. */
|
|
|
|
|
oload_ambiguous = 2;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
break;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
case 2: /* New champion, record details. */
|
|
|
|
|
*oload_champ_bv = bv;
|
1999-07-07 22:19:36 +02:00
|
|
|
|
oload_ambiguous = 0;
|
|
|
|
|
oload_champ = ix;
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-12-15 02:01:51 +01:00
|
|
|
|
xfree (parm_types);
|
2000-07-09 07:15:50 +02:00
|
|
|
|
if (overload_debug)
|
|
|
|
|
{
|
2014-05-20 15:41:39 +02:00
|
|
|
|
if (fns_ptr != NULL)
|
2007-08-14 02:31:40 +02:00
|
|
|
|
fprintf_filtered (gdb_stderr,
|
2011-01-05 23:22:53 +01:00
|
|
|
|
"Overloaded method instance %s, # of parms %d\n",
|
2007-08-14 02:31:40 +02:00
|
|
|
|
fns_ptr[ix].physname, nparms);
|
2014-05-20 15:41:39 +02:00
|
|
|
|
else if (xm_worker_vec != NULL)
|
|
|
|
|
fprintf_filtered (gdb_stderr,
|
|
|
|
|
"Xmethod worker, # of parms %d\n",
|
|
|
|
|
nparms);
|
2000-07-09 07:15:50 +02:00
|
|
|
|
else
|
2007-08-14 02:31:40 +02:00
|
|
|
|
fprintf_filtered (gdb_stderr,
|
2011-01-05 23:22:53 +01:00
|
|
|
|
"Overloaded function instance "
|
|
|
|
|
"%s # of parms %d\n",
|
2007-08-14 02:31:40 +02:00
|
|
|
|
SYMBOL_DEMANGLED_NAME (oload_syms[ix]),
|
|
|
|
|
nparms);
|
2002-05-12 04:20:38 +02:00
|
|
|
|
for (jj = 0; jj < nargs - static_offset; jj++)
|
2007-08-14 02:31:40 +02:00
|
|
|
|
fprintf_filtered (gdb_stderr,
|
|
|
|
|
"...Badness @ %d : %d\n",
|
2010-11-04 21:26:23 +01:00
|
|
|
|
jj, bv->rank[jj].rank);
|
2011-01-05 23:22:53 +01:00
|
|
|
|
fprintf_filtered (gdb_stderr, "Overload resolution "
|
|
|
|
|
"champion is %d, ambiguous? %d\n",
|
2007-08-14 02:31:40 +02:00
|
|
|
|
oload_champ, oload_ambiguous);
|
2000-07-09 07:15:50 +02:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
return oload_champ;
|
|
|
|
|
}
|
2000-07-09 07:15:50 +02:00
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
/* Return 1 if we're looking at a static method, 0 if we're looking at
|
|
|
|
|
a non-static method or a function that isn't a method. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
static int
|
2014-03-03 14:08:47 +01:00
|
|
|
|
oload_method_static_p (struct fn_field *fns_ptr, int index)
|
2004-02-02 21:44:53 +01:00
|
|
|
|
{
|
2014-03-03 14:08:47 +01:00
|
|
|
|
if (fns_ptr && index >= 0 && TYPE_FN_FIELD_STATIC_P (fns_ptr, index))
|
2004-02-02 21:44:53 +01:00
|
|
|
|
return 1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
2004-02-02 21:44:53 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-02-02 21:44:53 +01:00
|
|
|
|
/* Check how good an overload match OLOAD_CHAMP_BV represents. */
|
|
|
|
|
|
|
|
|
|
static enum oload_classification
|
|
|
|
|
classify_oload_match (struct badness_vector *oload_champ_bv,
|
|
|
|
|
int nargs,
|
|
|
|
|
int static_offset)
|
|
|
|
|
{
|
|
|
|
|
int ix;
|
2011-10-14 22:22:17 +02:00
|
|
|
|
enum oload_classification worst = STANDARD;
|
2004-02-02 21:44:53 +01:00
|
|
|
|
|
|
|
|
|
for (ix = 1; ix <= nargs - static_offset; ix++)
|
2002-01-04 18:51:38 +01:00
|
|
|
|
{
|
2010-11-04 21:26:23 +01:00
|
|
|
|
/* If this conversion is as bad as INCOMPATIBLE_TYPE_BADNESS
|
|
|
|
|
or worse return INCOMPATIBLE. */
|
|
|
|
|
if (compare_ranks (oload_champ_bv->rank[ix],
|
|
|
|
|
INCOMPATIBLE_TYPE_BADNESS) <= 0)
|
2007-08-14 02:31:40 +02:00
|
|
|
|
return INCOMPATIBLE; /* Truly mismatched types. */
|
2010-11-04 21:26:23 +01:00
|
|
|
|
/* Otherwise If this conversion is as bad as
|
|
|
|
|
NS_POINTER_CONVERSION_BADNESS or worse return NON_STANDARD. */
|
|
|
|
|
else if (compare_ranks (oload_champ_bv->rank[ix],
|
|
|
|
|
NS_POINTER_CONVERSION_BADNESS) <= 0)
|
2011-10-14 22:22:17 +02:00
|
|
|
|
worst = NON_STANDARD; /* Non-standard type conversions
|
2007-08-14 02:31:40 +02:00
|
|
|
|
needed. */
|
2002-01-04 18:51:38 +01:00
|
|
|
|
}
|
2002-07-10 19:18:16 +02:00
|
|
|
|
|
2011-10-14 22:22:17 +02:00
|
|
|
|
/* If no INCOMPATIBLE classification was found, return the worst one
|
|
|
|
|
that was found (if any). */
|
|
|
|
|
return worst;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* 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
|
2011-05-06 16:12:18 +02:00
|
|
|
|
inappropriate for TYPE, an error is signaled. Parameter TYPE should not yet
|
|
|
|
|
have CHECK_TYPEDEF applied, this function will apply it itself. */
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int
|
2011-05-06 16:12:18 +02:00
|
|
|
|
destructor_name_p (const char *name, struct type *type)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
if (name[0] == '~')
|
|
|
|
|
{
|
2011-05-06 16:12:18 +02:00
|
|
|
|
const char *dname = type_name_no_tag_or_error (type);
|
|
|
|
|
const char *cp = strchr (dname, '<');
|
1999-04-16 03:35:26 +02:00
|
|
|
|
unsigned int len;
|
|
|
|
|
|
|
|
|
|
/* Do not compare the template part for template classes. */
|
|
|
|
|
if (cp == NULL)
|
|
|
|
|
len = strlen (dname);
|
|
|
|
|
else
|
|
|
|
|
len = cp - dname;
|
2003-11-06 23:54:02 +01:00
|
|
|
|
if (strlen (name + 1) != len || strncmp (dname, name + 1, len) != 0)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("name of destructor must equal name of class"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-27 19:24:27 +01:00
|
|
|
|
/* Find an enum constant named NAME in TYPE. TYPE must be an "enum
|
|
|
|
|
class". If the name is found, return a value representing it;
|
|
|
|
|
otherwise throw an exception. */
|
|
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
|
enum_constant_from_type (struct type *type, const char *name)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int name_len = strlen (name);
|
|
|
|
|
|
|
|
|
|
gdb_assert (TYPE_CODE (type) == TYPE_CODE_ENUM
|
|
|
|
|
&& TYPE_DECLARED_CLASS (type));
|
|
|
|
|
|
|
|
|
|
for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); ++i)
|
|
|
|
|
{
|
|
|
|
|
const char *fname = TYPE_FIELD_NAME (type, i);
|
|
|
|
|
int len;
|
|
|
|
|
|
|
|
|
|
if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL
|
|
|
|
|
|| fname == NULL)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* Look for the trailing "::NAME", since enum class constant
|
|
|
|
|
names are qualified here. */
|
|
|
|
|
len = strlen (fname);
|
|
|
|
|
if (len + 2 >= name_len
|
|
|
|
|
&& fname[len - name_len - 2] == ':'
|
|
|
|
|
&& fname[len - name_len - 1] == ':'
|
|
|
|
|
&& strcmp (&fname[len - name_len], name) == 0)
|
|
|
|
|
return value_from_longest (type, TYPE_FIELD_ENUMVAL (type, i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error (_("no constant named \"%s\" in enum \"%s\""),
|
|
|
|
|
name, TYPE_TAG_NAME (type));
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-25 18:39:39 +02:00
|
|
|
|
/* C++: Given an aggregate type CURTYPE, and a member name NAME,
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
return the appropriate member (or the address of the member, if
|
|
|
|
|
WANT_ADDRESS). This function is used to resolve user expressions
|
|
|
|
|
of the form "DOMAIN::NAME". For more details on what happens, see
|
|
|
|
|
the comment before value_struct_elt_for_reference. */
|
2003-09-25 18:39:39 +02:00
|
|
|
|
|
|
|
|
|
struct value *
|
2014-03-27 19:16:38 +01:00
|
|
|
|
value_aggregate_elt (struct type *curtype, const char *name,
|
2009-11-10 23:17:58 +01:00
|
|
|
|
struct type *expect_type, int want_address,
|
2003-09-25 18:39:39 +02:00
|
|
|
|
enum noside noside)
|
|
|
|
|
{
|
|
|
|
|
switch (TYPE_CODE (curtype))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
|
|
|
|
case TYPE_CODE_UNION:
|
2007-08-14 02:31:40 +02:00
|
|
|
|
return value_struct_elt_for_reference (curtype, 0, curtype,
|
2009-11-10 23:17:58 +01:00
|
|
|
|
name, expect_type,
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
want_address, noside);
|
2003-09-25 18:39:39 +02:00
|
|
|
|
case TYPE_CODE_NAMESPACE:
|
2007-08-14 02:31:40 +02:00
|
|
|
|
return value_namespace_elt (curtype, name,
|
|
|
|
|
want_address, noside);
|
2014-03-27 19:24:27 +01:00
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ENUM:
|
|
|
|
|
return enum_constant_from_type (curtype, name);
|
|
|
|
|
|
2003-09-25 18:39:39 +02:00
|
|
|
|
default:
|
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
|
|
|
|
_("non-aggregate type in value_aggregate_elt"));
|
2003-09-25 18:39:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-10 23:17:58 +01:00
|
|
|
|
/* Compares the two method/function types T1 and T2 for "equality"
|
2011-02-26 03:07:10 +01:00
|
|
|
|
with respect to the methods' parameters. If the types of the
|
2009-11-10 23:17:58 +01:00
|
|
|
|
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
|
|
|
|
|
the first artificial parameter in T1, assumed to be a 'this' pointer.
|
|
|
|
|
|
|
|
|
|
The type T2 is expected to have come from make_params (in eval.c). */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
compare_parameters (struct type *t1, struct type *t2, int skip_artificial)
|
|
|
|
|
{
|
|
|
|
|
int start = 0;
|
|
|
|
|
|
2011-01-29 11:30:20 +01:00
|
|
|
|
if (TYPE_NFIELDS (t1) > 0 && TYPE_FIELD_ARTIFICIAL (t1, 0))
|
2009-11-10 23:17:58 +01:00
|
|
|
|
++start;
|
|
|
|
|
|
|
|
|
|
/* If skipping artificial fields, find the first real field
|
2011-01-12 02:23:29 +01:00
|
|
|
|
in T1. */
|
2009-11-10 23:17:58 +01:00
|
|
|
|
if (skip_artificial)
|
|
|
|
|
{
|
|
|
|
|
while (start < TYPE_NFIELDS (t1)
|
|
|
|
|
&& TYPE_FIELD_ARTIFICIAL (t1, start))
|
|
|
|
|
++start;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-12 02:23:29 +01:00
|
|
|
|
/* Now compare parameters. */
|
2009-11-10 23:17:58 +01:00
|
|
|
|
|
|
|
|
|
/* Special case: a method taking void. T1 will contain no
|
|
|
|
|
non-artificial fields, and T2 will contain TYPE_CODE_VOID. */
|
|
|
|
|
if ((TYPE_NFIELDS (t1) - start) == 0 && TYPE_NFIELDS (t2) == 1
|
|
|
|
|
&& TYPE_CODE (TYPE_FIELD_TYPE (t2, 0)) == TYPE_CODE_VOID)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if ((TYPE_NFIELDS (t1) - start) == TYPE_NFIELDS (t2))
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
2009-11-10 23:17:58 +01:00
|
|
|
|
for (i = 0; i < TYPE_NFIELDS (t2); ++i)
|
|
|
|
|
{
|
2010-11-04 21:26:23 +01:00
|
|
|
|
if (compare_ranks (rank_one_type (TYPE_FIELD_TYPE (t1, start + i),
|
2011-10-14 22:22:17 +02:00
|
|
|
|
TYPE_FIELD_TYPE (t2, i), NULL),
|
2010-11-04 21:26:23 +01:00
|
|
|
|
EXACT_MATCH_BADNESS) != 0)
|
2009-11-10 23:17:58 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* C++: Given an aggregate type CURTYPE, and a member name NAME,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
return the address of this member as a "pointer to member" type.
|
|
|
|
|
If INTYPE is non-null, then it will be the type of the member we
|
|
|
|
|
are looking for. This will help us resolve "pointers to member
|
|
|
|
|
functions". This function is used to resolve user expressions of
|
|
|
|
|
the form "DOMAIN::NAME". */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
static struct value *
|
2000-07-30 03:48:28 +02:00
|
|
|
|
value_struct_elt_for_reference (struct type *domain, int offset,
|
2014-03-27 19:16:38 +01:00
|
|
|
|
struct type *curtype, const char *name,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
struct type *intype,
|
|
|
|
|
int want_address,
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
enum noside noside)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-14 18:32:14 +02:00
|
|
|
|
struct type *t = curtype;
|
|
|
|
|
int i;
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
struct value *v, *result;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
|
if (TYPE_CODE (t) != TYPE_CODE_STRUCT
|
1999-04-16 03:35:26 +02:00
|
|
|
|
&& TYPE_CODE (t) != TYPE_CODE_UNION)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("Internal error: non-aggregate type "
|
|
|
|
|
"to value_struct_elt_for_reference"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); i--)
|
|
|
|
|
{
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
|
|
|
|
const char *t_field_name = TYPE_FIELD_NAME (t, i);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2003-11-08 01:13:03 +01:00
|
|
|
|
if (t_field_name && strcmp (t_field_name, name) == 0)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
Convert static_kind into loc_kind enum.
* gdbtypes.h (enum field_loc_kind): New.
(union field_location): New field dwarf_block.
(struct field): Rename static_kind as loc_kind.
(FIELD_STATIC_KIND): Rename to ...
(FIELD_LOC_KIND): ... here.
(TYPE_FIELD_STATIC_KIND): Rename to ...
(TYPE_FIELD_LOC_KIND): ... here and use there now new FIELD_LOC_KIND.
(TYPE_FIELD_STATIC_HAS_ADDR): Remove.
(TYPE_FIELD_STATIC): Remove.
(TYPE_FIELD_BITPOS): Reformat.
(SET_FIELD_BITPOS): New.
(FIELD_PHYSADDR): Rename to ...
(FIELD_STATIC_PHYSADDR): ... here.
(TYPE_FIELD_STATIC_PHYSADDR): Follow the FIELD_PHYSADDR rename.
(SET_FIELD_PHYSADDR): Use new FIELD_LOC_KIND.
(FIELD_PHYSNAME): Rename to ...
(FIELD_STATIC_PHYSNAME): ... here.
(TYPE_FIELD_STATIC_PHYSNAME): Follow the FIELD_PHYSNAME rename.
(SET_FIELD_PHYSNAME): Use new FIELD_LOC_KIND.
(FIELD_DWARF_BLOCK, TYPE_FIELD_DWARF_BLOCK, SET_FIELD_DWARF_BLOCK): New.
(field_is_static): New declaration.
* gdbtypes.c (field_is_static): New function.
(copy_type_recursive): Update throughout.
* amd64-tdep.c, c-typeprint.c, coffread.c, cp-valprint.c, dwarf2read.c,
eval.c, jv-typeprint.c, jv-valprint.c, mdebugread.c, p-typeprint.c,
p-valprint.c, valops.c, value.c, varobj.c: Update throughout.
2008-10-08 14:49:13 +02:00
|
|
|
|
if (field_is_static (&TYPE_FIELD (t, i)))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
v = value_static_field (t, i);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
if (want_address)
|
|
|
|
|
v = value_addr (v);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
if (TYPE_FIELD_PACKED (t, i))
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("pointers to bitfield members not allowed"));
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
if (want_address)
|
|
|
|
|
return value_from_longest
|
|
|
|
|
(lookup_memberptr_type (TYPE_FIELD_TYPE (t, i), domain),
|
|
|
|
|
offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
|
2013-11-25 22:37:08 +01:00
|
|
|
|
else if (noside != EVAL_NORMAL)
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
return allocate_value (TYPE_FIELD_TYPE (t, i));
|
|
|
|
|
else
|
2013-11-25 22:37:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Try to evaluate NAME as a qualified name with implicit
|
|
|
|
|
this pointer. In this case, attempt to return the
|
|
|
|
|
equivalent to `this->*(&TYPE::NAME)'. */
|
|
|
|
|
v = value_of_this_silent (current_language);
|
|
|
|
|
if (v != NULL)
|
|
|
|
|
{
|
|
|
|
|
struct value *ptr;
|
|
|
|
|
long mem_offset;
|
|
|
|
|
struct type *type, *tmp;
|
|
|
|
|
|
|
|
|
|
ptr = value_aggregate_elt (domain, name, NULL, 1, noside);
|
|
|
|
|
type = check_typedef (value_type (ptr));
|
|
|
|
|
gdb_assert (type != NULL
|
|
|
|
|
&& TYPE_CODE (type) == TYPE_CODE_MEMBERPTR);
|
2015-02-01 06:17:05 +01:00
|
|
|
|
tmp = lookup_pointer_type (TYPE_SELF_TYPE (type));
|
2013-11-25 22:37:08 +01:00
|
|
|
|
v = value_cast_pointers (tmp, v, 1);
|
|
|
|
|
mem_offset = value_as_long (ptr);
|
|
|
|
|
tmp = lookup_pointer_type (TYPE_TARGET_TYPE (type));
|
|
|
|
|
result = value_from_pointer (tmp,
|
|
|
|
|
value_as_long (v) + mem_offset);
|
|
|
|
|
return value_ind (result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
error (_("Cannot reference non-static field \"%s\""), name);
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* C++: If it was not found as a data field, then try to return it
|
|
|
|
|
as a pointer to a method. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
/* Perform all necessary dereferencing. */
|
|
|
|
|
while (intype && TYPE_CODE (intype) == TYPE_CODE_PTR)
|
|
|
|
|
intype = TYPE_TARGET_TYPE (intype);
|
|
|
|
|
|
|
|
|
|
for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i)
|
|
|
|
|
{
|
* gdbtypes.h (struct main_type): Change type of name,tag_name,
and fields.name members from char * to const char *. All uses updated.
(struct cplus_struct_type): Change type of fn_fieldlists.name member
from char * to const char *. All uses updated.
(type_name_no_tag): Update.
(lookup_unsigned_typename, lookup_signed_typename): Update.
* gdbtypes.c (type_name_no_tag): Change result type
from char * to const char *. All callers updated.
(lookup_unsigned_typename, lookup_signed_typename): Change type of
name parameter from char * to const char *.
* symtab.h (struct cplus_specific): Change type of demangled_name
member from char * to const char *. All uses updated.
(struct general_symbol_info): Change type of name and
mangled_lang.demangled_name members from char * to const char *.
All uses updated.
(symbol_get_demangled_name, symbol_natural_name): Update.
(symbol_demangled_name, symbol_search_name): Update.
* symtab.c (symbol_get_demangled_name): Change result type
from char * to const char *. All callers updated.
(symbol_natural_name, symbol_demangled_name): Ditto.
(symbol_search_name): Ditto.
(completion_list_add_name): Change type of symname,sym_text,
text,word parameters from char * to const char *.
(completion_list_objc_symbol): Change type of sym_text,
text,word parameters from char * to const char *.
* ada-lang.c (find_struct_field): Change type of name parameter
from char * to const char *.
(encoded_ordered_before): Similarly for N0,N1 parameters.
(old_renaming_is_invisible): Similarly for function_name parameter.
(ada_type_name): Change result type from char * to const char *.
All callers updated.
* ada-lang.h (ada_type_name): Update.
* buildsym.c (hashname): Change type of name parameter
from char * to const char *.
* buildsym.h (hashname): Update.
* dbxread.c (end_psymtab): Change type of include_list parameter
from char ** to const char **.
* dwarf2read.c (determine_prefix): Change result type
from char * to const char *. All callers updated.
* f-lang.c (find_common_for_function): Change type of name, funcname
parameters from char * to const char *.
* f-lang.c (find_common_for_function): Update.
* f-valprint.c (list_all_visible_commons): Change type of funcname
parameters from char * to const char *.
* gdbarch.sh (static_transform_name): Change type of name parameter
and result from char * to const char *.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* i386-sol2-tdep.c (i386_sol2_static_transform_name): Change type
of name parameter from char * to const char *.
* jv-lang.c (java_primitive_type_from_name): Ditto.
(java_demangled_signature_length): Similarly for signature parameter.
(java_demangled_signature_copy): Ditto.
(java_demangle_type_signature): Ditto.
* jv-lang.h (java_primitive_type_from_name): Update.
(java_demangle_type_signature): Update.
* objc-lang.c (specialcmp): Change type of a,b parameters
from char * to const char *.
* p-lang.c (is_pascal_string_type): Change type of arrayname parameter
from char * to const char *. All callers updated.
* p-lang.h (is_pascal_string_type): Update.
* solib-frv.c (find_canonical_descriptor_in_load_object): Change type
of name parameter from char * to const char *.
* sparc-sol2-tdep.c (sparc_sol2_static_transform_name): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* defs.h (fprintf_symbol_filtered): Update.
* sparc-tdep.h (sparc_sol2_static_transform_name): Update.
* stabsread.h (end_psymtab): Update.
* stack.c (find_frame_funname): Change type of funname parameter
from char ** to const char **.
* stack.h (find_frame_funname): Update.
* typeprint.c (type_print): Change type of varstring parameter
from char * to const char *.
* value.h (type_print): Update.
* xcoffread.c (xcoff_start_psymtab): Change type of filename parameter
from char * to const char *. All callers updated.
(xcoff_end_psymtab): Change type of include_list parameter
from char ** to const char **. All callers updated.
(swap_sym): Similarly for name parameter. All callers updated.
* coffread.c (patch_type): Add (char*) cast to xfree parameter.
Use xstrdup.
(process_coff_symbol): Use xstrdup.
* stabsread.c (stabs_method_name_from_physname): Renamed from
update_method_name_from_physname. Change result type from void
to char *. All callers updated.
(read_member_functions): In has_destructor case, store name in objfile
obstack instead of malloc space. In !has_stub case, fix mem leak.
2012-02-07 05:48:23 +01:00
|
|
|
|
const char *t_field_name = TYPE_FN_FIELDLIST_NAME (t, i);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
char dem_opname[64];
|
|
|
|
|
|
2015-03-06 10:42:06 +01:00
|
|
|
|
if (startswith (t_field_name, "__")
|
|
|
|
|
|| startswith (t_field_name, "op")
|
|
|
|
|
|| startswith (t_field_name, "type"))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2007-08-14 02:31:40 +02:00
|
|
|
|
if (cplus_demangle_opname (t_field_name,
|
|
|
|
|
dem_opname, DMGL_ANSI))
|
1999-07-07 22:19:36 +02:00
|
|
|
|
t_field_name = dem_opname;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
else if (cplus_demangle_opname (t_field_name,
|
|
|
|
|
dem_opname, 0))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
t_field_name = dem_opname;
|
|
|
|
|
}
|
2003-11-08 01:13:03 +01:00
|
|
|
|
if (t_field_name && strcmp (t_field_name, name) == 0)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2009-11-10 23:17:58 +01:00
|
|
|
|
int j;
|
|
|
|
|
int len = TYPE_FN_FIELDLIST_LENGTH (t, i);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2002-09-14 04:09:39 +02:00
|
|
|
|
check_stub_method_group (t, i);
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (intype)
|
|
|
|
|
{
|
2009-11-10 23:17:58 +01:00
|
|
|
|
for (j = 0; j < len; ++j)
|
|
|
|
|
{
|
Make "p S::method() const::static_var" work too
Trying to print a function local static variable of a const-qualified
method still doesn't work after the previous fixes:
(gdb) p 'S::method() const'::static_var
$1 = {i1 = 1, i2 = 2, i3 = 3}
(gdb) p S::method() const::static_var
No symbol "static_var" in specified context.
The reason is that the expression parser/evaluator loses the "const",
and the above unquoted case is just like trying to print a variable of
the non-const overload, if it exists, even. As if the above unquoted
case had been written as:
(gdb) p S::method()::static_var
No symbol "static_var" in specified context.
We can see the problem without static vars in the picture. With:
struct S
{
void method ();
void method () const;
};
Compare:
(gdb) print 'S::method(void) const'
$1 = {void (const S * const)} 0x400606 <S::method() const>
(gdb) print S::method(void) const
$2 = {void (S * const)} 0x4005d8 <S::method()> # wrong method!
That's what we need to fix. If we fix that, the function local static
case starts working.
The grammar production for function/method types is this one:
exp: exp '(' parameter_typelist ')' const_or_volatile
This results in a TYPE_INSTANCE expression evaluator operator. For
the example above, we get something like this ("set debug expression 1"):
...
0 TYPE_INSTANCE 1 TypeInstance: Type @0x560fda958be0 (void)
5 OP_SCOPE Type @0x560fdaa544d8 (S) Field name: `method'
...
While evaluating TYPE_INSTANCE, we end up in
value_struct_elt_for_reference, trying to find the method named
"method" that has the prototype recorded in TYPE_INSTANCE. In this
case, TYPE_INSTANCE says that we're looking for a method that has
"(void)" as parameters (that's what "1 TypeInstance: Type
@0x560fda958be0 (void)" above means. The trouble is that nowhere in
this mechanism do we communicate to value_struct_elt_for_reference
that we're looking for the _const_ overload.
value_struct_elt_for_reference only compared parameters, and the
non-const "method()" overload has matching parameters, so it's
considered the right match...
Conveniently, the "const_or_volatile" production in the grammar
already records "const" and "volatile" info in the type stack. The
type stack is not used in this code path, but we can borrow the
information. The patch converts the info in the type stack to an
"instance flags" enum, and adds that as another element in
TYPE_INSTANCE operators. This type instance flags is then applied to
the temporary type that is passed to value_struct_elt_for_reference
for matching.
The other side of the problem is that methods in the debug info aren't
marked const/volatile, so with that in place, the matching never finds
const/volatile-qualified methods.
The problem is that in the DWARF, there's no indication at all whether
a method is const/volatile qualified... For example (c++filt applied
to the linkage name for convenience):
<2><d3>: Abbrev Number: 6 (DW_TAG_subprogram)
<d4> DW_AT_external : 1
<d4> DW_AT_name : (indirect string, offset: 0x3df): method
<d8> DW_AT_decl_file : 1
<d9> DW_AT_decl_line : 58
<da> DW_AT_linkage_name: (indirect string, offset: 0x5b2): S::method() const
<de> DW_AT_declaration : 1
<de> DW_AT_object_pointer: <0xe6>
<e2> DW_AT_sibling : <0xec>
I see the same with both GCC and Clang. The patch works around this
by extracting the cv qualification from the "const" and "volatile" in
the demangled name. This will need further tweaking for "&" and
"const &" overloads, but we don't support them in the parser yet,
anyway.
The TYPE_CONST changes were necessary otherwise the comparisons in valops.c:
if (TYPE_CONST (intype) != TYPE_FN_FIELD_CONST (f, j))
continue;
would fail, because when both TYPE_CONST() TYPE_FN_FIELD_CONST() were
true, their values were different.
BTW, I'm recording the const/volatile-ness of methods in the
TYPE_FN_FIELD info because #1 - I'm not sure it's kosher to change the
method's type directly (vs having to call make_cv_type to create a new
type), and #2 it's what stabsread.c does:
...
case 'A': /* Normal functions. */
new_sublist->fn_field.is_const = 0;
new_sublist->fn_field.is_volatile = 0;
(*pp)++;
break;
case 'B': /* `const' member functions. */
new_sublist->fn_field.is_const = 1;
new_sublist->fn_field.is_volatile = 0;
...
After all this, this finally all works:
print S::method(void) const
$1 = {void (const S * const)} 0x400606 <S::method() const>
(gdb) p S::method() const::static_var
$2 = {i1 = 1, i2 = 2, i3 = 3}
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* c-exp.y (function_method, function_method_void): Add current
instance flags to TYPE_INSTANCE.
* dwarf2read.c (check_modifier): New.
(compute_delayed_physnames): Assert that only C++ adds delayed
physnames. Mark fn_fields as const/volatile depending on
physname.
* eval.c (make_params): New type_instance_flags parameter. Use
it as the new type's instance flags.
(evaluate_subexp_standard) <TYPE_INSTANCE>: Extract the instance
flags element and pass it to make_params.
* expprint.c (print_subexp_standard) <TYPE_INSTANCE>: Handle
instance flags element.
(dump_subexp_body_standard) <TYPE_INSTANCE>: Likewise.
* gdbtypes.h: Include "enum-flags.h".
(type_instance_flags): New enum-flags type.
(TYPE_CONST, TYPE_VOLATILE, TYPE_RESTRICT, TYPE_ATOMIC)
(TYPE_CODE_SPACE, TYPE_DATA_SPACE): Return boolean.
* parse.c (operator_length_standard) <TYPE_INSTANCE>: Adjust.
(follow_type_instance_flags): New function.
(operator_check_standard) <TYPE_INSTANCE>: Adjust.
* parser-defs.h (follow_type_instance_flags): Declare.
* valops.c (value_struct_elt_for_reference): const/volatile must
match too.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/func-static.c (S::method const, S::method volatile)
(S::method volatile const): New methods.
(c_s, v_s, cv_s): New instances.
(main): Call method() on them.
* gdb.base/func-static.exp (syntax_re, cannot_resolve_re): New variables.
(cannot_resolve): New procedure.
(cxx_scopes_list): Test cv methods. Add print-scope-quote and
print-quote-unquoted columns.
(do_test): Test printing each scope too.
2017-09-04 21:21:16 +02:00
|
|
|
|
if (TYPE_CONST (intype) != TYPE_FN_FIELD_CONST (f, j))
|
|
|
|
|
continue;
|
|
|
|
|
if (TYPE_VOLATILE (intype) != TYPE_FN_FIELD_VOLATILE (f, j))
|
|
|
|
|
continue;
|
|
|
|
|
|
2009-11-10 23:17:58 +01:00
|
|
|
|
if (compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype, 0)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
|| compare_parameters (TYPE_FN_FIELD_TYPE (f, j),
|
|
|
|
|
intype, 1))
|
2009-11-10 23:17:58 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (j == len)
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("no member function matches "
|
|
|
|
|
"that type instantiation"));
|
2009-12-04 21:26:33 +01:00
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
2009-11-10 23:17:58 +01:00
|
|
|
|
{
|
|
|
|
|
int ii;
|
2009-12-04 21:26:33 +01:00
|
|
|
|
|
|
|
|
|
j = -1;
|
2011-03-29 19:04:31 +02:00
|
|
|
|
for (ii = 0; ii < len; ++ii)
|
2009-11-10 23:17:58 +01:00
|
|
|
|
{
|
2009-12-04 21:26:33 +01:00
|
|
|
|
/* Skip artificial methods. This is necessary if,
|
|
|
|
|
for example, the user wants to "print
|
|
|
|
|
subclass::subclass" with only one user-defined
|
2011-03-29 19:04:31 +02:00
|
|
|
|
constructor. There is no ambiguity in this case.
|
|
|
|
|
We are careful here to allow artificial methods
|
|
|
|
|
if they are the unique result. */
|
2009-11-10 23:17:58 +01:00
|
|
|
|
if (TYPE_FN_FIELD_ARTIFICIAL (f, ii))
|
2011-03-29 19:04:31 +02:00
|
|
|
|
{
|
|
|
|
|
if (j == -1)
|
|
|
|
|
j = ii;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2009-11-10 23:17:58 +01:00
|
|
|
|
|
2009-12-04 21:26:33 +01:00
|
|
|
|
/* Desired method is ambiguous if more than one
|
|
|
|
|
method is defined. */
|
2011-03-29 19:04:31 +02:00
|
|
|
|
if (j != -1 && !TYPE_FN_FIELD_ARTIFICIAL (f, j))
|
2011-01-05 23:22:53 +01:00
|
|
|
|
error (_("non-unique member `%s' requires "
|
|
|
|
|
"type instantiation"), name);
|
2009-11-10 23:17:58 +01:00
|
|
|
|
|
2009-12-04 21:26:33 +01:00
|
|
|
|
j = ii;
|
|
|
|
|
}
|
2011-03-29 19:04:31 +02:00
|
|
|
|
|
|
|
|
|
if (j == -1)
|
|
|
|
|
error (_("no matching member function"));
|
2009-11-10 23:17:58 +01:00
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
if (TYPE_FN_FIELD_STATIC_P (f, j))
|
|
|
|
|
{
|
2007-08-14 02:31:40 +02:00
|
|
|
|
struct symbol *s =
|
|
|
|
|
lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
0, VAR_DOMAIN, 0).symbol;
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
if (s == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if (want_address)
|
2015-02-05 17:00:06 +01:00
|
|
|
|
return value_addr (read_var_value (s, 0, 0));
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
else
|
2015-02-05 17:00:06 +01:00
|
|
|
|
return read_var_value (s, 0, 0);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
|
|
|
|
|
{
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
if (want_address)
|
|
|
|
|
{
|
|
|
|
|
result = allocate_value
|
|
|
|
|
(lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
|
2008-09-11 16:24:28 +02:00
|
|
|
|
cplus_make_method_ptr (value_type (result),
|
|
|
|
|
value_contents_writeable (result),
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
TYPE_FN_FIELD_VOFFSET (f, j), 1);
|
|
|
|
|
}
|
|
|
|
|
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
|
|
|
|
return allocate_value (TYPE_FN_FIELD_TYPE (f, j));
|
|
|
|
|
else
|
|
|
|
|
error (_("Cannot reference virtual member function \"%s\""),
|
|
|
|
|
name);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-08-14 02:31:40 +02:00
|
|
|
|
struct symbol *s =
|
|
|
|
|
lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
0, VAR_DOMAIN, 0).symbol;
|
2010-05-17 20:48:52 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (s == NULL)
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
return NULL;
|
|
|
|
|
|
2015-02-05 17:00:06 +01:00
|
|
|
|
v = read_var_value (s, 0, 0);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
if (!want_address)
|
|
|
|
|
result = v;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
|
2008-09-11 16:24:28 +02:00
|
|
|
|
cplus_make_method_ptr (value_type (result),
|
|
|
|
|
value_contents_writeable (result),
|
2009-05-28 02:53:52 +02:00
|
|
|
|
value_address (v), 0);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
return result;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i = TYPE_N_BASECLASSES (t) - 1; i >= 0; i--)
|
|
|
|
|
{
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *v;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int base_offset;
|
|
|
|
|
|
|
|
|
|
if (BASETYPE_VIA_VIRTUAL (t, i))
|
|
|
|
|
base_offset = 0;
|
|
|
|
|
else
|
|
|
|
|
base_offset = TYPE_BASECLASS_BITPOS (t, i) / 8;
|
|
|
|
|
v = value_struct_elt_for_reference (domain,
|
|
|
|
|
offset + base_offset,
|
|
|
|
|
TYPE_BASECLASS (t, i),
|
2007-08-14 02:31:40 +02:00
|
|
|
|
name, intype,
|
|
|
|
|
want_address, noside);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (v)
|
|
|
|
|
return v;
|
|
|
|
|
}
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
|
|
|
|
|
/* As a last chance, pretend that CURTYPE is a namespace, and look
|
|
|
|
|
it up that way; this (frequently) works for types nested inside
|
|
|
|
|
classes. */
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
return value_maybe_namespace_elt (curtype, name,
|
|
|
|
|
want_address, noside);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-25 18:39:39 +02:00
|
|
|
|
/* C++: Return the member NAME of the namespace given by the type
|
|
|
|
|
CURTYPE. */
|
|
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
|
value_namespace_elt (const struct type *curtype,
|
2014-03-27 19:16:38 +01:00
|
|
|
|
const char *name, int want_address,
|
2003-09-25 18:39:39 +02:00
|
|
|
|
enum noside noside)
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
{
|
|
|
|
|
struct value *retval = value_maybe_namespace_elt (curtype, name,
|
2007-08-14 02:31:40 +02:00
|
|
|
|
want_address,
|
|
|
|
|
noside);
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
|
|
|
|
|
if (retval == NULL)
|
2007-08-14 02:31:40 +02:00
|
|
|
|
error (_("No symbol \"%s\" in namespace \"%s\"."),
|
|
|
|
|
name, TYPE_TAG_NAME (curtype));
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A helper function used by value_namespace_elt and
|
|
|
|
|
value_struct_elt_for_reference. It looks up NAME inside the
|
|
|
|
|
context CURTYPE; this works if CURTYPE is a namespace or if CURTYPE
|
|
|
|
|
is a class and NAME refers to a type in CURTYPE itself (as opposed
|
|
|
|
|
to, say, some base class of CURTYPE). */
|
|
|
|
|
|
|
|
|
|
static struct value *
|
|
|
|
|
value_maybe_namespace_elt (const struct type *curtype,
|
2014-03-27 19:16:38 +01:00
|
|
|
|
const char *name, int want_address,
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
enum noside noside)
|
2003-09-25 18:39:39 +02:00
|
|
|
|
{
|
|
|
|
|
const char *namespace_name = TYPE_TAG_NAME (curtype);
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
struct block_symbol sym;
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
struct value *result;
|
2003-09-25 18:39:39 +02:00
|
|
|
|
|
2010-03-15 18:29:36 +01:00
|
|
|
|
sym = cp_lookup_symbol_namespace (namespace_name, name,
|
2010-06-28 22:35:52 +02:00
|
|
|
|
get_selected_block (0), VAR_DOMAIN);
|
|
|
|
|
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
if (sym.symbol == NULL)
|
2004-01-14 David Carlton <carlton@kealia.com>
Change symbols for C++ nested types to contain the fully qualified
name, if possible. (At least in the DWARF-2 case.) Partial fix
for PR's c++/57, c++/488, c++/539, c++/573, c++/609, c++/832,
c++/895.
* c-exp.y: Update copyright:
(qualified_type): Handle types nested within classes.
* cp-namespace.c: Update comments.
(cp_set_block_scope): Delete #if 0.
(cp_lookup_nested_type): Handle types nested within classes.
* dwarf2read.c: (scan_partial_symbols): Call add_partial_structure
when appropriate.
(add_partial_symbol): Add the name of the enclosing namespace to
types.
(pdi_needs_namespace): New.
(add_partial_namespace): Tweak comment.
(add_partial_structure): New.
(psymtab_to_symtab_1): Initialize processing_current_prefix
here...
(process_die): instead of here.
(read_structure_scope): Try to figure out the name of the class or
namespace that the structure might be defined within.
(read_enumeration): Generate fully-qualified names, if possible.
(read_namespace): Don't set name to NULL.
(die_specification): New.
(new_symbol): Generate fully-qualified names for types.
(read_type_die): Determine appropriate prefix.
(determine_prefix): New.
(typename_concat): New.
(class_name): New.
* valops.c: Update copyright.
(value_aggregate_elt): Pass NOSIDE to
value_struct_elt_for_reference.
(value_struct_elt_for_reference): Make static, add NOSIDE
parameter, call value_maybe_namespace_elt as a last resort.
(value_namespace_elt): Break out code into
value_maybe_namespace_elt.
(value_maybe_namespace_elt): New.
2004-01-14 David Carlton <carlton@kealia.com>
* gdb.cp/namespace.exp: Add tests involving classes defined within
namespaces.
* gdb.cp/namespace.cc (C::CClass): New.
* gdb.cp/namespace1.cc: Update copyright.
(C::OtherFileClass): New.
2004-01-14 17:54:43 +01:00
|
|
|
|
return NULL;
|
2003-09-25 18:39:39 +02:00
|
|
|
|
else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
&& (SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF))
|
|
|
|
|
result = allocate_value (SYMBOL_TYPE (sym.symbol));
|
2003-09-25 18:39:39 +02:00
|
|
|
|
else
|
Replace the block_found global with explicit data-flow
As Pedro suggested on gdb-patches@ (see
https://sourceware.org/ml/gdb-patches/2015-05/msg00714.html), this
change makes symbol lookup functions return a structure that includes
both the symbol found and the block in which it was found. This makes
it possible to get rid of the block_found global variable and thus makes
block hunting explicit.
gdb/
* ada-exp.y (write_object_renaming): Replace struct
ada_symbol_info with struct block_symbol. Update field
references accordingly.
(block_lookup, select_possible_type_sym): Likewise.
(find_primitive_type): Likewise. Also update call to
ada_lookup_symbol to extract the symbol itself.
(write_var_or_type, write_name_assoc): Likewise.
* ada-lang.h (struct ada_symbol_info): Remove.
(ada_lookup_symbol_list): Replace struct ada_symbol_info with
struct block_symbol.
(ada_lookup_encoded_symbol, user_select_syms): Likewise.
(ada_lookup_symbol): Return struct block_symbol instead of a
mere symbol.
* ada-lang.c (defns_collected): Replace struct ada_symbol_info
with struct block_symbol.
(resolve_subexp, ada_resolve_function, sort_choices,
user_select_syms, is_nonfunction, add_defn_to_vec,
num_defns_collected, defns_collected,
symbols_are_identical_enums, remove_extra_symbols,
remove_irrelevant_renamings, add_lookup_symbol_list_worker,
ada_lookup_symbol_list, ada_iterate_over_symbols,
ada_lookup_encoded_symbol, get_var_value): Likewise.
(ada_lookup_symbol): Return a block_symbol instead of a mere
symbol. Replace struct ada_symbol_info with struct
block_symbol.
(ada_lookup_symbol_nonlocal): Likewise.
(standard_lookup): Make block passing explicit through
lookup_symbol_in_language.
* ada-tasks.c (get_tcb_types_info): Update the calls to
lookup_symbol_in_language to extract the mere symbol out of the
returned value.
(ada_tasks_inferior_data_sniffer): Likewise.
* ax-gdb.c (gen_static_field): Likewise for the call to
lookup_symbol.
(gen_maybe_namespace_elt): Deal with struct symbol_in_block from
lookup functions.
(gen_expr): Likewise.
* c-exp.y: Likewise. Remove uses of block_found.
(lex_one_token, classify_inner_name, c_print_token): Likewise.
(classify_name): Likewise. Rename the "sym" local variable to
"bsym".
* c-valprint.c (print_unpacked_pointer): Likewise.
* compile/compile-c-symbols.c (convert_symbol_sym): Promote the
"sym" parameter from struct symbol * to struct block_symbol.
Use it to remove uses of block_found. Deal with struct
symbol_in_block from lookup functions.
(gcc_convert_symbol): Likewise. Update the call to
convert_symbol_sym.
* compile/compile-object-load.c (compile_object_load): Deal with
struct symbol_in_block from lookup functions.
* cp-namespace.c (cp_lookup_nested_symbol_1,
cp_lookup_nested_symbol, cp_lookup_bare_symbol,
cp_search_static_and_baseclasses,
cp_lookup_symbol_in_namespace, cp_lookup_symbol_via_imports,
cp_lookup_symbol_imports_or_template,
cp_lookup_symbol_via_all_imports, cp_lookup_symbol_namespace,
lookup_namespace_scope, cp_lookup_nonlocal,
find_symbol_in_baseclass): Return struct symbol_in_block instead
of mere symbols and deal with struct symbol_in_block from lookup
functions.
* cp-support.c (inspect_type, replace_typedefs,
cp_lookup_rtti_type): Deal with struct symbol_in_block from
lookup functions.
* cp-support.h (cp_lookup_symbol_nonlocal,
cp_lookup_symbol_from_namespace,
cp_lookup_symbol_imports_or_template, cp_lookup_nested_symbol):
Return struct symbol_in_block instead of mere symbols.
* d-exp.y (d_type_from_name, d_module_from_name, push_variable,
push_module_name):
Deal with struct symbol_in_block from lookup functions. Remove
uses of block_found.
* eval.c (evaluate_subexp_standard): Update call to
cp_lookup_symbol_namespace.
* f-exp.y: Deal with struct symbol_in_block from lookup
functions. Remove uses of block_found.
(yylex): Likewise.
* gdbtypes.c (lookup_typename, lookup_struct, lookup_union,
lookup_enum, lookup_template_type, check_typedef): Deal with
struct symbol_in_block from lookup functions.
* guile/scm-frame.c (gdbscm_frame_read_var): Likewise.
* guile/scm-symbol.c (gdbscm_lookup_symbol): Likewise.
(gdbscm_lookup_global_symbol): Likewise.
* gnu-v3-abi.c (gnuv3_get_typeid_type): Likewise.
* go-exp.y: Likewise. Remove uses of block_found.
(package_name_p, classify_packaged_name, classify_name):
Likewise.
* infrun.c (insert_exception_resume_breakpoint): Likewise.
* jv-exp.y (push_variable): Likewise.
* jv-lang.c (java_lookup_class, get_java_object_type): Likewise.
* language.c (language_bool_type): Likewise.
* language.h (struct language_defn): Update
la_lookup_symbol_nonlocal to return a struct symbol_in_block
rather than a mere symbol.
* linespec.c (find_label_symbols): Deal with struct
symbol_in_block from lookup functions.
* m2-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* mi/mi-cmd-stack.c (list_args_or_locals): Likewise.
* objc-lang.c (lookup_struct_typedef, find_imps): Likewise.
* p-exp.y: Likewise. Remove uses of block_found.
(yylex): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
* parse.c (write_dollar_variable): Likewise. Remove uses of
block_found.
* parser-defs.h (struct symtoken): Turn the SYM field into a
struct symbol_in_block.
* printcmd.c (address_info): Deal with struct symbol_in_block
from lookup functions.
* python/py-frame.c (frapy_read_var): Likewise.
* python/py-symbol.c (gdbpy_lookup_symbol,
gdbpy_lookup_global_symbol): Likewise.
* skip.c (skip_function_command): Likewise.
* solib-darwin.c (darwin_lookup_lib_symbol): Return a struct
symbol_in_block instead of a mere symbol.
* solib-spu.c (spu_lookup_lib_symbol): Likewise.
* solib-svr4.c (elf_lookup_lib_symbol): Likewise.
* solib.c (solib_global_lookup): Likewise.
* solist.h (solib_global_lookup): Likewise.
(struct target_so_ops): Update lookup_lib_global_symbol to
return a struct symbol_in_block rather than a mere symbol.
* source.c (select_source_symtab): Deal with struct
symbol_in_block from lookup functions.
* stack.c (print_frame_args, iterate_over_block_arg_vars):
Likewise.
* symfile.c (set_initial_language): Likewise.
* symtab.c (SYMBOL_LOOKUP_FAILED): Turn into a struct
symbol_in_block.
(SYMBOL_LOOKUP_FAILED_P): New predicate as a macro.
(struct symbol_cache_slot): Turn the FOUND field into a struct
symbol_in_block.
(block_found): Remove.
(eq_symbol_entry): Update to deal with struct symbol_in_block in
cache slots.
(symbol_cache_lookup): Return a struct symbol_in_block rather
than a mere symbol.
(symbol_cache_mark_found): Add a BLOCK parameter to fill
appropriately the cache slots. Update callers.
(symbol_cache_dump): Update cache slots handling to the type
change.
(lookup_symbol_in_language, lookup_symbol, lookup_language_this,
lookup_symbol_aux, lookup_local_symbol,
lookup_symbol_in_objfile, lookup_global_symbol_from_objfile,
lookup_symbol_in_objfile_symtabs,
lookup_symbol_in_objfile_from_linkage_name,
lookup_symbol_via_quick_fns, basic_lookup_symbol_nonlocal,
lookup_symbol_in_static_block, lookup_static_symbol,
lookup_global_symbol):
Return a struct symbol_in_block rather than a mere symbol. Deal
with struct symbol_in_block from other lookup functions. Remove
uses of block_found.
(lookup_symbol_in_block): Remove uses of block_found.
(struct global_sym_lookup_data): Turn the RESULT field into a
struct symbol_in_block.
(lookup_symbol_global_iterator_cb): Update references to the
RESULT field.
(search_symbols): Deal with struct symbol_in_block from lookup
functions.
* symtab.h (struct symbol_in_block): New structure.
(block_found): Remove.
(lookup_symbol_in_language, lookup_symbol,
basic_lookup_symbol_nonlocal, lookup_symbol_in_static_block,
looku_static_symbol, lookup_global_symbol,
lookup_symbol_in_block, lookup_language_this,
lookup_global_symbol_from_objfile): Return a struct
symbol_in_block rather than just a mere symbol. Update comments
to remove mentions of block_found.
* valops.c (find_function_in_inferior,
value_struct_elt_for_reference, value_maybe_namespace_elt,
value_of_this): Deal with struct symbol_in_block from lookup
functions.
* value.c (value_static_field, value_fn_field): Likewise.
2015-07-21 17:02:15 +02:00
|
|
|
|
result = value_of_variable (sym.symbol, sym.block);
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
|
2014-12-13 08:25:46 +01:00
|
|
|
|
if (want_address)
|
* NEWS: Mention pointer to member improvements.
* Makefile.in (gnu-v3-abi.o): Delete special rule.
(eval.o, gnu-v3-abi.o, ia64-tdep.o): Update.
* ada-valprint.c (ada_print_scalar): Update for new type codes.
* c-typeprint.c (c_print_type): Update for new type codes.
(c_type_print_varspec_prefix, c_type_print_varspec_suffix)
(c_type_print_base): Likewise.
(c_type_print_args): Rewrite.
* c-valprint.c (c_val_print): Update for new type codes. Remove
support for references to members. Treat methods like functions.
* cp-abi.c (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New.
* cp-abi.h (cplus_print_method_ptr, cplus_method_ptr_size)
(cplus_make_method_ptr, cplus_method_ptr_to_value): New prototypes.
(struct cp_abi_ops): Add corresponding members.
* cp-valprint.c (cp_print_class_method): Delete.
(cp_find_class_member): New function.
(cp_print_class_member): Use it. Simplify support for bogus
member pointers.
* dwarf2read.c (quirk_gcc_member_function_pointer): Use
lookup_methodptr_type.
(read_tag_ptr_to_member_type): Likewise, and lookup_memberptr_type.
* eval.c (evaluate_subexp_standard): Implement EVAL_SKIP for
OP_SCOPE. Update call to value_aggregate_elt. Rewrite member
pointer support.
(evaluate_subexp_for_address): Handle OP_SCOPE explicitly. Handle
references returned by user defined operators.
* f-typeprint.c (f_print_type, f_type_print_varspec_prefix)
(f_type_print_varspec_suffix): Remove support for member pointers.
* gdbtypes.c (lookup_memberptr_type): Renamed from lookup_member_type
and adjusted.
(smash_to_memberptr_type): Likewise, from smash_to_member_type.
(lookup_methodptr_type): New.
(rank_one_type): Adjust for TYPE_CODE_MEMBERPTR.
(recursive_dump_type): Update for new types.
* gdbtypes.h (enum type_code): Replace TYPE_CODE_MEMBER with
TYPE_CODE_MEMBERPTR and TYPE_CODE_METHODPTR.
(lookup_memberptr_type, lookup_methodptr_type)
(smash_to_memberptr_type): New prototypes.
(smash_to_method_type): Formatting fix.
(lookup_member_type, smash_to_member_type): Delete prototypes.
* gnu-v3-abi.c (gnuv3_get_vtable, gnuv3_get_virtual_fn): New.
Do not rely on debug information for the vptr or the method's
enclosing type. Handle function descriptors for IA64.
(gnuv3_virtual_fn_field): Rewrite using the new functions.
(gnuv3_find_method_in, gnuv3_print_method_ptr)
(gnuv3_method_ptr_size, gnuv3_make_method_ptr)
(gnuv3_method_ptr_to_value): New.
(init_gnuv3_ops): Set new members of gnu_v3_abi_ops.
* hpread.c (hpread_type_lookup): Update for new types.
* infcall.c (value_arg_coerce): Likewise.
* m2-typeprint.c (m2_print_type): Remove explicit support
for member pointers.
* m2-valprint.c (m2_val_print): Likewise.
* p-typeprint.c (pascal_type_print_varspec_prefix)
(pascal_type_print_varspec_suffix, pascal_type_print_base): Likewise.
* p-valprint.c (pascal_val_print): Likewise.
(pascal_object_print_class_method, pascal_object_print_class_member):
Delete.
* p-lang.h (pascal_object_print_class_method)
(pascal_object_print_class_member): Delete prototypes.
* stabsread.c (read_type): Update for new types.
* typeprint.c (print_type_scalar): Likewise.
* valops.c (value_struct_elt_for_reference, value_namespace_elt)
(value_maybe_namespace_elt, value_aggregate_elt): Add want_address
argument. Construct a pointer to member if the address of a
function or data member is requested.
(value_cast_pointers): Don't modify the input value.
(value_cast): Adjust pointer to member handling for new types.
Allow null pointer to member constants. Don't modify the input
value.
(value_ind): Remove pointer to member check. Handle function
descriptors for function pointers.
(value_struct_elt, value_find_oload_method_list, check_field):
Remove pointer to member checks.
* value.c (unpack_long): Allow pointers to data members.
(value_from_longest): Allow member pointers.
* value.h (value_aggregate_elt): Add want_address.
* varobj.c (c_variable_editable): Remove check for members.
* gdbarch.sh: Add vtable_function_descriptors and vbit_in_delta.
* ia64-tdep.c (ia64_convert_from_func_ptr_addr): Handle descriptors
in virtual tables.
(ia64_gdbarch_init): Call set_gdbarch_vtable_function_descriptors.
* c-lang.h (cp_print_class_method): Delete prototype.
* arm-tdep.c (arm_gdbarch_init): Call set_gdbarch_vbit_in_delta.
* mips-tdep.c (mips_gdbarch_init): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* gdb.cp/classes.exp (test_pointers_to_class_members): Update expected
output. Test the types of members and member pointers.
* gdb.cp/inherit.exp (test_print_mi_member_types): Remove KFAILs for
gdb/2092.
* gdb.cp/member-ptr.exp: Search for a comment instead of a
statement. Enable for GCC. Update expected output for some tests
and add new tests. Remove obsolete GCC KFAILs. Allow GCC's class
layout.
* gdb.cp/member-ptr.cc (Padding, Padding::vspacer, Base, Base::get_x)
(Base::vget_base, Left, Left::vget, Right, Right::vget, Diamond)
(Diamond::vget_base): New.
(main): Add new tests.
* gdb.cp/printmethod.exp: Update expected output for member functions.
* gdb.cp/virtfunc.exp (test_virtual_calls): Add a KFAIL for
print pEe->D::vg().
2007-01-03 19:05:45 +01:00
|
|
|
|
result = value_addr (result);
|
|
|
|
|
|
|
|
|
|
return result;
|
2003-09-25 18:39:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-21 14:48:59 +01:00
|
|
|
|
/* Given a pointer or a reference value V, find its real (RTTI) type.
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
Other parameters FULL, TOP, USING_ENC as with value_rtti_type()
|
2007-08-14 02:31:40 +02:00
|
|
|
|
and refer to the values computed for the object pointed to. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
struct type *
|
2012-02-21 14:48:59 +01:00
|
|
|
|
value_rtti_indirect_type (struct value *v, int *full,
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST *top, int *using_enc)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2015-01-23 18:59:24 +01:00
|
|
|
|
struct value *target = NULL;
|
2012-02-21 14:48:59 +01:00
|
|
|
|
struct type *type, *real_type, *target_type;
|
|
|
|
|
|
|
|
|
|
type = value_type (v);
|
|
|
|
|
type = check_typedef (type);
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
if (TYPE_IS_REFERENCE (type))
|
2012-02-21 14:48:59 +01:00
|
|
|
|
target = coerce_ref (v);
|
|
|
|
|
else if (TYPE_CODE (type) == TYPE_CODE_PTR)
|
2015-01-23 18:59:24 +01:00
|
|
|
|
{
|
|
|
|
|
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 16:14:14 +01:00
|
|
|
|
TRY
|
2015-01-23 18:59:24 +01:00
|
|
|
|
{
|
|
|
|
|
target = value_ind (v);
|
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 16:14:14 +01:00
|
|
|
|
CATCH (except, RETURN_MASK_ERROR)
|
2015-01-23 18:59:24 +01:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 16:14:14 +01:00
|
|
|
|
END_CATCH
|
2015-01-23 18:59:24 +01:00
|
|
|
|
}
|
2012-02-21 14:48:59 +01:00
|
|
|
|
else
|
|
|
|
|
return NULL;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2012-02-21 14:48:59 +01:00
|
|
|
|
real_type = value_rtti_type (target, full, top, using_enc);
|
|
|
|
|
|
|
|
|
|
if (real_type)
|
|
|
|
|
{
|
|
|
|
|
/* Copy qualifiers to the referenced object. */
|
|
|
|
|
target_type = value_type (target);
|
|
|
|
|
real_type = make_cv_type (TYPE_CONST (target_type),
|
|
|
|
|
TYPE_VOLATILE (target_type), real_type, NULL);
|
Convert lvalue reference type check to general reference type check
In almost all contexts (except for overload resolution rules and expression
semantics), lvalue and rvalue references are equivalent. That means that in all
but these cases we can replace a TYPE_CODE_REF check to a TYPE_IS_REFERENCE
check and, for switch statements, add a case label for a rvalue reference type
next to a case label for an lvalue reference type. This patch does exactly
that.
gdb/ChangeLog
PR gdb/14441
* aarch64-tdep.c (aarch64_type_align)
(aarch64_extract_return_value, aarch64_store_return_value): Change
lvalue reference type checks to general reference type checks.
* amd64-tdep.c (amd64_classify): Likewise.
* amd64-windows-tdep.c (amd64_windows_passed_by_integer_register):
Likewise.
* arm-tdep.c (arm_type_align, arm_extract_return_value)
(arm_store_return_value): Likewise.
* ax-gdb.c (gen_fetch, gen_cast): Likewise.
* c-typeprint.c (c_print_type): Likewise.
* c-varobj.c (adjust_value_for_child_access, c_value_of_variable)
(cplus_number_of_children, cplus_describe_child): Likewise.
* compile/compile-c-symbols.c (generate_vla_size): Likewise.
* completer.c (expression_completer): Likewise.
* cp-support.c (make_symbol_overload_list_adl_namespace):
Likewise.
* darwin-nat-info.c (info_mach_region_command): Likewise.
* dwarf2loc.c (entry_data_value_coerce_ref)
(value_of_dwarf_reg_entry): Likewise.
* eval.c (ptrmath_type_p, evaluate_subexp_standard)
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof):
Likewise.
* findvar.c (extract_typed_address, store_typed_address):
Likewise.
* gdbtypes.c (rank_one_type): Likewise.
* hppa-tdep.c (hppa64_integral_or_pointer_p): Likewise.
* infcall.c (value_arg_coerce): Likewise.
* language.c (pointer_type): Likewise.
* m32c-tdep.c (m32c_reg_arg_type, m32c_m16c_address_to_pointer):
Likewise.
* m88k-tdep.c (m88k_integral_or_pointer_p): Likewise.
* mn10300-tdep.c (mn10300_type_align): Likewise.
* msp430-tdep.c (msp430_push_dummy_call): Likewise.
* ppc-sysv-tdep.c (do_ppc_sysv_return_value)
(ppc64_sysv_abi_push_param, ppc64_sysv_abi_return_value):
Likewise.
* printcmd.c (print_formatted, x_command): Likewise.
* python/py-type.c (typy_get_composite, typy_template_argument):
Likewise.
* python/py-value.c (valpy_referenced_value)
(valpy_get_dynamic_type, value_has_field): Likewise.
* s390-linux-tdep.c (s390_function_arg_integer): Likewise.
* sparc-tdep.c (sparc_integral_or_pointer_p): Likewise.
* sparc64-tdep.c (sparc64_integral_or_pointer_p): Likewise.
* spu-tdep.c (spu_scalar_value_p): Likewise.
* symtab.c (lookup_symbol_aux): Likewise.
* typeprint.c (whatis_exp, print_type_scalar): Likewise.
* valarith.c (binop_types_user_defined_p, unop_user_defined_p):
Likewise.
* valops.c (value_cast_pointers, value_cast)
(value_reinterpret_cast, value_dynamic_cast, value_addr, typecmp)
(value_struct_elt, value_struct_elt_bitpos)
(value_find_oload_method_list, find_overload_match)
(value_rtti_indirect_type): Likewise.
* valprint.c (val_print_scalar_type_p, generic_val_print):
Likewise.
* value.c (value_actual_type, value_as_address, unpack_long)
(pack_long, pack_unsigned_long, coerce_ref_if_computed)
(coerce_ref): Likewise.
* varobj.c (varobj_get_value_type): Likewise.
2017-03-20 21:47:54 +01:00
|
|
|
|
if (TYPE_IS_REFERENCE (type))
|
|
|
|
|
real_type = lookup_reference_type (real_type, TYPE_CODE (type));
|
2012-02-21 14:48:59 +01:00
|
|
|
|
else if (TYPE_CODE (type) == TYPE_CODE_PTR)
|
|
|
|
|
real_type = lookup_pointer_type (real_type);
|
|
|
|
|
else
|
|
|
|
|
internal_error (__FILE__, __LINE__, _("Unexpected value type."));
|
|
|
|
|
|
|
|
|
|
/* Copy qualifiers to the pointer/reference. */
|
|
|
|
|
real_type = make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type),
|
|
|
|
|
real_type, NULL);
|
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2012-02-21 14:48:59 +01:00
|
|
|
|
return real_type;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Given a value pointed to by ARGP, check its real run-time type, and
|
|
|
|
|
if that is different from the enclosing type, create a new value
|
|
|
|
|
using the real run-time type as the enclosing type (and of the same
|
|
|
|
|
type as ARGP) and return it, with the embedded offset adjusted to
|
2007-08-14 02:31:40 +02:00
|
|
|
|
be the correct offset to the enclosed object. RTYPE is the type,
|
|
|
|
|
and XFULL, XTOP, and XUSING_ENC are the other parameters, computed
|
|
|
|
|
by value_rtti_type(). If these are available, they can be supplied
|
|
|
|
|
and a second call to value_rtti_type() is avoided. (Pass RTYPE ==
|
|
|
|
|
NULL if they're not available. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2007-08-14 02:31:40 +02:00
|
|
|
|
value_full_object (struct value *argp,
|
|
|
|
|
struct type *rtype,
|
|
|
|
|
int xfull, int xtop,
|
2000-07-30 03:48:28 +02:00
|
|
|
|
int xusing_enc)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
1999-07-07 22:19:36 +02:00
|
|
|
|
struct type *real_type;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int full = 0;
|
2016-04-12 21:02:57 +02:00
|
|
|
|
LONGEST top = -1;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
int using_enc = 0;
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *new_val;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
if (rtype)
|
|
|
|
|
{
|
|
|
|
|
real_type = rtype;
|
|
|
|
|
full = xfull;
|
|
|
|
|
top = xtop;
|
|
|
|
|
using_enc = xusing_enc;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
real_type = value_rtti_type (argp, &full, &top, &using_enc);
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* If no RTTI data, or if object is already complete, do nothing. */
|
2005-02-02 21:31:35 +01:00
|
|
|
|
if (!real_type || real_type == value_enclosing_type (argp))
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return argp;
|
|
|
|
|
|
2011-11-09 20:50:15 +01:00
|
|
|
|
/* 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
|
|
|
|
|
&& TYPE_LENGTH (real_type) < TYPE_LENGTH (value_enclosing_type (argp)))
|
|
|
|
|
return argp;
|
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* If we have the full object, but for some reason the enclosing
|
2007-08-14 02:31:40 +02:00
|
|
|
|
type is wrong, set it. */
|
|
|
|
|
/* pai: FIXME -- sounds iffy */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (full)
|
|
|
|
|
{
|
2010-11-10 18:47:23 +01:00
|
|
|
|
argp = value_copy (argp);
|
|
|
|
|
set_value_enclosing_type (argp, real_type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return argp;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-12 02:23:29 +01:00
|
|
|
|
/* Check if object is in memory. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (VALUE_LVAL (argp) != lval_memory)
|
|
|
|
|
{
|
2011-01-05 23:22:53 +01:00
|
|
|
|
warning (_("Couldn't retrieve complete object of RTTI "
|
|
|
|
|
"type %s; object may be in register(s)."),
|
2007-08-14 02:31:40 +02:00
|
|
|
|
TYPE_NAME (real_type));
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return argp;
|
|
|
|
|
}
|
1999-07-07 22:19:36 +02:00
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* All other cases -- retrieve the complete object. */
|
|
|
|
|
/* Go back by the computed top_offset from the beginning of the
|
|
|
|
|
object, adjusting for the embedded offset of argp if that's what
|
|
|
|
|
value_rtti_type used for its computation. */
|
2009-05-28 02:53:52 +02:00
|
|
|
|
new_val = value_at_lazy (real_type, value_address (argp) - top +
|
2005-02-07 18:06:29 +01:00
|
|
|
|
(using_enc ? 0 : value_embedded_offset (argp)));
|
2005-02-07 Andrew Cagney <cagney@gnu.org>
* value.h (deprecated_set_value_type): Declare.
* value.c (deprecated_set_value_type): Define.
* hpacc-abi.c, gnu-v2-abi.c, cp-valprint.c: Update.
* c-valprint.c, jv-lang.c, objc-lang.c, ada-lang.c: Update.
* infcall.c, printcmd.c, valops.c, eval.c, p-exp.y: Update.
* ax-gdb.c, tracepoint.c: Update.
2005-02-08 00:51:03 +01:00
|
|
|
|
deprecated_set_value_type (new_val, value_type (argp));
|
2005-02-07 18:06:29 +01:00
|
|
|
|
set_value_embedded_offset (new_val, (using_enc
|
|
|
|
|
? top + value_embedded_offset (argp)
|
|
|
|
|
: top));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return new_val;
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-19 05:58:41 +02:00
|
|
|
|
|
2011-09-08 16:54:20 +02:00
|
|
|
|
/* Return the value of the local variable, if one exists. Throw error
|
|
|
|
|
otherwise, such as if the request is made in an inappropriate context. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2011-09-08 16:54:20 +02:00
|
|
|
|
value_of_this (const struct language_defn *lang)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2015-02-05 17:00:06 +01:00
|
|
|
|
struct block_symbol sym;
|
constify struct block in some places
This makes some spots in gdb, particularly general_symbol_info, use a
"const struct block", then fixes the fallout.
The justification is that, ordinarily, blocks ought to be readonly.
Note though that we can't add "const" in the blockvector due to block
relocation. This can be done once blocks are made independent of the
program space.
2014-06-18 Tom Tromey <tromey@redhat.com>
* varobj.c (varobj_create): Update.
* valops.c (value_of_this): Update.
* tracepoint.c (add_local_symbols, scope_info): Update.
* symtab.h (struct general_symbol_info) <block>: Now const.
* symtab.c (skip_prologue_sal)
(default_make_symbol_completion_list_break_on)
(skip_prologue_using_sal): Update.
* stack.h (iterate_over_block_locals)
(iterate_over_block_local_vars): Update.
* stack.c (print_frame_args): Update.
(iterate_over_block_locals, iterate_over_block_local_vars): Make
parameter const.
(get_selected_block): Make return type const.
* python/py-frame.c (frapy_block): Update.
* python/py-block.c (gdbpy_block_for_pc): Update.
* p-exp.y (%union) <bval>: Now const.
* mi/mi-cmd-stack.c (list_args_or_locals): Update.
* mdebugread.c (mylookup_symbol, parse_procedure): Update.
* m2-exp.y (%union) <bval>: Now const.
* linespec.c (get_current_search_block): Make return type const.
(create_sals_line_offset, find_label_symbols): Update.
* inline-frame.c (inline_frame_sniffer, skip_inline_frames):
Update.
(block_starting_point_at): Make "block" const.
* infrun.c (insert_exception_resume_breakpoint): Make "b" const.
(check_exception_resume): Update.
* guile/scm-frame.c (gdbscm_frame_block): Update.
* guile/scm-block.c (gdbscm_lookup_block): Update.
* frame.h (get_frame_block): Update.
(get_selected_block): Make return type const.
* frame.c (frame_id_inner): Update.
* f-valprint.c (info_common_command_for_block)
(info_common_command): Update.
* dwarf2loc.c (dwarf2_find_location_expression)
(dwarf_expr_frame_base, dwarf2_compile_expr_to_ax)
(locexpr_describe_location_piece): Update.
* c-exp.y (%union) <bval>: Now const.
* breakpoint.c (resolve_sal_pc): Update.
* blockframe.c (get_frame_block):Make return type const.
(get_pc_function_start, get_frame_function, find_pc_sect_function)
(block_innermost_frame): Update.
* block.h (blockvector_for_pc, blockvector_for_pc_sect)
(block_for_pc, block_for_pc_sect): Update.
* block.c (blockvector_for_pc_sect, blockvector_for_pc): Make
'pblock' const.
(block_for_pc_sect, block_for_pc): Make return type const.
* ax-gdb.c (gen_expr): Update.
* alpha-mdebug-tdep.c (find_proc_desc): Update.
* ada-lang.c (ada_read_renaming_var_value): Make 'block' const.
(ada_make_symbol_completion_list, ada_add_exceptions_from_frame)
(ada_read_var_value): Update.
* ada-exp.y (struct name_info) <block>: Now const.
(%union): Likewise.
(block_lookup): Constify.
2013-03-12 16:51:37 +01:00
|
|
|
|
const struct block *b;
|
* frame.c (deprecated_selected_frame): Rename to...
(selected_frame): ...this. Make static.
(get_selected_frame, select_frame): Update.
* frame.h (deprected_select_frame): Delete.
(deprecated_safe_get_selected_frame): Update comments.
* breakpoint.c, cli/cli-cmds.c, f-valprint.c, infcmd.c, inflow.c,
infrun.c, stack.c, tui/tui-disasm.c, tui/tui-source.c,
tui/tui-winsource.c, valops.c, varobj.c, findvar.c, macroscope.c,
parse.c, regcache.h, sh64-tdep.c, tui/tui-hooks.c, tui/tui-win.c,
tui/tui.c: Replace references to deprecated_selected_frame.
2007-02-27 20:46:04 +01:00
|
|
|
|
struct frame_info *frame;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2011-06-17 22:46:47 +02:00
|
|
|
|
if (!lang->la_name_of_this)
|
2011-09-08 16:54:20 +02:00
|
|
|
|
error (_("no `this' in current language"));
|
2011-06-17 22:24:22 +02:00
|
|
|
|
|
2011-09-08 16:54:20 +02:00
|
|
|
|
frame = get_selected_frame (_("no frame selected"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2011-06-17 22:46:47 +02:00
|
|
|
|
b = get_frame_block (frame, NULL);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2015-02-05 17:00:06 +01:00
|
|
|
|
sym = lookup_language_this (lang, b);
|
|
|
|
|
if (sym.symbol == NULL)
|
2011-09-08 16:54:20 +02:00
|
|
|
|
error (_("current stack frame does not contain a variable named `%s'"),
|
|
|
|
|
lang->la_name_of_this);
|
|
|
|
|
|
2015-02-05 17:00:06 +01:00
|
|
|
|
return read_var_value (sym.symbol, sym.block, frame);
|
2011-09-08 16:54:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the value of the local variable, if one exists. Return NULL
|
|
|
|
|
otherwise. Never throw error. */
|
|
|
|
|
|
|
|
|
|
struct value *
|
|
|
|
|
value_of_this_silent (const struct language_defn *lang)
|
|
|
|
|
{
|
|
|
|
|
struct value *ret = NULL;
|
|
|
|
|
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 16:14:14 +01:00
|
|
|
|
TRY
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2011-09-08 16:54:20 +02:00
|
|
|
|
ret = value_of_this (lang);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 16:14:14 +01:00
|
|
|
|
CATCH (except, RETURN_MASK_ERROR)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
END_CATCH
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-10-14 04:02:42 +02:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* 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. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
|
|
|
|
value_slice (struct value *array, int lowbound, int length)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
struct type *slice_range_type, *slice_type, *range_type;
|
2002-11-22 17:32:45 +01:00
|
|
|
|
LONGEST lowerbound, upperbound;
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *slice;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
struct type *array_type;
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
array_type = check_typedef (value_type (array));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (TYPE_CODE (array_type) != TYPE_CODE_ARRAY
|
2012-08-16 09:36:28 +02:00
|
|
|
|
&& TYPE_CODE (array_type) != TYPE_CODE_STRING)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("cannot take slice of non-array"));
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
range_type = TYPE_INDEX_TYPE (array_type);
|
|
|
|
|
if (get_discrete_bounds (range_type, &lowerbound, &upperbound) < 0)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("slice from bad array or bitstring"));
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
if (lowbound < lowerbound || length < 0
|
2002-08-01 Andrew Cagney <cagney@redhat.com>
* NEWS: Menion that CHILL has been made obsolete.
* gdbtypes.c (chill_varying_type): Make chill references obsolete.
* gdbserver/Makefile.in: Ditto.
* stabsread.c (read_range_type): Ditto.
* gdbtypes.h: Ditto.
* language.c (binop_type_check): Ditto.
(binop_result_type): Ditto.
(integral_type): Ditto.
(character_type): Ditto.
(string_type): Ditto.
(boolean_type): Ditto.
(structured_type): Ditto.
(lang_bool_type): Ditto.
(binop_type_check): Ditto.
* language.h (_LANG_chill): Ditto.
* dwarfread.c (set_cu_language): Ditto.
* dwarfread.c (CHILL_PRODUCER): Ditto.
* dwarfread.c (handle_producer): Ditto.
* expression.h (enum exp_opcode): Ditto.
* eval.c: Ditto for comments.
* typeprint.c (typedef_print) [_LANG_chill]: Ditto.
* expprint.c (print_subexp): Ditto.
(print_subexp): Ditto.
* valops.c (value_cast): Ditto.
(search_struct_field): Ditto.
* value.h (COERCE_VARYING_ARRAY): Ditto.
* symfile.c (init_filename_language_table): Ditto.
(add_psymbol_with_dem_name_to_list): Ditto.
* valarith.c (value_binop): Ditto.
(value_neg): Ditto.
* valops.c (value_slice): Ditto.
* symtab.h (union language_specific): Ditto.
(SYMBOL_INIT_LANGUAGE_SPECIFIC): Ditto.
(SYMBOL_DEMANGLED_NAME): Ditto.
(SYMBOL_CHILL_DEMANGLED_NAME): Ditto.
* defs.h (enum language): Ditto.
* symtab.c (got_symtab): Ditto.
* utils.c (fprintf_symbol_filtered): Ditto.
* ch-typeprint.c: Make file obsolete.
* ch-valprint.c: Make file obsolete.
* ch-lang.h: Make file obsolete.
* ch-exp.c: Make file obsolete.
* ch-lang.c: Make file obsolete.
* Makefile.in (FLAGS_TO_PASS): Do not pass CHILL or CHILLFLAGS or
CHILL_LIB.
(TARGET_FLAGS_TO_PASS): Ditto.
(CHILLFLAGS): Obsolete.
(CHILL): Obsolete.
(CHILL_FOR_TARGET): Obsolete.
(CHILL_LIB): Obsolete.
(SFILES): Remove ch-exp.c, ch-lang.c, ch-typeprint.c and
ch-valprint.c.
(HFILES_NO_SRCDIR): Remove ch-lang.h.
(COMMON_OBS): Remove ch-valprint.o, ch-typeprint.o, ch-exp.o and
ch-lang.o.
(ch-exp.o, ch-lang.o, ch-typeprint.o, ch-valprint.o): Delete
targets.
2002-08-01 Andrew Cagney <cagney@redhat.com>
* stabs.texinfo, gdb.texinfo, gdbint.texinfo: Obsolete references
to CHILL.
2002-08-01 Andrew Cagney <cagney@redhat.com>
* Makefile.in (TARGET_FLAGS_TO_PASS): Remove CHILLFLAGS, CHILL,
CHILL_FOR_TARGET and CHILL_LIB.
* configure.in (configdirs): Remove gdb.chill.
* configure: Regenerate.
* lib/gdb.exp: Obsolete references to chill.
* gdb.fortran/types.exp: Ditto.
* gdb.fortran/exprs.exp: Ditto.
2002-08-01 19:18:35 +02:00
|
|
|
|
|| lowbound + length - 1 > upperbound)
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("slice out of range"));
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
/* FIXME-type-allocation: need a way to free this type when we are
|
|
|
|
|
done with it. */
|
2013-12-19 09:31:17 +01:00
|
|
|
|
slice_range_type = create_static_range_type ((struct type *) NULL,
|
|
|
|
|
TYPE_TARGET_TYPE (range_type),
|
|
|
|
|
lowbound,
|
|
|
|
|
lowbound + length - 1);
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
2014-01-29 11:25:18 +01:00
|
|
|
|
{
|
|
|
|
|
struct type *element_type = TYPE_TARGET_TYPE (array_type);
|
|
|
|
|
LONGEST offset
|
|
|
|
|
= (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type));
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
2014-01-29 11:25:18 +01:00
|
|
|
|
slice_type = create_array_type ((struct type *) NULL,
|
|
|
|
|
element_type,
|
|
|
|
|
slice_range_type);
|
|
|
|
|
TYPE_CODE (slice_type) = TYPE_CODE (array_type);
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
2014-01-29 11:25:18 +01:00
|
|
|
|
if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
|
|
|
|
|
slice = allocate_value_lazy (slice_type);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
slice = allocate_value (slice_type);
|
|
|
|
|
value_contents_copy (slice, 0, array, offset,
|
2015-07-28 17:01:50 +02:00
|
|
|
|
type_length_units (slice_type));
|
2014-01-29 11:25:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set_value_component_location (slice, array);
|
|
|
|
|
set_value_offset (slice, value_offset (array) + offset);
|
|
|
|
|
}
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return slice;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Create a value for a FORTRAN complex number. Currently most of the
|
|
|
|
|
time values are coerced to COMPLEX*16 (i.e. a complex number
|
2000-04-04 06:53:50 +02:00
|
|
|
|
composed of 2 doubles. This really should be a smarter routine
|
|
|
|
|
that figures out precision inteligently as opposed to assuming
|
2007-08-14 02:31:40 +02:00
|
|
|
|
doubles. FIXME: fmb */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *
|
2007-08-14 02:31:40 +02:00
|
|
|
|
value_literal_complex (struct value *arg1,
|
|
|
|
|
struct value *arg2,
|
|
|
|
|
struct type *type)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *val;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
struct type *real_type = TYPE_TARGET_TYPE (type);
|
|
|
|
|
|
|
|
|
|
val = allocate_value (type);
|
|
|
|
|
arg1 = value_cast (real_type, arg1);
|
|
|
|
|
arg2 = value_cast (real_type, arg2);
|
|
|
|
|
|
2005-02-02 01:20:07 +01:00
|
|
|
|
memcpy (value_contents_raw (val),
|
2005-02-06 Andrew Cagney <cagney@gnu.org>
* value.c (value_contents, value_contents_writeable): New
functions.
* value.h (VALUE_CONTENTS): Delete macro.
(value_contents, value_contents_writeable): Declare.
* xstormy16-tdep.c, value.c, valops.c, valarith.c: Update.
* stack.c, sparc-tdep.c, sparc64-tdep.c, sh-tdep.c: Update.
* sh64-tdep.c, scm-valprint.c, scm-exp.c, s390-tdep.c: Update.
* rs6000-tdep.c, p-valprint.c, printcmd.c: Update.
* ppc-sysv-tdep.c, mips-tdep.c, mi/mi-main.c: Update.
* m88k-tdep.c, m68hc11-tdep.c, m32r-tdep.c: Update.
* jv-valprint.c, ia64-tdep.c, hppa-tdep.c: Update.
* hpacc-abi.c, f-valprint.c, frv-tdep.c, eval.c: Update.
* c-valprint.c, cris-tdep.c, cp-valprint.c: Update.
* cli/cli-dump.c, breakpoint.c, avr-tdep.c, arm-tdep.c: Update.
* arm-linux-tdep.c, amd64-tdep.c, alpha-tdep.c: Update.
* ada-valprint.c, ada-lang.c: Update.
2005-02-07 01:09:56 +01:00
|
|
|
|
value_contents (arg1), TYPE_LENGTH (real_type));
|
2005-02-02 01:20:07 +01:00
|
|
|
|
memcpy (value_contents_raw (val) + TYPE_LENGTH (real_type),
|
2005-02-06 Andrew Cagney <cagney@gnu.org>
* value.c (value_contents, value_contents_writeable): New
functions.
* value.h (VALUE_CONTENTS): Delete macro.
(value_contents, value_contents_writeable): Declare.
* xstormy16-tdep.c, value.c, valops.c, valarith.c: Update.
* stack.c, sparc-tdep.c, sparc64-tdep.c, sh-tdep.c: Update.
* sh64-tdep.c, scm-valprint.c, scm-exp.c, s390-tdep.c: Update.
* rs6000-tdep.c, p-valprint.c, printcmd.c: Update.
* ppc-sysv-tdep.c, mips-tdep.c, mi/mi-main.c: Update.
* m88k-tdep.c, m68hc11-tdep.c, m32r-tdep.c: Update.
* jv-valprint.c, ia64-tdep.c, hppa-tdep.c: Update.
* hpacc-abi.c, f-valprint.c, frv-tdep.c, eval.c: Update.
* c-valprint.c, cris-tdep.c, cp-valprint.c: Update.
* cli/cli-dump.c, breakpoint.c, avr-tdep.c, arm-tdep.c: Update.
* arm-linux-tdep.c, amd64-tdep.c, alpha-tdep.c: Update.
* ada-valprint.c, ada-lang.c: Update.
2005-02-07 01:09:56 +01:00
|
|
|
|
value_contents (arg2), TYPE_LENGTH (real_type));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-14 02:31:40 +02:00
|
|
|
|
/* Cast a value into the appropriate complex data type. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2002-01-04 06:20:09 +01:00
|
|
|
|
static struct value *
|
|
|
|
|
cast_into_complex (struct type *type, struct value *val)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
struct type *real_type = TYPE_TARGET_TYPE (type);
|
2007-08-14 02:31:40 +02:00
|
|
|
|
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
if (TYPE_CODE (value_type (val)) == TYPE_CODE_COMPLEX)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
struct type *val_real_type = TYPE_TARGET_TYPE (value_type (val));
|
2002-01-04 06:20:09 +01:00
|
|
|
|
struct value *re_val = allocate_value (val_real_type);
|
|
|
|
|
struct value *im_val = allocate_value (val_real_type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
2005-02-02 01:20:07 +01:00
|
|
|
|
memcpy (value_contents_raw (re_val),
|
2005-02-06 Andrew Cagney <cagney@gnu.org>
* value.c (value_contents, value_contents_writeable): New
functions.
* value.h (VALUE_CONTENTS): Delete macro.
(value_contents, value_contents_writeable): Declare.
* xstormy16-tdep.c, value.c, valops.c, valarith.c: Update.
* stack.c, sparc-tdep.c, sparc64-tdep.c, sh-tdep.c: Update.
* sh64-tdep.c, scm-valprint.c, scm-exp.c, s390-tdep.c: Update.
* rs6000-tdep.c, p-valprint.c, printcmd.c: Update.
* ppc-sysv-tdep.c, mips-tdep.c, mi/mi-main.c: Update.
* m88k-tdep.c, m68hc11-tdep.c, m32r-tdep.c: Update.
* jv-valprint.c, ia64-tdep.c, hppa-tdep.c: Update.
* hpacc-abi.c, f-valprint.c, frv-tdep.c, eval.c: Update.
* c-valprint.c, cris-tdep.c, cp-valprint.c: Update.
* cli/cli-dump.c, breakpoint.c, avr-tdep.c, arm-tdep.c: Update.
* arm-linux-tdep.c, amd64-tdep.c, alpha-tdep.c: Update.
* ada-valprint.c, ada-lang.c: Update.
2005-02-07 01:09:56 +01:00
|
|
|
|
value_contents (val), TYPE_LENGTH (val_real_type));
|
2005-02-02 01:20:07 +01:00
|
|
|
|
memcpy (value_contents_raw (im_val),
|
2005-02-06 Andrew Cagney <cagney@gnu.org>
* value.c (value_contents, value_contents_writeable): New
functions.
* value.h (VALUE_CONTENTS): Delete macro.
(value_contents, value_contents_writeable): Declare.
* xstormy16-tdep.c, value.c, valops.c, valarith.c: Update.
* stack.c, sparc-tdep.c, sparc64-tdep.c, sh-tdep.c: Update.
* sh64-tdep.c, scm-valprint.c, scm-exp.c, s390-tdep.c: Update.
* rs6000-tdep.c, p-valprint.c, printcmd.c: Update.
* ppc-sysv-tdep.c, mips-tdep.c, mi/mi-main.c: Update.
* m88k-tdep.c, m68hc11-tdep.c, m32r-tdep.c: Update.
* jv-valprint.c, ia64-tdep.c, hppa-tdep.c: Update.
* hpacc-abi.c, f-valprint.c, frv-tdep.c, eval.c: Update.
* c-valprint.c, cris-tdep.c, cp-valprint.c: Update.
* cli/cli-dump.c, breakpoint.c, avr-tdep.c, arm-tdep.c: Update.
* arm-linux-tdep.c, amd64-tdep.c, alpha-tdep.c: Update.
* ada-valprint.c, ada-lang.c: Update.
2005-02-07 01:09:56 +01:00
|
|
|
|
value_contents (val) + TYPE_LENGTH (val_real_type),
|
1999-07-07 22:19:36 +02:00
|
|
|
|
TYPE_LENGTH (val_real_type));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
|
|
return value_literal_complex (re_val, im_val, type);
|
|
|
|
|
}
|
2004-11-12 Andrew Cagney <cagney@gnu.org>
* value.h (VALUE_TYPE, VALUE_NEXT, VALUE_OFFSET, VALUE_BITSIZE)
(VALUE_BITPOS): Delete.
(value_type, value_offset, value_bitsize, value_bitpos): Declare.
* value.c (value_type, value_offset, value_bitpos)
(value_bitsize): New functions. Update references.
* arm-tdep.c, gnu-v3-abi.c, hpacc-abi.c, gnu-v2-abi.c: Update.
* f-valprint.c, cp-valprint.c, c-valprint.c: Update.
* ada-valprint.c, typeprint.c, scm-valprint.c, scm-exp.c: Update.
* p-valprint.c, jv-valprint.c, jv-lang.c, varobj.c: Update.
* objc-lang.c, ada-lang.c, std-regs.c, stack.c: Update.
* infcall.c, linespec.c, printcmd.c, valarith.c: Update.
* valops.c, eval.c, findvar.c, breakpoint.c: Update.
* tracepoint.c, ax-gdb.c, mi/mi-main.c, cli/cli-dump.c:
* rs6000-tdep.c, ppc-sysv-tdep.c: Update.
2004-11-12 22:45:08 +01:00
|
|
|
|
else if (TYPE_CODE (value_type (val)) == TYPE_CODE_FLT
|
|
|
|
|
|| TYPE_CODE (value_type (val)) == TYPE_CODE_INT)
|
2007-08-14 02:31:40 +02:00
|
|
|
|
return value_literal_complex (val,
|
|
|
|
|
value_zero (real_type, not_lval),
|
|
|
|
|
type);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
else
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
|
|
|
|
error (_("cannot cast non-number to complex"));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
|
_initialize_valops (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
|
{
|
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_boolean_command through out. Delete #ifdef 0'ed
code adding set/show boolean commands.
* cp-valprint.c, dcache.c, exec.c, gdbtypes.c, infrun.c: Update.
* monitor.c, p-valprint.c, pa64solib.c, printcmd.c: Update.
* proc-api.c, remote-mips.c, remote.c, solib.c: Update.
* somsolib.c, symfile.c, top.c, utils.c, valops.c: Update.
* valprint.c, win32-nat.c, wince.c, xcoffsolib.c: Update.
* cli/cli-cmds.c: Update.
2005-02-18 16:25:32 +01:00
|
|
|
|
add_setshow_boolean_cmd ("overload-resolution", class_support,
|
|
|
|
|
&overload_resolution, _("\
|
|
|
|
|
Set overload resolution in evaluating C++ functions."), _("\
|
2007-08-14 02:31:40 +02:00
|
|
|
|
Show overload resolution in evaluating C++ functions."),
|
|
|
|
|
NULL, NULL,
|
2005-02-24 Andrew Cagney <cagney@gnu.org>
Add show_VARIABLE functions, update add_setshow call.
* varobj.c (_initialize_varobj, show_varobjdebug): Add and update.
* valprint.c (_initialize_valprint, show_print_max)
(show_stop_print_at_null, show_repeat_count_threshold)
(show_prettyprint_structs, show_unionprint)
(show_prettyprint_arrays, show_addressprint, show_input_radix)
(show_output_radix): Ditto.
* valops.c (_initialize_valops, show_overload_resolution): Ditto.
* utils.c (initialize_utils, show_chars_per_line)
(show_lines_per_page, show_demangle, show_pagination_enabled)
(show_sevenbit_strings, show_asm_demangle): Ditto
* tui/tui-win.c (_initialize_tui_win, show_tui_border_kind)
(show_tui_border_mode, show_tui_active_border_mode): Ditto.
* top.c (init_main, show_new_async_prompt)
(show_async_command_editing_p, show_write_history_p)
(show_history_size, show_history_filename, show_caution)
(show_annotation_level, init_main): Ditto.
* target.c (initialize_targets, show_targetdebug)
(show_trust_readonly): Ditto.
* symfile.c (_initialize_symfile, show_symbol_reloading)
(show_ext_args, show_download_write_size)
(show_debug_file_directory): Ditto.
* source.c (_initialize_source, show_lines_to_list): Ditto.
* solib.c (_initialize_solib, show_auto_solib_add)
(show_solib_search_path): Ditto.
* p-valprint.c (_initialize_pascal_valprint)
(show_pascal_static_field_print): Ditto.
* printcmd.c (_initialize_printcmd, show_max_symbolic_offset)
(show_print_symbol_filename): Add and update.
* parse.c (_initialize_parse, show_expressiondebug): Dito.
* observer.c (_initialize_observer, show_observer_debug): Dito.
* maint.c (_initialize_maint_cmds, show_watchdog)
(show_maintenance_profile_p): Dito.
* linux-nat.c (_initialize_linux_nat, show_debug_linux_nat): Dito.
* infrun.c (_initialize_infrun, show_debug_infrun)
(show_stop_on_solib_events, show_follow_fork_mode_string)
(show_scheduler_mode, show_step_stop_if_no_debug): Ditto.
* infcall.c (_initialize_infcall, show_coerce_float_to_double_p)
(show_unwind_on_signal_p): Ditto.
* gdbtypes.c (build_gdbtypes, show_opaque_type_resolution)
(_initialize_gdbtypes, show_overload_debug): Ditto.
* gdb-events.c, gdb-events.sh (_initialize_gdb_events)
(show_gdb_events_debug): Ditto.
* gdbarch.c, gdbarch.sh (show_gdbarch_debug)
(_initialize_gdbarch): Ditto.
* frame.c (_initialize_frame, show_backtrace_past_main)
(show_backtrace_past_entry, show_backtrace_limit)
(show_frame_debug): Ditto.
* exec.c (_initialize_exec, show_write_files): Ditto.
* dwarf2read.c (_initialize_dwarf2_read)
(show_dwarf2_max_cache_age): Ditto.
* demangle.c (_initialize_demangler)
(show_demangling_style_names): Ditto.
* dcache.c (_initialize_dcache, show_dcache_enabled_p): Ditto.
* cp-valprint.c (show_static_field_print)
(_initialize_cp_valprint, show_vtblprint, show_objectprint): Ditto.
* corefile.c (_initialize_core, show_gnutarget_string): Ditto.
* cli/cli-logging.c (_initialize_cli_logging)
(show_logging_overwrite, show_logging_redirect)
(show_logging_filename): Ditto.
* cli/cli-cmds.c (show_info_verbose, show_history_expansion_p)
(init_cli_cmds, show_baud_rate, show_remote_debug)
(show_remote_timeout, show_max_user_call_depth): Ditto.
* charset.c (show_host_charset_name, show_target_charset_name)
(initialize_charset): Ditto.
* breakpoint.c (show_can_use_hw_watchpoints)
(show_pending_break_support, _initialize_breakpoint): Ditto.
2005-02-24 14:51:36 +01:00
|
|
|
|
show_overload_resolution,
|
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_boolean_command through out. Delete #ifdef 0'ed
code adding set/show boolean commands.
* cp-valprint.c, dcache.c, exec.c, gdbtypes.c, infrun.c: Update.
* monitor.c, p-valprint.c, pa64solib.c, printcmd.c: Update.
* proc-api.c, remote-mips.c, remote.c, solib.c: Update.
* somsolib.c, symfile.c, top.c, utils.c, valops.c: Update.
* valprint.c, win32-nat.c, wince.c, xcoffsolib.c: Update.
* cli/cli-cmds.c: Update.
2005-02-18 16:25:32 +01:00
|
|
|
|
&setlist, &showlist);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
overload_resolution = 1;
|
|
|
|
|
}
|