Skip to contentSkip to conversation

[6338] Convert references to logfile/loglevel to use qemu_log*() macros

Qemu-devel Applied Anthony Liguori 3 participants 3 messages Jan 15, 2009 – Jan 20, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 6338

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6338
Author:   aliguori
Date:     2009-01-15 22:34:14 +0000 (Thu, 15 Jan 2009)

Log Message:
-----------
Convert references to logfile/loglevel to use qemu_log*() macros

This is a large patch that changes all occurrences of logfile/loglevel global variables to use the new qemu_log*() macros.

Modified Paths:
--------------

    trunk/block-raw-posix.c
    trunk/bsd-user/elfload.c
    trunk/bsd-user/main.c
    trunk/cpu-exec.c
    trunk/darwin-user/commpage.c
    trunk/darwin-user/machload.c
    trunk/darwin-user/main.c
    trunk/darwin-user/syscall.c
    trunk/exec.c
    trunk/hw/alpha_palcode.c
    trunk/hw/mips_timer.c
    trunk/hw/ppc.c
    trunk/hw/ppc4xx_devs.c
    trunk/hw/ppc_prep.c
    trunk/kqemu.c
    trunk/linux-user/elfload.c
    trunk/linux-user/main.c
    trunk/linux-user/vm86.c
    trunk/target-alpha/translate.c
    trunk/target-arm/translate.c
    trunk/target-cris/helper.c
    trunk/target-cris/mmu.c
    trunk/target-cris/op_helper.c
    trunk/target-cris/translate.c
    trunk/target-i386/op_helper.c
    trunk/target-i386/translate.c
    trunk/target-m68k/translate.c
    trunk/target-mips/helper.c
    trunk/target-mips/op_helper.c
    trunk/target-mips/translate.c
    trunk/target-ppc/helper.c
    trunk/target-ppc/op_helper.c
    trunk/target-ppc/translate.c
    trunk/target-sh4/helper.c
    trunk/target-sh4/translate.c
    trunk/target-sparc/op_helper.c
    trunk/target-sparc/translate.c
    trunk/tcg/tcg.c
    trunk/translate-all.c
    trunk/vl.c

Modified: trunk/block-raw-posix.c
===================================================================

block-raw-posix.c +2 -2
@@ -67,8 +67,8 @@
 
 //#define DEBUG_BLOCK
 #if defined(DEBUG_BLOCK)
-#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0)	\
-    { fprintf(logfile, formatCstr, ##args); fflush(logfile); } } while (0)
+#define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (qemu_log_enabled())	\
+    { qemu_log(formatCstr, ##args); fflush(logfile); } } while (0)
 #else
 #define DEBUG_BLOCK_PRINT(formatCstr, args...)
 #endif

Modified: trunk/bsd-user/elfload.c
===================================================================

bsd-user/elfload.c +1 -1
@@ -1456,7 +1456,7 @@
 
     free(elf_phdata);
 
-    if (loglevel)
+    if (qemu_log_enabled())
         load_symbols(&elf_ex, bprm->fd);
 
     if (interpreter_type != INTERPRETER_AOUT) close(bprm->fd);

Modified: trunk/bsd-user/main.c
===================================================================

bsd-user/main.c +12 -14
@@ -533,21 +533,19 @@
 
     free(target_environ);
 
-    if (loglevel) {
-        page_dump(logfile);
+    log_page_dump();
 
-        fprintf(logfile, "start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
-        fprintf(logfile, "end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
-        fprintf(logfile, "start_code  0x" TARGET_ABI_FMT_lx "\n",
-                info->start_code);
-        fprintf(logfile, "start_data  0x" TARGET_ABI_FMT_lx "\n",
-                info->start_data);
-        fprintf(logfile, "end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
-        fprintf(logfile, "start_stack 0x" TARGET_ABI_FMT_lx "\n",
-                info->start_stack);
-        fprintf(logfile, "brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
-        fprintf(logfile, "entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
-    }
+    qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
+    qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
+    qemu_log("start_code  0x" TARGET_ABI_FMT_lx "\n",
+            info->start_code);
+    qemu_log("start_data  0x" TARGET_ABI_FMT_lx "\n",
+            info->start_data);
+    qemu_log("end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
+    qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n",
+            info->start_stack);
+    qemu_log("brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
+    qemu_log("entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
 
     target_set_brk(info->brk);
     syscall_init();

Modified: trunk/cpu-exec.c
===================================================================

cpu-exec.c +14 -19
@@ -390,9 +390,7 @@
                             svm_check_intercept(SVM_EXIT_INTR);
                             env->interrupt_request &= ~(CPU_INTERRUPT_HARD | CPU_INTERRUPT_VIRQ);
                             intno = cpu_get_pic_interrupt(env);
-                            if (loglevel & CPU_LOG_TB_IN_ASM) {
-                                fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno);
-                            }
+                            qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing hardware INT=0x%02x\n", intno);
                             do_interrupt(intno, 0, 0, 0, 1);
                             /* ensure that no TB jump will be modified as
                                the program flow was changed */
@@ -405,8 +403,7 @@
                             /* FIXME: this should respect TPR */
                             svm_check_intercept(SVM_EXIT_VINTR);
                             intno = ldl_phys(env->vm_vmcb + offsetof(struct vmcb, control.int_vector));
-                            if (loglevel & CPU_LOG_TB_IN_ASM)
-                                fprintf(logfile, "Servicing virtual hardware INT=0x%02x\n", intno);
+                            qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing virtual hardware INT=0x%02x\n", intno);
                             do_interrupt(intno, 0, 0, 0, 1);
                             env->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
                             next_tb = 0;
@@ -540,28 +537,28 @@
                     regs_to_env();
 #if defined(TARGET_I386)
                     env->eflags = env->eflags | helper_cc_compute_all(CC_OP) | (DF & DF_MASK);
-                    cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
+                    log_cpu_state(env, X86_DUMP_CCOP);
                     env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
 #elif defined(TARGET_ARM)
-                    cpu_dump_state(env, logfile, fprintf, 0);
+                    log_cpu_state(env, 0);
 #elif defined(TARGET_SPARC)
-                    cpu_dump_state(env, logfile, fprintf, 0);
+                    log_cpu_state(env, 0);
 #elif defined(TARGET_PPC)
-                    cpu_dump_state(env, logfile, fprintf, 0);
+                    log_cpu_state(env, 0);
 #elif defined(TARGET_M68K)
                     cpu_m68k_flush_flags(env, env->cc_op);
                     env->cc_op = CC_OP_FLAGS;
                     env->sr = (env->sr & 0xffe0)
                               | env->cc_dest | (env->cc_x << 4);
-                    cpu_dump_state(env, logfile, fprintf, 0);
+                    log_cpu_state(env, 0);
 #elif defined(TARGET_MIPS)
-                    cpu_dump_state(env, logfile, fprintf, 0);
+                    log_cpu_state(env, 0);
 #elif defined(TARGET_SH4)
-		    cpu_dump_state(env, logfile, fprintf, 0);
+		    log_cpu_state(env, 0);
 #elif defined(TARGET_ALPHA)
-                    cpu_dump_state(env, logfile, fprintf, 0);
+                    log_cpu_state(env, 0);
 #elif defined(TARGET_CRIS)
-                    cpu_dump_state(env, logfile, fprintf, 0);
+                    log_cpu_state(env, 0);
 #else
 #error unsupported target CPU
 #endif
@@ -579,11 +576,9 @@
                     tb_invalidated_flag = 0;
                 }
 #ifdef DEBUG_EXEC
-                if ((loglevel & CPU_LOG_EXEC)) {
-                    fprintf(logfile, "Trace 0x%08lx [" TARGET_FMT_lx "] %s\n",
-                            (long)tb->tc_ptr, tb->pc,
-                            lookup_symbol(tb->pc));
-                }
+                qemu_log_mask(CPU_LOG_EXEC, "Trace 0x%08lx [" TARGET_FMT_lx "] %s\n",
+                             (long)tb->tc_ptr, tb->pc,
+                             lookup_symbol(tb->pc));
 #endif
                 /* see if we can patch the calling TB. When the TB
                    spans two pages, we cannot safely do a direct

Modified: trunk/darwin-user/commpage.c
===================================================================

darwin-user/commpage.c +2 -2
@@ -35,9 +35,9 @@
 //#define DEBUG_COMMPAGE
 
 #ifdef DEBUG_COMMPAGE
-# define DPRINTF(...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); printf(__VA_ARGS__); } while(0)
+# define DPRINTF(...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0)
 #else
-# define DPRINTF(...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0)
+# define DPRINTF(...) do { qemu_log(__VA_ARGS__); } while(0)
 #endif
 
 /********************************************************************

Modified: trunk/darwin-user/machload.c
===================================================================

darwin-user/machload.c +2 -2
@@ -39,9 +39,9 @@
 //#define DEBUG_MACHLOAD
 
 #ifdef DEBUG_MACHLOAD
-# define DPRINTF(...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); printf(__VA_ARGS__); } while(0)
+# define DPRINTF(...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0)
 #else
-# define DPRINTF(...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0)
+# define DPRINTF(...) do { qemu_log(__VA_ARGS__); } while(0)
 #endif
 
 # define check_mach_header(x) (x.magic == MH_CIGAM)

Modified: trunk/darwin-user/main.c
===================================================================

darwin-user/main.c +2 -4
@@ -160,10 +160,8 @@
 do {                                                                          \
     fprintf(stderr, fmt , ##args);                                            \
     cpu_dump_state(env, stderr, fprintf, 0);                                  \
-    if (loglevel != 0) {                                                      \
-        fprintf(logfile, fmt , ##args);                                       \
-        cpu_dump_state(env, logfile, fprintf, 0);                             \
-    }                                                                         \
+    qemu_log(fmt, ##args);                                                   \
+    log_cpu_state(env, 0);                                                      \
 } while (0)
 
 void cpu_loop(CPUPPCState *env)

Modified: trunk/darwin-user/syscall.c
===================================================================

darwin-user/syscall.c +2 -2
@@ -69,7 +69,7 @@
 # define DEBUG_ENABLE_ALL()  static int __DEBUG_qemu_user_force_enable = 1
     DEBUG_ENABLE_ALL();
 
-# define DPRINTF(...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); \
+# define DPRINTF(...) do { qemu_log(__VA_ARGS__); \
                            if(__DEBUG_qemu_user_force_enable) fprintf(stderr, __VA_ARGS__); \
                          } while(0)
 #else
@@ -77,7 +77,7 @@
 # define DEBUG_BEGIN_ENABLE
 # define DEBUG_END_ENABLE
 
-# define DPRINTF(...) do { if(loglevel) fprintf(logfile, __VA_ARGS__); } while(0)
+# define DPRINTF(...) do { qemu_log(__VA_ARGS__); } while(0)
 #endif
 
 enum {

Modified: trunk/exec.c
===================================================================

exec.c +11 -13
@@ -1004,12 +1004,10 @@
     int offset, b;
 #if 0
     if (1) {
-        if (loglevel) {
-            fprintf(logfile, "modifying code at 0x%x size=%d EIP=%x PC=%08x\n",
-                   cpu_single_env->mem_io_vaddr, len,
-                   cpu_single_env->eip,
-                   cpu_single_env->eip + (long)cpu_single_env->segs[R_CS].base);
-        }
+        qemu_log("modifying code at 0x%x size=%d EIP=%x PC=%08x\n",
+                  cpu_single_env->mem_io_vaddr, len,
+                  cpu_single_env->eip,
+                  cpu_single_env->eip + (long)cpu_single_env->segs[R_CS].base);
     }
 #endif
     p = page_find(start >> TARGET_PAGE_BITS);
@@ -1634,17 +1632,17 @@
 #else
     cpu_dump_state(env, stderr, fprintf, 0);
 #endif
-    if (logfile) {
-        fprintf(logfile, "qemu: fatal: ");
-        vfprintf(logfile, fmt, ap2);
-        fprintf(logfile, "\n");
+    if (qemu_log_enabled()) {
+        qemu_log("qemu: fatal: ");
+        qemu_log_vprintf(fmt, ap2);
+        qemu_log("\n");
 #ifdef TARGET_I386
-        cpu_dump_state(env, logfile, fprintf, X86_DUMP_FPU | X86_DUMP_CCOP);
+        log_cpu_state(env, X86_DUMP_FPU | X86_DUMP_CCOP);
 #else
-        cpu_dump_state(env, logfile, fprintf, 0);
+        log_cpu_state(env, 0);
 #endif
         fflush(logfile);
-        fclose(logfile);
+        qemu_log_close();
     }
     va_end(ap2);
     va_end(ap);

Modified: trunk/hw/alpha_palcode.c
===================================================================

hw/alpha_palcode.c +5 -10
@@ -1061,13 +1061,11 @@
 {
     target_long ret;
 
-    if (logfile != NULL)
-        fprintf(logfile, "%s: palcode %02x\n", __func__, palcode);
+    qemu_log("%s: palcode %02x\n", __func__, palcode);
     switch (palcode) {
     case 0x83:
         /* CALLSYS */
-        if (logfile != NULL)
-            fprintf(logfile, "CALLSYS n " TARGET_FMT_ld "\n", env->ir[0]);
+        qemu_log("CALLSYS n " TARGET_FMT_ld "\n", env->ir[0]);
         ret = do_syscall(env, env->ir[IR_V0], env->ir[IR_A0], env->ir[IR_A1],
                          env->ir[IR_A2], env->ir[IR_A3], env->ir[IR_A4],
                          env->ir[IR_A5]);
@@ -1082,18 +1080,15 @@
     case 0x9E:
         /* RDUNIQUE */
         env->ir[IR_V0] = env->unique;
-        if (logfile != NULL)
-            fprintf(logfile, "RDUNIQUE: " TARGET_FMT_lx "\n", env->unique);
+        qemu_log("RDUNIQUE: " TARGET_FMT_lx "\n", env->unique);
         break;
     case 0x9F:
         /* WRUNIQUE */
         env->unique = env->ir[IR_A0];
-        if (logfile != NULL)
-            fprintf(logfile, "WRUNIQUE: " TARGET_FMT_lx "\n", env->unique);
+        qemu_log("WRUNIQUE: " TARGET_FMT_lx "\n", env->unique);
         break;
     default:
-        if (logfile != NULL)
-            fprintf(logfile, "%s: unhandled palcode %02x\n",
+        qemu_log("%s: unhandled palcode %02x\n",
                     __func__, palcode);
         exit(1);
     }

Modified: trunk/hw/mips_timer.c
===================================================================

hw/mips_timer.c +1 -3
@@ -84,9 +84,7 @@
 
     env = opaque;
 #if 0
-    if (logfile) {
-        fprintf(logfile, "%s\n", __func__);
-    }
+    qemu_log("%s\n", __func__);
 #endif
 
     if (env->CP0_Cause & (1 << CP0Ca_DC))

Modified: trunk/hw/ppc.c
===================================================================

hw/ppc.c +2 -8
@@ -32,20 +32,14 @@
 //#define PPC_DEBUG_TB
 
 #ifdef PPC_DEBUG_IRQ
-#  define LOG_IRQ(...) do {              \
-     if (loglevel & CPU_LOG_INT)         \
-       fprintf(logfile, ## __VA_ARGS__); \
-   } while (0)
+#  define LOG_IRQ(...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)
 #else
 #  define LOG_IRQ(...) do { } while (0)
 #endif
 
 
 #ifdef PPC_DEBUG_TB
-#  define LOG_TB(...) do {               \
-     if (loglevel)                       \
-       fprintf(logfile, ## __VA_ARGS__); \
-   } while (0)
+#  define LOG_TB(...) qemu_log(__VA_ARGS__)
 #else
 #  define LOG_TB(...) do { } while (0)
 #endif

Modified: trunk/hw/ppc4xx_devs.c
===================================================================

hw/ppc4xx_devs.c +1 -4
@@ -33,10 +33,7 @@
 
 
 #ifdef DEBUG_UIC
-#  define LOG_UIC(...) do {              \
-     if (loglevel & CPU_LOG_INT)         \
-       fprintf(logfile, ## __VA_ARGS__); \
-   } while (0)
+#  define LOG_UIC(...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)
 #else
 #  define LOG_UIC(...) do { } while (0)
 #endif

Modified: trunk/hw/ppc_prep.c
===================================================================

hw/ppc_prep.c +2 -7
@@ -53,18 +53,13 @@
 #define PPC_IO_DPRINTF(fmt, args...)                     \
 do {                                                     \
     if (loglevel & CPU_LOG_IOPORT) {                     \
-        fprintf(logfile, "%s: " fmt, __func__ , ##args); \
+        qemu_log("%s: " fmt, __func__ , ##args); \
     } else {                                             \
         printf("%s : " fmt, __func__ , ##args);          \
     }                                                    \
 } while (0)
 #elif defined (DEBUG_PPC_IO)
-#define PPC_IO_DPRINTF(fmt, args...)                     \
-do {                                                     \
-    if (loglevel & CPU_LOG_IOPORT) {                     \
-        fprintf(logfile, "%s: " fmt, __func__ , ##args); \
-    }                                                    \
-} while (0)
+#define PPC_IO_DPRINTF(fmt, args...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)
 #else
 #define PPC_IO_DPRINTF(fmt, args...) do { } while (0)
 #endif

Modified: trunk/kqemu.c
===================================================================

kqemu.c +2 -9
@@ -49,15 +49,8 @@
 
 
 #ifdef DEBUG
-#  define LOG_INT(...) do {              \
-     if (loglevel & CPU_LOG_INT)         \
-       fprintf(logfile, ## __VA_ARGS__); \
-   } while (0)
-#  define LOG_INT_STATE(env) \
-      do {                                            \
-         if (loglevel & CPU_LOG_INT)                  \
-            cpu_dump_state(env, logfile, fprintf, 0); \
-      } while (0)
+#  define LOG_INT(...) qemu_log_mask(CPU_LOG_INT, ## __VA_ARGS__)
+#  define LOG_INT_STATE(env) log_cpu_state_mask(CPU_LOG_INT, (env), 0)
 #else
 #  define LOG_INT(...) do { } while (0)
 #  define LOG_INT_STATE(env) do { } while (0)

Modified: trunk/linux-user/elfload.c
===================================================================

linux-user/elfload.c +1 -1
@@ -1454,7 +1454,7 @@
 
     free(elf_phdata);
 
-    if (loglevel)
+    if (qemu_log_enabled())
 	load_symbols(&elf_ex, bprm->fd);
 
     if (interpreter_type != INTERPRETER_AOUT) close(bprm->fd);

Modified: trunk/linux-user/main.c
===================================================================

linux-user/main.c +14 -18
@@ -1057,10 +1057,8 @@
 do {                                                                          \
     fprintf(stderr, fmt , ##args);                                            \
     cpu_dump_state(env, stderr, fprintf, 0);                                  \
-    if (loglevel != 0) {                                                      \
-        fprintf(logfile, fmt , ##args);                                       \
-        cpu_dump_state(env, logfile, fprintf, 0);                             \
-    }                                                                         \
+    qemu_log(fmt, ##args);                                                   \
+    log_cpu_state(env, 0);                                                      \
 } while (0)
 
 void cpu_loop(CPUPPCState *env)
@@ -2396,21 +2394,19 @@
 
     free(target_environ);
 
-    if (loglevel) {
-        page_dump(logfile);
+    log_page_dump();
 
-        fprintf(logfile, "start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
-        fprintf(logfile, "end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
-        fprintf(logfile, "start_code  0x" TARGET_ABI_FMT_lx "\n",
-                info->start_code);
-        fprintf(logfile, "start_data  0x" TARGET_ABI_FMT_lx "\n",
-                info->start_data);
-        fprintf(logfile, "end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
-        fprintf(logfile, "start_stack 0x" TARGET_ABI_FMT_lx "\n",
-                info->start_stack);
-        fprintf(logfile, "brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
-        fprintf(logfile, "entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
-    }
+    qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
+    qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
+    qemu_log("start_code  0x" TARGET_ABI_FMT_lx "\n",
+            info->start_code);
+    qemu_log("start_data  0x" TARGET_ABI_FMT_lx "\n",
+            info->start_data);
+    qemu_log("end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
+    qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n",
+            info->start_stack);
+    qemu_log("brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
+    qemu_log("entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
 
     target_set_brk(info->brk);
     syscall_init();

Modified: trunk/linux-user/vm86.c
===================================================================

linux-user/vm86.c +1 -1
@@ -30,7 +30,7 @@
 //#define DEBUG_VM86
 
 #ifdef DEBUG_VM86
-#  define LOG_VM86(...) fprintf(logfile, ## __VA_ARGS__);
+#  define LOG_VM86(...) qemu_log(__VA_ARGS__);
 #else
 #  define LOG_VM86(...) do { } while (0)
 #endif

Modified: trunk/target-alpha/translate.c
===================================================================

target-alpha/translate.c +5 -10
@@ -39,10 +39,7 @@
 
 
 #ifdef ALPHA_DEBUG_DISAS
-#  define LOG_DISAS(...) do {            \
-     if (logfile)                        \
-       fprintf(logfile, ## __VA_ARGS__); \
-   } while (0)
+#  define LOG_DISAS(...) qemu_log(__VA_ARGS__)
 #else
 #  define LOG_DISAS(...) do { } while (0)
 #endif
@@ -2444,13 +2441,11 @@
         tb->icount = num_insns;
     }
 #if defined ALPHA_DEBUG_DISAS
-    if (loglevel & CPU_LOG_TB_CPU) {
-        cpu_dump_state(env, logfile, fprintf, 0);
-    }
+    log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
     if (loglevel & CPU_LOG_TB_IN_ASM) {
-        fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
-        target_disas(logfile, pc_start, ctx.pc - pc_start, 1);
-        fprintf(logfile, "\n");
+        qemu_log("IN: %s\n", lookup_symbol(pc_start));
+        log_target_disas(pc_start, ctx.pc - pc_start, 1);
+        qemu_log("\n");
     }
 #endif
 }

Modified: trunk/target-arm/translate.c
===================================================================

target-arm/translate.c +4 -4
@@ -8871,10 +8871,10 @@
 
 #ifdef DEBUG_DISAS
     if (loglevel & CPU_LOG_TB_IN_ASM) {
-        fprintf(logfile, "----------------\n");
-        fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
-        target_disas(logfile, pc_start, dc->pc - pc_start, env->thumb);
-        fprintf(logfile, "\n");
+        qemu_log("----------------\n");
+        qemu_log("IN: %s\n", lookup_symbol(pc_start));
+        log_target_disas(pc_start, dc->pc - pc_start, env->thumb);
+        qemu_log("\n");
     }
 #endif
     if (search_pc) {

Modified: trunk/target-cris/helper.c
===================================================================

target-cris/helper.c +1 -1
@@ -34,7 +34,7 @@
 
 #ifdef CRIS_HELPER_DEBUG
 #define D(x) x
-#define D_LOG(...) fprintf(logfile, ## __VA_ARGS__)
+#define D_LOG(...) qemu_log(__VA__ARGS__)
 #else
 #define D(x)
 #define D_LOG(...) do { } while (0)

Modified: trunk/target-cris/mmu.c
===================================================================

target-cris/mmu.c +1 -1
@@ -32,7 +32,7 @@
 
 #ifdef DEBUG
 #define D(x) x
-#define D_LOG(...) fprintf(logfile, ## __VA_ARGS__)
+#define D_LOG(...) qemu_log(__VA__ARGS__)
 #else
 #define D(x)
 #define D_LOG(...) do { } while (0)

Modified: trunk/target-cris/op_helper.c
===================================================================

target-cris/op_helper.c +2 -2
@@ -30,7 +30,7 @@
 
 #ifdef CRIS_OP_HELPER_DEBUG
 #define D(x) x
-#define D_LOG(...) fprintf(logfile, ## __VA_ARGS__)
+#define D_LOG(...) qemu_log(__VA__ARGS__)
 #else
 #define D(x)
 #define D_LOG(...) do { } while (0)
@@ -117,7 +117,7 @@
 
 void helper_dump(uint32_t a0, uint32_t a1, uint32_t a2)
 {
-	(fprintf(logfile, "%s: a0=%x a1=%x\n", __func__, a0, a1)); 
+	qemu_log("%s: a0=%x a1=%x\n", __func__, a0, a1);
 }
 
 /* Used by the tlb decoder.  */

Modified: trunk/target-cris/translate.c
===================================================================

target-cris/translate.c +9 -13
@@ -44,10 +44,7 @@
 
 #define DISAS_CRIS 0
 #if DISAS_CRIS
-#  define LOG_DIS(...) do {               \
-     if (loglevel & CPU_LOG_TB_IN_ASM)    \
-       fprintf(logfile, ## __VA_ARGS__);  \
-   } while (0)
+#  define LOG_DIS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)
 #else
 #  define LOG_DIS(...) do { } while (0)
 #endif
@@ -131,7 +128,7 @@
 static void gen_BUG(DisasContext *dc, const char *file, int line)
 {
 	printf ("BUG: pc=%x %s %d\n", dc->pc, file, line);
-	fprintf (logfile, "BUG: pc=%x %s %d\n", dc->pc, file, line);
+	qemu_log("BUG: pc=%x %s %d\n", dc->pc, file, line);
 	cpu_abort(dc->env, "%s:%d\n", file, line);
 }
 
@@ -798,7 +795,7 @@
 			t_gen_subx_carry(dc, dst);
 			break;
 		default:
-			fprintf (logfile, "illegal ALU op.\n");
+			qemu_log("illegal ALU op.\n");
 			BUG();
 			break;
 	}
@@ -3147,8 +3144,7 @@
         int num_insns;
         int max_insns;
 
-	if (!logfile)
-		logfile = stderr;
+	qemu_log_try_set_file(stderr);
 
 	/* Odd PC indicates that branch is rexecuting due to exception in the
 	 * delayslot, like in real hw.
@@ -3184,7 +3180,7 @@
 	dc->cpustate_changed = 0;
 
 	if (loglevel & CPU_LOG_TB_IN_ASM) {
-		fprintf(logfile,
+		qemu_log(
 			"srch=%d pc=%x %x flg=%llx bt=%x ds=%u ccs=%x\n"
 			"pid=%x usp=%x\n"
 			"%x.%x.%x.%x\n"
@@ -3202,8 +3198,8 @@
 			env->regs[10], env->regs[11],
 			env->regs[12], env->regs[13],
 			env->regs[14], env->regs[15]);
-		fprintf(logfile, "--------------\n");
-		fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
+		qemu_log("--------------\n");
+		qemu_log("IN: %s\n", lookup_symbol(pc_start));
 	}
 
 	next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
@@ -3336,8 +3332,8 @@
 #ifdef DEBUG_DISAS
 #if !DISAS_CRIS
 	if (loglevel & CPU_LOG_TB_IN_ASM) {
-		target_disas(logfile, pc_start, dc->pc - pc_start, 0);
-		fprintf(logfile, "\nisize=%d osize=%zd\n",
+		log_target_disas(pc_start, dc->pc - pc_start, 0);
+		qemu_log("\nisize=%d osize=%zd\n",
 			dc->pc - pc_start, gen_opc_ptr - gen_opc_buf);
 	}
 #endif

Modified: trunk/target-i386/op_helper.c
===================================================================

target-i386/op_helper.c +28 -49

191 lines not on this page · raw message

Modified: trunk/target-i386/translate.c
===================================================================

target-i386/translate.c +8 -10
@@ -7675,21 +7675,19 @@
     }
 
 #ifdef DEBUG_DISAS
-    if (loglevel & CPU_LOG_TB_CPU) {
-        cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
-    }
+    log_cpu_state_mask(CPU_LOG_TB_CPU, env, X86_DUMP_CCOP);
     if (loglevel & CPU_LOG_TB_IN_ASM) {
         int disas_flags;
-        fprintf(logfile, "----------------\n");
-        fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
+        qemu_log("----------------\n");
+        qemu_log("IN: %s\n", lookup_symbol(pc_start));
 #ifdef TARGET_X86_64
         if (dc->code64)
             disas_flags = 2;
         else
 #endif
             disas_flags = !dc->code32;
-	target_disas(logfile, pc_start, pc_ptr - pc_start, disas_flags);
-        fprintf(logfile, "\n");
+        log_target_disas(pc_start, pc_ptr - pc_start, disas_flags);
+        qemu_log("\n");
     }
 #endif
 
@@ -7716,13 +7714,13 @@
 #ifdef DEBUG_DISAS
     if (loglevel & CPU_LOG_TB_OP) {
         int i;
-        fprintf(logfile, "RESTORE:\n");
+        qemu_log("RESTORE:\n");
         for(i = 0;i <= pc_pos; i++) {
             if (gen_opc_instr_start[i]) {
-                fprintf(logfile, "0x%04x: " TARGET_FMT_lx "\n", i, gen_opc_pc[i]);
+                qemu_log("0x%04x: " TARGET_FMT_lx "\n", i, gen_opc_pc[i]);
             }
         }
-        fprintf(logfile, "spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n",
+        qemu_log("spc=0x%08lx pc_pos=0x%x eip=" TARGET_FMT_lx " cs_base=%x\n",
                 searched_pc, pc_pos, gen_opc_pc[pc_pos] - tb->cs_base,
                 (uint32_t)tb->cs_base);
     }

Modified: trunk/target-m68k/translate.c
===================================================================

target-m68k/translate.c +5 -5
@@ -165,7 +165,7 @@
 #define DISAS_INSN(name) \
   static void real_disas_##name (DisasContext *s, uint16_t insn); \
   static void disas_##name (DisasContext *s, uint16_t insn) { \
-    if (logfile) fprintf(logfile, "Dispatch " #name "\n"); \
+    qemu_log("Dispatch " #name "\n"); \
     real_disas_##name(s, insn); } \
   static void real_disas_##name (DisasContext *s, uint16_t insn)
 #else
@@ -3064,10 +3064,10 @@
 
 #ifdef DEBUG_DISAS
     if (loglevel & CPU_LOG_TB_IN_ASM) {
-        fprintf(logfile, "----------------\n");
-        fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
-        target_disas(logfile, pc_start, dc->pc - pc_start, 0);
-        fprintf(logfile, "\n");
+        qemu_log("----------------\n");
+        qemu_log("IN: %s\n", lookup_symbol(pc_start));
+        log_target_disas(pc_start, dc->pc - pc_start, 0);
+        qemu_log("\n");
     }
 #endif
     if (search_pc) {

Modified: trunk/target-mips/helper.c
===================================================================

target-mips/helper.c +14 -25
@@ -117,10 +117,7 @@
     int ret = TLBRET_MATCH;
 
 #if 0
-    if (logfile) {
-        fprintf(logfile, "user mode %d h %08x\n",
-                user_mode, env->hflags);
-    }
+    qemu_log("user mode %d h %08x\n", user_mode, env->hflags);
 #endif
 
     if (address <= (int32_t)0x7FFFFFFFUL) {
@@ -198,9 +195,8 @@
         }
     }
 #if 0
-    if (logfile) {
-        fprintf(logfile, TARGET_FMT_lx " %d %d => " TARGET_FMT_lx " %d (%d)\n",
-                address, rw, access_type, *physical, *prot, ret);
+    qemu_log(TARGET_FMT_lx " %d %d => " TARGET_FMT_lx " %d (%d)\n",
+            address, rw, access_type, *physical, *prot, ret);
     }
 #endif
 
@@ -233,13 +229,11 @@
     int access_type;
     int ret = 0;
 
-    if (logfile) {
 #if 0
-        cpu_dump_state(env, logfile, fprintf, 0);
+    log_cpu_state(env, 0);
 #endif
-        fprintf(logfile, "%s pc " TARGET_FMT_lx " ad " TARGET_FMT_lx " rw %d mmu_idx %d smmu %d\n",
-                __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu);
-    }
+    qemu_log("%s pc " TARGET_FMT_lx " ad " TARGET_FMT_lx " rw %d mmu_idx %d smmu %d\n",
+              __func__, env->active_tc.PC, address, rw, mmu_idx, is_softmmu);
 
     rw &= 1;
 
@@ -252,10 +246,8 @@
 #else
     ret = get_physical_address(env, &physical, &prot,
                                address, rw, access_type);
-    if (logfile) {
-        fprintf(logfile, "%s address=" TARGET_FMT_lx " ret %d physical " TARGET_FMT_lx " prot %d\n",
-                __func__, address, ret, physical, prot);
-    }
+    qemu_log("%s address=" TARGET_FMT_lx " ret %d physical " TARGET_FMT_lx " prot %d\n",
+              __func__, address, ret, physical, prot);
     if (ret == TLBRET_MATCH) {
        ret = tlb_set_page(env, address & TARGET_PAGE_MASK,
                           physical & TARGET_PAGE_MASK, prot,
@@ -357,14 +349,14 @@
     int cause = -1;
     const char *name;
 
-    if (logfile && env->exception_index != EXCP_EXT_INTERRUPT) {
+    if (qemu_log_enabled() && env->exception_index != EXCP_EXT_INTERRUPT) {
         if (env->exception_index < 0 || env->exception_index > EXCP_LAST)
             name = "unknown";
         else
             name = excp_names[env->exception_index];
 
-        fprintf(logfile, "%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n",
-                __func__, env->active_tc.PC, env->CP0_EPC, name);
+        qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n",
+                 __func__, env->active_tc.PC, env->CP0_EPC, name);
     }
     if (env->exception_index == EXCP_EXT_INTERRUPT &&
         (env->hflags & MIPS_HFLAG_DM))
@@ -558,15 +550,12 @@
         env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC);
         break;
     default:
-        if (logfile) {
-            fprintf(logfile, "Invalid MIPS exception %d. Exiting\n",
-                    env->exception_index);
-        }
+        qemu_log("Invalid MIPS exception %d. Exiting\n", env->exception_index);
         printf("Invalid MIPS exception %d. Exiting\n", env->exception_index);
         exit(1);
     }
-    if (logfile && env->exception_index != EXCP_EXT_INTERRUPT) {
-        fprintf(logfile, "%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n"
+    if (qemu_log_enabled() && env->exception_index != EXCP_EXT_INTERRUPT) {
+        qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n"
                 "    S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n",
                 __func__, env->active_tc.PC, env->CP0_EPC, cause,
                 env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr,

Modified: trunk/target-mips/op_helper.c
===================================================================

target-mips/op_helper.c +33 -33

117 lines not on this page · raw message

Modified: trunk/target-mips/translate.c
===================================================================

target-mips/translate.c +14 -25
@@ -514,18 +514,11 @@
       "h24", "h25", "h26", "h27", "h28", "h29", "h30", "h31", };
 
 #ifdef MIPS_DEBUG_DISAS
-#define MIPS_DEBUG(fmt, args...)                                              \
-do {                                                                          \
-    if (loglevel & CPU_LOG_TB_IN_ASM) {                                       \
-        fprintf(logfile, TARGET_FMT_lx ": %08x " fmt "\n",                    \
-                ctx->pc, ctx->opcode , ##args);                               \
-    }                                                                         \
-} while (0)
-#define LOG_DISAS(...)                        \
-    do {                                      \
-        if (loglevel & CPU_LOG_TB_IN_ASM)     \
-            fprintf(logfile, ## __VA_ARGS__); \
-    } while (0)
+#define MIPS_DEBUG(fmt, args...)                         \
+        qemu_log_mask(CPU_LOG_TB_IN_ASM,                \
+                       TARGET_FMT_lx ": %08x " fmt "\n", \
+                       ctx->pc, ctx->opcode , ##args)
+#define LOG_DISAS(...) qemu_log_mask(CPU_LOG_TB_IN_ASM, ## __VA_ARGS__)
 #else
 #define MIPS_DEBUG(fmt, args...) do { } while(0)
 #define LOG_DISAS(...) do { } while (0)
@@ -8180,8 +8173,8 @@
     int num_insns;
     int max_insns;
 
-    if (search_pc && loglevel)
-        fprintf (logfile, "search pc %d\n", search_pc);
+    if (search_pc)
+        qemu_log("search pc %d\n", search_pc);
 
     pc_start = tb->pc;
     /* Leave some spare opc slots for branch handling. */
@@ -8203,11 +8196,9 @@
     if (max_insns == 0)
         max_insns = CF_COUNT_MASK;
 #ifdef DEBUG_DISAS
-    if (loglevel & CPU_LOG_TB_CPU) {
-        fprintf(logfile, "------------------------------------------------\n");
-        /* FIXME: This may print out stale hflags from env... */
-        cpu_dump_state(env, logfile, fprintf, 0);
-    }
+    qemu_log_mask(CPU_LOG_TB_CPU, "------------------------------------------------\n");
+    /* FIXME: This may print out stale hflags from env... */
+    log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
 #endif
     LOG_DISAS("\ntb %p idx %d hflags %04x\n", tb, ctx.mem_idx, ctx.hflags);
     gen_icount_start();
@@ -8299,13 +8290,11 @@
 #ifdef DEBUG_DISAS
     LOG_DISAS("\n");
     if (loglevel & CPU_LOG_TB_IN_ASM) {
-        fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
-        target_disas(logfile, pc_start, ctx.pc - pc_start, 0);
-        fprintf(logfile, "\n");
+        qemu_log("IN: %s\n", lookup_symbol(pc_start));
+        log_target_disas(pc_start, ctx.pc - pc_start, 0);
+        qemu_log("\n");
     }
-    if (loglevel & CPU_LOG_TB_CPU) {
-        fprintf(logfile, "---------------- %d %08x\n", ctx.bstate, ctx.hflags);
-    }
+    qemu_log_mask(CPU_LOG_TB_CPU, "---------------- %d %08x\n", ctx.bstate, ctx.hflags);
 #endif
 }
 

Modified: trunk/target-ppc/helper.c
===================================================================

target-ppc/helper.c +29 -69

233 lines not on this page · raw message

Modified: trunk/target-ppc/op_helper.c
===================================================================

target-ppc/op_helper.c +8 -25
@@ -29,10 +29,7 @@
 //#define DEBUG_SOFTWARE_TLB
 
 #ifdef DEBUG_SOFTWARE_TLB
-#  define LOG_SWTLB(...) do {            \
-     if (loglevel)                       \
-       fprintf(logfile, ## __VA_ARGS__); \
-   } while (0)
+#  define LOG_SWTLB(...) qemu_log(__VA_ARGS__)
 #else
 #  define LOG_SWTLB(...) do { } while (0)
 #endif
@@ -84,18 +81,14 @@
 /* SPR accesses */
 void helper_load_dump_spr (uint32_t sprn)
 {
-    if (loglevel != 0) {
-        fprintf(logfile, "Read SPR %d %03x => " ADDRX "\n",
+    qemu_log("Read SPR %d %03x => " ADDRX "\n",
                 sprn, sprn, env->spr[sprn]);
-    }
 }
 
 void helper_store_dump_spr (uint32_t sprn)
 {
-    if (loglevel != 0) {
-        fprintf(logfile, "Write SPR %d %03x <= " ADDRX "\n",
+    qemu_log("Write SPR %d %03x <= " ADDRX "\n",
                 sprn, sprn, env->spr[sprn]);
-    }
 }
 
 target_ulong helper_load_tbl (void)
@@ -192,10 +185,8 @@
         env->hflags_nmsr &= ~(1 << MSR_LE);
         env->hflags_nmsr |= (1 << MSR_LE) & (((val >> 3) & 1) << MSR_LE);
         env->hflags |= env->hflags_nmsr;
-        if (loglevel != 0) {
-            fprintf(logfile, "%s: set endianness to %c => " ADDRX "\n",
+        qemu_log("%s: set endianness to %c => " ADDRX "\n",
                     __func__, val & 0x8 ? 'l' : 'b', env->hflags);
-        }
     }
     env->spr[SPR_HID0] = (uint32_t)val;
 }
@@ -1870,15 +1861,11 @@
     target_ulong val = 0;
 
     if (unlikely(env->dcr_env == NULL)) {
-        if (loglevel != 0) {
-            fprintf(logfile, "No DCR environment\n");
-        }
+        qemu_log("No DCR environment\n");
         helper_raise_exception_err(POWERPC_EXCP_PROGRAM,
                                    POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL);
     } else if (unlikely(ppc_dcr_read(env->dcr_env, dcrn, &val) != 0)) {
-        if (loglevel != 0) {
-            fprintf(logfile, "DCR read error %d %03x\n", (int)dcrn, (int)dcrn);
-        }
+        qemu_log("DCR read error %d %03x\n", (int)dcrn, (int)dcrn);
         helper_raise_exception_err(POWERPC_EXCP_PROGRAM,
                                    POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);
     }
@@ -1888,15 +1875,11 @@
 void helper_store_dcr (target_ulong dcrn, target_ulong val)
 {
     if (unlikely(env->dcr_env == NULL)) {
-        if (loglevel != 0) {
-            fprintf(logfile, "No DCR environment\n");
-        }
+        qemu_log("No DCR environment\n");
         helper_raise_exception_err(POWERPC_EXCP_PROGRAM,
                                    POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL);
     } else if (unlikely(ppc_dcr_write(env->dcr_env, dcrn, val) != 0)) {
-        if (loglevel != 0) {
-            fprintf(logfile, "DCR write error %d %03x\n", (int)dcrn, (int)dcrn);
-        }
+        qemu_log("DCR write error %d %03x\n", (int)dcrn, (int)dcrn);
         helper_raise_exception_err(POWERPC_EXCP_PROGRAM,
                                    POWERPC_EXCP_INVAL | POWERPC_EXCP_PRIV_REG);
     }

Modified: trunk/target-ppc/translate.c
===================================================================

target-ppc/translate.c +21 -34

111 lines not on this page · raw message

Modified: trunk/target-sh4/helper.c
===================================================================

target-sh4/helper.c +3 -3
@@ -151,9 +151,9 @@
             expname = do_irq ? "interrupt" : "???";
             break;
 	}
-	fprintf(logfile, "exception 0x%03x [%s] raised\n",
-		irq_vector, expname);
-	cpu_dump_state(env, logfile, fprintf, 0);
+	qemu_log("exception 0x%03x [%s] raised\n",
+		  irq_vector, expname);
+	log_cpu_state(env, 0);
     }
 
     env->ssr = env->sr;

Modified: trunk/target-sh4/translate.c
===================================================================

target-sh4/translate.c +7 -10
@@ -1840,11 +1840,9 @@
     ctx.features = env->features;
 
 #ifdef DEBUG_DISAS
-    if (loglevel & CPU_LOG_TB_CPU) {
-	fprintf(logfile,
-		"------------------------------------------------\n");
-	cpu_dump_state(env, logfile, fprintf, 0);
-    }
+    qemu_log_mask(CPU_LOG_TB_CPU,
+                 "------------------------------------------------\n");
+    log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
 #endif
 
     ii = -1;
@@ -1937,13 +1935,12 @@
 
 #ifdef DEBUG_DISAS
 #ifdef SH4_DEBUG_DISAS
-    if (loglevel & CPU_LOG_TB_IN_ASM)
-	fprintf(logfile, "\n");
+    qemu_log_mask(CPU_LOG_TB_IN_ASM, "\n");
 #endif
     if (loglevel & CPU_LOG_TB_IN_ASM) {
-	fprintf(logfile, "IN:\n");	/* , lookup_symbol(pc_start)); */
-	target_disas(logfile, pc_start, ctx.pc - pc_start, 0);
-	fprintf(logfile, "\n");
+	qemu_log("IN:\n");	/* , lookup_symbol(pc_start)); */
+	log_target_disas(pc_start, ctx.pc - pc_start, 0);
+	qemu_log("\n");
     }
 #endif
 }

Modified: trunk/target-sparc/op_helper.c
===================================================================

target-sparc/op_helper.c +10 -10
@@ -2829,23 +2829,23 @@
                 name = "Unknown";
         }
 
-        fprintf(logfile, "%6d: %s (v=%04x) pc=%016" PRIx64 " npc=%016" PRIx64
+        qemu_log("%6d: %s (v=%04x) pc=%016" PRIx64 " npc=%016" PRIx64
                 " SP=%016" PRIx64 "\n",
                 count, name, intno,
                 env->pc,
                 env->npc, env->regwptr[6]);
-        cpu_dump_state(env, logfile, fprintf, 0);
+        log_cpu_state(env, 0);
 #if 0
         {
             int i;
             uint8_t *ptr;
 
-            fprintf(logfile, "       code=");
+            qemu_log("       code=");
             ptr = (uint8_t *)env->pc;
             for(i = 0; i < 16; i++) {
-                fprintf(logfile, " %02x", ldub(ptr + i));
+                qemu_log(" %02x", ldub(ptr + i));
             }
-            fprintf(logfile, "\n");
+            qemu_log("\n");
         }
 #endif
         count++;
@@ -2956,22 +2956,22 @@
                 name = "Unknown";
         }
 
-        fprintf(logfile, "%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n",
+        qemu_log("%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n",
                 count, name, intno,
                 env->pc,
                 env->npc, env->regwptr[6]);
-        cpu_dump_state(env, logfile, fprintf, 0);
+        log_cpu_state(env, 0);
 #if 0
         {
             int i;
             uint8_t *ptr;
 
-            fprintf(logfile, "       code=");
+            qemu_log("       code=");
             ptr = (uint8_t *)env->pc;
             for(i = 0; i < 16; i++) {
-                fprintf(logfile, " %02x", ldub(ptr + i));
+                qemu_log(" %02x", ldub(ptr + i));
             }
-            fprintf(logfile, "\n");
+            qemu_log("\n");
         }
 #endif
         count++;

Modified: trunk/target-sparc/translate.c
===================================================================

target-sparc/translate.c +6 -9
@@ -4829,8 +4829,7 @@
             }
         }
         if (spc) {
-            if (loglevel > 0)
-                fprintf(logfile, "Search PC...\n");
+            qemu_log("Search PC...\n");
             j = gen_opc_ptr - gen_opc_buf;
             if (lj < j) {
                 lj++;
@@ -4897,9 +4896,7 @@
         while (lj <= j)
             gen_opc_instr_start[lj++] = 0;
 #if 0
-        if (loglevel > 0) {
-            page_dump(logfile);
-        }
+        log_page_dump();
 #endif
         gen_opc_jump_pc[0] = dc->jump_pc[0];
         gen_opc_jump_pc[1] = dc->jump_pc[1];
@@ -4909,10 +4906,10 @@
     }
 #ifdef DEBUG_DISAS
     if (loglevel & CPU_LOG_TB_IN_ASM) {
-        fprintf(logfile, "--------------\n");
-        fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
-        target_disas(logfile, pc_start, last_pc + 4 - pc_start, 0);
-        fprintf(logfile, "\n");
+        qemu_log("--------------\n");
+        qemu_log("IN: %s\n", lookup_symbol(pc_start));
+        log_target_disas(pc_start, last_pc + 4 - pc_start, 0);
+        qemu_log("\n");
     }
 #endif
 }

Modified: trunk/tcg/tcg.c
===================================================================

tcg/tcg.c +4 -4
@@ -1879,9 +1879,9 @@
 
 #ifdef DEBUG_DISAS
     if (unlikely(loglevel & CPU_LOG_TB_OP)) {
-        fprintf(logfile, "OP:\n");
+        qemu_log("OP:\n");
         tcg_dump_ops(s, logfile);
-        fprintf(logfile, "\n");
+        qemu_log("\n");
     }
 #endif
 
@@ -1895,9 +1895,9 @@
 
 #ifdef DEBUG_DISAS
     if (unlikely(loglevel & CPU_LOG_TB_OP_OPT)) {
-        fprintf(logfile, "OP after la:\n");
+        qemu_log("OP after la:\n");
         tcg_dump_ops(s, logfile);
-        fprintf(logfile, "\n");
+        qemu_log("\n");
     }
 #endif
 

Modified: trunk/translate-all.c
===================================================================

translate-all.c +3 -3
@@ -128,9 +128,9 @@
 
 #ifdef DEBUG_DISAS
     if (loglevel & CPU_LOG_TB_OUT_ASM) {
-        fprintf(logfile, "OUT: [size=%d]\n", *gen_code_size_ptr);
-        disas(logfile, tb->tc_ptr, *gen_code_size_ptr);
-        fprintf(logfile, "\n");
+        qemu_log("OUT: [size=%d]\n", *gen_code_size_ptr);
+        log_disas(tb->tc_ptr, *gen_code_size_ptr);
+        qemu_log("\n");
         fflush(logfile);
     }
 #endif

Modified: trunk/vl.c
===================================================================

vl.c +1 -4
@@ -156,10 +156,7 @@
 
 
 #ifdef DEBUG_IOPORT
-#  define LOG_IOPORT(...) do {           \
-     if (loglevel & CPU_LOG_IOPORT)      \
-       fprintf(logfile, ## __VA_ARGS__); \
-   } while (0)
+#  define LOG_IOPORT(...) qemu_log_mask(CPU_LOG_IOPORT, ## __VA_ARGS__)
 #else
 #  define LOG_IOPORT(...) do { } while (0)
 #endif
#1 lore raw
Quoted 41 lines

Modified: trunk/linux-user/main.c
===================================================================

linux-user/main.c +7 -18
@@ -1057,10 +1057,8 @@
 do {                                                                          \
     fprintf(stderr, fmt , ##args);                                            \
     cpu_dump_state(env, stderr, fprintf, 0);                                  \
-    if (loglevel != 0) {                                                      \
-        fprintf(logfile, fmt , ##args);                                       \
-        cpu_dump_state(env, logfile, fprintf, 0);                             \
-    }                                                                         \
+    qemu_log(fmt, ##args);                                                   \
+    log_cpu_state(env, 0);                                                      \
 } while (0)
 
 void cpu_loop(CPUPPCState *env)
@@ -2396,21 +2394,19 @@
 
     free(target_environ);
 
-    if (loglevel) {
-        page_dump(logfile);
+    log_page_dump();
 
-        fprintf(logfile, "start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
-        fprintf(logfile, "end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
-        fprintf(logfile, "start_code  0x" TARGET_ABI_FMT_lx "\n",
-                info->start_code);
-        fprintf(logfile, "start_data  0x" TARGET_ABI_FMT_lx "\n",
-                info->start_data);
-        fprintf(logfile, "end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
-        fprintf(logfile, "start_stack 0x" TARGET_ABI_FMT_lx "\n",
-                info->start_stack);
-        fprintf(logfile, "brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
-        fprintf(logfile, "entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
-    }
+    qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
+    qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
+    qemu_log("start_code  0x" TARGET_ABI_FMT_lx "\n",
+            info->start_code);

linux-user/main.c line 2412

Quoted 10 lines
linux-user/main.c +7 -0
+    qemu_log("start_data  0x" TARGET_ABI_FMT_lx "\n",
+            info->start_data);
+    qemu_log("end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
+    qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n",
+            info->start_stack);
+    qemu_log("brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
+    qemu_log("entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
 
     target_set_brk(info->brk);
     syscall_init();

This breaks linux-user when called without -d option. The attached patch fixes it for me(tm).

Quoted 1 line

From 1b31992e04e8006fb0087d25b186800f48babbe0 Mon Sep 17 00:00:00 2001

From: Riku Voipio <[email protected]>
Date: Tue, 20 Jan 2009 17:22:07 +0200
Subject: [PATCH] linux-user: fix breakage from r6338

log_page_dump() will segfault is logfile is NULL.

---
 linux-user/main.c |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)
linux-user/main.c +16 -13
index 5685b37..59da5fd 100644
@@ -2394,19 +2394,22 @@ int main(int argc, char **argv, char **envp)
 
     free(target_environ);
 
-    log_page_dump();
-
-    qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
-    qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
-    qemu_log("start_code  0x" TARGET_ABI_FMT_lx "\n",
-            info->start_code);
-    qemu_log("start_data  0x" TARGET_ABI_FMT_lx "\n",
-            info->start_data);
-    qemu_log("end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
-    qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n",
-            info->start_stack);
-    qemu_log("brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
-    qemu_log("entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
+    if(qemu_log_enabled())
+    {
+        log_page_dump();
+
+        qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
+        qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
+        qemu_log("start_code  0x" TARGET_ABI_FMT_lx "\n",
+                info->start_code);
+        qemu_log("start_data  0x" TARGET_ABI_FMT_lx "\n",
+                info->start_data);
+        qemu_log("end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
+        qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n",
+                info->start_stack);
+        qemu_log("brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
+        qemu_log("entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
+    }
 
     target_set_brk(info->brk);
     syscall_init();
Signature · 1 line
1.5.6.3
Applied
#2 lore raw
Quoted 49 lines · Riku Voipio
Quoted 49 lines

Modified: trunk/linux-user/main.c
===================================================================

linux-user/main.c 2009-01-15 22:34:14 UTC (rev 6338) renamed from linux-user/main.c 2009-01-15 22:17:38 UTC (rev 6337) +14 -18
@@ -1057,10 +1057,8 @@
 do {                                                                          \
     fprintf(stderr, fmt , ##args);                                            \
     cpu_dump_state(env, stderr, fprintf, 0);                                  \
-    if (loglevel != 0) {                                                      \
-        fprintf(logfile, fmt , ##args);                                       \
-        cpu_dump_state(env, logfile, fprintf, 0);                             \
-    }                                                                         \
+    qemu_log(fmt, ##args);                                                   \
+    log_cpu_state(env, 0);                                                      \
 } while (0)
 
 void cpu_loop(CPUPPCState *env)
@@ -2396,21 +2394,19 @@
 
     free(target_environ);
 
-    if (loglevel) {
-        page_dump(logfile);
+    log_page_dump();
 
-        fprintf(logfile, "start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
-        fprintf(logfile, "end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
-        fprintf(logfile, "start_code  0x" TARGET_ABI_FMT_lx "\n",
-                info->start_code);
-        fprintf(logfile, "start_data  0x" TARGET_ABI_FMT_lx "\n",
-                info->start_data);
-        fprintf(logfile, "end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
-        fprintf(logfile, "start_stack 0x" TARGET_ABI_FMT_lx "\n",
-                info->start_stack);
-        fprintf(logfile, "brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
-        fprintf(logfile, "entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
-    }
+    qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
+    qemu_log("end_code    0x" TARGET_ABI_FMT_lx "\n", info->end_code);
+    qemu_log("start_code  0x" TARGET_ABI_FMT_lx "\n",
+            info->start_code);
+    qemu_log("start_data  0x" TARGET_ABI_FMT_lx "\n",
+            info->start_data);
+    qemu_log("end_data    0x" TARGET_ABI_FMT_lx "\n", info->end_data);
+    qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n",
+            info->start_stack);
+    qemu_log("brk         0x" TARGET_ABI_FMT_lx "\n", info->brk);
+    qemu_log("entry       0x" TARGET_ABI_FMT_lx "\n", info->entry);
 
Quoted 6 lines

linux-user/main.c 2009-01-15 22:34:14 UTC (rev 6338) line 2412

Quoted 2 lines
linux-user/main.c 2009-01-15 22:34:14 UTC (rev 6338) renamed from linux-user/main.c 2009-01-15 22:17:38 UTC (rev 6337) +0 -0
     target_set_brk(info->brk);
     syscall_init();

This breaks linux-user when called without -d option. The attached patch
fixes it for me(tm).

Thanks, applied. I also fixed bsd-user.