From patchwork Mon Oct 30 15:32:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 23965 Received: (qmail 79152 invoked by alias); 30 Oct 2017 15:32:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 79120 invoked by uid 89); 30 Oct 2017 15:32:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=reserved X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Oct 2017 15:32:14 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66F2A2627 for ; Mon, 30 Oct 2017 15:32:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 66F2A2627 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8F8760244 for ; Mon, 30 Oct 2017 15:32:12 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/2] Make make-target-delegates grok namespace scope op and template params Date: Mon, 30 Oct 2017 15:32:10 +0000 Message-Id: <1509377531-21044-2-git-send-email-palves@redhat.com> In-Reply-To: <1509377531-21044-1-git-send-email-palves@redhat.com> References: <1509377531-21044-1-git-send-email-palves@redhat.com> The next patch will want to use gdb::array_view as parameter type of a target_ops method. However, that runs into a make-target-delegates limitation: target_debug_foo calls in target-delegates.c for parameters/return types with namespace scope operators ("::") or template parameters, end up looking like: @@ -1313,9 +1313,7 @@ debug_set_syscall_catchpoint (struct target_ops *self, int arg1, int arg2, int a fputs_unfiltered (", ", gdb_stdlog); target_debug_print_int (arg3); fputs_unfiltered (", ", gdb_stdlog); - target_debug_print_int (arg4); - fputs_unfiltered (", ", gdb_stdlog); - target_debug_print_int_p (arg5); + target_debug_print_gdb::array_view (arg4); which obviously isn't something that compiles. The problem is that make-target-delegates wasn't ever taught that '::', '<', and '>' can appear in parameter/return types. You could work around it by hidding the unsupported characters behind a typedef in the target method declaration, or by using an explicit TARGET_DEBUG_PRINTER, but it's better to just remove the limitation. While at it, also fix an "abuse" of reserved identifiers. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * make-target-delegates (munge_type): Also munge '<', '>', and ':'. Avoid double underscores in identifiers, and trailing underscores. * target-debug.h (target_debug_print_VEC_static_tracepoint_marker_p__p): Rename to ... (target_debug_print_VEC_static_tracepoint_marker_p_p): ... this. * target-delegates.c: Regenerate. --- gdb/make-target-delegates | 12 +++++++++++- gdb/target-debug.h | 2 +- gdb/target-delegates.c | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gdb/make-target-delegates b/gdb/make-target-delegates index fd51c64..1773232 100755 --- a/gdb/make-target-delegates +++ b/gdb/make-target-delegates @@ -232,8 +232,18 @@ sub munge_type($) { $result = $1; } else { ($result = $typename) =~ s/\s+$//; - $result =~ s/[ ()]/_/g; + $result =~ s/[ ()<>:]/_/g; $result =~ s/[*]/p/g; + + # Identifers with double underscores are reserved to the C++ + # implementation. + $result =~ s/_+/_/g; + + # Avoid ending the function name with underscore, for + # cosmetics. Trailing underscores appear after munging types + # with template parameters, like e.g. "foo". + $result =~ s/_$//g; + $result = 'target_debug_print_' . $result; } diff --git a/gdb/target-debug.h b/gdb/target-debug.h index 14196b4..068495e 100644 --- a/gdb/target-debug.h +++ b/gdb/target-debug.h @@ -116,7 +116,7 @@ target_debug_do_print (host_address_to_string (X)) #define target_debug_print_mem_region_vector(X) \ target_debug_do_print (host_address_to_string (X.data ())) -#define target_debug_print_VEC_static_tracepoint_marker_p__p(X) \ +#define target_debug_print_VEC_static_tracepoint_marker_p_p(X) \ target_debug_do_print (host_address_to_string (X)) #define target_debug_print_const_struct_target_desc_p(X) \ target_debug_do_print (host_address_to_string (X)) diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index e0d7a9a..1cbe6f8 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -3352,7 +3352,7 @@ debug_static_tracepoint_markers_by_strid (struct target_ops *self, const char *a fputs_unfiltered (", ", gdb_stdlog); target_debug_print_const_char_p (arg1); fputs_unfiltered (") = ", gdb_stdlog); - target_debug_print_VEC_static_tracepoint_marker_p__p (result); + target_debug_print_VEC_static_tracepoint_marker_p_p (result); fputs_unfiltered ("\n", gdb_stdlog); return result; }