gdb/testsuite/
[binutils-gdb.git] / gdb / cp-abi.c
index ced1a96b965b98b35a2c7666eccf6a5cab682b9a..14552d1e6d95309685eb13feb2a6ad72147ba7d5 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic code for supporting multiple C++ ABI's
 
 /* Generic code for supporting multiple C++ ABI's
 
-   Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007
+   Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GDB.
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -22,6 +22,7 @@
 #include "value.h"
 #include "cp-abi.h"
 #include "command.h"
 #include "value.h"
 #include "cp-abi.h"
 #include "command.h"
+#include "exceptions.h"
 #include "gdbcmd.h"
 #include "ui-out.h"
 
 #include "gdbcmd.h"
 #include "ui-out.h"
 
@@ -89,9 +90,18 @@ value_virtual_fn_field (struct value **arg1p, struct fn_field *f, int j,
 struct type *
 value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
 {
 struct type *
 value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
 {
+  struct type *ret = NULL;
+  struct gdb_exception e;
+
   if ((current_cp_abi.rtti_type) == NULL)
     return NULL;
   if ((current_cp_abi.rtti_type) == NULL)
     return NULL;
-  return (*current_cp_abi.rtti_type) (v, full, top, using_enc);
+  TRY_CATCH (e, RETURN_MASK_ERROR)
+    {
+      ret = (*current_cp_abi.rtti_type) (v, full, top, using_enc);
+    }
+  if (e.reason < 0)
+    return NULL;
+  return ret;
 }
 
 void
 }
 
 void
@@ -104,19 +114,20 @@ cplus_print_method_ptr (const gdb_byte *contents, struct type *type,
 }
 
 int
 }
 
 int
-cplus_method_ptr_size (void)
+cplus_method_ptr_size (struct type *to_type)
 {
   if (current_cp_abi.method_ptr_size == NULL)
     error (_("GDB does not support pointers to methods on this target"));
 {
   if (current_cp_abi.method_ptr_size == NULL)
     error (_("GDB does not support pointers to methods on this target"));
-  return (*current_cp_abi.method_ptr_size) ();
+  return (*current_cp_abi.method_ptr_size) (to_type);
 }
 
 void
 }
 
 void
-cplus_make_method_ptr (gdb_byte *contents, CORE_ADDR value, int is_virtual)
+cplus_make_method_ptr (struct type *type, gdb_byte *contents,
+                      CORE_ADDR value, int is_virtual)
 {
   if (current_cp_abi.make_method_ptr == NULL)
     error (_("GDB does not support pointers to methods on this target"));
 {
   if (current_cp_abi.make_method_ptr == NULL)
     error (_("GDB does not support pointers to methods on this target"));
-  (*current_cp_abi.make_method_ptr) (contents, value, is_virtual);
+  (*current_cp_abi.make_method_ptr) (type, contents, value, is_virtual);
 }
 
 CORE_ADDR
 }
 
 CORE_ADDR
@@ -193,10 +204,10 @@ set_cp_abi_as_auto_default (const char *short_name)
   auto_cp_abi = *abi;
 
   auto_cp_abi.shortname = "auto";
   auto_cp_abi = *abi;
 
   auto_cp_abi.shortname = "auto";
-  xasprintf (&new_longname, "currently \"%s\"", abi->shortname);
+  new_longname = xstrprintf ("currently \"%s\"", abi->shortname);
   auto_cp_abi.longname = new_longname;
 
   auto_cp_abi.longname = new_longname;
 
-  xasprintf (&new_doc, "Automatically selected; currently \"%s\"",
+  new_doc = xstrprintf ("Automatically selected; currently \"%s\"",
             abi->shortname);
   auto_cp_abi.doc = new_doc;
 
             abi->shortname);
   auto_cp_abi.doc = new_doc;
 
@@ -228,8 +239,8 @@ list_cp_abis (int from_tty)
 {
   struct cleanup *cleanup_chain;
   int i;
 {
   struct cleanup *cleanup_chain;
   int i;
-  ui_out_text (uiout, "The available C++ ABIs are:\n");
 
 
+  ui_out_text (uiout, "The available C++ ABIs are:\n");
   cleanup_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "cp-abi-list");
   for (i = 0; i < num_cp_abis; i++)
     {
   cleanup_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "cp-abi-list");
   for (i = 0; i < num_cp_abis; i++)
     {