From patchwork Thu Jan 7 00:05:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Igor V. Kovalenko" X-Patchwork-Id: 42378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CA057B7BBA for ; Thu, 7 Jan 2010 11:06:24 +1100 (EST) Received: from localhost ([127.0.0.1]:39235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSftN-0002yT-RL for incoming@patchwork.ozlabs.org; Wed, 06 Jan 2010 19:06:21 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSfsq-0002yO-Bi for qemu-devel@nongnu.org; Wed, 06 Jan 2010 19:05:48 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSfsl-0002y8-Ti for qemu-devel@nongnu.org; Wed, 06 Jan 2010 19:05:47 -0500 Received: from [199.232.76.173] (port=46395 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSfsl-0002y5-Nt for qemu-devel@nongnu.org; Wed, 06 Jan 2010 19:05:43 -0500 Received: from mail-bw0-f212.google.com ([209.85.218.212]:32855) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NSfsl-0001af-5t for qemu-devel@nongnu.org; Wed, 06 Jan 2010 19:05:43 -0500 Received: by bwz4 with SMTP id 4so11255846bwz.2 for ; Wed, 06 Jan 2010 16:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=IGcDlIYmMgJy+lB9wC9qJvEVyIf9vHlu4wt9XJwc6s8=; b=fHKES4YCIWkLONz4eCFzJN+bkTBEDrc84Rjd8hbPu2drQ2slsCXDHqPY3b8Wo30d4y BnK330oq2DWNkfX5HGU9eCQFMx92zC419iz+Iy3CoN/nZsIG1AfDrTYbnNoHEmBOdKcT oFmBpH+wkR0HD6+QmiQSYQOLeINLJ1XSp3+Xw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=hQTsXW2tOqAeIrDgPymI3Tc7qaYCPcIeZG89CFDDJYQBNSvv20DcO31Hv/vvfRmfti UqtwSHSAKhgNF91mLjBbPypE7gOX2WOaVnZlN2cqLqBv9LvdyeB3qtfau06coj4yWlIh C5A8LLwsUnOwqD4YYg12ve4DZB1Dckl/C5Vys= MIME-Version: 1.0 Received: by 10.204.130.89 with SMTP id r25mr1405622bks.54.1262822741889; Wed, 06 Jan 2010 16:05:41 -0800 (PST) In-Reply-To: <20100106235113.GE29412@valinux.co.jp> References: <1262745591-28697-1-git-send-email-yamahata@valinux.co.jp> <1262745591-28697-25-git-send-email-yamahata@valinux.co.jp> <4B447724.6070708@mail.berlios.de> <20100106235113.GE29412@valinux.co.jp> Date: Thu, 7 Jan 2010 03:05:41 +0300 Message-ID: Subject: Re: [Qemu-devel] [PATCH V12 24/27] pm_smbus: remove #ifdef DEBUG. From: Igor Kovalenko To: Isaku Yamahata X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: qemu-devel@nongnu.org, aurelien@aurel32.net, kraxel@redhat.com X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Thu, Jan 7, 2010 at 2:51 AM, Isaku Yamahata 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 >> > Acked-by: Gerd Hoffmann >> > --- >> > 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; }