From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0wyq-0008HS-Tt for qemu-devel@nongnu.org; Fri, 05 Jun 2015 15:08:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0wyn-0005xO-Ng for qemu-devel@nongnu.org; Fri, 05 Jun 2015 15:08:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0wyn-0005xE-HP for qemu-devel@nongnu.org; Fri, 05 Jun 2015 15:08:33 -0400 Message-ID: <5571F3AA.6080506@redhat.com> Date: Fri, 05 Jun 2015 13:08:26 -0600 From: Eric Blake MIME-Version: 1.0 References: <1433519734-11243-1-git-send-email-alex.bennee@linaro.org> In-Reply-To: <1433519734-11243-1-git-send-email-alex.bennee@linaro.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="88GMid00Q8CK0DFRJcUwpTeDeB1SS2iQn" Subject: Re: [Qemu-devel] [RFC PATCH] cputlb: modernise the debug support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QWxleCBCZW5uw6ll?= , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --88GMid00Q8CK0DFRJcUwpTeDeB1SS2iQn Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/05/2015 09:55 AM, Alex Benn=C3=A9e 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. >=20 > I've also removed DEBUG_TLB_CHECK which wasn't used. >=20 > Signed-off-by: Alex Benn=C3=A9e > --- > cputlb.c | 47 ++++++++++++++++++++++++++++------------------- > 1 file changed, 28 insertions(+), 19 deletions(-) >=20 > 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" > =20 > -//#define DEBUG_TLB > -//#define DEBUG_TLB_CHECK > +/* DEBUG defines, enable DEBUG_TLB_LOG to log to the CPU_LOG_MMU targe= t */ > +/* #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).= --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --88GMid00Q8CK0DFRJcUwpTeDeB1SS2iQn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVcfOqAAoJEKeha0olJ0NqfOYIAKldZ+hMcAGq6f8HYErXSUYv fWizgpwcT211K2dGwwMB6ok115J/5fKcdmuijpGLQw3JZQ+FpAqusE5Tr2/iFYwg eH7VUrhGb6ly1/fKmhPcO4VUCfQ9lBidgTImV2QvWBdGr4Z/c2+BkS7KTQQNsczz OAuZuR+u2okbacGDSlMBHp7Oc2Pjb98P+bDbIc9jf3bz3dkLYd8mvn/RWhVOOGWT 9uErzQfhKvrI0uBrJxww5Wva4eMSskW7PCSJcqW7EMgNWZfnzYWHWgZ0FBVWR7ck RJkDpFkyAB4Zv7b56Lvfk6NF9C+EsChtxgA+AgbFjN+ZVL3iDO8aqZVMddU9Qgg= =wkv1 -----END PGP SIGNATURE----- --88GMid00Q8CK0DFRJcUwpTeDeB1SS2iQn--