From owner-svn-src-head@freebsd.org Wed Dec 2 17:22:30 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 885074A14F5; Wed, 2 Dec 2020 17:22:30 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CmQlB3WD7z3KFk; Wed, 2 Dec 2020 17:22:30 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B7FF2EC7; Wed, 2 Dec 2020 17:22:30 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0B2HMUrI020438; Wed, 2 Dec 2020 17:22:30 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0B2HMUOc020437; Wed, 2 Dec 2020 17:22:30 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <202012021722.0B2HMUOc020437@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 2 Dec 2020 17:22:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368280 - head/contrib/elftoolchain/addr2line X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/contrib/elftoolchain/addr2line X-SVN-Commit-Revision: 368280 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Dec 2020 17:22:30 -0000 Author: emaste Date: Wed Dec 2 17:22:29 2020 New Revision: 368280 URL: https://svnweb.freebsd.org/changeset/base/368280 Log: addr2line: rework check_range conditions Simplify logic and reduce indentation for DW_AT_low_pc case. Reviewed by: Tiger Gao, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27426 Modified: head/contrib/elftoolchain/addr2line/addr2line.c Modified: head/contrib/elftoolchain/addr2line/addr2line.c ============================================================================== --- head/contrib/elftoolchain/addr2line/addr2line.c Wed Dec 2 16:54:24 2020 (r368279) +++ head/contrib/elftoolchain/addr2line/addr2line.c Wed Dec 2 17:22:29 2020 (r368280) @@ -580,8 +580,8 @@ check_range(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Unsi ranges_cnt = 0; in_cu = false; - ret = dwarf_attrval_unsigned(die, DW_AT_ranges, &ranges_off, &de); - if (ret == DW_DLV_OK) { + if (dwarf_attrval_unsigned(die, DW_AT_ranges, &ranges_off, &de) == + DW_DLV_OK) { ret = dwarf_get_ranges(dbg, ranges_off, &ranges, &ranges_cnt, NULL, &de); if (ret != DW_DLV_OK) @@ -612,33 +612,30 @@ check_range(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Unsi break; } } - } else { - if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) == + } else if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) == + DW_DLV_OK) { + if (lopc == curlopc) + return (DW_DLV_ERROR); + if (dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, &de) == DW_DLV_OK) { - if (lopc == curlopc) + /* + * Check if the address falls into the PC + * range of this CU. + */ + if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK) return (DW_DLV_ERROR); - if (dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, - &de) == DW_DLV_OK) { - /* - * Check if the address falls into the PC - * range of this CU. - */ - if (handle_high_pc(die, lopc, &hipc) != - DW_DLV_OK) - return (DW_DLV_ERROR); - } else { - /* Assume ~0ULL if DW_AT_high_pc not present. */ - hipc = ~0ULL; - } - - if (addr >= lopc && addr < hipc) { - in_cu = true; - } } else { - /* Addr not in range die, try labels. */ - ret = check_labels(dbg, die, addr, range); - return ret; + /* Assume ~0ULL if DW_AT_high_pc not present. */ + hipc = ~0ULL; } + + if (addr >= lopc && addr < hipc) { + in_cu = true; + } + } else { + /* Addr not found above, try labels. */ + ret = check_labels(dbg, die, addr, range); + return ret; } if (in_cu) {