@@ -47,6 +47,11 @@
* New commands
+demangle name
+ Demangle "name" in the current language. This command is renamed from
+ the"maint demangle" command. The latter is kept as a no-op to avoid
+ "maint demangle" being interpreted as "maint demangler-warning".
+
queue-signal signal-name-or-number
Queue a signal to be delivered to the thread when it is resumed.
@@ -28,6 +28,8 @@
#include "gdbcmd.h"
#include "demangle.h"
#include "gdb-demangle.h"
+#include "language.h"
+
/* Select the default C++ demangling style to use. The default is "auto",
which allows gdb to attempt to pick an appropriate demangling style for
the executable it has loaded. It can be set to a specific style ("gnu",
@@ -40,6 +42,8 @@
#define DEFAULT_DEMANGLING_STYLE AUTO_DEMANGLING_STYLE_STRING
#endif
+static void demangle_command (char *, int);
+
/* See documentation in gdb-demangle.h. */
int demangle = 1;
@@ -151,6 +155,31 @@ is_cplus_marker (int c)
return c && strchr (cplus_markers, c) != NULL;
}
+/* Demangle the given string in the current language. */
+
+static void
+demangle_command (char *args, int from_tty)
+{
+ char *demangled;
+
+ if (args == NULL || *args == '\0')
+ printf_filtered (_("\"demangle\" takes an argument to demangle.\n"));
+ else
+ {
+ demangled = language_demangle (current_language, args,
+ DMGL_ANSI | DMGL_PARAMS);
+ if (demangled != NULL)
+ {
+ printf_filtered ("%s\n", demangled);
+ xfree (demangled);
+ }
+ else
+ {
+ printf_filtered (_("Can't demangle \"%s\"\n"), args);
+ }
+ }
+}
+
extern initialize_file_ftype _initialize_demangler; /* -Wmissing-prototypes */
void
@@ -200,4 +229,8 @@ Use `set demangle-style' without arguments for a list of demangling styles."),
set_demangling_command,
show_demangling_style_names,
&setlist, &showlist);
+
+ add_cmd ("demangle", class_support, demangle_command, _("\
+Demangle a mangled name in the current language."),
+ &cmdlist);
}
@@ -139,38 +139,14 @@ maintenance_demangler_warning (char *args, int from_tty)
demangler_warning (__FILE__, __LINE__, "%s", (args == NULL ? "" : args));
}
-/* Someday we should allow demangling for things other than just
- explicit strings. For example, we might want to be able to specify
- the address of a string in either GDB's process space or the
- debuggee's process space, and have gdb fetch and demangle that
- string. If we have a char* pointer "ptr" that points to a string,
- we might want to be able to given just the name and have GDB
- demangle and print what it points to, etc. (FIXME) */
+/* Old command to demangle a string. The command has been moved to "demangle".
+ It is kept for now because otherwise "mt demangle" gets interpreted as
+ "mt demangler-warning" which artificially creates an internal gdb error. */
static void
maintenance_demangle (char *args, int from_tty)
{
- char *demangled;
-
- if (args == NULL || *args == '\0')
- {
- printf_unfiltered (_("\"maintenance demangle\" takes "
- "an argument to demangle.\n"));
- }
- else
- {
- demangled = language_demangle (current_language, args,
- DMGL_ANSI | DMGL_PARAMS);
- if (demangled != NULL)
- {
- printf_unfiltered ("%s\n", demangled);
- xfree (demangled);
- }
- else
- {
- printf_unfiltered (_("Can't demangle \"%s\"\n"), args);
- }
- }
+ printf_filtered (_("This command has been moved to \"demangle\".\n"));
}
static void
@@ -1012,8 +988,7 @@ _initialize_maint_cmds (void)
add_prefix_cmd ("maintenance", class_maintenance, maintenance_command, _("\
Commands for use by GDB maintainers.\n\
Includes commands to dump specific internal GDB structures in\n\
-a human readable form, to cause GDB to deliberately dump core,\n\
-to test internal functions such as the C++/ObjC demangler, etc."),
+a human readable form, to cause GDB to deliberately dump core, etc."),
&maintenancelist, "maintenance ", 0,
&cmdlist);
@@ -1083,9 +1058,7 @@ Cause GDB to behave as if a demangler warning was reported."),
&maintenancelist);
add_cmd ("demangle", class_maintenance, maintenance_demangle, _("\
-Demangle a C++/ObjC mangled name.\n\
-Call internal GDB demangler routine to demangle a C++ link name\n\
-and prints the result."),
+This command has been moved to \"demangle\"."),
&maintenancelist);
add_prefix_cmd ("per-command", class_maintenance, set_per_command_cmd, _("\
@@ -25,7 +25,6 @@
#maintenance expand-symtabs -- Expand symtabs matching a file regexp
#maintenance set -- Set GDB internal variables used by the GDB maintainer
#maintenance show -- Show GDB internal variables used by the GDB maintainer
-#maintenance demangle -- Demangle a C++ mangled name
#maintenance dump-me -- Get fatal error; make debugger dump its core
#maintenance print -- Maintenance command for printing GDB internal state
#maintenance info -- Commands for showing internal info about the program being debugged
@@ -136,13 +135,6 @@ gdb_test "pwd" \
"Command execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+#symtabs: $decimal \\(\\+$decimal\\), #compunits: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)"
gdb_test_no_output "maint set per-command off"
-gdb_test "maint demangle" \
- "\"maintenance demangle\" takes an argument to demangle\\."
-
-gdb_test "maint demangle main" "Can't demangle \"main\""
-
-
-
# The timeout value is raised, because printing all the symbols and
# statistical information about Cygwin and Windows libraries takes a lot
# of time.
@@ -484,7 +476,7 @@ set timeout $oldtimeout
#============test help on maint commands
gdb_test "help maint" \
- "Commands for use by GDB maintainers\\..*Includes commands to dump specific internal GDB structures in.*a human readable form, to cause GDB to deliberately dump core,.*to test internal functions such as the C../ObjC demangler, etc\\..*List of maintenance subcommands:.*maintenance info.*maintenance internal-error.*maintenance print.*maintenance set.*maintenance show.*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\..*Command name abbreviations are allowed if unambiguous\\..*"
+ "Commands for use by GDB maintainers\\..*Includes commands to dump specific internal GDB structures in.*a human readable form, to cause GDB to deliberately dump core, etc\\..*List of maintenance subcommands:.*maintenance info.*maintenance internal-error.*maintenance print.*maintenance set.*maintenance show.*Type.*help maintenance.*followed by maintenance subcommand name for full documentation\\..*Command name abbreviations are allowed if unambiguous\\..*"
gdb_test "help maint info" \
"Commands for showing internal info about the program being debugged.*unambiguous\\..*"
@@ -496,8 +488,7 @@ test_prefix_command_help {"maint print" "maintenance print"} {
test_prefix_command_help {"maint" "maintenance"} {
"Commands for use by GDB maintainers\\.\[\r\n\]+"
"Includes commands to dump specific internal GDB structures in\[\r\n\]+"
- "a human readable form, to cause GDB to deliberately dump core,\[\r\n\]+"
- "to test internal functions such as the C\\+\\+/ObjC demangler, etc\\.\[\r\n\]+"
+ "a human readable form, to cause GDB to deliberately dump core, etc\\.\[\r\n\]+"
}
#set oldtimeout $timeout
@@ -73,7 +73,7 @@ proc test_demangling_core {tester test result} {
set_demangling_style $style
}
- $tester "maintenance demangle $name" $result $test
+ $tester "demangle $name" $result $test
}
### Demangle an identifier, and check that the result matches a pattern.
@@ -527,7 +527,7 @@ proc test_gnu_style_demangling {} {
## 1999-04-19: "Fix from Dale Hawkins". Shouldn't segfault.
# Accept even a dubious demangling; the string is ambiguous.
- gdb_test_multiple "maintenance demangle __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" {
+ gdb_test_multiple "demangle __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator" {
-re "virtual function thunk \\(delta:-64\\) for CosNaming::_proxy_NamingContext::_0RL__list\\(unsigned long, _CORBA_Unbounded_Sequence<CosNaming::Binding> \\*\\&, CosNaming::BindingIterator \\*\\&\\)\r\n$gdb_prompt $" {
pass "gnu: __thunk_64__0RL__list__Q29CosNaming20_proxy_NamingContextUlRPt25_CORBA_Unbounded_Sequence1ZQ29CosNaming7BindingRPQ29CosNaming15BindingIterator"
}
@@ -23,7 +23,7 @@ if { [skip_d_tests] } { continue }
### Utility function for test_demangling and test_demangling_exact.
proc test_demangling {test result} {
- gdb_test_exact "maintenance demangle $test" $result $test
+ gdb_test_exact "demangle $test" $result $test
}
proc test_d_demangling {} {
@@ -14215,6 +14215,10 @@ method tables of the object computed by @var{expression}. This shows
one entry per virtual table; there may be multiple virtual tables when
multiple inheritance is in use.
+@cindex C@t{++} demangling
+@item demangle @var{name}
+Demangle @var{name}.
+
@cindex C@t{++} symbol display
@item set print demangle
@itemx show print demangle
@@ -16070,6 +16074,11 @@ _start + 5 in section .text of /tmp/a.out
__read_nocancel + 6 in section .text of /usr/lib64/libc.so.6
@end smallexample
+@kindex demangle
+@cindex demangle
+@item demangle @var{name}
+Demangle @var{name} in the current language.
+
@kindex whatis
@item whatis[/@var{flags}] [@var{arg}]
Print the data type of @var{arg}, which can be either an expression
@@ -33470,10 +33479,6 @@ Print the first C@t{++} class/namespace component of @var{name}.
@item maint cplus namespace
Print the list of possible C@t{++} namespaces.
-@kindex maint demangle
-@item maint demangle @var{name}
-Demangle a C@t{++} or Objective-C mangled @var{name}.
-
@kindex maint deprecate
@kindex maint undeprecate
@cindex deprecated commands