From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id EE2163858C27 for ; Sat, 1 Jan 2022 17:55:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EE2163858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id 6025E10041921 for ; Sat, 1 Jan 2022 17:55:24 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id 3ibDnEa0HXOyf3ibEnAB01; Sat, 01 Jan 2022 17:55:24 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Ot6Kdwzt c=1 sm=1 tr=0 ts=61d0958c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=DghFqjY3_ZEA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=OoRdxxP6UrhB5YuI114A:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=GwQT0RsRnHJSmDKuxOxmV5F1vxJ2b/czwvGT2TWZDYA=; b=enEq+LtzWnWUH58qT1jveeKApa a4igXuMdj9A+C0FDExtFZvzW/RL/5c5dYh1niTJIYeFgCBjdKj+JVsDwc7yleocE0gEz2GrqpWMOf 1hZwZ6dFM1wUbOJFPYZbZIUok; Received: from 75-166-134-30.hlrn.qwest.net ([75.166.134.30]:52052 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n3ibD-0034re-Bn; Sat, 01 Jan 2022 10:55:23 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 02/12] Use filtered output in target-descriptions.c Date: Sat, 1 Jan 2022 10:55:10 -0700 Message-Id: <20220101175520.351628-3-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220101175520.351628-1-tom@tromey.com> References: <20220101175520.351628-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 75.166.134.30 X-Source-L: No X-Exim-ID: 1n3ibD-0034re-Bn X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-134-30.hlrn.qwest.net (localhost.localdomain) [75.166.134.30]:52052 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3032.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L3, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Jan 2022 17:55:27 -0000 target-descriptions.c uses unfiltered output. However, if you happen to invoke this command interactively, it's probably better for it to use filtering. For non-interactive use, this doesn't matter. --- gdb/target-descriptions.c | 152 +++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 824112094ba..282729df9e6 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -1347,7 +1347,7 @@ class print_c_tdesc : public tdesc_element_visitor *outp = '\0'; /* Standard boilerplate. */ - printf_unfiltered ("/* THIS FILE IS GENERATED. " + printf_filtered ("/* THIS FILE IS GENERATED. " "-*- buffer-read-only: t -*- vi" ":set ro:\n"); } @@ -1359,56 +1359,56 @@ class print_c_tdesc : public tdesc_element_visitor void visit_pre (const target_desc *e) override { - printf_unfiltered (" Original: %s */\n\n", - lbasename (m_filename_after_features.c_str ())); - - printf_unfiltered ("#include \"defs.h\"\n"); - printf_unfiltered ("#include \"osabi.h\"\n"); - printf_unfiltered ("#include \"target-descriptions.h\"\n"); - printf_unfiltered ("\n"); - - printf_unfiltered ("struct target_desc *tdesc_%s;\n", m_function); - printf_unfiltered ("static void\n"); - printf_unfiltered ("initialize_tdesc_%s (void)\n", m_function); - printf_unfiltered ("{\n"); - printf_unfiltered + printf_filtered (" Original: %s */\n\n", + lbasename (m_filename_after_features.c_str ())); + + printf_filtered ("#include \"defs.h\"\n"); + printf_filtered ("#include \"osabi.h\"\n"); + printf_filtered ("#include \"target-descriptions.h\"\n"); + printf_filtered ("\n"); + + printf_filtered ("struct target_desc *tdesc_%s;\n", m_function); + printf_filtered ("static void\n"); + printf_filtered ("initialize_tdesc_%s (void)\n", m_function); + printf_filtered ("{\n"); + printf_filtered (" target_desc_up result = allocate_target_description ();\n"); if (tdesc_architecture (e) != NULL) { - printf_unfiltered + printf_filtered (" set_tdesc_architecture (result.get (), bfd_scan_arch (\"%s\"));\n", tdesc_architecture (e)->printable_name); - printf_unfiltered ("\n"); + printf_filtered ("\n"); } if (tdesc_osabi (e) > GDB_OSABI_UNKNOWN && tdesc_osabi (e) < GDB_OSABI_INVALID) { - printf_unfiltered + printf_filtered (" set_tdesc_osabi (result.get (), osabi_from_tdesc_string (\"%s\"));\n", gdbarch_osabi_name (tdesc_osabi (e))); - printf_unfiltered ("\n"); + printf_filtered ("\n"); } for (const tdesc_compatible_info_up &compatible : e->compatible) - printf_unfiltered + printf_filtered (" tdesc_add_compatible (result.get (), bfd_scan_arch (\"%s\"));\n", compatible->arch ()->printable_name); if (!e->compatible.empty ()) - printf_unfiltered ("\n"); + printf_filtered ("\n"); for (const property &prop : e->properties) - printf_unfiltered (" set_tdesc_property (result.get (), \"%s\", \"%s\");\n", - prop.key.c_str (), prop.value.c_str ()); + printf_filtered (" set_tdesc_property (result.get (), \"%s\", \"%s\");\n", + prop.key.c_str (), prop.value.c_str ()); - printf_unfiltered (" struct tdesc_feature *feature;\n"); + printf_filtered (" struct tdesc_feature *feature;\n"); } void visit_pre (const tdesc_feature *e) override { - printf_unfiltered ("\n feature = tdesc_create_feature (result.get (), \"%s\");\n", - e->name.c_str ()); + printf_filtered ("\n feature = tdesc_create_feature (result.get (), \"%s\");\n", + e->name.c_str ()); } void visit_post (const tdesc_feature *e) override @@ -1416,8 +1416,8 @@ class print_c_tdesc : public tdesc_element_visitor void visit_post (const target_desc *e) override { - printf_unfiltered ("\n tdesc_%s = result.release ();\n", m_function); - printf_unfiltered ("}\n"); + printf_filtered ("\n tdesc_%s = result.release ();\n", m_function); + printf_filtered ("}\n"); } void visit (const tdesc_type_builtin *type) override @@ -1429,25 +1429,25 @@ class print_c_tdesc : public tdesc_element_visitor { if (!m_printed_element_type) { - printf_unfiltered (" tdesc_type *element_type;\n"); + printf_filtered (" tdesc_type *element_type;\n"); m_printed_element_type = true; } - printf_unfiltered + printf_filtered (" element_type = tdesc_named_type (feature, \"%s\");\n", type->element_type->name.c_str ()); - printf_unfiltered + printf_filtered (" tdesc_create_vector (feature, \"%s\", element_type, %d);\n", type->name.c_str (), type->count); - printf_unfiltered ("\n"); + printf_filtered ("\n"); } void visit (const tdesc_type_with_fields *type) override { if (!m_printed_type_with_fields) { - printf_unfiltered (" tdesc_type_with_fields *type_with_fields;\n"); + printf_filtered (" tdesc_type_with_fields *type_with_fields;\n"); m_printed_type_with_fields = true; } @@ -1457,16 +1457,16 @@ class print_c_tdesc : public tdesc_element_visitor case TDESC_TYPE_FLAGS: if (type->kind == TDESC_TYPE_STRUCT) { - printf_unfiltered + printf_filtered (" type_with_fields = tdesc_create_struct (feature, \"%s\");\n", type->name.c_str ()); if (type->size != 0) - printf_unfiltered + printf_filtered (" tdesc_set_struct_size (type_with_fields, %d);\n", type->size); } else { - printf_unfiltered + printf_filtered (" type_with_fields = tdesc_create_flags (feature, \"%s\", %d);\n", type->name.c_str (), type->size); } @@ -1485,7 +1485,7 @@ class print_c_tdesc : public tdesc_element_visitor if (f.type->kind == TDESC_TYPE_BOOL) { gdb_assert (f.start == f.end); - printf_unfiltered + printf_filtered (" tdesc_add_flag (type_with_fields, %d, \"%s\");\n", f.start, f.name.c_str ()); } @@ -1493,7 +1493,7 @@ class print_c_tdesc : public tdesc_element_visitor || (type->size == 8 && f.type->kind == TDESC_TYPE_UINT64)) { - printf_unfiltered + printf_filtered (" tdesc_add_bitfield (type_with_fields, \"%s\", %d, %d);\n", f.name.c_str (), f.start, f.end); } @@ -1502,7 +1502,7 @@ class print_c_tdesc : public tdesc_element_visitor printf_field_type_assignment ("tdesc_named_type (feature, \"%s\");\n", type_name); - printf_unfiltered + printf_filtered (" tdesc_add_typed_bitfield (type_with_fields, \"%s\"," " %d, %d, field_type);\n", f.name.c_str (), f.start, f.end); @@ -1514,31 +1514,31 @@ class print_c_tdesc : public tdesc_element_visitor gdb_assert (type->kind == TDESC_TYPE_STRUCT); printf_field_type_assignment ("tdesc_named_type (feature, \"%s\");\n", type_name); - printf_unfiltered + printf_filtered (" tdesc_add_field (type_with_fields, \"%s\", field_type);\n", f.name.c_str ()); } } break; case TDESC_TYPE_UNION: - printf_unfiltered + printf_filtered (" type_with_fields = tdesc_create_union (feature, \"%s\");\n", type->name.c_str ()); for (const tdesc_type_field &f : type->fields) { printf_field_type_assignment ("tdesc_named_type (feature, \"%s\");\n", f.type->name.c_str ()); - printf_unfiltered + printf_filtered (" tdesc_add_field (type_with_fields, \"%s\", field_type);\n", f.name.c_str ()); } break; case TDESC_TYPE_ENUM: - printf_unfiltered + printf_filtered (" type_with_fields = tdesc_create_enum (feature, \"%s\", %d);\n", type->name.c_str (), type->size); for (const tdesc_type_field &f : type->fields) - printf_unfiltered + printf_filtered (" tdesc_add_enum_value (type_with_fields, %d, \"%s\");\n", f.start, f.name.c_str ()); break; @@ -1546,19 +1546,19 @@ class print_c_tdesc : public tdesc_element_visitor error (_("C output is not supported type \"%s\"."), type->name.c_str ()); } - printf_unfiltered ("\n"); + printf_filtered ("\n"); } void visit (const tdesc_reg *reg) override { - printf_unfiltered (" tdesc_create_reg (feature, \"%s\", %ld, %d, ", - reg->name.c_str (), reg->target_regnum, - reg->save_restore); + printf_filtered (" tdesc_create_reg (feature, \"%s\", %ld, %d, ", + reg->name.c_str (), reg->target_regnum, + reg->save_restore); if (!reg->group.empty ()) - printf_unfiltered ("\"%s\", ", reg->group.c_str ()); + printf_filtered ("\"%s\", ", reg->group.c_str ()); else - printf_unfiltered ("NULL, "); - printf_unfiltered ("%d, \"%s\");\n", reg->bitsize, reg->type.c_str ()); + printf_filtered ("NULL, "); + printf_filtered ("%d, \"%s\");\n", reg->bitsize, reg->type.c_str ()); } protected: @@ -1573,15 +1573,15 @@ class print_c_tdesc : public tdesc_element_visitor { if (!m_printed_field_type) { - printf_unfiltered (" tdesc_type *field_type;\n"); + printf_filtered (" tdesc_type *field_type;\n"); m_printed_field_type = true; } - printf_unfiltered (" field_type = "); + printf_filtered (" field_type = "); va_list args; va_start (args, fmt); - vprintf_unfiltered (fmt, args); + vprintf_filtered (fmt, args); va_end (args); } @@ -1613,11 +1613,11 @@ class print_c_feature : public print_c_tdesc void visit_pre (const target_desc *e) override { - printf_unfiltered (" Original: %s */\n\n", - lbasename (m_filename_after_features.c_str ())); + printf_filtered (" Original: %s */\n\n", + lbasename (m_filename_after_features.c_str ())); - printf_unfiltered ("#include \"gdbsupport/tdesc.h\"\n"); - printf_unfiltered ("\n"); + printf_filtered ("#include \"gdbsupport/tdesc.h\"\n"); + printf_filtered ("\n"); } void visit_post (const target_desc *e) override @@ -1633,22 +1633,22 @@ class print_c_feature : public print_c_tdesc std::replace (name.begin (), name.end (), '/', '_'); std::replace (name.begin (), name.end (), '-', '_'); - printf_unfiltered ("static int\n"); - printf_unfiltered ("create_feature_%s ", name.c_str ()); - printf_unfiltered ("(struct target_desc *result, long regnum)\n"); + printf_filtered ("static int\n"); + printf_filtered ("create_feature_%s ", name.c_str ()); + printf_filtered ("(struct target_desc *result, long regnum)\n"); - printf_unfiltered ("{\n"); - printf_unfiltered (" struct tdesc_feature *feature;\n"); + printf_filtered ("{\n"); + printf_filtered (" struct tdesc_feature *feature;\n"); - printf_unfiltered + printf_filtered ("\n feature = tdesc_create_feature (result, \"%s\");\n", e->name.c_str ()); } void visit_post (const tdesc_feature *e) override { - printf_unfiltered (" return regnum;\n"); - printf_unfiltered ("}\n"); + printf_filtered (" return regnum;\n"); + printf_filtered ("}\n"); } void visit (const tdesc_reg *reg) override @@ -1681,27 +1681,27 @@ class print_c_feature : public print_c_tdesc and also print the message so that it can be saved in the generated c file. */ - printf_unfiltered ("ERROR: \"regnum\" attribute %ld ", - reg->target_regnum); - printf_unfiltered ("is not the largest number (%d).\n", - m_next_regnum); + printf_filtered ("ERROR: \"regnum\" attribute %ld ", + reg->target_regnum); + printf_filtered ("is not the largest number (%d).\n", + m_next_regnum); error (_("\"regnum\" attribute %ld is not the largest number (%d)."), reg->target_regnum, m_next_regnum); } if (reg->target_regnum > m_next_regnum) { - printf_unfiltered (" regnum = %ld;\n", reg->target_regnum); + printf_filtered (" regnum = %ld;\n", reg->target_regnum); m_next_regnum = reg->target_regnum; } - printf_unfiltered (" tdesc_create_reg (feature, \"%s\", regnum++, %d, ", - reg->name.c_str (), reg->save_restore); + printf_filtered (" tdesc_create_reg (feature, \"%s\", regnum++, %d, ", + reg->name.c_str (), reg->save_restore); if (!reg->group.empty ()) - printf_unfiltered ("\"%s\", ", reg->group.c_str ()); + printf_filtered ("\"%s\", ", reg->group.c_str ()); else - printf_unfiltered ("NULL, "); - printf_unfiltered ("%d, \"%s\");\n", reg->bitsize, reg->type.c_str ()); + printf_filtered ("NULL, "); + printf_filtered ("%d, \"%s\");\n", reg->bitsize, reg->type.c_str ()); m_next_regnum++; } @@ -1858,7 +1858,7 @@ maint_print_xml_tdesc_cmd (const char *args, int from_tty) std::string buf; print_xml_feature v (&buf); tdesc->accept (v); - puts_unfiltered (buf.c_str ()); + puts_filtered (buf.c_str ()); } namespace selftests { -- 2.31.1