From nobody Thu Nov 28 03:51:21 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 606D818593D for ; Sat, 5 Oct 2024 19:56:37 +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=1728158199; cv=none; b=So8CNeRdpRlqEqH/RHqcAg8XC6prD/aG1vKNKvhFbJPX4Vv68yJSELS4WNbLyy07j2A2J1M71HMkpYz2LSF6VE5MCPgM1vjaMYVF2QmiEpijIxOVPPl8IQAsWoTL6HWniwAS+leAISPL8mrfBPV8iHZ0BAK/EfOu8i8dI+5ZCcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728158199; c=relaxed/simple; bh=TfSSpaClTWkztEMDJOpaYOhgo1TBAP7LFL/J9eyzwJo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=C8G/ffua67uZNwD07vCyYKCgES9qOU0bXv3Et/n4F2el9zQtrJxF7hmuUXK+bm0FLbBp6xlc99olEpLjFjmkuxs1l2Bv6m1vNuYQb9Uqcsybnx2RIApup5W1J9i4K69uf11uAJiKbntAaNJQGMurtheS4yUFp7bI+Z6zyDu2LgQ= 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=mavSd/Fe; 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="mavSd/Fe" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e0b8fa94718so4781793276.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=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=0piuJuEbl3cyfBd1ycTRiflZHzTELs7cJF9ZD6VJNSY=; b=mavSd/FeWQeQzdHDi9FU8uGhk2DtapUfabUj/NjpIv1afrGbcGvgdZJ973LWrtoHcR mmw8d1MDD3zWOQHnnBXn5X+YpLW0QVlwq+0nR4bo0FZvUBJWPMY8JtUfoeKTaxVAhmYr nrSKNONA0mAVNeDIX6CuFsimybeestnvX2leBXAUeokccEkVaD5gqQXZinuwtpza8wBA qS5kXkij7vOcy2NQZrMXybx7ZwSBp0U9pilhA/3hCsmebGfZQ45gWKQEs7hyrhg8gzP+ H9ENe/xQUkf8LUyNxycM1gLoMMfEJXLTRscKW1V7klnwlT2OAF9TqUPK0ruUmLwORDqU 3Dwg== 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=Vvl3NGtot1NHuxz6Ii4E2EATIk0iZzrzkYCE+tkltgIuE0wxEymG4qZTrjQ9Zufbjw C3INQSBndP7xKk7iGEXpzjreq7H7KpmFC4PyWXHUMbA56StQM5CaR/hhXV8/wR6vxQs0 uTz+0OqJ0f1p+FNpcpQq1B6oNPJHOoXRqjBpK3cQOrQZLWihmDk0MZeT9AjSbzvROLRT tDk8pX0yYEVf+ADxwrQF48kfNdlZS4Q61fTr1A8N6L2xzVyfrz5rfpBOfHDqOk3wtVfl YoGfKBm9Ud5yLfjoeBrHixqyflk9Htnc25f3fA6GHYln6MHjiTJ7ftlAT+kEfV6dRz4x kQ4g== X-Forwarded-Encrypted: i=1; AJvYcCVM9bYxdkgLie/3xyVQciOj6VyCmhwulsVdpEnwk6+2gk5liR4X3QInjeNxTnllX98fhO0Lsy6BOSsznHo=@vger.kernel.org X-Gm-Message-State: AOJu0YwG56dRutsyRaay81P05dAhppq8tkBatmjeCy8rutktb+QTqfAM Hpm3czT6M0W+AsmOcE3Q8obN0rHou4FKVzCZ5u4IeP2eB6a8WOQwfRG/0KWtieBR6M6yYEv3Pj5 +5LDZPQ== 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> 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 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 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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) =20 /* 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 @@ =20 #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, unsigne= d int flags); =20 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(lo= ng 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; =20 - regs =3D get_dwarf_regstr(regn, machine); + regs =3D 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 p= robe_finder *pf) dwarf_diename(vr_die)); =20 ret =3D 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 =3D=3D -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 *d= bg, if (gelf_getehdr(elf, &ehdr) =3D=3D NULL) return -EINVAL; =20 - pf->machine =3D ehdr.e_machine; + pf->e_machine =3D ehdr.e_machine; + pf->e_flags =3D ehdr.e_flags; =20 do { GElf_Shdr shdr; @@ -1171,7 +1172,7 @@ static int copy_variables_cb(Dwarf_Die *die_mem, void= *data) (tag =3D=3D DW_TAG_variable && vf->vars)) { if (convert_variable_location(die_mem, vf->pf->addr, vf->pf->fb_ops, &pf->sp_die, - pf->machine, NULL) =3D=3D 0) { + pf, /*tvar=3D*/NULL) =3D=3D 0) { vf->args[vf->nargs].var =3D (char *)dwarf_diename(die_mem); if (vf->args[vf->nargs].var =3D=3D NULL) { vf->ret =3D -ENOMEM; @@ -1403,7 +1404,7 @@ static int collect_variables_cb(Dwarf_Die *die_mem, v= oid *data) tag =3D=3D DW_TAG_variable) { ret =3D convert_variable_location(die_mem, af->pf.addr, af->pf.fb_ops, &af->pf.sp_die, - af->pf.machine, NULL); + &af->pf, /*tvar=3D*/NULL); if (ret =3D=3D 0 || ret =3D=3D -ERANGE) { int ret2; bool externs =3D !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 */ --=20 2.47.0.rc0.187.ge670bccf7e-goog