if (change_color)
ui_browser__set_color(self, color);
if (dl->ins && dl->ins->ops->scnprintf) {
- dl->ins->ops->scnprintf(dl->ins, bf, sizeof(bf),
- !ab->use_offset ? dl->operands : NULL,
- dl->target);
+ dl->ins->ops->scnprintf(dl->ins, bf, sizeof(bf), &dl->ops,
+ !ab->use_offset);
slsmg_write_nstring(" ", 2);
printed += 2;
} else
- scnprintf(bf, sizeof(bf), " %-6.6s %s", dl->name, dl->operands);
+ scnprintf(bf, sizeof(bf), " %-6.6s %s", dl->name, dl->ops.raw);
slsmg_write_nstring(bf, width - 10 - printed);
}
if (!ins__is_call(dl->ins))
return false;
- ip = ms->map->map_ip(ms->map, dl->target);
+ ip = ms->map->map_ip(ms->map, dl->ops.target);
target = map__find_symbol(ms->map, ip, NULL);
if (target == NULL) {
ui_helpline__puts("The called function was not found.");
if (!ins__is_jump(dl->ins))
return false;
- dl = annotate_browser__find_offset(browser, dl->target, &idx);
+ dl = annotate_browser__find_offset(browser, dl->ops.target, &idx);
if (dl == NULL) {
ui_helpline__puts("Invallid jump offset");
return true;
if (!dl || !dl->ins || !ins__is_jump(dl->ins))
continue;
- if (dl->target >= size) {
+ if (dl->ops.target >= size) {
ui__error("jump to after symbol!\n"
"size: %zx, jump target: %" PRIx64,
- size, dl->target);
+ size, dl->ops.target);
continue;
}
- dlt = browser->offsets[dl->target];
+ dlt = browser->offsets[dl->ops.target];
bdlt = disasm_line__browser(dlt);
bdlt->jump_target = true;
}
const char *disassembler_style;
-static int call_ops__parse_target(const char *operands, u64 *target)
+static int call__parse(struct ins_operands *ops)
{
- *target = strtoull(operands, NULL, 16);
+ ops->target = strtoull(ops->raw, NULL, 16);
return 0;
}
static struct ins_ops call_ops = {
- .parse_target = call_ops__parse_target,
+ .parse = call__parse,
};
bool ins__is_call(const struct ins *ins)
return ins->ops == &call_ops;
}
-static int jump_ops__parse_target(const char *operands, u64 *target)
+static int jump__parse(struct ins_operands *ops)
{
- const char *s = strchr(operands, '+');
+ const char *s = strchr(ops->raw, '+');
if (s++ == NULL)
return -1;
- *target = strtoll(s, NULL, 16);
+ ops->target = strtoll(s, NULL, 16);
return 0;
}
-static int jump_ops__scnprintf(struct ins *ins, char *bf, size_t size,
- const char *operands, u64 target)
+static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
+ struct ins_operands *ops, bool addrs)
{
- if (operands)
- return scnprintf(bf, size, "%-6.6s %s", ins->name, operands);
+ if (addrs)
+ return scnprintf(bf, size, "%-6.6s %s", ins->name, ops->raw);
- return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, target);
+ return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target);
}
static struct ins_ops jump_ops = {
- .parse_target = jump_ops__parse_target,
- .scnprintf = jump_ops__scnprintf,
+ .parse = jump__parse,
+ .scnprintf = jump__scnprintf,
};
bool ins__is_jump(const struct ins *ins)
if (!dl->ins->ops)
return;
- if (dl->ins->ops->parse_target)
- dl->ins->ops->parse_target(dl->operands, &dl->target);
+ if (dl->ins->ops->parse)
+ dl->ins->ops->parse(&dl->ops);
}
static struct disasm_line *disasm_line__new(s64 offset, char *line, size_t privsize)
if (name[0] == '\0')
goto out_delete;
- dl->operands = name + 1;
+ dl->ops.raw = name + 1;
- while (dl->operands[0] != '\0' &&
- !isspace(dl->operands[0]))
- ++dl->operands;
+ while (dl->ops.raw[0] != '\0' &&
+ !isspace(dl->ops.raw[0]))
+ ++dl->ops.raw;
- tmp = dl->operands[0];
- dl->operands[0] = '\0';
+ tmp = dl->ops.raw[0];
+ dl->ops.raw[0] = '\0';
dl->name = strdup(name);
if (dl->name == NULL)
goto out_free_line;
- dl->operands[0] = tmp;
+ dl->ops.raw[0] = tmp;
- if (dl->operands[0] != '\0') {
- dl->operands++;
- while (isspace(dl->operands[0]))
- ++dl->operands;
+ if (dl->ops.raw[0] != '\0') {
+ dl->ops.raw++;
+ while (isspace(dl->ops.raw[0]))
+ ++dl->ops.raw;
}
disasm_line__init_ins(dl);
printed = fprintf(fp, "%#" PRIx64 " %s", dl->offset, dl->name);
- if (dl->operands[0] != '\0') {
+ if (dl->ops.raw[0] != '\0') {
printed += fprintf(fp, "%.*s %s\n", 6 - (int)printed, " ",
- dl->operands);
+ dl->ops.raw);
}
return printed + fprintf(fp, "\n");