[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7cgkV3CZ_2xAp+v62hpfutAB+RpsnvGa2u09P4C0Fm5ULw@mail.gmail.com>
Date: Tue, 20 Jun 2023 21:54:04 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: WANG Rui <wangrui@...ngson.cn>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Huacai Chen <chenhuacai@...ngson.cn>,
loongarch@...ts.linux.dev, Tiezhu Yang <yangtiezhu@...ngson.cn>,
WANG Xuerui <kernel@...0n.name>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, loongson-kernel@...ts.loongnix.cn
Subject: Re: [PATCH] perf annotate: Fix instruction association and parsing
for LoongArch
On Tue, Jun 20, 2023 at 9:37 PM WANG Rui <wangrui@...ngson.cn> wrote:
>
> Hello Namhyung,
>
> On Wed, Jun 21, 2023 at 2:42 AM Namhyung Kim <namhyung@...nel.org> wrote:
> > > +static int loongarch_call__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms)
> > > +{
> > > + char *c, *endptr, *tok, *name;
> > > + struct map *map = ms->map;
> > > + struct addr_map_symbol target = {
> > > + .ms = { .map = map, },
> >
> > Looking here...
> >
> > > + };
> > > +
> > > + c = strchr(ops->raw, '#');
> > > + if (c++ == NULL)
> > > + return -1;
> > > +
> > > + ops->target.addr = strtoull(c, &endptr, 16);
> > > +
> > > + name = strchr(endptr, '<');
> > > + name++;
> > > +
> > > + if (arch->objdump.skip_functions_char &&
> > > + strchr(name, arch->objdump.skip_functions_char))
> > > + return -1;
> > > +
> > > + tok = strchr(name, '>');
> > > + if (tok == NULL)
> > > + return -1;
> > > +
> > > + *tok = '\0';
> > > + ops->target.name = strdup(name);
> > > + *tok = '>';
> > > +
> > > + if (ops->target.name == NULL)
> > > + return -1;
> > > +
> > > + target.addr = map__objdump_2mem(map, ops->target.addr);
> > > +
> > > + if (maps__find_ams(ms->maps, &target) == 0 &&
> > > + map__rip_2objdump(target.ms.map, map__map_ip(target.ms.map, target.addr)) == ops->target.addr)
> >
> > So the target.ms.map is 'map', right? Then we can reduce the line.
>
> toos/perf/util/maps.c:
>
> > int maps__find_ams(struct maps *maps, struct addr_map_symbol *ams)
> > {
> > if (ams->addr < map__start(ams->ms.map) || ams->addr >= map__end(ams->ms.map)) {
> > if (maps == NULL)
> > return -1;
> > ams->ms.map = maps__find(maps, ams->addr);
>
> Is it possible that `target.ms.map` might be reassigned within the
> `maps_find_ams` function in this case?
Ah, ok. Missed that part. It can change if the target is from a
different library.
Acked-by: Namhyung Kim <namhyung@...nel.org>
Thanks,
Namhyung
>
> > if (ams->ms.map == NULL)
> > return -1;
> > }
> >
> > ams->al_addr = map__map_ip(ams->ms.map, ams->addr);
> > ams->ms.sym = map__find_symbol(ams->ms.map, ams->al_addr);
> >
> > return ams->ms.sym ? 0 : -1;
> > }
>
Powered by blists - more mailing lists