mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
perf annotate: Find 'call' instruction target symbol at parsing time
So that we do it just once, not everytime we press enter or -> on a 'call' instruction line. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-uysyojl1e6nm94amzzzs08tf@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
b09c2364a4
commit
696703af37
3 changed files with 27 additions and 29 deletions
|
@ -568,35 +568,28 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
|
||||||
struct map_symbol *ms = browser->b.priv;
|
struct map_symbol *ms = browser->b.priv;
|
||||||
struct disasm_line *dl = disasm_line(browser->selection);
|
struct disasm_line *dl = disasm_line(browser->selection);
|
||||||
struct annotation *notes;
|
struct annotation *notes;
|
||||||
struct addr_map_symbol target = {
|
|
||||||
.map = ms->map,
|
|
||||||
.addr = map__objdump_2mem(ms->map, dl->ops.target.addr),
|
|
||||||
};
|
|
||||||
char title[SYM_TITLE_MAX_SIZE];
|
char title[SYM_TITLE_MAX_SIZE];
|
||||||
|
|
||||||
if (!ins__is_call(&dl->ins))
|
if (!ins__is_call(&dl->ins))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (map_groups__find_ams(&target) ||
|
if (!dl->ops.target.sym) {
|
||||||
map__rip_2objdump(target.map, target.map->map_ip(target.map,
|
|
||||||
target.addr)) !=
|
|
||||||
dl->ops.target.addr) {
|
|
||||||
ui_helpline__puts("The called function was not found.");
|
ui_helpline__puts("The called function was not found.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
notes = symbol__annotation(target.sym);
|
notes = symbol__annotation(dl->ops.target.sym);
|
||||||
pthread_mutex_lock(¬es->lock);
|
pthread_mutex_lock(¬es->lock);
|
||||||
|
|
||||||
if (notes->src == NULL && symbol__alloc_hist(target.sym) < 0) {
|
if (notes->src == NULL && symbol__alloc_hist(dl->ops.target.sym) < 0) {
|
||||||
pthread_mutex_unlock(¬es->lock);
|
pthread_mutex_unlock(¬es->lock);
|
||||||
ui__warning("Not enough memory for annotating '%s' symbol!\n",
|
ui__warning("Not enough memory for annotating '%s' symbol!\n",
|
||||||
target.sym->name);
|
dl->ops.target.sym->name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(¬es->lock);
|
pthread_mutex_unlock(¬es->lock);
|
||||||
symbol__tui_annotate(target.sym, target.map, evsel, hbt);
|
symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt);
|
||||||
sym_title(ms->sym, ms->map, title, sizeof(title));
|
sym_title(ms->sym, ms->map, title, sizeof(title));
|
||||||
ui_browser__show_title(&browser->b, title);
|
ui_browser__show_title(&browser->b, title);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -187,6 +187,9 @@ bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2)
|
||||||
static int call__parse(struct arch *arch, struct ins_operands *ops, struct map *map)
|
static int call__parse(struct arch *arch, struct ins_operands *ops, struct map *map)
|
||||||
{
|
{
|
||||||
char *endptr, *tok, *name;
|
char *endptr, *tok, *name;
|
||||||
|
struct addr_map_symbol target = {
|
||||||
|
.map = map,
|
||||||
|
};
|
||||||
|
|
||||||
ops->target.addr = strtoull(ops->raw, &endptr, 16);
|
ops->target.addr = strtoull(ops->raw, &endptr, 16);
|
||||||
|
|
||||||
|
@ -208,28 +211,29 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map *
|
||||||
ops->target.name = strdup(name);
|
ops->target.name = strdup(name);
|
||||||
*tok = '>';
|
*tok = '>';
|
||||||
|
|
||||||
return ops->target.name == NULL ? -1 : 0;
|
if (ops->target.name == NULL)
|
||||||
|
return -1;
|
||||||
|
find_target:
|
||||||
|
target.addr = map__objdump_2mem(map, ops->target.addr);
|
||||||
|
|
||||||
|
if (map_groups__find_ams(&target) == 0 &&
|
||||||
|
map__rip_2objdump(target.map, map->map_ip(target.map, target.addr)) == ops->target.addr)
|
||||||
|
ops->target.sym = target.sym;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
indirect_call:
|
indirect_call:
|
||||||
tok = strchr(endptr, '*');
|
tok = strchr(endptr, '*');
|
||||||
if (tok == NULL) {
|
if (tok != NULL)
|
||||||
struct symbol *sym = map__find_symbol(map, map->map_ip(map, ops->target.addr));
|
|
||||||
if (sym != NULL)
|
|
||||||
ops->target.name = strdup(sym->name);
|
|
||||||
else
|
|
||||||
ops->target.addr = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ops->target.addr = strtoull(tok + 1, NULL, 16);
|
ops->target.addr = strtoull(tok + 1, NULL, 16);
|
||||||
return 0;
|
goto find_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int call__scnprintf(struct ins *ins, char *bf, size_t size,
|
static int call__scnprintf(struct ins *ins, char *bf, size_t size,
|
||||||
struct ins_operands *ops)
|
struct ins_operands *ops)
|
||||||
{
|
{
|
||||||
if (ops->target.name)
|
if (ops->target.sym)
|
||||||
return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.name);
|
return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.sym->name);
|
||||||
|
|
||||||
if (ops->target.addr == 0)
|
if (ops->target.addr == 0)
|
||||||
return ins__raw_scnprintf(ins, bf, size, ops);
|
return ins__raw_scnprintf(ins, bf, size, ops);
|
||||||
|
@ -1283,8 +1287,8 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file,
|
||||||
dl->ops.target.offset_avail = true;
|
dl->ops.target.offset_avail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* kcore has no symbols, so add the call target name */
|
/* kcore has no symbols, so add the call target symbol */
|
||||||
if (dl->ins.ops && ins__is_call(&dl->ins) && !dl->ops.target.name) {
|
if (dl->ins.ops && ins__is_call(&dl->ins) && !dl->ops.target.sym) {
|
||||||
struct addr_map_symbol target = {
|
struct addr_map_symbol target = {
|
||||||
.map = map,
|
.map = map,
|
||||||
.addr = dl->ops.target.addr,
|
.addr = dl->ops.target.addr,
|
||||||
|
@ -1292,7 +1296,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file,
|
||||||
|
|
||||||
if (!map_groups__find_ams(&target) &&
|
if (!map_groups__find_ams(&target) &&
|
||||||
target.sym->start == target.al_addr)
|
target.sym->start == target.al_addr)
|
||||||
dl->ops.target.name = strdup(target.sym->name);
|
dl->ops.target.sym = target.sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
annotation_line__add(&dl->al, ¬es->src->source);
|
annotation_line__add(&dl->al, ¬es->src->source);
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct ins_operands {
|
||||||
struct {
|
struct {
|
||||||
char *raw;
|
char *raw;
|
||||||
char *name;
|
char *name;
|
||||||
|
struct symbol *sym;
|
||||||
u64 addr;
|
u64 addr;
|
||||||
s64 offset;
|
s64 offset;
|
||||||
bool offset_avail;
|
bool offset_avail;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue