Quellcode durchsuchen

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>
Alex Bennée vor 5 Jahren
Ursprung
Commit
e5ef4ec28b
5 geänderte Dateien mit 17 neuen und 11 gelöschten Zeilen
  1. 2 2
      accel/tcg/translate-all.c
  2. 10 4
      disas.c
  3. 1 1
      include/disas/disas.h
  4. 2 2
      include/exec/log.h
  5. 2 2
      tcg/tcg.c

+ 2 - 2
accel/tcg/translate-all.c

@@ -1800,7 +1800,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
             size_t data_size = gen_code_size - code_size;
             size_t data_size = gen_code_size - code_size;
             size_t i;
             size_t i;
 
 
-            log_disas(tb->tc.ptr, code_size);
+            log_disas(tb->tc.ptr, code_size, NULL);
 
 
             for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
             for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
                 if (sizeof(tcg_target_ulong) == 8) {
                 if (sizeof(tcg_target_ulong) == 8) {
@@ -1814,7 +1814,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
                 }
                 }
             }
             }
         } else {
         } else {
-            log_disas(tb->tc.ptr, gen_code_size);
+            log_disas(tb->tc.ptr, gen_code_size, NULL);
         }
         }
         qemu_log("\n");
         qemu_log("\n");
         qemu_log_flush();
         qemu_log_flush();

+ 10 - 4
disas.c

@@ -586,7 +586,7 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size)
 }
 }
 
 
 /* Disassemble this for me please... (debugging). */
 /* Disassemble this for me please... (debugging). */
-void disas(FILE *out, void *code, unsigned long size)
+void disas(FILE *out, void *code, unsigned long size, const char *note)
 {
 {
     uintptr_t pc;
     uintptr_t pc;
     int count;
     int count;
@@ -674,10 +674,16 @@ void disas(FILE *out, void *code, unsigned long size)
     for (pc = (uintptr_t)code; size > 0; pc += count, size -= count) {
     for (pc = (uintptr_t)code; size > 0; pc += count, size -= count) {
         fprintf(out, "0x%08" PRIxPTR ":  ", pc);
         fprintf(out, "0x%08" PRIxPTR ":  ", pc);
         count = print_insn(pc, &s.info);
         count = print_insn(pc, &s.info);
-	fprintf(out, "\n");
-	if (count < 0)
-	    break;
+        if (note) {
+            fprintf(out, "\t\t%s", note);
+            note = NULL;
+        }
+        fprintf(out, "\n");
+        if (count < 0) {
+            break;
+        }
     }
     }
+
 }
 }
 
 
 /* Look up symbol for debugging purpose.  Returns "" if unknown. */
 /* Look up symbol for debugging purpose.  Returns "" if unknown. */

+ 1 - 1
include/disas/disas.h

@@ -7,7 +7,7 @@
 #include "cpu.h"
 #include "cpu.h"
 
 
 /* Disassemble this for me please... (debugging). */
 /* Disassemble this for me please... (debugging). */
-void disas(FILE *out, void *code, unsigned long size);
+void disas(FILE *out, void *code, unsigned long size, const char *note);
 void target_disas(FILE *out, CPUState *cpu, target_ulong code,
 void target_disas(FILE *out, CPUState *cpu, target_ulong code,
                   target_ulong size);
                   target_ulong size);
 
 

+ 2 - 2
include/exec/log.h

@@ -56,13 +56,13 @@ static inline void log_target_disas(CPUState *cpu, target_ulong start,
     rcu_read_unlock();
     rcu_read_unlock();
 }
 }
 
 
-static inline void log_disas(void *code, unsigned long size)
+static inline void log_disas(void *code, unsigned long size, const char *note)
 {
 {
     QemuLogFile *logfile;
     QemuLogFile *logfile;
     rcu_read_lock();
     rcu_read_lock();
     logfile = atomic_rcu_read(&qemu_logfile);
     logfile = atomic_rcu_read(&qemu_logfile);
     if (logfile) {
     if (logfile) {
-        disas(logfile->fd, code, size);
+        disas(logfile->fd, code, size, note);
     }
     }
     rcu_read_unlock();
     rcu_read_unlock();
 }
 }

+ 2 - 2
tcg/tcg.c

@@ -1092,7 +1092,7 @@ void tcg_prologue_init(TCGContext *s)
             size_t data_size = prologue_size - code_size;
             size_t data_size = prologue_size - code_size;
             size_t i;
             size_t i;
 
 
-            log_disas(buf0, code_size);
+            log_disas(buf0, code_size, NULL);
 
 
             for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
             for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) {
                 if (sizeof(tcg_target_ulong) == 8) {
                 if (sizeof(tcg_target_ulong) == 8) {
@@ -1106,7 +1106,7 @@ void tcg_prologue_init(TCGContext *s)
                 }
                 }
             }
             }
         } else {
         } else {
-            log_disas(buf0, prologue_size);
+            log_disas(buf0, prologue_size, NULL);
         }
         }
         qemu_log("\n");
         qemu_log("\n");
         qemu_log_flush();
         qemu_log_flush();