From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR2Zn-0001rd-6X for qemu-devel@nongnu.org; Wed, 03 Feb 2016 13:54:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aR2Zk-0008Ib-WA for qemu-devel@nongnu.org; Wed, 03 Feb 2016 13:54:51 -0500 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]:35074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR2Zk-0008ID-PC for qemu-devel@nongnu.org; Wed, 03 Feb 2016 13:54:48 -0500 Received: by mail-wm0-x232.google.com with SMTP id r129so179282089wmr.0 for ; Wed, 03 Feb 2016 10:54:47 -0800 (PST) References: <1438593291-27109-1-git-send-email-alex.bennee@linaro.org> <1438593291-27109-12-git-send-email-alex.bennee@linaro.org> <20150804123331.GB8960@aurel32.net> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <20150804123331.GB8960@aurel32.net> Date: Wed, 03 Feb 2016 18:54:45 +0000 Message-ID: <87y4b1oc96.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v4 11/11] cputlb: modernise the debug support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno Cc: qemu-trivial@nongnu.org, pbonzini@redhat.com, crosthwaitepeter@gmail.com, qemu-devel@nongnu.org, rth@twiddle.net Aurelien Jarno writes: > On 2015-08-03 10:14, Alex Bennée wrote: >> To avoid cluttering the code with #ifdef legs we wrap up the print >> statements into a tlb_debug() macro. As access to the virtual TLB can >> get quite heavy defining DEBUG_TLB_LOG will ensure all the logs go to >> the qemu_log target of CPU_LOG_MMU instead of stderr. >> >> I've also removed DEBUG_TLB_CHECK which wasn't used. >> >> Signed-off-by: Alex Bennée >> >> --- >> v2 >> - ensure the compiler checks format strings even if debug is optimised out >> --- >> cputlb.c | 54 +++++++++++++++++++++++++++++++++++------------------- >> 1 file changed, 35 insertions(+), 19 deletions(-) >> >> diff --git a/cputlb.c b/cputlb.c >> index a506086..7095e6f 100644 >> --- a/cputlb.c >> +++ b/cputlb.c >> @@ -30,8 +30,30 @@ >> #include "exec/ram_addr.h" >> #include "tcg/tcg.h" >> >> -//#define DEBUG_TLB >> -//#define DEBUG_TLB_CHECK >> +/* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU target */ >> +/* #define DEBUG_TLB */ >> +/* #define DEBUG_TLB_LOG */ >> + >> +#ifdef DEBUG_TLB >> +# define DEBUG_TLB_GATE 1 >> +# ifdef DEBUG_TLB_LOG >> +# define DEBUG_TLB_LOG_GATE 1 >> +# else >> +# define DEBUG_TLB_LOG_GATE 0 >> +# endif >> +#else >> +# define DEBUG_TLB_GATE 0 >> +# define DEBUG_TLB_LOG_GATE 0 >> +#endif >> + >> +#define tlb_debug(fmt, ...) do { \ >> + if (DEBUG_TLB_LOG_GATE) { \ >> + qemu_log_mask(CPU_LOG_MMU, "%s: " fmt, __func__, \ >> + ## __VA_ARGS__); \ >> + } else if (DEBUG_TLB_GATE) { \ >> + fprintf(stderr, "%s: " fmt, __func__, ## __VA_ARGS__); \ >> + } \ >> +} while (0) > > Do we really want to support sending debug logs to either the logfile or > stderr? It's already possible to send the debug logs through stderr when > not specifying -D file. It preserves the old behaviour (and the general behaviour of DEBUG_FOO going to stderr). However I'm happy to make it default to using the log output. It does raise the question of if we should just enable the debugging by default? -- Alex Bennée