From 50f182aa6671dea0fdcf063d5974c623332f3e63 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Thu, 10 Nov 2011 20:21:29 +0000 Subject: * 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". --- gdb/ChangeLog | 21 +++++++++++++++++++++ gdb/breakpoint.c | 2 +- gdb/defs.h | 7 ------- gdb/demangle.c | 50 +++++++++++++++++++++++++++++++++++++++++++++----- gdb/dwarf2read.c | 1 + gdb/gdb-demangle.h | 37 +++++++++++++++++++++++++++++++++++++ gdb/gnu-v2-abi.c | 1 + gdb/jv-typeprint.c | 1 + gdb/mdebugread.c | 1 + gdb/p-typeprint.c | 2 +- gdb/printcmd.c | 4 +--- gdb/stabsread.c | 1 + gdb/symtab.h | 11 +++++------ gdb/tui/tui-stack.c | 1 + gdb/utils.c | 45 +-------------------------------------------- 15 files changed, 118 insertions(+), 67 deletions(-) create mode 100644 gdb/gdb-demangle.h (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 577e9b0..4cdc9ed 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -10,6 +10,27 @@ 2011-11-10 Doug Evans + * 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. 2011-11-10 Joel Brobecker diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 8c98bef..b78b011 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -38,7 +38,7 @@ #include "target.h" #include "language.h" #include "gdb_string.h" -#include "demangle.h" +#include "gdb-demangle.h" #include "filenames.h" #include "annotate.h" #include "symfile.h" diff --git a/gdb/defs.h b/gdb/defs.h index d0b6813..b5bc6c5 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -149,9 +149,6 @@ typedef bfd_vma CORE_ADDR; #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. */ 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); -/* From demangle.c */ - -extern void set_demangling_style (char *); - /* Annotation stuff. */ diff --git a/gdb/demangle.c b/gdb/demangle.c index 5600692..bf4d937 100644 --- a/gdb/demangle.c +++ b/gdb/demangle.c @@ -28,6 +28,7 @@ #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", @@ -42,7 +43,31 @@ #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 @@ -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. @@ -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,12 +190,16 @@ 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) { @@ -191,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 diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 84eb589..5a3e469 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -34,6 +34,7 @@ #include "dwarf2.h" #include "buildsym.h" #include "demangle.h" +#include "gdb-demangle.h" #include "expression.h" #include "filenames.h" /* for DOSish file names */ #include "macrotab.h" diff --git a/gdb/gdb-demangle.h b/gdb/gdb-demangle.h new file mode 100644 index 0000000..2b8c6ac --- /dev/null +++ b/gdb/gdb-demangle.h @@ -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 . */ + +#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 */ diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 3d49a06..a0d4830 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -26,6 +26,7 @@ #include "gdbtypes.h" #include "value.h" #include "demangle.h" +#include "gdb-demangle.h" #include "cp-abi.h" #include "cp-support.h" #include "exceptions.h" diff --git a/gdb/jv-typeprint.c b/gdb/jv-typeprint.c index 8d9ebfd..b1e6aba 100644 --- a/gdb/jv-typeprint.c +++ b/gdb/jv-typeprint.c @@ -23,6 +23,7 @@ #include "gdbtypes.h" #include "value.h" #include "demangle.h" +#include "gdb-demangle.h" #include "jv-lang.h" #include "gdb_string.h" #include "typeprint.h" diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 29fe97b..0eab988 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -52,6 +52,7 @@ #include "stabsread.h" #include "complaints.h" #include "demangle.h" +#include "gdb-demangle.h" #include "gdb_assert.h" #include "block.h" #include "dictionary.h" diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 5ac3bc5..04e3025 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -31,7 +31,7 @@ #include "language.h" #include "p-lang.h" #include "typeprint.h" - +#include "gdb-demangle.h" #include "gdb_string.h" #include #include diff --git a/gdb/printcmd.c b/gdb/printcmd.c index ad6993e..5a522f4 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -32,6 +32,7 @@ #include "target.h" #include "breakpoint.h" #include "demangle.h" +#include "gdb-demangle.h" #include "valprint.h" #include "annotate.h" #include "symfile.h" /* for overlay functions */ @@ -62,9 +63,6 @@ # define USE_PRINTF_I64 0 #endif -extern int asm_demangle; /* Whether to demangle syms in asm - printouts. */ - struct format_data { int count; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 3ff3f5e..bb51808 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -41,6 +41,7 @@ #include "buildsym.h" #include "complaints.h" #include "demangle.h" +#include "gdb-demangle.h" #include "language.h" #include "doublest.h" #include "cp-abi.h" diff --git a/gdb/symtab.h b/gdb/symtab.h index 90a6fe4..e5bf155 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -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 demangle is off. In other languages this is just the symbol name. The result should never be NULL. Don't use this for internal - purposes (e.g. storing in a hashtable): it's only suitable for - output. */ + purposes (e.g. storing in a hashtable): it's only suitable for output. + + N.B. symbol may be anything with a ginfo member, + e.g., struct symbol or struct minimal_symbol. */ #define SYMBOL_PRINT_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. First test the unencoded name, then looks for and test a C++ encoded @@ -866,10 +869,6 @@ struct symtab extern int currently_reading_symtab; -/* From utils.c. */ -extern int demangle; -extern int asm_demangle; - /* symtab.c lookup functions */ extern const char multiple_symbols_ask[]; diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c index 1ec9bcc..10d52e8 100644 --- a/gdb/tui/tui-stack.c +++ b/gdb/tui/tui-stack.c @@ -28,6 +28,7 @@ #include "inferior.h" #include "target.h" #include "top.h" +#include "gdb-demangle.h" #include "gdb_string.h" #include "tui/tui.h" #include "tui/tui-data.h" diff --git a/gdb/utils.c b/gdb/utils.c index 008baac..82a0f45 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -50,7 +50,7 @@ #include "serial.h" #include "bfd.h" #include "target.h" -#include "demangle.h" +#include "gdb-demangle.h" #include "expression.h" #include "language.h" #include "charset.h" @@ -138,35 +138,6 @@ int quit_flag; 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 as octal escapes. Zero means just print the value (e.g. it's an 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 (); - 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, &pagination_enabled, _("\ Set state of pagination."), _("\ @@ -2895,13 +2859,6 @@ Show printing of 8-bit characters in strings as \\nnn."), NULL, show_sevenbit_strings, &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, &debug_timestamp, _("\ Set timestamping of debugging messages."), _("\ -- cgit v1.1