From patchwork Fri Nov 8 23:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13869152 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 9B37DD64099 for ; Sat, 9 Nov 2024 01:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pJ8FG6zy5TUWlnq+xC0331u7ZC2AgCRZ0YVucMGPpFo=; b=CngNpjH1bXYkwedW4lYgCCb5NL stUzBqsOPQSk+voSjo8qhGjaaqpXTdhPAHx/tKNrxEiWjhs4iu7uR6POYhb1GHcr8wKJ98+jqc8pr VV5Rsh2IzLN8kXJLIeqdtQVcPeuN4vzQ6iW0Kx8VQ5GIhaQ8UqSlpp/bWr6O5FnVL/rS4z+ZMQu+w pPOEZKFleqwd5JVWM82eBpC8JuPPreHlC8CbTneVtgq0z8ipRLc/uQh2hvr9ylkALrYq34+UQaclV VnQRVwAeovq6P7d74n3/rDNufiRmrBGkVQhZZObdGdQAdlc2jmU2Dz95J57MuWIDPHeAAQNs295nO 1bZu+5dA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t9aKW-0000000CRsF-2KaL; Sat, 09 Nov 2024 01:32:00 +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 1t9YgL-0000000CF36-3E4k for linux-arm-kernel@lists.infradead.org; Fri, 08 Nov 2024 23:46:27 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6ea863ecfe9so55456317b3.3 for ; Fri, 08 Nov 2024 15:46:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731109584; x=1731714384; 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=pJ8FG6zy5TUWlnq+xC0331u7ZC2AgCRZ0YVucMGPpFo=; b=z8DQ/NM0Y3VJejRsMq0BPoVgohqbplbfqq2eaKzDh7kLmuW9vD7tiY1Ni9BtgLG/xH wv4Takhkc1EwqmU1yYW+OJXkwexJHoBlxU9ROvdiCHZMLdakgqcY6DJt+dIMfu/6aPFM 4jgh7bJka9Dq+S2EHOtiEMO92n6Ap5ac8NS/tccxCpd+vloZxYA4BBaEwleQuazqlWSa D5mfs5Px9siRwAX//3h6G8VUdK8F/v1o75qgR5Q09Igsw5v3RYCiM1FSB4vvJArU8Aif JoIpTsqi4DRWkTLtBumrlNFMRYxczpQmIcDLSRjbIJC4HEqIa06/wkDufJ8eAYtjkIkU u3Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731109584; x=1731714384; 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=pJ8FG6zy5TUWlnq+xC0331u7ZC2AgCRZ0YVucMGPpFo=; b=PdSJM3SZ/Td2z1tZoRtUjfZHez/ZFyMXR+E6oR9ovNZFGk13jrSRY3ZYQLGHtSktwQ p/QcZ/8E2M6eaYDyRjg9d4Ppa18w1UyS3oTaGo8grzGhW6Bd78B/jBZf1ceEgH5OgDXH 1fN5COTzg/mJnOQzcET8b01JYCqmxEnqHb7kfIGj/GS7YbrMIBCE8K04VSiOxrGp+1NI nE45VPhFjlyORzU1rystV9Pwf8+MtD3wVcqGZj8Gu8ZD8GWGS03Q9eggSuzME6R39NIY PN7h/lrYiC+sbJehG1f9SIrYIfe1xVGcsv14h2v8eIDIxdUrT4zPCe3i6fp/U0nEjNvF gBOQ== X-Forwarded-Encrypted: i=1; AJvYcCWawkT+WQueZ8miIJRWjSbe29Bz/ygt/TcB4eIGsA96x7mEzrvjyY4qhW4m5UUZnxOxIEjQqontFXkXMQ+8EnI2@lists.infradead.org X-Gm-Message-State: AOJu0YziJrQUMhkm00fzmvog0k331KnzSV3bKHcoxKCWLq5c+1u0u7aJ WzzUej9gEryAghg8c+T1YoL8iKX6MRMbkj3jkSUsQewFNVFLijlH+PmX+mFKYXtwDPRzlHsbh7P QCSNw8g== X-Google-Smtp-Source: AGHT+IHg4RSsHZd7KxofWdmf3WMrYAK9htxRk4zqCdhJjgG3IPf6PuCptYOSwoHmhhxh7CfReCPu0Lzm3Nqx X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:6fd2:1e36:6d8c:7c49]) (user=irogers job=sendgmr) by 2002:a05:690c:200f:b0:6ea:34c3:742b with SMTP id 00721157ae682-6eaddfad76amr476327b3.6.1731109584191; Fri, 08 Nov 2024 15:46:24 -0800 (PST) Date: Fri, 8 Nov 2024 15:45:51 -0800 In-Reply-To: <20241108234606.429459-1-irogers@google.com> Message-Id: <20241108234606.429459-7-irogers@google.com> 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 06/20] 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 , "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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241108_154625_972578_C628CD36 X-CRM114-Status: GOOD ( 19.84 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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/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 3c3a908b9f36..0ef428d07bcc 100644 --- a/tools/perf/util/include/dwarf-regs.h +++ b/tools/perf/util/include/dwarf-regs.h @@ -90,12 +90,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 c2ca94e29aca..7f2ee0cb43ca 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; @@ -1402,7 +1403,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 dfcf8cdd9e8d..be7b46ea2460 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. Not owned. */ 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 */