aboutsummaryrefslogtreecommitdiff
path: root/gdb/demangle.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/demangle.c')
-rw-r--r--gdb/demangle.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/gdb/demangle.c b/gdb/demangle.c
index 2c59dec..20758be 100644
--- a/gdb/demangle.c
+++ b/gdb/demangle.c
@@ -49,6 +49,11 @@ extern void _initialize_demangler (void);
static char *current_demangling_style_string;
+/* The array of names of the known demanglyng styles. Generated by
+ _initialize_demangler from libiberty_demanglers[] array. */
+
+static const char **demangling_style_names;
+
static void set_demangling_command (char *, int, struct cmd_list_element *);
/* Set current demangling style. Called by the "set demangle-style"
@@ -173,12 +178,26 @@ void
_initialize_demangler (void)
{
struct cmd_list_element *set, *show;
-
- set = add_set_cmd ("demangle-style", class_support, var_string_noescape,
- (char *) &current_demangling_style_string,
- "Set the current C++ demangling style.\n\
+ int i, ndems;
+
+ /* Fill the demangling_style_names[] array. */
+ for (ndems = 0;
+ libiberty_demanglers[ndems].demangling_style != unknown_demangling;
+ ndems++)
+ ;
+ demangling_style_names = xmalloc (ndems * sizeof (char *));
+ for (i = 0;
+ libiberty_demanglers[i].demangling_style != unknown_demangling;
+ i++)
+ demangling_style_names[i] =
+ xstrdup (libiberty_demanglers[i].demangling_style_name);
+
+ set = add_set_enum_cmd ("demangle-style", class_support,
+ demangling_style_names,
+ (const char **) &current_demangling_style_string,
+ "Set the current C++ demangling style.\n\
Use `set demangle-style' without arguments for a list of demangling styles.",
- &setlist);
+ &setlist);
show = add_show_from_set (set, &showlist);
set->function.sfunc = set_demangling_command;