From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam08on2041.outbound.protection.outlook.com [40.107.100.41]) by sourceware.org (Postfix) with ESMTPS id D6C6F385840C for ; Wed, 30 Mar 2022 09:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D6C6F385840C ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lubz6m/g0AfbxzYiW5ToBAcO+8oLLvdXY1MovR6eUXU5i10l+43ZbYxtaxqd+Kmm42PoSWuQFLcDVT1XkvMo6gNNK9ZX7EKQL3WB8XK6o/HuMrlmDLUIZ78IGSR6Ai11aq7vHrrOf/+sdswRFWCfvbsL0hoELgg1/wm0mlBXf8BKgSpFF22laWzFEsN0sAH5vHgpYNAUr0yalTBYQMH3ARiTwZRhOvHrKu665HTSg9j2mPKrbHTFEWHALEFTCiWBsoT8TDvjLPaQUEN0LG5kj+Mr81dNnwtr2kSYBQymGWSftMkAd+supo9TeQmej32+zB06x6WmITioBEMBQkM1EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=n73Kj6fr2gAnhn31U3ce3O/JnAAe5rmK7r6or4v1BIM=; b=jn5X3EbewDxAYwaIQk4UBvNf60qn3A2kfWHVvrZHuCBXtC7mEbDArQhhKDRHgBft+KC4heVS63+n7Q92G41JAwzYBt2TcNYgvRgeAAvtdHUZSGnmUr/OwOh+i1bvXm6MvMDfqNLiAAbq1DqV07DVdZ325tQeHV0RvJ9nOPFwjyJwnXRLIyO9fGnOE3y7j1kzHqpRRlZwja/xWjpCaD3LyfF/R816dEXW7F/9azSCk680l2kB4n67gpSsNmyvcbeBANEewyoYKCXc9Txr1eKphtU2UerTAQuRuGewV/SL36DTjn4wqEMHUudKpo+y6dW+GFQ3wUY/dCQ9oC2nTf+bIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from BN0PR04CA0191.namprd04.prod.outlook.com (2603:10b6:408:e9::16) by BL1PR12MB5361.namprd12.prod.outlook.com (2603:10b6:208:31f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18; Wed, 30 Mar 2022 09:35:26 +0000 Received: from BN8NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::4c) by BN0PR04CA0191.outlook.office365.com (2603:10b6:408:e9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Wed, 30 Mar 2022 09:35:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT019.mail.protection.outlook.com (10.13.176.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5123.19 via Frontend Transport; Wed, 30 Mar 2022 09:35:25 +0000 Received: from khazad-dum.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 30 Mar 2022 04:35:24 -0500 From: Lancelot SIX To: CC: , Lancelot SIX Subject: [PATCH v2 1/2] gdb/buildsym: Line record use a record flag Date: Wed, 30 Mar 2022 10:34:57 +0100 Message-ID: <20220330093458.148497-2-lancelot.six@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220330093458.148497-1-lancelot.six@amd.com> References: <20220330093458.148497-1-lancelot.six@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b0b3a218-197d-4d7d-fe23-08da12309ec2 X-MS-TrafficTypeDiagnostic: BL1PR12MB5361:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rb4a9bgC0/YZ3oX2JNLqVtwyRcx1THFZ62VaOJxuSEB6R1oGe5dXspOv+bHwLi3GHSKpUxkiIzw98/xavOmG0xDscSbWfAWsx2AJG6keFT9FG7M81iP/SOQX9e6mb8pJ6jhkBVW4HSBmnTiLThSwGG2+WwMtuaRo6X1Cnyg1nwjKu2JpRo1uZCBa0XttKtel4B9nDdSz1SjbeItyY8ulceq86pXzI4GBGXbF8FEUPtNW2dhHOqUnsqY3ZyZguHqMqp4fY7OYFfsSPp1o9spYYI/SHcOtDNENNHbIEZo/+kpEbFUKl9FqS3Mc3VgopLjK+B4ON+lZERCw6iy/UTKFN6a6YJiV7CuoByDDCoAohrkcahDxjImWr9ngV25p2HXOCm5ro8OLrjzH9zy8Fm86wXuK3xxpROkSNn9mOfKXAlsENMMV1R+X2X8p1AFJ3Xse6p61A+LCN7S91hKZz/J3Tg8e4O7AB5EW3Vw2hRFxTA7cS7fxVKZZ2DJ+xcZxbMHU98YT/psE1mjcVB16tRmRkeQsk/T0GVKRPjWGAWnTMpsyoQWtu2b+mgHtWNNLB1i8j7v82m0ornjpaWf9pncCiIYBMvxDIONcmDIf2ySyeKT1efawT3/b/VqSKpN59q9mBHFKfndTpZGVhdSxJJakz4FQPaS6VKhJicOps0nOdh1TN0EeeW/hxAJb+ZM1/e+6379qV4Ci8cYIQAvCNwBsOA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(70206006)(2616005)(8936002)(81166007)(5660300002)(36756003)(70586007)(4326008)(8676002)(508600001)(336012)(356005)(47076005)(426003)(83380400001)(86362001)(6666004)(40460700003)(36860700001)(7696005)(82310400004)(1076003)(54906003)(2906002)(316002)(16526019)(186003)(26005)(6916009)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2022 09:35:25.7030 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0b3a218-197d-4d7d-fe23-08da12309ec2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5361 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Wed, 30 Mar 2022 09:35:29 -0000 Currently when recording a line entry (with buildsym_compunit::record_line), a boolean argument argument is used to indicate that the is_stmt flag should be set for this particular record. As a later commit will add support for new flags, instead of adding a parameter to record_line for each possible flag, transform the current is_stmt parameter into a enum flag. This flags parameter will allow greater flexibility in future commits. This enum flags type is not propagated into the linetable_entry type as this would require a lot of changes across the codebase for no practical gain (it currently uses a bitfield where each interesting flag only occupy 1 bit in the structure). Tested on x86_64-linux, no regression observed. Change-Id: I5d061fa67bdb34918742505ff983d37453839d6a --- gdb/buildsym-legacy.c | 2 +- gdb/buildsym.c | 4 ++-- gdb/buildsym.h | 11 ++++++++++- gdb/dwarf2/read.c | 37 ++++++++++++++++++++++--------------- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/gdb/buildsym-legacy.c b/gdb/buildsym-legacy.c index 7659f53cbe0..53cd3bd865b 100644 --- a/gdb/buildsym-legacy.c +++ b/gdb/buildsym-legacy.c @@ -254,7 +254,7 @@ record_line (struct subfile *subfile, int line, CORE_ADDR pc) gdb_assert (buildsym_compunit != nullptr); /* Assume every line entry is a statement start, that is a good place to put a breakpoint for that line number. */ - buildsym_compunit->record_line (subfile, line, pc, true); + buildsym_compunit->record_line (subfile, line, pc, LEF_IS_STMT); } /* Start a new symtab for a new source file in OBJFILE. Called, for example, diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 999f632f401..a875eb5ce38 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -667,7 +667,7 @@ buildsym_compunit::pop_subfile () void buildsym_compunit::record_line (struct subfile *subfile, int line, - CORE_ADDR pc, bool is_stmt) + CORE_ADDR pc, linetable_entry_flags flags) { struct linetable_entry *e; @@ -723,7 +723,7 @@ buildsym_compunit::record_line (struct subfile *subfile, int line, e = subfile->line_vector->item + subfile->line_vector->nitems++; e->line = line; - e->is_stmt = is_stmt ? 1 : 0; + e->is_stmt = (flags & LEF_IS_STMT) != 0; e->pc = pc; } diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 003d8a59719..09c2d563ec9 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -110,6 +110,15 @@ struct context_stack }; +/* Flags associated with a linetable entry. */ + +enum linetable_entry_flag : unsigned +{ + LEF_IS_STMT = 1 << 1, +}; +DEF_ENUM_FLAGS_TYPE (enum linetable_entry_flag, linetable_entry_flags); + + /* Buildsym's counterpart to struct compunit_symtab. */ struct buildsym_compunit @@ -188,7 +197,7 @@ struct buildsym_compunit const char *pop_subfile (); void record_line (struct subfile *subfile, int line, CORE_ADDR pc, - bool is_stmt); + linetable_entry_flags flags); struct compunit_symtab *get_compunit_symtab () { diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5c02d5660a0..e4247711002 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -20918,7 +20918,7 @@ class lnp_state_machine /* Handle DW_LNS_negate_stmt. */ void handle_negate_stmt () { - m_is_stmt = !m_is_stmt; + m_flags ^= LEF_IS_STMT; } /* Handle DW_LNS_const_add_pc. */ @@ -20977,7 +20977,7 @@ class lnp_state_machine /* These are initialized in the constructor. */ CORE_ADDR m_address; - bool m_is_stmt; + linetable_entry_flags m_flags; unsigned int m_discriminator; /* Additional bits of state we need to track. */ @@ -20992,9 +20992,9 @@ class lnp_state_machine CORE_ADDR m_last_address; /* Set to true when a previous line at the same address (using - m_last_address) had m_is_stmt true. This is reset to false when a - line entry at a new address (m_address different to m_last_address) is - processed. */ + m_last_address) had LEF_IS_STMT set in m_flags. This is reset to false + when a line entry at a new address (m_address different to + m_last_address) is processed. */ bool m_stmt_at_address = false; /* When true, record the lines we decode. */ @@ -21124,7 +21124,8 @@ dwarf_record_line_p (struct dwarf2_cu *cu, static void dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile, - unsigned int line, CORE_ADDR address, bool is_stmt, + unsigned int line, CORE_ADDR address, + linetable_entry_flags flags, struct dwarf2_cu *cu) { CORE_ADDR addr = gdbarch_addr_bits_remove (gdbarch, address); @@ -21138,7 +21139,7 @@ dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile, } if (cu != nullptr) - cu->get_builder ()->record_line (subfile, line, addr, is_stmt); + cu->get_builder ()->record_line (subfile, line, addr, flags); } /* Subroutine of dwarf_decode_lines_1 to simplify it. @@ -21161,7 +21162,7 @@ dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile, paddress (gdbarch, address)); } - dwarf_record_line_1 (gdbarch, subfile, 0, address, true, cu); + dwarf_record_line_1 (gdbarch, subfile, 0, address, LEF_IS_STMT, cu); } void @@ -21174,7 +21175,8 @@ lnp_state_machine::record_line (bool end_sequence) " address %s, is_stmt %u, discrim %u%s\n", m_line, m_file, paddress (m_gdbarch, m_address), - m_is_stmt, m_discriminator, + (m_flags & LEF_IS_STMT) != 0, + m_discriminator, (end_sequence ? "\t(end sequence)" : "")); } @@ -21209,7 +21211,8 @@ lnp_state_machine::record_line (bool end_sequence) = m_last_subfile != m_cu->get_builder ()->get_current_subfile (); bool ignore_this_line = ((file_changed && !end_sequence && m_last_address == m_address - && !m_is_stmt && m_stmt_at_address) + && ((m_flags & LEF_IS_STMT) == 0) + && m_stmt_at_address) || (!end_sequence && m_line == 0)); if ((file_changed && !ignore_this_line) || end_sequence) @@ -21220,7 +21223,9 @@ lnp_state_machine::record_line (bool end_sequence) if (!end_sequence && !ignore_this_line) { - bool is_stmt = producer_is_codewarrior (m_cu) || m_is_stmt; + linetable_entry_flags lte_flags = m_flags; + if (producer_is_codewarrior (m_cu)) + lte_flags |= LEF_IS_STMT; if (dwarf_record_line_p (m_cu, m_line, m_last_line, m_line_has_non_zero_discriminator, @@ -21229,7 +21234,7 @@ lnp_state_machine::record_line (bool end_sequence) buildsym_compunit *builder = m_cu->get_builder (); dwarf_record_line_1 (m_gdbarch, builder->get_current_subfile (), - m_line, m_address, is_stmt, + m_line, m_address, m_flags, m_currently_recording_lines ? m_cu : nullptr); } m_last_subfile = m_cu->get_builder ()->get_current_subfile (); @@ -21238,14 +21243,14 @@ lnp_state_machine::record_line (bool end_sequence) } } - /* Track whether we have seen any m_is_stmt true at m_address in case we + /* Track whether we have seen any IS_STMT true at m_address in case we have multiple line table entries all at m_address. */ if (m_last_address != m_address) { m_stmt_at_address = false; m_last_address = m_address; } - m_stmt_at_address |= m_is_stmt; + m_stmt_at_address |= (m_flags & LEF_IS_STMT) != 0; } lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, @@ -21263,7 +21268,9 @@ lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, and also record it in case it needs it. This is currently used by MIPS code, cf. `mips_adjust_dwarf2_line'. */ m_address = gdbarch_adjust_dwarf2_line (arch, 0, 0); - m_is_stmt = lh->default_is_stmt; + m_flags = 0; + if (lh->default_is_stmt) + m_flags |= LEF_IS_STMT; m_discriminator = 0; m_last_address = m_address; -- 2.25.1