summaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/annotate.c46
-rw-r--r--tools/perf/util/annotate.h4
2 files changed, 41 insertions, 9 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 5eb34123f55..6b4146b40a2 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);
}
@@ -104,6 +113,16 @@ bool ins__is_jump(const struct ins *ins)
return ins->ops == &jump_ops;
}
+static int nop__scnprintf(struct ins *ins __used, char *bf, size_t size,
+ struct ins_operands *ops __used)
+{
+ return scnprintf(bf, size, "%-6.6s", "nop");
+}
+
+static struct ins_ops nop_ops = {
+ .scnprintf = nop__scnprintf,
+};
+
/*
* Must be sorted by name!
*/
@@ -145,6 +164,9 @@ static struct ins instructions[] = {
{ .name = "jrcxz", .ops = &jump_ops, },
{ .name = "js", .ops = &jump_ops, },
{ .name = "jz", .ops = &jump_ops, },
+ { .name = "nop", .ops = &nop_ops, },
+ { .name = "nopl", .ops = &nop_ops, },
+ { .name = "nopw", .ops = &nop_ops, },
};
static int ins__cmp(const void *name, const void *insp)
@@ -296,6 +318,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);
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 13a21f10dab..bb0a9f27165 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -22,7 +22,7 @@ struct ins_operands {
struct ins_ops {
int (*parse)(struct ins_operands *ops);
int (*scnprintf)(struct ins *ins, char *bf, size_t size,
- struct ins_operands *ops, bool addrs);
+ struct ins_operands *ops);
};
struct ins {
@@ -32,6 +32,7 @@ struct ins {
bool ins__is_jump(const struct ins *ins);
bool ins__is_call(const struct ins *ins);
+int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops);
struct disasm_line {
struct list_head node;
@@ -49,6 +50,7 @@ static inline bool disasm_line__has_offset(const struct disasm_line *dl)
void disasm_line__free(struct disasm_line *dl);
struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disasm_line *pos);
+int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw);
size_t disasm__fprintf(struct list_head *head, FILE *fp);
struct sym_hist {