From nobody Thu Nov 28 03:39: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 4514E17A5B5 for ; Sat, 5 Oct 2024 19:56:35 +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=1728158196; cv=none; b=W1bdrGcuUBbgRIcQaggHk1EFRICZClXSzwdCFSsR1bJszWjCVpcyc63ZQ1qGZaSl221my6XjKY9Ae5LStktyryz1H8SlnXRwtCT+F63bpFTJNOcDEpV2KJLP+/XeEtzV1QAaHTuF7tKdEP2uFrRR02feYxe1Avq0kxrE8YMblbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728158196; c=relaxed/simple; bh=ZXckq9/5rBlLdDdPjIGQW8xHKpySzPV+gMGHrENNoZg=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=D8s0rQuVOK3p9JwQk1x7NX93SU1tPemLj4kvuC6+JFljvRVXkWMdtLGiofOqLUgGHm3tapulR4qmz/dpxzrFLssWGLi5PE2+7agsTJZAqNgW19tFtgHobV2RlE5R1TqQBbtqKsUA1NP2I4zeDb4Y+qdWvJNjEW8CPNHoyAVTZmg= 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=T1+uWp65; 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="T1+uWp65" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e2364f45a4so42688097b3.2 for ; Sat, 05 Oct 2024 12:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728158194; x=1728762994; 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=i2ESjB2YIGNr0kAF0x/rOVXxJN2WJ7SSqyQKEEmQuJA=; b=T1+uWp65CMTQrH+EuM2H41rh+/iKOFuJeCeLU3NaoD00220fTqUUyCUL8IYVOD9b8q QthROhhcP1fIBljIHpgDIEyFbF+B+u/C+ofIOnCJUWmfPs/gGIxtVPtqST2/EwkhaLiN YygXZEuSVNbCGbHC1Ye9ZCNUYZrNcHEo0peuaUTNPGrTdw03tezGnyj3zPvuCKQ1JDaZ SobyzjLs9lk0ppE7j2s+nRn2uxX/HA5AANpX0a4KxntG30K+c2lAdxJcSnUOpwRf3xCe 6RWs3RY6hkEsUng/k3NWKSBRrXgr49vMoDpYI+QI1U32FIwGgCVaMMqNTUipM4DuERvZ 3OBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728158194; x=1728762994; 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=i2ESjB2YIGNr0kAF0x/rOVXxJN2WJ7SSqyQKEEmQuJA=; b=Iga0ptwF1Urs82UG98cij3MtZxl6R2holvKAhf+H0jQBCEooyxDMQJB5snpdbHvbTX YvAM5exAzzpSsMO94C6JWlt1/9HdMeG0uF/N9Vt/Mez5CzCDAr8pBTXlTwHvQ+BteKVz 0rlCYxl9FQSLzDCECEOLr7BzHn5GuzckNFucIh7s0IFv6xB79SB92PewLHhd2nCgT24H t+qiuEFHFoZbs0snzKajiQiJTjR7ltozzaW2pnQlvwGOcgW68FI4++0T2i9BjER4GoX0 V1hsdKekVbp9fI2pFJMHo6asu/OHpkNP0UxUnnEFKAd2+c2whicoEyHaa2d7LRxSH5x8 vMLA== X-Forwarded-Encrypted: i=1; AJvYcCVxFlFA4llzIdBLhVn4rE1uabAgN4jF1wNvz+eXUhEOUPk15D2/x5pgoEYoV60oL+6IitDnb6wpJAYUFQ8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3BSvSHzx1UI9JlqRmBylYKzCjsDmZ3XvWFNNOSAEnU5bk4W73 6Xuv/JapLkx40UXIKTFoYrm753wwNk3zQihXIrksu+bmZ+HajRROL2FpLzANUq8mzbJrVWao07i OF5yCRA== X-Google-Smtp-Source: AGHT+IHEbD4MRwZ2PKCjAUCVKxtlz40qrMSN6DbbdIeVTb8C/0Bd+XGDjYe2Dr3Ix5YBR4/AVrrPnEznaGld X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:4c2:5b4d:8797:7249]) (user=irogers job=sendgmr) by 2002:a25:c512:0:b0:e28:8f62:e735 with SMTP id 3f1490d57ef6-e28936c055bmr5227276.1.1728158193972; Sat, 05 Oct 2024 12:56:33 -0700 (PDT) Date: Sat, 5 Oct 2024 12:55:26 -0700 In-Reply-To: <20241005195541.380070-1-irogers@google.com> Message-Id: <20241005195541.380070-17-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241005195541.380070-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog Subject: [PATCH v2 16/31] 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 , "Steven Rostedt (Google)" , "Masami Hiramatsu (Google)" , Guilherme Amadio , Changbin Du , Daniel Bristot de Oliveira , Daniel Wagner , Aditya Gupta , Athira Rajeev , Masahiro Yamada , Kajol Jain , Huacai Chen , Bibo Mao , Anup Patel , Atish Patra , Shenlin Liang , Oliver Upton , "Steinar H. Gunderson" , "Dr. David Alan Gilbert" , Chen Pei , Dima Kogan , Yury Norov , 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. 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 f4f87ded5e3d..ee0a734564c7 100644 --- a/tools/perf/util/include/dwarf-regs.h +++ b/tools/perf/util/include/dwarf-regs.h @@ -93,12 +93,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.rc0.187.ge670bccf7e-goog