- n = insn->size;
- split = info->cap_insn_split;
-
- /* Dump the first SPLIT bytes of the instruction. */
- cap_dump_insn_units(info, insn, 0, MIN(n, split));
-
- /* Add padding up to SPLIT so that mnemonics line up. */
- if (n < split) {
- int width = (split - n) / info->cap_insn_unit;
- width *= (2 * info->cap_insn_unit + 1);
- print(info->stream, "%*s", width, "");
- }
-
- /* Print the actual instruction. */
- print(info->stream, " %-8s %s\n", insn->mnemonic, insn->op_str);
-
- /* Dump any remaining part of the insn on subsequent lines. */
- for (i = split; i < n; i += split) {
- print(info->stream, "0x%08" PRIx64 ": ", insn->address + i);
- cap_dump_insn_units(info, insn, i, MIN(n, i + split));
- print(info->stream, "\n");
- }
-}
-
-/* Disassemble SIZE bytes at PC for the target. */
-static bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size)
-{
- uint8_t cap_buf[1024];
- csh handle;
- cs_insn *insn;
- size_t csize = 0;
-
- if (cap_disas_start(info, &handle) != CS_ERR_OK) {
- return false;
- }
- insn = cap_insn;
-
- while (1) {
- size_t tsize = MIN(sizeof(cap_buf) - csize, size);
- const uint8_t *cbuf = cap_buf;
-
- target_read_memory(pc + csize, cap_buf + csize, tsize, info);
- csize += tsize;
- size -= tsize;
-
- while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) {
- cap_dump_insn(info, insn);
- }
-
- /* If the target memory is not consumed, go back for more... */
- if (size != 0) {
- /* ... taking care to move any remaining fractional insn
- to the beginning of the buffer. */
- if (csize != 0) {
- memmove(cap_buf, cbuf, csize);
- }
- continue;
- }
-
- /* Since the target memory is consumed, we should not have
- a remaining fractional insn. */
- if (csize != 0) {
- (*info->fprintf_func)(info->stream,
- "Disassembler disagrees with translator "
- "over instruction decoding\n"
- "Please report this to qemu-devel@nongnu.org\n");
- }
- break;
- }
-
- cs_close(&handle);
- return true;
-}
-
-/* Disassemble SIZE bytes at CODE for the host. */
-static bool cap_disas_host(disassemble_info *info, void *code, size_t size)
-{
- csh handle;
- const uint8_t *cbuf;
- cs_insn *insn;
- uint64_t pc;
-
- if (cap_disas_start(info, &handle) != CS_ERR_OK) {
- return false;
- }
- insn = cap_insn;
-
- cbuf = code;
- pc = (uintptr_t)code;