From 83300a66dd6f3e3ddd71f1fdd9f3ecb78fb221b1 Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Tue, 17 Jan 2006 18:17:01 +0000 Subject: [PATCH] Fixed printing of 64-bit values forma. When compiling with cygwin with -mno-cygwin option the format should be like in MSVC --- bochs/.conf.win32-cygwin | 2 +- bochs/instrument/example0/instrument.cc | 19 ++++----------- bochs/instrument/example1/instrument.cc | 21 +++++------------ bochs/osdep.h | 31 ++++++++++++++++++------- 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/bochs/.conf.win32-cygwin b/bochs/.conf.win32-cygwin index dcfe4a1ee..ae7e92409 100755 --- a/bochs/.conf.win32-cygwin +++ b/bochs/.conf.win32-cygwin @@ -6,7 +6,7 @@ CC="gcc" CXX="g++" -CFLAGS="-O3 -march=pentium" +CFLAGS="-O3 -Wall -Wno-format -march=pentium" CXXFLAGS="$CFLAGS" export CC diff --git a/bochs/instrument/example0/instrument.cc b/bochs/instrument/example0/instrument.cc index af210d589..bf42791fe 100644 --- a/bochs/instrument/example0/instrument.cc +++ b/bochs/instrument/example0/instrument.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: instrument.cc,v 1.15 2006-01-16 19:53:11 sshwarts Exp $ +// $Id: instrument.cc,v 1.16 2006-01-17 18:17:01 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -98,34 +98,25 @@ void bx_instr_new_instruction(unsigned cpu) { fprintf(stderr, "----------------------------------------------------------\n"); fprintf(stderr, "CPU: %d: %s\n", cpu, disasm_tbuf); - fprintf(stderr, "LEN: %d\tPREFIX: %d\tBYTES: ", length, i->nprefixes); + fprintf(stderr, "LEN: %d\tPREFIXES: %d\tBYTES: ", length, i->nprefixes); for(n=0;nopcode[n]); if(i->is_branch) { fprintf(stderr, "\tBRANCH "); if(i->is_taken) - fprintf(stderr, "TARGET %08x (TAKEN)", i->target_linear); + fprintf(stderr, "TARGET " FMT_ADDRX " (TAKEN)", i->target_linear); else fprintf(stderr, "(NOT TAKEN)"); } - fprintf(stderr, "\nMEMORY ACCESSES: %u\n", i->num_data_accesses); + fprintf(stderr, "\n"); for(n=0;nnum_data_accesses;n++) { -#if BX_SUPPORT_X86_64 - fprintf(stderr, "MEM ACCESS: %08x%08x (linear) %08x (physical) %s SIZE: %d\n", - (Bit32u)(i->data_access[n].laddr >> 32), - (Bit32u)(i->data_access[n].laddr & 0xffffffff), - i->data_access[n].paddr, - i->data_access[n].op == BX_READ ? "RD":"WR", - i->data_access[n].size); -#else - fprintf(stderr, "MEM ACCESS: %08x (linear) %08x (physical) %s SIZE: %d\n", + fprintf(stderr, "MEM ACCESS[%u]: " FMT_ADDRX " (linear) 0x%08x (physical) %s SIZE: %d\n", n, i->data_access[n].laddr, i->data_access[n].paddr, i->data_access[n].op == BX_READ ? "RD":"WR", i->data_access[n].size); -#endif } fprintf(stderr, "\n"); } diff --git a/bochs/instrument/example1/instrument.cc b/bochs/instrument/example1/instrument.cc index 3331e87de..1d0fb2cc8 100644 --- a/bochs/instrument/example1/instrument.cc +++ b/bochs/instrument/example1/instrument.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: instrument.cc,v 1.11 2006-01-16 19:53:11 sshwarts Exp $ +// $Id: instrument.cc,v 1.12 2006-01-17 18:17:01 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -64,34 +64,25 @@ void bxInstrumentation::bx_instr_new_instruction() { fprintf(stderr, "----------------------------------------------------------\n"); fprintf(stderr, "CPU: %d: %s\n", cpu_id, disasm_tbuf); - fprintf(stderr, "LEN: %d\tPREFIX: %d\tBYTES: ", length, nprefixes); + fprintf(stderr, "LEN: %d\tPREFIXES: %d\tBYTES: ", length, nprefixes); for(n=0;n> 32), - (Bit32u)(data_access[n].laddr & 0xffffffff), + fprintf(stderr, "MEM ACCESS[%u]: " FMT_ADDRX " (linear) 0x%08x (physical) %s SIZE: %d\n", n, + data_access[n].laddr, data_access[n].paddr, data_access[n].op == BX_READ ? "RD":"WR", data_access[n].size); -#else - fprintf(stderr, "MEM ACCESS %u: %08x (linear) %08x (physical) %s SIZE: %d\n", n, - i->data_access[n].laddr, - i->data_access[n].paddr, - i->data_access[n].op == BX_READ ? "RD":"WR", - i->data_access[n].size); -#endif } fprintf(stderr, "\n"); } diff --git a/bochs/osdep.h b/bochs/osdep.h index d9ec68d20..87aa9d7ea 100644 --- a/bochs/osdep.h +++ b/bochs/osdep.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: osdep.h,v 1.23 2004-09-19 18:38:09 vruppert Exp $ +// $Id: osdep.h,v 1.24 2006-01-17 18:17:01 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -52,12 +52,20 @@ extern "C" { # define ssize_t long #ifndef __MINGW32__ -#define FMT_LL "%I64" -#define FMT_TICK "%011I64u" // Definitions that are needed for WIN32 compilers EXCEPT FOR // cygwin compiling with -mno-cygwin. e.g. VC++. +#if !defined(_MSC_VER) // gcc without -mno-cygwin +#define FMT_LL "%ll" +#define FMT_TICK "%011llu" +#define FMT_ADDRX64 "0x%016llx" +#else +#define FMT_LL "%I64" +#define FMT_TICK "%011I64u" +#define FMT_ADDRX64 "0x%016I64x" +#endif + // always return regular file. # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) @@ -77,18 +85,23 @@ extern "C" { #define stat _stati64 #endif -#else /* ifndef __MINGW32__ */ -#define FMT_LL "%ll" -#define FMT_TICK "%011llu" +#else /* __MINGW32__ defined */ +// Definitions for cygwin compiled with -mno-cygwin +#define FMT_LL "%I64" +#define FMT_TICK "%011I64u" +#define FMT_ADDRX64 "0x%016I64x" #define off_t __int64 #define lseek _lseeki64 +#endif /* __MINGW32__ defined */ -#endif /* ifndef __MINGW32__ */ -#else /* WIN32 */ +#else /* not WIN32 definitions */ #define FMT_LL "%ll" #define FMT_TICK "%011llu" -#endif /* WIN32 */ +#define FMT_ADDRX64 "0x%016llx" +#endif /* not WIN32 definitions */ + +#define FMT_ADDRX32 "0x%08x" // Missing defines for open #ifndef S_IRUSR