From patchwork Sat Apr 1 13:39:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danil Antonov X-Patchwork-Id: 9657911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 333D760353 for ; Sat, 1 Apr 2017 13:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2413B285F8 for ; Sat, 1 Apr 2017 13:40:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18FB928610; Sat, 1 Apr 2017 13:40:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B02DF2860F for ; Sat, 1 Apr 2017 13:40:02 +0000 (UTC) Received: from localhost ([::1]:51371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJG5-00065H-TW for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Apr 2017 09:40:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJFY-00064F-Q2 for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:39:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuJFX-0001Yi-DV for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:39:28 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:35822) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuJFX-0001YP-6M for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:39:27 -0400 Received: by mail-oi0-x241.google.com with SMTP id d2so5833507oig.2 for ; Sat, 01 Apr 2017 06:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=rPlg1X+oQKtVaeBGxMAID2Q8cMUKg86Z3mgaDEycq8U=; b=qgyMWKi197TP66UNSeKw2+GiLTeGtrV/Htl2G2NPSfSWOFDWrUW3WsMJ2DbxOJNX7U lpV89v4WKdxOE7XgVkU1iwhrWI7lD6npALp87EIZ+pISgzMk5jIF57i4y8o/rDwja+Uq MOnyf470G2FheeO2esVJ3yxiM8khlZ/7X5GeTbfclORmiXxz22rXT/6OBYhyDzkIOEa+ xfPhA674LzK8ZmJzEMWXuFF7dhWaIQueTLdundlVFmeGb7VlVPU9YLLfbQAkWdmPGmvj qyHpDjo5e1tMQi0oUQKHmxqPPNiioul8vIiSZyYtD9EU9hy/cHTCI53EfaZnhLSJK17z VqRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=rPlg1X+oQKtVaeBGxMAID2Q8cMUKg86Z3mgaDEycq8U=; b=PoCAVdAG2vXNRBwpDbYCeqsmRnguCsrXccW2tkBThGdQQFN2LHU0a3fj1Qp039w1rk f6Ia8nAZ+unROtb3lwWfoPS3rsQ8KVluycSxaa1nBGwFdqa2lHEBkmXXLtbzyEKjYnFH yb1D5/rtfawEQau0NT7qkgVwwwfvJt3b0g/gHvAdWKs3N2LTgBEFgJodTwQj3G17H+uB oEJRRwIEh0X+N7/MpDYeP7VZ427EQ5LzvRLEbOSFT137uazK+BOri/EvtaeotaS1FQ4+ s79TuJr3rx1k1y9fxDIiMyrbyg1fpAumDWr5CuWhk92ARF0SiMaGJNmPBX7uHmhhrrby 411g== X-Gm-Message-State: AFeK/H0w6UzK4nY1rkH23XkkwDFCIwUV3sWiABH2/Gcg5wfv+8bqWkmFwMhs4yFaARsO1D7zDEbdwIggIpIuUQ== X-Received: by 10.157.15.157 with SMTP id d29mr5237336otd.48.1491053966475; Sat, 01 Apr 2017 06:39:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.32.234 with HTTP; Sat, 1 Apr 2017 06:39:26 -0700 (PDT) From: Danil Antonov Date: Sat, 1 Apr 2017 16:39:26 +0300 Message-ID: To: qemu-devel@nongnu.org, pbonzini@redhat.com, mtosatti@redhat.com, rth@twiddle.net, ehabkost@redhat.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] [PATCH 07/43] ldst_helper: made printf always compile in debug output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From a827e069c46b272ab952dfde370c1954decdf3dd Mon Sep 17 00:00:00 2001 From: Danil Antonov Date: Wed, 29 Mar 2017 02:15:48 +0300 Subject: [PATCH 07/43] ldst_helper: made printf always compile in debug output Wrapped printf calls inside debug macros (DPRINTF) in `if` statement. This will ensure that printf function will always compile even if debug output is turned off and, in turn, will prevent bitrot of the format strings. Signed-off-by: Danil Antonov --- target/sparc/ldst_helper.c | 67 +++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 28 deletions(-) } #ifdef DEBUG_MMU dump_mmu(stdout, fprintf, env); @@ -1715,7 +1726,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, if (oldreg != env->dmmu.mmuregs[reg]) { DPRINTF_MMU("dmmu change reg[%d]: 0x%016" PRIx64 " -> 0x%016" - PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]); + PRIx64 "\n", reg, oldreg, env->dmmu.mmuregs[reg]); } #ifdef DEBUG_MMU dump_mmu(stdout, fprintf, env); diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 57968d9..7fe9b85 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -25,38 +25,49 @@ #include "exec/cpu_ldst.h" #include "asi.h" -//#define DEBUG_MMU -//#define DEBUG_MXCC //#define DEBUG_UNALIGNED //#define DEBUG_UNASSIGNED -//#define DEBUG_ASI -//#define DEBUG_CACHE_CONTROL -#ifdef DEBUG_MMU -#define DPRINTF_MMU(fmt, ...) \ - do { printf("MMU: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF_MMU(fmt, ...) do {} while (0) -#endif +#ifndef DEBUG_MMU +#define DEBUG_MMU 0 +#endif -#ifdef DEBUG_MXCC -#define DPRINTF_MXCC(fmt, ...) \ - do { printf("MXCC: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF_MXCC(fmt, ...) do {} while (0) -#endif +#ifndef DEBUG_MXCC +#define DEBUG_MXCC 0 +#endif -#ifdef DEBUG_ASI -#define DPRINTF_ASI(fmt, ...) \ - do { printf("ASI: " fmt , ## __VA_ARGS__); } while (0) -#endif +#ifndef DEBUG_ASI +#define DEBUG_ASI 0 +#endif -#ifdef DEBUG_CACHE_CONTROL -#define DPRINTF_CACHE_CONTROL(fmt, ...) \ - do { printf("CACHE_CONTROL: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF_CACHE_CONTROL(fmt, ...) do {} while (0) -#endif +#ifndef DEBUG_CACHE_CONTROL +#define DEBUG_CACHE_CONTROL 0 +#endif + + +#define DPRINTF_MMU(fmt, ...) do { \ + if (DEBUG_MMU) { \ + fprintf(stderr, "MMU: " fmt, ## __VA_ARGS__); \ + } \ +} while (0); + +#define DPRINTF_MXCC(fmt, ...) do { \ + if (DEBUG_MXCC) { \ + fprintf(stderr, "MXCC: " fmt, ## __VA_ARGS__); \ + } \ +} while (0); + +#define DPRINTF_ASI(fmt, ...) do { \ + if (DEBUG_ASI) { \ + fprintf(stderr, "ASI: " fmt, ## __VA_ARGS__); \ + } \ +} while (0); + +#define DPRINTF_CACHE_CONTROL(fmt, ...) do { \ + if (DEBUG_CACHE_CONTROL) { \ + fprintf(stderr, "CACHE_CONTROL: " fmt, ## __VA_ARGS__); \ + } \ +} while (0); #ifdef TARGET_SPARC64 #ifndef TARGET_ABI32 @@ -1631,7 +1642,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val, if (oldreg != env->immu.mmuregs[reg]) { DPRINTF_MMU("immu change reg[%d]: 0x%016" PRIx64 " -> 0x%016" - PRIx64 "\n", reg, oldreg, env->immuregs[reg]); + PRIx64 "\n", reg, oldreg, env->immu.mmuregs[reg]);