summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 0b8573fd9b05..ac9ad2330f93 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
*
* Parts came from builtin-annotate.c, see those files for further
* copyright notes.
- *
- * Released under the GPL v2. (and only v2, not any later version)
*/
#include <errno.h>
@@ -36,6 +35,7 @@
#include <pthread.h>
#include <linux/bitops.h>
#include <linux/kernel.h>
+#include <linux/string.h>
#include <bpf/libbpf.h>
/* FIXME: For the HE_COLORSET */
@@ -50,7 +50,7 @@
#define DARROW_CHAR ((unsigned char)'.')
#define UARROW_CHAR ((unsigned char)'-')
-#include "sane_ctype.h"
+#include <linux/ctype.h>
struct annotation_options annotation__default_options = {
.use_offset = true,
@@ -145,6 +145,7 @@ static int arch__associate_ins_ops(struct arch* arch, const char *name, struct i
#include "arch/arc/annotate/instructions.c"
#include "arch/arm/annotate/instructions.c"
#include "arch/arm64/annotate/instructions.c"
+#include "arch/csky/annotate/instructions.c"
#include "arch/x86/annotate/instructions.c"
#include "arch/powerpc/annotate/instructions.c"
#include "arch/s390/annotate/instructions.c"
@@ -164,6 +165,10 @@ static struct arch architectures[] = {
.init = arm64__annotate_init,
},
{
+ .name = "csky",
+ .init = csky__annotate_init,
+ },
+ {
.name = "x86",
.init = x86__annotate_init,
.instructions = x86__instructions,
@@ -558,7 +563,7 @@ static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_sy
if (comment == NULL)
return 0;
- comment = ltrim(comment);
+ comment = skip_spaces(comment);
comment__symbol(ops->source.raw, comment + 1, &ops->source.addr, &ops->source.name);
comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name);
@@ -603,7 +608,7 @@ static int dec__parse(struct arch *arch __maybe_unused, struct ins_operands *ops
if (comment == NULL)
return 0;
- comment = ltrim(comment);
+ comment = skip_spaces(comment);
comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name);
return 0;
@@ -932,9 +937,8 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
if (sym == NULL)
return 0;
src = symbol__hists(sym, evsel->evlist->nr_entries);
- if (src == NULL)
- return -ENOMEM;
- return __symbol__inc_addr_samples(sym, map, src, evsel->idx, addr, sample);
+ return (src) ? __symbol__inc_addr_samples(sym, map, src, evsel->idx,
+ addr, sample) : 0;
}
static int symbol__account_cycles(u64 addr, u64 start,
@@ -1100,7 +1104,7 @@ static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, str
static int disasm_line__parse(char *line, const char **namep, char **rawp)
{
- char tmp, *name = ltrim(line);
+ char tmp, *name = skip_spaces(line);
if (name[0] == '\0')
return -1;
@@ -1115,16 +1119,14 @@ static int disasm_line__parse(char *line, const char **namep, char **rawp)
*namep = strdup(name);
if (*namep == NULL)
- goto out_free_name;
+ goto out;
(*rawp)[0] = tmp;
- *rawp = ltrim(*rawp);
+ *rawp = skip_spaces(*rawp);
return 0;
-out_free_name:
- free((void *)namep);
- *namep = NULL;
+out:
return -1;
}
@@ -1233,8 +1235,7 @@ void disasm_line__free(struct disasm_line *dl)
dl->ins.ops->free(&dl->ops);
else
ins__delete(&dl->ops);
- free((void *)dl->ins.name);
- dl->ins.name = NULL;
+ zfree(&dl->ins.name);
annotation_line__delete(&dl->al);
}
@@ -1497,7 +1498,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file,
return -1;
line_ip = -1;
- parsed_line = rtrim(line);
+ parsed_line = strim(line);
/* /filename:linenr ? Save line number and ignore. */
if (regexec(&file_lineno, parsed_line, 2, match, 0) == 0) {
@@ -1505,7 +1506,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file,
return 0;
}
- tmp = ltrim(parsed_line);
+ tmp = skip_spaces(parsed_line);
if (*tmp) {
/*
* Parse hexa addresses followed by ':'
@@ -1585,7 +1586,7 @@ static void delete_last_nop(struct symbol *sym)
return;
}
- list_del(&dl->al.node);
+ list_del_init(&dl->al.node);
disasm_line__free(dl);
}
}
@@ -2462,7 +2463,7 @@ void annotated_source__purge(struct annotated_source *as)
struct annotation_line *al, *n;
list_for_each_entry_safe(al, n, &as->source, node) {
- list_del(&al->node);
+ list_del_init(&al->node);
disasm_line__free(disasm_line(al));
}
}