/* Support for printing C values for GDB, the GNU debugger.
- Copyright 1986, 1988, 1989, 1991-1997, 2000
+ Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+ 1998, 1999, 2000
Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbtypes.h"
#include "expression.h"
#include "value.h"
-#include "demangle.h"
#include "valprint.h"
#include "language.h"
#include "c-lang.h"
+#include "cp-abi.h"
\f
+/* 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);
+}
+
+
/* 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
The PRETTY parameter controls prettyprinting. */
int
-c_val_print (type, valaddr, embedded_offset, address, stream, format, deref_ref, recurse,
- pretty)
- 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;
+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)
{
register unsigned int i = 0; /* Number of characters printed */
unsigned len;
-fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
CORE_ADDR addr
= extract_typed_address (valaddr + embedded_offset, type);
- print_address_demangle (addr, stream, demangle);
+ print_function_pointer_address (addr, stream);
break;
}
elttype = check_typedef (TYPE_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
/* Try to print what function it points to. */
- print_address_demangle (addr, stream, demangle);
+ print_function_pointer_address (addr, stream);
/* Return value is irrelevant except for string pointers. */
return (0);
}
}
/* Fall through. */
case TYPE_CODE_STRUCT:
+ /*FIXME: Abstract this away */
if (vtblprint && cp_is_vtbl_ptr_type (type))
{
/* Print the unmangled name if desired. */
CORE_ADDR addr
= extract_typed_address (valaddr + offset, field_type);
- print_address_demangle (addr, stream, demangle);
+ print_function_pointer_address (addr, stream);
}
else
cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,
}
\f
int
-c_value_print (val, stream, format, pretty)
- value_ptr val;
- struct ui_file *stream;
- int format;
- enum val_prettyprint pretty;
+c_value_print (value_ptr val, struct ui_file *stream, int format,
+ enum val_prettyprint pretty)
{
struct type *type = VALUE_TYPE (val);
struct type *real_type;