* defs.h (is_cplus_marker, set_demangling_style): Moved to ...

* gdb-demangle.h: ... here.  New file.
	* demangle.c: #include "gdb-demangle.h".
	(_initialize_demangler): Use initialize_file_ftype for prototype.
	Move "set demangle" and "set asm-demangle" parameters here from utils.c
	(demangle, show_demangle, asm_demangle, show_asm_demangle): Move here
	from utils.c
	* utils.c: Update. #include "gdb-demangle.h".
	* symtab.h (asm_demangle): Delete.
	(demangle): Move declaration next to use.
	* breakpoint.c: #include "gdb-demangle.h" instead of "demangle.h".
	* dwarf2read.c: #include "gdb-demangle.h".
	* gnu-v2-abi.c: Ditto.
	* jv-typeprint.c: Ditto.
	* mdebugread.c: Ditto.
	* p-typeprint.c: Ditto.
	* stabsread.c: Ditto.
	* printcmd.c: Ditto.
	(asm_demangle): Delete declaration.
	* tui/tui-stack.c: #include "gdb-demangle.h".
This commit is contained in:
Doug Evans
2011-11-10 20:21:29 +00:00
parent 6953d2240a
commit 50f182aa66
15 changed files with 118 additions and 67 deletions

View File

@ -10,6 +10,27 @@
2011-11-10 Doug Evans <dje@google.com> 2011-11-10 Doug Evans <dje@google.com>
* defs.h (is_cplus_marker, set_demangling_style): Moved to ...
* gdb-demangle.h: ... here. New file.
* demangle.c: #include "gdb-demangle.h".
(_initialize_demangler): Use initialize_file_ftype for prototype.
Move "set demangle" and "set asm-demangle" parameters here from utils.c
(demangle, show_demangle, asm_demangle, show_asm_demangle): Move here
from utils.c
* utils.c: Update. #include "gdb-demangle.h".
* symtab.h (asm_demangle): Delete.
(demangle): Move declaration next to use.
* breakpoint.c: #include "gdb-demangle.h" instead of "demangle.h".
* dwarf2read.c: #include "gdb-demangle.h".
* gnu-v2-abi.c: Ditto.
* jv-typeprint.c: Ditto.
* mdebugread.c: Ditto.
* p-typeprint.c: Ditto.
* stabsread.c: Ditto.
* printcmd.c: Ditto.
(asm_demangle): Delete declaration.
* tui/tui-stack.c: #include "gdb-demangle.h".
* python/py-type.c (typy_fields_items): Call check_typedef. * python/py-type.c (typy_fields_items): Call check_typedef.
2011-11-10 Joel Brobecker <brobecker@adacore.com> 2011-11-10 Joel Brobecker <brobecker@adacore.com>

View File

@ -38,7 +38,7 @@
#include "target.h" #include "target.h"
#include "language.h" #include "language.h"
#include "gdb_string.h" #include "gdb_string.h"
#include "demangle.h" #include "gdb-demangle.h"
#include "filenames.h" #include "filenames.h"
#include "annotate.h" #include "annotate.h"
#include "symfile.h" #include "symfile.h"

View File

@ -149,9 +149,6 @@ typedef bfd_vma CORE_ADDR;
#include "ptid.h" #include "ptid.h"
/* Check if a character is one of the commonly used C++ marker characters. */
extern int is_cplus_marker (int);
/* Enable xdb commands if set. */ /* Enable xdb commands if set. */
extern int xdb_commands; extern int xdb_commands;
@ -442,10 +439,6 @@ extern struct cleanup *make_bpstat_clear_actions_cleanup (void);
extern int producer_is_gcc_ge_4 (const char *producer); extern int producer_is_gcc_ge_4 (const char *producer);
/* From demangle.c */
extern void set_demangling_style (char *);
/* Annotation stuff. */ /* Annotation stuff. */

View File

@ -28,6 +28,7 @@
#include "command.h" #include "command.h"
#include "gdbcmd.h" #include "gdbcmd.h"
#include "demangle.h" #include "demangle.h"
#include "gdb-demangle.h"
#include "gdb_string.h" #include "gdb_string.h"
/* Select the default C++ demangling style to use. The default is "auto", /* Select the default C++ demangling style to use. The default is "auto",
@ -42,7 +43,31 @@
#define DEFAULT_DEMANGLING_STYLE AUTO_DEMANGLING_STYLE_STRING #define DEFAULT_DEMANGLING_STYLE AUTO_DEMANGLING_STYLE_STRING
#endif #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 /* String name for the current demangling style. Set by the
"set demangle-style" command, printed as part of the output by the "set demangle-style" command, printed as part of the output by the
@ -62,9 +87,6 @@ show_demangling_style_names(struct ui_file *file, int from_tty,
value); value);
} }
static void set_demangling_command (char *, int, struct cmd_list_element *);
/* Set current demangling style. Called by the "set demangle-style" /* Set current demangling style. Called by the "set demangle-style"
command after it has updated the current_demangling_style_string to command after it has updated the current_demangling_style_string to
match what the user has entered. match what the user has entered.
@ -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 void
set_demangling_style (char *style) set_demangling_style (char *style)
@ -168,12 +190,16 @@ set_demangling_style (char *style)
static char cplus_markers[] = {'$', '.', '\0'}; static char cplus_markers[] = {'$', '.', '\0'};
/* See documentation in gdb-demangle.h. */
int int
is_cplus_marker (int c) is_cplus_marker (int c)
{ {
return c && strchr (cplus_markers, c) != NULL; return c && strchr (cplus_markers, c) != NULL;
} }
extern initialize_file_ftype _initialize_demangler; /* -Wmissing-prototypes */
void void
_initialize_demangler (void) _initialize_demangler (void)
{ {
@ -191,6 +217,20 @@ _initialize_demangler (void)
demangling_style_names[i] = demangling_style_names[i] =
xstrdup (libiberty_demanglers[i].demangling_style_name); 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 /* FIXME: cagney/2005-02-20: The code implementing this variable are
malloc-ing and free-ing current_demangling_style_string when it malloc-ing and free-ing current_demangling_style_string when it
should instead just point to an element of should instead just point to an element of

View File

@ -34,6 +34,7 @@
#include "dwarf2.h" #include "dwarf2.h"
#include "buildsym.h" #include "buildsym.h"
#include "demangle.h" #include "demangle.h"
#include "gdb-demangle.h"
#include "expression.h" #include "expression.h"
#include "filenames.h" /* for DOSish file names */ #include "filenames.h" /* for DOSish file names */
#include "macrotab.h" #include "macrotab.h"

37
gdb/gdb-demangle.h Normal file
View File

@ -0,0 +1,37 @@
/* Basic C++ demangling support for GDB.
Copyright (c) 2011 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef GDB_DEMANGLE_H
#define GDB_DEMANGLE_H
/* Nonzero means that encoded C++/ObjC names should be printed out in their
C++/ObjC form rather than raw. */
extern int demangle;
/* Nonzero means that encoded C++/ObjC names should be printed out in their
C++/ObjC form even in assembler language displays. If this is set, but
DEMANGLE is zero, names are printed raw, i.e. DEMANGLE controls. */
extern int asm_demangle;
/* Fake a "set demangle-style" command. */
extern void set_demangling_style (char *);
/* Check if a character is one of the commonly used C++ marker characters. */
extern int is_cplus_marker (int);
#endif /* GDB_DEMANGLE_H */

View File

@ -26,6 +26,7 @@
#include "gdbtypes.h" #include "gdbtypes.h"
#include "value.h" #include "value.h"
#include "demangle.h" #include "demangle.h"
#include "gdb-demangle.h"
#include "cp-abi.h" #include "cp-abi.h"
#include "cp-support.h" #include "cp-support.h"
#include "exceptions.h" #include "exceptions.h"

View File

@ -23,6 +23,7 @@
#include "gdbtypes.h" #include "gdbtypes.h"
#include "value.h" #include "value.h"
#include "demangle.h" #include "demangle.h"
#include "gdb-demangle.h"
#include "jv-lang.h" #include "jv-lang.h"
#include "gdb_string.h" #include "gdb_string.h"
#include "typeprint.h" #include "typeprint.h"

View File

@ -52,6 +52,7 @@
#include "stabsread.h" #include "stabsread.h"
#include "complaints.h" #include "complaints.h"
#include "demangle.h" #include "demangle.h"
#include "gdb-demangle.h"
#include "gdb_assert.h" #include "gdb_assert.h"
#include "block.h" #include "block.h"
#include "dictionary.h" #include "dictionary.h"

View File

@ -31,7 +31,7 @@
#include "language.h" #include "language.h"
#include "p-lang.h" #include "p-lang.h"
#include "typeprint.h" #include "typeprint.h"
#include "gdb-demangle.h"
#include "gdb_string.h" #include "gdb_string.h"
#include <errno.h> #include <errno.h>
#include <ctype.h> #include <ctype.h>

View File

@ -32,6 +32,7 @@
#include "target.h" #include "target.h"
#include "breakpoint.h" #include "breakpoint.h"
#include "demangle.h" #include "demangle.h"
#include "gdb-demangle.h"
#include "valprint.h" #include "valprint.h"
#include "annotate.h" #include "annotate.h"
#include "symfile.h" /* for overlay functions */ #include "symfile.h" /* for overlay functions */
@ -62,9 +63,6 @@
# define USE_PRINTF_I64 0 # define USE_PRINTF_I64 0
#endif #endif
extern int asm_demangle; /* Whether to demangle syms in asm
printouts. */
struct format_data struct format_data
{ {
int count; int count;

View File

@ -41,6 +41,7 @@
#include "buildsym.h" #include "buildsym.h"
#include "complaints.h" #include "complaints.h"
#include "demangle.h" #include "demangle.h"
#include "gdb-demangle.h"
#include "language.h" #include "language.h"
#include "doublest.h" #include "doublest.h"
#include "cp-abi.h" #include "cp-abi.h"

View File

@ -244,11 +244,14 @@ extern char *symbol_demangled_name (const struct general_symbol_info *symbol);
name if demangle is on and the "mangled" form of the name if name if demangle is on and the "mangled" form of the name if
demangle is off. In other languages this is just the symbol name. demangle is off. In other languages this is just the symbol name.
The result should never be NULL. Don't use this for internal The result should never be NULL. Don't use this for internal
purposes (e.g. storing in a hashtable): it's only suitable for purposes (e.g. storing in a hashtable): it's only suitable for output.
output. */
N.B. symbol may be anything with a ginfo member,
e.g., struct symbol or struct minimal_symbol. */
#define SYMBOL_PRINT_NAME(symbol) \ #define SYMBOL_PRINT_NAME(symbol) \
(demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol)) (demangle ? SYMBOL_NATURAL_NAME (symbol) : SYMBOL_LINKAGE_NAME (symbol))
extern int demangle;
/* Macro that tests a symbol for a match against a specified name string. /* Macro that tests a symbol for a match against a specified name string.
First test the unencoded name, then looks for and test a C++ encoded First test the unencoded name, then looks for and test a C++ encoded
@ -866,10 +869,6 @@ struct symtab
extern int currently_reading_symtab; extern int currently_reading_symtab;
/* From utils.c. */
extern int demangle;
extern int asm_demangle;
/* symtab.c lookup functions */ /* symtab.c lookup functions */
extern const char multiple_symbols_ask[]; extern const char multiple_symbols_ask[];

View File

@ -28,6 +28,7 @@
#include "inferior.h" #include "inferior.h"
#include "target.h" #include "target.h"
#include "top.h" #include "top.h"
#include "gdb-demangle.h"
#include "gdb_string.h" #include "gdb_string.h"
#include "tui/tui.h" #include "tui/tui.h"
#include "tui/tui-data.h" #include "tui/tui-data.h"

View File

@ -50,7 +50,7 @@
#include "serial.h" #include "serial.h"
#include "bfd.h" #include "bfd.h"
#include "target.h" #include "target.h"
#include "demangle.h" #include "gdb-demangle.h"
#include "expression.h" #include "expression.h"
#include "language.h" #include "language.h"
#include "charset.h" #include "charset.h"
@ -138,35 +138,6 @@ int quit_flag;
int immediate_quit; int immediate_quit;
/* Nonzero means that encoded C++/ObjC names should be printed out in their
C++/ObjC form rather than raw. */
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);
}
/* Nonzero means that encoded C++/ObjC names should be printed out in their
C++/ObjC form even in assembler language displays. If this is set, but
DEMANGLE is zero, names are printed raw, i.e. DEMANGLE controls. */
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);
}
/* Nonzero means that strings with character values >0x7F should be printed /* Nonzero means that strings with character values >0x7F should be printed
as octal escapes. Zero means just print the value (e.g. it's an as octal escapes. Zero means just print the value (e.g. it's an
international character, and the terminal or window can cope.) */ international character, and the terminal or window can cope.) */
@ -2864,13 +2835,6 @@ Show number of lines gdb thinks are in a page."), NULL,
init_page_info (); init_page_info ();
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 ("pagination", class_support, add_setshow_boolean_cmd ("pagination", class_support,
&pagination_enabled, _("\ &pagination_enabled, _("\
Set state of pagination."), _("\ Set state of pagination."), _("\
@ -2895,13 +2859,6 @@ Show printing of 8-bit characters in strings as \\nnn."), NULL,
show_sevenbit_strings, show_sevenbit_strings,
&setprintlist, &showprintlist); &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);
add_setshow_boolean_cmd ("timestamp", class_maintenance, add_setshow_boolean_cmd ("timestamp", class_maintenance,
&debug_timestamp, _("\ &debug_timestamp, _("\
Set timestamping of debugging messages."), _("\ Set timestamping of debugging messages."), _("\