From nobody Tue Nov 26 17:26:34 2024 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 0DC1D8F6C for ; Thu, 17 Oct 2024 00:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729124742; cv=none; b=Ml6MEGMI9dGtiAZFS/iSPPEqK0JiT/BWW4yvcYuRS/BtpCAImwEwThGL7UpZeQ0NbSBlyAG7vnXJ8oWj8V1IMpyi+k2X4z8h8XEZBmI/pWhOt7shxCbJApLSm78e7ApMtpNGmI/hoYcxJbtNn45xUKRf63xR0C2kpkrry8QBISk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729124742; c=relaxed/simple; bh=pjIIA43SghEugoe0WZ1k1xzKHy+DAgbM7RilvHgchP8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=I//rkl2oPBGmxzzoFQ1CIN4eRS9W05CW7U8eRcLuahgGuKXJzeLzkLWTXZp7xuR4p2ShN+xCfsptUbDYx6KLszQMKfZi+H9RKd2ryxxl7oYM2oInsl/wGAjB1WqvARpd6GUiLwbGDRiZvIetcG3mrOAr6SHr7oWbTN3LCEir26o= 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=dboPLXsz; arc=none smtp.client-ip=209.85.219.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="dboPLXsz" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e290222fde4so526894276.1 for ; Wed, 16 Oct 2024 17:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1729124740; x=1729729540; 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=48mjrfomMuomFB22b093k885CPaCWm0H0utyyG5sq/o=; b=dboPLXsznIf04UTRmQcpZU5l6rbK6vkdftgtHgOsAcU7xR+TFbZU4ZunKJ358yRTvo Ce6kJ0lks43QHmxvsA9T1d1E3wEFrbErXC4P2O35aPBAKM4Zb0jz2wvxVh/BQscGCEyw 6816Pn2EZlO30fmMLqaYy7jUgQSRWyqMz06GdqZw2xC8gUbWmY/Mz9iAQx8GUgpbhNNs dSDtEvaO6a914vzwcHLIHE9r/NOfCBzIa7nRMZz1RP9R0CE1B4KsIZA6jSReQ0M9iKUY IpMawDvaNfQgL1Cnb+pjHRQZuh/VqsEF2zFpz4ICBN4tOTqsQ5qU4mIC358xoeDPrkHR ZQmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729124740; x=1729729540; 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=48mjrfomMuomFB22b093k885CPaCWm0H0utyyG5sq/o=; b=PUWy4RduUtDEN1SjDmEnh1OMIInMIpOnFi+JPHvJ74qJd5vbS0MdhYZxG/X4wmHZlt Ur7+DIAKslbQOfnX+NiOqAxRItpqRvJGf56l/F+FvXur0Smm+KvWMNPvfCkl3J5c7gnc pd1hKNa0JBPeATgNKy1HnmXYxmtFiGUS8edyG0jjooImhXcAuYGPs4gmI7VpP8zm5RK/ VOV1hzA/HR1ARiNYNiIiaXM/mIHSvKMQdrS3sYCBaxR02ulfwmc/cdt95Q076dmXqubS LHGn1dMJUWU7svHOnx7m8D2b9/otZH4NM8xwyG2KRi21MOfWjUx2Zn4TJZfRAb5FwLOK PZJQ== X-Forwarded-Encrypted: i=1; AJvYcCU5qBMUBqVqSjA6wjMO6lDBy5N6Kl1pKxNoLCZZ7wLRv8Q/19klnwMLwsLI7r/2l1kchFKoh+0f+Ergfk8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9IhAyOpo6Ly53doYDkinfuvxDTahEMBocVNOESMligq9ky0E2 07vonxKhEezHjgtXTMGLo/1DH5lumv34cLDblEJDyUI+kzsFTJE+12KpKsxoCs3zIX49BrwfmLD +h/0vtQ== X-Google-Smtp-Source: AGHT+IG8JiIQK8uXOvPdoaWI2mxht6B92+7n0NisCZoM8iJKAkzjyBLEa7nUOj+aZg/H9XU8lHqJJagHTx/j X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:a00a:f237:9bc0:79c]) (user=irogers job=sendgmr) by 2002:a25:dc4e:0:b0:e28:f231:1aa8 with SMTP id 3f1490d57ef6-e29782bbb03mr7731276.2.1729124739976; Wed, 16 Oct 2024 17:25:39 -0700 (PDT) Date: Wed, 16 Oct 2024 17:25:05 -0700 In-Reply-To: <20241017002520.59124-1-irogers@google.com> Message-Id: <20241017002520.59124-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: <20241017002520.59124-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog Subject: [PATCH v3 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. 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.105.g07ac214952-goog