Lines Matching defs:ops

131 static int arch__associate_ins_ops(struct arch* arch, const char *name, struct ins_ops *ops)
144 ins->ops = ops;
215 static void ins__delete(struct ins_operands *ops)
217 if (ops == NULL)
219 zfree(&ops->source.raw);
220 zfree(&ops->source.name);
221 zfree(&ops->target.raw);
222 zfree(&ops->target.name);
226 struct ins_operands *ops, int max_ins_name)
228 return scnprintf(bf, size, "%-*s %s", max_ins_name, ins->name, ops->raw);
232 struct ins_operands *ops, int max_ins_name)
234 if (ins->ops->scnprintf)
235 return ins->ops->scnprintf(ins, bf, size, ops, max_ins_name);
237 return ins__raw_scnprintf(ins, bf, size, ops, max_ins_name);
248 static int call__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms)
256 ops->target.addr = strtoull(ops->raw, &endptr, 16);
273 ops->target.name = strdup(name);
276 if (ops->target.name == NULL)
279 target.addr = map__objdump_2mem(map, ops->target.addr);
282 map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
283 ops->target.sym = target.ms.sym;
295 ops->target.addr = strtoull(endptr, NULL, 16);
301 struct ins_operands *ops, int max_ins_name)
303 if (ops->target.sym)
304 return scnprintf(bf, size, "%-*s %s", max_ins_name, ins->name, ops->target.sym->name);
306 if (ops->target.addr == 0)
307 return ins__raw_scnprintf(ins, bf, size, ops, max_ins_name);
309 if (ops->target.name)
310 return scnprintf(bf, size, "%-*s %s", max_ins_name, ins->name, ops->target.name);
312 return scnprintf(bf, size, "%-*s *%" PRIx64, max_ins_name, ins->name, ops->target.addr);
322 return ins->ops == &call_ops || ins->ops == &s390_call_ops;
332 static inline const char *validate_comma(const char *c, struct ins_operands *ops)
334 if (ops->raw_comment && c > ops->raw_comment)
337 if (ops->raw_func_start && c > ops->raw_func_start)
343 static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms)
350 const char *c = strchr(ops->raw, ',');
353 ops->raw_comment = strchr(ops->raw, arch->objdump.comment_char);
354 ops->raw_func_start = strchr(ops->raw, '<');
356 c = validate_comma(c, ops);
374 ops->target.addr = strtoull(c, NULL, 16);
375 if (!ops->target.addr) {
377 c = validate_comma(c, ops);
379 ops->target.addr = strtoull(c, NULL, 16);
382 ops->target.addr = strtoull(ops->raw, NULL, 16);
385 target.addr = map__objdump_2mem(map, ops->target.addr);
389 ops->target.outside = target.addr < start || target.addr > end;
410 map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr)
411 ops->target.sym = target.ms.sym;
413 if (!ops->target.outside) {
414 ops->target.offset = target.addr - start;
415 ops->target.offset_avail = true;
417 ops->target.offset_avail = false;
424 struct ins_operands *ops, int max_ins_name)
428 if (!ops->target.addr || ops->target.offset < 0)
429 return ins__raw_scnprintf(ins, bf, size, ops, max_ins_name);
431 if (ops->target.outside && ops->target.sym != NULL)
432 return scnprintf(bf, size, "%-*s %s", max_ins_name, ins->name, ops->target.sym->name);
434 c = strchr(ops->raw, ',');
435 c = validate_comma(c, ops);
440 c2 = validate_comma(c2, ops);
452 ins->name, c ? c - ops->raw : 0, ops->raw,
453 ops->target.offset);
463 return ins->ops == &jump_ops;
493 static int lock__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms)
495 ops->locked.ops = zalloc(sizeof(*ops->locked.ops));
496 if (ops->locked.ops == NULL)
499 if (disasm_line__parse(ops->raw, &ops->locked.ins.name, &ops->locked.ops->raw) < 0)
502 ops->locked.ins.ops = ins__find(arch, ops->locked.ins.name);
504 if (ops->locked.ins.ops == NULL)
507 if (ops->locked.ins.ops->parse &&
508 ops->locked.ins.ops->parse(arch, ops->locked.ops, ms) < 0)
514 zfree(&ops->locked.ops);
519 struct ins_operands *ops, int max_ins_name)
523 if (ops->locked.ins.ops == NULL)
524 return ins__raw_scnprintf(ins, bf, size, ops, max_ins_name);
527 return printed + ins__scnprintf(&ops->locked.ins, bf + printed,
528 size - printed, ops->locked.ops, max_ins_name);
531 static void lock__delete(struct ins_operands *ops)
533 struct ins *ins = &ops->locked.ins;
535 if (ins->ops && ins->ops->free)
536 ins->ops->free(ops->locked.ops);
538 ins__delete(ops->locked.ops);
540 zfree(&ops->locked.ops);
541 zfree(&ops->target.raw);
542 zfree(&ops->target.name);
551 static int mov__parse(struct arch *arch, struct ins_operands *ops, struct map_symbol *ms __maybe_unused)
553 char *s = strchr(ops->raw, ','), *target, *comment, prev;
559 ops->source.raw = strdup(ops->raw);
562 if (ops->source.raw == NULL)
579 ops->target.raw = strdup(target);
582 if (ops->target.raw == NULL)
589 comment__symbol(ops->source.raw, comment + 1, &ops->source.addr, &ops->source.name);
590 comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name);
595 zfree(&ops->source.raw);
600 struct ins_operands *ops, int max_ins_name)
603 ops->source.name ?: ops->source.raw,
604 ops->target.name ?: ops->target.raw);
612 static int dec__parse(struct arch *arch __maybe_unused, struct ins_operands *ops, struct map_symbol *ms __maybe_unused)
616 target = s = ops->raw;
623 ops->target.raw = strdup(target);
626 if (ops->target.raw == NULL)
634 comment__symbol(ops->target.raw, comment + 1, &ops->target.addr, &ops->target.name);
640 struct ins_operands *ops, int max_ins_name)
643 ops->target.name ?: ops->target.raw);
652 struct ins_operands *ops __maybe_unused, int max_ins_name)
667 return ins->ops == &ret_ops;
672 return ins->ops == &lock_ops;
708 return ins ? ins->ops : NULL;
713 struct ins_ops *ops = __ins__find(arch, name);
715 if (!ops && arch->associate_instruction_ops)
716 ops = arch->associate_instruction_ops(arch, name);
718 return ops;
1123 dl->ins.ops = ins__find(arch, dl->ins.name);
1125 if (!dl->ins.ops)
1128 if (dl->ins.ops->parse && dl->ins.ops->parse(arch, &dl->ops, ms) < 0)
1129 dl->ins.ops = NULL;
1221 if (disasm_line__parse(dl->al.line, &dl->ins.name, &dl->ops.raw) < 0)
1238 if (dl->ins.ops && dl->ins.ops->free)
1239 dl->ins.ops->free(&dl->ops);
1241 ins__delete(&dl->ops);
1249 if (raw || !dl->ins.ops)
1250 return scnprintf(bf, size, "%-*s %s", max_ins_name, dl->ins.name, dl->ops.raw);
1252 return ins__scnprintf(&dl->ins, bf, size, &dl->ops, max_ins_name);
1481 * <offset> <name> <ops.raw>
1485 * The ops.raw part will be parsed further according to type of the instruction.
1529 dl->ops.target.offset = dl->ops.target.addr -
1531 dl->ops.target.offset_avail = true;
1535 if (dl->ins.ops && ins__is_call(&dl->ins) && !dl->ops.target.sym) {
1537 .addr = dl->ops.target.addr,
1543 dl->ops.target.sym = target.ms.sym;
1565 if (dl->ins.ops) {
1566 if (dl->ins.ops != &nop_ops)
2604 if (dl->ops.raw[0] != '\0') {
2606 dl->ops.raw);
2625 if (!dl || !dl->ins.ops || !ins__is_jump(&dl->ins) ||
2626 !disasm_line__has_local_offset(dl) || dl->ops.target.offset < 0 ||
2627 dl->ops.target.offset >= (s64)symbol__size(sym))
2650 al = notes->offsets[dl->ops.target.offset];
2866 if (dl->ins.ops && dl->ins.ops->scnprintf) {
2870 if (dl->ops.target.outside)
2872 fwd = dl->ops.target.offset > dl->al.offset;