From patchwork Sun Apr 21 17:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 88815 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BDC50384AB6F for ; Sun, 21 Apr 2024 17:01:13 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 74D003858D33 for ; Sun, 21 Apr 2024 17:00:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 74D003858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 74D003858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713718809; cv=none; b=hz4id644V+86R1olbEV2o9zpiLKx+66bs/aS1nK+KgTgaarwvvkXGKErDJLHQS8oAp4ug+NSasSXPdnvHzvFgHKtzqkPZIEhyMJic4gDXFcqo9YKaC3xfFGLJO0w0L5mGUH3qRIPitF98i9iEzrE5mwUQmFqtfXskP/axiqqU1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713718809; c=relaxed/simple; bh=stc/VN+df0vOZk8qNpTtoa89cz/3jP4G3gz+1te3jFU=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=eCRuf0l3DR62rdyrpJB4YAgHpJ14bxLGtldHXblkGiOkk0YSzT/9Oxf+wcrI/Lhjricc7G/NFmW98+52WeVaSuncXjo4IRVi7OxshUs1ogzxifISrMnOO2ivF7rq5T+/xndOpoZAzvlhILvdyPxUySlhvPaiA5MBtmHKUjcRqyI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5006a.ext.cloudfilter.net ([10.0.29.179]) by cmsmtp with ESMTPS id yZqkr6kMyHXmAyaXsr1W0Q; Sun, 21 Apr 2024 17:00:04 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id yaXrrHUTOqaR9yaXrrFQmt; Sun, 21 Apr 2024 17:00:03 +0000 X-Authority-Analysis: v=2.4 cv=MqZU6Xae c=1 sm=1 tr=0 ts=66254613 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=oYOYw8Ultr3lYnx_CakA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=YezpLC9zPUxKKus0p/zvBygdwOJIK7EvTnZpH9TkjOo=; b=MxJcW5kfvvMHFNL5Bow0K3/kYU qfDTf5kasWIgq7xbfglD0V57l7B87bODwZ6FR/VWz5Ric1te20i0JR5sMzNItv62wvLL+AGn/fII/ DwHzmCqDg9FJAttPVR13+V456; Received: from 97-122-86-252.hlrn.qwest.net ([97.122.86.252]:53968 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1ryaXq-003wVC-1t for gdb-patches@sourceware.org; Sun, 21 Apr 2024 11:00:02 -0600 From: Tom Tromey Date: Sun, 21 Apr 2024 11:00:01 -0600 Subject: [PATCH 01/10] Remove test code from cp-name-parser.y MIME-Version: 1.0 Message-Id: <20240421-canon-fixes-v1-1-4dc4791d270d@tromey.com> References: <20240421-canon-fixes-v1-0-4dc4791d270d@tromey.com> In-Reply-To: <20240421-canon-fixes-v1-0-4dc4791d270d@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.13.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.86.252 X-Source-L: No X-Exim-ID: 1ryaXq-003wVC-1t X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-86-252.hlrn.qwest.net ([192.168.0.21]) [97.122.86.252]:53968 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGAdfnGFHmzHMvXCRxjavv5TzJIZrMzeZX/xjQRrkLMA+vK0fuvoMRDyLV6EPekds+mJ2Nw4XbX9Wwwq9pjvbiK0MuCmA1GhBJt1n+SKAtKkkwxq8eDe RCx2fpzyCK4EPM8IX5TGwlJuJRfMMaijorgYVE7MzOQsF1WRvX9YWC2BbPUItIO9ZdeUcSMP4Lejxbz3kLaMGwaHfBQenkDBWrw= X-Spam-Status: No, score=-3021.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org 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. --- gdb/Makefile.in | 15 +----- gdb/cp-name-parser.y | 135 --------------------------------------------------- gdb/yy-remap.h | 4 -- 3 files changed, 1 insertion(+), 153 deletions(-) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 23894ea4a4d..2f7fc1ca249 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -2147,16 +2147,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.). @@ -2168,7 +2158,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 \ @@ -2244,7 +2233,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 \ @@ -2677,8 +2665,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)),\ diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index 87f13445bba..9f4561a36b4 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. */ @@ -2051,133 +2046,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 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 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 diff --git a/gdb/yy-remap.h b/gdb/yy-remap.h index d52a59d11b9..e32ce394339 100644 --- a/gdb/yy-remap.h +++ b/gdb/yy-remap.h @@ -93,8 +93,4 @@ # define YYDEBUG 1 /* Default to yydebug support */ #endif -#ifndef TEST_CPNAMES -# define YYFPRINTF parser_fprintf -#endif - #endif /* YY_REMAP_H */