2012-02-27 Luis Machado <lgustavo@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / demangle.c
index b5ccf8719aae21540facd328218f01dfc5317967..fa6f4a635d62a557a3a368ff486928b3151211b8 100644 (file)
@@ -1,7 +1,7 @@
 /* Basic C++ demangling support for GDB.
 
-   Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-   2003, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1991-1996, 1998-2001, 2003, 2007-2012 Free Software
+   Foundation, Inc.
 
    Written by Fred Fish at Cygnus Support.
 
 
 
 /*  This file contains support code for C++ demangling that is common
-   to a styles of demangling, and GDB specific. */
+   to a styles of demangling, and GDB specific.  */
 
 #include "defs.h"
 #include "command.h"
 #include "gdbcmd.h"
 #include "demangle.h"
+#include "gdb-demangle.h"
 #include "gdb_string.h"
 
 /* Select the default C++ demangling style to use.  The default is "auto",
    "lucid", "arm", "hp", etc.) in which case gdb will never attempt to do auto
    selection of the style unless you do an explicit "set demangle auto".
    To select one of these as the default, set DEFAULT_DEMANGLING_STYLE in
-   the appropriate target configuration file. */
+   the appropriate target configuration file.  */
 
 #ifndef DEFAULT_DEMANGLING_STYLE
 #define DEFAULT_DEMANGLING_STYLE AUTO_DEMANGLING_STYLE_STRING
 #endif
 
-extern void _initialize_demangler (void);
+/* See documentation in gdb-demangle.h.  */
+int demangle = 1;
+
+static void
+show_demangle (struct ui_file *file, int from_tty,
+              struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file,
+                   _("Demangling of encoded C++/ObjC names "
+                     "when displaying symbols is %s.\n"),
+                   value);
+}
+
+/* See documentation in gdb-demangle.h.  */
+int asm_demangle = 0;
+
+static void
+show_asm_demangle (struct ui_file *file, int from_tty,
+                  struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file,
+                   _("Demangling of C++/ObjC names in "
+                     "disassembly listings is %s.\n"),
+                   value);
+}
 
 /* String name for the current demangling style.  Set by the
    "set demangle-style" command, printed as part of the output by the
-   "show demangle-style" command. */
+   "show demangle-style" command.  */
 
 static char *current_demangling_style_string;
 
@@ -62,9 +87,6 @@ show_demangling_style_names(struct ui_file *file, int from_tty,
                    value);
 }
 
-
-static void set_demangling_command (char *, int, struct cmd_list_element *);
-
 /* Set current demangling style.  Called by the "set demangle-style"
    command after it has updated the current_demangling_style_string to
    match what the user has entered.
@@ -79,7 +101,7 @@ static void set_demangling_command (char *, int, struct cmd_list_element *);
    enum value.
 
    Note:  Assumes that current_demangling_style_string always points to
-   a malloc'd string, even if it is a null-string. */
+   a malloc'd string, even if it is a null-string.  */
 
 static void
 set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
@@ -89,7 +111,7 @@ set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
   /*  First just try to match whatever style name the user supplied with
      one of the known ones.  Don't bother special casing for an empty
      name, we just treat it as any other style name that doesn't match.
-     If we match, update the current demangling style enum. */
+     If we match, update the current demangling style enum.  */
 
   for (dem = libiberty_demanglers; 
        dem->demangling_style != unknown_demangling; 
@@ -104,8 +126,8 @@ set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
     }
 
   /* Check to see if we found a match.  If not, gripe about any non-empty
-     style name and supply a list of valid ones.  FIXME:  This should
-     probably be done with some sort of completion and with help. */
+     style name and supply a list of valid ones.  FIXME: This should
+     probably be done with some sort of completion and with help.  */
 
   if (dem->demangling_style == unknown_demangling)
     {
@@ -132,7 +154,7 @@ set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
        {
          /* This can happen during initialization if gdb is compiled with
             a DEMANGLING_STYLE value that is unknown, so pick the first
-            one as the default. */
+            one as the default.  */
          current_demangling_style = libiberty_demanglers[0].demangling_style;
          current_demangling_style_string =
            xstrdup (libiberty_demanglers[0].demangling_style_name);
@@ -142,7 +164,7 @@ set_demangling_command (char *ignore, int from_tty, struct cmd_list_element *c)
     }
 }
 
-/* Fake a "set demangle-style" command. */
+/* See documentation in gdb-demangle.h.  */
 
 void
 set_demangling_style (char *style)
@@ -168,16 +190,19 @@ set_demangling_style (char *style)
 
 static char cplus_markers[] = {'$', '.', '\0'};
 
+/* See documentation in gdb-demangle.h.  */
+
 int
 is_cplus_marker (int c)
 {
   return c && strchr (cplus_markers, c) != NULL;
 }
 
+extern initialize_file_ftype _initialize_demangler; /* -Wmissing-prototypes */
+
 void
 _initialize_demangler (void)
 {
-  struct cmd_list_element *set, *show;
   int i, ndems;
 
   /* Fill the demangling_style_names[] array.  */
@@ -192,6 +217,20 @@ _initialize_demangler (void)
     demangling_style_names[i] =
       xstrdup (libiberty_demanglers[i].demangling_style_name);
 
+  add_setshow_boolean_cmd ("demangle", class_support, &demangle, _("\
+Set demangling of encoded C++/ObjC names when displaying symbols."), _("\
+Show demangling of encoded C++/ObjC names when displaying symbols."), NULL,
+                          NULL,
+                          show_demangle,
+                          &setprintlist, &showprintlist);
+
+  add_setshow_boolean_cmd ("asm-demangle", class_support, &asm_demangle, _("\
+Set demangling of C++/ObjC names in disassembly listings."), _("\
+Show demangling of C++/ObjC names in disassembly listings."), NULL,
+                          NULL,
+                          show_asm_demangle,
+                          &setprintlist, &showprintlist);
+
   /* FIXME: cagney/2005-02-20: The code implementing this variable are
      malloc-ing and free-ing current_demangling_style_string when it
      should instead just point to an element of
@@ -206,6 +245,6 @@ Use `set demangle-style' without arguments for a list of demangling styles."),
                        show_demangling_style_names,
                        &setlist, &showlist);
 
-  /* Set the default demangling style chosen at compilation time. */
+  /* Set the default demangling style chosen at compilation time.  */
   set_demangling_style (DEFAULT_DEMANGLING_STYLE);
 }
This page took 0.025431 seconds and 4 git commands to generate.