[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 08/13] disas: add optional note support to cap_disas
From: |
Alex Bennée |
Subject: |
[PULL v2 08/13] disas: add optional note support to cap_disas |
Date: |
Fri, 15 May 2020 15:44:00 +0100 |
Include support for outputting a note at the top of a chunk of
disassembly to capstone as well.
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
diff --git a/disas.c b/disas.c
index 7e8692de301..45285d3f63f 100644
--- a/disas.c
+++ b/disas.c
@@ -260,7 +260,8 @@ static void cap_dump_insn_units(disassemble_info *info,
cs_insn *insn,
}
}
-static void cap_dump_insn(disassemble_info *info, cs_insn *insn)
+static void cap_dump_insn(disassemble_info *info, cs_insn *insn,
+ const char *note)
{
fprintf_function print = info->fprintf_func;
int i, n, split;
@@ -281,7 +282,11 @@ static void cap_dump_insn(disassemble_info *info, cs_insn
*insn)
}
/* Print the actual instruction. */
- print(info->stream, " %-8s %s\n", insn->mnemonic, insn->op_str);
+ print(info->stream, " %-8s %s", insn->mnemonic, insn->op_str);
+ if (note) {
+ print(info->stream, "\t\t%s", note);
+ }
+ print(info->stream, "\n");
/* Dump any remaining part of the insn on subsequent lines. */
for (i = split; i < n; i += split) {
@@ -313,7 +318,7 @@ static bool cap_disas_target(disassemble_info *info,
uint64_t pc, size_t size)
size -= tsize;
while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) {
- cap_dump_insn(info, insn);
+ cap_dump_insn(info, insn, NULL);
}
/* If the target memory is not consumed, go back for more... */
@@ -342,7 +347,8 @@ static bool cap_disas_target(disassemble_info *info,
uint64_t pc, size_t size)
}
/* Disassemble SIZE bytes at CODE for the host. */
-static bool cap_disas_host(disassemble_info *info, void *code, size_t size)
+static bool cap_disas_host(disassemble_info *info, void *code, size_t size,
+ const char *note)
{
csh handle;
const uint8_t *cbuf;
@@ -358,7 +364,8 @@ static bool cap_disas_host(disassemble_info *info, void
*code, size_t size)
pc = (uintptr_t)code;
while (cs_disasm_iter(handle, &cbuf, &size, &pc, insn)) {
- cap_dump_insn(info, insn);
+ cap_dump_insn(info, insn, note);
+ note = NULL;
}
if (size != 0) {
(*info->fprintf_func)(info->stream,
@@ -402,7 +409,7 @@ static bool cap_disas_monitor(disassemble_info *info,
uint64_t pc, int count)
csize += tsize;
if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) {
- cap_dump_insn(info, insn);
+ cap_dump_insn(info, insn, NULL);
if (--count <= 0) {
break;
}
@@ -416,7 +423,7 @@ static bool cap_disas_monitor(disassemble_info *info,
uint64_t pc, int count)
#endif /* !CONFIG_USER_ONLY */
#else
# define cap_disas_target(i, p, s) false
-# define cap_disas_host(i, p, s) false
+# define cap_disas_host(i, p, s, n) false
# define cap_disas_monitor(i, p, c) false
# define cap_disas_plugin(i, p, c) false
#endif /* CONFIG_CAPSTONE */
@@ -664,7 +671,7 @@ void disas(FILE *out, void *code, unsigned long size, const
char *note)
print_insn = print_insn_hppa;
#endif
- if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size)) {
+ if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size, note)) {
return;
}
--
2.20.1
- [PULL v2 00/13] testing, tcg and plugin updates, Alex Bennée, 2020/05/15
- [PULL v2 01/13] tests/guest-debug: catch hanging guests, Alex Bennée, 2020/05/15
- [PULL v2 02/13] travis.yml: Improve the --disable-tcg test on s390x, Alex Bennée, 2020/05/15
- [PULL v2 04/13] exec/cpu-all: Use bool for have_guest_base, Alex Bennée, 2020/05/15
- [PULL v2 05/13] accel/tcg: Relax va restrictions on 64-bit guests, Alex Bennée, 2020/05/15
- [PULL v2 09/13] translate-all: include guest address in out_asm output, Alex Bennée, 2020/05/15
- [PULL v2 03/13] linux-user: completely re-write init_guest_space, Alex Bennée, 2020/05/15
- [PULL v2 06/13] accel/tcg: don't disable exec_tb trace events, Alex Bennée, 2020/05/15
- [PULL v2 08/13] disas: add optional note support to cap_disas,
Alex Bennée <=
- [PULL v2 07/13] disas: include an optional note for the start of disassembly, Alex Bennée, 2020/05/15
- [PULL v2 11/13] qemu/plugin: Move !CONFIG_PLUGIN stubs altogether, Alex Bennée, 2020/05/15
- [PULL v2 10/13] qemu/plugin: Trivial code movement, Alex Bennée, 2020/05/15
- [PULL v2 13/13] MAINTAINERS: update the orphaned cpus-common.c file, Alex Bennée, 2020/05/15
- [PULL v2 12/13] qemu/qemu-plugin: Make qemu_plugin_hwaddr_is_io() hwaddr argument const, Alex Bennée, 2020/05/15
- Re: [PULL v2 00/13] testing, tcg and plugin updates, Peter Maydell, 2020/05/15