]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove test code from cp-name-parser.y
authorTom Tromey <tom@tromey.com>
Wed, 10 Apr 2024 20:34:42 +0000 (14:34 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 14 May 2024 19:28:39 +0000 (13:28 -0600)
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>
gdb/Makefile.in
gdb/cp-name-parser.y
gdb/yy-remap.h

index 234d0051f494cd9a0ad1207f8e0cb323c76bafb7..265c086725da4d5b5625e7f4a31b5e071259de24 100644 (file)
@@ -2152,16 +2152,6 @@ uninstall: force $(CONFIG_UNINSTALL)
        rm -f $(DESTDIR)$(bindir)/$$transformed_name
        @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
 
-# The C++ name parser can be built standalone for testing.
-test-cp-name-parser.o: cp-name-parser.c
-       $(COMPILE) -DTEST_CPNAMES cp-name-parser.c
-       $(POSTCOMPILE)
-
-test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
-       $(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) \
-               -o test-cp-name-parser$(EXEEXT) test-cp-name-parser.o \
-               $(LIBIBERTY)
-
 # We do this by grepping through sources.  If that turns out to be too slow,
 # maybe we could just require every .o file to have an initialization routine
 # of a given name (top.o -> _initialize_top, etc.).
@@ -2173,7 +2163,6 @@ test-cp-name-parser$(EXEEXT): test-cp-name-parser.o $(LIBIBERTY)
 # computing the list of source files from the list of object files.
 
 INIT_FILES_FILTER_OUT = \
-       cp-name-parser.o \
        init.o \
        version.o \
        xml-builtin.o \
@@ -2249,7 +2238,6 @@ clean mostlyclean: $(CONFIG_CLEAN)
        rm -f init.c stamp-init version.c stamp-version
        rm -f gdb$(EXEEXT) core make.log
        rm -f gdb[0-9]$(EXEEXT)
-       rm -f test-cp-name-parser$(EXEEXT)
        rm -f xml-builtin.c stamp-xml
        rm -f $(DEPDIR)/*
        for i in $(CONFIG_SRC_SUBDIR); do \
@@ -2682,8 +2670,7 @@ endif
 
 # A list of all the objects we might care about in this build, for
 # dependency tracking.
-all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o \
-       test-cp-name-parser.o
+all_object_files = gdb.o $(LIBGDB_OBS) gdbtk-main.o
 
 # All the .deps files to include.
 all_deps_files = $(foreach dep,$(patsubst %.o,%.Po,$(all_object_files)),\
index e944276d00184df124474e6af30e6de4414d32a2..782005387d6fbe85a29b40c9ea81dfa2eeeafb0a 100644 (file)
@@ -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
index d52a59d11b92b1644d219ed939b4a7c16fdedf08..e32ce394339e7ab45a76a67a9ba72b7ffc4155fd 100644 (file)
@@ -93,8 +93,4 @@
 # define YYDEBUG 1  /* Default to yydebug support */
 #endif
 
-#ifndef TEST_CPNAMES
-# define YYFPRINTF parser_fprintf
-#endif
-
 #endif /* YY_REMAP_H */