From patchwork Sat Oct 5 19:55:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13823582 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D0E8CFB43C for ; Sat, 5 Oct 2024 21:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8fHtBenV6Tm+XgVGg5y9xjqMEFrkXnNyc9ZuPphdy2U=; b=FfFv1ppLDYF3uB 2QPjEYUFsY8WwBWvZ+fCQU3m0/X2LpKeCyKfqFTc5+Ek/JHejqUOsQHDv76JjAvUEAVcM3HWRgxz1 EVJUUGgijNGlSI5wVhh8iG+F8FpAWNCs0eGQCyPUDZUQ0gpsOlkkVCFQpJ8PwD2yqau5jG7vququz K3B5blVpXyKLjOFQsFPWaT4sczMI1HCE2vJMcyeFTyHhyQkQAy4APcnv/vsXt392FaAQcTT8jIrpD +8ljP65yZQ0rubs2IZP+psDWf2vbvucM9WpW5M5NgJzWpuDmKiaIyj9lYFNFD6G3z8SUcTVDcSjQu +EEJpJApVJKFc+ponENQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxCNq-0000000Fyzn-2iYx; Sat, 05 Oct 2024 21:32:14 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxAtJ-0000000FqB7-3jhU for linux-riscv@lists.infradead.org; Sat, 05 Oct 2024 19:56:39 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6e230808455so40287037b3.0 for ; Sat, 05 Oct 2024 12:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728158196; x=1728762996; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=0piuJuEbl3cyfBd1ycTRiflZHzTELs7cJF9ZD6VJNSY=; b=pLxbJCALAcaC4yNzOWdy3jfR8VO+CejxUw21A36lUHHl+d0fEKOgwLNnsgEDpoVc0/ uzNt0fMnj6rDsuCRsH1JqUFIeYqbbFWv1BPkaIazfIA6AuUsIjsVm/4IZWxBtid3QWuj iaPfvHxss4Dlz3r7GIOAHZGJoWQSpybC01zsuAUD3jWvY2y3kA/2G0SCNVZ44hWVMmTg hYp5yX4RoP8fIN8A6KSCE5xQ4wo9sUvtajrrue91MV1DkptUuqBLl7yuoYI9z1zhGggO Vn6uNUZh+QVAYXoRLWBhEOtzEr4QuSln2/W1ZFK0ql3qN3ST04Qc3+WvRaIGMK0JhQZa zPCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728158196; x=1728762996; 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=0piuJuEbl3cyfBd1ycTRiflZHzTELs7cJF9ZD6VJNSY=; b=FY4A/hv5VB34bQR6jJwAd1Dy6DFSzQpBPTMyBCn+ltAMGjybqOTYXxWbk7MvnbxJyJ W5cIZ1v2nB9KIDWHroMkxepZD4cr/89f2abfH6iTbGNFBTn0x2Arx/asbW66kZaeOUqY bC+66v0rsdqQUEst9fP8xfUSnzp9qEC8MQJRMACAEBLZhPKCURONwq0Jx4Q9WD+URBlW EuwmW2E5qCn7nlqnGJW9kDklXnJLNRbuLAg/1cVOgqybZYP01OGtlBUVHBPMmei6kMR4 vd0NIPxBa7KjELC0QZHlnXnrRzXYtpT9P9iUS+b+YXzjWmw/9IwUr6CgqmLC2HcVTaHh bcUg== X-Forwarded-Encrypted: i=1; AJvYcCX9H3uX+RzetruCQPVXIfwTpb3u4hzDHY9Dtr+vy/Kk0M4mgpGmoUXMUAyXgMWoJRvdjNHzsrMcGdXeow==@lists.infradead.org X-Gm-Message-State: AOJu0Yz4yKYqdAbJn4sS1CnuXhCxAwL2IcIDfpKvyqm4hPZWToPwjzyv zcSA38M9PlwgqM2qhIfMiWlmhe42A+uRUMxqRQ1h2PXmhPjs0b+MFOK2BghUjdDGK95nX19YMyT P5Af34Q== X-Google-Smtp-Source: AGHT+IFw5CxBdphrH0oO2pIqnbwppYx+xeDmInG4DbSWMHLYMTF4BCdDpwkczfpwGniJ6rB2By3vVlUyf6uu X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:4c2:5b4d:8797:7249]) (user=irogers job=sendgmr) by 2002:a25:d852:0:b0:e0b:fe07:1e22 with SMTP id 3f1490d57ef6-e28936be881mr14121276.1.1728158196428; Sat, 05 Oct 2024 12:56:36 -0700 (PDT) Date: Sat, 5 Oct 2024 12:55:27 -0700 In-Reply-To: <20241005195541.380070-1-irogers@google.com> Message-Id: <20241005195541.380070-18-irogers@google.com> 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 17/31] perf dwarf-regs: Pass ELF flags to get_dwarf_regstr 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241005_125638_046144_C5E903EC X-CRM114-Status: GOOD ( 17.68 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Pass a flags value as architectures like csky need the flags to determine the ABI variant. Signed-off-by: Ian Rogers --- tools/perf/util/dwarf-regs.c | 3 ++- tools/perf/util/include/dwarf-regs.h | 11 ++++++----- tools/perf/util/probe-finder.c | 13 +++++++------ tools/perf/util/probe-finder.h | 3 ++- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/dwarf-regs.c b/tools/perf/util/dwarf-regs.c index 1321387f6948..86b3ef638fbb 100644 --- a/tools/perf/util/dwarf-regs.c +++ b/tools/perf/util/dwarf-regs.c @@ -29,7 +29,8 @@ #define __get_dwarf_regstr(tbl, n) (((n) < ARRAY_SIZE(tbl)) ? (tbl)[(n)] : NULL) /* Return architecture dependent register string (for kprobe-tracer) */ -const char *get_dwarf_regstr(unsigned int n, unsigned int machine) +const char *get_dwarf_regstr(unsigned int n, unsigned int machine, + unsigned int flags __maybe_unused) { switch (machine) { case EM_NONE: /* Generic arch - use host arch */ diff --git a/tools/perf/util/include/dwarf-regs.h b/tools/perf/util/include/dwarf-regs.h index ee0a734564c7..925525405e2d 100644 --- a/tools/perf/util/include/dwarf-regs.h +++ b/tools/perf/util/include/dwarf-regs.h @@ -80,12 +80,13 @@ #ifdef HAVE_LIBDW_SUPPORT const char *get_arch_regstr(unsigned int n); -/* - * get_dwarf_regstr - Returns ftrace register string from DWARF regnum - * n: DWARF register number - * machine: ELF machine signature (EM_*) +/** + * get_dwarf_regstr() - Returns ftrace register string from DWARF regnum. + * @n: DWARF register number. + * @machine: ELF machine signature (EM_*). + * @flags: ELF flags for things like ABI differences. */ -const char *get_dwarf_regstr(unsigned int n, unsigned int machine); +const char *get_dwarf_regstr(unsigned int n, unsigned int machine, unsigned int flags); int get_arch_regnum(const char *name); /* diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 8019d232f515..29eaa9beca86 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c @@ -56,7 +56,7 @@ static struct probe_trace_arg_ref *alloc_trace_arg_ref(long offs) */ static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr, Dwarf_Op *fb_ops, Dwarf_Die *sp_die, - unsigned int machine, + const struct probe_finder *pf, struct probe_trace_arg *tvar) { Dwarf_Attribute attr; @@ -166,7 +166,7 @@ static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr, if (!tvar) return ret2; - regs = get_dwarf_regstr(regn, machine); + regs = get_dwarf_regstr(regn, pf->e_machine, pf->e_flags); if (!regs) { /* This should be a bug in DWARF or this tool */ pr_warning("Mapping for the register number %u " @@ -451,7 +451,7 @@ static int convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf) dwarf_diename(vr_die)); ret = convert_variable_location(vr_die, pf->addr, pf->fb_ops, - &pf->sp_die, pf->machine, pf->tvar); + &pf->sp_die, pf, pf->tvar); if (ret == -ENOENT && pf->skip_empty_arg) /* This can be found in other place. skip it */ return 0; @@ -1134,7 +1134,8 @@ static int debuginfo__find_probes(struct debuginfo *dbg, if (gelf_getehdr(elf, &ehdr) == NULL) return -EINVAL; - pf->machine = ehdr.e_machine; + pf->e_machine = ehdr.e_machine; + pf->e_flags = ehdr.e_flags; do { GElf_Shdr shdr; @@ -1171,7 +1172,7 @@ static int copy_variables_cb(Dwarf_Die *die_mem, void *data) (tag == DW_TAG_variable && vf->vars)) { if (convert_variable_location(die_mem, vf->pf->addr, vf->pf->fb_ops, &pf->sp_die, - pf->machine, NULL) == 0) { + pf, /*tvar=*/NULL) == 0) { vf->args[vf->nargs].var = (char *)dwarf_diename(die_mem); if (vf->args[vf->nargs].var == NULL) { vf->ret = -ENOMEM; @@ -1403,7 +1404,7 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data) tag == DW_TAG_variable) { ret = convert_variable_location(die_mem, af->pf.addr, af->pf.fb_ops, &af->pf.sp_die, - af->pf.machine, NULL); + &af->pf, /*tvar=*/NULL); if (ret == 0 || ret == -ERANGE) { int ret2; bool externs = !af->child; diff --git a/tools/perf/util/probe-finder.h b/tools/perf/util/probe-finder.h index b9a5afca4cc1..71e21cb4492a 100644 --- a/tools/perf/util/probe-finder.h +++ b/tools/perf/util/probe-finder.h @@ -68,7 +68,8 @@ struct probe_finder { /* Call Frame Information from .debug_frame */ Dwarf_CFI *cfi_dbg; Dwarf_Op *fb_ops; /* Frame base attribute */ - unsigned int machine; /* Target machine arch */ + unsigned int e_machine; /* ELF target machine arch */ + unsigned int e_flags; /* ELF target machine flags */ struct perf_probe_arg *pvar; /* Current target variable */ struct probe_trace_arg *tvar; /* Current result variable */ bool skip_empty_arg; /* Skip non-exist args */