From patchwork Sat Apr 1 13:37:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danil Antonov X-Patchwork-Id: 9657909 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 24D8960353 for ; Sat, 1 Apr 2017 13:39:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13441285F8 for ; Sat, 1 Apr 2017 13:39:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05D8C28610; Sat, 1 Apr 2017 13:39:02 +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 9879B285F8 for ; Sat, 1 Apr 2017 13:39:01 +0000 (UTC) Received: from localhost ([::1]:51369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJF6-0005Yn-9Q for patchwork-qemu-devel@patchwork.kernel.org; Sat, 01 Apr 2017 09:39:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cuJE7-0005IR-9s for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:38:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cuJE5-0000XH-OV for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:37:59 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:33434) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cuJE5-0000Wf-Gl for qemu-devel@nongnu.org; Sat, 01 Apr 2017 09:37:57 -0400 Received: by mail-oi0-x244.google.com with SMTP id f193so13181880oib.0 for ; Sat, 01 Apr 2017 06:37:57 -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=cz1pHs7vq3O6X/fO0w9PammBV1xnEQJne+3LCuWJHZE=; b=H6zgjH1VCoz1wZHX3LHZEf2A9/6Wjzed5EY9z6BieQwbXAF1UD5V7CTLM5/d+p81N0 c2GgVXesw27oqc/Sue+9PmYiXYKS7ZIQ4A4tA7BFnvB1cbiiEIfggIBhS52zbMBxo8qf xqgAogHWPHFS/krl405wBc2xE1XtXi5pwbJEBrkO2l4sgXVfHdEaKuE2jiiwPtgbvZGs SIzTwkFs6v2J14SfqcsRtst3rzMiwokzWb4rNGWKHO0bVYew9yMXQwFStmtSYES2n8WE vIVu4Bc1tcseImQXa/QOxtYGEyNWaaK05w/LlBchESk5J3mgO6d0FaG/j1nvlzNFqk+P KxVw== 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=cz1pHs7vq3O6X/fO0w9PammBV1xnEQJne+3LCuWJHZE=; b=k1K1BWcMBEwxHKwZo22omDoT9dtFchCmNvpe0Mzq57lmrSQAOdM8ub6L9CFAkkZMz0 5KD1u8SuFSZpvJ6xFyh/4yCBvrrJuVdvlCKf9yUpH+dxCbFXOJxqUGCHiBJ2j4w5uHDo jUC3tFZKhrJSkcsVOEHibZFfLS5xFUSaMzvIr7hAw+v85+PoPaaEKQRLpd7XhZtjrlzu tR98Q1WKmDa3UwdDxv8DvJGQJ9zweQP0cc0/7+6bKkgPWsO2fEZTnxkt4QIbtTLW2FVu i1jLjc7bj2E9E2+CR/N9yI8gC/SlRus/6CXKL9OyUxLmOyFtBC7FImLx7Wfu4QAgovki zrGg== X-Gm-Message-State: AFeK/H1/u5NllSz1tKVJqQzMC7AJ1DeXXexX7h+W9jw6G/EWzUZ25ecPULKWckkz80jVV8HuK5ZS+gWEaJyK+w== X-Received: by 10.157.32.129 with SMTP id x1mr4419783ota.185.1491053876717; Sat, 01 Apr 2017 06:37:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.32.234 with HTTP; Sat, 1 Apr 2017 06:37:56 -0700 (PDT) From: Danil Antonov Date: Sat, 1 Apr 2017 16:37:56 +0300 Message-ID: To: mark.cave-ayland@ilande.co.uk, atar4qemu@gmail.com, qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::244 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]);