qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Kovalenko <igor.v.kovalenko@gmail.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: qemu-devel@nongnu.org, aurelien@aurel32.net, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH V12 24/27] pm_smbus: remove #ifdef DEBUG.
Date: Thu, 7 Jan 2010 03:05:41 +0300	[thread overview]
Message-ID: <b2fa41d61001061605q3e91b929sbc706877389eece3@mail.gmail.com> (raw)
In-Reply-To: <20100106235113.GE29412@valinux.co.jp>

On Thu, Jan 7, 2010 at 2:51 AM, Isaku Yamahata <yamahata@valinux.co.jp> wrote:
> On Wed, Jan 06, 2010 at 12:42:28PM +0100, Stefan Weil wrote:
>> Isaku Yamahata schrieb:
>> > remove #ifdef DEBUG by using macro.
>> >
>> > Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
>> > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
>> > ---
>> > hw/pm_smbus.c | 21 ++++++++++++---------
>> > 1 files changed, 12 insertions(+), 9 deletions(-)
>> >
>> > diff --git a/hw/pm_smbus.c b/hw/pm_smbus.c
>> > index 6ef6b9e..9929d72 100644
>> > --- a/hw/pm_smbus.c
>> > +++ b/hw/pm_smbus.c
>> > @@ -37,6 +37,15 @@
>> > #define SMBHSTDAT1 0x06
>> > #define SMBBLKDAT 0x07
>> >
>> > +//#define DEBUG
>> > +
>> > +#ifdef DEBUG
>> > +# define SMBUS_DPRINTF(format, ...) printf(format, ## __VA_ARGS__)
>>
>> Debug output should go to stderr. So this would be even better:
>>
>> +# define SMBUS_DPRINTF(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
>>
>
> Yes, in general.
> However the original code sends debug output to stdout and
> Most of debug output goes to stdout than stderr. You can easily
> see it by greping with DEBUG.
>
> So at this time, I'd like to send debug output to stdout.
> (And hopefully later create a framework and make debug output go
> to stderr consistently over sources.)

Maybe logfile redirection would do as well, with a few changes to
logfile handling.
Default may be stderr or stdout (with appropriate command line switch)

This way you can do debug output to logfile always. The following
changes sets default to stdout always and prevents errors while
reopening logfile.

diff --git a/vl.c b/vl.c
index e881e45..63c199c 100644
--- a/vl.c
+++ b/vl.c
@@ -4878,6 +4878,9 @@ int main(int argc, char **argv, char **envp)
     CPUState *env;
     int show_vnc_port = 0;

+    /* Prevent unfortunate early crash with debugging fprintf */
+    logfile=stdout;
+
     init_clocks();

     qemu_errors_to_file(stderr);
l

diff --git a/exec.c b/exec.c
index 2b068f5..752e208 100644
--- a/exec.c
+++ b/exec.c
@@ -1494,7 +1494,7 @@ void cpu_single_step(CPUState *env, int enabled)
 void cpu_set_log(int log_flags)
 {
     loglevel = log_flags;
-    if (loglevel && !logfile) {
+    if (loglevel && (!logfile || logfile == stdout)) {
         logfile = fopen(logfilename, log_append ? "a" : "w");
         if (!logfile) {
             perror(logfilename);
@@ -1521,7 +1521,7 @@ void cpu_set_log(int log_flags)
 void cpu_set_log_filename(const char *filename)
 {
     logfilename = strdup(filename);
-    if (logfile) {
+    if (logfile && logfile != stdout) {
         fclose(logfile);
         logfile = NULL;
     }

-- 
Kind regards,
Igor V. Kovalenko

  reply	other threads:[~2010-01-07  0:05 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06  2:39 [Qemu-devel] [PATCH V12 00/27] split out piix specific part from pc emulator and some clean ups Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 01/27] acpi: split out piix4 smbus routines from acpi.c into pm_smbus.c Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 02/27] acpi: split out apm register emulation from acpi.c Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 03/27] acpi: add acpi constants from linux header files and use them Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 04/27] acpi: split acpi.c into the common part and the piix4 part Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 05/27] acpi_piix4: remove unused variable in get_pmsts() Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 06/27] pc: initialize ioapic before use Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 07/27] pc, i440fx: Make smm enable/disable function i440fx independent Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 08/27] pc: make an unnecessary global variable, pit, local Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 09/27] pc: remove a global variable, floppy_controller Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 10/27] pc: remove global variable rtc_state by using qemu_irq Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 11/27] pc: introduce a function to allocate cpu irq Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 12/27] pc: make pc_init1() not refer ferr_irq directly Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 13/27] pc: split out cpu initialization from pc_init1() into pc_cpus_init() Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 14/27] pc: split out memory allocation from pc_init1() into pc_memory_init() Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 15/27] pc: split out vga initialization from pc_init1() into pc_vga_init() Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 16/27] pc: split out basic device init from pc_init1() into pc_basic_device_init() Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 17/27] pc: split out pci device init from pc_init1() into pc_pci_device_init() Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 18/27] pc: split out piix specific part from pc.c into pc_piix.c Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 19/27] pc: move rtc declarations from pc.h into a dedicated header file Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 20/27] rtc: make rtc_xxx accept/return ISADevice instead of RTCState Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 21/27] acpi_piix4: qdevfy Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 22/27] pci hotplug: add argument to pci hot plug callback Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 23/27] pci hotadd, acpi_piix4: remove global variables Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 24/27] pm_smbus: remove #ifdef DEBUG Isaku Yamahata
2010-01-06 11:42   ` Stefan Weil
2010-01-06 23:51     ` Isaku Yamahata
2010-01-07  0:05       ` Igor Kovalenko [this message]
2010-01-17 16:09       ` [Qemu-devel] [RFC] Don't send local debug output to stdout (was: pm_smbus: remove #ifdef DEBUG) Stefan Weil
2010-02-24  2:28         ` Paul Brook
2010-02-24 18:29           ` [Qemu-devel] [RFC] Don't send local debug output to stdout Stefan Weil
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 25/27] acpi_piix4: remove #ifdef DEBUG Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 26/27] apm: " Isaku Yamahata
2010-01-06  2:39 ` [Qemu-devel] [PATCH V12 27/27] mc146818rtc: remove #ifdef DEBUG_CMOS Isaku Yamahata
2010-01-12  5:07 ` [Qemu-devel] [PATCH V12 00/27] split out piix specific part from pc emulator and some clean ups Isaku Yamahata

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2fa41d61001061605q3e91b929sbc706877389eece3@mail.gmail.com \
    --to=igor.v.kovalenko@gmail.com \
    --cc=aurelien@aurel32.net \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yamahata@valinux.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).