Add some more casts (2/2)
[deliverable/binutils-gdb.git] / gdb / typeprint.c
index 53cc9ebff0f31a827c25abb0280408797eee8a62..8fbd1789a89f4ad62bd6440d04ddb19c1bf160d4 100644 (file)
@@ -1,7 +1,6 @@
 /* Language independent support for printing types for GDB, the GNU debugger.
 
-   Copyright (C) 1986, 1988-1989, 1991-1995, 1998-2001, 2003, 2006-2012
-   Free Software Foundation, Inc.
+   Copyright (C) 1986-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "language.h"
 #include "cp-abi.h"
 #include "typeprint.h"
-#include "gdb_string.h"
-#include "exceptions.h"
 #include "valprint.h"
-#include <errno.h>
 #include <ctype.h>
 #include "cli/cli-utils.h"
-#include "python/python.h"
+#include "extension.h"
 #include "completer.h"
 
 extern void _initialize_typeprint (void);
@@ -91,7 +87,7 @@ struct typedef_hash_table
 static hashval_t
 hash_typedef_field (const void *p)
 {
-  const struct typedef_field *tf = p;
+  const struct typedef_field *tf = (const struct typedef_field *) p;
   struct type *t = check_typedef (tf->type);
 
   return htab_hash_string (TYPE_SAFE_NAME (t));
@@ -102,8 +98,8 @@ hash_typedef_field (const void *p)
 static int
 eq_typedef_field (const void *a, const void *b)
 {
-  const struct typedef_field *tfa = a;
-  const struct typedef_field *tfb = b;
+  const struct typedef_field *tfa = (const struct typedef_field *) a;
+  const struct typedef_field *tfb = (const struct typedef_field *) b;
 
   return types_equal (tfa->type, tfb->type);
 }
@@ -199,7 +195,7 @@ free_typedef_hash (struct typedef_hash_table *table)
 static void
 do_free_typedef_hash (void *arg)
 {
-  free_typedef_hash (arg);
+  free_typedef_hash ((struct typedef_hash_table *) arg);
 }
 
 /* Return a new cleanup that frees TABLE.  */
@@ -215,7 +211,7 @@ make_cleanup_free_typedef_hash (struct typedef_hash_table *table)
 static int
 copy_typedef_hash_element (void **slot, void *nt)
 {
-  htab_t new_table = nt;
+  htab_t new_table = (htab_t) nt;
   void **new_slot;
 
   new_slot = htab_find_slot (new_table, *slot, INSERT);
@@ -246,10 +242,10 @@ copy_typedef_hash (struct typedef_hash_table *table)
 static void
 do_free_global_table (void *arg)
 {
-  struct type_print_options *flags = arg;
+  struct type_print_options *flags = (struct type_print_options *) arg;
 
   free_typedef_hash (flags->global_typedefs);
-  free_type_printers (flags->global_printers);
+  free_ext_lang_type_printers (flags->global_printers);
 }
 
 /* Create the global typedef hash.  */
@@ -259,13 +255,13 @@ create_global_typedef_table (struct type_print_options *flags)
 {
   gdb_assert (flags->global_typedefs == NULL && flags->global_printers == NULL);
   flags->global_typedefs = create_typedef_hash ();
-  flags->global_printers = start_type_printers ();
+  flags->global_printers = start_ext_lang_type_printers ();
   return make_cleanup (do_free_global_table, flags);
 }
 
 /* Look up the type T in the global typedef hash.  If it is found,
    return the typedef name.  If it is not found, apply the
-   type-printers, if any, given by start_type_printers and return the
+   type-printers, if any, given by start_script_type_printers and return the
    result.  A NULL return means that the name was not found.  */
 
 static const char *
@@ -285,24 +281,25 @@ find_global_typedef (const struct type_print_options *flags,
   slot = htab_find_slot (flags->global_typedefs->table, &tf, INSERT);
   if (*slot != NULL)
     {
-      new_tf = *slot;
+      new_tf = (struct typedef_field *) *slot;
       return new_tf->name;
     }
 
-  /* Put an entry into the hash table now, in case apply_type_printers
-     recurses.  */
+  /* Put an entry into the hash table now, in case
+     apply_ext_lang_type_printers recurses.  */
   new_tf = XOBNEW (&flags->global_typedefs->storage, struct typedef_field);
   new_tf->name = NULL;
   new_tf->type = t;
 
   *slot = new_tf;
 
-  applied = apply_type_printers (flags->global_printers, t);
+  applied = apply_ext_lang_type_printers (flags->global_printers, t);
 
   if (applied != NULL)
     {
-      new_tf->name = obstack_copy0 (&flags->global_typedefs->storage, applied,
-                                   strlen (applied));
+      new_tf->name
+       = (const char *) obstack_copy0 (&flags->global_typedefs->storage,
+                                       applied, strlen (applied));
       xfree (applied);
     }
 
@@ -323,7 +320,8 @@ find_typedef_in_hash (const struct type_print_options *flags, struct type *t)
 
       tf.name = NULL;
       tf.type = t;
-      found = htab_find (flags->local_typedefs->table, &tf);
+      found = (struct typedef_field *) htab_find (flags->local_typedefs->table,
+                                                 &tf);
 
       if (found != NULL)
        return found->name;
@@ -339,9 +337,9 @@ find_typedef_in_hash (const struct type_print_options *flags, struct type *t)
    NEW is the new name for a type TYPE.  */
 
 void
-typedef_print (struct type *type, struct symbol *new, struct ui_file *stream)
+typedef_print (struct type *type, struct symbol *newobj, struct ui_file *stream)
 {
-  LA_PRINT_TYPEDEF (type, new, stream);
+  LA_PRINT_TYPEDEF (type, newobj, stream);
 }
 
 /* The default way to print a typedef.  */
@@ -376,18 +374,20 @@ type_to_string (struct type *type)
   char *s = NULL;
   struct ui_file *stb;
   struct cleanup *old_chain;
-  volatile struct gdb_exception except;
 
   stb = mem_fileopen ();
   old_chain = make_cleanup_ui_file_delete (stb);
 
-  TRY_CATCH (except, RETURN_MASK_ALL)
+  TRY
     {
       type_print (type, "", stb, -1);
       s = ui_file_xstrdup (stb, NULL);
     }
-  if (except.reason < 0)
-    s = NULL;
+  CATCH (except, RETURN_MASK_ALL)
+    {
+      s = NULL;
+    }
+  END_CATCH
 
   do_cleanups (old_chain);
 
@@ -465,9 +465,9 @@ whatis_exp (char *exp, int show)
     {
       if (((TYPE_CODE (type) == TYPE_CODE_PTR)
           || (TYPE_CODE (type) == TYPE_CODE_REF))
-         && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+         && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT))
         real_type = value_rtti_indirect_type (val, &full, &top, &using_enc);
-      else if (TYPE_CODE (type) == TYPE_CODE_CLASS)
+      else if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
        real_type = value_rtti_type (val, &full, &top, &using_enc);
     }
 
@@ -503,9 +503,9 @@ whatis_command (char *exp, int from_tty)
 /* TYPENAME is either the name of a type, or an expression.  */
 
 static void
-ptype_command (char *typename, int from_tty)
+ptype_command (char *type_name, int from_tty)
 {
-  whatis_exp (typename, 1);
+  whatis_exp (type_name, 1);
 }
 
 /* Print integral scalar data VAL, of type TYPE, onto stdio stream STREAM.
@@ -526,7 +526,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
   unsigned int i;
   unsigned len;
 
-  CHECK_TYPEDEF (type);
+  type = check_typedef (type);
 
   switch (TYPE_CODE (type))
     {
@@ -596,16 +596,16 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
    and whatis_command().  */
 
 void
-maintenance_print_type (char *typename, int from_tty)
+maintenance_print_type (char *type_name, int from_tty)
 {
   struct value *val;
   struct type *type;
   struct cleanup *old_chain;
   struct expression *expr;
 
-  if (typename != NULL)
+  if (type_name != NULL)
     {
-      expr = parse_expression (typename);
+      expr = parse_expression (type_name);
       old_chain = make_cleanup (free_current_contents, &expr);
       if (expr->elts[0].opcode == OP_TYPE)
        {
@@ -637,7 +637,7 @@ set_print_type (char *arg, int from_tty)
 {
   printf_unfiltered (
      "\"set print type\" must be followed by the name of a subcommand.\n");
-  help_list (setprintlist, "set print type ", -1, gdb_stdout);
+  help_list (setprintlist, "set print type ", all_commands, gdb_stdout);
 }
 
 static void
@@ -685,9 +685,10 @@ _initialize_typeprint (void)
 
   c = add_com ("ptype", class_vars, ptype_command, _("\
 Print definition of type TYPE.\n\
-Usage: ptype[/FLAGS] TYPE-NAME | EXPRESSION\n\
-Argument may be a type name defined by typedef, or \"struct STRUCT-TAG\"\n\
-or \"class CLASS-NAME\" or \"union UNION-TAG\" or \"enum ENUM-TAG\".\n\
+Usage: ptype[/FLAGS] TYPE | EXPRESSION\n\
+Argument may be any type (for example a type name defined by typedef,\n\
+or \"struct STRUCT-TAG\" or \"class CLASS-NAME\" or \"union UNION-TAG\"\n\
+or \"enum ENUM-TAG\") or an expression.\n\
 The selected stack frame's lexical context is used to look up the name.\n\
 Contrary to \"whatis\", \"ptype\" always unrolls any typedefs.\n\
 \n\
This page took 0.028739 seconds and 4 git commands to generate.