mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
perf script: Move map__fprintf_srccode() to near its only user
No need to have it elsewhere. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-8cw846pudpxo0xdkvi9qnvrh@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
2ea352d596
commit
540a63ea30
3 changed files with 42 additions and 50 deletions
|
@ -932,6 +932,48 @@ static int grab_bb(u8 *buffer, u64 start, u64 end,
|
|||
return len;
|
||||
}
|
||||
|
||||
static int map__fprintf_srccode(struct map *map, u64 addr, FILE *fp, struct srccode_state *state)
|
||||
{
|
||||
char *srcfile;
|
||||
int ret = 0;
|
||||
unsigned line;
|
||||
int len;
|
||||
char *srccode;
|
||||
|
||||
if (!map || !map->dso)
|
||||
return 0;
|
||||
srcfile = get_srcline_split(map->dso,
|
||||
map__rip_2objdump(map, addr),
|
||||
&line);
|
||||
if (!srcfile)
|
||||
return 0;
|
||||
|
||||
/* Avoid redundant printing */
|
||||
if (state &&
|
||||
state->srcfile &&
|
||||
!strcmp(state->srcfile, srcfile) &&
|
||||
state->line == line) {
|
||||
free(srcfile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
srccode = find_sourceline(srcfile, line, &len);
|
||||
if (!srccode)
|
||||
goto out_free_line;
|
||||
|
||||
ret = fprintf(fp, "|%-8d %.*s", line, len, srccode);
|
||||
|
||||
if (state) {
|
||||
state->srcfile = srcfile;
|
||||
state->line = line;
|
||||
}
|
||||
return ret;
|
||||
|
||||
out_free_line:
|
||||
free(srcfile);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int print_srccode(struct thread *thread, u8 cpumode, uint64_t addr)
|
||||
{
|
||||
struct addr_location al;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue