From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751164AbdBBGiT (ORCPT ); Thu, 2 Feb 2017 01:38:19 -0500 Received: from mail-pf0-f178.google.com ([209.85.192.178]:36266 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751093AbdBBGiQ (ORCPT ); Thu, 2 Feb 2017 01:38:16 -0500 From: David Carrillo-Cisneros To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Arnaldo Carvalho de Melo , Jiri Olsa , Alexander Shishkin , Wang Nan , He Kuang , Michal Marek , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Stephane Eranian , Paul Turner , David Carrillo-Cisneros Subject: [PATCH 2/4] tools lib traceevent: Robustify do_generate_dynamic_list_file Date: Wed, 1 Feb 2017 22:38:02 -0800 Message-Id: <20170202063804.94027-3-davidcc@google.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170202063804.94027-1-davidcc@google.com> References: <20170202063804.94027-1-davidcc@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dynamic-list-file used to export dynamic symbols introduced in commit e3d09ec8126f ("tools lib traceevent: Export dynamic symbols used by traceevent plugins") is generated without any sort of error checking. I experienced problems due to an old version of nm (v 0.158) that outputs in a format distinct from the assumed by the script. Robustify this by enforcing that the second column in the symbol output is an "U" (Undefined) as it should be since we are calling $(NM) -u ... and print an error message otherwise. Signed-off-by: David Carrillo-Cisneros --- tools/lib/traceevent/Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile index 2616c66e10c1..1b6e146429d0 100644 --- a/tools/lib/traceevent/Makefile +++ b/tools/lib/traceevent/Makefile @@ -257,10 +257,15 @@ define do_install_plugins endef define do_generate_dynamic_list_file - (echo '{'; \ - $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u; \ - echo '};'; \ - ) > $2 + symbol_type=`$(NM) -u -D $1 | awk 'NF>1 {print $$1}' | sort -u`;\ + if [ "$$symbol_type" == "U" ];then \ + (echo '{'; \ + $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ + echo '};'; \ + ) > $2; \ + else \ + (echo Either missing one of [$1] or bad version of $(NM)) 1>&2;\ + fi endef install_lib: all_cmd install_plugins -- 2.11.0.483.g087da7b7c-goog