1999-04-16 09:35:26 +08:00
|
|
|
|
/* Support for printing C values for GDB, the GNU debugger.
|
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* ax-gdb.c, c-valprint.c, charset.c, corefile.c: Update copyright.
* demangle.c, disasm.c, dwarf2cfi.c, dwarfread.c: Update copyright.
* elfread.c, eval.c, expprint.c, expression.h: Update copyright.
* f-typeprint.c, findvar.c, gcore.c, gdb_mbuild.sh: Update copyright.
* gdbtypes.h, gnu-v2-abi.c, inferior.h, inftarg.c: Update copyright.
* language.c, language.h, m32r-tdep.c: Update copyright.
* mn10200-tdep.c, scm-lang.c, scm-lang.h: Update copyright.
* somsolib.c, somsolib.h, symfile.c, symtab.h: Update copyright.
* thread-db.c, typeprint.c, utils.c, valarith.c: Update copyright.
* values.c, win32-nat.c, x86-64-linux-nat.c: Update copyright.
* x86-64-linux-tdep.c, z8k-tdep.c: Update copyright.
* cli/cli-decode.h, config/h8500/tm-h8500.h: Update copyright.
Index: mi/ChangeLog
2003-01-13 Andrew Cagney <ac131313@redhat.com>
* mi-cmd-env.c: Update copyright.
2003-01-14 08:49:06 +08:00
|
|
|
|
|
|
|
|
|
Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
|
|
|
|
|
1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08: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
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08: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 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
2002-08-28 06:37:14 +08:00
|
|
|
|
#include "gdb_string.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
|
#include "expression.h"
|
|
|
|
|
#include "value.h"
|
|
|
|
|
#include "valprint.h"
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "c-lang.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 08:19:09 +08:00
|
|
|
|
#include "cp-abi.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
|
2000-11-21 04:33:53 +08:00
|
|
|
|
/* Print function pointer with inferior address ADDRESS onto stdio
|
|
|
|
|
stream STREAM. */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
|
|
|
|
|
{
|
|
|
|
|
CORE_ADDR func_addr = CONVERT_FROM_FUNC_PTR_ADDR (address);
|
|
|
|
|
|
|
|
|
|
/* If the function pointer is represented by a description, print the
|
|
|
|
|
address of the description. */
|
|
|
|
|
if (addressprint && func_addr != address)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered ("@", stream);
|
|
|
|
|
print_address_numeric (address, 1, stream);
|
|
|
|
|
fputs_filtered (": ", stream);
|
|
|
|
|
}
|
|
|
|
|
print_address_demangle (func_addr, stream, demangle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Print data of type TYPE located at VALADDR (within GDB), which came from
|
|
|
|
|
the inferior at address ADDRESS, onto stdio stream STREAM according to
|
|
|
|
|
FORMAT (a letter or 0 for natural format). The data at VALADDR is in
|
|
|
|
|
target byte order.
|
|
|
|
|
|
|
|
|
|
If the data are a string pointer, returns the number of string characters
|
|
|
|
|
printed.
|
|
|
|
|
|
|
|
|
|
If DEREF_REF is nonzero, then dereference references, otherwise just print
|
|
|
|
|
them like pointers.
|
|
|
|
|
|
|
|
|
|
The PRETTY parameter controls prettyprinting. */
|
|
|
|
|
|
|
|
|
|
int
|
2000-07-30 09:48:28 +08:00
|
|
|
|
c_val_print (struct type *type, char *valaddr, int embedded_offset,
|
|
|
|
|
CORE_ADDR address, struct ui_file *stream, int format,
|
|
|
|
|
int deref_ref, int recurse, enum val_prettyprint pretty)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
register unsigned int i = 0; /* Number of characters printed */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
unsigned len;
|
|
|
|
|
struct type *elttype;
|
|
|
|
|
unsigned eltlen;
|
|
|
|
|
LONGEST val;
|
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
|
|
CHECK_TYPEDEF (type);
|
|
|
|
|
switch (TYPE_CODE (type))
|
|
|
|
|
{
|
|
|
|
|
case TYPE_CODE_ARRAY:
|
|
|
|
|
elttype = check_typedef (TYPE_TARGET_TYPE (type));
|
|
|
|
|
if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
|
|
|
|
|
{
|
|
|
|
|
eltlen = TYPE_LENGTH (elttype);
|
|
|
|
|
len = TYPE_LENGTH (type) / eltlen;
|
|
|
|
|
if (prettyprint_arrays)
|
|
|
|
|
{
|
|
|
|
|
print_spaces_filtered (2 + 2 * recurse, stream);
|
|
|
|
|
}
|
|
|
|
|
/* For an array of chars, print with string syntax. */
|
|
|
|
|
if (eltlen == 1 &&
|
|
|
|
|
((TYPE_CODE (elttype) == TYPE_CODE_INT)
|
|
|
|
|
|| ((current_language->la_language == language_m2)
|
|
|
|
|
&& (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
|
|
|
|
|
&& (format == 0 || format == 's'))
|
|
|
|
|
{
|
|
|
|
|
/* If requested, look for the first null char and only print
|
1999-07-08 04:19:36 +08:00
|
|
|
|
elements up to it. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
if (stop_print_at_null)
|
|
|
|
|
{
|
2000-02-08 12:39:02 +08:00
|
|
|
|
unsigned int temp_len;
|
1999-07-08 04:19:36 +08:00
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Look for a NULL char. */
|
|
|
|
|
for (temp_len = 0;
|
|
|
|
|
(valaddr + embedded_offset)[temp_len]
|
|
|
|
|
&& temp_len < len && temp_len < print_max;
|
|
|
|
|
temp_len++);
|
|
|
|
|
len = temp_len;
|
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0);
|
|
|
|
|
i = len;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (stream, "{");
|
|
|
|
|
/* If this is a virtual function table, print the 0th
|
1999-07-08 04:19:36 +08:00
|
|
|
|
entry specially, and the rest of the members normally. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
if (cp_is_vtbl_ptr_type (elttype))
|
|
|
|
|
{
|
|
|
|
|
i = 1;
|
|
|
|
|
fprintf_filtered (stream, "%d vtable entries", len - 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
val_print_array_elements (type, valaddr + embedded_offset, address, stream,
|
1999-07-08 04:19:36 +08:00
|
|
|
|
format, deref_ref, recurse, pretty, i);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fprintf_filtered (stream, "}");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* Array of unspecified length: treat like pointer to first elt. */
|
|
|
|
|
addr = address;
|
|
|
|
|
goto print_unpacked_pointer;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_PTR:
|
|
|
|
|
if (format && format != 's')
|
|
|
|
|
{
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
if (vtblprint && cp_is_vtbl_ptr_type (type))
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
/* Print the unmangled name if desired. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Print vtable entry - we only get here if we ARE using
|
|
|
|
|
-fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
|
* 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-15 02:43:41 +08:00
|
|
|
|
CORE_ADDR addr
|
|
|
|
|
= extract_typed_address (valaddr + embedded_offset, type);
|
2000-11-21 04:33:53 +08:00
|
|
|
|
print_function_pointer_address (addr, stream);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
elttype = check_typedef (TYPE_TARGET_TYPE (type));
|
|
|
|
|
if (TYPE_CODE (elttype) == TYPE_CODE_METHOD)
|
|
|
|
|
{
|
|
|
|
|
cp_print_class_method (valaddr + embedded_offset, type, stream);
|
|
|
|
|
}
|
|
|
|
|
else if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER)
|
|
|
|
|
{
|
|
|
|
|
cp_print_class_member (valaddr + embedded_offset,
|
|
|
|
|
TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)),
|
|
|
|
|
stream, "&");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
addr = unpack_pointer (type, valaddr + embedded_offset);
|
|
|
|
|
print_unpacked_pointer:
|
|
|
|
|
|
|
|
|
|
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
|
|
|
|
|
{
|
|
|
|
|
/* Try to print what function it points to. */
|
2000-11-21 04:33:53 +08:00
|
|
|
|
print_function_pointer_address (addr, stream);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Return value is irrelevant except for string pointers. */
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addressprint && format != 's')
|
|
|
|
|
{
|
|
|
|
|
print_address_numeric (addr, 1, stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* For a pointer to char or unsigned char, also print the string
|
|
|
|
|
pointed to, unless pointer is null. */
|
|
|
|
|
/* FIXME: need to handle wchar_t here... */
|
|
|
|
|
|
|
|
|
|
if (TYPE_LENGTH (elttype) == 1
|
|
|
|
|
&& TYPE_CODE (elttype) == TYPE_CODE_INT
|
|
|
|
|
&& (format == 0 || format == 's')
|
|
|
|
|
&& addr != 0)
|
|
|
|
|
{
|
|
|
|
|
i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
|
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
else if (cp_is_vtbl_member (type))
|
|
|
|
|
{
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* print vtbl's nicely */
|
|
|
|
|
CORE_ADDR vt_address = unpack_pointer (type, valaddr + embedded_offset);
|
|
|
|
|
|
|
|
|
|
struct minimal_symbol *msymbol =
|
1999-07-08 04:19:36 +08:00
|
|
|
|
lookup_minimal_symbol_by_pc (vt_address);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
if ((msymbol != NULL) &&
|
|
|
|
|
(vt_address == SYMBOL_VALUE_ADDRESS (msymbol)))
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (" <", stream);
|
2003-02-20 David Carlton <carlton@math.stanford.edu>
* symtab.h (SYMBOL_PRINT_NAME): Rename from SYMBOL_SOURCE_NAME;
expand comment.
* ada-lang.c (user_select_syms, ada_finish_decode_line_1): Replace
SYMBOL_PRINT_NAME with SYMBOL_SOURCE_NAME.
* ada-typeprint.c (ada_typedef_print): Ditto.
* ax-gdb.c (gen_var_ref): Ditto.
* breakpoint.c (print_one_breakpoint): Ditto.
* buildsym.c (finish_block): Ditto.
* c-valprint.c (c_val_print): Ditto.
* expprint.c (print_subexp): Ditto.
* findvar.c (locate_var_value): Ditto.
* infcmd.c (jump_command): Ditto.
* linespec.c (decode_line_2, decode_compound): Ditto.
* maint.c (maintenance_translate_address): Ditto.
* objc-lang.c (compare_selectors, compare_classes): Ditto.
* printcmd.c (build_address_symbolic, sym_info, print_frame_args):
Ditto.
* p-valprint.c (pascal_val_print): Ditto.
* stabsread.c (define_symbol): Ditto.
* stack.c (print_frame, frame_info, print_block_frame_locals)
(print_frame_arg_vars, return_command): Ditto.
* symfile.c (compare_symbols, compare_psymbols): Ditto.
* symmisc.c (print_symbol): Ditto.
* symtab.c (lookup_partial_symbol, lookup_block_symbol)
(compare_search_syms, print_symbol_info, print_msymbol_info)
(rbreak_command): Ditto.
* tracepoint.c (tracepoints_info): Ditto.
* typeprint.c (typedef_print): Ditto.
* valops.c (value_of_variable, hand_function_call): Ditto.
* cli/cli-cmds.c (edit_command, list_command): Ditto.
* ada-typeprint.c: Update Copyright.
* infcmd.c, objc-lang.c, p-valprint.c, symmisc.c: Ditto.
* tracepoint.c, cli/cli-cmds.c: Ditto.
2003-02-21 01:17:25 +08:00
|
|
|
|
fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fputs_filtered (">", stream);
|
|
|
|
|
}
|
|
|
|
|
if (vt_address && vtblprint)
|
1999-07-08 04:19:36 +08:00
|
|
|
|
{
|
2001-11-11 04:44:38 +08:00
|
|
|
|
struct value *vt_val;
|
1999-07-08 04:19:36 +08:00
|
|
|
|
struct symbol *wsym = (struct symbol *) NULL;
|
|
|
|
|
struct type *wtype;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
struct symtab *s;
|
1999-07-08 04:19:36 +08:00
|
|
|
|
struct block *block = (struct block *) NULL;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
int is_this_fld;
|
|
|
|
|
|
|
|
|
|
if (msymbol != NULL)
|
2003-02-25 David Carlton <carlton@math.stanford.edu>
* symtab.h (SYMBOL_NATURAL_NAME): New macro.
(SYMBOL_LINKAGE_NAME): Ditto.
(SYMBOL_PRINT_NAME): Use SYMBOL_NATURAL_NAME and
SYMBOL_LINKAGE_NAME.
(struct general_symbol_info): Expand comment.
(DEPRECATED_SYMBOL_NAME): Rename from SYMBOL_NAME.
(SYMBOL_MATCHES_NAME): Use DEPRECATED_SYMBOL_NAME.
(SYMBOL_MATCHES_REGEXP): Ditto.
* symtab.c (symbol_natural_name): New function.
* objfiles.h: Replace all uses of SYMBOL_NAME by
DEPRECATED_SYMBOL_NAME.
* xcoffread.c, valops.c, typeprint.c, tracepoint.c: Ditto.
* symtab.c, symmisc.c, symfile.c, stack.c, stabsread.c: Ditto.
* somsolib.c, sol-thread.c, rs6000-tdep.c, p-valprint.c: Ditto.
* printcmd.c, objfiles.c, objc-lang.c, mipsread.c: Ditto.
* minsyms.c, mdebugread.c, linespec.c, jv-lang.c: Ditto.
* i386-tdep.c, i386-linux-tdep.c, hpread.c, hppa-tdep.c: Ditto.
* gnu-v2-abi.c, f-valprint.c, findvar.c, expprint.c: Ditto.
* dwarfread.c, dwarf2read.c, dbxread.c, c-valprint.c: Ditto.
* cp-valprint.c, coffread.c, buildsym.c, breakpoint.c: Ditto.
* blockframe.c, ax-gdb.c, arm-linux-tdep.c, ada-lang.c: Ditto.
* ada-exp.y: Ditto.
* ada-exp.y: Update copyright.
* sol-thread.c, mipsread.c, jv-lang.c, f-valprint.c: Ditto.
* cp-valprint.c: Ditto.
2003-02-25 David Carlton <carlton@math.stanford.edu>
* generic/gdbtk.h: Replace all instances of SYMBOL_NAME by
DEPRECATED_SYMBOL_NAME.
* generic/gdbtk-stack.c, generic/gdbtk-cmds.c: Ditto.
* generic/gdbtk-stack.c, generic/gdbtk-cmds.c: Update copyright.
2003-02-25 David Carlton <carlton@math.stanford.edu>
* mi-cmd-stack.c: Replace all instances of SYMBOL_NAME with
DEPRECATED_SYMBOL_NAME. Update copyright.
2003-02-26 05:36:23 +08:00
|
|
|
|
wsym = lookup_symbol (DEPRECATED_SYMBOL_NAME (msymbol), block,
|
2003-05-14 Elena Zannoni <ezannoni@redhat.com>
* symtab.h (enum domain_enum): Rename from namespace_enum.
(UNDEF_DOMAIN, VAR_DOMAIN, STRUCT_DOMAIN, LABEL_DOMAIN,
VARIABLES_DOMAIN, FUNCTIONS_DOMAIN, TYPES_DOMAIN, METHODS_DOMAIN):
Rename from UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE,
LABEL_NAMESPACE, VARIABLES_NAMESPACE, FUNCTIONS_NAMESPACE,
TYPES_NAMESPACE, METHODS_NAMESPACE.
(SYMBOL_NAMESPACE): Rename to SYMBOL_DOMAIN.
(struct symbol, struct partial_symbol): Rename field
'namespace_enum namespace' to 'domain_enum domain'.
(PSYMBOL_NAMESPACE): Rename to PSYMBOL_DOMAIN.
Delete old define kludge for namespace.
* ada-exp.y, ada-lang.c, ada-lang.h, alpha-tdep.c, arm-tdep.c,
blockframe.c, c-exp.y, c-valprint.c, coffread.c, dbxread.c,
dwarf2read.c, dwarfread.c, f-exp.y, gdbtypes.c, gdbtypes.h,
gnu-v3-abi.c, hppa-tdep.c, hpread.c, jv-exp.y, jv-lang.c,
language.c, linespec.c, m2-exp.y, m3-nat.c, mdebugread.c,
mips-tdep.c, nlmread.c, objc-exp.y, objc-lang.c, objfiles.c,
p-exp.y, p-valprint.c, parse.c, printcmd.c, scm-lang.c, source.c,
stabsread.c, stack.c, symfile.c, symfile.h, symmisc.c, symtab.c,
valops.c, values.c, xcoffread.c, xstormy16-tdep.c: Replace all
occurrences of the above.
2003-05-12 Elena Zannoni <ezannoni@redhat.com>
* mi-mi-cmd-stack.c (list_args_or_locals): Rename VAR_NAMESPACE to
VAR_DOMAIN.
2003-05-15 01:43:20 +08:00
|
|
|
|
VAR_DOMAIN, &is_this_fld, &s);
|
1999-07-08 04:19:36 +08:00
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
if (wsym)
|
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
wtype = SYMBOL_TYPE (wsym);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
wtype = TYPE_TARGET_TYPE (type);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
vt_val = value_at (wtype, vt_address, NULL);
|
|
|
|
|
val_print (VALUE_TYPE (vt_val), VALUE_CONTENTS (vt_val), 0,
|
|
|
|
|
VALUE_ADDRESS (vt_val), stream, format,
|
|
|
|
|
deref_ref, recurse + 1, pretty);
|
|
|
|
|
if (pretty)
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (stream, "\n");
|
|
|
|
|
print_spaces_filtered (2 + 2 * recurse, stream);
|
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
/* Return number of characters printed, including the terminating
|
|
|
|
|
'\0' if we reached the end. val_print_string takes care including
|
|
|
|
|
the terminating '\0' if necessary. */
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_MEMBER:
|
|
|
|
|
error ("not implemented: member type in c_val_print");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_REF:
|
|
|
|
|
elttype = check_typedef (TYPE_TARGET_TYPE (type));
|
|
|
|
|
if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER)
|
1999-07-08 04:19:36 +08:00
|
|
|
|
{
|
1999-04-16 09:35:26 +08:00
|
|
|
|
cp_print_class_member (valaddr + embedded_offset,
|
|
|
|
|
TYPE_DOMAIN_TYPE (elttype),
|
|
|
|
|
stream, "");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (addressprint)
|
1999-07-08 04:19:36 +08: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-15 02:43:41 +08:00
|
|
|
|
CORE_ADDR addr
|
|
|
|
|
= extract_typed_address (valaddr + embedded_offset, type);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fprintf_filtered (stream, "@");
|
* 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-15 02:43:41 +08:00
|
|
|
|
print_address_numeric (addr, 1, stream);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
if (deref_ref)
|
|
|
|
|
fputs_filtered (": ", stream);
|
1999-07-08 04:19:36 +08:00
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* De-reference the reference. */
|
|
|
|
|
if (deref_ref)
|
|
|
|
|
{
|
|
|
|
|
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
|
|
|
|
|
{
|
2001-11-11 04:44:38 +08:00
|
|
|
|
struct value *deref_val =
|
1999-07-08 04:19:36 +08:00
|
|
|
|
value_at
|
|
|
|
|
(TYPE_TARGET_TYPE (type),
|
|
|
|
|
unpack_pointer (lookup_pointer_type (builtin_type_void),
|
|
|
|
|
valaddr + embedded_offset),
|
|
|
|
|
NULL);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
val_print (VALUE_TYPE (deref_val),
|
1999-07-08 04:19:36 +08:00
|
|
|
|
VALUE_CONTENTS (deref_val),
|
|
|
|
|
0,
|
|
|
|
|
VALUE_ADDRESS (deref_val),
|
|
|
|
|
stream,
|
|
|
|
|
format,
|
|
|
|
|
deref_ref,
|
|
|
|
|
recurse,
|
|
|
|
|
pretty);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fputs_filtered ("???", stream);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_UNION:
|
|
|
|
|
if (recurse && !unionprint)
|
|
|
|
|
{
|
|
|
|
|
fprintf_filtered (stream, "{...}");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* Fall through. */
|
|
|
|
|
case TYPE_CODE_STRUCT:
|
(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 08:19:09 +08:00
|
|
|
|
/*FIXME: Abstract this away */
|
1999-07-08 04:19:36 +08:00
|
|
|
|
if (vtblprint && cp_is_vtbl_ptr_type (type))
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
/* Print the unmangled name if desired. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Print vtable entry - we only get here if NOT using
|
|
|
|
|
-fvtable_thunks. (Otherwise, look under TYPE_CODE_PTR.) */
|
* 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-15 02:43:41 +08:00
|
|
|
|
int offset = (embedded_offset +
|
|
|
|
|
TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8);
|
|
|
|
|
struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET);
|
|
|
|
|
CORE_ADDR addr
|
|
|
|
|
= extract_typed_address (valaddr + offset, field_type);
|
|
|
|
|
|
2000-11-21 04:33:53 +08:00
|
|
|
|
print_function_pointer_address (addr, stream);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,
|
|
|
|
|
recurse, pretty, NULL, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ENUM:
|
|
|
|
|
if (format)
|
|
|
|
|
{
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
len = TYPE_NFIELDS (type);
|
|
|
|
|
val = unpack_long (type, valaddr + embedded_offset);
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
QUIT;
|
|
|
|
|
if (val == TYPE_FIELD_BITPOS (type, i))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (i < len)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print_longest (stream, 'd', 0, val);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_FUNC:
|
|
|
|
|
if (format)
|
|
|
|
|
{
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* FIXME, we should consider, at least for ANSI C language, eliminating
|
1999-07-08 04:19:36 +08:00
|
|
|
|
the distinction made between FUNCs and POINTERs to FUNCs. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fprintf_filtered (stream, "{");
|
|
|
|
|
type_print (type, "", stream, -1);
|
|
|
|
|
fprintf_filtered (stream, "} ");
|
|
|
|
|
/* Try to print what function it points to, and its address. */
|
|
|
|
|
print_address_demangle (address, stream, demangle);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_BOOL:
|
|
|
|
|
format = format ? format : output_format;
|
|
|
|
|
if (format)
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
val = unpack_long (type, valaddr + embedded_offset);
|
|
|
|
|
if (val == 0)
|
|
|
|
|
fputs_filtered ("false", stream);
|
|
|
|
|
else if (val == 1)
|
|
|
|
|
fputs_filtered ("true", stream);
|
|
|
|
|
else
|
|
|
|
|
print_longest (stream, 'd', 0, val);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_RANGE:
|
|
|
|
|
/* FIXME: create_range_type does not set the unsigned bit in a
|
1999-07-08 04:19:36 +08:00
|
|
|
|
range type (I think it probably should copy it from the target
|
|
|
|
|
type), so we won't print values which are too large to
|
|
|
|
|
fit in a signed integer correctly. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* FIXME: Doesn't handle ranges of enums correctly. (Can't just
|
1999-07-08 04:19:36 +08:00
|
|
|
|
print with the target type, though, because the size of our type
|
|
|
|
|
and the target type might differ). */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_INT:
|
|
|
|
|
format = format ? format : output_format;
|
|
|
|
|
if (format)
|
|
|
|
|
{
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
val_print_type_code_int (type, valaddr + embedded_offset, stream);
|
|
|
|
|
/* C and C++ has no single byte int type, char is used instead.
|
|
|
|
|
Since we don't know whether the value is really intended to
|
|
|
|
|
be used as an integer or a character, print the character
|
|
|
|
|
equivalent as well. */
|
|
|
|
|
if (TYPE_LENGTH (type) == 1)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (" ", stream);
|
|
|
|
|
LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
|
|
|
|
|
stream);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_CHAR:
|
|
|
|
|
format = format ? format : output_format;
|
|
|
|
|
if (format)
|
|
|
|
|
{
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-08-10 05:36:23 +08:00
|
|
|
|
val = unpack_long (type, valaddr + embedded_offset);
|
|
|
|
|
if (TYPE_UNSIGNED (type))
|
|
|
|
|
fprintf_filtered (stream, "%u", (unsigned int) val);
|
|
|
|
|
else
|
|
|
|
|
fprintf_filtered (stream, "%d", (int) val);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fputs_filtered (" ", stream);
|
1999-08-10 05:36:23 +08:00
|
|
|
|
LA_PRINT_CHAR ((unsigned char) val, stream);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_FLT:
|
|
|
|
|
if (format)
|
|
|
|
|
{
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print_floating (valaddr + embedded_offset, type, stream);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_METHOD:
|
2002-02-04 10:14:46 +08:00
|
|
|
|
{
|
|
|
|
|
struct value *v = value_at (type, address, NULL);
|
|
|
|
|
cp_print_class_method (VALUE_CONTENTS (value_addr (v)),
|
|
|
|
|
lookup_pointer_type (type), stream);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
case TYPE_CODE_VOID:
|
|
|
|
|
fprintf_filtered (stream, "void");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_ERROR:
|
|
|
|
|
fprintf_filtered (stream, "<error type>");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TYPE_CODE_UNDEF:
|
|
|
|
|
/* This happens (without TYPE_FLAG_STUB set) on systems which don't use
|
1999-07-08 04:19:36 +08:00
|
|
|
|
dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar"
|
|
|
|
|
and no complete type for struct foo in that file. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fprintf_filtered (stream, "<incomplete type>");
|
|
|
|
|
break;
|
|
|
|
|
|
2002-02-06 05:41:29 +08:00
|
|
|
|
case TYPE_CODE_COMPLEX:
|
|
|
|
|
if (format)
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset,
|
|
|
|
|
TYPE_TARGET_TYPE (type),
|
|
|
|
|
format, 0, stream);
|
|
|
|
|
else
|
|
|
|
|
print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
|
|
|
|
|
stream);
|
|
|
|
|
fprintf_filtered (stream, " + ");
|
|
|
|
|
if (format)
|
|
|
|
|
print_scalar_formatted (valaddr + embedded_offset
|
|
|
|
|
+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
|
|
|
|
|
TYPE_TARGET_TYPE (type),
|
|
|
|
|
format, 0, stream);
|
|
|
|
|
else
|
|
|
|
|
print_floating (valaddr + embedded_offset
|
|
|
|
|
+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
|
|
|
|
|
TYPE_TARGET_TYPE (type),
|
|
|
|
|
stream);
|
|
|
|
|
fprintf_filtered (stream, " * I");
|
|
|
|
|
break;
|
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
default:
|
|
|
|
|
error ("Invalid C/C++ type code %d in symbol table.", TYPE_CODE (type));
|
|
|
|
|
}
|
|
|
|
|
gdb_flush (stream);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-11-11 04:44:38 +08:00
|
|
|
|
c_value_print (struct value *val, struct ui_file *stream, int format,
|
2000-07-30 09:48:28 +08:00
|
|
|
|
enum val_prettyprint pretty)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
struct type *type = VALUE_TYPE (val);
|
1999-07-08 04:19:36 +08:00
|
|
|
|
struct type *real_type;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
int full, top, using_enc;
|
1999-07-08 04:19:36 +08:00
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* If it is a pointer, indicate what it points to.
|
|
|
|
|
|
|
|
|
|
Print type also if it is a reference.
|
|
|
|
|
|
|
|
|
|
C++: if it is a member pointer, we will take care
|
|
|
|
|
of that when we print it. */
|
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_PTR ||
|
|
|
|
|
TYPE_CODE (type) == TYPE_CODE_REF)
|
|
|
|
|
{
|
|
|
|
|
/* Hack: remove (char *) for char strings. Their
|
1999-07-08 04:19:36 +08:00
|
|
|
|
type is indicated by the quoted string anyway. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_PTR &&
|
|
|
|
|
TYPE_NAME (type) == NULL &&
|
|
|
|
|
TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL &&
|
2003-01-10 02:30:32 +08:00
|
|
|
|
strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0)
|
1999-04-16 09:35:26 +08:00
|
|
|
|
{
|
|
|
|
|
/* Print nothing */
|
|
|
|
|
}
|
|
|
|
|
else if (objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
|
1999-07-08 04:19:36 +08:00
|
|
|
|
{
|
2000-04-04 12:53:50 +08:00
|
|
|
|
|
|
|
|
|
if (TYPE_CODE(type) == TYPE_CODE_REF)
|
|
|
|
|
{
|
|
|
|
|
/* Copy value, change to pointer, so we don't get an
|
|
|
|
|
* error about a non-pointer type in value_rtti_target_type
|
|
|
|
|
*/
|
2001-11-11 04:44:38 +08:00
|
|
|
|
struct value *temparg;
|
2000-04-04 12:53:50 +08:00
|
|
|
|
temparg=value_copy(val);
|
|
|
|
|
VALUE_TYPE (temparg) = lookup_pointer_type(TYPE_TARGET_TYPE(type));
|
|
|
|
|
val=temparg;
|
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
/* Pointer to class, check real type of object */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fprintf_filtered (stream, "(");
|
1999-12-14 09:06:04 +08:00
|
|
|
|
real_type = value_rtti_target_type (val, &full, &top, &using_enc);
|
|
|
|
|
if (real_type)
|
1999-07-08 04:19:36 +08:00
|
|
|
|
{
|
|
|
|
|
/* RTTI entry found */
|
1999-12-14 09:06:04 +08:00
|
|
|
|
if (TYPE_CODE (type) == TYPE_CODE_PTR)
|
|
|
|
|
{
|
|
|
|
|
/* create a pointer type pointing to the real type */
|
|
|
|
|
type = lookup_pointer_type (real_type);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* create a reference type referencing the real type */
|
|
|
|
|
type = lookup_reference_type (real_type);
|
|
|
|
|
}
|
2000-04-04 12:53:50 +08:00
|
|
|
|
/* JYG: Need to adjust pointer value. */
|
|
|
|
|
val->aligner.contents[0] -= top;
|
|
|
|
|
|
1999-12-14 09:06:04 +08:00
|
|
|
|
/* Note: When we look up RTTI entries, we don't get any
|
|
|
|
|
information on const or volatile attributes */
|
|
|
|
|
}
|
|
|
|
|
type_print (type, "", stream, -1);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fprintf_filtered (stream, ") ");
|
1999-07-08 04:19:36 +08:00
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
1999-07-08 04:19:36 +08:00
|
|
|
|
/* normal case */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
fprintf_filtered (stream, "(");
|
|
|
|
|
type_print (type, "", stream, -1);
|
|
|
|
|
fprintf_filtered (stream, ") ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (objectprint && (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_CLASS))
|
|
|
|
|
{
|
|
|
|
|
/* Attempt to determine real type of object */
|
|
|
|
|
real_type = value_rtti_type (val, &full, &top, &using_enc);
|
1999-07-08 04:19:36 +08:00
|
|
|
|
if (real_type)
|
|
|
|
|
{
|
|
|
|
|
/* We have RTTI information, so use it */
|
|
|
|
|
val = value_full_object (val, real_type, full, top, using_enc);
|
|
|
|
|
fprintf_filtered (stream, "(%s%s) ",
|
|
|
|
|
TYPE_NAME (real_type),
|
|
|
|
|
full ? "" : " [incomplete object]");
|
|
|
|
|
/* Print out object: enclosing type is same as real_type if full */
|
|
|
|
|
return val_print (VALUE_ENCLOSING_TYPE (val), VALUE_CONTENTS_ALL (val), 0,
|
|
|
|
|
VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
|
1999-12-14 09:06:04 +08:00
|
|
|
|
/* Note: When we look up RTTI entries, we don't get any information on
|
|
|
|
|
const or volatile attributes */
|
1999-07-08 04:19:36 +08:00
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
else if (type != VALUE_ENCLOSING_TYPE (val))
|
1999-07-08 04:19:36 +08:00
|
|
|
|
{
|
|
|
|
|
/* No RTTI information, so let's do our best */
|
|
|
|
|
fprintf_filtered (stream, "(%s ?) ",
|
|
|
|
|
TYPE_NAME (VALUE_ENCLOSING_TYPE (val)));
|
|
|
|
|
return val_print (VALUE_ENCLOSING_TYPE (val), VALUE_CONTENTS_ALL (val), 0,
|
|
|
|
|
VALUE_ADDRESS (val), stream, format, 1, 0, pretty);
|
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Otherwise, we end up at the return outside this "if" */
|
|
|
|
|
}
|
1999-07-08 04:19:36 +08:00
|
|
|
|
|
|
|
|
|
return val_print (type, VALUE_CONTENTS_ALL (val), VALUE_EMBEDDED_OFFSET (val),
|
1999-04-16 09:35:26 +08:00
|
|
|
|
VALUE_ADDRESS (val),
|
|
|
|
|
stream, format, 1, 0, pretty);
|
|
|
|
|
}
|