From patchwork Sat Jan 19 12:33:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 31124 Received: (qmail 127924 invoked by alias); 19 Jan 2019 12:33:28 -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 127808 invoked by uid 89); 19 Jan 2019 12:33:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:typedef, sk:type_co, HContent-Transfer-Encoding:8bit X-HELO: mailsec102.isp.belgacom.be Received: from mailsec102.isp.belgacom.be (HELO mailsec102.isp.belgacom.be) (195.238.20.98) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 Jan 2019 12:33:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1547901205; x=1579437205; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=km89g3f8bu+V+komd31FMbP36pbdgiU960ryjPftrHA=; b=wro0ers+UOTfDoeOyylrb/TdVMQGMBZjU3XoG6JOvXURdHYZYzcSSmat S8kyOynEtnRi8eHUFARw79KSiylIYQ==; Received: from 184.205-67-87.adsl-dyn.isp.belgacom.be (HELO md.home) ([87.67.205.184]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 19 Jan 2019 13:33:21 +0100 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFAv3 1/3] Use function_name_style to print Ada and C function names Date: Sat, 19 Jan 2019 13:33:13 +0100 Message-Id: <20190119123315.5758-2-philippe.waroquiers@skynet.be> In-Reply-To: <20190119123315.5758-1-philippe.waroquiers@skynet.be> References: <20190119123315.5758-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes Note that ada-typeprint.c print_func_type is called with types representing functions and is also called to print a function NAME together with its type. In such a case, the function name will be printed using function name style. Similarly, c_print_type_1 is called to print a type, optionally with the name of an object of this type in the VARSTRING arg. So, c_print_type_1 uses function name style to print varstring when the type code indicates that c_print_type_1 TYPE is some 'real code'. gdb/ChangeLog 2019-01-19 Philippe Waroquiers * ada-typeprint.c (print_func_type): Print function name style to print function name. * c-typeprint.c (c_print_type_1): Likewise. --- gdb/ada-typeprint.c | 6 +++++- gdb/c-typeprint.c | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 2b6cdaf264..8c42e8140d 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -30,6 +30,7 @@ #include "language.h" #include "demangle.h" #include "c-lang.h" +#include "cli/cli-style.h" #include "typeprint.h" #include "target-float.h" #include "ada-lang.h" @@ -779,7 +780,10 @@ print_func_type (struct type *type, struct ui_file *stream, const char *name, fprintf_filtered (stream, "function"); if (name != NULL && name[0] != '\0') - fprintf_filtered (stream, " %s", name); + { + fputs_filtered (" ", stream); + fputs_styled (name, function_name_style.style (), stream); + } if (len > 0) { diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 5e7e672e02..6690ca53bc 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -28,6 +28,7 @@ #include "language.h" #include "demangle.h" #include "c-lang.h" +#include "cli/cli-style.h" #include "typeprint.h" #include "cp-abi.h" #include "cp-support.h" @@ -115,6 +116,7 @@ c_print_type_1 (struct type *type, type = check_typedef (type); local_name = typedef_hash_table::find_typedef (flags, type); + code = TYPE_CODE (type); if (local_name != NULL) { fputs_filtered (local_name, stream); @@ -124,7 +126,6 @@ c_print_type_1 (struct type *type, else { c_type_print_base_1 (type, stream, show, level, language, flags, podata); - code = TYPE_CODE (type); if ((varstring != NULL && *varstring != '\0') /* Need a space if going to print stars or brackets; but not if we will print just a type name. */ @@ -144,7 +145,10 @@ c_print_type_1 (struct type *type, if (varstring != NULL) { - fputs_filtered (varstring, stream); + if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD) + fputs_styled (varstring, function_name_style.style (), stream); + else + fputs_filtered (varstring, stream); /* For demangled function names, we have the arglist as part of the name, so don't print an additional pair of ()'s. */