From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753163AbdJLDWQ (ORCPT ); Wed, 11 Oct 2017 23:22:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:54600 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752029AbdJLDWM (ORCPT ); Wed, 11 Oct 2017 23:22:12 -0400 From: NeilBrown To: Linus Torvalds , Ingo Molnar Date: Thu, 12 Oct 2017 14:22:04 +1100 Cc: LKML , Josh Poimboeuf Subject: [PATCH] scripts: fix faddr2line to work on last symbol Message-ID: <8760blnj8j.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable If faddr2line is given a function name which is the last one listed by "nm -n", it will fail because it never finds the next symbol. So teach the awk script to catch that possibility, and use 'size' to provide the end point of the last function. Signed-off-by: NeilBrown =2D-- scripts/faddr2line | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/faddr2line b/scripts/faddr2line index 29df825d375c..2f6ce802397d 100755 =2D-- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -103,11 +103,12 @@ __faddr2line() { =20 # Go through each of the object's symbols which match the func name. # In rare cases there might be duplicates. + file_end=3D$(size -Ax $objfile | awk '$1 =3D=3D ".text" {print $2}') while read symbol; do local fields=3D($symbol) local sym_base=3D0x${fields[0]} local sym_type=3D${fields[1]} =2D local sym_end=3D0x${fields[3]} + local sym_end=3D${fields[3]} =20 # calculate the size local sym_size=3D$(($sym_end - $sym_base)) @@ -157,7 +158,7 @@ __faddr2line() { addr2line -fpie $objfile $addr | sed "s; $dir_prefix\(\./\)*; ;" DONE=3D1 =20 =2D done < <(nm -n $objfile | awk -v fn=3D$func '$3 =3D=3D fn { found=3D1; = line=3D$0; start=3D$1; next } found =3D=3D 1 { found=3D0; print line, $1 }') + done < <(nm -n $objfile | awk -v fn=3D$func -v end=3D$file_end '$3 =3D=3D= fn { found=3D1; line=3D$0; start=3D$1; next } found =3D=3D 1 { found=3D0; = print line, "0x"$1 } END {if (found =3D=3D 1) print line, end; }') } =20 [[ $# -lt 2 ]] && usage =2D-=20 2.14.0.rc0.dirty --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlne39wACgkQOeye3VZi gbntYA//atJ9cLx3IZ2/5y9LNPa28s4k/vhZbzZJf+jpwqVqRZONf9wow4AIai2K THYluzvZvSXqPxMj0N9d8J2jqI+SQs12LN/N3zmlWnz7zU4c4usY9b25ub0LI3GE M9toLRuivdCcQlFeObJd/14RBcsjmr1GxY6OzxsLg0fe7YPRB1BHdcUB2RZLJubJ fhOGzFiU1ORbImHfmLKagjK6LHQA9ozVY2h2LhfosjlWo2mjv1aXlngPfRX8bosL S/BSfMT7rKhB3PapzuOQ0NbaJJMWPKJ72fe+FXhLPiBzTA4wMtMO+mqLc/QhDDK+ URMvpbH20EyOynGSAS6BmPJiQAT4ihFvuc7ATSdiGq3tEHg/dMVOuGeJ3iiNh3VT Qr48siszoIJGMEaQE0l+pC4qZoTthRnOn4YlWllELqaEi9PoIwvp94T9nkHOz15i D4mXYwSIwPd++yuo6ma6ETRQkByAIaACmlUzPpdLnzhnJ0o5AcDJr01P/R+N9N8Y PPeJTlTkVBACwW/sIV+PK1yuFZxR4ZkqvgPGtActe2FvAD/9zfJEWi+Gw6PEcVRp VarkwloS4zuaaAlwU/CTQA5u5PYIOJBqO8XTiRbXUECNvCLI+v9hU1zo6ktupSkE B5x8p6/8Q82lYIe1W4ZD0aZ5SCc8VNHudCuhd/323QAPlQV8q9I= =HYWL -----END PGP SIGNATURE----- --=-=-=--