Skip to content

Commit a784847

Browse files
captain5050namhyung
authored andcommitted
perf dwarf-regs: Pass ELF flags to get_dwarf_regstr
Pass a flags value as architectures like csky need the flags to determine the ABI variant. Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Ian Rogers <[email protected]> Cc: Anup Patel <[email protected]> Cc: Yang Jihong <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: David S. Miller <[email protected]> Cc: Albert Ou <[email protected]> Cc: Shenlin Liang <[email protected]> Cc: Nick Terrell <[email protected]> Cc: Guilherme Amadio <[email protected]> Cc: Steinar H. Gunderson <[email protected]> Cc: Changbin Du <[email protected]> Cc: Alexander Lobakin <[email protected]> Cc: Przemek Kitszel <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Guo Ren <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Will Deacon <[email protected]> Cc: James Clark <[email protected]> Cc: Mike Leach <[email protected]> Cc: Chen Pei <[email protected]> Cc: Leo Yan <[email protected]> Cc: Oliver Upton <[email protected]> Cc: Aditya Gupta <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Bibo Mao <[email protected]> Cc: John Garry <[email protected]> Cc: Atish Patra <[email protected]> Cc: Dima Kogan <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Dr. David Alan Gilbert <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent 9fc4489 commit a784847

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

tools/perf/util/dwarf-regs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
#define __get_dwarf_regstr(tbl, n) (((n) < ARRAY_SIZE(tbl)) ? (tbl)[(n)] : NULL)
3030

3131
/* Return architecture dependent register string (for kprobe-tracer) */
32-
const char *get_dwarf_regstr(unsigned int n, unsigned int machine)
32+
const char *get_dwarf_regstr(unsigned int n, unsigned int machine,
33+
unsigned int flags __maybe_unused)
3334
{
3435
switch (machine) {
3536
case EM_NONE: /* Generic arch - use host arch */

tools/perf/util/include/dwarf-regs.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@
9090

9191
#ifdef HAVE_LIBDW_SUPPORT
9292
const char *get_arch_regstr(unsigned int n);
93-
/*
94-
* get_dwarf_regstr - Returns ftrace register string from DWARF regnum
95-
* n: DWARF register number
96-
* machine: ELF machine signature (EM_*)
93+
/**
94+
* get_dwarf_regstr() - Returns ftrace register string from DWARF regnum.
95+
* @n: DWARF register number.
96+
* @machine: ELF machine signature (EM_*).
97+
* @flags: ELF flags for things like ABI differences.
9798
*/
98-
const char *get_dwarf_regstr(unsigned int n, unsigned int machine);
99+
const char *get_dwarf_regstr(unsigned int n, unsigned int machine, unsigned int flags);
99100

100101
int get_arch_regnum(const char *name);
101102
/*

tools/perf/util/probe-finder.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static struct probe_trace_arg_ref *alloc_trace_arg_ref(long offs)
5656
*/
5757
static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr,
5858
Dwarf_Op *fb_ops, Dwarf_Die *sp_die,
59-
unsigned int machine,
59+
const struct probe_finder *pf,
6060
struct probe_trace_arg *tvar)
6161
{
6262
Dwarf_Attribute attr;
@@ -166,7 +166,7 @@ static int convert_variable_location(Dwarf_Die *vr_die, Dwarf_Addr addr,
166166
if (!tvar)
167167
return ret2;
168168

169-
regs = get_dwarf_regstr(regn, machine);
169+
regs = get_dwarf_regstr(regn, pf->e_machine, pf->e_flags);
170170
if (!regs) {
171171
/* This should be a bug in DWARF or this tool */
172172
pr_warning("Mapping for the register number %u "
@@ -451,7 +451,7 @@ static int convert_variable(Dwarf_Die *vr_die, struct probe_finder *pf)
451451
dwarf_diename(vr_die));
452452

453453
ret = convert_variable_location(vr_die, pf->addr, pf->fb_ops,
454-
&pf->sp_die, pf->machine, pf->tvar);
454+
&pf->sp_die, pf, pf->tvar);
455455
if (ret == -ENOENT && pf->skip_empty_arg)
456456
/* This can be found in other place. skip it */
457457
return 0;
@@ -1134,7 +1134,8 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
11341134
if (gelf_getehdr(elf, &ehdr) == NULL)
11351135
return -EINVAL;
11361136

1137-
pf->machine = ehdr.e_machine;
1137+
pf->e_machine = ehdr.e_machine;
1138+
pf->e_flags = ehdr.e_flags;
11381139

11391140
do {
11401141
GElf_Shdr shdr;
@@ -1171,7 +1172,7 @@ static int copy_variables_cb(Dwarf_Die *die_mem, void *data)
11711172
(tag == DW_TAG_variable && vf->vars)) {
11721173
if (convert_variable_location(die_mem, vf->pf->addr,
11731174
vf->pf->fb_ops, &pf->sp_die,
1174-
pf->machine, NULL) == 0) {
1175+
pf, /*tvar=*/NULL) == 0) {
11751176
vf->args[vf->nargs].var = (char *)dwarf_diename(die_mem);
11761177
if (vf->args[vf->nargs].var == NULL) {
11771178
vf->ret = -ENOMEM;
@@ -1402,7 +1403,7 @@ static int collect_variables_cb(Dwarf_Die *die_mem, void *data)
14021403
tag == DW_TAG_variable) {
14031404
ret = convert_variable_location(die_mem, af->pf.addr,
14041405
af->pf.fb_ops, &af->pf.sp_die,
1405-
af->pf.machine, NULL);
1406+
&af->pf, /*tvar=*/NULL);
14061407
if (ret == 0 || ret == -ERANGE) {
14071408
int ret2;
14081409
bool externs = !af->child;

tools/perf/util/probe-finder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ struct probe_finder {
6868
/* Call Frame Information from .debug_frame. Not owned. */
6969
Dwarf_CFI *cfi_dbg;
7070
Dwarf_Op *fb_ops; /* Frame base attribute */
71-
unsigned int machine; /* Target machine arch */
71+
unsigned int e_machine; /* ELF target machine arch */
72+
unsigned int e_flags; /* ELF target machine flags */
7273
struct perf_probe_arg *pvar; /* Current target variable */
7374
struct probe_trace_arg *tvar; /* Current result variable */
7475
bool skip_empty_arg; /* Skip non-exist args */

0 commit comments

Comments
 (0)