From: Eric Blake <eblake@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH] cputlb: modernise the debug support
Date: Fri, 05 Jun 2015 13:08:26 -0600 [thread overview]
Message-ID: <5571F3AA.6080506@redhat.com> (raw)
In-Reply-To: <1433519734-11243-1-git-send-email-alex.bennee@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 2311 bytes --]
On 06/05/2015 09:55 AM, 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 <alex.bennee@linaro.org>
> ---
> cputlb.c | 47 ++++++++++++++++++++++++++++-------------------
> 1 file changed, 28 insertions(+), 19 deletions(-)
>
> diff --git a/cputlb.c b/cputlb.c
> index 7606548..ddb7b59 100644
> --- a/cputlb.c
> +++ b/cputlb.c
> @@ -30,8 +30,23 @@
> #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
> +#ifdef DEBUG_TLB_LOG
> +#define tlb_debug(fmt, ...) do { \
> + qemu_log_mask(CPU_LOG_MMU, "%s: " fmt, __func__, ## __VA_ARGS__); \
> + } while (0)
> +#else
> +#define tlb_debug(fmt, ...) do { \
> + fprintf(stderr, "%s: " fmt, __func__, ## __VA_ARGS__); \
> + } while (0)
> +#endif
> +#else
> +#define tlb_debug(fmt, ...) do { } while (0)
This is prone to bitrot.
Better would be:
#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)
because then tlb_debug() will automatically guarantee compiler
compliance to correct fmt vs. argument, while still benefitting from no
increase in code size (all compilers can properly optimize if(0) blocks).
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
prev parent reply other threads:[~2015-06-05 19:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 15:55 [Qemu-devel] [RFC PATCH] cputlb: modernise the debug support Alex Bennée
2015-06-05 19:08 ` Eric Blake [this message]
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=5571F3AA.6080506@redhat.com \
--to=eblake@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 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.