s/struct _serial_t/struct serial/
[deliverable/binutils-gdb.git] / gdb / c-valprint.c
index 784cbc8bbdc4f2fda9f86adc01d5878ef59e3ed6..e1e8b8211b430f97c551d0812ef1bda5c754345b 100644 (file)
@@ -1,5 +1,6 @@
 /* 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
@@ -129,7 +150,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
             -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));
@@ -152,7 +173,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
          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);
            }
@@ -283,6 +304,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
        }
       /* Fall through.  */
     case TYPE_CODE_STRUCT:
+      /*FIXME: Abstract this away */
       if (vtblprint && cp_is_vtbl_ptr_type (type))
        {
          /* Print the unmangled name if desired.  */
@@ -294,7 +316,7 @@ c_val_print (struct type *type, char *valaddr, int embedded_offset,
          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,
This page took 0.024612 seconds and 4 git commands to generate.