aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <[email protected]>2012-05-07 21:54:16 +0000
committerArnaldo Carvalho de Melo <[email protected]>2012-05-07 21:54:16 +0000
commit5417072bf6b17eaa31f21f12906f381f148b5200 (patch)
treeee57c5bccfc88ac660369edea9383a8773e1db1b /tools/perf/util/annotate.c
parentperf annotate browser: Don't change the asm line color when toggling source (diff)
downloadkernel-5417072bf6b17eaa31f21f12906f381f148b5200.tar.gz
kernel-5417072bf6b17eaa31f21f12906f381f148b5200.zip
perf annotate browser: Do raw printing in 'o'ffset in a single place
Instead of doing the same in all ins scnprintf methods. Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5eb34123f55b..0905db4390c1 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -18,6 +18,21 @@
const char *disassembler_style;
+static int ins__raw_scnprintf(struct ins *ins, char *bf, size_t size,
+ struct ins_operands *ops)
+{
+ return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);
+}
+
+int ins__scnprintf(struct ins *ins, char *bf, size_t size,
+ struct ins_operands *ops)
+{
+ if (ins->ops->scnprintf)
+ return ins->ops->scnprintf(ins, bf, size, ops);
+
+ return ins__raw_scnprintf(ins, bf, size, ops);
+}
+
static int call__parse(struct ins_operands *ops)
{
char *endptr, *tok, *name;
@@ -50,11 +65,8 @@ indirect_call:
}
static int call__scnprintf(struct ins *ins, char *bf, size_t size,
- struct ins_operands *ops, bool addrs)
+ struct ins_operands *ops)
{
- if (addrs)
- return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);
-
if (ops->target.name)
return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->target.name);
@@ -86,11 +98,8 @@ static int jump__parse(struct ins_operands *ops)
}
static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
- struct ins_operands *ops, bool addrs)
+ struct ins_operands *ops)
{
- if (addrs)
- return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);
-
return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset);
}
@@ -296,6 +305,14 @@ void disasm_line__free(struct disasm_line *dl)
free(dl);
}
+int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw)
+{
+ if (raw || !dl->ins)
+ return scnprintf(bf, size, "%-6.6s %s", dl->name, dl->ops.raw);
+
+ return ins__scnprintf(dl->ins, bf, size, &dl->ops);
+}
+
static void disasm__add(struct list_head *head, struct disasm_line *line)
{
list_add_tail(&line->node, head);