Skip to content

Commit

Permalink
perf: Fix building warning on ARM 32
Browse files Browse the repository at this point in the history
Commit 85c116a ("perf callchain: Make get_srcline fall back to sym+offset")
introduces asprintf() call and matches '%ld' to a u64 argument, which is
incorrect on ARM:

   CC       /home/wn/util/srcline.o
 util/srcline.c: In function 'get_srcline':
 util/srcline.c:297:6: error: format '%ld' expects argument of type 'long int', but argument 4 has type 'u64' [-Werror=format]
 cc1: all warnings being treated as errors
 make[1]: *** [/home/wn/util/srcline.o] Error 1

In addition, all users of get_srcline() use u64 addr, and libbfd
also use 64 bit bfd_vma as address. This patch also fix
prototype of get_srcline() and addr2line() to use u64 addr
instead of unsigned long.

Signed-off-by: Wang Nan <[email protected]>
Acked-by: Namhyung Kim <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
WangNan0 authored and Ingo Molnar committed Dec 19, 2014
1 parent 6aaba7c commit ac931f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions tools/perf/util/srcline.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

struct a2l_data {
const char *input;
unsigned long addr;
u64 addr;

bool found;
const char *filename;
Expand Down Expand Up @@ -147,7 +147,7 @@ static void addr2line_cleanup(struct a2l_data *a2l)
free(a2l);
}

static int addr2line(const char *dso_name, unsigned long addr,
static int addr2line(const char *dso_name, u64 addr,
char **file, unsigned int *line, struct dso *dso)
{
int ret = 0;
Expand Down Expand Up @@ -193,7 +193,7 @@ void dso__free_a2l(struct dso *dso)

#else /* HAVE_LIBBFD_SUPPORT */

static int addr2line(const char *dso_name, unsigned long addr,
static int addr2line(const char *dso_name, u64 addr,
char **file, unsigned int *line_nr,
struct dso *dso __maybe_unused)
{
Expand Down Expand Up @@ -252,7 +252,7 @@ void dso__free_a2l(struct dso *dso __maybe_unused)
*/
#define A2L_FAIL_LIMIT 123

char *get_srcline(struct dso *dso, unsigned long addr, struct symbol *sym,
char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
bool show_sym)
{
char *file = NULL;
Expand Down Expand Up @@ -293,10 +293,10 @@ char *get_srcline(struct dso *dso, unsigned long addr, struct symbol *sym,
dso__free_a2l(dso);
}
if (sym) {
if (asprintf(&srcline, "%s+%ld", show_sym ? sym->name : "",
if (asprintf(&srcline, "%s+%" PRIu64, show_sym ? sym->name : "",
addr - sym->start) < 0)
return SRCLINE_UNKNOWN;
} else if (asprintf(&srcline, "%s[%lx]", dso->short_name, addr) < 0)
} else if (asprintf(&srcline, "%s[%" PRIx64 "]", dso->short_name, addr) < 0)
return SRCLINE_UNKNOWN;
return srcline;
}
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static inline int path__join3(char *bf, size_t size,
struct dso;
struct symbol;

char *get_srcline(struct dso *dso, unsigned long addr, struct symbol *sym,
char *get_srcline(struct dso *dso, u64 addr, struct symbol *sym,
bool show_sym);
void free_srcline(char *srcline);

Expand Down

0 comments on commit ac931f8

Please sign in to comment.