From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39205 invoked by alias); 3 Oct 2018 08:49:30 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 38048 invoked by uid 89); 3 Oct 2018 08:49:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=party, H*MI:john, H*F:D*au, accessibility X-HELO: jocasta.intra Received: from de.cellform.com (HELO jocasta.intra) (88.217.224.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 Oct 2018 08:49:12 +0000 Received: from jocasta.intra (localhost [127.0.0.1]) by jocasta.intra (8.15.2/8.15.2/Debian-8) with ESMTPS id w938n985029584 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 3 Oct 2018 10:49:09 +0200 Received: (from john@localhost) by jocasta.intra (8.15.2/8.15.2/Submit) id w938n94P029583; Wed, 3 Oct 2018 10:49:09 +0200 From: John Darrington To: gdb-patches@sourceware.org Cc: John Darrington Subject: [PATCH] GDB: Work around buggy Dwarf lineinfo produced by third party compiler. Date: Wed, 03 Oct 2018 08:49:00 -0000 Message-Id: <20181003084907.29538-1-john@darrington.wattle.id.au> X-SW-Source: 2018-10/txt/msg00064.txt.bz2 * gdb/dwarf2read.c (producer_is_codewarrior): New function. * gdb/dwarf2read.c (lnp_state_machine::record_line): Ignore is_stmt flag for records produced by codewarrior. --- gdb/dwarf2read.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 4a35e389e9..62f2937f3f 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -552,6 +552,7 @@ struct dwarf2_cu unsigned int producer_is_gxx_lt_4_6 : 1; unsigned int producer_is_gcc_lt_4_3 : 1; unsigned int producer_is_icc_lt_14 : 1; + unsigned int producer_is_codewarrior : 1; /* When set, the file that we're processing is known to have debugging info for C++ namespaces. GCC 3.3.x did not produce @@ -14903,6 +14904,8 @@ check_producer (struct dwarf2_cu *cu) } else if (producer_is_icc (cu->producer, &major, &minor)) cu->producer_is_icc_lt_14 = major < 14; + else if (startswith (cu->producer, "CodeWarrior S12/L-ISA")) + cu->producer_is_codewarrior = true; else { /* For other non-GCC compilers, expect their behavior is DWARF version @@ -14925,6 +14928,19 @@ producer_is_gxx_lt_4_6 (struct dwarf2_cu *cu) return cu->producer_is_gxx_lt_4_6; } + +/* Codewarrior generates dwarf line information with incorrect is_stmt + attributes. */ + +static int +producer_is_codewarrior (struct dwarf2_cu *cu) +{ + if (!cu->checked_producer) + check_producer (cu); + + return cu->producer_is_codewarrior; +} + /* Return the default accessibility type if it is not overriden by DW_AT_accessibility. */ @@ -20789,7 +20805,7 @@ lnp_state_machine::record_line (bool end_sequence) else if (m_op_index == 0 || end_sequence) { fe->included_p = 1; - if (m_record_lines_p && m_is_stmt) + if (m_record_lines_p && (producer_is_codewarrior (m_cu) || m_is_stmt)) { if (m_last_subfile != m_cu->builder->get_current_subfile () || end_sequence) @@ -25120,6 +25136,7 @@ dwarf2_cu::dwarf2_cu (struct dwarf2_per_cu_data *per_cu_) producer_is_gxx_lt_4_6 (0), producer_is_gcc_lt_4_3 (0), producer_is_icc_lt_14 (0), + producer_is_codewarrior (0), processing_has_namespace_info (0) { per_cu->cu = this; -- 2.11.0