All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions
@ 2010-10-22 21:03 Stefan Weil
  2010-10-22 21:03 ` [Qemu-devel] [PATCH 2/4] tcg: Use fprintf_function (format checking) Stefan Weil
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Stefan Weil @ 2010-10-22 21:03 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

This kind of function pointers is used very often in qemu.

The new data type uses format checking with GCC_FMT_ATTR
and will be used in later patches.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 qemu-common.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/qemu-common.h b/qemu-common.h
index d5ae420..7eeec8e 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -81,6 +81,9 @@ struct iovec {
 #define GCC_FMT_ATTR(n, m)
 #endif
 
+typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
+    GCC_FMT_ATTR(2, 3);
+
 #ifdef _WIN32
 #define fsync _commit
 #define lseek _lseeki64
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH 2/4] tcg: Use fprintf_function (format checking)
  2010-10-22 21:03 [Qemu-devel] [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions Stefan Weil
@ 2010-10-22 21:03 ` Stefan Weil
  2010-10-22 21:03 ` [Qemu-devel] [PATCH 3/4] exec: Use fprintf_function for dump_exec_info " Stefan Weil
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Stefan Weil @ 2010-10-22 21:03 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

fprintf_function uses format checking with GCC_FMT_ATTR.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 tcg/tcg.c |    6 ++----
 tcg/tcg.h |    3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/tcg/tcg.c b/tcg/tcg.c
index 0cdef0d..5dd6a2c 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2124,8 +2124,7 @@ int tcg_gen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset)
 }
 
 #ifdef CONFIG_PROFILER
-void tcg_dump_info(FILE *f,
-                   int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf)
 {
     TCGContext *s = &tcg_ctx;
     int64_t tot;
@@ -2169,8 +2168,7 @@ void tcg_dump_info(FILE *f,
     dump_op_count();
 }
 #else
-void tcg_dump_info(FILE *f,
-                   int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf)
 {
     cpu_fprintf(f, "[TCG profiler not compiled]\n");
 }
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 972df72..e1afde2 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -392,8 +392,7 @@ static inline TCGv_i64 tcg_temp_local_new_i64(void)
 void tcg_temp_free_i64(TCGv_i64 arg);
 char *tcg_get_arg_str_i64(TCGContext *s, char *buf, int buf_size, TCGv_i64 arg);
 
-void tcg_dump_info(FILE *f,
-                   int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf);
 
 #define TCG_CT_ALIAS  0x80
 #define TCG_CT_IALIAS 0x40
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH 3/4] exec: Use fprintf_function for dump_exec_info (format checking)
  2010-10-22 21:03 [Qemu-devel] [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions Stefan Weil
  2010-10-22 21:03 ` [Qemu-devel] [PATCH 2/4] tcg: Use fprintf_function (format checking) Stefan Weil
@ 2010-10-22 21:03 ` Stefan Weil
  2010-10-22 21:03 ` [Qemu-devel] [PATCH 4/4] target-xxx: Use fprintf_function " Stefan Weil
  2010-10-30  9:23 ` [Qemu-devel] Re: [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions Blue Swirl
  3 siblings, 0 replies; 13+ messages in thread
From: Stefan Weil @ 2010-10-22 21:03 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

fprintf_function uses format checking with GCC_FMT_ATTR.

It is declared in qemu-common.h and used in cpu-all.h
(which is included from cpu.h), so qemu-common.h must
be included earlier. Some redundant include statements
for standard include files were removed.

Fix also two format errors (ptrdiff_t needs %td).

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 cpu-all.h |    3 +--
 exec.c    |   16 ++++------------
 2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 11edddc..ba9d766 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -959,8 +959,7 @@ int cpu_physical_memory_get_dirty_tracking(void);
 int cpu_physical_sync_dirty_bitmap(target_phys_addr_t start_addr,
                                    target_phys_addr_t end_addr);
 
-void dump_exec_info(FILE *f,
-                    int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+void dump_exec_info(FILE *f, fprintf_function cpu_fprintf);
 #endif /* !CONFIG_USER_ONLY */
 
 int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
diff --git a/exec.c b/exec.c
index 631d8c5..db9ff55 100644
--- a/exec.c
+++ b/exec.c
@@ -23,17 +23,10 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <inttypes.h>
 
+#include "qemu-common.h"
 #include "cpu.h"
 #include "exec-all.h"
-#include "qemu-common.h"
 #include "tcg.h"
 #include "hw/hw.h"
 #include "hw/qdev.h"
@@ -4096,8 +4089,7 @@ void cpu_io_recompile(CPUState *env, void *retaddr)
 
 #if !defined(CONFIG_USER_ONLY)
 
-void dump_exec_info(FILE *f,
-                    int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void dump_exec_info(FILE *f, fprintf_function cpu_fprintf)
 {
     int i, target_code_size, max_target_code_size;
     int direct_jmp_count, direct_jmp2_count, cross_page;
@@ -4124,14 +4116,14 @@ void dump_exec_info(FILE *f,
     }
     /* XXX: avoid using doubles ? */
     cpu_fprintf(f, "Translation buffer state:\n");
-    cpu_fprintf(f, "gen code size       %ld/%ld\n",
+    cpu_fprintf(f, "gen code size       %td/%ld\n",
                 code_gen_ptr - code_gen_buffer, code_gen_buffer_max_size);
     cpu_fprintf(f, "TB count            %d/%d\n", 
                 nb_tbs, code_gen_max_blocks);
     cpu_fprintf(f, "TB avg target size  %d max=%d bytes\n",
                 nb_tbs ? target_code_size / nb_tbs : 0,
                 max_target_code_size);
-    cpu_fprintf(f, "TB avg host size    %d bytes (expansion ratio: %0.1f)\n",
+    cpu_fprintf(f, "TB avg host size    %td bytes (expansion ratio: %0.1f)\n",
                 nb_tbs ? (code_gen_ptr - code_gen_buffer) / nb_tbs : 0,
                 target_code_size ? (double) (code_gen_ptr - code_gen_buffer) / target_code_size : 0);
     cpu_fprintf(f, "cross page TB count %d (%d%%)\n",
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
  2010-10-22 21:03 [Qemu-devel] [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions Stefan Weil
  2010-10-22 21:03 ` [Qemu-devel] [PATCH 2/4] tcg: Use fprintf_function (format checking) Stefan Weil
  2010-10-22 21:03 ` [Qemu-devel] [PATCH 3/4] exec: Use fprintf_function for dump_exec_info " Stefan Weil
@ 2010-10-22 21:03 ` Stefan Weil
  2010-11-01  2:24   ` TeLeMan
  2010-10-30  9:23 ` [Qemu-devel] Re: [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions Blue Swirl
  3 siblings, 1 reply; 13+ messages in thread
From: Stefan Weil @ 2010-10-22 21:03 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

fprintf_function uses format checking with GCC_FMT_ATTR.

Format errors were fixed in
* target-i386/helper.c
* target-mips/translate.c
* target-ppc/translate.c

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 cpu-all.h                     |    8 +++-----
 cpus.c                        |    3 +--
 cpus.h                        |    3 +--
 target-alpha/helper.c         |    3 +--
 target-arm/cpu.h              |    4 +++-
 target-arm/helper.c           |    2 +-
 target-arm/translate.c        |    3 +--
 target-cris/cpu.h             |    2 +-
 target-cris/translate.c       |    5 ++---
 target-i386/cpu.h             |    4 ++--
 target-i386/cpuid.c           |    3 +--
 target-i386/helper.c          |   14 +++++++-------
 target-m68k/cpu.h             |    3 ++-
 target-m68k/helper.c          |    2 +-
 target-m68k/translate.c       |    3 +--
 target-microblaze/translate.c |    3 +--
 target-mips/cpu.h             |    3 ++-
 target-mips/translate.c       |   12 +++++-------
 target-mips/translate_init.c  |    2 +-
 target-ppc/cpu.h              |    4 ++--
 target-ppc/translate.c        |   14 ++++++--------
 target-ppc/translate_init.c   |    2 +-
 target-s390x/translate.c      |    3 +--
 target-sh4/cpu.h              |    3 ++-
 target-sh4/translate.c        |    2 +-
 target-sparc/helper.c         |   11 ++++-------
 26 files changed, 54 insertions(+), 67 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index ba9d766..30ae17d 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -765,12 +765,10 @@ int page_check_range(target_ulong start, target_ulong len, int flags);
 CPUState *cpu_copy(CPUState *env);
 CPUState *qemu_get_cpu(int cpu);
 
-void cpu_dump_state(CPUState *env, FILE *f,
-                    int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                     int flags);
-void cpu_dump_statistics (CPUState *env, FILE *f,
-                          int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
-                          int flags);
+void cpu_dump_statistics(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
+                         int flags);
 
 void QEMU_NORETURN cpu_abort(CPUState *env, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
diff --git a/cpus.c b/cpus.c
index 36a6d1f..91a0fb1 100644
--- a/cpus.c
+++ b/cpus.c
@@ -978,8 +978,7 @@ int64_t cpu_get_icount(void)
     return qemu_icount_bias + (icount << icount_time_shift);
 }
 
-void list_cpus(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
-               const char *optarg)
+void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg)
 {
     /* XXX: implement xxx_cpu_list for targets that still miss it */
 #if defined(cpu_list_id)
diff --git a/cpus.h b/cpus.h
index af267ea..bf4d9bb 100644
--- a/cpus.h
+++ b/cpus.h
@@ -16,7 +16,6 @@ void vm_state_notify(int running, int reason);
 bool cpu_exec_all(void);
 void set_numa_modes(void);
 void set_cpu_log(const char *optarg);
-void list_cpus(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
-               const char *optarg);
+void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg);
 
 #endif
diff --git a/target-alpha/helper.c b/target-alpha/helper.c
index b6d2160..3ba4478 100644
--- a/target-alpha/helper.c
+++ b/target-alpha/helper.c
@@ -537,8 +537,7 @@ void do_interrupt (CPUState *env)
 }
 #endif
 
-void cpu_dump_state (CPUState *env, FILE *f,
-                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                      int flags)
 {
     static const char *linux_reg_names[] = {
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 39c4a0e..b87c605 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -25,6 +25,8 @@
 
 #define CPUState struct CPUARMState
 
+#include "config.h"
+#include "qemu-common.h"
 #include "cpu-defs.h"
 
 #include "softfloat.h"
@@ -353,7 +355,7 @@ static inline int arm_feature(CPUARMState *env, int feature)
     return (env->features & (1u << feature)) != 0;
 }
 
-void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 
 /* Interface between CPU and Interrupt controller.  */
 void armv7m_nvic_set_pending(void *opaque, int irq);
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 2dd64d9..996d40d 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -348,7 +348,7 @@ static const struct arm_cpu_t arm_cpu_names[] = {
     { 0, NULL}
 };
 
-void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
     int i;
 
diff --git a/target-arm/translate.c b/target-arm/translate.c
index 6fcdd7e..99464ab 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -9262,8 +9262,7 @@ static const char *cpu_mode_names[16] = {
   "???", "???", "???", "und", "???", "???", "???", "sys"
 };
 
-void cpu_dump_state(CPUState *env, FILE *f,
-                    int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                     int flags)
 {
     int i;
diff --git a/target-cris/cpu.h b/target-cris/cpu.h
index e1d48ed..d908775 100644
--- a/target-cris/cpu.h
+++ b/target-cris/cpu.h
@@ -263,6 +263,6 @@ static inline void cpu_get_tb_cpu_state(CPUState *env, target_ulong *pc,
 }
 
 #define cpu_list cris_cpu_list
-void cris_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+void cris_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 
 #endif
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 8361369..4e4606c 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3426,8 +3426,7 @@ void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
     gen_intermediate_code_internal(env, tb, 1);
 }
 
-void cpu_dump_state (CPUState *env, FILE *f,
-                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                      int flags)
 {
 	int i;
@@ -3480,7 +3479,7 @@ struct
 	{32, "crisv32"},
 };
 
-void cris_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void cris_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
     unsigned int i;
 
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 85ed30f..2440d65 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -20,6 +20,7 @@
 #define CPU_I386_H
 
 #include "config.h"
+#include "qemu-common.h"
 
 #ifdef TARGET_X86_64
 #define TARGET_LONG_BITS 64
@@ -756,8 +757,7 @@ typedef struct CPUX86State {
 CPUX86State *cpu_x86_init(const char *cpu_model);
 int cpu_x86_exec(CPUX86State *s);
 void cpu_x86_close(CPUX86State *s);
-void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
-                   const char *optarg);
+void x86_cpu_list (FILE *f, fprintf_function cpu_fprintf, const char *optarg);
 void x86_cpudef_setup(void);
 
 int cpu_get_pic_interrupt(CPUX86State *s);
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index 0e0bf60..650a719 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -762,8 +762,7 @@ static void listflags(char *buf, int bufsize, uint32_t fbits,
  * -?dump    output all model (x86_def_t) data
  * -?cpuid   list all recognized cpuid flag names
  */
-void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
-                  const char *optarg)
+void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf, const char *optarg)
 {
     unsigned char model = !strcmp("?model", optarg);
     unsigned char dump = !strcmp("?dump", optarg);
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 4fff4a8..26ea1e5 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -169,8 +169,7 @@ static const char *cc_op_str[] = {
 };
 
 static void
-cpu_x86_dump_seg_cache(CPUState *env, FILE *f,
-                       int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+cpu_x86_dump_seg_cache(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                        const char *name, struct SegmentCache *sc)
 {
 #ifdef TARGET_X86_64
@@ -224,8 +223,7 @@ done:
     cpu_fprintf(f, "\n");
 }
 
-void cpu_dump_state(CPUState *env, FILE *f,
-                    int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                     int flags)
 {
     int eflags, i, nb;
@@ -335,9 +333,11 @@ void cpu_dump_state(CPUState *env, FILE *f,
                     (uint32_t)env->cr[2],
                     (uint32_t)env->cr[3],
                     (uint32_t)env->cr[4]);
-        for(i = 0; i < 4; i++)
-            cpu_fprintf(f, "DR%d=%08x ", i, env->dr[i]);
-        cpu_fprintf(f, "\nDR6=%08x DR7=%08x\n", env->dr[6], env->dr[7]);
+        for(i = 0; i < 4; i++) {
+            cpu_fprintf(f, "DR%d=" TARGET_FMT_lx " ", i, env->dr[i]);
+        }
+        cpu_fprintf(f, "\nDR6=" TARGET_FMT_lx " DR7=" TARGET_FMT_lx "\n",
+                    env->dr[6], env->dr[7]);
     }
     if (flags & X86_DUMP_CCOP) {
         if ((unsigned)env->cc_op < CC_OP_NB)
diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h
index 33c41b2..b025b66 100644
--- a/target-m68k/cpu.h
+++ b/target-m68k/cpu.h
@@ -24,6 +24,7 @@
 
 #define CPUState struct CPUM68KState
 
+#include "qemu-common.h"
 #include "cpu-defs.h"
 
 #include "softfloat.h"
@@ -198,7 +199,7 @@ static inline int m68k_feature(CPUM68KState *env, int feature)
     return (env->features & (1u << feature)) != 0;
 }
 
-void m68k_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 
 void register_m68k_insns (CPUM68KState *env);
 
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index b4ebb14..56de897 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -53,7 +53,7 @@ static m68k_def_t m68k_cpu_defs[] = {
     {NULL, 0},
 };
 
-void m68k_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
     unsigned int i;
 
diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index 5351880..6f72a2b 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -3092,8 +3092,7 @@ void gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
     gen_intermediate_code_internal(env, tb, 1);
 }
 
-void cpu_dump_state(CPUState *env, FILE *f,
-                    int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                     int flags)
 {
     int i;
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index 38149bb..1ada15e 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -1534,8 +1534,7 @@ void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
     gen_intermediate_code_internal(env, tb, 1);
 }
 
-void cpu_dump_state (CPUState *env, FILE *f,
-                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                      int flags)
 {
     int i;
diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index 19511d7..c1f211f 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -8,6 +8,7 @@
 #define CPUState struct CPUMIPSState
 
 #include "config.h"
+#include "qemu-common.h"
 #include "mips-defs.h"
 #include "cpu-defs.h"
 #include "softfloat.h"
@@ -496,7 +497,7 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,
                           int unused, int size);
 #endif
 
-void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 
 #define cpu_init cpu_mips_init
 #define cpu_exec cpu_mips_exec
diff --git a/target-mips/translate.c b/target-mips/translate.c
index d62c615..ba45eb0 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -12450,8 +12450,7 @@ void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)
     gen_intermediate_code_internal(env, tb, 1);
 }
 
-static void fpu_dump_state(CPUState *env, FILE *f,
-                           int (*fpu_fprintf)(FILE *f, const char *fmt, ...),
+static void fpu_dump_state(CPUState *env, FILE *f, fprintf_function fpu_fprintf,
                            int flags)
 {
     int i;
@@ -12480,8 +12479,8 @@ static void fpu_dump_state(CPUState *env, FILE *f,
     } while(0)
 
 
-    fpu_fprintf(f, "CP1 FCR0 0x%08x  FCR31 0x%08x  SR.FR %d  fp_status 0x%08x(0x%02x)\n",
-                env->active_fpu.fcr0, env->active_fpu.fcr31, is_fpu64, env->active_fpu.fp_status,
+    fpu_fprintf(f, "CP1 FCR0 0x%08x  FCR31 0x%08x  SR.FR %d  fp_status 0x%02x\n",
+                env->active_fpu.fcr0, env->active_fpu.fcr31, is_fpu64,
                 get_float_exception_flags(&env->active_fpu.fp_status));
     for (i = 0; i < 32; (is_fpu64) ? i++ : (i += 2)) {
         fpu_fprintf(f, "%3s: ", fregnames[i]);
@@ -12499,7 +12498,7 @@ static void fpu_dump_state(CPUState *env, FILE *f,
 
 static void
 cpu_mips_check_sign_extensions (CPUState *env, FILE *f,
-                                int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+                                fprintf_function cpu_fprintf,
                                 int flags)
 {
     int i;
@@ -12525,8 +12524,7 @@ cpu_mips_check_sign_extensions (CPUState *env, FILE *f,
 }
 #endif
 
-void cpu_dump_state (CPUState *env, FILE *f,
-                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                      int flags)
 {
     int i;
diff --git a/target-mips/translate_init.c b/target-mips/translate_init.c
index 8d1ece7..590e092 100644
--- a/target-mips/translate_init.c
+++ b/target-mips/translate_init.c
@@ -500,7 +500,7 @@ static const mips_def_t *cpu_mips_find_by_name (const char *name)
     return NULL;
 }
 
-void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf)
 {
     int i;
 
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 1334dd1..deb8d7c 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -20,7 +20,7 @@
 #define __CPU_PPC_H__
 
 #include "config.h"
-#include <inttypes.h>
+#include "qemu-common.h"
 
 //#define PPC_EMULATE_32BITS_HYPV
 
@@ -761,7 +761,7 @@ void ppc_store_sr (CPUPPCState *env, int srnum, target_ulong value);
 #endif /* !defined(CONFIG_USER_ONLY) */
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
 
-void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 
 const ppc_def_t *cpu_ppc_find_by_name (const char *name);
 int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def);
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index fd06861..c82a483 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -8830,8 +8830,7 @@ GEN_SPEOP_LDST(evstwwo, 0x1E, 2),
 
 /*****************************************************************************/
 /* Misc PowerPC helpers */
-void cpu_dump_state (CPUState *env, FILE *f,
-                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state (CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                      int flags)
 {
 #define RGPL  4
@@ -8840,15 +8839,15 @@ void cpu_dump_state (CPUState *env, FILE *f,
     int i;
 
     cpu_fprintf(f, "NIP " TARGET_FMT_lx "   LR " TARGET_FMT_lx " CTR "
-                TARGET_FMT_lx " XER %08x\n", env->nip, env->lr, env->ctr,
-                env->xer);
+                TARGET_FMT_lx " XER " TARGET_FMT_lx "\n",
+                env->nip, env->lr, env->ctr, env->xer);
     cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx "  HF "
                 TARGET_FMT_lx " idx %d\n", env->msr, env->spr[SPR_HID0],
                 env->hflags, env->mmu_idx);
 #if !defined(NO_TIMER_DUMP)
-    cpu_fprintf(f, "TB %08x %08x "
+    cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64
 #if !defined(CONFIG_USER_ONLY)
-                "DECR %08x"
+                " DECR %08" PRIu32
 #endif
                 "\n",
                 cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env)
@@ -8898,8 +8897,7 @@ void cpu_dump_state (CPUState *env, FILE *f,
 #undef RFPL
 }
 
-void cpu_dump_statistics (CPUState *env, FILE*f,
-                          int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_statistics (CPUState *env, FILE*f, fprintf_function cpu_fprintf,
                           int flags)
 {
 #if defined(DO_PPC_STATISTICS)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 05ffe95..dfcd949 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9756,7 +9756,7 @@ const ppc_def_t *cpu_ppc_find_by_name (const char *name)
     return ret;
 }
 
-void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf)
 {
     int i, max;
 
diff --git a/target-s390x/translate.c b/target-s390x/translate.c
index 44dfa65..881d8c4 100644
--- a/target-s390x/translate.c
+++ b/target-s390x/translate.c
@@ -23,8 +23,7 @@
 #include "tcg-op.h"
 #include "qemu-log.h"
 
-void cpu_dump_state(CPUState *env, FILE *f,
-                    int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                     int flags)
 {
     int i;
diff --git a/target-sh4/cpu.h b/target-sh4/cpu.h
index 64a609b..e197766 100644
--- a/target-sh4/cpu.h
+++ b/target-sh4/cpu.h
@@ -20,6 +20,7 @@
 #define _CPU_SH4_H
 
 #include "config.h"
+#include "qemu-common.h"
 
 #define TARGET_LONG_BITS 32
 #define TARGET_HAS_ICE 1
@@ -168,7 +169,7 @@ int cpu_sh4_handle_mmu_fault(CPUSH4State * env, target_ulong address, int rw,
 #define cpu_handle_mmu_fault cpu_sh4_handle_mmu_fault
 void do_interrupt(CPUSH4State * env);
 
-void sh4_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 #if !defined(CONFIG_USER_ONLY)
 void cpu_sh4_invalidate_tlb(CPUSH4State *s);
 void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, target_phys_addr_t addr,
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index deee939..f418139 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -257,7 +257,7 @@ static const sh4_def_t *cpu_sh4_find_by_name(const char *name)
     return NULL;
 }
 
-void sh4_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
     int i;
 
diff --git a/target-sparc/helper.c b/target-sparc/helper.c
index aa1fd63..e84c312 100644
--- a/target-sparc/helper.c
+++ b/target-sparc/helper.c
@@ -1323,8 +1323,7 @@ static const char * const feature_name[] = {
     "gl",
 };
 
-static void print_features(FILE *f,
-                           int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+static void print_features(FILE *f, fprintf_function cpu_fprintf,
                            uint32_t features, const char *prefix)
 {
     unsigned int i;
@@ -1452,7 +1451,7 @@ static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model)
     return -1;
 }
 
-void sparc_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
+void sparc_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
     unsigned int i;
 
@@ -1479,8 +1478,7 @@ void sparc_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
                    "fpu_version mmu_version nwindows\n");
 }
 
-static void cpu_print_cc(FILE *f,
-                         int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+static void cpu_print_cc(FILE *f, fprintf_function cpu_fprintf,
                          uint32_t cc)
 {
     cpu_fprintf(f, "%c%c%c%c", cc & PSR_NEG? 'N' : '-',
@@ -1494,8 +1492,7 @@ static void cpu_print_cc(FILE *f,
 #define REGS_PER_LINE 8
 #endif
 
-void cpu_dump_state(CPUState *env, FILE *f,
-                    int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
+void cpu_dump_state(CPUState *env, FILE *f, fprintf_function cpu_fprintf,
                     int flags)
 {
     int i, x;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions
  2010-10-22 21:03 [Qemu-devel] [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions Stefan Weil
                   ` (2 preceding siblings ...)
  2010-10-22 21:03 ` [Qemu-devel] [PATCH 4/4] target-xxx: Use fprintf_function " Stefan Weil
@ 2010-10-30  9:23 ` Blue Swirl
  3 siblings, 0 replies; 13+ messages in thread
From: Blue Swirl @ 2010-10-30  9:23 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

Thanks, applied all.

On Fri, Oct 22, 2010 at 9:03 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> This kind of function pointers is used very often in qemu.
>
> The new data type uses format checking with GCC_FMT_ATTR
> and will be used in later patches.
>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  qemu-common.h |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-common.h b/qemu-common.h
> index d5ae420..7eeec8e 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -81,6 +81,9 @@ struct iovec {
>  #define GCC_FMT_ATTR(n, m)
>  #endif
>
> +typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
> +    GCC_FMT_ATTR(2, 3);
> +
>  #ifdef _WIN32
>  #define fsync _commit
>  #define lseek _lseeki64
> --
> 1.7.1
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
  2010-10-22 21:03 ` [Qemu-devel] [PATCH 4/4] target-xxx: Use fprintf_function " Stefan Weil
@ 2010-11-01  2:24   ` TeLeMan
  2010-11-01  7:05     ` Stefan Weil
  0 siblings, 1 reply; 13+ messages in thread
From: TeLeMan @ 2010-11-01  2:24 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Blue Swirl, QEMU Developers

On Sat, Oct 23, 2010 at 05:03, Stefan Weil <weil@mail.berlios.de> wrote:
>     int eflags, i, nb;
> @@ -335,9 +333,11 @@ void cpu_dump_state(CPUState *env, FILE *f,
>                     (uint32_t)env->cr[2],
>                     (uint32_t)env->cr[3],
>                     (uint32_t)env->cr[4]);
> -        for(i = 0; i < 4; i++)
> -            cpu_fprintf(f, "DR%d=%08x ", i, env->dr[i]);
> -        cpu_fprintf(f, "\nDR6=%08x DR7=%08x\n", env->dr[6], env->dr[7]);
> +        for(i = 0; i < 4; i++) {
> +            cpu_fprintf(f, "DR%d=" TARGET_FMT_lx " ", i, env->dr[i]);
> +        }
> +        cpu_fprintf(f, "\nDR6=" TARGET_FMT_lx " DR7=" TARGET_FMT_lx "\n",
> +                    env->dr[6], env->dr[7]);
>     }
I think this patch is not right. Outputting 64bits data is not
necessary on 32bits mode.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
  2010-11-01  2:24   ` TeLeMan
@ 2010-11-01  7:05     ` Stefan Weil
  2010-11-01  9:50       ` TeLeMan
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Weil @ 2010-11-01  7:05 UTC (permalink / raw)
  To: TeLeMan; +Cc: Blue Swirl, QEMU Developers

Am 01.11.2010 03:24, schrieb TeLeMan:
> On Sat, Oct 23, 2010 at 05:03, Stefan Weil <weil@mail.berlios.de> wrote:
>>     int eflags, i, nb;
>> @@ -335,9 +333,11 @@ void cpu_dump_state(CPUState *env, FILE *f,
>>                     (uint32_t)env->cr[2],
>>                     (uint32_t)env->cr[3],
>>                     (uint32_t)env->cr[4]);
>> -        for(i = 0; i < 4; i++)
>> -            cpu_fprintf(f, "DR%d=%08x ", i, env->dr[i]);
>> -        cpu_fprintf(f, "\nDR6=%08x DR7=%08x\n", env->dr[6], env->dr[7]);
>> +        for(i = 0; i < 4; i++) {
>> +            cpu_fprintf(f, "DR%d=" TARGET_FMT_lx " ", i, env->dr[i]);
>> +        }
>> +        cpu_fprintf(f, "\nDR6=" TARGET_FMT_lx " DR7=" TARGET_FMT_lx 
>> "\n",
>> +                    env->dr[6], env->dr[7]);
>>     }
> I think this patch is not right. Outputting 64bits data is not
> necessary on 32bits mode.

Do you speak of 32 bit hosts or 32 bit targets?

dr is of type target_ulong, so its size depends on the target's
word size. TARGET_FMT_lx is the correct format specifier
for target_ulong.

What would you propose?

Cheers,
Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
  2010-11-01  7:05     ` Stefan Weil
@ 2010-11-01  9:50       ` TeLeMan
  2010-11-01 10:14         ` [Qemu-devel] " Paolo Bonzini
  0 siblings, 1 reply; 13+ messages in thread
From: TeLeMan @ 2010-11-01  9:50 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Blue Swirl, QEMU Developers

--
SUN OF A BEACH



On Mon, Nov 1, 2010 at 15:05, Stefan Weil <weil@mail.berlios.de> wrote:
> Am 01.11.2010 03:24, schrieb TeLeMan:
>>
>> On Sat, Oct 23, 2010 at 05:03, Stefan Weil <weil@mail.berlios.de> wrote:
>>>
>>>    int eflags, i, nb;
>>> @@ -335,9 +333,11 @@ void cpu_dump_state(CPUState *env, FILE *f,
>>>                    (uint32_t)env->cr[2],
>>>                    (uint32_t)env->cr[3],
>>>                    (uint32_t)env->cr[4]);
>>> -        for(i = 0; i < 4; i++)
>>> -            cpu_fprintf(f, "DR%d=%08x ", i, env->dr[i]);
>>> -        cpu_fprintf(f, "\nDR6=%08x DR7=%08x\n", env->dr[6], env->dr[7]);
>>> +        for(i = 0; i < 4; i++) {
>>> +            cpu_fprintf(f, "DR%d=" TARGET_FMT_lx " ", i, env->dr[i]);
>>> +        }
>>> +        cpu_fprintf(f, "\nDR6=" TARGET_FMT_lx " DR7=" TARGET_FMT_lx
>>> "\n",
>>> +                    env->dr[6], env->dr[7]);
>>>    }
>>
>> I think this patch is not right. Outputting 64bits data is not
>> necessary on 32bits mode.
>
> Do you speak of 32 bit hosts or 32 bit targets?
32bit mode of x64

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
  2010-11-01  9:50       ` TeLeMan
@ 2010-11-01 10:14         ` Paolo Bonzini
  2010-11-01 10:20           ` Paolo Bonzini
       [not found]           ` <AANLkTino2N6qxYxwXu1cLn=oVanETcqOjthfX7qr4_Dh@mail.gmail.com>
  0 siblings, 2 replies; 13+ messages in thread
From: Paolo Bonzini @ 2010-11-01 10:14 UTC (permalink / raw)
  To: TeLeMan; +Cc: Blue Swirl, QEMU Developers

On 11/01/2010 10:50 AM, TeLeMan wrote:
>>> I think this patch is not right. Outputting 64bits data is not
>>> necessary on 32bits mode.
>>
>> Do you speak of 32 bit hosts or 32 bit targets?
>
> 32bit mode of x64

There is no such thing as a 32 bit host on x64, only 64-bit hosts that 
haven't turned on long mode.  So printing 64 bits is correct for those.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
  2010-11-01 10:14         ` [Qemu-devel] " Paolo Bonzini
@ 2010-11-01 10:20           ` Paolo Bonzini
       [not found]           ` <AANLkTino2N6qxYxwXu1cLn=oVanETcqOjthfX7qr4_Dh@mail.gmail.com>
  1 sibling, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2010-11-01 10:20 UTC (permalink / raw)
  Cc: Blue Swirl, TeLeMan, QEMU Developers

On 11/01/2010 11:14 AM, Paolo Bonzini wrote:
> There is no such thing as a 32 bit host on x64, only 64-bit hosts that
                                      ^^^^                     ^^^^^

guests

> haven't turned on long mode.  So printing 64 bits is correct for those.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
       [not found]           ` <AANLkTino2N6qxYxwXu1cLn=oVanETcqOjthfX7qr4_Dh@mail.gmail.com>
@ 2010-11-01 11:03             ` Paolo Bonzini
  2010-11-01 15:18               ` Stefan Weil
  0 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2010-11-01 11:03 UTC (permalink / raw)
  To: TeLeMan, Blue Swirl, qemu-devel, Stefan Weil

On 11/01/2010 11:27 AM, TeLeMan wrote:
> On Mon, Nov 1, 2010 at 18:14, Paolo Bonzini<pbonzini@redhat.com>  wrote:
>> On 11/01/2010 10:50 AM, TeLeMan wrote:
>>>>>
>>>>> I think this patch is not right. Outputting 64bits data is not
>>>>> necessary on 32bits mode.
>>>>
>>>> Do you speak of 32 bit hosts or 32 bit targets?
>>>
>>> 32bit mode of x64
>>
>> There is no such thing as a 32 bit host on x64, only 64-bit hosts that
>> haven't turned on long mode.  So printing 64 bits is correct for those.
>
> If so, why the above crX is printed by 32 bits?

There are two issues.  One is what type specifier to use (and it is a 
correctness issue), the other is what width to use (and it is an 
aesthetics issue).  The patch fixes the correctness issue and makes the 
aesthetic part worse.

I agree that a better fix would be to cast to uint32_t as it is done for 
crX, but this patch is anyway better than nothing because right now DR7 
is printed incorrectly _exactly on 64-bit guests running on 32-bit mode_.

An even better fix than uint32_t would be to introduce TARGET_FMT_8lx 
(which maps to "%08"PRI_x64) so that, if for some reason the high 32-bit 
are not zero, they will be shown.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
  2010-11-01 11:03             ` Paolo Bonzini
@ 2010-11-01 15:18               ` Stefan Weil
  2010-11-01 15:42                 ` Paolo Bonzini
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Weil @ 2010-11-01 15:18 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Blue Swirl, TeLeMan, qemu-devel

Am 01.11.2010 12:03, schrieb Paolo Bonzini:
> On 11/01/2010 11:27 AM, TeLeMan wrote:
>> On Mon, Nov 1, 2010 at 18:14, Paolo Bonzini<pbonzini@redhat.com>  wrote:
>>> On 11/01/2010 10:50 AM, TeLeMan wrote:
>>>>>>
>>>>>> I think this patch is not right. Outputting 64bits data is not
>>>>>> necessary on 32bits mode.
>>>>>
>>>>> Do you speak of 32 bit hosts or 32 bit targets?
>>>>
>>>> 32bit mode of x64
>>>
>>> There is no such thing as a 32 bit host on x64, only 64-bit hosts that
>>> haven't turned on long mode.  So printing 64 bits is correct for those.
>>
>> If so, why the above crX is printed by 32 bits?
>
> There are two issues.  One is what type specifier to use (and it is a 
> correctness issue), the other is what width to use (and it is an 
> aesthetics issue).  The patch fixes the correctness issue and makes 
> the aesthetic part worse.
>
> I agree that a better fix would be to cast to uint32_t as it is done 
> for crX, but this patch is anyway better than nothing because right 
> now DR7 is printed incorrectly _exactly on 64-bit guests running on 
> 32-bit mode_.
>
> An even better fix than uint32_t would be to introduce TARGET_FMT_8lx 
> (which maps to "%08"PRI_x64) so that, if for some reason the high 
> 32-bit are not zero, they will be shown.
>
> Paolo

Yes. We already had a similar discussion about TARGET_FMT_PLX, see
http://www.mail-archive.com/qemu-devel@nongnu.org/msg42977.html.

There I suggested to define PRIxTPA (format specifier for a target
physical address). We could also add a PRIxTUL (for target_ulong),
so it would be possible to output "%04" PRIxTUL or "%08" PRIxTUL.
Thus we could avoid the need for TARGET_FMT_8lx, TARGET_FMT_4lx
and maybe even TARGET_FMT_2lx.

Kind regards,
Stefan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: [PATCH 4/4] target-xxx: Use fprintf_function (format checking)
  2010-11-01 15:18               ` Stefan Weil
@ 2010-11-01 15:42                 ` Paolo Bonzini
  0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2010-11-01 15:42 UTC (permalink / raw)
  To: Stefan Weil; +Cc: Blue Swirl, TeLeMan, qemu-devel

> > An even better fix than uint32_t would be to introduce TARGET_FMT_8lx 
> > (which maps to "%08"PRI_x64) so that, if for some reason the high 
> > 32-bit are not zero, they will be shown.
> >
> Yes. We already had a similar discussion about TARGET_FMT_PLX, see
> http://www.mail-archive.com/qemu-devel@nongnu.org/msg42977.html.
>
> There I suggested to define PRIxTPA (format specifier for a target
> physical address). We could also add a PRIxTUL (for target_ulong),
> so it would be possible to output "%04" PRIxTUL or "%08" PRIxTUL.
> Thus we could avoid the need for TARGET_FMT_8lx, TARGET_FMT_4lx
> and maybe even TARGET_FMT_2lx.

Yes, that would be nice to have too.

Paolo

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-11-01 15:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-22 21:03 [Qemu-devel] [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions Stefan Weil
2010-10-22 21:03 ` [Qemu-devel] [PATCH 2/4] tcg: Use fprintf_function (format checking) Stefan Weil
2010-10-22 21:03 ` [Qemu-devel] [PATCH 3/4] exec: Use fprintf_function for dump_exec_info " Stefan Weil
2010-10-22 21:03 ` [Qemu-devel] [PATCH 4/4] target-xxx: Use fprintf_function " Stefan Weil
2010-11-01  2:24   ` TeLeMan
2010-11-01  7:05     ` Stefan Weil
2010-11-01  9:50       ` TeLeMan
2010-11-01 10:14         ` [Qemu-devel] " Paolo Bonzini
2010-11-01 10:20           ` Paolo Bonzini
     [not found]           ` <AANLkTino2N6qxYxwXu1cLn=oVanETcqOjthfX7qr4_Dh@mail.gmail.com>
2010-11-01 11:03             ` Paolo Bonzini
2010-11-01 15:18               ` Stefan Weil
2010-11-01 15:42                 ` Paolo Bonzini
2010-10-30  9:23 ` [Qemu-devel] Re: [PATCH 1/4] Add fprintf_function for function pointers to fprintf-like functions Blue Swirl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.