* [Qemu-devel] [PATCH 00/13] Cleanup some logging code @ 2008-12-10 18:24 Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro Eduardo Habkost ` (13 more replies) 0 siblings, 14 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost The following patches are small cleanups of the logging code on multiple partes of qemu. Most of them are for removing duplicated code and #ifdefs from the code. The patches are available on a git tree (see pull request below). My long-term plan is to have a propper logging API on qemu, instead of the global variables 'loglevel' and 'logfile'. These cleanups should make that work easier, in addition to the code readability improvement. --- The following changes since commit eeda67786ccfb1016d8bd5977821bc5175ae862a: aurel32 (1): target-sh4: Add SH bit handling to TLB are available in the git repository at: git://github.com/ehabkost/qemu-hacks.git logging-cleanup Eduardo Habkost (13): hw/ppc.c: LOG_IRQ macro hw/ppc.c: use LOG_IRQ instead of #ifdefs hw/ppc.c: LOG_TB macro hw/ppc.c: use LOG_TB instead of #ifdefs vl.c: LOG_IOPORT macro vl.c: use LOG_IOPORT instead of #ifdefs kqemu.c: LOG_INT macro kqemu.c: use LOG_INT instead of #ifdefs kqemu.c: LOG_INT_STATE macro kqemu.c: use LOG_INT_STATE instead of #ifdefs target-i386/op_helper.c: LOG_PCALL macro target-i386/op_helper.c: use LOG_PCALL instead of #ifdefs target-cris/translate.c: create LOG_DIS macro hw/ppc.c | 313 ++++++++++------------------------------------ kqemu.c | 52 ++++----- target-cris/translate.c | 289 ++++++++++++++++++++++--------------------- target-i386/op_helper.c | 27 ++-- vl.c | 40 +++---- 5 files changed, 266 insertions(+), 455 deletions(-) -- Eduardo ^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-11 21:45 ` Anthony Liguori 2008-12-10 18:24 ` [Qemu-devel] [PATCH 02/13] hw/ppc.c: use LOG_IRQ instead of #ifdefs Eduardo Habkost ` (12 subsequent siblings) 13 siblings, 1 reply; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost This macro will avoid some #ifdefs in the code and create a single point where the logging call can be changed in the future. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- hw/ppc.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/hw/ppc.c b/hw/ppc.c index 60d6e86..cbd69e0 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -31,6 +31,16 @@ //#define PPC_DEBUG_IRQ //#define PPC_DEBUG_TB +#ifdef PPC_DEBUG_IRQ +# define LOG_IRQ(...) do { \ + if (loglevel & CPU_LOG_INT) \ + fprintf(logfile, __VA_ARGS__); \ + } while (0) +#else +# define LOG_IRQ(...) do { } while (0) +#endif + + static void cpu_ppc_tb_stop (CPUState *env); static void cpu_ppc_tb_start (CPUState *env); -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro 2008-12-10 18:24 ` [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro Eduardo Habkost @ 2008-12-11 21:45 ` Anthony Liguori 2008-12-11 22:54 ` Andreas Färber 0 siblings, 1 reply; 21+ messages in thread From: Anthony Liguori @ 2008-12-11 21:45 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Eduardo Habkost wrote: > This macro will avoid some #ifdefs in the code and create a single point > where the logging call can be changed in the future. > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> > --- > hw/ppc.c | 10 ++++++++++ > 1 files changed, 10 insertions(+), 0 deletions(-) > > diff --git a/hw/ppc.c b/hw/ppc.c > index 60d6e86..cbd69e0 100644 > --- a/hw/ppc.c > +++ b/hw/ppc.c > @@ -31,6 +31,16 @@ > //#define PPC_DEBUG_IRQ > //#define PPC_DEBUG_TB > > +#ifdef PPC_DEBUG_IRQ > +# define LOG_IRQ(...) do { \ > + if (loglevel & CPU_LOG_INT) \ > + fprintf(logfile, __VA_ARGS__); \ > + } while (0) > +#else > +# define LOG_IRQ(...) do { } while (0) > +#endif > This style of macro is less ideal than: #define LOG_IRQ(fmt, ...) fprintf(logfile, fmt, ## __VA_ARGS__). Other than that, this series looks pretty sane. If you fix these macros, I'll apply the series. Regards, Anthony Liguori > + > + > static void cpu_ppc_tb_stop (CPUState *env); > static void cpu_ppc_tb_start (CPUState *env); > > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro 2008-12-11 21:45 ` Anthony Liguori @ 2008-12-11 22:54 ` Andreas Färber 2008-12-11 23:31 ` Eduardo Habkost 2008-12-12 14:31 ` Anthony Liguori 0 siblings, 2 replies; 21+ messages in thread From: Andreas Färber @ 2008-12-11 22:54 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Am 11.12.2008 um 22:45 schrieb Anthony Liguori: > Eduardo Habkost wrote: >> This macro will avoid some #ifdefs in the code and create a single >> point >> where the logging call can be changed in the future. >> >> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> >> --- >> hw/ppc.c | 10 ++++++++++ >> 1 files changed, 10 insertions(+), 0 deletions(-) >> >> diff --git a/hw/ppc.c b/hw/ppc.c >> index 60d6e86..cbd69e0 100644 >> --- a/hw/ppc.c >> +++ b/hw/ppc.c >> @@ -31,6 +31,16 @@ >> //#define PPC_DEBUG_IRQ >> //#define PPC_DEBUG_TB >> +#ifdef PPC_DEBUG_IRQ >> +# define LOG_IRQ(...) do { \ >> + if (loglevel & CPU_LOG_INT) \ >> + fprintf(logfile, __VA_ARGS__); \ >> + } while (0) >> +#else >> +# define LOG_IRQ(...) do { } while (0) >> +#endif >> > > This style of macro is less ideal than: > > #define LOG_IRQ(fmt, ...) fprintf(logfile, fmt, ## __VA_ARGS__). Now that the TCG conversion is done, does QEMU still require GCC? I remember we had issues with such macros in Mono's eGLib due to some compilers needing "fmt..." instead of "fmt, ..." and some not supporting "__VA_ARGS__" but "...". It might make sense then to put such logging macros in a central place (qemu-common.h?) to avoid having to cope with such annoyances in all those source files. Andreas ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro 2008-12-11 22:54 ` Andreas Färber @ 2008-12-11 23:31 ` Eduardo Habkost 2008-12-14 18:09 ` Jamie Lokier 2008-12-12 14:31 ` Anthony Liguori 1 sibling, 1 reply; 21+ messages in thread From: Eduardo Habkost @ 2008-12-11 23:31 UTC (permalink / raw) To: Andreas Färber; +Cc: qemu-devel On Thu, Dec 11, 2008 at 11:54:08PM +0100, Andreas Färber wrote: > > Am 11.12.2008 um 22:45 schrieb Anthony Liguori: > >> Eduardo Habkost wrote: >>> This macro will avoid some #ifdefs in the code and create a single >>> point >>> where the logging call can be changed in the future. >>> >>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> >>> --- >>> hw/ppc.c | 10 ++++++++++ >>> 1 files changed, 10 insertions(+), 0 deletions(-) >>> >>> diff --git a/hw/ppc.c b/hw/ppc.c >>> index 60d6e86..cbd69e0 100644 >>> --- a/hw/ppc.c >>> +++ b/hw/ppc.c >>> @@ -31,6 +31,16 @@ >>> //#define PPC_DEBUG_IRQ >>> //#define PPC_DEBUG_TB >>> +#ifdef PPC_DEBUG_IRQ >>> +# define LOG_IRQ(...) do { \ >>> + if (loglevel & CPU_LOG_INT) \ >>> + fprintf(logfile, __VA_ARGS__); \ >>> + } while (0) >>> +#else >>> +# define LOG_IRQ(...) do { } while (0) >>> +#endif >>> >> >> This style of macro is less ideal than: >> >> #define LOG_IRQ(fmt, ...) fprintf(logfile, fmt, ## __VA_ARGS__). > > Now that the TCG conversion is done, does QEMU still require GCC? I > remember we had issues with such macros in Mono's eGLib due to some > compilers needing "fmt..." instead of "fmt, ..." and some not supporting > "__VA_ARGS__" but "...". I chose __VA_ARGS__ because I expected it to be more commonly supported on other compilers. GCC documentation mentions "fmt..." as a GCC extension. > > It might make sense then to put such logging macros in a central place > (qemu-common.h?) to avoid having to cope with such annoyances in all > those source files. Yes. I plan to unify all those debug macros somewhere, later. But I want to do this one step at a time. This first series is just to keep exactly the same behavior with a cleaner code. After that, we can make all targets use similar macros and then unify them on a single place. -- Eduardo ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro 2008-12-11 23:31 ` Eduardo Habkost @ 2008-12-14 18:09 ` Jamie Lokier 0 siblings, 0 replies; 21+ messages in thread From: Jamie Lokier @ 2008-12-14 18:09 UTC (permalink / raw) To: qemu-devel; +Cc: Andreas Färber Eduardo Habkost wrote: > I chose __VA_ARGS__ because I expected it to be more commonly supported on > other compilers. C99 compilers. > GCC documentation mentions "fmt..." as a GCC extension. It is. The only thing is that older GCCs (perhaps pre-3.0) only support the extension, not the C99 syntax. -- Jamie ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro 2008-12-11 22:54 ` Andreas Färber 2008-12-11 23:31 ` Eduardo Habkost @ 2008-12-12 14:31 ` Anthony Liguori 1 sibling, 0 replies; 21+ messages in thread From: Anthony Liguori @ 2008-12-12 14:31 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Andreas Färber wrote: > > Am 11.12.2008 um 22:45 schrieb Anthony Liguori: > >> Eduardo Habkost wrote: >>> This macro will avoid some #ifdefs in the code and create a single >>> point >>> where the logging call can be changed in the future. >>> >>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> >>> --- >>> hw/ppc.c | 10 ++++++++++ >>> 1 files changed, 10 insertions(+), 0 deletions(-) >>> >>> diff --git a/hw/ppc.c b/hw/ppc.c >>> index 60d6e86..cbd69e0 100644 >>> --- a/hw/ppc.c >>> +++ b/hw/ppc.c >>> @@ -31,6 +31,16 @@ >>> //#define PPC_DEBUG_IRQ >>> //#define PPC_DEBUG_TB >>> +#ifdef PPC_DEBUG_IRQ >>> +# define LOG_IRQ(...) do { \ >>> + if (loglevel & CPU_LOG_INT) \ >>> + fprintf(logfile, __VA_ARGS__); \ >>> + } while (0) >>> +#else >>> +# define LOG_IRQ(...) do { } while (0) >>> +#endif >>> >> >> This style of macro is less ideal than: >> >> #define LOG_IRQ(fmt, ...) fprintf(logfile, fmt, ## __VA_ARGS__). > > Now that the TCG conversion is done, does QEMU still require GCC? I > remember we had issues with such macros in Mono's eGLib due to some > compilers needing "fmt..." instead of "fmt, ..." and some not > supporting "__VA_ARGS__" but "...". fmt... is an old GCC-ism. __VA_ARGS__ is C99. Eduardo's syntax (w/o ##) is actually stricter C99 as ## is a GCC extension. However, I think it's a pretty good one. In terms of QEMU requiring GCC, I personally would like to maintain the status quo. C99 whenever possible with judicious use of GCC extensions when they're necessary. If someone wants to do the work to port to another compiler, posts the patches, and is willing to maintain that support (which means constant testing and nagging), we can re-examine our GCC dependency. It's not worth debating about (GCC dependency) unless someone is really going to put in the work of maintaining another compiler. Regards, Anhtony Liguori > > It might make sense then to put such logging macros in a central place > (qemu-common.h?) to avoid having to cope with such annoyances in all > those source files. > > Andreas > > ^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 02/13] hw/ppc.c: use LOG_IRQ instead of #ifdefs 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 03/13] hw/ppc.c: LOG_TB macro Eduardo Habkost ` (11 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Use the new LOG_IRQ macro. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- hw/ppc.c | 180 ++++++++++--------------------------------------------------- 1 files changed, 30 insertions(+), 150 deletions(-) diff --git a/hw/ppc.c b/hw/ppc.c index cbd69e0..44d2f48 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -54,13 +54,9 @@ static void ppc_set_irq (CPUState *env, int n_IRQ, int level) if (env->pending_interrupts == 0) cpu_reset_interrupt(env, CPU_INTERRUPT_HARD); } -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: %p n_IRQ %d level %d => pending %08" PRIx32 + LOG_IRQ("%s: %p n_IRQ %d level %d => pending %08" PRIx32 "req %08x\n", __func__, env, n_IRQ, level, env->pending_interrupts, env->interrupt_request); - } -#endif } /* PowerPC 6xx / 7xx internal IRQ controller */ @@ -69,24 +65,16 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level) CPUState *env = opaque; int cur_level; -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: env %p pin %d level %d\n", __func__, + LOG_IRQ("%s: env %p pin %d level %d\n", __func__, env, pin, level); - } -#endif cur_level = (env->irq_input_state >> pin) & 1; /* Don't generate spurious events */ if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { switch (pin) { case PPC6xx_INPUT_TBEN: /* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: %s the time base\n", + LOG_IRQ("%s: %s the time base\n", __func__, level ? "start" : "stop"); - } -#endif if (level) { cpu_ppc_tb_start(env); } else { @@ -94,22 +82,14 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level) } case PPC6xx_INPUT_INT: /* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the external IRQ state to %d\n", + LOG_IRQ("%s: set the external IRQ state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_EXT, level); break; case PPC6xx_INPUT_SMI: /* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the SMI IRQ state to %d\n", + LOG_IRQ("%s: set the SMI IRQ state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_SMI, level); break; case PPC6xx_INPUT_MCP: @@ -118,12 +98,8 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level) * 603/604/740/750: check HID0[EMCP] */ if (cur_level == 1 && level == 0) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: raise machine check state\n", + LOG_IRQ("%s: raise machine check state\n", __func__); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_MCK, 1); } break; @@ -132,22 +108,14 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level) /* XXX: TODO: relay the signal to CKSTP_OUT pin */ /* XXX: Note that the only way to restart the CPU is to reset it */ if (level) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: stop the CPU\n", __func__); - } -#endif + LOG_IRQ("%s: stop the CPU\n", __func__); env->halted = 1; } break; case PPC6xx_INPUT_HRESET: /* Level sensitive - active low */ if (level) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: reset the CPU\n", __func__); - } -#endif + LOG_IRQ("%s: reset the CPU\n", __func__); env->interrupt_request |= CPU_INTERRUPT_EXITTB; /* XXX: TOFIX */ #if 0 @@ -158,21 +126,13 @@ static void ppc6xx_set_irq (void *opaque, int pin, int level) } break; case PPC6xx_INPUT_SRESET: -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the RESET IRQ state to %d\n", + LOG_IRQ("%s: set the RESET IRQ state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_RESET, level); break; default: /* Unknown pin - do nothing */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin); - } -#endif + LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin); return; } if (level) @@ -195,34 +155,22 @@ static void ppc970_set_irq (void *opaque, int pin, int level) CPUState *env = opaque; int cur_level; -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: env %p pin %d level %d\n", __func__, + LOG_IRQ("%s: env %p pin %d level %d\n", __func__, env, pin, level); - } -#endif cur_level = (env->irq_input_state >> pin) & 1; /* Don't generate spurious events */ if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { switch (pin) { case PPC970_INPUT_INT: /* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the external IRQ state to %d\n", + LOG_IRQ("%s: set the external IRQ state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_EXT, level); break; case PPC970_INPUT_THINT: /* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the SMI IRQ state to %d\n", __func__, + LOG_IRQ("%s: set the SMI IRQ state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_THERM, level); break; case PPC970_INPUT_MCP: @@ -231,12 +179,8 @@ static void ppc970_set_irq (void *opaque, int pin, int level) * 603/604/740/750: check HID0[EMCP] */ if (cur_level == 1 && level == 0) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: raise machine check state\n", + LOG_IRQ("%s: raise machine check state\n", __func__); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_MCK, 1); } break; @@ -244,18 +188,10 @@ static void ppc970_set_irq (void *opaque, int pin, int level) /* Level sensitive - active low */ /* XXX: TODO: relay the signal to CKSTP_OUT pin */ if (level) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: stop the CPU\n", __func__); - } -#endif + LOG_IRQ("%s: stop the CPU\n", __func__); env->halted = 1; } else { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: restart the CPU\n", __func__); - } -#endif + LOG_IRQ("%s: restart the CPU\n", __func__); env->halted = 0; } break; @@ -263,40 +199,24 @@ static void ppc970_set_irq (void *opaque, int pin, int level) /* Level sensitive - active low */ if (level) { #if 0 // XXX: TOFIX -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: reset the CPU\n", __func__); - } -#endif + LOG_IRQ("%s: reset the CPU\n", __func__); cpu_reset(env); #endif } break; case PPC970_INPUT_SRESET: -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the RESET IRQ state to %d\n", + LOG_IRQ("%s: set the RESET IRQ state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_RESET, level); break; case PPC970_INPUT_TBEN: -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the TBEN state to %d\n", __func__, + LOG_IRQ("%s: set the TBEN state to %d\n", __func__, level); - } -#endif /* XXX: TODO */ break; default: /* Unknown pin - do nothing */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin); - } -#endif + LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin); return; } if (level) @@ -319,103 +239,63 @@ static void ppc40x_set_irq (void *opaque, int pin, int level) CPUState *env = opaque; int cur_level; -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: env %p pin %d level %d\n", __func__, + LOG_IRQ("%s: env %p pin %d level %d\n", __func__, env, pin, level); - } -#endif cur_level = (env->irq_input_state >> pin) & 1; /* Don't generate spurious events */ if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { switch (pin) { case PPC40x_INPUT_RESET_SYS: if (level) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: reset the PowerPC system\n", + LOG_IRQ("%s: reset the PowerPC system\n", __func__); - } -#endif ppc40x_system_reset(env); } break; case PPC40x_INPUT_RESET_CHIP: if (level) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: reset the PowerPC chip\n", __func__); - } -#endif + LOG_IRQ("%s: reset the PowerPC chip\n", __func__); ppc40x_chip_reset(env); } break; case PPC40x_INPUT_RESET_CORE: /* XXX: TODO: update DBSR[MRR] */ if (level) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: reset the PowerPC core\n", __func__); - } -#endif + LOG_IRQ("%s: reset the PowerPC core\n", __func__); ppc40x_core_reset(env); } break; case PPC40x_INPUT_CINT: /* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the critical IRQ state to %d\n", + LOG_IRQ("%s: set the critical IRQ state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_CEXT, level); break; case PPC40x_INPUT_INT: /* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the external IRQ state to %d\n", + LOG_IRQ("%s: set the external IRQ state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_EXT, level); break; case PPC40x_INPUT_HALT: /* Level sensitive - active low */ if (level) { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: stop the CPU\n", __func__); - } -#endif + LOG_IRQ("%s: stop the CPU\n", __func__); env->halted = 1; } else { -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: restart the CPU\n", __func__); - } -#endif + LOG_IRQ("%s: restart the CPU\n", __func__); env->halted = 0; } break; case PPC40x_INPUT_DEBUG: /* Level sensitive - active high */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: set the debug pin state to %d\n", + LOG_IRQ("%s: set the debug pin state to %d\n", __func__, level); - } -#endif ppc_set_irq(env, PPC_INTERRUPT_DEBUG, level); break; default: /* Unknown pin - do nothing */ -#if defined(PPC_DEBUG_IRQ) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin); - } -#endif + LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin); return; } if (level) -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 03/13] hw/ppc.c: LOG_TB macro 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 02/13] hw/ppc.c: use LOG_IRQ instead of #ifdefs Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 04/13] hw/ppc.c: use LOG_TB instead of #ifdefs Eduardo Habkost ` (10 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost This macro will avoid some #ifdefs in the code and create a single point where the logging call can be changed in the future. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- hw/ppc.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/hw/ppc.c b/hw/ppc.c index 44d2f48..53257a4 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -41,6 +41,15 @@ #endif +#ifdef PPC_DEBUG_TB +# define LOG_TB(...) do { \ + if (loglevel) \ + fprintf(logfile, __VA_ARGS__); \ + } while (0) +#else +# define LOG_TB(...) do { } while (0) +#endif + static void cpu_ppc_tb_stop (CPUState *env); static void cpu_ppc_tb_start (CPUState *env); -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 04/13] hw/ppc.c: use LOG_TB instead of #ifdefs 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (2 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 03/13] hw/ppc.c: LOG_TB macro Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 05/13] vl.c: LOG_IOPORT macro Eduardo Habkost ` (9 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- hw/ppc.c | 114 ++++++++++--------------------------------------------------- 1 files changed, 19 insertions(+), 95 deletions(-) diff --git a/hw/ppc.c b/hw/ppc.c index 53257a4..7a404bf 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -352,11 +352,7 @@ uint32_t cpu_ppc_load_tbl (CPUState *env) uint64_t tb; tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset); -#if defined(PPC_DEBUG_TB) - if (loglevel != 0) { - fprintf(logfile, "%s: tb %016" PRIx64 "\n", __func__, tb); - } -#endif + LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb); return tb & 0xFFFFFFFF; } @@ -367,11 +363,7 @@ static always_inline uint32_t _cpu_ppc_load_tbu (CPUState *env) uint64_t tb; tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->tb_offset); -#if defined(PPC_DEBUG_TB) - if (loglevel != 0) { - fprintf(logfile, "%s: tb %016" PRIx64 "\n", __func__, tb); - } -#endif + LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb); return tb >> 32; } @@ -386,12 +378,8 @@ static always_inline void cpu_ppc_store_tb (ppc_tb_t *tb_env, uint64_t vmclk, uint64_t value) { *tb_offsetp = value - muldiv64(vmclk, tb_env->tb_freq, ticks_per_sec); -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: tb %016" PRIx64 " offset %08" PRIx64 "\n", + LOG_TB("%s: tb %016" PRIx64 " offset %08" PRIx64 "\n", __func__, value, *tb_offsetp); - } -#endif } void cpu_ppc_store_tbl (CPUState *env, uint32_t value) @@ -427,11 +415,7 @@ uint32_t cpu_ppc_load_atbl (CPUState *env) uint64_t tb; tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset); -#if defined(PPC_DEBUG_TB) - if (loglevel != 0) { - fprintf(logfile, "%s: tb %016" PRIx64 "\n", __func__, tb); - } -#endif + LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb); return tb & 0xFFFFFFFF; } @@ -442,11 +426,7 @@ uint32_t cpu_ppc_load_atbu (CPUState *env) uint64_t tb; tb = cpu_ppc_get_tb(tb_env, qemu_get_clock(vm_clock), tb_env->atb_offset); -#if defined(PPC_DEBUG_TB) - if (loglevel != 0) { - fprintf(logfile, "%s: tb %016" PRIx64 "\n", __func__, tb); - } -#endif + LOG_TB("%s: tb %016" PRIx64 "\n", __func__, tb); return tb >> 32; } @@ -528,11 +508,7 @@ static always_inline uint32_t _cpu_ppc_load_decr (CPUState *env, decr = muldiv64(diff, tb_env->decr_freq, ticks_per_sec); else decr = -muldiv64(-diff, tb_env->decr_freq, ticks_per_sec); -#if defined(PPC_DEBUG_TB) - if (loglevel != 0) { - fprintf(logfile, "%s: %08" PRIx32 "\n", __func__, decr); - } -#endif + LOG_TB("%s: %08" PRIx32 "\n", __func__, decr); return decr; } @@ -567,22 +543,14 @@ uint64_t cpu_ppc_load_purr (CPUState *env) static always_inline void cpu_ppc_decr_excp (CPUState *env) { /* Raise it */ -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "raise decrementer exception\n"); - } -#endif + LOG_TB("raise decrementer exception\n"); ppc_set_irq(env, PPC_INTERRUPT_DECR, 1); } static always_inline void cpu_ppc_hdecr_excp (CPUState *env) { /* Raise it */ -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "raise decrementer exception\n"); - } -#endif + LOG_TB("raise decrementer exception\n"); ppc_set_irq(env, PPC_INTERRUPT_HDECR, 1); } @@ -595,12 +563,8 @@ static void __cpu_ppc_store_decr (CPUState *env, uint64_t *nextp, ppc_tb_t *tb_env = env->tb_env; uint64_t now, next; -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: %08" PRIx32 " => %08" PRIx32 "\n", __func__, + LOG_TB("%s: %08" PRIx32 " => %08" PRIx32 "\n", __func__, decr, value); - } -#endif now = qemu_get_clock(vm_clock); next = now + muldiv64(value, ticks_per_sec, tb_env->decr_freq); if (is_excp) @@ -781,13 +745,9 @@ static void cpu_4xx_fit_cb (void *opaque) env->spr[SPR_40x_TSR] |= 1 << 26; if ((env->spr[SPR_40x_TCR] >> 23) & 0x1) ppc_set_irq(env, PPC_INTERRUPT_FIT, 1); -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: ir %d TCR " ADDRX " TSR " ADDRX "\n", __func__, + LOG_TB("%s: ir %d TCR " ADDRX " TSR " ADDRX "\n", __func__, (int)((env->spr[SPR_40x_TCR] >> 23) & 0x1), env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]); - } -#endif } /* Programmable interval timer */ @@ -801,19 +761,11 @@ static void start_stop_pit (CPUState *env, ppc_tb_t *tb_env, int is_excp) !((env->spr[SPR_40x_TCR] >> 26) & 0x1) || (is_excp && !((env->spr[SPR_40x_TCR] >> 22) & 0x1))) { /* Stop PIT */ -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: stop PIT\n", __func__); - } -#endif + LOG_TB("%s: stop PIT\n", __func__); qemu_del_timer(tb_env->decr_timer); } else { -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: start PIT %016" PRIx64 "\n", + LOG_TB("%s: start PIT %016" PRIx64 "\n", __func__, ppcemb_timer->pit_reload); - } -#endif now = qemu_get_clock(vm_clock); next = now + muldiv64(ppcemb_timer->pit_reload, ticks_per_sec, tb_env->decr_freq); @@ -839,16 +791,12 @@ static void cpu_4xx_pit_cb (void *opaque) if ((env->spr[SPR_40x_TCR] >> 26) & 0x1) ppc_set_irq(env, PPC_INTERRUPT_PIT, 1); start_stop_pit(env, tb_env, 1); -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: ar %d ir %d TCR " ADDRX " TSR " ADDRX " " + LOG_TB("%s: ar %d ir %d TCR " ADDRX " TSR " ADDRX " " "%016" PRIx64 "\n", __func__, (int)((env->spr[SPR_40x_TCR] >> 22) & 0x1), (int)((env->spr[SPR_40x_TCR] >> 26) & 0x1), env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR], ppcemb_timer->pit_reload); - } -#endif } /* Watchdog timer */ @@ -883,12 +831,8 @@ static void cpu_4xx_wdt_cb (void *opaque) next = now + muldiv64(next, ticks_per_sec, tb_env->decr_freq); if (next == now) next++; -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: TCR " ADDRX " TSR " ADDRX "\n", __func__, + LOG_TB("%s: TCR " ADDRX " TSR " ADDRX "\n", __func__, env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR]); - } -#endif switch ((env->spr[SPR_40x_TSR] >> 30) & 0x3) { case 0x0: case 0x1: @@ -930,11 +874,7 @@ void store_40x_pit (CPUState *env, target_ulong val) tb_env = env->tb_env; ppcemb_timer = tb_env->opaque; -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s val" ADDRX "\n", __func__, val); - } -#endif + LOG_TB("%s val" ADDRX "\n", __func__, val); ppcemb_timer->pit_reload = val; start_stop_pit(env, tb_env, 0); } @@ -946,11 +886,7 @@ target_ulong load_40x_pit (CPUState *env) void store_booke_tsr (CPUState *env, target_ulong val) { -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: val " ADDRX "\n", __func__, val); - } -#endif + LOG_TB("%s: val " ADDRX "\n", __func__, val); env->spr[SPR_40x_TSR] &= ~(val & 0xFC000000); if (val & 0x80000000) ppc_set_irq(env, PPC_INTERRUPT_PIT, 0); @@ -961,11 +897,7 @@ void store_booke_tcr (CPUState *env, target_ulong val) ppc_tb_t *tb_env; tb_env = env->tb_env; -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s: val " ADDRX "\n", __func__, val); - } -#endif + LOG_TB("%s: val " ADDRX "\n", __func__, val); env->spr[SPR_40x_TCR] = val & 0xFFC00000; start_stop_pit(env, tb_env, 1); cpu_4xx_wdt_cb(env); @@ -976,12 +908,8 @@ static void ppc_emb_set_tb_clk (void *opaque, uint32_t freq) CPUState *env = opaque; ppc_tb_t *tb_env = env->tb_env; -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s set new frequency to %" PRIu32 "\n", __func__, + LOG_TB("%s set new frequency to %" PRIu32 "\n", __func__, freq); - } -#endif tb_env->tb_freq = freq; tb_env->decr_freq = freq; /* XXX: we should also update all timers */ @@ -1001,11 +929,7 @@ clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq) tb_env->tb_freq = freq; tb_env->decr_freq = freq; tb_env->opaque = ppcemb_timer; -#ifdef PPC_DEBUG_TB - if (loglevel != 0) { - fprintf(logfile, "%s freq %" PRIu32 "\n", __func__, freq); - } -#endif + LOG_TB("%s freq %" PRIu32 "\n", __func__, freq); if (ppcemb_timer != NULL) { /* We use decr timer for PIT */ tb_env->decr_timer = qemu_new_timer(vm_clock, &cpu_4xx_pit_cb, env); -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 05/13] vl.c: LOG_IOPORT macro 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (3 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 04/13] hw/ppc.c: use LOG_TB instead of #ifdefs Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 06/13] vl.c: use LOG_IOPORT instead of #ifdefs Eduardo Habkost ` (8 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost This macro will avoid some #ifdefs in the code and create a single point where the logging call can be changed in the future. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- vl.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/vl.c b/vl.c index c6d888c..c9fc13c 100644 --- a/vl.c +++ b/vl.c @@ -161,6 +161,16 @@ //#define DEBUG_NET //#define DEBUG_SLIRP + +#ifdef DEBUG_IOPORT +# define LOG_IOPORT(...) do { \ + if (loglevel & CPU_LOG_IOPORT) \ + fprintf(logfile, __VA_ARGS__); \ + } while (0) +#else +# define LOG_IOPORT(...) do { } while (0) +#endif + #ifdef TARGET_PPC #define DEFAULT_RAM_SIZE 144 #else -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 06/13] vl.c: use LOG_IOPORT instead of #ifdefs 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (4 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 05/13] vl.c: LOG_IOPORT macro Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 07/13] kqemu.c: LOG_INT macro Eduardo Habkost ` (7 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- vl.c | 30 ++++++------------------------ 1 files changed, 6 insertions(+), 24 deletions(-) diff --git a/vl.c b/vl.c index c9fc13c..07154d8 100644 --- a/vl.c +++ b/vl.c @@ -422,10 +422,7 @@ void isa_unassign_ioport(int start, int length) void cpu_outb(CPUState *env, int addr, int val) { -#ifdef DEBUG_IOPORT - if (loglevel & CPU_LOG_IOPORT) - fprintf(logfile, "outb: %04x %02x\n", addr, val); -#endif + LOG_IOPORT("outb: %04x %02x\n", addr, val); ioport_write(0, addr, val); #ifdef USE_KQEMU if (env) @@ -435,10 +432,7 @@ void cpu_outb(CPUState *env, int addr, int val) void cpu_outw(CPUState *env, int addr, int val) { -#ifdef DEBUG_IOPORT - if (loglevel & CPU_LOG_IOPORT) - fprintf(logfile, "outw: %04x %04x\n", addr, val); -#endif + LOG_IOPORT("outw: %04x %04x\n", addr, val); ioport_write(1, addr, val); #ifdef USE_KQEMU if (env) @@ -448,10 +442,7 @@ void cpu_outw(CPUState *env, int addr, int val) void cpu_outl(CPUState *env, int addr, int val) { -#ifdef DEBUG_IOPORT - if (loglevel & CPU_LOG_IOPORT) - fprintf(logfile, "outl: %04x %08x\n", addr, val); -#endif + LOG_IOPORT("outl: %04x %08x\n", addr, val); ioport_write(2, addr, val); #ifdef USE_KQEMU if (env) @@ -463,10 +454,7 @@ int cpu_inb(CPUState *env, int addr) { int val; val = ioport_read(0, addr); -#ifdef DEBUG_IOPORT - if (loglevel & CPU_LOG_IOPORT) - fprintf(logfile, "inb : %04x %02x\n", addr, val); -#endif + LOG_IOPORT("inb : %04x %02x\n", addr, val); #ifdef USE_KQEMU if (env) env->last_io_time = cpu_get_time_fast(); @@ -478,10 +466,7 @@ int cpu_inw(CPUState *env, int addr) { int val; val = ioport_read(1, addr); -#ifdef DEBUG_IOPORT - if (loglevel & CPU_LOG_IOPORT) - fprintf(logfile, "inw : %04x %04x\n", addr, val); -#endif + LOG_IOPORT("inw : %04x %04x\n", addr, val); #ifdef USE_KQEMU if (env) env->last_io_time = cpu_get_time_fast(); @@ -493,10 +478,7 @@ int cpu_inl(CPUState *env, int addr) { int val; val = ioport_read(2, addr); -#ifdef DEBUG_IOPORT - if (loglevel & CPU_LOG_IOPORT) - fprintf(logfile, "inl : %04x %08x\n", addr, val); -#endif + LOG_IOPORT("inl : %04x %08x\n", addr, val); #ifdef USE_KQEMU if (env) env->last_io_time = cpu_get_time_fast(); -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 07/13] kqemu.c: LOG_INT macro 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (5 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 06/13] vl.c: use LOG_IOPORT instead of #ifdefs Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 08/13] kqemu.c: use LOG_INT instead of #ifdefs Eduardo Habkost ` (6 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost This macro will avoid some #ifdefs in the code and create a single point where the logging call can be changed in the future. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- kqemu.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/kqemu.c b/kqemu.c index 4783aa2..9000d00 100644 --- a/kqemu.c +++ b/kqemu.c @@ -47,6 +47,16 @@ #define DEBUG //#define PROFILE + +#ifdef DEBUG +# define LOG_INT(...) do { \ + if (loglevel & CPU_LOG_INT) \ + fprintf(logfile, __VA_ARGS__); \ + } while (0) +#else +# define LOG_INT(...) do { } while (0) +#endif + #include <unistd.h> #include <fcntl.h> #include "kqemu.h" -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 08/13] kqemu.c: use LOG_INT instead of #ifdefs 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (6 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 07/13] kqemu.c: LOG_INT macro Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 09/13] kqemu.c: LOG_INT_STATE macro Eduardo Habkost ` (5 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- kqemu.c | 24 ++++-------------------- 1 files changed, 4 insertions(+), 20 deletions(-) diff --git a/kqemu.c b/kqemu.c index 9000d00..7ff99d6 100644 --- a/kqemu.c +++ b/kqemu.c @@ -251,11 +251,7 @@ int kqemu_init(CPUState *env) void kqemu_flush_page(CPUState *env, target_ulong addr) { -#if defined(DEBUG) - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "kqemu_flush_page: addr=" TARGET_FMT_lx "\n", addr); - } -#endif + LOG_INT("kqemu_flush_page: addr=" TARGET_FMT_lx "\n", addr); if (nb_pages_to_flush >= KQEMU_MAX_PAGES_TO_FLUSH) nb_pages_to_flush = KQEMU_FLUSH_ALL; else @@ -264,22 +260,14 @@ void kqemu_flush_page(CPUState *env, target_ulong addr) void kqemu_flush(CPUState *env, int global) { -#ifdef DEBUG - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "kqemu_flush:\n"); - } -#endif + LOG_INT("kqemu_flush:\n"); nb_pages_to_flush = KQEMU_FLUSH_ALL; } void kqemu_set_notdirty(CPUState *env, ram_addr_t ram_addr) { -#ifdef DEBUG - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "kqemu_set_notdirty: addr=%08lx\n", + LOG_INT("kqemu_set_notdirty: addr=%08lx\n", (unsigned long)ram_addr); - } -#endif /* we only track transitions to dirty state */ if (phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] != 0xff) return; @@ -877,11 +865,7 @@ int kqemu_cpu_exec(CPUState *env) else env->hflags &= ~HF_OSFXSR_MASK; -#ifdef DEBUG - if (loglevel & CPU_LOG_INT) { - fprintf(logfile, "kqemu: kqemu_cpu_exec: ret=0x%x\n", ret); - } -#endif + LOG_INT("kqemu: kqemu_cpu_exec: ret=0x%x\n", ret); if (ret == KQEMU_RET_SYSCALL) { /* syscall instruction */ return do_syscall(env, kenv); -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 09/13] kqemu.c: LOG_INT_STATE macro 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (7 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 08/13] kqemu.c: use LOG_INT instead of #ifdefs Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 10/13] kqemu.c: use LOG_INT_STATE instead of #ifdefs Eduardo Habkost ` (4 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost This macro will avoid some #ifdefs in the code and create a single point where the logging call can be changed in the future. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- kqemu.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/kqemu.c b/kqemu.c index 7ff99d6..912dac3 100644 --- a/kqemu.c +++ b/kqemu.c @@ -53,8 +53,14 @@ 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) #else # define LOG_INT(...) do { } while (0) +# define LOG_INT_STATE(env) do { } while (0) #endif #include <unistd.h> -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 10/13] kqemu.c: use LOG_INT_STATE instead of #ifdefs 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (8 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 09/13] kqemu.c: LOG_INT_STATE macro Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 11/13] target-i386/op_helper.c: LOG_PCALL macro Eduardo Habkost ` (3 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- kqemu.c | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-) diff --git a/kqemu.c b/kqemu.c index 912dac3..00a76ad 100644 --- a/kqemu.c +++ b/kqemu.c @@ -912,11 +912,7 @@ int kqemu_cpu_exec(CPUState *env) #ifdef CONFIG_PROFILER kqemu_ret_intr_count++; #endif -#ifdef DEBUG - if (loglevel & CPU_LOG_INT) { - cpu_dump_state(env, logfile, fprintf, 0); - } -#endif + LOG_INT_STATE(env); return 0; } else if (ret == KQEMU_RET_SOFTMMU) { #ifdef CONFIG_PROFILER @@ -925,11 +921,7 @@ int kqemu_cpu_exec(CPUState *env) kqemu_record_pc(pc); } #endif -#ifdef DEBUG - if (loglevel & CPU_LOG_INT) { - cpu_dump_state(env, logfile, fprintf, 0); - } -#endif + LOG_INT_STATE(env); return 2; } else { cpu_dump_state(env, stderr, fprintf, 0); -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 11/13] target-i386/op_helper.c: LOG_PCALL macro 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (9 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 10/13] kqemu.c: use LOG_INT_STATE instead of #ifdefs Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 12/13] target-i386/op_helper.c: use LOG_PCALL instead of #ifdefs Eduardo Habkost ` (2 subsequent siblings) 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost This macro will avoid some #ifdefs in the code and create a single point where the logging call can be changed in the future. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- target-i386/op_helper.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c index d32a6a3..13f65e1 100644 --- a/target-i386/op_helper.c +++ b/target-i386/op_helper.c @@ -23,6 +23,17 @@ //#define DEBUG_PCALL + +#ifdef DEBUG_PCALL +# define LOG_PCALL(...) do { \ + if (loglevel & CPU_LOG_PCALL) \ + fprintf(logfile, __VA_ARGS__); \ + } while (0) +#else +# define LOG_PCALL(...) do { } while (0) +#endif + + #if 0 #define raise_exception_err(a, b)\ do {\ -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 12/13] target-i386/op_helper.c: use LOG_PCALL instead of #ifdefs 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (10 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 11/13] target-i386/op_helper.c: LOG_PCALL macro Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 13/13] target-cris/translate.c: create LOG_DIS macro Eduardo Habkost 2008-12-10 21:37 ` [Qemu-devel] [PATCH 00/13] Cleanup some logging code Hollis Blanchard 13 siblings, 0 replies; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- target-i386/op_helper.c | 16 +++------------- 1 files changed, 3 insertions(+), 13 deletions(-) diff --git a/target-i386/op_helper.c b/target-i386/op_helper.c index 13f65e1..b0cd632 100644 --- a/target-i386/op_helper.c +++ b/target-i386/op_helper.c @@ -287,10 +287,7 @@ static void switch_tss(int tss_selector, target_ulong ptr; type = (e2 >> DESC_TYPE_SHIFT) & 0xf; -#ifdef DEBUG_PCALL - if (loglevel & CPU_LOG_PCALL) - fprintf(logfile, "switch_tss: sel=0x%04x type=%d src=%d\n", tss_selector, type, source); -#endif + LOG_PCALL("switch_tss: sel=0x%04x type=%d src=%d\n", tss_selector, type, source); /* if task gate, we read the TSS segment and we load it */ if (type == 5) { @@ -2408,11 +2405,8 @@ void helper_lcall_protected(int new_cs, target_ulong new_eip, if (!(e2 & DESC_C_MASK) && dpl < cpl) { /* to inner privilege */ get_ss_esp_from_tss(&ss, &sp, dpl); -#ifdef DEBUG_PCALL - if (loglevel & CPU_LOG_PCALL) - fprintf(logfile, "new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n", + LOG_PCALL("new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n", ss, sp, param_count, ESP); -#endif if ((ss & 0xfffc) == 0) raise_exception_err(EXCP0A_TSS, ss & 0xfffc); if ((ss & 3) != dpl) @@ -2655,12 +2649,8 @@ static inline void helper_ret_protected(int shift, int is_iret, int addend) POPW(ssp, sp, sp_mask, new_esp); POPW(ssp, sp, sp_mask, new_ss); } -#ifdef DEBUG_PCALL - if (loglevel & CPU_LOG_PCALL) { - fprintf(logfile, "new ss:esp=%04x:" TARGET_FMT_lx "\n", + LOG_PCALL("new ss:esp=%04x:" TARGET_FMT_lx "\n", new_ss, new_esp); - } -#endif if ((new_ss & 0xfffc) == 0) { #ifdef TARGET_X86_64 /* NULL ss is allowed in long mode if cpl != 3*/ -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH 13/13] target-cris/translate.c: create LOG_DIS macro 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (11 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 12/13] target-i386/op_helper.c: use LOG_PCALL instead of #ifdefs Eduardo Habkost @ 2008-12-10 18:24 ` Eduardo Habkost 2008-12-11 8:43 ` Edgar E. Iglesias 2008-12-10 21:37 ` [Qemu-devel] [PATCH 00/13] Cleanup some logging code Hollis Blanchard 13 siblings, 1 reply; 21+ messages in thread From: Eduardo Habkost @ 2008-12-10 18:24 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost Instead of using DIS(fprintf(logfile, fmt)) everywhere, create and use a LOG_DIS(fmt) macro. This will make changing the logging code easier in the future. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- target-cris/translate.c | 289 ++++++++++++++++++++++++----------------------- 1 files changed, 146 insertions(+), 143 deletions(-) diff --git a/target-cris/translate.c b/target-cris/translate.c index 242ef9c..a1769ac 100644 --- a/target-cris/translate.c +++ b/target-cris/translate.c @@ -44,9 +44,12 @@ #define DISAS_CRIS 0 #if DISAS_CRIS -#define DIS(x) if (loglevel & CPU_LOG_TB_IN_ASM) x +# define LOG_DIS(...) do { \ + if (loglevel & CPU_LOG_TB_IN_ASM) \ + fprintf(logfile, __VA_ARGS__); \ + } while (0) #else -#define DIS(x) +# define LOG_DIS(...) do { } while (0) #endif #define D(x) @@ -1463,7 +1466,7 @@ static unsigned int dec_bccq(DisasContext *dc) tmp = offset; offset = sign_extend(offset, 8); - DIS(fprintf (logfile, "b%s %x\n", cc_name(cond), dc->pc + offset)); + LOG_DIS("b%s %x\n", cc_name(cond), dc->pc + offset); /* op2 holds the condition-code. */ cris_cc_mask(dc, 0); @@ -1477,7 +1480,7 @@ static unsigned int dec_addoq(DisasContext *dc) dc->op1 = EXTRACT_FIELD(dc->ir, 0, 7); imm = sign_extend(dc->op1, 7); - DIS(fprintf (logfile, "addoq %d, $r%u\n", imm, dc->op2)); + LOG_DIS("addoq %d, $r%u\n", imm, dc->op2); cris_cc_mask(dc, 0); /* Fetch register operand, */ tcg_gen_addi_tl(cpu_R[R_ACR], cpu_R[dc->op2], imm); @@ -1486,7 +1489,7 @@ static unsigned int dec_addoq(DisasContext *dc) } static unsigned int dec_addq(DisasContext *dc) { - DIS(fprintf (logfile, "addq %u, $r%u\n", dc->op1, dc->op2)); + LOG_DIS("addq %u, $r%u\n", dc->op1, dc->op2); dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); @@ -1502,7 +1505,7 @@ static unsigned int dec_moveq(DisasContext *dc) dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); imm = sign_extend(dc->op1, 5); - DIS(fprintf (logfile, "moveq %d, $r%u\n", imm, dc->op2)); + LOG_DIS("moveq %d, $r%u\n", imm, dc->op2); tcg_gen_mov_tl(cpu_R[dc->op2], tcg_const_tl(imm)); return 2; @@ -1511,7 +1514,7 @@ static unsigned int dec_subq(DisasContext *dc) { dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); - DIS(fprintf (logfile, "subq %u, $r%u\n", dc->op1, dc->op2)); + LOG_DIS("subq %u, $r%u\n", dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); cris_alu(dc, CC_OP_SUB, @@ -1524,7 +1527,7 @@ static unsigned int dec_cmpq(DisasContext *dc) dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); imm = sign_extend(dc->op1, 5); - DIS(fprintf (logfile, "cmpq %d, $r%d\n", imm, dc->op2)); + LOG_DIS("cmpq %d, $r%d\n", imm, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); cris_alu(dc, CC_OP_CMP, @@ -1537,7 +1540,7 @@ static unsigned int dec_andq(DisasContext *dc) dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); imm = sign_extend(dc->op1, 5); - DIS(fprintf (logfile, "andq %d, $r%d\n", imm, dc->op2)); + LOG_DIS("andq %d, $r%d\n", imm, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); cris_alu(dc, CC_OP_AND, @@ -1549,7 +1552,7 @@ static unsigned int dec_orq(DisasContext *dc) uint32_t imm; dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); imm = sign_extend(dc->op1, 5); - DIS(fprintf (logfile, "orq %d, $r%d\n", imm, dc->op2)); + LOG_DIS("orq %d, $r%d\n", imm, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); cris_alu(dc, CC_OP_OR, @@ -1560,7 +1563,7 @@ static unsigned int dec_btstq(DisasContext *dc) { TCGv l0; dc->op1 = EXTRACT_FIELD(dc->ir, 0, 4); - DIS(fprintf (logfile, "btstq %u, $r%d\n", dc->op1, dc->op2)); + LOG_DIS("btstq %u, $r%d\n", dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); l0 = tcg_temp_local_new(); @@ -1575,7 +1578,7 @@ static unsigned int dec_btstq(DisasContext *dc) static unsigned int dec_asrq(DisasContext *dc) { dc->op1 = EXTRACT_FIELD(dc->ir, 0, 4); - DIS(fprintf (logfile, "asrq %u, $r%d\n", dc->op1, dc->op2)); + LOG_DIS("asrq %u, $r%d\n", dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); tcg_gen_sari_tl(cpu_R[dc->op2], cpu_R[dc->op2], dc->op1); @@ -1587,7 +1590,7 @@ static unsigned int dec_asrq(DisasContext *dc) static unsigned int dec_lslq(DisasContext *dc) { dc->op1 = EXTRACT_FIELD(dc->ir, 0, 4); - DIS(fprintf (logfile, "lslq %u, $r%d\n", dc->op1, dc->op2)); + LOG_DIS("lslq %u, $r%d\n", dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); @@ -1601,7 +1604,7 @@ static unsigned int dec_lslq(DisasContext *dc) static unsigned int dec_lsrq(DisasContext *dc) { dc->op1 = EXTRACT_FIELD(dc->ir, 0, 4); - DIS(fprintf (logfile, "lsrq %u, $r%d\n", dc->op1, dc->op2)); + LOG_DIS("lsrq %u, $r%d\n", dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); @@ -1616,8 +1619,8 @@ static unsigned int dec_move_r(DisasContext *dc) { int size = memsize_zz(dc); - DIS(fprintf (logfile, "move.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("move.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); if (size == 4) { @@ -1644,8 +1647,8 @@ static unsigned int dec_scc_r(DisasContext *dc) { int cond = dc->op2; - DIS(fprintf (logfile, "s%s $r%u\n", - cc_name(cond), dc->op1)); + LOG_DIS("s%s $r%u\n", + cc_name(cond), dc->op1); if (cond != CC_A) { @@ -1688,8 +1691,8 @@ static unsigned int dec_and_r(DisasContext *dc) TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "and.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("and.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); @@ -1703,8 +1706,8 @@ static unsigned int dec_and_r(DisasContext *dc) static unsigned int dec_lz_r(DisasContext *dc) { TCGv t0; - DIS(fprintf (logfile, "lz $r%u, $r%u\n", - dc->op1, dc->op2)); + LOG_DIS("lz $r%u, $r%u\n", + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); t0 = tcg_temp_new(); dec_prep_alu_r(dc, dc->op1, dc->op2, 4, 0, cpu_R[dc->op2], t0); @@ -1718,8 +1721,8 @@ static unsigned int dec_lsl_r(DisasContext *dc) TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "lsl.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("lsl.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); cris_alu_alloc_temps(dc, size, t); @@ -1735,8 +1738,8 @@ static unsigned int dec_lsr_r(DisasContext *dc) TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "lsr.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("lsr.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); cris_alu_alloc_temps(dc, size, t); @@ -1752,8 +1755,8 @@ static unsigned int dec_asr_r(DisasContext *dc) TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "asr.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("asr.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); cris_alu_alloc_temps(dc, size, t); @@ -1769,8 +1772,8 @@ static unsigned int dec_muls_r(DisasContext *dc) TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "muls.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("muls.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZV); cris_alu_alloc_temps(dc, size, t); dec_prep_alu_r(dc, dc->op1, dc->op2, size, 1, t[0], t[1]); @@ -1785,8 +1788,8 @@ static unsigned int dec_mulu_r(DisasContext *dc) TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "mulu.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("mulu.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZV); cris_alu_alloc_temps(dc, size, t); dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); @@ -1799,7 +1802,7 @@ static unsigned int dec_mulu_r(DisasContext *dc) static unsigned int dec_dstep_r(DisasContext *dc) { - DIS(fprintf (logfile, "dstep $r%u, $r%u\n", dc->op1, dc->op2)); + LOG_DIS("dstep $r%u, $r%u\n", dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); cris_alu(dc, CC_OP_DSTEP, cpu_R[dc->op2], cpu_R[dc->op2], cpu_R[dc->op1], 4); @@ -1810,8 +1813,8 @@ static unsigned int dec_xor_r(DisasContext *dc) { TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "xor.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("xor.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); BUG_ON(size != 4); /* xor is dword. */ cris_cc_mask(dc, CC_MASK_NZ); cris_alu_alloc_temps(dc, size, t); @@ -1826,8 +1829,8 @@ static unsigned int dec_bound_r(DisasContext *dc) { TCGv l0; int size = memsize_zz(dc); - DIS(fprintf (logfile, "bound.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("bound.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); l0 = tcg_temp_local_new(); dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, l0); @@ -1840,8 +1843,8 @@ static unsigned int dec_cmp_r(DisasContext *dc) { TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "cmp.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("cmp.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); cris_alu_alloc_temps(dc, size, t); dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); @@ -1855,8 +1858,8 @@ static unsigned int dec_abs_r(DisasContext *dc) { TCGv t0; - DIS(fprintf (logfile, "abs $r%u, $r%u\n", - dc->op1, dc->op2)); + LOG_DIS("abs $r%u, $r%u\n", + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); t0 = tcg_temp_new(); @@ -1874,8 +1877,8 @@ static unsigned int dec_add_r(DisasContext *dc) { TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "add.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("add.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); cris_alu_alloc_temps(dc, size, t); dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); @@ -1887,8 +1890,8 @@ static unsigned int dec_add_r(DisasContext *dc) static unsigned int dec_addc_r(DisasContext *dc) { - DIS(fprintf (logfile, "addc $r%u, $r%u\n", - dc->op1, dc->op2)); + LOG_DIS("addc $r%u, $r%u\n", + dc->op1, dc->op2); cris_evaluate_flags(dc); cris_cc_mask(dc, CC_MASK_NZVC); cris_alu(dc, CC_OP_ADDC, @@ -1898,8 +1901,8 @@ static unsigned int dec_addc_r(DisasContext *dc) static unsigned int dec_mcp_r(DisasContext *dc) { - DIS(fprintf (logfile, "mcp $p%u, $r%u\n", - dc->op2, dc->op1)); + LOG_DIS("mcp $p%u, $r%u\n", + dc->op2, dc->op1); cris_evaluate_flags(dc); cris_cc_mask(dc, CC_MASK_RNZV); cris_alu(dc, CC_OP_MCP, @@ -1929,8 +1932,8 @@ static unsigned int dec_swap_r(DisasContext *dc) #if DISAS_CRIS char modename[4]; #endif - DIS(fprintf (logfile, "swap%s $r%u\n", - swapmode_name(dc->op2, modename), dc->op1)); + LOG_DIS("swap%s $r%u\n", + swapmode_name(dc->op2, modename), dc->op1); cris_cc_mask(dc, CC_MASK_NZ); t0 = tcg_temp_new(); @@ -1953,8 +1956,8 @@ static unsigned int dec_or_r(DisasContext *dc) { TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "or.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("or.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); cris_alu_alloc_temps(dc, size, t); dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); @@ -1966,8 +1969,8 @@ static unsigned int dec_or_r(DisasContext *dc) static unsigned int dec_addi_r(DisasContext *dc) { TCGv t0; - DIS(fprintf (logfile, "addi.%c $r%u, $r%u\n", - memsize_char(memsize_zz(dc)), dc->op2, dc->op1)); + LOG_DIS("addi.%c $r%u, $r%u\n", + memsize_char(memsize_zz(dc)), dc->op2, dc->op1); cris_cc_mask(dc, 0); t0 = tcg_temp_new(); tcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize)); @@ -1979,8 +1982,8 @@ static unsigned int dec_addi_r(DisasContext *dc) static unsigned int dec_addi_acr(DisasContext *dc) { TCGv t0; - DIS(fprintf (logfile, "addi.%c $r%u, $r%u, $acr\n", - memsize_char(memsize_zz(dc)), dc->op2, dc->op1)); + LOG_DIS("addi.%c $r%u, $r%u, $acr\n", + memsize_char(memsize_zz(dc)), dc->op2, dc->op1); cris_cc_mask(dc, 0); t0 = tcg_temp_new(); tcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize)); @@ -1993,8 +1996,8 @@ static unsigned int dec_neg_r(DisasContext *dc) { TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "neg.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("neg.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); cris_alu_alloc_temps(dc, size, t); dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); @@ -2007,8 +2010,8 @@ static unsigned int dec_neg_r(DisasContext *dc) static unsigned int dec_btst_r(DisasContext *dc) { TCGv l0; - DIS(fprintf (logfile, "btst $r%u, $r%u\n", - dc->op1, dc->op2)); + LOG_DIS("btst $r%u, $r%u\n", + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); l0 = tcg_temp_local_new(); @@ -2024,8 +2027,8 @@ static unsigned int dec_sub_r(DisasContext *dc) { TCGv t[2]; int size = memsize_zz(dc); - DIS(fprintf (logfile, "sub.%c $r%u, $r%u\n", - memsize_char(size), dc->op1, dc->op2)); + LOG_DIS("sub.%c $r%u, $r%u\n", + memsize_char(size), dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); cris_alu_alloc_temps(dc, size, t); dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); @@ -2039,9 +2042,9 @@ static unsigned int dec_movu_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); - DIS(fprintf (logfile, "movu.%c $r%u, $r%u\n", + LOG_DIS("movu.%c $r%u, $r%u\n", memsize_char(size), - dc->op1, dc->op2)); + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); t0 = tcg_temp_new(); @@ -2056,9 +2059,9 @@ static unsigned int dec_movs_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); - DIS(fprintf (logfile, "movs.%c $r%u, $r%u\n", + LOG_DIS("movs.%c $r%u, $r%u\n", memsize_char(size), - dc->op1, dc->op2)); + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZ); t0 = tcg_temp_new(); @@ -2075,9 +2078,9 @@ static unsigned int dec_addu_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); - DIS(fprintf (logfile, "addu.%c $r%u, $r%u\n", + LOG_DIS("addu.%c $r%u, $r%u\n", memsize_char(size), - dc->op1, dc->op2)); + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); t0 = tcg_temp_new(); @@ -2094,9 +2097,9 @@ static unsigned int dec_adds_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); - DIS(fprintf (logfile, "adds.%c $r%u, $r%u\n", + LOG_DIS("adds.%c $r%u, $r%u\n", memsize_char(size), - dc->op1, dc->op2)); + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); t0 = tcg_temp_new(); @@ -2113,9 +2116,9 @@ static unsigned int dec_subu_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); - DIS(fprintf (logfile, "subu.%c $r%u, $r%u\n", + LOG_DIS("subu.%c $r%u, $r%u\n", memsize_char(size), - dc->op1, dc->op2)); + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); t0 = tcg_temp_new(); @@ -2132,9 +2135,9 @@ static unsigned int dec_subs_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); - DIS(fprintf (logfile, "subs.%c $r%u, $r%u\n", + LOG_DIS("subs.%c $r%u, $r%u\n", memsize_char(size), - dc->op1, dc->op2)); + dc->op1, dc->op2); cris_cc_mask(dc, CC_MASK_NZVC); t0 = tcg_temp_new(); @@ -2155,15 +2158,15 @@ static unsigned int dec_setclrf(DisasContext *dc) flags = (EXTRACT_FIELD(dc->ir, 12, 15) << 4) | EXTRACT_FIELD(dc->ir, 0, 3); if (set && flags == 0) { - DIS(fprintf (logfile, "nop\n")); + LOG_DIS("nop\n"); return 2; } else if (!set && (flags & 0x20)) { - DIS(fprintf (logfile, "di\n")); + LOG_DIS("di\n"); } else { - DIS(fprintf (logfile, "%sf %x\n", + LOG_DIS("%sf %x\n", set ? "set" : "clr", - flags)); + flags); } /* User space is not allowed to touch these. Silently ignore. */ @@ -2218,14 +2221,14 @@ static unsigned int dec_setclrf(DisasContext *dc) static unsigned int dec_move_rs(DisasContext *dc) { - DIS(fprintf (logfile, "move $r%u, $s%u\n", dc->op1, dc->op2)); + LOG_DIS("move $r%u, $s%u\n", dc->op1, dc->op2); cris_cc_mask(dc, 0); gen_helper_movl_sreg_reg(tcg_const_tl(dc->op2), tcg_const_tl(dc->op1)); return 2; } static unsigned int dec_move_sr(DisasContext *dc) { - DIS(fprintf (logfile, "move $s%u, $r%u\n", dc->op2, dc->op1)); + LOG_DIS("move $s%u, $r%u\n", dc->op2, dc->op1); cris_cc_mask(dc, 0); gen_helper_movl_reg_sreg(tcg_const_tl(dc->op1), tcg_const_tl(dc->op2)); return 2; @@ -2234,7 +2237,7 @@ static unsigned int dec_move_sr(DisasContext *dc) static unsigned int dec_move_rp(DisasContext *dc) { TCGv t[2]; - DIS(fprintf (logfile, "move $r%u, $p%u\n", dc->op1, dc->op2)); + LOG_DIS("move $r%u, $p%u\n", dc->op1, dc->op2); cris_cc_mask(dc, 0); t[0] = tcg_temp_new(); @@ -2264,7 +2267,7 @@ static unsigned int dec_move_rp(DisasContext *dc) static unsigned int dec_move_pr(DisasContext *dc) { TCGv t0; - DIS(fprintf (logfile, "move $p%u, $r%u\n", dc->op1, dc->op2)); + LOG_DIS("move $p%u, $r%u\n", dc->op1, dc->op2); cris_cc_mask(dc, 0); if (dc->op2 == PR_CCS) @@ -2282,10 +2285,10 @@ static unsigned int dec_move_mr(DisasContext *dc) { int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "move.%c [$r%u%s, $r%u\n", + LOG_DIS("move.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); if (memsize == 4) { insn_len = dec_prep_move_m(dc, 0, 4, cpu_R[dc->op2]); @@ -2325,10 +2328,10 @@ static unsigned int dec_movs_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_z(dc); int insn_len; - DIS(fprintf (logfile, "movs.%c [$r%u%s, $r%u\n", + LOG_DIS("movs.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); /* sign extend. */ @@ -2346,10 +2349,10 @@ static unsigned int dec_addu_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_z(dc); int insn_len; - DIS(fprintf (logfile, "addu.%c [$r%u%s, $r%u\n", + LOG_DIS("addu.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); /* sign extend. */ @@ -2367,10 +2370,10 @@ static unsigned int dec_adds_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_z(dc); int insn_len; - DIS(fprintf (logfile, "adds.%c [$r%u%s, $r%u\n", + LOG_DIS("adds.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); /* sign extend. */ @@ -2387,10 +2390,10 @@ static unsigned int dec_subu_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_z(dc); int insn_len; - DIS(fprintf (logfile, "subu.%c [$r%u%s, $r%u\n", + LOG_DIS("subu.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); /* sign extend. */ @@ -2407,10 +2410,10 @@ static unsigned int dec_subs_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_z(dc); int insn_len; - DIS(fprintf (logfile, "subs.%c [$r%u%s, $r%u\n", + LOG_DIS("subs.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); /* sign extend. */ @@ -2428,10 +2431,10 @@ static unsigned int dec_movu_m(DisasContext *dc) int memsize = memsize_z(dc); int insn_len; - DIS(fprintf (logfile, "movu.%c [$r%u%s, $r%u\n", + LOG_DIS("movu.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); @@ -2447,10 +2450,10 @@ static unsigned int dec_cmpu_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_z(dc); int insn_len; - DIS(fprintf (logfile, "cmpu.%c [$r%u%s, $r%u\n", + LOG_DIS("cmpu.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); @@ -2466,10 +2469,10 @@ static unsigned int dec_cmps_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_z(dc); int insn_len; - DIS(fprintf (logfile, "cmps.%c [$r%u%s, $r%u\n", + LOG_DIS("cmps.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 1, memsize, t[0], t[1]); @@ -2487,10 +2490,10 @@ static unsigned int dec_cmp_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "cmp.%c [$r%u%s, $r%u\n", + LOG_DIS("cmp.%c [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); @@ -2508,10 +2511,10 @@ static unsigned int dec_test_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "test.%d [$r%u%s] op2=%x\n", + LOG_DIS("test.%d [$r%u%s] op2=%x\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_evaluate_flags(dc); @@ -2532,10 +2535,10 @@ static unsigned int dec_and_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "and.%d [$r%u%s, $r%u\n", + LOG_DIS("and.%d [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); @@ -2551,10 +2554,10 @@ static unsigned int dec_add_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "add.%d [$r%u%s, $r%u\n", + LOG_DIS("add.%d [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); @@ -2571,10 +2574,10 @@ static unsigned int dec_addo_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "add.%d [$r%u%s, $r%u\n", + LOG_DIS("add.%d [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 1, memsize, t[0], t[1]); @@ -2590,10 +2593,10 @@ static unsigned int dec_bound_m(DisasContext *dc) TCGv l[2]; int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "bound.%d [$r%u%s, $r%u\n", + LOG_DIS("bound.%d [$r%u%s, $r%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); l[0] = tcg_temp_local_new(); l[1] = tcg_temp_local_new(); @@ -2610,9 +2613,9 @@ static unsigned int dec_addc_mr(DisasContext *dc) { TCGv t[2]; int insn_len = 2; - DIS(fprintf (logfile, "addc [$r%u%s, $r%u\n", + LOG_DIS("addc [$r%u%s, $r%u\n", dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_evaluate_flags(dc); cris_alu_m_alloc_temps(t); @@ -2629,10 +2632,10 @@ static unsigned int dec_sub_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "sub.%c [$r%u%s, $r%u ir=%x zz=%x\n", + LOG_DIS("sub.%c [$r%u%s, $r%u ir=%x zz=%x\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2, dc->ir, dc->zzsize)); + dc->op2, dc->ir, dc->zzsize); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); @@ -2648,10 +2651,10 @@ static unsigned int dec_or_m(DisasContext *dc) TCGv t[2]; int memsize = memsize_zz(dc); int insn_len; - DIS(fprintf (logfile, "or.%d [$r%u%s, $r%u pc=%x\n", + LOG_DIS("or.%d [$r%u%s, $r%u pc=%x\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2, dc->pc)); + dc->op2, dc->pc); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); @@ -2669,11 +2672,11 @@ static unsigned int dec_move_mp(DisasContext *dc) int memsize = memsize_zz(dc); int insn_len = 2; - DIS(fprintf (logfile, "move.%c [$r%u%s, $p%u\n", + LOG_DIS("move.%c [$r%u%s, $p%u\n", memsize_char(memsize), dc->op1, dc->postinc ? "+]" : "]", - dc->op2)); + dc->op2); cris_alu_m_alloc_temps(t); insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); @@ -2702,9 +2705,9 @@ static unsigned int dec_move_pm(DisasContext *dc) memsize = preg_sizes[dc->op2]; - DIS(fprintf (logfile, "move.%c $p%u, [$r%u%s\n", + LOG_DIS("move.%c $p%u, [$r%u%s\n", memsize_char(memsize), - dc->op2, dc->op1, dc->postinc ? "+]" : "]")); + dc->op2, dc->op1, dc->postinc ? "+]" : "]"); /* prepare store. Address in T0, value in T1. */ if (dc->op2 == PR_CCS) @@ -2729,8 +2732,8 @@ static unsigned int dec_movem_mr(DisasContext *dc) int i; int nr = dc->op2 + 1; - DIS(fprintf (logfile, "movem [$r%u%s, $r%u\n", dc->op1, - dc->postinc ? "+]" : "]", dc->op2)); + LOG_DIS("movem [$r%u%s, $r%u\n", dc->op1, + dc->postinc ? "+]" : "]", dc->op2); addr = tcg_temp_new(); /* There are probably better ways of doing this. */ @@ -2773,8 +2776,8 @@ static unsigned int dec_movem_rm(DisasContext *dc) TCGv addr; int i; - DIS(fprintf (logfile, "movem $r%u, [$r%u%s\n", dc->op2, dc->op1, - dc->postinc ? "+]" : "]")); + LOG_DIS("movem $r%u, [$r%u%s\n", dc->op2, dc->op1, + dc->postinc ? "+]" : "]"); cris_flush_cc_state(dc); @@ -2802,8 +2805,8 @@ static unsigned int dec_move_rm(DisasContext *dc) memsize = memsize_zz(dc); - DIS(fprintf (logfile, "move.%d $r%u, [$r%u]\n", - memsize, dc->op2, dc->op1)); + LOG_DIS("move.%d $r%u, [$r%u]\n", + memsize, dc->op2, dc->op1); /* prepare store. */ cris_flush_cc_state(dc); @@ -2817,8 +2820,8 @@ static unsigned int dec_move_rm(DisasContext *dc) static unsigned int dec_lapcq(DisasContext *dc) { - DIS(fprintf (logfile, "lapcq %x, $r%u\n", - dc->pc + dc->op1*2, dc->op2)); + LOG_DIS("lapcq %x, $r%u\n", + dc->pc + dc->op1*2, dc->op2); cris_cc_mask(dc, 0); tcg_gen_movi_tl(cpu_R[dc->op2], dc->pc + dc->op1 * 2); return 2; @@ -2834,7 +2837,7 @@ static unsigned int dec_lapc_im(DisasContext *dc) cris_cc_mask(dc, 0); imm = ldl_code(dc->pc + 2); - DIS(fprintf (logfile, "lapc 0x%x, $r%u\n", imm + dc->pc, dc->op2)); + LOG_DIS("lapc 0x%x, $r%u\n", imm + dc->pc, dc->op2); pc = dc->pc; pc += imm; @@ -2845,7 +2848,7 @@ static unsigned int dec_lapc_im(DisasContext *dc) /* Jump to special reg. */ static unsigned int dec_jump_p(DisasContext *dc) { - DIS(fprintf (logfile, "jump $p%u\n", dc->op2)); + LOG_DIS("jump $p%u\n", dc->op2); if (dc->op2 == PR_CCS) cris_evaluate_flags(dc); @@ -2860,7 +2863,7 @@ static unsigned int dec_jump_p(DisasContext *dc) /* Jump and save. */ static unsigned int dec_jas_r(DisasContext *dc) { - DIS(fprintf (logfile, "jas $r%u, $p%u\n", dc->op1, dc->op2)); + LOG_DIS("jas $r%u, $p%u\n", dc->op1, dc->op2); cris_cc_mask(dc, 0); /* Store the return address in Pd. */ tcg_gen_mov_tl(env_btarget, cpu_R[dc->op1]); @@ -2878,7 +2881,7 @@ static unsigned int dec_jas_im(DisasContext *dc) imm = ldl_code(dc->pc + 2); - DIS(fprintf (logfile, "jas 0x%x\n", imm)); + LOG_DIS("jas 0x%x\n", imm); cris_cc_mask(dc, 0); /* Store the return address in Pd. */ t_gen_mov_preg_TN(dc, dc->op2, tcg_const_tl(dc->pc + 8)); @@ -2894,7 +2897,7 @@ static unsigned int dec_jasc_im(DisasContext *dc) imm = ldl_code(dc->pc + 2); - DIS(fprintf (logfile, "jasc 0x%x\n", imm)); + LOG_DIS("jasc 0x%x\n", imm); cris_cc_mask(dc, 0); /* Store the return address in Pd. */ t_gen_mov_preg_TN(dc, dc->op2, tcg_const_tl(dc->pc + 8 + 4)); @@ -2906,7 +2909,7 @@ static unsigned int dec_jasc_im(DisasContext *dc) static unsigned int dec_jasc_r(DisasContext *dc) { - DIS(fprintf (logfile, "jasc_r $r%u, $p%u\n", dc->op1, dc->op2)); + LOG_DIS("jasc_r $r%u, $p%u\n", dc->op1, dc->op2); cris_cc_mask(dc, 0); /* Store the return address in Pd. */ tcg_gen_mov_tl(env_btarget, cpu_R[dc->op1]); @@ -2922,9 +2925,9 @@ static unsigned int dec_bcc_im(DisasContext *dc) offset = ldsw_code(dc->pc + 2); - DIS(fprintf (logfile, "b%s %d pc=%x dst=%x\n", + LOG_DIS("b%s %d pc=%x dst=%x\n", cc_name(cond), offset, - dc->pc, dc->pc + offset)); + dc->pc, dc->pc + offset); cris_cc_mask(dc, 0); /* op2 holds the condition-code. */ @@ -2939,7 +2942,7 @@ static unsigned int dec_bas_im(DisasContext *dc) simm = ldl_code(dc->pc + 2); - DIS(fprintf (logfile, "bas 0x%x, $p%u\n", dc->pc + simm, dc->op2)); + LOG_DIS("bas 0x%x, $p%u\n", dc->pc + simm, dc->op2); cris_cc_mask(dc, 0); /* Store the return address in Pd. */ t_gen_mov_preg_TN(dc, dc->op2, tcg_const_tl(dc->pc + 8)); @@ -2954,7 +2957,7 @@ static unsigned int dec_basc_im(DisasContext *dc) int32_t simm; simm = ldl_code(dc->pc + 2); - DIS(fprintf (logfile, "basc 0x%x, $p%u\n", dc->pc + simm, dc->op2)); + LOG_DIS("basc 0x%x, $p%u\n", dc->pc + simm, dc->op2); cris_cc_mask(dc, 0); /* Store the return address in Pd. */ t_gen_mov_preg_TN(dc, dc->op2, tcg_const_tl(dc->pc + 12)); @@ -2974,20 +2977,20 @@ static unsigned int dec_rfe_etc(DisasContext *dc) switch (dc->op2 & 7) { case 2: /* rfe. */ - DIS(fprintf(logfile, "rfe\n")); + LOG_DIS("rfe\n"); cris_evaluate_flags(dc); gen_helper_rfe(); dc->is_jmp = DISAS_UPDATE; break; case 5: /* rfn. */ - DIS(fprintf(logfile, "rfn\n")); + LOG_DIS("rfn\n"); cris_evaluate_flags(dc); gen_helper_rfn(); dc->is_jmp = DISAS_UPDATE; break; case 6: - DIS(fprintf(logfile, "break %d\n", dc->op1)); + LOG_DIS("break %d\n", dc->op1); cris_evaluate_flags (dc); /* break. */ tcg_gen_movi_tl(env_pc, dc->pc + 2); @@ -3339,7 +3342,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, } /* Pretty disas. */ - DIS(fprintf(logfile, "%8.8x:\t", dc->pc)); + LOG_DIS("%8.8x:\t", dc->pc); if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) gen_io_start(); -- 1.5.5.GIT ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 13/13] target-cris/translate.c: create LOG_DIS macro 2008-12-10 18:24 ` [Qemu-devel] [PATCH 13/13] target-cris/translate.c: create LOG_DIS macro Eduardo Habkost @ 2008-12-11 8:43 ` Edgar E. Iglesias 0 siblings, 0 replies; 21+ messages in thread From: Edgar E. Iglesias @ 2008-12-11 8:43 UTC (permalink / raw) To: Eduardo Habkost; +Cc: qemu-devel On Wed, Dec 10, 2008 at 04:24:24PM -0200, Eduardo Habkost wrote: > Instead of using DIS(fprintf(logfile, fmt)) everywhere, create and use > a LOG_DIS(fmt) macro. This will make changing the logging code easier > in the future. > > Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Looks good, thanks. Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> > --- > target-cris/translate.c | 289 ++++++++++++++++++++++++----------------------- > 1 files changed, 146 insertions(+), 143 deletions(-) > > diff --git a/target-cris/translate.c b/target-cris/translate.c > index 242ef9c..a1769ac 100644 > --- a/target-cris/translate.c > +++ b/target-cris/translate.c > @@ -44,9 +44,12 @@ > > #define DISAS_CRIS 0 > #if DISAS_CRIS > -#define DIS(x) if (loglevel & CPU_LOG_TB_IN_ASM) x > +# define LOG_DIS(...) do { \ > + if (loglevel & CPU_LOG_TB_IN_ASM) \ > + fprintf(logfile, __VA_ARGS__); \ > + } while (0) > #else > -#define DIS(x) > +# define LOG_DIS(...) do { } while (0) > #endif > > #define D(x) > @@ -1463,7 +1466,7 @@ static unsigned int dec_bccq(DisasContext *dc) > tmp = offset; > offset = sign_extend(offset, 8); > > - DIS(fprintf (logfile, "b%s %x\n", cc_name(cond), dc->pc + offset)); > + LOG_DIS("b%s %x\n", cc_name(cond), dc->pc + offset); > > /* op2 holds the condition-code. */ > cris_cc_mask(dc, 0); > @@ -1477,7 +1480,7 @@ static unsigned int dec_addoq(DisasContext *dc) > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 7); > imm = sign_extend(dc->op1, 7); > > - DIS(fprintf (logfile, "addoq %d, $r%u\n", imm, dc->op2)); > + LOG_DIS("addoq %d, $r%u\n", imm, dc->op2); > cris_cc_mask(dc, 0); > /* Fetch register operand, */ > tcg_gen_addi_tl(cpu_R[R_ACR], cpu_R[dc->op2], imm); > @@ -1486,7 +1489,7 @@ static unsigned int dec_addoq(DisasContext *dc) > } > static unsigned int dec_addq(DisasContext *dc) > { > - DIS(fprintf (logfile, "addq %u, $r%u\n", dc->op1, dc->op2)); > + LOG_DIS("addq %u, $r%u\n", dc->op1, dc->op2); > > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); > > @@ -1502,7 +1505,7 @@ static unsigned int dec_moveq(DisasContext *dc) > > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); > imm = sign_extend(dc->op1, 5); > - DIS(fprintf (logfile, "moveq %d, $r%u\n", imm, dc->op2)); > + LOG_DIS("moveq %d, $r%u\n", imm, dc->op2); > > tcg_gen_mov_tl(cpu_R[dc->op2], tcg_const_tl(imm)); > return 2; > @@ -1511,7 +1514,7 @@ static unsigned int dec_subq(DisasContext *dc) > { > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); > > - DIS(fprintf (logfile, "subq %u, $r%u\n", dc->op1, dc->op2)); > + LOG_DIS("subq %u, $r%u\n", dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZVC); > cris_alu(dc, CC_OP_SUB, > @@ -1524,7 +1527,7 @@ static unsigned int dec_cmpq(DisasContext *dc) > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); > imm = sign_extend(dc->op1, 5); > > - DIS(fprintf (logfile, "cmpq %d, $r%d\n", imm, dc->op2)); > + LOG_DIS("cmpq %d, $r%d\n", imm, dc->op2); > cris_cc_mask(dc, CC_MASK_NZVC); > > cris_alu(dc, CC_OP_CMP, > @@ -1537,7 +1540,7 @@ static unsigned int dec_andq(DisasContext *dc) > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); > imm = sign_extend(dc->op1, 5); > > - DIS(fprintf (logfile, "andq %d, $r%d\n", imm, dc->op2)); > + LOG_DIS("andq %d, $r%d\n", imm, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > > cris_alu(dc, CC_OP_AND, > @@ -1549,7 +1552,7 @@ static unsigned int dec_orq(DisasContext *dc) > uint32_t imm; > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 5); > imm = sign_extend(dc->op1, 5); > - DIS(fprintf (logfile, "orq %d, $r%d\n", imm, dc->op2)); > + LOG_DIS("orq %d, $r%d\n", imm, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > > cris_alu(dc, CC_OP_OR, > @@ -1560,7 +1563,7 @@ static unsigned int dec_btstq(DisasContext *dc) > { > TCGv l0; > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 4); > - DIS(fprintf (logfile, "btstq %u, $r%d\n", dc->op1, dc->op2)); > + LOG_DIS("btstq %u, $r%d\n", dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > l0 = tcg_temp_local_new(); > @@ -1575,7 +1578,7 @@ static unsigned int dec_btstq(DisasContext *dc) > static unsigned int dec_asrq(DisasContext *dc) > { > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 4); > - DIS(fprintf (logfile, "asrq %u, $r%d\n", dc->op1, dc->op2)); > + LOG_DIS("asrq %u, $r%d\n", dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > > tcg_gen_sari_tl(cpu_R[dc->op2], cpu_R[dc->op2], dc->op1); > @@ -1587,7 +1590,7 @@ static unsigned int dec_asrq(DisasContext *dc) > static unsigned int dec_lslq(DisasContext *dc) > { > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 4); > - DIS(fprintf (logfile, "lslq %u, $r%d\n", dc->op1, dc->op2)); > + LOG_DIS("lslq %u, $r%d\n", dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > > @@ -1601,7 +1604,7 @@ static unsigned int dec_lslq(DisasContext *dc) > static unsigned int dec_lsrq(DisasContext *dc) > { > dc->op1 = EXTRACT_FIELD(dc->ir, 0, 4); > - DIS(fprintf (logfile, "lsrq %u, $r%d\n", dc->op1, dc->op2)); > + LOG_DIS("lsrq %u, $r%d\n", dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > > @@ -1616,8 +1619,8 @@ static unsigned int dec_move_r(DisasContext *dc) > { > int size = memsize_zz(dc); > > - DIS(fprintf (logfile, "move.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("move.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > if (size == 4) { > @@ -1644,8 +1647,8 @@ static unsigned int dec_scc_r(DisasContext *dc) > { > int cond = dc->op2; > > - DIS(fprintf (logfile, "s%s $r%u\n", > - cc_name(cond), dc->op1)); > + LOG_DIS("s%s $r%u\n", > + cc_name(cond), dc->op1); > > if (cond != CC_A) > { > @@ -1688,8 +1691,8 @@ static unsigned int dec_and_r(DisasContext *dc) > TCGv t[2]; > int size = memsize_zz(dc); > > - DIS(fprintf (logfile, "and.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("and.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > > @@ -1703,8 +1706,8 @@ static unsigned int dec_and_r(DisasContext *dc) > static unsigned int dec_lz_r(DisasContext *dc) > { > TCGv t0; > - DIS(fprintf (logfile, "lz $r%u, $r%u\n", > - dc->op1, dc->op2)); > + LOG_DIS("lz $r%u, $r%u\n", > + dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > t0 = tcg_temp_new(); > dec_prep_alu_r(dc, dc->op1, dc->op2, 4, 0, cpu_R[dc->op2], t0); > @@ -1718,8 +1721,8 @@ static unsigned int dec_lsl_r(DisasContext *dc) > TCGv t[2]; > int size = memsize_zz(dc); > > - DIS(fprintf (logfile, "lsl.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("lsl.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > cris_alu_alloc_temps(dc, size, t); > @@ -1735,8 +1738,8 @@ static unsigned int dec_lsr_r(DisasContext *dc) > TCGv t[2]; > int size = memsize_zz(dc); > > - DIS(fprintf (logfile, "lsr.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("lsr.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > cris_alu_alloc_temps(dc, size, t); > @@ -1752,8 +1755,8 @@ static unsigned int dec_asr_r(DisasContext *dc) > TCGv t[2]; > int size = memsize_zz(dc); > > - DIS(fprintf (logfile, "asr.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("asr.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > cris_alu_alloc_temps(dc, size, t); > @@ -1769,8 +1772,8 @@ static unsigned int dec_muls_r(DisasContext *dc) > TCGv t[2]; > int size = memsize_zz(dc); > > - DIS(fprintf (logfile, "muls.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("muls.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZV); > cris_alu_alloc_temps(dc, size, t); > dec_prep_alu_r(dc, dc->op1, dc->op2, size, 1, t[0], t[1]); > @@ -1785,8 +1788,8 @@ static unsigned int dec_mulu_r(DisasContext *dc) > TCGv t[2]; > int size = memsize_zz(dc); > > - DIS(fprintf (logfile, "mulu.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("mulu.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZV); > cris_alu_alloc_temps(dc, size, t); > dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); > @@ -1799,7 +1802,7 @@ static unsigned int dec_mulu_r(DisasContext *dc) > > static unsigned int dec_dstep_r(DisasContext *dc) > { > - DIS(fprintf (logfile, "dstep $r%u, $r%u\n", dc->op1, dc->op2)); > + LOG_DIS("dstep $r%u, $r%u\n", dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > cris_alu(dc, CC_OP_DSTEP, > cpu_R[dc->op2], cpu_R[dc->op2], cpu_R[dc->op1], 4); > @@ -1810,8 +1813,8 @@ static unsigned int dec_xor_r(DisasContext *dc) > { > TCGv t[2]; > int size = memsize_zz(dc); > - DIS(fprintf (logfile, "xor.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("xor.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > BUG_ON(size != 4); /* xor is dword. */ > cris_cc_mask(dc, CC_MASK_NZ); > cris_alu_alloc_temps(dc, size, t); > @@ -1826,8 +1829,8 @@ static unsigned int dec_bound_r(DisasContext *dc) > { > TCGv l0; > int size = memsize_zz(dc); > - DIS(fprintf (logfile, "bound.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("bound.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > l0 = tcg_temp_local_new(); > dec_prep_move_r(dc, dc->op1, dc->op2, size, 0, l0); > @@ -1840,8 +1843,8 @@ static unsigned int dec_cmp_r(DisasContext *dc) > { > TCGv t[2]; > int size = memsize_zz(dc); > - DIS(fprintf (logfile, "cmp.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("cmp.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZVC); > cris_alu_alloc_temps(dc, size, t); > dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); > @@ -1855,8 +1858,8 @@ static unsigned int dec_abs_r(DisasContext *dc) > { > TCGv t0; > > - DIS(fprintf (logfile, "abs $r%u, $r%u\n", > - dc->op1, dc->op2)); > + LOG_DIS("abs $r%u, $r%u\n", > + dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > > t0 = tcg_temp_new(); > @@ -1874,8 +1877,8 @@ static unsigned int dec_add_r(DisasContext *dc) > { > TCGv t[2]; > int size = memsize_zz(dc); > - DIS(fprintf (logfile, "add.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("add.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZVC); > cris_alu_alloc_temps(dc, size, t); > dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); > @@ -1887,8 +1890,8 @@ static unsigned int dec_add_r(DisasContext *dc) > > static unsigned int dec_addc_r(DisasContext *dc) > { > - DIS(fprintf (logfile, "addc $r%u, $r%u\n", > - dc->op1, dc->op2)); > + LOG_DIS("addc $r%u, $r%u\n", > + dc->op1, dc->op2); > cris_evaluate_flags(dc); > cris_cc_mask(dc, CC_MASK_NZVC); > cris_alu(dc, CC_OP_ADDC, > @@ -1898,8 +1901,8 @@ static unsigned int dec_addc_r(DisasContext *dc) > > static unsigned int dec_mcp_r(DisasContext *dc) > { > - DIS(fprintf (logfile, "mcp $p%u, $r%u\n", > - dc->op2, dc->op1)); > + LOG_DIS("mcp $p%u, $r%u\n", > + dc->op2, dc->op1); > cris_evaluate_flags(dc); > cris_cc_mask(dc, CC_MASK_RNZV); > cris_alu(dc, CC_OP_MCP, > @@ -1929,8 +1932,8 @@ static unsigned int dec_swap_r(DisasContext *dc) > #if DISAS_CRIS > char modename[4]; > #endif > - DIS(fprintf (logfile, "swap%s $r%u\n", > - swapmode_name(dc->op2, modename), dc->op1)); > + LOG_DIS("swap%s $r%u\n", > + swapmode_name(dc->op2, modename), dc->op1); > > cris_cc_mask(dc, CC_MASK_NZ); > t0 = tcg_temp_new(); > @@ -1953,8 +1956,8 @@ static unsigned int dec_or_r(DisasContext *dc) > { > TCGv t[2]; > int size = memsize_zz(dc); > - DIS(fprintf (logfile, "or.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("or.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > cris_alu_alloc_temps(dc, size, t); > dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); > @@ -1966,8 +1969,8 @@ static unsigned int dec_or_r(DisasContext *dc) > static unsigned int dec_addi_r(DisasContext *dc) > { > TCGv t0; > - DIS(fprintf (logfile, "addi.%c $r%u, $r%u\n", > - memsize_char(memsize_zz(dc)), dc->op2, dc->op1)); > + LOG_DIS("addi.%c $r%u, $r%u\n", > + memsize_char(memsize_zz(dc)), dc->op2, dc->op1); > cris_cc_mask(dc, 0); > t0 = tcg_temp_new(); > tcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize)); > @@ -1979,8 +1982,8 @@ static unsigned int dec_addi_r(DisasContext *dc) > static unsigned int dec_addi_acr(DisasContext *dc) > { > TCGv t0; > - DIS(fprintf (logfile, "addi.%c $r%u, $r%u, $acr\n", > - memsize_char(memsize_zz(dc)), dc->op2, dc->op1)); > + LOG_DIS("addi.%c $r%u, $r%u, $acr\n", > + memsize_char(memsize_zz(dc)), dc->op2, dc->op1); > cris_cc_mask(dc, 0); > t0 = tcg_temp_new(); > tcg_gen_shl_tl(t0, cpu_R[dc->op2], tcg_const_tl(dc->zzsize)); > @@ -1993,8 +1996,8 @@ static unsigned int dec_neg_r(DisasContext *dc) > { > TCGv t[2]; > int size = memsize_zz(dc); > - DIS(fprintf (logfile, "neg.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("neg.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZVC); > cris_alu_alloc_temps(dc, size, t); > dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); > @@ -2007,8 +2010,8 @@ static unsigned int dec_neg_r(DisasContext *dc) > static unsigned int dec_btst_r(DisasContext *dc) > { > TCGv l0; > - DIS(fprintf (logfile, "btst $r%u, $r%u\n", > - dc->op1, dc->op2)); > + LOG_DIS("btst $r%u, $r%u\n", > + dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZ); > > l0 = tcg_temp_local_new(); > @@ -2024,8 +2027,8 @@ static unsigned int dec_sub_r(DisasContext *dc) > { > TCGv t[2]; > int size = memsize_zz(dc); > - DIS(fprintf (logfile, "sub.%c $r%u, $r%u\n", > - memsize_char(size), dc->op1, dc->op2)); > + LOG_DIS("sub.%c $r%u, $r%u\n", > + memsize_char(size), dc->op1, dc->op2); > cris_cc_mask(dc, CC_MASK_NZVC); > cris_alu_alloc_temps(dc, size, t); > dec_prep_alu_r(dc, dc->op1, dc->op2, size, 0, t[0], t[1]); > @@ -2039,9 +2042,9 @@ static unsigned int dec_movu_r(DisasContext *dc) > { > TCGv t0; > int size = memsize_z(dc); > - DIS(fprintf (logfile, "movu.%c $r%u, $r%u\n", > + LOG_DIS("movu.%c $r%u, $r%u\n", > memsize_char(size), > - dc->op1, dc->op2)); > + dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > t0 = tcg_temp_new(); > @@ -2056,9 +2059,9 @@ static unsigned int dec_movs_r(DisasContext *dc) > { > TCGv t0; > int size = memsize_z(dc); > - DIS(fprintf (logfile, "movs.%c $r%u, $r%u\n", > + LOG_DIS("movs.%c $r%u, $r%u\n", > memsize_char(size), > - dc->op1, dc->op2)); > + dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZ); > t0 = tcg_temp_new(); > @@ -2075,9 +2078,9 @@ static unsigned int dec_addu_r(DisasContext *dc) > { > TCGv t0; > int size = memsize_z(dc); > - DIS(fprintf (logfile, "addu.%c $r%u, $r%u\n", > + LOG_DIS("addu.%c $r%u, $r%u\n", > memsize_char(size), > - dc->op1, dc->op2)); > + dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZVC); > t0 = tcg_temp_new(); > @@ -2094,9 +2097,9 @@ static unsigned int dec_adds_r(DisasContext *dc) > { > TCGv t0; > int size = memsize_z(dc); > - DIS(fprintf (logfile, "adds.%c $r%u, $r%u\n", > + LOG_DIS("adds.%c $r%u, $r%u\n", > memsize_char(size), > - dc->op1, dc->op2)); > + dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZVC); > t0 = tcg_temp_new(); > @@ -2113,9 +2116,9 @@ static unsigned int dec_subu_r(DisasContext *dc) > { > TCGv t0; > int size = memsize_z(dc); > - DIS(fprintf (logfile, "subu.%c $r%u, $r%u\n", > + LOG_DIS("subu.%c $r%u, $r%u\n", > memsize_char(size), > - dc->op1, dc->op2)); > + dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZVC); > t0 = tcg_temp_new(); > @@ -2132,9 +2135,9 @@ static unsigned int dec_subs_r(DisasContext *dc) > { > TCGv t0; > int size = memsize_z(dc); > - DIS(fprintf (logfile, "subs.%c $r%u, $r%u\n", > + LOG_DIS("subs.%c $r%u, $r%u\n", > memsize_char(size), > - dc->op1, dc->op2)); > + dc->op1, dc->op2); > > cris_cc_mask(dc, CC_MASK_NZVC); > t0 = tcg_temp_new(); > @@ -2155,15 +2158,15 @@ static unsigned int dec_setclrf(DisasContext *dc) > flags = (EXTRACT_FIELD(dc->ir, 12, 15) << 4) > | EXTRACT_FIELD(dc->ir, 0, 3); > if (set && flags == 0) { > - DIS(fprintf (logfile, "nop\n")); > + LOG_DIS("nop\n"); > return 2; > } else if (!set && (flags & 0x20)) { > - DIS(fprintf (logfile, "di\n")); > + LOG_DIS("di\n"); > } > else { > - DIS(fprintf (logfile, "%sf %x\n", > + LOG_DIS("%sf %x\n", > set ? "set" : "clr", > - flags)); > + flags); > } > > /* User space is not allowed to touch these. Silently ignore. */ > @@ -2218,14 +2221,14 @@ static unsigned int dec_setclrf(DisasContext *dc) > > static unsigned int dec_move_rs(DisasContext *dc) > { > - DIS(fprintf (logfile, "move $r%u, $s%u\n", dc->op1, dc->op2)); > + LOG_DIS("move $r%u, $s%u\n", dc->op1, dc->op2); > cris_cc_mask(dc, 0); > gen_helper_movl_sreg_reg(tcg_const_tl(dc->op2), tcg_const_tl(dc->op1)); > return 2; > } > static unsigned int dec_move_sr(DisasContext *dc) > { > - DIS(fprintf (logfile, "move $s%u, $r%u\n", dc->op2, dc->op1)); > + LOG_DIS("move $s%u, $r%u\n", dc->op2, dc->op1); > cris_cc_mask(dc, 0); > gen_helper_movl_reg_sreg(tcg_const_tl(dc->op1), tcg_const_tl(dc->op2)); > return 2; > @@ -2234,7 +2237,7 @@ static unsigned int dec_move_sr(DisasContext *dc) > static unsigned int dec_move_rp(DisasContext *dc) > { > TCGv t[2]; > - DIS(fprintf (logfile, "move $r%u, $p%u\n", dc->op1, dc->op2)); > + LOG_DIS("move $r%u, $p%u\n", dc->op1, dc->op2); > cris_cc_mask(dc, 0); > > t[0] = tcg_temp_new(); > @@ -2264,7 +2267,7 @@ static unsigned int dec_move_rp(DisasContext *dc) > static unsigned int dec_move_pr(DisasContext *dc) > { > TCGv t0; > - DIS(fprintf (logfile, "move $p%u, $r%u\n", dc->op1, dc->op2)); > + LOG_DIS("move $p%u, $r%u\n", dc->op1, dc->op2); > cris_cc_mask(dc, 0); > > if (dc->op2 == PR_CCS) > @@ -2282,10 +2285,10 @@ static unsigned int dec_move_mr(DisasContext *dc) > { > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "move.%c [$r%u%s, $r%u\n", > + LOG_DIS("move.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > if (memsize == 4) { > insn_len = dec_prep_move_m(dc, 0, 4, cpu_R[dc->op2]); > @@ -2325,10 +2328,10 @@ static unsigned int dec_movs_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_z(dc); > int insn_len; > - DIS(fprintf (logfile, "movs.%c [$r%u%s, $r%u\n", > + LOG_DIS("movs.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > /* sign extend. */ > @@ -2346,10 +2349,10 @@ static unsigned int dec_addu_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_z(dc); > int insn_len; > - DIS(fprintf (logfile, "addu.%c [$r%u%s, $r%u\n", > + LOG_DIS("addu.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > /* sign extend. */ > @@ -2367,10 +2370,10 @@ static unsigned int dec_adds_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_z(dc); > int insn_len; > - DIS(fprintf (logfile, "adds.%c [$r%u%s, $r%u\n", > + LOG_DIS("adds.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > /* sign extend. */ > @@ -2387,10 +2390,10 @@ static unsigned int dec_subu_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_z(dc); > int insn_len; > - DIS(fprintf (logfile, "subu.%c [$r%u%s, $r%u\n", > + LOG_DIS("subu.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > /* sign extend. */ > @@ -2407,10 +2410,10 @@ static unsigned int dec_subs_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_z(dc); > int insn_len; > - DIS(fprintf (logfile, "subs.%c [$r%u%s, $r%u\n", > + LOG_DIS("subs.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > /* sign extend. */ > @@ -2428,10 +2431,10 @@ static unsigned int dec_movu_m(DisasContext *dc) > int memsize = memsize_z(dc); > int insn_len; > > - DIS(fprintf (logfile, "movu.%c [$r%u%s, $r%u\n", > + LOG_DIS("movu.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); > @@ -2447,10 +2450,10 @@ static unsigned int dec_cmpu_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_z(dc); > int insn_len; > - DIS(fprintf (logfile, "cmpu.%c [$r%u%s, $r%u\n", > + LOG_DIS("cmpu.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); > @@ -2466,10 +2469,10 @@ static unsigned int dec_cmps_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_z(dc); > int insn_len; > - DIS(fprintf (logfile, "cmps.%c [$r%u%s, $r%u\n", > + LOG_DIS("cmps.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 1, memsize, t[0], t[1]); > @@ -2487,10 +2490,10 @@ static unsigned int dec_cmp_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "cmp.%c [$r%u%s, $r%u\n", > + LOG_DIS("cmp.%c [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); > @@ -2508,10 +2511,10 @@ static unsigned int dec_test_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "test.%d [$r%u%s] op2=%x\n", > + LOG_DIS("test.%d [$r%u%s] op2=%x\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_evaluate_flags(dc); > > @@ -2532,10 +2535,10 @@ static unsigned int dec_and_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "and.%d [$r%u%s, $r%u\n", > + LOG_DIS("and.%d [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); > @@ -2551,10 +2554,10 @@ static unsigned int dec_add_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "add.%d [$r%u%s, $r%u\n", > + LOG_DIS("add.%d [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); > @@ -2571,10 +2574,10 @@ static unsigned int dec_addo_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "add.%d [$r%u%s, $r%u\n", > + LOG_DIS("add.%d [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 1, memsize, t[0], t[1]); > @@ -2590,10 +2593,10 @@ static unsigned int dec_bound_m(DisasContext *dc) > TCGv l[2]; > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "bound.%d [$r%u%s, $r%u\n", > + LOG_DIS("bound.%d [$r%u%s, $r%u\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > l[0] = tcg_temp_local_new(); > l[1] = tcg_temp_local_new(); > @@ -2610,9 +2613,9 @@ static unsigned int dec_addc_mr(DisasContext *dc) > { > TCGv t[2]; > int insn_len = 2; > - DIS(fprintf (logfile, "addc [$r%u%s, $r%u\n", > + LOG_DIS("addc [$r%u%s, $r%u\n", > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_evaluate_flags(dc); > cris_alu_m_alloc_temps(t); > @@ -2629,10 +2632,10 @@ static unsigned int dec_sub_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "sub.%c [$r%u%s, $r%u ir=%x zz=%x\n", > + LOG_DIS("sub.%c [$r%u%s, $r%u ir=%x zz=%x\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2, dc->ir, dc->zzsize)); > + dc->op2, dc->ir, dc->zzsize); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); > @@ -2648,10 +2651,10 @@ static unsigned int dec_or_m(DisasContext *dc) > TCGv t[2]; > int memsize = memsize_zz(dc); > int insn_len; > - DIS(fprintf (logfile, "or.%d [$r%u%s, $r%u pc=%x\n", > + LOG_DIS("or.%d [$r%u%s, $r%u pc=%x\n", > memsize_char(memsize), > dc->op1, dc->postinc ? "+]" : "]", > - dc->op2, dc->pc)); > + dc->op2, dc->pc); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); > @@ -2669,11 +2672,11 @@ static unsigned int dec_move_mp(DisasContext *dc) > int memsize = memsize_zz(dc); > int insn_len = 2; > > - DIS(fprintf (logfile, "move.%c [$r%u%s, $p%u\n", > + LOG_DIS("move.%c [$r%u%s, $p%u\n", > memsize_char(memsize), > dc->op1, > dc->postinc ? "+]" : "]", > - dc->op2)); > + dc->op2); > > cris_alu_m_alloc_temps(t); > insn_len = dec_prep_alu_m(dc, 0, memsize, t[0], t[1]); > @@ -2702,9 +2705,9 @@ static unsigned int dec_move_pm(DisasContext *dc) > > memsize = preg_sizes[dc->op2]; > > - DIS(fprintf (logfile, "move.%c $p%u, [$r%u%s\n", > + LOG_DIS("move.%c $p%u, [$r%u%s\n", > memsize_char(memsize), > - dc->op2, dc->op1, dc->postinc ? "+]" : "]")); > + dc->op2, dc->op1, dc->postinc ? "+]" : "]"); > > /* prepare store. Address in T0, value in T1. */ > if (dc->op2 == PR_CCS) > @@ -2729,8 +2732,8 @@ static unsigned int dec_movem_mr(DisasContext *dc) > int i; > int nr = dc->op2 + 1; > > - DIS(fprintf (logfile, "movem [$r%u%s, $r%u\n", dc->op1, > - dc->postinc ? "+]" : "]", dc->op2)); > + LOG_DIS("movem [$r%u%s, $r%u\n", dc->op1, > + dc->postinc ? "+]" : "]", dc->op2); > > addr = tcg_temp_new(); > /* There are probably better ways of doing this. */ > @@ -2773,8 +2776,8 @@ static unsigned int dec_movem_rm(DisasContext *dc) > TCGv addr; > int i; > > - DIS(fprintf (logfile, "movem $r%u, [$r%u%s\n", dc->op2, dc->op1, > - dc->postinc ? "+]" : "]")); > + LOG_DIS("movem $r%u, [$r%u%s\n", dc->op2, dc->op1, > + dc->postinc ? "+]" : "]"); > > cris_flush_cc_state(dc); > > @@ -2802,8 +2805,8 @@ static unsigned int dec_move_rm(DisasContext *dc) > > memsize = memsize_zz(dc); > > - DIS(fprintf (logfile, "move.%d $r%u, [$r%u]\n", > - memsize, dc->op2, dc->op1)); > + LOG_DIS("move.%d $r%u, [$r%u]\n", > + memsize, dc->op2, dc->op1); > > /* prepare store. */ > cris_flush_cc_state(dc); > @@ -2817,8 +2820,8 @@ static unsigned int dec_move_rm(DisasContext *dc) > > static unsigned int dec_lapcq(DisasContext *dc) > { > - DIS(fprintf (logfile, "lapcq %x, $r%u\n", > - dc->pc + dc->op1*2, dc->op2)); > + LOG_DIS("lapcq %x, $r%u\n", > + dc->pc + dc->op1*2, dc->op2); > cris_cc_mask(dc, 0); > tcg_gen_movi_tl(cpu_R[dc->op2], dc->pc + dc->op1 * 2); > return 2; > @@ -2834,7 +2837,7 @@ static unsigned int dec_lapc_im(DisasContext *dc) > > cris_cc_mask(dc, 0); > imm = ldl_code(dc->pc + 2); > - DIS(fprintf (logfile, "lapc 0x%x, $r%u\n", imm + dc->pc, dc->op2)); > + LOG_DIS("lapc 0x%x, $r%u\n", imm + dc->pc, dc->op2); > > pc = dc->pc; > pc += imm; > @@ -2845,7 +2848,7 @@ static unsigned int dec_lapc_im(DisasContext *dc) > /* Jump to special reg. */ > static unsigned int dec_jump_p(DisasContext *dc) > { > - DIS(fprintf (logfile, "jump $p%u\n", dc->op2)); > + LOG_DIS("jump $p%u\n", dc->op2); > > if (dc->op2 == PR_CCS) > cris_evaluate_flags(dc); > @@ -2860,7 +2863,7 @@ static unsigned int dec_jump_p(DisasContext *dc) > /* Jump and save. */ > static unsigned int dec_jas_r(DisasContext *dc) > { > - DIS(fprintf (logfile, "jas $r%u, $p%u\n", dc->op1, dc->op2)); > + LOG_DIS("jas $r%u, $p%u\n", dc->op1, dc->op2); > cris_cc_mask(dc, 0); > /* Store the return address in Pd. */ > tcg_gen_mov_tl(env_btarget, cpu_R[dc->op1]); > @@ -2878,7 +2881,7 @@ static unsigned int dec_jas_im(DisasContext *dc) > > imm = ldl_code(dc->pc + 2); > > - DIS(fprintf (logfile, "jas 0x%x\n", imm)); > + LOG_DIS("jas 0x%x\n", imm); > cris_cc_mask(dc, 0); > /* Store the return address in Pd. */ > t_gen_mov_preg_TN(dc, dc->op2, tcg_const_tl(dc->pc + 8)); > @@ -2894,7 +2897,7 @@ static unsigned int dec_jasc_im(DisasContext *dc) > > imm = ldl_code(dc->pc + 2); > > - DIS(fprintf (logfile, "jasc 0x%x\n", imm)); > + LOG_DIS("jasc 0x%x\n", imm); > cris_cc_mask(dc, 0); > /* Store the return address in Pd. */ > t_gen_mov_preg_TN(dc, dc->op2, tcg_const_tl(dc->pc + 8 + 4)); > @@ -2906,7 +2909,7 @@ static unsigned int dec_jasc_im(DisasContext *dc) > > static unsigned int dec_jasc_r(DisasContext *dc) > { > - DIS(fprintf (logfile, "jasc_r $r%u, $p%u\n", dc->op1, dc->op2)); > + LOG_DIS("jasc_r $r%u, $p%u\n", dc->op1, dc->op2); > cris_cc_mask(dc, 0); > /* Store the return address in Pd. */ > tcg_gen_mov_tl(env_btarget, cpu_R[dc->op1]); > @@ -2922,9 +2925,9 @@ static unsigned int dec_bcc_im(DisasContext *dc) > > offset = ldsw_code(dc->pc + 2); > > - DIS(fprintf (logfile, "b%s %d pc=%x dst=%x\n", > + LOG_DIS("b%s %d pc=%x dst=%x\n", > cc_name(cond), offset, > - dc->pc, dc->pc + offset)); > + dc->pc, dc->pc + offset); > > cris_cc_mask(dc, 0); > /* op2 holds the condition-code. */ > @@ -2939,7 +2942,7 @@ static unsigned int dec_bas_im(DisasContext *dc) > > simm = ldl_code(dc->pc + 2); > > - DIS(fprintf (logfile, "bas 0x%x, $p%u\n", dc->pc + simm, dc->op2)); > + LOG_DIS("bas 0x%x, $p%u\n", dc->pc + simm, dc->op2); > cris_cc_mask(dc, 0); > /* Store the return address in Pd. */ > t_gen_mov_preg_TN(dc, dc->op2, tcg_const_tl(dc->pc + 8)); > @@ -2954,7 +2957,7 @@ static unsigned int dec_basc_im(DisasContext *dc) > int32_t simm; > simm = ldl_code(dc->pc + 2); > > - DIS(fprintf (logfile, "basc 0x%x, $p%u\n", dc->pc + simm, dc->op2)); > + LOG_DIS("basc 0x%x, $p%u\n", dc->pc + simm, dc->op2); > cris_cc_mask(dc, 0); > /* Store the return address in Pd. */ > t_gen_mov_preg_TN(dc, dc->op2, tcg_const_tl(dc->pc + 12)); > @@ -2974,20 +2977,20 @@ static unsigned int dec_rfe_etc(DisasContext *dc) > switch (dc->op2 & 7) { > case 2: > /* rfe. */ > - DIS(fprintf(logfile, "rfe\n")); > + LOG_DIS("rfe\n"); > cris_evaluate_flags(dc); > gen_helper_rfe(); > dc->is_jmp = DISAS_UPDATE; > break; > case 5: > /* rfn. */ > - DIS(fprintf(logfile, "rfn\n")); > + LOG_DIS("rfn\n"); > cris_evaluate_flags(dc); > gen_helper_rfn(); > dc->is_jmp = DISAS_UPDATE; > break; > case 6: > - DIS(fprintf(logfile, "break %d\n", dc->op1)); > + LOG_DIS("break %d\n", dc->op1); > cris_evaluate_flags (dc); > /* break. */ > tcg_gen_movi_tl(env_pc, dc->pc + 2); > @@ -3339,7 +3342,7 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, > } > > /* Pretty disas. */ > - DIS(fprintf(logfile, "%8.8x:\t", dc->pc)); > + LOG_DIS("%8.8x:\t", dc->pc); > > if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) > gen_io_start(); > -- > 1.5.5.GIT > > ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH 00/13] Cleanup some logging code 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost ` (12 preceding siblings ...) 2008-12-10 18:24 ` [Qemu-devel] [PATCH 13/13] target-cris/translate.c: create LOG_DIS macro Eduardo Habkost @ 2008-12-10 21:37 ` Hollis Blanchard 13 siblings, 0 replies; 21+ messages in thread From: Hollis Blanchard @ 2008-12-10 21:37 UTC (permalink / raw) To: qemu-devel; +Cc: Eduardo Habkost On Wed, 2008-12-10 at 16:24 -0200, Eduardo Habkost wrote: > The following patches are small cleanups of the logging code on multiple > partes of qemu. Most of them are for removing duplicated code and #ifdefs > from the code. The patches are available on a git tree (see pull request > below). > > My long-term plan is to have a propper logging API on qemu, instead of > the global variables 'loglevel' and 'logfile'. These cleanups should > make that work easier, in addition to the code readability improvement. Sounds good to me. You might want to look at GRUB2's grub_dprintf(), which has proven invaluable for low-level remote debugging. Basically you can just tell someone to run "set debug=disk" at runtime to enable the "disk" class of debug output. Other classes include partition map, ELF loading, filesystems, etc. It's nothing revolutionary, but it's been really really useful. -- Hollis Blanchard IBM Linux Technology Center ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2008-12-14 18:09 UTC | newest] Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-12-10 18:24 [Qemu-devel] [PATCH 00/13] Cleanup some logging code Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 01/13] hw/ppc.c: LOG_IRQ macro Eduardo Habkost 2008-12-11 21:45 ` Anthony Liguori 2008-12-11 22:54 ` Andreas Färber 2008-12-11 23:31 ` Eduardo Habkost 2008-12-14 18:09 ` Jamie Lokier 2008-12-12 14:31 ` Anthony Liguori 2008-12-10 18:24 ` [Qemu-devel] [PATCH 02/13] hw/ppc.c: use LOG_IRQ instead of #ifdefs Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 03/13] hw/ppc.c: LOG_TB macro Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 04/13] hw/ppc.c: use LOG_TB instead of #ifdefs Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 05/13] vl.c: LOG_IOPORT macro Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 06/13] vl.c: use LOG_IOPORT instead of #ifdefs Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 07/13] kqemu.c: LOG_INT macro Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 08/13] kqemu.c: use LOG_INT instead of #ifdefs Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 09/13] kqemu.c: LOG_INT_STATE macro Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 10/13] kqemu.c: use LOG_INT_STATE instead of #ifdefs Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 11/13] target-i386/op_helper.c: LOG_PCALL macro Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 12/13] target-i386/op_helper.c: use LOG_PCALL instead of #ifdefs Eduardo Habkost 2008-12-10 18:24 ` [Qemu-devel] [PATCH 13/13] target-cris/translate.c: create LOG_DIS macro Eduardo Habkost 2008-12-11 8:43 ` Edgar E. Iglesias 2008-12-10 21:37 ` [Qemu-devel] [PATCH 00/13] Cleanup some logging code Hollis Blanchard
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.