qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

disas: include an optional note for the start of disassembly

This will become useful shortly for providing more information about
output assembly inline. While there fix up the indenting and code
formatting in disas().

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Message-Id: <20200513175134.19619-9-alex.bennee@linaro.org>

+17 -11
+2 -2
accel/tcg/translate-all.c
··· 1800 1800 size_t data_size = gen_code_size - code_size; 1801 1801 size_t i; 1802 1802 1803 - log_disas(tb->tc.ptr, code_size); 1803 + log_disas(tb->tc.ptr, code_size, NULL); 1804 1804 1805 1805 for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { 1806 1806 if (sizeof(tcg_target_ulong) == 8) { ··· 1814 1814 } 1815 1815 } 1816 1816 } else { 1817 - log_disas(tb->tc.ptr, gen_code_size); 1817 + log_disas(tb->tc.ptr, gen_code_size, NULL); 1818 1818 } 1819 1819 qemu_log("\n"); 1820 1820 qemu_log_flush();
+10 -4
disas.c
··· 586 586 } 587 587 588 588 /* Disassemble this for me please... (debugging). */ 589 - void disas(FILE *out, void *code, unsigned long size) 589 + void disas(FILE *out, void *code, unsigned long size, const char *note) 590 590 { 591 591 uintptr_t pc; 592 592 int count; ··· 674 674 for (pc = (uintptr_t)code; size > 0; pc += count, size -= count) { 675 675 fprintf(out, "0x%08" PRIxPTR ": ", pc); 676 676 count = print_insn(pc, &s.info); 677 - fprintf(out, "\n"); 678 - if (count < 0) 679 - break; 677 + if (note) { 678 + fprintf(out, "\t\t%s", note); 679 + note = NULL; 680 + } 681 + fprintf(out, "\n"); 682 + if (count < 0) { 683 + break; 684 + } 680 685 } 686 + 681 687 } 682 688 683 689 /* Look up symbol for debugging purpose. Returns "" if unknown. */
+1 -1
include/disas/disas.h
··· 7 7 #include "cpu.h" 8 8 9 9 /* Disassemble this for me please... (debugging). */ 10 - void disas(FILE *out, void *code, unsigned long size); 10 + void disas(FILE *out, void *code, unsigned long size, const char *note); 11 11 void target_disas(FILE *out, CPUState *cpu, target_ulong code, 12 12 target_ulong size); 13 13
+2 -2
include/exec/log.h
··· 56 56 rcu_read_unlock(); 57 57 } 58 58 59 - static inline void log_disas(void *code, unsigned long size) 59 + static inline void log_disas(void *code, unsigned long size, const char *note) 60 60 { 61 61 QemuLogFile *logfile; 62 62 rcu_read_lock(); 63 63 logfile = atomic_rcu_read(&qemu_logfile); 64 64 if (logfile) { 65 - disas(logfile->fd, code, size); 65 + disas(logfile->fd, code, size, note); 66 66 } 67 67 rcu_read_unlock(); 68 68 }
+2 -2
tcg/tcg.c
··· 1092 1092 size_t data_size = prologue_size - code_size; 1093 1093 size_t i; 1094 1094 1095 - log_disas(buf0, code_size); 1095 + log_disas(buf0, code_size, NULL); 1096 1096 1097 1097 for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { 1098 1098 if (sizeof(tcg_target_ulong) == 8) { ··· 1106 1106 } 1107 1107 } 1108 1108 } else { 1109 - log_disas(buf0, prologue_size); 1109 + log_disas(buf0, prologue_size, NULL); 1110 1110 } 1111 1111 qemu_log("\n"); 1112 1112 qemu_log_flush();