aboutsummaryrefslogtreecommitdiff
path: root/gdb/cp-name-parser.y
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2024-04-10 14:34:42 -0600
committerTom Tromey <tom@tromey.com>2024-05-14 13:28:39 -0600
commit6bc4d69d3d76dceab9681578d9e5f99175ee0c39 (patch)
tree4f91e9508de1800afe5e4bd0f93c96c0fd9f9e76 /gdb/cp-name-parser.y
parentbe2a6a5803e575db62a1c27e022cb596d237181a (diff)
downloadgdb-6bc4d69d3d76dceab9681578d9e5f99175ee0c39.zip
gdb-6bc4d69d3d76dceab9681578d9e5f99175ee0c39.tar.gz
gdb-6bc4d69d3d76dceab9681578d9e5f99175ee0c39.tar.bz2
Remove test code from cp-name-parser.y
This removes the current test 'main' from cp-name-parser.y. There aren't any tests using this, and nowadays it would be better as a unit test. Approved-By: John Baldwin <jhb@FreeBSD.org>
Diffstat (limited to 'gdb/cp-name-parser.y')
-rw-r--r--gdb/cp-name-parser.y135
1 files changed, 0 insertions, 135 deletions
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index e944276..7820053 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -171,11 +171,6 @@ cpname_state::d_grab ()
#define INT_SIGNED (1 << 4)
#define INT_UNSIGNED (1 << 5)
-/* Enable yydebug for the stand-alone parser. */
-#ifdef TEST_CPNAMES
-# define YYDEBUG 1
-#endif
-
/* Helper functions. These wrap the demangler tree interface, handle
allocation from our global store, and return the allocated component. */
@@ -2047,133 +2042,3 @@ cp_demangled_name_to_comp (const char *demangled_name,
return result;
}
-
-#ifdef TEST_CPNAMES
-
-static void
-cp_print (struct demangle_component *result)
-{
- char *str;
- size_t err = 0;
-
- str = gdb_cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, result, 64, &err);
- if (str == NULL)
- return;
-
- fputs (str, stdout);
-
- free (str);
-}
-
-static char
-trim_chars (char *lexptr, char **extra_chars)
-{
- char *p = (char *) symbol_end (lexptr);
- char c = 0;
-
- if (*p)
- {
- c = *p;
- *p = 0;
- *extra_chars = p + 1;
- }
-
- return c;
-}
-
-/* When this file is built as a standalone program, xmalloc comes from
- libiberty --- in which case we have to provide xfree ourselves. */
-
-void
-xfree (void *ptr)
-{
- if (ptr != NULL)
- {
- /* Literal `free' would get translated back to xfree again. */
- CONCAT2 (fr,ee) (ptr);
- }
-}
-
-/* GDB normally defines internal_error itself, but when this file is built
- as a standalone program, we must also provide an implementation. */
-
-void
-internal_error (const char *file, int line, const char *fmt, ...)
-{
- va_list ap;
-
- va_start (ap, fmt);
- fprintf (stderr, "%s:%d: internal error: ", file, line);
- vfprintf (stderr, fmt, ap);
- exit (1);
-}
-
-int
-main (int argc, char **argv)
-{
- char *str2, *extra_chars, c;
- char buf[65536];
- int arg;
-
- arg = 1;
- if (argv[arg] && strcmp (argv[arg], "--debug") == 0)
- {
- yydebug = 1;
- arg++;
- }
-
- if (argv[arg] == NULL)
- while (fgets (buf, 65536, stdin) != NULL)
- {
- buf[strlen (buf) - 1] = 0;
- /* Use DMGL_VERBOSE to get expanded standard substitutions. */
- c = trim_chars (buf, &extra_chars);
- str2 = cplus_demangle (buf, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
- if (str2 == NULL)
- {
- printf ("Demangling error\n");
- if (c)
- printf ("%s%c%s\n", buf, c, extra_chars);
- else
- printf ("%s\n", buf);
- continue;
- }
-
- std::string errmsg;
- std::unique_ptr<demangle_parse_info> result
- = cp_demangled_name_to_comp (str2, &errmsg);
- if (result == NULL)
- {
- fputs (errmsg.c_str (), stderr);
- fputc ('\n', stderr);
- continue;
- }
-
- cp_print (result->tree);
-
- free (str2);
- if (c)
- {
- putchar (c);
- fputs (extra_chars, stdout);
- }
- putchar ('\n');
- }
- else
- {
- std::string errmsg;
- std::unique_ptr<demangle_parse_info> result
- = cp_demangled_name_to_comp (argv[arg], &errmsg);
- if (result == NULL)
- {
- fputs (errmsg.c_str (), stderr);
- fputc ('\n', stderr);
- return 0;
- }
- cp_print (result->tree);
- putchar ('\n');
- }
- return 0;
-}
-
-#endif