From nobody Sun Nov 24 00:41:22 2024 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9717620DD6A for ; Fri, 8 Nov 2024 23:46:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731109584; cv=none; b=UfghKhWu39W/amf9MCo4uBJBc45SyVSBKeG4KbgpHSz9Z0Sw6cLYBSGnRAVMNAn1poyy4fhVOrO/KuH/jlR2QrR3jozMoWo8SXd+IMLNFzrYawpyW91ipEMQJME0Xu9cbKTTAQrmmlPp+jvr6HpEJd9VAwRMgzp64hJYfkY5Nko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731109584; c=relaxed/simple; bh=UpbEPbsvR+MMP/prNjsuZ9PUWl/4549dj65p4AXiKzk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=PAO7zM3npSrXEWpBYw5MOrx4alIEC3tLD8WjcI8MflAMHLIfxyzSGcRRPzh0cjjrhqLfYl4bKfWZJZs6R7jqX8uJU0ZGZ4y+Ww+8XIOsu8YDXcDGE2j1luYEjrw/rczxZphKjBQaRNF8jIIV08hQQ3Ma7ZRaPUahArUt6AK763o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4vQSA4Ek; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4vQSA4Ek" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6ea8a5e83a3so54615057b3.2 for ; Fri, 08 Nov 2024 15:46:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731109582; x=1731714382; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=AVtWpsuHpFiBnlibbq5HoTF1wljBLHXYozEcDvYWBgA=; b=4vQSA4EkVEIJM5AubTw7cfStKPLmDDT9yF38/RsRU1HOp1Qt4QbSTyxFgPASB+HtIT 0EWD48cEW2ApwaQxRiWVlGDSyZEXdTxMvVTjue+hIv/UMFoS9ADmoD5SLlsYKrRm41Z9 PaoWoveFNf/5r0RDYCG7k4wzx/4WaxY5Vsw/429P5ppWhNz9/6rPZukOdc7pJ3VPaLiI ANa/dkx5TYTzrD/iMp5/SBm/zvcSxXwtYHYVOWWmtV/9Zg1LkAr5Ig+4DpsEyDu4qdZR I73mKSNk8qgt4qICj9LbTos1ZZZYVjSS19/yFuG+Hovn6WLOJiSerizvAm3uNdNh1FIs hlQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731109582; x=1731714382; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AVtWpsuHpFiBnlibbq5HoTF1wljBLHXYozEcDvYWBgA=; b=EHsFvjiFL7CjPf0SdhQuoSGDSsqDsxBBT8bm4LZkLlH0tqkQm+SRG9nPTLM8TYxIKs 6S3w6KksO8mQ1p0Qp+uPx02SNmrVxrtVKC1lyzwaW0UXS3FTo6Rwa8XiZSzrpYpcXN4R uDsi1DvrcolnHfi2HwA3XYTBIPlIOJHF6AtVg8+hd7G9qnCFhC3VD3ulfGGCpafGBJai s7UKaofgzKpqtgMBS2Ik62yv+ithZ066RYq7ViXMg6zC76jwgNosXzP56CBnsLjS8wj1 pOdZsTllhhrK5x+ryJXqg8H8LRDovAdRNtWpG47QFpC/mpIjqmUYpaFWlTHjnYHnZwFU Y3tg== X-Forwarded-Encrypted: i=1; AJvYcCXqqimkRWfQQQiJHnXUEHV1CAYuZoWyja4Jwxmpog+T0INNEmA4W7j40GE+GAkKXCRjc2oANQ5geOO6TnE=@vger.kernel.org X-Gm-Message-State: AOJu0YxOwfSBvrxvwXCUTusDC6R7aUxAmhaKGbnRJCQUwO8JqqAlkIRy 0oDroWY5vBy6JD5nohMis3uABKTWUte3notk54Yfb4zCbbFwsNZYAtJ/Vnbu3pIu0ZCGDuUzIxr EkEURDg== X-Google-Smtp-Source: AGHT+IFq1UuJ7hc/ApetK/H2sFL5m2uMATjY+fqFwJq/WDc5NUWTV7ClaOKOd64kgsF/WFeRan59owDlPrau X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:6fd2:1e36:6d8c:7c49]) (user=irogers job=sendgmr) by 2002:a25:84c9:0:b0:e33:111b:c6a4 with SMTP id 3f1490d57ef6-e337f81b835mr3397276.1.1731109581785; Fri, 08 Nov 2024 15:46:21 -0800 (PST) Date: Fri, 8 Nov 2024 15:45:50 -0800 In-Reply-To: <20241108234606.429459-1-irogers@google.com> Message-Id: <20241108234606.429459-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241108234606.429459-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Subject: [PATCH v4 05/20] perf dwarf-regs: Pass accurate disassembly machine to get_dwarf_regnum From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Guo Ren , Paul Walmsley , Palmer Dabbelt , Albert Ou , Nick Terrell , "Masami Hiramatsu (Google)" , Changbin Du , Guilherme Amadio , Yang Jihong , Aditya Gupta , Athira Rajeev , Masahiro Yamada , Bibo Mao , Huacai Chen , Kajol Jain , Atish Patra , Shenlin Liang , Anup Patel , Oliver Upton , "Steinar H. Gunderson" , "Dr. David Alan Gilbert" , Chen Pei , Dima Kogan , Przemek Kitszel , "David S. Miller" , Alexander Lobakin , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than pass 0/EM_NONE, use the value computed in the disasm struct arch. Switch the EM_NONE case to EM_HOST, rewriting EM_NONE if it were passed to get_dwarf_regnum. Pass a flags value as architectures like csky need the flags to determine the ABI variant. Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Ian Rogers --- tools/perf/util/annotate.c | 6 +++--- tools/perf/util/dwarf-regs.c | 8 ++++++-- tools/perf/util/include/dwarf-regs.h | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 37ce43c4eb8f..b1d98da79be8 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2292,7 +2292,7 @@ static int extract_reg_offset(struct arch *arch, cons= t char *str, if (regname =3D=3D NULL) return -1; =20 - op_loc->reg1 =3D get_dwarf_regnum(regname, 0); + op_loc->reg1 =3D get_dwarf_regnum(regname, arch->e_machine, arch->e_flags= ); free(regname); =20 /* Get the second register */ @@ -2305,7 +2305,7 @@ static int extract_reg_offset(struct arch *arch, cons= t char *str, if (regname =3D=3D NULL) return -1; =20 - op_loc->reg2 =3D get_dwarf_regnum(regname, 0); + op_loc->reg2 =3D get_dwarf_regnum(regname, arch->e_machine, arch->e_flag= s); free(regname); } return 0; @@ -2405,7 +2405,7 @@ int annotate_get_insn_location(struct arch *arch, str= uct disasm_line *dl, return -1; =20 if (*s =3D=3D arch->objdump.register_char) - op_loc->reg1 =3D get_dwarf_regnum(s, 0); + op_loc->reg1 =3D get_dwarf_regnum(s, arch->e_machine, arch->e_flags); else if (*s =3D=3D arch->objdump.imm_char) { op_loc->offset =3D strtol(s + 1, &p, 0); if (p && p !=3D s + 1) diff --git a/tools/perf/util/dwarf-regs.c b/tools/perf/util/dwarf-regs.c index 7c01bc4d7e5b..1321387f6948 100644 --- a/tools/perf/util/dwarf-regs.c +++ b/tools/perf/util/dwarf-regs.c @@ -70,7 +70,7 @@ __weak int get_arch_regnum(const char *name __maybe_unuse= d) } =20 /* Return DWARF register number from architecture register name */ -int get_dwarf_regnum(const char *name, unsigned int machine) +int get_dwarf_regnum(const char *name, unsigned int machine, unsigned int = flags __maybe_unused) { char *regname =3D strdup(name); int reg =3D -1; @@ -84,8 +84,12 @@ int get_dwarf_regnum(const char *name, unsigned int mach= ine) if (p) *p =3D '\0'; =20 + if (machine =3D=3D EM_NONE) { + /* Generic arch - use host arch */ + machine =3D EM_HOST; + } switch (machine) { - case EM_NONE: /* Generic arch - use host arch */ + case EM_HOST: reg =3D get_arch_regnum(regname); break; default: diff --git a/tools/perf/util/include/dwarf-regs.h b/tools/perf/util/include= /dwarf-regs.h index ce9f10b3282d..3c3a908b9f36 100644 --- a/tools/perf/util/include/dwarf-regs.h +++ b/tools/perf/util/include/dwarf-regs.h @@ -103,12 +103,13 @@ int get_arch_regnum(const char *name); * name: architecture register name * machine: ELF machine signature (EM_*) */ -int get_dwarf_regnum(const char *name, unsigned int machine); +int get_dwarf_regnum(const char *name, unsigned int machine, unsigned int = flags); =20 #else /* HAVE_LIBDW_SUPPORT */ =20 static inline int get_dwarf_regnum(const char *name __maybe_unused, - unsigned int machine __maybe_unused) + unsigned int machine __maybe_unused, + unsigned int flags __maybe_unused) { return -1; } --=20 2.47.0.277.g8800431eea-goog