From patchwork Thu Sep 26 11:36:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 20595 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f200.google.com (mail-ye0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AE40623A4E for ; Thu, 26 Sep 2013 11:37:30 +0000 (UTC) Received: by mail-ye0-f200.google.com with SMTP id r5sf808634yen.7 for ; Thu, 26 Sep 2013 04:37:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=m6U66BqCk3em+JgiUcEhKiNVgPHHEbv0z3tIGMoi4VM=; b=HdunEyHIeMB4AxABg28dbRYncT/ZI0/qO20xu4qwcS/dMcCU9Oqs+skgigIDIQQooQ k5ih3/T/i4QdaLJNpH9FL7M8ej9LS0Wxz+WuutfIPc/615UEMXs7o3INJYfhfW8CjHf5 8LYj949awj4MuW/jJRCPbadJdwyQhTLMxsoKE/IWmHaVA4GJa35kmt4SGBafiXgUQ946 o4BlSvrQ1Dn2gb8Ufwox7YhT5+PyWnXatmynTpvFRD0rKlE9D5NM30GnktDUwBoofar3 6cDX/Psoj6QyeOmYEKhnYjx8smmv4dILy+h8A4rHlOWJXTCxks3ve4KbbJQq05awZCSV z9cg== X-Gm-Message-State: ALoCoQnrXs7k4v/MIoreKKgeL1Va26qVMGkVhut2cKgs6Tcrk+eYrVf4G+4b6BnO9D7V5HX2zqu/ X-Received: by 10.236.73.164 with SMTP id v24mr80643yhd.24.1380195450545; Thu, 26 Sep 2013 04:37:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.87.36 with SMTP id u4ls849527qez.56.gmail; Thu, 26 Sep 2013 04:37:30 -0700 (PDT) X-Received: by 10.220.142.147 with SMTP id q19mr185362vcu.39.1380195450448; Thu, 26 Sep 2013 04:37:30 -0700 (PDT) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id 10si287198vcr.3.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 04:37:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id h10so720508vbh.34 for ; Thu, 26 Sep 2013 04:37:00 -0700 (PDT) X-Received: by 10.58.19.195 with SMTP id h3mr216694vee.48.1380195420339; Thu, 26 Sep 2013 04:37:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp360784vcz; Thu, 26 Sep 2013 04:36:59 -0700 (PDT) X-Received: by 10.15.67.131 with SMTP id u3mr645404eex.34.1380195419332; Thu, 26 Sep 2013 04:36:59 -0700 (PDT) Received: from mail-ea0-f178.google.com (mail-ea0-f178.google.com [209.85.215.178]) by mx.google.com with ESMTPS id b1si1071226eep.197.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 04:36:59 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.178 is neither permitted nor denied by best guess record for domain of jean.pihet@linaro.org) client-ip=209.85.215.178; Received: by mail-ea0-f178.google.com with SMTP id a15so480877eae.9 for ; Thu, 26 Sep 2013 04:36:58 -0700 (PDT) X-Received: by 10.14.219.5 with SMTP id l5mr628557eep.60.1380195418784; Thu, 26 Sep 2013 04:36:58 -0700 (PDT) Received: from localhost.localdomain (221.61-241-81.adsl-dyn.isp.belgacom.be. [81.241.61.221]) by mx.google.com with ESMTPSA id f49sm2945588eec.7.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 04:36:58 -0700 (PDT) From: Jean Pihet To: Will Deacon , Jiri Olsa , linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, Ingo Molnar , linux-arm-kernel@lists.infradead.org Cc: patches@linaro.org, Jean Pihet Subject: [PATCH 2/4] ARM: perf: wire up perf_regs and unwind support for ARM Date: Thu, 26 Sep 2013 13:36:36 +0200 Message-Id: <1380195398-4402-3-git-send-email-jean.pihet@linaro.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1380195398-4402-1-git-send-email-jean.pihet@linaro.org> References: <1380195398-4402-1-git-send-email-jean.pihet@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jean.pihet@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Will Deacon This patch hooks in the perf_regs and libunwind code for ARM. Signed-off-by: Will Deacon Cc: Jean Pihet --- tools/perf/arch/arm/Makefile | 3 ++ tools/perf/arch/arm/include/perf_regs.h | 54 +++++++++++++++++++++++++++++++++ tools/perf/arch/arm/util/unwind.c | 48 +++++++++++++++++++++++++++++ tools/perf/config/Makefile | 7 +++-- 4 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 tools/perf/arch/arm/include/perf_regs.h create mode 100644 tools/perf/arch/arm/util/unwind.c diff --git a/tools/perf/arch/arm/Makefile b/tools/perf/arch/arm/Makefile index 15130b5..fe9b61e 100644 --- a/tools/perf/arch/arm/Makefile +++ b/tools/perf/arch/arm/Makefile @@ -2,3 +2,6 @@ ifndef NO_DWARF PERF_HAVE_DWARF_REGS := 1 LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o endif +ifndef NO_LIBUNWIND +LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/unwind.o +endif diff --git a/tools/perf/arch/arm/include/perf_regs.h b/tools/perf/arch/arm/include/perf_regs.h new file mode 100644 index 0000000..2a1cfde --- /dev/null +++ b/tools/perf/arch/arm/include/perf_regs.h @@ -0,0 +1,54 @@ +#ifndef ARCH_PERF_REGS_H +#define ARCH_PERF_REGS_H + +#include +#include "../../util/types.h" +#include + +#define PERF_REGS_MASK ((1ULL << PERF_REG_ARM_MAX) - 1) +#define PERF_REG_IP PERF_REG_ARM_PC +#define PERF_REG_SP PERF_REG_ARM_SP + +static inline const char *perf_reg_name(int id) +{ + switch (id) { + case PERF_REG_ARM_R0: + return "r0"; + case PERF_REG_ARM_R1: + return "r1"; + case PERF_REG_ARM_R2: + return "r2"; + case PERF_REG_ARM_R3: + return "r3"; + case PERF_REG_ARM_R4: + return "r4"; + case PERF_REG_ARM_R5: + return "r5"; + case PERF_REG_ARM_R6: + return "r6"; + case PERF_REG_ARM_R7: + return "r7"; + case PERF_REG_ARM_R8: + return "r8"; + case PERF_REG_ARM_R9: + return "r9"; + case PERF_REG_ARM_R10: + return "r10"; + case PERF_REG_ARM_FP: + return "fp"; + case PERF_REG_ARM_IP: + return "ip"; + case PERF_REG_ARM_SP: + return "sp"; + case PERF_REG_ARM_LR: + return "lr"; + case PERF_REG_ARM_PC: + return "pc"; + default: + return NULL; + } + + return NULL; +} + +#endif /* ARCH_PERF_REGS_H */ diff --git a/tools/perf/arch/arm/util/unwind.c b/tools/perf/arch/arm/util/unwind.c new file mode 100644 index 0000000..da3dc95 --- /dev/null +++ b/tools/perf/arch/arm/util/unwind.c @@ -0,0 +1,48 @@ + +#include +#include +#include "perf_regs.h" +#include "../../util/unwind.h" + +int unwind__arch_reg_id(int regnum) +{ + switch (regnum) { + case UNW_ARM_R0: + return PERF_REG_ARM_R0; + case UNW_ARM_R1: + return PERF_REG_ARM_R1; + case UNW_ARM_R2: + return PERF_REG_ARM_R2; + case UNW_ARM_R3: + return PERF_REG_ARM_R3; + case UNW_ARM_R4: + return PERF_REG_ARM_R4; + case UNW_ARM_R5: + return PERF_REG_ARM_R5; + case UNW_ARM_R6: + return PERF_REG_ARM_R6; + case UNW_ARM_R7: + return PERF_REG_ARM_R7; + case UNW_ARM_R8: + return PERF_REG_ARM_R8; + case UNW_ARM_R9: + return PERF_REG_ARM_R9; + case UNW_ARM_R10: + return PERF_REG_ARM_R10; + case UNW_ARM_R11: + return PERF_REG_ARM_FP; + case UNW_ARM_R12: + return PERF_REG_ARM_IP; + case UNW_ARM_R13: + return PERF_REG_ARM_SP; + case UNW_ARM_R14: + return PERF_REG_ARM_LR; + case UNW_ARM_R15: + return PERF_REG_ARM_PC; + default: + pr_err("unwind: invalid reg id %d\n", regnum); + return -EINVAL; + } + + return -EINVAL; +} diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 214e17e..4b65710 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -29,6 +29,10 @@ ifeq ($(ARCH),x86_64) NO_PERF_REGS := 0 LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 endif +ifeq ($(ARCH),arm) + NO_PERF_REGS := 0 + LIBUNWIND_LIBS = -lunwind -lunwind-arm +endif ifeq ($(NO_PERF_REGS),0) CFLAGS += -DHAVE_PERF_REGS @@ -205,8 +209,7 @@ ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) endif # try-cc endif # NO_LIBELF -# There's only x86 (both 32 and 64) support for CFI unwind so far -ifneq ($(ARCH),x86) +ifeq ($(LIBUNWIND_LIBS),) NO_LIBUNWIND := 1 endif