From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621022; cv=none; d=zoho.com; s=zohoarc; b=K6RDBoZ9kWegszQ7CirV5Zw1nqtvYqcfThbf9iWKwj8CIUPMKBIKEQmz8aikwT5eWQdE4K2YQ+7JRRrE3LF0BfWfmaaLbkgQi4LakhCszzVdHPjHcebX+9VVJJxZTwfb5ZoU/5zljWI6bPDxzvwbciJN3VHNyYInt/PKQbw+czU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621022; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=25M5UOq+9nzYHJp0pdohaZKpsENUFKD2USbRFTLp70Q=; b=M1zGc7FIlYpCSgvrHGUIBsDsI1oIfkDl1aPfu1QRuQ1Ye2lwkYYni/lwdUypvUHGMiAHXvYwmCRv9HafL9VrhVnMsLwQ3DFRE+ZAtR3WCUj2C/7UVQ4nc25ibf1+8gxolGUQsT9HNyyYio1qbtkxKdmL/uEb/uKb1Xu1t9HlW9o= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621022540558.7615809341871; Thu, 18 Apr 2019 13:57:02 -0700 (PDT) Received: from localhost ([127.0.0.1]:47170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE5Y-0000TM-Gf for importer@patchew.org; Thu, 18 Apr 2019 16:56:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0S-00055e-Ba for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0R-0005A7-4B for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58638) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0Q-00059G-Se for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:39 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5B81C05681F for ; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85E7560852; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F28B91132BB6; Thu, 18 Apr 2019 22:51:35 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:00 +0200 Message-Id: <20190418205135.6686-2-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 18 Apr 2019 20:51:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 01/36] qemu-io: Use error_[gs]et_progname() 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: , Cc: Christophe Fergeau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Christophe Fergeau qemu-io reimplements itself what error_get_progname()/error_set_progname() already does. This commit switches it to use this API from qemu-error.h Signed-off-by: Christophe Fergeau Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20190131164614.19209-2-cfergeau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- qemu-io.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index 6df7731af4..2c52ac0ade 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -34,8 +34,6 @@ =20 #define CMD_NOFILE_OK 0x01 =20 -static char *progname; - static BlockBackend *qemuio_blk; static bool quit_qemu_io; =20 @@ -312,7 +310,7 @@ static char *get_prompt(void) static char prompt[FILENAME_MAX + 2 /*"> "*/ + 1 /*"\0"*/ ]; =20 if (!prompt[0]) { - snprintf(prompt, sizeof(prompt), "%s> ", progname); + snprintf(prompt, sizeof(prompt), "%s> ", error_get_progname()); } =20 return prompt; @@ -525,7 +523,7 @@ int main(int argc, char **argv) #endif =20 module_call_init(MODULE_INIT_TRACE); - progname =3D g_path_get_basename(argv[0]); + error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); =20 qcrypto_init(&error_fatal); @@ -580,10 +578,10 @@ int main(int argc, char **argv) break; case 'V': printf("%s version " QEMU_FULL_VERSION "\n" - QEMU_COPYRIGHT "\n", progname); + QEMU_COPYRIGHT "\n", error_get_progname()); exit(0); case 'h': - usage(progname); + usage(error_get_progname()); exit(0); case 'U': force_share =3D true; @@ -600,13 +598,13 @@ int main(int argc, char **argv) imageOpts =3D true; break; default: - usage(progname); + usage(error_get_progname()); exit(1); } } =20 if ((argc - optind) > 1) { - usage(progname); + usage(error_get_progname()); exit(1); } =20 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555620859; cv=none; d=zoho.com; s=zohoarc; b=FQDbvhldCol/en6RjKzqbSp4gKIM6xHAGy1fTl3pqh2W2R0DMg/ONxglG2sDCKwBDytmvwE5cJeJCNO0fu4Z4a2FnWrccGaTR3Iy8+MuEfRZRwq4CAUaYnHkerruu3sSzoBe9KoggnMxjmYucIKLsbswa7/zvDGgnr0ub43r7g0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555620859; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OMqAQpFxkurBbP7MiwpjeJMrilG56sh8jmqOFVXkOgc=; b=W3cMFeNHzXVG4ZKLbCLIhFdm2i88eI4V/hUC2BVRO2XrK4aF2X4BVjEEQ3g7725dEQeihLUyuyv7bTpzP8sd4w7VRr0jGey75VmSyRtzffknVUo2SqIkFWoWJ+DZ/miz8lxCtBujSVrxr801dtC1nUhKEQXcQTMdg5nms0yUDCo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555620859006624.1222016968974; Thu, 18 Apr 2019 13:54:19 -0700 (PDT) Received: from localhost ([127.0.0.1]:47120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE2u-0006at-S1 for importer@patchew.org; Thu, 18 Apr 2019 16:54:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0S-000561-UQ for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0R-0005AK-5Y for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52846) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0Q-00059I-S9 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:39 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE0BEC04B94F for ; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 85E85600C5; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 02B861132BD3; Thu, 18 Apr 2019 22:51:35 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:01 +0200 Message-Id: <20190418205135.6686-3-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 18 Apr 2019 20:51:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 02/36] log: Make glib logging go through QEMU 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: , Cc: Christophe Fergeau Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Christophe Fergeau This commit adds a error_init() helper which calls g_log_set_default_handler() so that glib logs (g_log, g_warning, ...) are handled similarly to other QEMU logs. This means they will get a timestamp if timestamps are enabled, and they will go through the HMP monitor if one is configured. This commit also adds a call to error_init() to the binaries installed by QEMU. Since error_init() also calls error_set_progname(), this means that *-linux-user, *-bsd-user and qemu-pr-helper messages output with error_report, info_report, ... will slightly change: they will be prefixed by the binary name. glib debug messages are enabled through G_MESSAGES_DEBUG similarly to the glib default log handler. At the moment, this change will mostly impact SPICE logging if your spice version is >=3D 0.14.1. With older spice versions, this is not going to work as expected, but will not have any ill effect, so this call is not conditional on the SPICE version. Signed-off-by: Christophe Fergeau Reviewed-by: Stefan Hajnoczi Message-Id: <20190131164614.19209-3-cfergeau@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- bsd-user/main.c | 2 ++ include/qemu/error-report.h | 3 +- linux-user/main.c | 2 ++ qemu-img.c | 2 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- scsi/qemu-pr-helper.c | 1 + util/qemu-error.c | 55 ++++++++++++++++++++++++++++++++++++- vl.c | 2 +- 9 files changed, 65 insertions(+), 6 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 0d3156974c..8fd8ae4127 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -24,6 +24,7 @@ #include "qapi/error.h" #include "qemu.h" #include "qemu/config-file.h" +#include "qemu/error-report.h" #include "qemu/path.h" #include "qemu/help_option.h" #include "cpu.h" @@ -743,6 +744,7 @@ int main(int argc, char **argv) if (argc <=3D 1) usage(); =20 + error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); module_call_init(MODULE_INIT_QOM); diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index 0a8d9cc9ea..ce43c02314 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -34,7 +34,6 @@ void error_vprintf(const char *fmt, va_list ap) GCC_FMT_A= TTR(1, 0); void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_vprintf_unless_qmp(const char *fmt, va_list ap) GCC_FMT_ATTR(1,= 0); void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_set_progname(const char *argv0); =20 void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void warn_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); @@ -49,6 +48,8 @@ bool error_report_once_cond(bool *printed, const char *fm= t, ...) bool warn_report_once_cond(bool *printed, const char *fmt, ...) GCC_FMT_ATTR(2, 3); =20 +void error_init(const char *argv0); + /* * Similar to error_report(), except it prints the message just once. * Return true when it prints, false otherwise. diff --git a/linux-user/main.c b/linux-user/main.c index a0aba9cb1e..f9efe9ff6e 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -27,6 +27,7 @@ #include "qemu/path.h" #include "qemu/config-file.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" #include "qemu/help_option.h" #include "cpu.h" #include "exec/exec-all.h" @@ -600,6 +601,7 @@ int main(int argc, char **argv, char **envp) int ret; int execfd; =20 + error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); qemu_init_cpu_list(); module_call_init(MODULE_INIT_QOM); diff --git a/qemu-img.c b/qemu-img.c index aa6f81f1ea..8c7b2437f0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -4923,8 +4923,8 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); #endif =20 + error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); - error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); =20 if (qemu_init_main_loop(&local_error)) { diff --git a/qemu-io.c b/qemu-io.c index 2c52ac0ade..8d5d5911cb 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -522,8 +522,8 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); #endif =20 + error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); - error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); =20 qcrypto_init(&error_fatal); diff --git a/qemu-nbd.c b/qemu-nbd.c index 941ba729c2..dca9e72cee 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -690,8 +690,8 @@ int main(int argc, char **argv) signal(SIGPIPE, SIG_IGN); #endif =20 + error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); - error_set_progname(argv[0]); qcrypto_init(&error_fatal); =20 module_call_init(MODULE_INIT_QOM); diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index e7af637232..2541fbbd1b 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -895,6 +895,7 @@ int main(int argc, char **argv) =20 signal(SIGPIPE, SIG_IGN); =20 + error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); module_call_init(MODULE_INIT_QOM); qemu_add_opts(&qemu_trace_opts); diff --git a/util/qemu-error.c b/util/qemu-error.c index fcbe8a1f74..d08139d9ac 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -142,7 +142,7 @@ static const char *progname; /* * Set the program name for error_print_loc(). */ -void error_set_progname(const char *argv0) +static void error_set_progname(const char *argv0) { const char *p =3D strrchr(argv0, '/'); progname =3D p ? p + 1 : argv0; @@ -345,3 +345,56 @@ bool warn_report_once_cond(bool *printed, const char *= fmt, ...) va_end(ap); return true; } + +static char *qemu_glog_domains; + +static void qemu_log_func(const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data) +{ + switch (log_level & G_LOG_LEVEL_MASK) { + case G_LOG_LEVEL_DEBUG: + case G_LOG_LEVEL_INFO: + /* + * Use same G_MESSAGES_DEBUG logic as glib to enable/disable debug + * messages + */ + if (qemu_glog_domains =3D=3D NULL) { + break; + } + if (strcmp(qemu_glog_domains, "all") !=3D 0 && + (log_domain =3D=3D NULL || !strstr(qemu_glog_domains, log_domain= ))) { + break; + } + /* Fall through */ + case G_LOG_LEVEL_MESSAGE: + info_report("%s%s%s", + log_domain ?: "", log_domain ? ": " : "", message); + + break; + case G_LOG_LEVEL_WARNING: + warn_report("%s%s%s", + log_domain ?: "", log_domain ? ": " : "", message); + break; + case G_LOG_LEVEL_CRITICAL: + case G_LOG_LEVEL_ERROR: + error_report("%s%s%s", + log_domain ?: "", log_domain ? ": " : "", message); + break; + } +} + +void error_init(const char *argv0) +{ + /* Set the program name for error_print_loc(). */ + error_set_progname(argv0); + + /* + * This sets up glib logging so libraries using it also print their lo= gs + * through error_report(), warn_report(), info_report(). + */ + g_log_set_default_handler(qemu_log_func, NULL); + g_warn_if_fail(qemu_glog_domains =3D=3D NULL); + qemu_glog_domains =3D g_strdup(g_getenv("G_MESSAGES_DEBUG")); +} diff --git a/vl.c b/vl.c index c696ad2a13..9877972d97 100644 --- a/vl.c +++ b/vl.c @@ -3022,6 +3022,7 @@ int main(int argc, char **argv, char **envp) char *dir, **dirs; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); =20 + error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); =20 qemu_init_cpu_list(); @@ -3030,7 +3031,6 @@ int main(int argc, char **argv, char **envp) qemu_mutex_lock_iothread(); =20 atexit(qemu_run_exit_notifiers); - error_set_progname(argv[0]); qemu_init_exec_dir(argv[0]); =20 module_call_init(MODULE_INIT_QOM); --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621044; cv=none; d=zoho.com; s=zohoarc; b=Gcvnod7/HZeDCUMIiQOrNZdmfIr74AvuGzBI14c9YuEfLkbXNPTzycAI0Un930+6n0GmMi3LFPveaeKXDLlGwDNfOl16gTVU8A75o/AnwHwqLYmKT5Ywyp3Ukif8a/DO6xD5OEyXCIuCWa4W+5QfFJcR7OlbTUf2roruXpJDsig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621044; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2Ysf+bCeD1PaKYYChcFpbrUZi/hiZWRzShrHemWxsj4=; b=ltajRKAq7PA5xoxacFxtcB9N6d36cOabkWALvEY+pH8g0OZHYVu07iqxLt5y0si8wAe4vjm3WyVNbRV9raEIGIVU5z1NNJQKCqqTSt7Ka7feN7mB92jYUSxlG9cNe+cp30Qp/hSop04j8D6YEQkrJ2OutsqbHRbMY8NX1JNnOqE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621044956433.80333524530636; Thu, 18 Apr 2019 13:57:24 -0700 (PDT) Received: from localhost ([127.0.0.1]:47174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE5n-0000fc-QU for importer@patchew.org; Thu, 18 Apr 2019 16:57:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0S-00055a-8B for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0R-0005A0-3P for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55330) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0Q-00059H-SI for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B67FC81DFE for ; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 887CF60BE5; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0B60A1132B6C; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:02 +0200 Message-Id: <20190418205135.6686-4-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 18 Apr 2019 20:51:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 03/36] error: Fix error_report_err(), warn_report_err() hint printing 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Before the from qerror_report() to error_setg(), hints looked like this: qerror_report(QERR_MACRO, ... arguments ...); error_printf_unless_qmp(... hint ...); error_printf_unless_qmp() made perfect sense: it printed exactly when qerror_report() did. After the conversion to error_setg(): error_setg(errp, QERR_MACRO, ... arguments ...); error_printf_unless_qmp(... hint ...); The "unless QMP part" still made some sense; in QMP context, the caller generally uses the error as QMP response instead of printing it. However, everything else is wrong. If the caller handles the error, the hint gets printed anyway (unless QMP). If the caller reports the error, the hint gets printed *before* the report (unless QMP) or not at all (if QMP). Commit 50b7b000c91 fixed this by making hints a member of Error. It kept printing hints with error_printf_unless_qmp(): void error_report_err(Error *err) { error_report("%s", error_get_pretty(err)); + if (err->hint) { + error_printf_unless_qmp("%s\n", err->hint->str); + } error_free(err); } This is wrong. We should (and now can) print the hint exactly when we print the error. The mistake has since been copied to warn_report_err() in commit e43ead1d0b9. Fix both to use error_printf(). Reported-by: Vladimir Sementsov-Ogievskiy Cc: Eric Blake Signed-off-by: Markus Armbruster Message-Id: <20190416153850.5186-1-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy [Commit message tweaked] --- util/error.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/error.c b/util/error.c index 934a78e1b1..712b4d4b5d 100644 --- a/util/error.c +++ b/util/error.c @@ -223,7 +223,7 @@ void error_report_err(Error *err) { error_report("%s", error_get_pretty(err)); if (err->hint) { - error_printf_unless_qmp("%s", err->hint->str); + error_printf("%s", err->hint->str); } error_free(err); } @@ -232,7 +232,7 @@ void warn_report_err(Error *err) { warn_report("%s", error_get_pretty(err)); if (err->hint) { - error_printf_unless_qmp("%s", err->hint->str); + error_printf("%s", err->hint->str); } error_free(err); } --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555620846; cv=none; d=zoho.com; s=zohoarc; b=N3H8XnEyWkUlndVwUJmCqkJ28FGJKofjG8Haua9JceFdC0FpuPiUNllp7kBf61/2bp+CzH6APfP6VdVNmUqEp0rl3vyeUgVv+4XhPPH/q7ME3TAtAzgVY5sw/YtYGmCieDE1sLa01URHlYdyWH69U+HmAqpyjaCkMR8mC22jjHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555620846; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HEERyKY12va0hDFwNL3v3ZOrJX1+l8cVVk7nUDnu9+Q=; b=HZJaAPM29iP3QyWbPGnGfkHZ5gZ4nntczabXtXIEqtlw1Z04BqTKfKSzJtl0zyamMjLNPfSrmmOV2RB/PoU8h/LaHNzZaminFO6jjdO4GWfyTo2LUnOwHxOlY8u1xmMfUm9P4tSDUpr4UNDYvZcyBaaykzKFA6SFX8Y2h0E4gA4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555620846945847.9921484983802; Thu, 18 Apr 2019 13:54:06 -0700 (PDT) Received: from localhost ([127.0.0.1]:47115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE2j-0006Ov-Fr for importer@patchew.org; Thu, 18 Apr 2019 16:54:01 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0R-00055P-WC for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0R-00059s-0u for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0Q-00059J-R5 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6FA430642A8; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 882D55C22E; Thu, 18 Apr 2019 20:51:37 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 189091132B74; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:03 +0200 Message-Id: <20190418205135.6686-5-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 18 Apr 2019 20:51:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 04/36] util/error: do not free error on error_abort 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: , Cc: Vladimir Sementsov-Ogievskiy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy It would be nice to have Error object not freed away when debugging a coredump. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20190415142519.73060-1-vsementsov@virtuozzo.com> [error_printf_unless_qmp() replaced by error_printf()] Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- util/error.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/error.c b/util/error.c index 712b4d4b5d..ea6d1a3d7e 100644 --- a/util/error.c +++ b/util/error.c @@ -34,7 +34,10 @@ static void error_handle_fatal(Error **errp, Error *err) if (errp =3D=3D &error_abort) { fprintf(stderr, "Unexpected error in %s() at %s:%d:\n", err->func, err->src, err->line); - error_report_err(err); + error_report("%s", error_get_pretty(err)); + if (err->hint) { + error_printf("%s", err->hint->str); + } abort(); } if (errp =3D=3D &error_fatal) { --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622127; cv=none; d=zoho.com; s=zohoarc; b=Q77x3IjNu563LDlv/a6pG7wU4GuvKQRg1Ptax1S2mM7h/loVxUE19cLkdXZOAiZK4MUs8IkHhD7sY0ONDC9Zcwl/FtsmdP18EBRhCR2u/yLfERry1WjvL3ofqJsefLnxqhIbgU+/GD3PztK3NmdbypuO6Kc4KPryv/io4Se2co4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622127; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ptgfLzUnpeb0b5b9DaGXkO6XkLOxlmlEXGvvUX61X1U=; b=CxD5APCHc9OXvPOwPhARGBZwpPirbnnmY+KfqLF4xqxOMv3ISpGqI5mAmVCf7KdfO73AdCRh1u6omY3+HA1pH4VZPVlfNNy0KbLZ6gsKiBjPcxoz6f1r8LKcm5vXNKaEY3K824rnGC3ECIz3BJrVJz6hCvI2MSxGu1oEJ0pRPcI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622127810929.519521982217; Thu, 18 Apr 2019 14:15:27 -0700 (PDT) Received: from localhost ([127.0.0.1]:47434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHENK-0006qB-Kj for importer@patchew.org; Thu, 18 Apr 2019 17:15:18 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0e-0005Ds-AL for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0Z-0005Jm-1J for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45224) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0R-0005AQ-TS; Thu, 18 Apr 2019 16:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30EAE89C39; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 002A460852; Thu, 18 Apr 2019 20:51:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 23D2A1132B38; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:04 +0200 Message-Id: <20190418205135.6686-6-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 18 Apr 2019 20:51:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 05/36] qemu-img: Use error_vreport() in error_exit() 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: , Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" error_exit() uses low-level error_printf() to report errors. Modernize it to use error_vreport(). Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20190417190641.26814-2-armbru@redhat.com> --- qemu-img.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 8c7b2437f0..c376e91ca0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -85,13 +85,11 @@ static void QEMU_NORETURN GCC_FMT_ATTR(1, 2) error_exit= (const char *fmt, ...) { va_list ap; =20 - error_printf("qemu-img: "); - va_start(ap, fmt); - error_vprintf(fmt, ap); + error_vreport(fmt, ap); va_end(ap); =20 - error_printf("\nTry 'qemu-img --help' for more information\n"); + error_printf("Try 'qemu-img --help' for more information\n"); exit(EXIT_FAILURE); } =20 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622507; cv=none; d=zoho.com; s=zohoarc; b=UYJ0c0qjKVKQQtyamY09DXK4x3kvUMwhL2fSArx8YHa/u8ESycOB1gYHbBVmgFQ02tnbRxrEX22bEB61vLhNSmwz7XzLaXfDElKqjJG3stx7DFcV9aqHybmd+HjcVp4aO5PsV8hCeYzW7OizgoXYR1j2bkCQh3KfD3oQgP6iCvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622507; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+W2yqp+gZZCnOLN/x39GE9dG7kLh1vUILed5uH+Vmxo=; b=NqkUwiY3q04kIQj5GPCsY0t1BRkOfUcaINNlZjtcj/35tgJAtO6Ve0pFxK3rQg0RbBDQTWYVg6e7CgQlDbjLUbMj0kTxVxpy31/43y9P0NqGlI2AEEEnDRP4wedMul+/87w+hBYgrtWErdNa2aON5d1r6opQWPw6HWjcfbAPPy8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622507200913.3428295698502; Thu, 18 Apr 2019 14:21:47 -0700 (PDT) Received: from localhost ([127.0.0.1]:47559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHETU-0003NU-5f for importer@patchew.org; Thu, 18 Apr 2019 17:21:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0g-0005GD-RM for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0d-0005Mi-35 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33782) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0S-0005Ae-6U; Thu, 18 Apr 2019 16:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58D7C307B965; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F2D3A5D9CC; Thu, 18 Apr 2019 20:51:38 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2C47A1132B3B; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:05 +0200 Message-Id: <20190418205135.6686-7-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 18 Apr 2019 20:51:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 06/36] block/ssh: Do not report read/write/flush errors to the user 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: , Cc: Kevin Wolf , "Richard W.M. Jones" , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Callbacks ssh_co_readv(), ssh_co_writev(), ssh_co_flush() report errors to the user with error_printf(). They shouldn't, it's their caller's job. Replace by a suitable trace point. While there, drop the unreachable !s->sftp case. Perhaps we should convert this part of the block driver interface to Error, so block drivers can pass more detail to their callers. Not today. Cc: "Richard W.M. Jones" Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Message-Id: <20190417190641.26814-3-armbru@redhat.com> --- block/ssh.c | 38 +++++++++++++------------------------- block/trace-events | 3 +++ 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/block/ssh.c b/block/ssh.c index 190ef95300..859249113d 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -159,31 +159,19 @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const = char *fs, ...) g_free(msg); } =20 -static void GCC_FMT_ATTR(2, 3) -sftp_error_report(BDRVSSHState *s, const char *fs, ...) +static void sftp_error_trace(BDRVSSHState *s, const char *op) { - va_list args; + char *ssh_err; + int ssh_err_code; + unsigned long sftp_err_code; =20 - va_start(args, fs); - error_vprintf(fs, args); + /* This is not an errno. See . */ + ssh_err_code =3D libssh2_session_last_error(s->session, + &ssh_err, NULL, 0); + /* See . */ + sftp_err_code =3D libssh2_sftp_last_error((s)->sftp); =20 - if ((s)->sftp) { - char *ssh_err; - int ssh_err_code; - unsigned long sftp_err_code; - - /* This is not an errno. See . */ - ssh_err_code =3D libssh2_session_last_error(s->session, - &ssh_err, NULL, 0); - /* See . */ - sftp_err_code =3D libssh2_sftp_last_error((s)->sftp); - - error_printf(": %s (libssh2 error code: %d, sftp error code: %lu)", - ssh_err, ssh_err_code, sftp_err_code); - } - - va_end(args); - error_printf("\n"); + trace_sftp_error(op, ssh_err, ssh_err_code, sftp_err_code); } =20 static int parse_uri(const char *filename, QDict *options, Error **errp) @@ -1035,7 +1023,7 @@ static coroutine_fn int ssh_read(BDRVSSHState *s, Blo= ckDriverState *bs, goto again; } if (r < 0) { - sftp_error_report(s, "read failed"); + sftp_error_trace(s, "read"); s->offset =3D -1; return -EIO; } @@ -1105,7 +1093,7 @@ static int ssh_write(BDRVSSHState *s, BlockDriverStat= e *bs, goto again; } if (r < 0) { - sftp_error_report(s, "write failed"); + sftp_error_trace(s, "write"); s->offset =3D -1; return -EIO; } @@ -1188,7 +1176,7 @@ static coroutine_fn int ssh_flush(BDRVSSHState *s, Bl= ockDriverState *bs) return 0; } if (r < 0) { - sftp_error_report(s, "fsync failed"); + sftp_error_trace(s, "fsync"); return -EIO; } =20 diff --git a/block/trace-events b/block/trace-events index 7335a42540..79ccd8d824 100644 --- a/block/trace-events +++ b/block/trace-events @@ -208,3 +208,6 @@ sheepdog_co_rw_vector_new(uint64_t oid) "new oid 0x%" P= RIx64 sheepdog_snapshot_create_info(const char *sn_name, const char *id, const c= har *name, int64_t size, int is_snapshot) "sn_info: name %s id_str %s s: na= me %s vm_state_size %" PRId64 " " "is_snapshot %d" sheepdog_snapshot_create(const char *sn_name, const char *id) "%s %s" sheepdog_snapshot_create_inode(const char *name, uint32_t snap, uint32_t v= di) "s->inode: name %s snap_id 0x%" PRIx32 " vdi 0x%" PRIx32 + +# ssh.c +sftp_error(const char *op, const char *ssh_err, int ssh_err_code, unsigned= long sftp_err_code) "%s failed: %s (libssh2 error code: %d, sftp error cod= e: %lu)" --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621217; cv=none; d=zoho.com; s=zohoarc; b=A4cD8I/1qHwvkVmQOc7f5nQy082t0qt1kM4vq7x8Nh4+4m2reDjEIaLUvDlCGZyLCdo+XgbDdsUF3jZsFPS6uOk/KE0/W8LApPgBpbG+aJ1oZuKEr5grzyWSPVwMbdjBAFoaPtYLVCq7rKwmW+C8k0VchA6CJwsvebnULE908wo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621217; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LtoGOhTK2e2r/y7PMnj7CRb2RLkorOXF2cZ4Duz5BT4=; b=UmuVLgWTBYlNPdQqDhY/3BvxEQGyJfK9Me7l27Yx9fRlObrR9Fu78x2WpZq+XMvOIEygfdxKjq6zPCEnEm4v7MJw7dEBW/91wp7iuyymH99EIG2GjUBWbO6KIySEKP8S8b3La+GAPp/qhRDEBHM4TuPrhyiqi/uNMWvrOE8NkgQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621217118178.93040706105796; Thu, 18 Apr 2019 14:00:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:47204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE8h-0003Ch-Qa for importer@patchew.org; Thu, 18 Apr 2019 17:00:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0V-00056R-B4 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0S-0005CR-Hg for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33952) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0S-0005Ah-7q for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6681090901; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01276104C41C; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 380D71132A03; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:06 +0200 Message-Id: <20190418205135.6686-8-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 07/36] loader-fit: Wean off error_printf() 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: , Cc: Aleksandar Rikalo , Paul Burton Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" load_fit() reports errors with error_printf() instead of error_report(). Worse, it even reports errors it actually recovers from, in fit_cfg_compatible() and fit_load_fdt(). Messed up in initial commit 51b58561c1d. Convert the helper functions for load_fit() to Error. Make sure each failure path sets an error. Fix fit_cfg_compatible() and fit_load_fdt() not to report errors they actually recover from. Convert load_fit() to error_report(). Cc: Paul Burton Cc: Aleksandar Rikalo Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190417190641.26814-4-armbru@redhat.com> --- hw/core/loader-fit.c | 62 +++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c index 447f60857d..f27b6af942 100644 --- a/hw/core/loader-fit.c +++ b/hw/core/loader-fit.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" #include "qemu/units.h" #include "exec/memory.h" #include "hw/loader.h" @@ -33,7 +34,7 @@ #define FIT_LOADER_MAX_PATH (128) =20 static const void *fit_load_image_alloc(const void *itb, const char *name, - int *poff, size_t *psz) + int *poff, size_t *psz, Error **er= rp) { const void *data; const char *comp; @@ -46,6 +47,7 @@ static const void *fit_load_image_alloc(const void *itb, = const char *name, =20 off =3D fdt_path_offset(itb, path); if (off < 0) { + error_setg(errp, "can't find node %s", path); return NULL; } if (poff) { @@ -54,6 +56,7 @@ static const void *fit_load_image_alloc(const void *itb, = const char *name, =20 data =3D fdt_getprop(itb, off, "data", &sz); if (!data) { + error_setg(errp, "can't get %s/data", path); return NULL; } =20 @@ -73,7 +76,7 @@ static const void *fit_load_image_alloc(const void *itb, = const char *name, =20 uncomp_len =3D gunzip(uncomp_data, uncomp_len, (void *) data, sz); if (uncomp_len < 0) { - error_printf("unable to decompress %s image\n", name); + error_setg(errp, "unable to decompress %s image", name); g_free(uncomp_data); return NULL; } @@ -85,18 +88,19 @@ static const void *fit_load_image_alloc(const void *itb= , const char *name, return data; } =20 - error_printf("unknown compression '%s'\n", comp); + error_setg(errp, "unknown compression '%s'", comp); return NULL; } =20 static int fit_image_addr(const void *itb, int img, const char *name, - hwaddr *addr) + hwaddr *addr, Error **errp) { const void *prop; int len; =20 prop =3D fdt_getprop(itb, img, name, &len); if (!prop) { + error_setg(errp, "can't find %s address", name); return -ENOENT; } =20 @@ -108,13 +112,14 @@ static int fit_image_addr(const void *itb, int img, c= onst char *name, *addr =3D fdt64_to_cpu(*(fdt64_t *)prop); return 0; default: - error_printf("invalid %s address length %d\n", name, len); + error_setg(errp, "invalid %s address length %d", name, len); return -EINVAL; } } =20 static int fit_load_kernel(const struct fit_loader *ldr, const void *itb, - int cfg, void *opaque, hwaddr *pend) + int cfg, void *opaque, hwaddr *pend, + Error **errp) { const char *name; const void *data; @@ -126,26 +131,26 @@ static int fit_load_kernel(const struct fit_loader *l= dr, const void *itb, =20 name =3D fdt_getprop(itb, cfg, "kernel", NULL); if (!name) { - error_printf("no kernel specified by FIT configuration\n"); + error_setg(errp, "no kernel specified by FIT configuration"); return -EINVAL; } =20 - load_data =3D data =3D fit_load_image_alloc(itb, name, &img_off, &sz); + load_data =3D data =3D fit_load_image_alloc(itb, name, &img_off, &sz, = errp); if (!data) { - error_printf("unable to load kernel image from FIT\n"); + error_prepend(errp, "unable to load kernel image from FIT: "); return -EINVAL; } =20 - err =3D fit_image_addr(itb, img_off, "load", &load_addr); + err =3D fit_image_addr(itb, img_off, "load", &load_addr, errp); if (err) { - error_printf("unable to read kernel load address from FIT\n"); + error_prepend(errp, "unable to read kernel load address from FIT: = "); ret =3D err; goto out; } =20 - err =3D fit_image_addr(itb, img_off, "entry", &entry_addr); + err =3D fit_image_addr(itb, img_off, "entry", &entry_addr, errp); if (err) { - error_printf("unable to read kernel entry address from FIT\n"); + error_prepend(errp, "unable to read kernel entry address from FIT:= "); ret =3D err; goto out; } @@ -172,7 +177,7 @@ out: =20 static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, int cfg, void *opaque, const void *match_data, - hwaddr kernel_end) + hwaddr kernel_end, Error **errp) { const char *name; const void *data; @@ -187,16 +192,18 @@ static int fit_load_fdt(const struct fit_loader *ldr,= const void *itb, return 0; } =20 - load_data =3D data =3D fit_load_image_alloc(itb, name, &img_off, &sz); + load_data =3D data =3D fit_load_image_alloc(itb, name, &img_off, &sz, = errp); if (!data) { - error_printf("unable to load FDT image from FIT\n"); + error_prepend(errp, "unable to load FDT image from FIT: "); return -EINVAL; } =20 - err =3D fit_image_addr(itb, img_off, "load", &load_addr); + err =3D fit_image_addr(itb, img_off, "load", &load_addr, errp); if (err =3D=3D -ENOENT) { load_addr =3D ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB); + error_free(*errp); } else if (err) { + error_prepend(errp, "unable to read FDT load address from FIT: "); ret =3D err; goto out; } @@ -229,7 +236,7 @@ static bool fit_cfg_compatible(const void *itb, int cfg= , const char *compat) return false; } =20 - fdt =3D fit_load_image_alloc(itb, fdt_name, NULL, NULL); + fdt =3D fit_load_image_alloc(itb, fdt_name, NULL, NULL, NULL); if (!fdt) { return false; } @@ -252,11 +259,12 @@ out: =20 int load_fit(const struct fit_loader *ldr, const char *filename, void *opa= que) { + Error *err =3D NULL; const struct fit_loader_match *match; const void *itb, *match_data =3D NULL; const char *def_cfg_name; char path[FIT_LOADER_MAX_PATH]; - int itb_size, configs, cfg_off, off, err; + int itb_size, configs, cfg_off, off; hwaddr kernel_end; int ret; =20 @@ -267,6 +275,7 @@ int load_fit(const struct fit_loader *ldr, const char *= filename, void *opaque) =20 configs =3D fdt_path_offset(itb, "/configurations"); if (configs < 0) { + error_report("can't find node /configurations"); ret =3D configs; goto out; } @@ -301,20 +310,21 @@ int load_fit(const struct fit_loader *ldr, const char= *filename, void *opaque) } =20 if (cfg_off < 0) { - /* couldn't find a configuration to use */ + error_report("can't find configuration"); ret =3D cfg_off; goto out; } =20 - err =3D fit_load_kernel(ldr, itb, cfg_off, opaque, &kernel_end); - if (err) { - ret =3D err; + ret =3D fit_load_kernel(ldr, itb, cfg_off, opaque, &kernel_end, &err); + if (ret) { + error_report_err(err); goto out; } =20 - err =3D fit_load_fdt(ldr, itb, cfg_off, opaque, match_data, kernel_end= ); - if (err) { - ret =3D err; + ret =3D fit_load_fdt(ldr, itb, cfg_off, opaque, match_data, kernel_end, + &err); + if (ret) { + error_report_err(err); goto out; } =20 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621053; cv=none; d=zoho.com; s=zohoarc; b=bqXxRNrP7fRA2/cyb52vBpbzXym5W7cu3vyFVCoBKvc+q3CQ1wpicTElo8/JA/kbwgsHj7LwrXSU7uBSU9S+ZWltS6PQDaQGN5bedOJ9BN/q93X1xIHtnKZRiEEljZlbk6+eydxn1DEnpis2D/Ljp3a1ccXEQST/352Xd+LveLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621053; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7N1+c9Lj4ZYnBSbINvFvy3C0UyYOt8oZPeZGTu0V6wQ=; b=WEWI5DnpF2XN5fFAd4EtM9RedxRFIfMUH9IfD/tCSfikh9KKp03GVEsP1hmhNXTgMT140SUCcven4k2eqd0PKccc5UfsGZsywbBZWMc2vDMXjjDk35L1E0pCthDRXI5/QAZm4e2uFxJBWE1stxIVkJ6CRmLR4n5OdUS83PF/cz0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621053955894.7246121630018; Thu, 18 Apr 2019 13:57:33 -0700 (PDT) Received: from localhost ([127.0.0.1]:47176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE5w-0000nB-NW for importer@patchew.org; Thu, 18 Apr 2019 16:57:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0T-00056L-Fe for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0S-0005Bl-74 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56666) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0R-0005Aa-Vm for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3EE7C306C3F0; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 033A35D9D6; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 408DE11329CD; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:07 +0200 Message-Id: <20190418205135.6686-9-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 08/36] mips/boston: Report errors with error_report(), not error_printf() 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: , Cc: Aleksandar Rikalo , Paul Burton Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Cc: Paul Burton Cc: Aleksandar Rikalo Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190417190641.26814-5-armbru@redhat.com> --- hw/mips/boston.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index e5bab3cadc..a8b29f62f5 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -528,21 +528,21 @@ static void boston_mach_init(MachineState *machine) fw_size =3D load_image_targphys(machine->firmware, 0x1fc00000, 4 * MiB); if (fw_size =3D=3D -1) { - error_printf("unable to load firmware image '%s'\n", + error_report("unable to load firmware image '%s'", machine->firmware); exit(1); } } else if (machine->kernel_filename) { fit_err =3D load_fit(&boston_fit_loader, machine->kernel_filename,= s); if (fit_err) { - error_printf("unable to load FIT image\n"); + error_report("unable to load FIT image"); exit(1); } =20 gen_firmware(memory_region_get_ram_ptr(flash) + 0x7c00000, s->kernel_entry, s->fdt_base, is_64b); } else if (!qtest_enabled()) { - error_printf("Please provide either a -kernel or -bios argument\n"= ); + error_report("Please provide either a -kernel or -bios argument"); exit(1); } } --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621782; cv=none; d=zoho.com; s=zohoarc; b=BVWz8AfEe/Jo8xP29JKTCsadiRKSW6ZGF7EoON4stRCitH+lMfvEBwAPGYhlDlxc2nBWsGrWQVUsmrt/tnCVkz8G+/rfrEDUzO/D8vcPa33/petFTF7jsLDTQUQUfuSEoj0/FCr90O9UhPv2j6WJ8gVN8KJ3lVQVDq7Y+EvFutc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621782; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4cP2j0Op517oAfKmgdqTjdLHKBKFCz3ed62bdOzweg8=; b=M93fdHUj8NrWrCEfXT6maAEEg7lmF6YDjh48E6hnx3D9fZ7Zvaa6DAjF2xVzK3YE4HvcHUZxdpniI0gBNyPWfidwoEr0U4g9nhMZQZFMy9NHQzLj+vd+nqkrkII+aMUoWSST8jjZ52oFIm0uuaM6HwDknCXFaZ8sTAS8Q2nTAJw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621782655304.1832220684586; Thu, 18 Apr 2019 14:09:42 -0700 (PDT) Received: from localhost ([127.0.0.1]:47350 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEHh-00025C-Ix for importer@patchew.org; Thu, 18 Apr 2019 17:09:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54681) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0Z-00057k-GC for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0U-0005Fv-QH for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51084) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0U-0005Dy-EE for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5130A3082EF1; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E5B95D9E2; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 492EC11329CF; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:08 +0200 Message-Id: <20190418205135.6686-10-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 09/36] pci: Report fatal errors with error_report(), not error_printf() 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: , Cc: "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Signed-off-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum Message-Id: <20190417190641.26814-6-armbru@redhat.com> --- hw/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 6d13ef877b..1808b242dd 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -951,7 +951,7 @@ static uint16_t pci_req_id_cache_extract(PCIReqIDCache = *cache) result =3D PCI_BUILD_BDF(bus_n, 0); break; default: - error_printf("Invalid PCI requester ID cache type: %d\n", + error_report("Invalid PCI requester ID cache type: %d", cache->type); exit(1); break; --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621946; cv=none; d=zoho.com; s=zohoarc; b=XW6/TZJgL4MQ1mm8H9EzE6af5KhtCFXmGp/inJDb4yTSZlLoHCRbaI1Zg09ywZQrSxAeQWpKqUbGrdOneQf3OSSZ7PqJ2H8z1EBoRkgIVA3+LzWY/pzxT1AQQ+M1jESoyFJ8uLgVpw+okBo3vZDsvB3w6j3/Y1fBSOiZryiK69o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621946; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=FHS4H+7XJ+Fq1ByfMAVJ4FZcldqAdHqPi6FfGu+Ou/Q=; b=MXL5R3kamWBibPOOT7rMt0lnzuuOx9R5eoloKC1IyOVRihkKqkssLpAtO1LrPzlqCDi8Zc7hvf8H9JuLnIPpKnWNblgUV9sCsjRKFnWFfo6vtdtmce4JyWdyT0ksXxsj8+mOtp0njTE2IBvCTQ9Ac5qRSZ9paWgTBeIVtAd1N90= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621946142206.70604769225906; Thu, 18 Apr 2019 14:12:26 -0700 (PDT) Received: from localhost ([127.0.0.1]:47405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEKU-0004Zu-QL for importer@patchew.org; Thu, 18 Apr 2019 17:12:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CL-3d for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005Ht-PO for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58322) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005Dz-DP for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 519D330992B8 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20B69104C42F; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5118511329F5; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:09 +0200 Message-Id: <20190418205135.6686-11-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 10/36] hpet: Report warnings with warn_report(), not error_printf() 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: , Cc: Paolo Bonzini , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Message-Id: <20190417190641.26814-7-armbru@redhat.com> --- hw/timer/hpet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index d97436bc7b..41024f39fb 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -744,7 +744,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) HPETTimer *timer; =20 if (!s->intcap) { - error_printf("Hpet's intcap not initialized.\n"); + warn_report("Hpet's intcap not initialized"); } if (hpet_cfg.count =3D=3D UINT8_MAX) { /* first instance */ --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621397; cv=none; d=zoho.com; s=zohoarc; b=eODWOKnPWS7YjUxPucLLlpbXL1kLn8LGKbYNI7ePE4jQlPTZG+GTE1pkPIsm77axYuByYpuw050FTJs+EmdvC0RhfuZ/XAkgG8/PBUFKzuGQmX36ahf0B/IvpT1XJ0EP4pgoSnESQcWXk//aepmI08XsoFMVRSz/ZwgBU0V7xvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621397; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=R88AuLP7zySERbahBNoU1Cot1uxXCZ/+qLCh5BRduNM=; b=h/jaP3qRTS1fKwjvlBF6M/UcrFo72fuUF9DtmXInalEWIjNCv/fN6L4PS5EoW7U7yTIm2wl/scms/YiSWpF0lrIqqMxDE7MPIhznBly6OISIU9WlfSWsCZjxQspnBbzwfW+VJCPYfbsCsryoTyek+KBi3ye4f9hxti4WOfD7E6w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155562139703769.3933803781938; Thu, 18 Apr 2019 14:03:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:47262 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEBX-0005bL-3k for importer@patchew.org; Thu, 18 Apr 2019 17:03:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CG-3G for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005Ha-MK for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23455) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005Eg-1t for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CECCF3065416 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2897060856; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5855D1132988; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:10 +0200 Message-Id: <20190418205135.6686-12-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 11/36] vfio: Report warnings with warn_report(), not error_printf() 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: , Cc: Alex Williamson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: Alex Williamson Signed-off-by: Markus Armbruster Message-Id: <20190417190641.26814-8-armbru@redhat.com> Acked-by: Alex Williamson --- hw/vfio/pci.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 504019c458..0142819ea6 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -947,8 +947,10 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) if (vdev->pdev.romfile || !vdev->pdev.rom_bar) { /* Since pci handles romfile, just print a message and return */ if (vfio_blacklist_opt_rom(vdev) && vdev->pdev.romfile) { - error_printf("Warning : Device at %s is known to cause system = instability issues during option rom execution. Proceeding anyway since use= r specified romfile\n", - vdev->vbasedev.name); + warn_report("Device at %s is known to cause system instability" + " issues during option rom execution", + vdev->vbasedev.name); + error_printf("Proceeding anyway since user specified romfile\n= "); } return; } @@ -973,11 +975,16 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) =20 if (vfio_blacklist_opt_rom(vdev)) { if (dev->opts && qemu_opt_get(dev->opts, "rombar")) { - error_printf("Warning : Device at %s is known to cause system = instability issues during option rom execution. Proceeding anyway since use= r specified non zero value for rombar\n", - vdev->vbasedev.name); + warn_report("Device at %s is known to cause system instability" + " issues during option rom execution", + vdev->vbasedev.name); + error_printf("Proceeding anyway since user specified" + " non zero value for rombar\n"); } else { - error_printf("Warning : Rom loading for device at %s has been = disabled due to system instability issues. Specify rombar=3D1 or romfile to= force\n", - vdev->vbasedev.name); + warn_report("Rom loading for device at %s has been disabled" + " due to system instability issues", + vdev->vbasedev.name); + error_printf("Specify rombar=3D1 or romfile to force\n"); return; } } --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621026; cv=none; d=zoho.com; s=zohoarc; b=Gr+o0XYX/WTh0hLMg+/FfZTSE4hpBsTtxlFgMu45c694eK1C9fc/84162oN/33mUhWccWadmCqbyZFu6V4T1r6rcrWetaDGG4La/qxal4IPuRvBORGT91tMNJcEgKJDIu4uE1tDMzoQVr6o7EpTceH/PA5mhMf7icw+6BsfgDU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621026; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=N+b46vVi0G4oVgpOSHBGZwGsNYK69Ia3vne1iHtpBDs=; b=S6eFGg4FGtLyynAkGMrnQeYnhrfafkWYjy5enx0hHOIEomHj8KZ+rFdsK+vM0CiZ0xK0I50EbzIsh3f2MG8icW49STp67kToeePDCjP55WMoOnryc9Ln4DyPnlPqnZp41Qiceh1MBreKjJ0tiHvOFk7iVydUzhExB1jLNddxLbM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621026049173.42237799226893; Thu, 18 Apr 2019 13:57:06 -0700 (PDT) Received: from localhost ([127.0.0.1]:47172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE5c-0000Uf-19 for importer@patchew.org; Thu, 18 Apr 2019 16:57:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0U-00056N-4F for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0S-0005Ci-MV for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0S-0005B0-EB; Thu, 18 Apr 2019 16:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1EF889C41; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7124E60852; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5EF77113298A; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:11 +0200 Message-Id: <20190418205135.6686-13-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 18 Apr 2019 20:51:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 12/36] s390x/kvm: Report warnings with warn_report(), not error_printf() 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: , Cc: Thomas Huth , qemu-s390x@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" kvm_s390_mem_op() can fail in two ways: when !cap_mem_op, it returns -ENOSYS, and when kvm_vcpu_ioctl() fails, it returns -errno set by ioctl(). Its caller s390_cpu_virt_mem_rw() recovers from both failures. kvm_s390_mem_op() prints "KVM_S390_MEM_OP failed" with error_printf() in the latter failure mode. Since this is obviously a warning, use warn_report(). Perhaps the reporting should be left to the caller. It could warn on failure other than -ENOSYS. Cc: Thomas Huth Cc: qemu-s390x@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Message-Id: <20190417190641.26814-9-armbru@redhat.com> --- target/s390x/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 19530fb94e..2c6e35b5aa 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -782,7 +782,7 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t a= r, void *hostbuf, =20 ret =3D kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op); if (ret < 0) { - error_printf("KVM_S390_MEM_OP failed: %s\n", strerror(-ret)); + warn_report("KVM_S390_MEM_OP failed: %s", strerror(-ret)); } return ret; } --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555620865; cv=none; d=zoho.com; s=zohoarc; b=akG9jHDJROHvqy3BWHAC7GicFsL0LyNtZU7aLywUgkFMaf0FKvF84MR3PnXQhsawMCv1r3p5lhzcBo8LhhmyEk/4wAJ9jenYd/STCXuWrAX/dq6u6ZR0qY8PulYOCZ5+BhH54e6C0J+/NmKCO1k3t0jHv2UfhfPHb3ZQElpUbM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555620865; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ablmWzjPYd1aQ4lcUG0dfzyrEu23KF+a5dx+RwVEkYs=; b=K1d9jE9vMFCLmuJzIe2VEcOe0LTko6ErBjbQ894vaaASQciRGaMZmVHieD0rNK5/GgwqyvV2esFBo3G15ROxtUe97v4b7+/ZOJx3eqoS7pZJoDXocvKkrjaIZos+dLBj0+k/6YKgE706nasTM7UNGoJ+UfIyOdLAcS+SKucaAig= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555620865577333.9295014857088; Thu, 18 Apr 2019 13:54:25 -0700 (PDT) Received: from localhost ([127.0.0.1]:47122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE34-0006jZ-HP for importer@patchew.org; Thu, 18 Apr 2019 16:54:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0T-00056M-S7 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0S-0005Bz-Af for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0S-0005Ac-4U for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C26EC04B94F; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AB56600C5; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 67C06113292F; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:12 +0200 Message-Id: <20190418205135.6686-14-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 18 Apr 2019 20:51:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 13/36] vl: Make -machine $TYPE, help and -accel help print to stdout 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Command line help help explicitly requested by the user should be printed to stdout, not stderr. We do elsewhere. Adjust -machine $TYPE,help and -accel help to match: use printf() instead of error_printf(). Cc: Marcel Apfelbaum Signed-off-by: Markus Armbruster Reviewed-by: Marcel Apfelbaum Message-Id: <20190417190641.26814-10-armbru@redhat.com> --- vl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index 9877972d97..190c773176 100644 --- a/vl.c +++ b/vl.c @@ -1556,12 +1556,12 @@ static int machine_help_func(QemuOpts *opts, Machin= eState *machine) continue; } =20 - error_printf("%s.%s=3D%s", MACHINE_GET_CLASS(machine)->name, - prop->name, prop->type); + printf("%s.%s=3D%s", MACHINE_GET_CLASS(machine)->name, + prop->name, prop->type); if (prop->description) { - error_printf(" (%s)\n", prop->description); + printf(" (%s)\n", prop->description); } else { - error_printf("\n"); + printf("\n"); } } =20 @@ -3643,7 +3643,7 @@ int main(int argc, char **argv, char **envp) optarg, true); optarg =3D qemu_opt_get(accel_opts, "accel"); if (!optarg || is_help_option(optarg)) { - error_printf("Possible accelerators: kvm, xen, hax, tc= g\n"); + printf("Possible accelerators: kvm, xen, hax, tcg\n"); exit(0); } opts =3D qemu_opts_create(qemu_find_opts("machine"), NULL, --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621209; cv=none; d=zoho.com; s=zohoarc; b=lww3/L1S6E4npSMIv+bNky8pmlCy5xtyAkbi5++DP7BiNda55bekeCgufLCCU4oQQ7t6PJUm03D6poV/1wLBw44OGmIB01lkiXMPfMgeTVl4ToLIWhfTT8f1s2ikfwDWGNDj5dHYqfUqDyMbX+1ROR29B46Q14jEQ9Vg3NVsYB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621209; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uIHUXTM6SNPzmBXSc96plNEBbyeWIVe0KEvHFtvFJDQ=; b=AnwvbWw+qF77qxZ5MWtrTaz3WO0JyQId4zjEK0wuj9AGUO+nhRXy2f/8/oFjlxSg9blrMaBeELeJtIzPeLoTfIldgNgPozk+6JgROPDFwH2oHRrDvIwRvqbpTD8HHH998gEsxhG7O7b9lB6XzweT2/CPl5AIzzdkTJLG6X0tK2M= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621209063338.2785286374692; Thu, 18 Apr 2019 14:00:09 -0700 (PDT) Received: from localhost ([127.0.0.1]:47200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE8U-00030b-7c for importer@patchew.org; Thu, 18 Apr 2019 16:59:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0U-00056Q-WB for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0S-0005CY-KJ for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0S-0005Am-8N for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:40 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8379289C4C for ; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DE9019C79; Thu, 18 Apr 2019 20:51:39 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6F5FF11327DB; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:13 +0200 Message-Id: <20190418205135.6686-15-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 18 Apr 2019 20:51:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 14/36] monitor error: Make printf()-like functions return a value 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: , Cc: "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" printf() & friends return the number of characters written on success, negative value on error. monitor_printf(), monitor_vfprintf(), monitor_vprintf(), error_printf(), error_printf_unless_qmp(), error_vprintf(), and error_vprintf_unless_qmp() return void. Some of them carry a TODO comment asking for int instead. Improve them to return int like printf() does. This makes our use of monitor_printf() as fprintf_function slightly less dirty: the function cast no longer adds a return value that isn't there. It still changes a parameter's pointer type. That will be addressed in a future commit. monitor_vfprintf() always returns zero. Improve it to return the proper value. Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417190641.26814-11-armbru@redhat.com> --- include/monitor/monitor.h | 8 ++--- include/qemu/error-report.h | 8 ++--- monitor.c | 61 ++++++++++++++++++++----------------- stubs/error-printf.c | 13 +++++--- util/qemu-error.c | 12 +++++--- 5 files changed, 57 insertions(+), 45 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index c1b40a9cac..e4c3717454 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -28,9 +28,9 @@ void monitor_resume(Monitor *mon); int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp); int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp); =20 -void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); -void monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +int monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); int monitor_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void monitor_flush(Monitor *mon); int monitor_set_cpu(int cpu_index); @@ -48,7 +48,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd= ); void monitor_fdset_dup_fd_remove(int dup_fd); int monitor_fdset_dup_fd_find(int dup_fd); =20 -void monitor_vfprintf(FILE *stream, - const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); +int monitor_vfprintf(FILE *stream, + const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); =20 #endif /* MONITOR_H */ diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index ce43c02314..00d069b20f 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -30,10 +30,10 @@ void loc_set_none(void); void loc_set_cmdline(char **argv, int idx, int cnt); void loc_set_file(const char *fname, int lno); =20 -void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); -void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); -void error_vprintf_unless_qmp(const char *fmt, va_list ap) GCC_FMT_ATTR(1,= 0); -void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +int error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); +int error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); +int error_vprintf_unless_qmp(const char *fmt, va_list ap) GCC_FMT_ATTR(1, = 0); +int error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); =20 void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void warn_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); diff --git a/monitor.c b/monitor.c index 4807bbe811..7b4a78d798 100644 --- a/monitor.c +++ b/monitor.c @@ -430,15 +430,14 @@ void monitor_flush(Monitor *mon) } =20 /* flush at every end of line */ -static void monitor_puts(Monitor *mon, const char *str) +static int monitor_puts(Monitor *mon, const char *str) { + int i; char c; =20 qemu_mutex_lock(&mon->mon_lock); - for(;;) { - c =3D *str++; - if (c =3D=3D '\0') - break; + for (i =3D 0; str[i]; i++) { + c =3D str[i]; if (c =3D=3D '\n') { qstring_append_chr(mon->outbuf, '\r'); } @@ -448,39 +447,48 @@ static void monitor_puts(Monitor *mon, const char *st= r) } } qemu_mutex_unlock(&mon->mon_lock); + + return i; } =20 -void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { char *buf; + int n; =20 if (!mon) - return; + return -1; =20 if (monitor_is_qmp(mon)) { - return; + return -1; } =20 buf =3D g_strdup_vprintf(fmt, ap); - monitor_puts(mon, buf); + n =3D monitor_puts(mon, buf); g_free(buf); + return n; } =20 -void monitor_printf(Monitor *mon, const char *fmt, ...) +int monitor_printf(Monitor *mon, const char *fmt, ...) { + int ret; + va_list ap; va_start(ap, fmt); - monitor_vprintf(mon, fmt, ap); + ret =3D monitor_vprintf(mon, fmt, ap); va_end(ap); + return ret; } =20 int monitor_fprintf(FILE *stream, const char *fmt, ...) { + int ret; + va_list ap; va_start(ap, fmt); - monitor_vprintf((Monitor *)stream, fmt, ap); + ret =3D monitor_vprintf((Monitor *)stream, fmt, ap); va_end(ap); - return 0; + return ret; } =20 static void qmp_send_response(Monitor *mon, const QDict *rsp) @@ -4535,35 +4543,32 @@ static void monitor_readline_flush(void *opaque) =20 /* * Print to current monitor if we have one, else to stream. - * TODO should return int, so callers can calculate width, but that - * requires surgery to monitor_vprintf(). Left for another day. */ -void monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) +int monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) { if (cur_mon && !monitor_cur_is_qmp()) { - monitor_vprintf(cur_mon, fmt, ap); - } else { - vfprintf(stream, fmt, ap); + return monitor_vprintf(cur_mon, fmt, ap); } + return vfprintf(stream, fmt, ap); } =20 /* * Print to current monitor if we have one, else to stderr. - * TODO should return int, so callers can calculate width, but that - * requires surgery to monitor_vprintf(). Left for another day. */ -void error_vprintf(const char *fmt, va_list ap) +int error_vprintf(const char *fmt, va_list ap) { - monitor_vfprintf(stderr, fmt, ap); + return monitor_vfprintf(stderr, fmt, ap); } =20 -void error_vprintf_unless_qmp(const char *fmt, va_list ap) +int error_vprintf_unless_qmp(const char *fmt, va_list ap) { - if (cur_mon && !monitor_cur_is_qmp()) { - monitor_vprintf(cur_mon, fmt, ap); - } else if (!cur_mon) { - vfprintf(stderr, fmt, ap); + if (!cur_mon) { + return vfprintf(stderr, fmt, ap); } + if (!monitor_cur_is_qmp()) { + return monitor_vprintf(cur_mon, fmt, ap); + } + return -1; } =20 static void monitor_list_append(Monitor *mon) diff --git a/stubs/error-printf.c b/stubs/error-printf.c index 99c6406668..1f9d3b3714 100644 --- a/stubs/error-printf.c +++ b/stubs/error-printf.c @@ -2,19 +2,22 @@ #include "qemu-common.h" #include "qemu/error-report.h" =20 -void error_vprintf(const char *fmt, va_list ap) +int error_vprintf(const char *fmt, va_list ap) { + int ret; + if (g_test_initialized() && !g_test_subprocess() && getenv("QTEST_SILENT_ERRORS")) { char *msg =3D g_strdup_vprintf(fmt, ap); g_test_message("%s", msg); + ret =3D strlen(msg); g_free(msg); - } else { - vfprintf(stderr, fmt, ap); + return ret; } + return vfprintf(stderr, fmt, ap); } =20 -void error_vprintf_unless_qmp(const char *fmt, va_list ap) +int error_vprintf_unless_qmp(const char *fmt, va_list ap) { - error_vprintf(fmt, ap); + return error_vprintf(fmt, ap); } diff --git a/util/qemu-error.c b/util/qemu-error.c index d08139d9ac..f373f3b3b0 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -24,22 +24,26 @@ typedef enum { REPORT_TYPE_INFO, } report_type; =20 -void error_printf(const char *fmt, ...) +int error_printf(const char *fmt, ...) { va_list ap; + int ret; =20 va_start(ap, fmt); - error_vprintf(fmt, ap); + ret =3D error_vprintf(fmt, ap); va_end(ap); + return ret; } =20 -void error_printf_unless_qmp(const char *fmt, ...) +int error_printf_unless_qmp(const char *fmt, ...) { va_list ap; + int ret; =20 va_start(ap, fmt); - error_vprintf_unless_qmp(fmt, ap); + ret =3D error_vprintf_unless_qmp(fmt, ap); va_end(ap); + return ret; } =20 static Location std_loc =3D { --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621673; cv=none; d=zoho.com; s=zohoarc; b=A6u8fvOuCIucbXi34UBQvAXIHGWzYRUaKnSPjKW6eZO1PjLn4ylP3Mwj1/ZIrK6Xyg5+StcPa7YLtLiEMqgBgLsCzT2gUjLiJg4TKpd/RfXGPez1MDawfGwSRw9VgPNWKsIHw6FT6rYKKVA5hkNdddsLPMT7w8jfDqJcpwPfUk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621673; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GmWoRSnlGBa0jaOS+NV7bxALscsoazNMx5LRnbOf2aw=; b=Rq5Er7OW3vW5kPriQE+5ZtJY77uRebTeiyqe97HiySaoxQpz8AIBLCYEZTjFSpWNT2Maf8Bzsr0Y8iwtvalvD9QivMjXXkbO4SZbPZf6B9v5vQ563cYWJ4gWR2P5JC2PwUr2j9W2SLp2W61flUdSZeWEsKYj0Gu9MWTisZZgurE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621673295834.284113894854; Thu, 18 Apr 2019 14:07:53 -0700 (PDT) Received: from localhost ([127.0.0.1]:47327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEG6-0000m8-6w for importer@patchew.org; Thu, 18 Apr 2019 17:07:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0Z-00057h-Fv for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0U-0005Ez-Bw for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46336) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0T-0005D4-OG for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE0123084247 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67B2E19C79; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 780231132783; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:14 +0200 Message-Id: <20190418205135.6686-16-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 15/36] qemu-print: New qemu_printf(), qemu_vprintf() etc. 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: , Cc: "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We commonly want to print to the current monitor if we have one, else to stdout/stderr. For stderr, have error_printf(). For stdout, all we have is monitor_vfprintf(), which is rather unwieldy. We often print to stderr just because error_printf() is easier. New qemu_printf() and qemu_vprintf() do exactly what's needed. The next commits will put them to use. Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417190641.26814-12-armbru@redhat.com> --- MAINTAINERS | 2 ++ include/qemu/qemu-print.h | 19 ++++++++++++++++++ stubs/monitor.c | 5 +++++ tests/test-util-sockets.c | 1 + util/Makefile.objs | 1 + util/qemu-print.c | 42 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 70 insertions(+) create mode 100644 include/qemu/qemu-print.h create mode 100644 util/qemu-print.c diff --git a/MAINTAINERS b/MAINTAINERS index 56139ac8ab..1aa19dc4ef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1895,6 +1895,8 @@ F: hmp.[ch] F: hmp-commands*.hx F: include/monitor/hmp-target.h F: tests/test-hmp.c +F: include/qemu/qemu-print.h +F: util/qemu-print.c =20 Network device backends M: Jason Wang diff --git a/include/qemu/qemu-print.h b/include/qemu/qemu-print.h new file mode 100644 index 0000000000..8fed32bf42 --- /dev/null +++ b/include/qemu/qemu-print.h @@ -0,0 +1,19 @@ +/* + * Print to stream or current monitor + * + * Copyright (C) 2019 Red Hat Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef QEMU_PRINT_H +#define QEMU_PRINT_H + +int qemu_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); +int qemu_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); + +#endif diff --git a/stubs/monitor.c b/stubs/monitor.c index b57fe6c32f..b2ea975e40 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -6,6 +6,11 @@ =20 __thread Monitor *cur_mon; =20 +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) +{ + abort(); +} + int monitor_get_fd(Monitor *mon, const char *name, Error **errp) { error_setg(errp, "only QEMU supports file descriptor passing"); diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index 6195a3ac36..fd1ced058c 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -70,6 +70,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname, Erro= r **errp) * otherwise we get duplicate syms at link time. */ __thread Monitor *cur_mon; +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); } void monitor_init(Chardev *chr, int flags) {} =20 =20 diff --git a/util/Makefile.objs b/util/Makefile.objs index 835fcd69e2..9206878dec 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -23,6 +23,7 @@ util-obj-y +=3D bitmap.o bitops.o hbitmap.o util-obj-y +=3D fifo8.o util-obj-y +=3D cacheinfo.o util-obj-y +=3D error.o qemu-error.o +util-obj-y +=3D qemu-print.o util-obj-y +=3D id.o util-obj-y +=3D iov.o qemu-config.o qemu-sockets.o uri.o notify.o util-obj-y +=3D qemu-option.o qemu-progress.o diff --git a/util/qemu-print.c b/util/qemu-print.c new file mode 100644 index 0000000000..86f9417af8 --- /dev/null +++ b/util/qemu-print.c @@ -0,0 +1,42 @@ +/* + * Print to stream or current monitor + * + * Copyright (C) 2019 Red Hat Inc. + * + * Authors: + * Markus Armbruster , + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "monitor/monitor.h" +#include "qemu/qemu-print.h" + +/* + * Print like vprintf(). + * Print to current monitor if we have one, else to stdout. + */ +int qemu_vprintf(const char *fmt, va_list ap) +{ + if (cur_mon) { + return monitor_vprintf(cur_mon, fmt, ap); + } + return vprintf(fmt, ap); +} + +/* + * Print like printf(). + * Print to current monitor if we have one, else to stdout. + */ +int qemu_printf(const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret =3D qemu_vprintf(fmt, ap); + va_end(ap); + return ret; +} --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622313; cv=none; d=zoho.com; s=zohoarc; b=n01Y9k5hQx5kWtTLsCO4mhJwH0yxafou6G4TFi5kXVFOwqEErxDyKYrUDcHfOQKwNAd8Luy6LPyVljIm0yNnCIhjQ8J3quLFrNUA7VmCAMGqnpnsqSvnMDP1ZefC3rAoyC/l7WkwtqUOwrxT2oJEK/I/RCo6VfpHtQxBQLBqLDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622313; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=yxAUOzKgKwhLxSLSDdgIPScQvU/JxhT+7QnE3BQ06bk=; b=a4fjBsWS0hb/gVPRcB6F8RUGS/FCqhg+Me4Jf31t2oPfLJn9HEbKdjmcN7bGpK6hMcBi+P+LQ2ZmrTuYlQ1SOcg8O2eB9XlMuX9cmJLLejkTGAb3XCv8ZdoVlzRg7ydvpTibatxuk+bzOIhxU0iB3YLDZy3gTVjpGm3tqadtMEw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622313851522.6789507589281; Thu, 18 Apr 2019 14:18:33 -0700 (PDT) Received: from localhost ([127.0.0.1]:47493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEQQ-0000yj-Q0 for importer@patchew.org; Thu, 18 Apr 2019 17:18:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0g-0005FP-3q for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0d-0005Mo-3D for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33788) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0T-0005Cr-Ed; Thu, 18 Apr 2019 16:51:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0F6A30ADBB1; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6E6441001DDE; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 843FD1132786; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:15 +0200 Message-Id: <20190418205135.6686-17-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 16/36] blockdev: Make -drive format=help print to stdout 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: , Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Command line help explicitly requested by the user should be printed to stdout, not stderr. We do elsewhere. Adjust -drive to match: use qemu_printf() instead of error_printf(). Plain printf() would be wrong because we need to print to the current monitor for "drive_add ... format=3Dhelp". Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190417190641.26814-13-armbru@redhat.com> --- blockdev.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index 4775a07d93..79fbac8450 100644 --- a/blockdev.c +++ b/blockdev.c @@ -40,6 +40,7 @@ #include "monitor/monitor.h" #include "qemu/error-report.h" #include "qemu/option.h" +#include "qemu/qemu-print.h" #include "qemu/config-file.h" #include "qapi/qapi-commands-block.h" #include "qapi/qapi-commands-transaction.h" @@ -301,7 +302,7 @@ DriveInfo *drive_get_next(BlockInterfaceType type) =20 static void bdrv_format_print(void *opaque, const char *name) { - error_printf(" %s", name); + qemu_printf(" %s", name); } =20 typedef struct { @@ -530,11 +531,11 @@ static BlockBackend *blockdev_init(const char *file, = QDict *bs_opts, =20 if ((buf =3D qemu_opt_get(opts, "format")) !=3D NULL) { if (is_help_option(buf)) { - error_printf("Supported formats:"); + qemu_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL, false); - error_printf("\nSupported formats (read-only):"); + qemu_printf("\nSupported formats (read-only):"); bdrv_iterate_format(bdrv_format_print, NULL, true); - error_printf("\n"); + qemu_printf("\n"); goto early_err; } =20 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622333; cv=none; d=zoho.com; s=zohoarc; b=N9Jdm1qCVcHY/jTAFJ4M6HsTCqPeBlgMjFNuXuisYtFhBWCgrynQPMiYZStbIVdsS3BvIT6rTxosPlro0BRPmCG1tsAU90FFiy6p5B7BPgMCDaKPy25qq5Sv5dGFm99FChiZ+B6ObRXngVbiIkZyQ+KXwAhb0zdypswphYycUYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622333; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hhXUQQVDg09bJAvq6qgqptYodxhU3Cx73Qdgq808qWs=; b=h1vliGzIb3MGOgO5iRs86UVGXqTKGzCFjLgQZTl56cH8EFBASKBXGJowzgJugL1wdrPAckTZWU2n7DaVrz0c7aTL2yy7z0zSLCeh7Lm7GuldJv5Juj5YYf9z29bP02FRlZKBengJ8B+06GjG0FhWXonnVidsCwVev55s/CNlRwA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622333241808.9440130010432; Thu, 18 Apr 2019 14:18:53 -0700 (PDT) Received: from localhost ([127.0.0.1]:47495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEQh-0001B2-6D for importer@patchew.org; Thu, 18 Apr 2019 17:18:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0e-0005ER-WF for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0b-0005LC-0S for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33802) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005Fz-Ni for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A77CC3003737 for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79C1D600C5; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8C4AD113279E; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:16 +0200 Message-Id: <20190418205135.6686-18-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 17/36] char: Make -chardev help print to stdout 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: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Command line help explicitly requested by the user should be printed to stdout, not stderr. We do elsewhere. Adjust -chardev to match: use qemu_printf() instead of error_printf(). Plain printf() would be wrong because we need to print to the current monitor for "chardev-add help". Cc: "Marc-Andr=C3=A9 Lureau" Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190417190641.26814-14-armbru@redhat.com> --- chardev/char.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chardev/char.c b/chardev/char.c index 514cd6b0c3..54724a56b1 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -28,6 +28,7 @@ #include "sysemu/sysemu.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "chardev/char.h" #include "qapi/error.h" #include "qapi/qapi-commands-char.h" @@ -651,7 +652,7 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts, GMainCo= ntext *context, =20 chardev_name_foreach(help_string_append, str); =20 - error_printf("Available chardev backend types: %s\n", str->str); + qemu_printf("Available chardev backend types: %s\n", str->str); g_string_free(str, true); return NULL; } --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621590; cv=none; d=zoho.com; s=zohoarc; b=UDLOe9Cf9lJVQ4gspS06iIx8IyCQeNrgcPJ8QwkRaHIwZ0LN/h7+hZSA+GQG5O+RpSmnzCxbN0GoHycohM3tfmRS6qsS1XfS3LXVKXholtYyjTDPtGlGQPz6Yer9xSyRyo9GS34jkboyFkc0y6G/FsNs3A+p9EXnrbo4q7D8JL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621590; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GkksUi50f9Wd9+D2AXCYKJwcuNbfuVuHAODz8CZBs1Y=; b=Dxcuxxg2b26PAXLlXlI8hlK++FMTaPYKZkyOsdGsS4NcKfBWmwDl4/inX5jDBRPei7FFvO9QEFBK2ita27UjrpbR608KwyY2UiUnyEO4j2NOeLr3p+trNZ9DD0ThsipIGCtjfx/P3wjvbs72j50ji8Tii8t41pNm9pk1LBB6I0c= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621590781483.6776893133765; Thu, 18 Apr 2019 14:06:30 -0700 (PDT) Received: from localhost ([127.0.0.1]:47325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEEg-000867-MR for importer@patchew.org; Thu, 18 Apr 2019 17:06:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0V-00056T-LV for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0T-0005EL-TZ for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0T-0005Cv-FD for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC86F3003737 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FA385C206 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 93D7D1132724; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:17 +0200 Message-Id: <20190418205135.6686-19-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 18 Apr 2019 20:51:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 18/36] char-pty: Print "char device redirected" message to stdout 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" char_pty_open() prints a "char device redirected to PTY_NAME (label LABEL)" message to the current monitor or else to stderr. This is not an error, so it shouldn't go to stderr. Print it to stdout instead. Why is it even printed? No other ChardevClass::open() prints anything on success. It's because you need to know PTY_NAME to actually use this char device, e.g. like e.g. "socat STDIO,cfmakeraw FILE:PTY_NAME" to use the monitor's readline interface. You can get PTY_NAME with "info chardev" (a.k.a. query-chardev for QMP), but only if you already have a monitor. Signed-off-by: Markus Armbruster Message-Id: <20190417190641.26814-15-armbru@redhat.com> Reviewed-by: Eric Blake --- chardev/char-pty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index b034332edd..04759b0ef9 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -28,6 +28,7 @@ #include "io/channel-file.h" #include "qemu/sockets.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" =20 #include "chardev/char-io.h" =20 @@ -211,8 +212,8 @@ static void char_pty_open(Chardev *chr, qemu_set_nonblock(master_fd); =20 chr->filename =3D g_strdup_printf("pty:%s", pty_name); - error_printf("char device redirected to %s (label %s)\n", - pty_name, chr->label); + qemu_printf("char device redirected to %s (label %s)\n", + pty_name, chr->label); =20 s =3D PTY_CHARDEV(chr); s->ioc =3D QIO_CHANNEL(qio_channel_file_new_fd(master_fd)); --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621578; cv=none; d=zoho.com; s=zohoarc; b=Nng6G2y6KUwafsgTcWhJZctHwvFgtaSIyYOf7ZsUfLUVpvXsF43BQaOhw9sKjGxOk52fJ/NHLM9wmDYU6NXzz5Mn0bLQri0zha62btgfmCPFNBqrJXFRMJrdFcfGZIhE+kvZq+V+hqlRGmNZI5SydMQgT8L5te7IuOiuqZmLFeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621578; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Zh5jgJwzndHNnWKzzMYyl1pFkY9yMqXLWyebQAWn3/w=; b=NoBvK3EV9ILdAGyzFS+YH4ZD/Zw36K1LzxlkVFMWC8j4O1WhGlKZppwALoCdxYxj+yP4BUAlIHw8yQBG3Zam75C0y6vX2K0vZA73v01k0ddvEZiYDJXnsl3xau8x9Q0omM+vaDkde9zcyWFBlLl+04SZ337EZ/y6dtRYvGk+bh4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621578363392.7884311042453; Thu, 18 Apr 2019 14:06:18 -0700 (PDT) Received: from localhost ([127.0.0.1]:47318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEEZ-0007yZ-7h for importer@patchew.org; Thu, 18 Apr 2019 17:06:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CJ-4A for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0U-0005GI-Vv for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33960) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0U-0005DN-FR for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3FDF330279 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8DED360BE5; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 9C73D113274A; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:18 +0200 Message-Id: <20190418205135.6686-20-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Apr 2019 20:51:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 19/36] monitor: Simplify how -device/device_add print help 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: , Cc: "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit a95db58f210 added monitor_vfprintf() as an error_printf() generalized from stderr to arbitrary streams, then used it wrapped in helper out_printf() to print -device/device_add help to stdout. Use qemu_printf() instead, and delete monitor_vfprintf() and out_printf(). Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417190641.26814-16-armbru@redhat.com> --- include/monitor/monitor.h | 3 --- monitor.c | 16 ++++------------ qdev-monitor.c | 36 ++++++++++++++---------------------- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index e4c3717454..316a168c41 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -48,7 +48,4 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd= ); void monitor_fdset_dup_fd_remove(int dup_fd); int monitor_fdset_dup_fd_find(int dup_fd); =20 -int monitor_vfprintf(FILE *stream, - const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); - #endif /* MONITOR_H */ diff --git a/monitor.c b/monitor.c index 7b4a78d798..10be8bdb86 100644 --- a/monitor.c +++ b/monitor.c @@ -4541,23 +4541,15 @@ static void monitor_readline_flush(void *opaque) monitor_flush(opaque); } =20 -/* - * Print to current monitor if we have one, else to stream. - */ -int monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) -{ - if (cur_mon && !monitor_cur_is_qmp()) { - return monitor_vprintf(cur_mon, fmt, ap); - } - return vfprintf(stream, fmt, ap); -} - /* * Print to current monitor if we have one, else to stderr. */ int error_vprintf(const char *fmt, va_list ap) { - return monitor_vfprintf(stderr, fmt, ap); + if (cur_mon && !monitor_cur_is_qmp()) { + return monitor_vprintf(cur_mon, fmt, ap); + } + return vfprintf(stderr, fmt, ap); } =20 int error_vprintf_unless_qmp(const char *fmt, va_list ap) diff --git a/qdev-monitor.c b/qdev-monitor.c index d4320986a2..373b9ad445 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -31,6 +31,7 @@ #include "qemu/error-report.h" #include "qemu/help_option.h" #include "qemu/option.h" +#include "qemu/qemu-print.h" #include "sysemu/block-backend.h" #include "migration/misc.h" =20 @@ -104,31 +105,22 @@ static bool qdev_class_has_alias(DeviceClass *dc) return (qdev_class_get_alias(dc) !=3D NULL); } =20 -static void out_printf(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - monitor_vfprintf(stdout, fmt, ap); - va_end(ap); -} - static void qdev_print_devinfo(DeviceClass *dc) { - out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); + qemu_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); if (dc->bus_type) { - out_printf(", bus %s", dc->bus_type); + qemu_printf(", bus %s", dc->bus_type); } if (qdev_class_has_alias(dc)) { - out_printf(", alias \"%s\"", qdev_class_get_alias(dc)); + qemu_printf(", alias \"%s\"", qdev_class_get_alias(dc)); } if (dc->desc) { - out_printf(", desc \"%s\"", dc->desc); + qemu_printf(", desc \"%s\"", dc->desc); } if (!dc->user_creatable) { - out_printf(", no-user"); + qemu_printf(", no-user"); } - out_printf("\n"); + qemu_printf("\n"); } =20 static void qdev_print_devinfos(bool show_no_user) @@ -164,7 +156,7 @@ static void qdev_print_devinfos(bool show_no_user) continue; } if (!cat_printed) { - out_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); + qemu_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); cat_printed =3D true; } qdev_print_devinfo(dc); @@ -286,20 +278,20 @@ int qdev_device_help(QemuOpts *opts) } =20 if (prop_list) { - out_printf("%s options:\n", driver); + qemu_printf("%s options:\n", driver); } else { - out_printf("There are no options for %s.\n", driver); + qemu_printf("There are no options for %s.\n", driver); } for (prop =3D prop_list; prop; prop =3D prop->next) { int len; - out_printf(" %s=3D<%s>%n", prop->value->name, prop->value->type, = &len); + qemu_printf(" %s=3D<%s>%n", prop->value->name, prop->value->type,= &len); if (prop->value->has_description) { if (len < 24) { - out_printf("%*s", 24 - len, ""); + qemu_printf("%*s", 24 - len, ""); } - out_printf(" - %s\n", prop->value->description); + qemu_printf(" - %s\n", prop->value->description); } else { - out_printf("\n"); + qemu_printf("\n"); } } =20 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621397; cv=none; d=zoho.com; s=zohoarc; b=cIFoZLNLp0RIRrbR6bL0shvNsyH+CiFmi4Q6Or3xo7BulRfCDWRJT9vnr8/A7iP9DSfUlGEMtRbttS/N2E7XhFUII4Cdncm03mKVQ1Z+nrVdUT4HgNWoA8f6PGHQ1In91Tfi+RYIIvnChM7+ulwjZv7e4bCFo5yabCnSv9yVQgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621397; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zUdbpEOE2sCoSCCzub/k/gy09lZRWkzYEUTwv2/vUNg=; b=ehRyihXtA2k/QP3HCn3/gM4ooe1tbq7N+K7Mm7SI/UA4W2IQbid2NnpNVvgx/LG//aihdospcgtye3kY6M0mLBSbK5fNG0LjfShqcpz4KJLnoe4ZJ54DYhouI+IxPpYBQXp9g44NvShYjvK6CkP4h8/2QCZgXeh/SEsjW2Ie0wI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621397100164.84272651707363; Thu, 18 Apr 2019 14:03:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:47264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEBW-0005bS-T9 for importer@patchew.org; Thu, 18 Apr 2019 17:03:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0V-00056S-JT for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0T-0005EV-U4 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0T-0005D5-Gs for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C310230842A9 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92D9D60BEC for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id A3F7B1132751; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:19 +0200 Message-Id: <20190418205135.6686-21-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 18 Apr 2019 20:51:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 20/36] include: Include fprintf-fn.h only where needed 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-2-armbru@redhat.com> --- include/qemu-common.h | 2 -- include/qemu/cutils.h | 2 -- include/sysemu/cpus.h | 1 + 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/qemu-common.h b/include/qemu-common.h index a102245519..f891e05e7e 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -12,8 +12,6 @@ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H =20 -#include "qemu/fprintf-fn.h" - #define TFR(expr) do { if ((expr) !=3D -1) break; } while (errno =3D=3D EI= NTR) =20 /* Copyright string for -version arguments, About dialogs, etc */ diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index d2dad3057c..12301340a4 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -1,8 +1,6 @@ #ifndef QEMU_CUTILS_H #define QEMU_CUTILS_H =20 -#include "qemu/fprintf-fn.h" - /** * pstrcpy: * @buf: buffer to copy string into diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index 731756d948..eea0010b53 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -1,6 +1,7 @@ #ifndef QEMU_CPUS_H #define QEMU_CPUS_H =20 +#include "qemu/fprintf-fn.h" #include "qemu/timer.h" =20 /* cpus.c */ --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621201; cv=none; d=zoho.com; s=zohoarc; b=HxojOBnUtNvIJmcrkA9uL/qL2zHKhD6vgOenWIwdLzE8hRM5tIwc4tg2VAEeU0lyS1lLZDD1ZjOi/5EU2sDVrOwiN5mA6mhLAkYybpEB0p32yMoBmBpKn8i9JtNCMYL60afLRi9Kqadjm/W0K/Ihkq6jqj/0chTVrY7Np3qjjvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621201; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qbWDBf5qgaipfc+mlFKzmKxiG1gBsrHuWxRzRxsgZQ4=; b=cAr4NKbkfODN+TegGT3sCqsIawgq946HALz+fodES4T1QNVoTN8NIxVMMIWmcNmqhzJSzMKUyt5aL/z0XVfdjF8o23kwMh+2dYLQmeUxXej4wB5ypjk/y2oxf7nERPvpA79e2JZJtSU3ODUpZypf9NLSl5YLZUvVrw4jrXkmHZ8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621201194780.4667196737058; Thu, 18 Apr 2019 14:00:01 -0700 (PDT) Received: from localhost ([127.0.0.1]:47198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE8S-0002zW-Te for importer@patchew.org; Thu, 18 Apr 2019 16:59:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0Z-00057i-G0 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0U-0005Fl-NZ for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0U-0005DC-CU for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C82E481E1C for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 977C05D707 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id AB7001132752; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:20 +0200 Message-Id: <20190418205135.6686-22-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 18 Apr 2019 20:51:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 21/36] trace: Simplify how st_print_trace_file_status() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" st_print_trace_file_status() takes an fprintf()-like callback and a FILE * to pass to it. Its only caller hmp_trace_file() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-3-armbru@redhat.com> --- monitor.c | 2 +- trace/simple.c | 7 ++++--- trace/simple.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/monitor.c b/monitor.c index 10be8bdb86..a3e66b7159 100644 --- a/monitor.c +++ b/monitor.c @@ -1056,7 +1056,7 @@ static void hmp_trace_file(Monitor *mon, const QDict = *qdict) const char *arg =3D qdict_get_try_str(qdict, "arg"); =20 if (!op) { - st_print_trace_file_status((FILE *)mon, &monitor_fprintf); + st_print_trace_file_status(); } else if (!strcmp(op, "on")) { st_set_trace_file_enabled(true); } else if (!strcmp(op, "off")) { diff --git a/trace/simple.c b/trace/simple.c index ac904eca91..fc7106ec49 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -16,6 +16,7 @@ #include "trace/control.h" #include "trace/simple.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" =20 /** Trace file header event ID, picked to avoid conflict with real event I= Ds */ #define HEADER_EVENT_ID (~(uint64_t)0) @@ -363,10 +364,10 @@ void st_set_trace_file(const char *file) st_set_trace_file_enabled(true); } =20 -void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *s= tream, const char *fmt, ...)) +void st_print_trace_file_status(void) { - stream_printf(stream, "Trace file \"%s\" %s.\n", - trace_file_name, trace_fp ? "on" : "off"); + qemu_printf("Trace file \"%s\" %s.\n", + trace_file_name, trace_fp ? "on" : "off"); } =20 void st_flush_trace_buffer(void) diff --git a/trace/simple.h b/trace/simple.h index 9931808c05..5771a0634f 100644 --- a/trace/simple.h +++ b/trace/simple.h @@ -11,7 +11,7 @@ #ifndef TRACE_SIMPLE_H #define TRACE_SIMPLE_H =20 -void st_print_trace_file_status(FILE *stream, fprintf_function stream_prin= tf); +void st_print_trace_file_status(void); void st_set_trace_file_enabled(bool enable); void st_set_trace_file(const char *file); bool st_init(void); --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621395; cv=none; d=zoho.com; s=zohoarc; b=n7pHf1uScWrd3QbnjdjRFzCtFxUo93VJ5x939/VgDW8zKHfFB0Au3yrcC1gMfUj9K7q6g6BK/lVaNmmADteeLuRW31Zm4qHuuIrYqEuZp/og1QfnPlUAFSNzCO1M4969ZuvBD6bg0HnY6QtVLH8mD4hteQUzWkHpBUTq+znGkNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621395; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=t+cgk1iQNB6kdU7Lg+UybWYNVI5NKsCevFa6MWrW31Y=; b=lRAPpRW7PdWJVbotWJNmPbpAvgLnR8iCbxzRi38HWpr4muMNtVeZ5gfPun4LcKfbpNfEHQwaboZb+4mZPKV2LGWk+lWBiir+uq5hcMRennNGALyvChZRY4FlkkJxg/cRx0ojuD3VcZqJ+xweshl2Gt7mcgm8WvDURSNnbpPKndc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621395351377.49699605017975; Thu, 18 Apr 2019 14:03:15 -0700 (PDT) Received: from localhost ([127.0.0.1]:47260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEBU-0005XE-Qz for importer@patchew.org; Thu, 18 Apr 2019 17:03:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0a-00059U-W0 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005Ga-33 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45238) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0U-0005DU-Jf for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F159D7DCD7 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C96F5C21F for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B2C731132758; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:21 +0200 Message-Id: <20190418205135.6686-23-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 22/36] tcg: Simplify how dump_opcount_info() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" dump_opcount_info() takes an fprintf()-like callback and a FILE * to pass to it. Its only caller hmp_info_opcount() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-4-armbru@redhat.com> --- accel/tcg/translate-all.c | 4 ++-- include/exec/cpu-all.h | 2 +- monitor.c | 2 +- tcg/tcg.c | 9 +++++---- tcg/tcg.h | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 8f593b926f..85e80a1fad 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2333,9 +2333,9 @@ void dump_exec_info(FILE *f, fprintf_function cpu_fpr= intf) tcg_dump_info(f, cpu_fprintf); } =20 -void dump_opcount_info(FILE *f, fprintf_function cpu_fprintf) +void dump_opcount_info(void) { - tcg_dump_op_count(f, cpu_fprintf); + tcg_dump_op_count(); } =20 #else /* CONFIG_USER_ONLY */ diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index b16c9ec513..40f5edf4dc 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -363,7 +363,7 @@ static inline bool tlb_hit(target_ulong tlb_addr, targe= t_ulong addr) } =20 void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); -void dump_opcount_info(FILE *f, fprintf_function cpu_fprintf); +void dump_opcount_info(void); #endif /* !CONFIG_USER_ONLY */ =20 int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, diff --git a/monitor.c b/monitor.c index a3e66b7159..30a7ffe32b 100644 --- a/monitor.c +++ b/monitor.c @@ -1324,7 +1324,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *q= dict) =20 static void hmp_info_opcount(Monitor *mon, const QDict *qdict) { - dump_opcount_info((FILE *)mon, monitor_fprintf); + dump_opcount_info(); } #endif =20 diff --git a/tcg/tcg.c b/tcg/tcg.c index 9b2bf7f439..cc5f4e2a03 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -33,6 +33,7 @@ #include "qemu/error-report.h" #include "qemu/cutils.h" #include "qemu/host-utils.h" +#include "qemu/qemu-print.h" #include "qemu/timer.h" =20 /* Note: the long term plan is to reduce the dependencies on the QEMU @@ -3768,14 +3769,14 @@ static void tcg_profile_snapshot_table(TCGProfile *= prof) tcg_profile_snapshot(prof, false, true); } =20 -void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf) +void tcg_dump_op_count(void) { TCGProfile prof =3D {}; int i; =20 tcg_profile_snapshot_table(&prof); for (i =3D 0; i < NB_OPS; i++) { - cpu_fprintf(f, "%s %" PRId64 "\n", tcg_op_defs[i].name, + qemu_printf("%s %" PRId64 "\n", tcg_op_defs[i].name, prof.table_op_count[i]); } } @@ -3795,9 +3796,9 @@ int64_t tcg_cpu_exec_time(void) return ret; } #else -void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf) +void tcg_dump_op_count(void) { - cpu_fprintf(f, "[TCG profiler not compiled]\n"); + qemu_printf("[TCG profiler not compiled]\n"); } =20 int64_t tcg_cpu_exec_time(void) diff --git a/tcg/tcg.h b/tcg/tcg.h index 32b7cf3489..9f2b03f119 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1018,7 +1018,7 @@ int tcg_check_temp_count(void); =20 int64_t tcg_cpu_exec_time(void); void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf); -void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf); +void tcg_dump_op_count(void); =20 #define TCG_CT_ALIAS 0x80 #define TCG_CT_IALIAS 0x40 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622141; cv=none; d=zoho.com; s=zohoarc; b=Hvgc8rauHBwgGauMs4yzj3JyZwWObeDWK9YARUJpz0Qpkw40ER61bQsCnn7pMaSgO02dJepaUyGy5ue0/EAdJglLXmsJIK4csVg1KGBlj2Ky9cgfuvV8Xv8jBLjBl0QD3jJ2pQ1gg2pXHYxQEjryQNZzbZnqotB8mz9oZHX/hug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622141; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/z88WqrEVAULWVFlpijkU7tokyFhd88zcqbkkmRiAsY=; b=dHZyMP5AnAa5zMQSJLxDQcIyXXtrWQWCnkuB2r4KDlcrxje6sZcM+mlt3QAoghtqUSlIKp4f/jZbb7DT3VHJQYcWIBVAfeLpa7Hq9u7I5eGiyDtMWJ6WuHCUKKeIVkV9o7TEtSHHV9iuR1aF+igm2MoPxCxtnxfZDFHEhqa6ZBU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622141079861.6857681417246; Thu, 18 Apr 2019 14:15:41 -0700 (PDT) Received: from localhost ([127.0.0.1]:47438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHENV-00070K-TN for importer@patchew.org; Thu, 18 Apr 2019 17:15:29 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CH-3b for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0U-0005FA-EE for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55346) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0T-0005DZ-R2 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00AF581E19 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9DC1160852 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id BA51B114202D; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:22 +0200 Message-Id: <20190418205135.6686-24-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 23/36] tcg: Simplify how dump_exec_info() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" dump_exec_info() takes an fprintf()-like callback and a FILE * to pass to it. Its only caller hmp_info_jit() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-5-armbru@redhat.com> --- accel/tcg/translate-all.c | 45 ++++++++++++++++++++------------------- include/exec/cpu-all.h | 2 +- monitor.c | 2 +- tcg/tcg.c | 41 ++++++++++++++++++----------------- tcg/tcg.h | 2 +- 5 files changed, 47 insertions(+), 45 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 85e80a1fad..75a6cf49f1 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -50,6 +50,7 @@ #include "translate-all.h" #include "qemu/bitmap.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qemu/timer.h" #include "qemu/main-loop.h" #include "exec/log.h" @@ -2214,8 +2215,7 @@ void tb_flush_jmp_cache(CPUState *cpu, target_ulong a= ddr) tb_jmp_cache_clear_page(cpu, addr); } =20 -static void print_qht_statistics(FILE *f, fprintf_function cpu_fprintf, - struct qht_stats hst) +static void print_qht_statistics(struct qht_stats hst) { uint32_t hgram_opts; size_t hgram_bins; @@ -2224,7 +2224,7 @@ static void print_qht_statistics(FILE *f, fprintf_fun= ction cpu_fprintf, if (!hst.head_buckets) { return; } - cpu_fprintf(f, "TB hash buckets %zu/%zu (%0.2f%% head buckets used= )\n", + qemu_printf("TB hash buckets %zu/%zu (%0.2f%% head buckets used)\n= ", hst.used_head_buckets, hst.head_buckets, (double)hst.used_head_buckets / hst.head_buckets * 100); =20 @@ -2234,7 +2234,7 @@ static void print_qht_statistics(FILE *f, fprintf_fun= ction cpu_fprintf, hgram_opts |=3D QDIST_PR_NODECIMAL; } hgram =3D qdist_pr(&hst.occupancy, 10, hgram_opts); - cpu_fprintf(f, "TB hash occupancy %0.2f%% avg chain occ. Histogram: = %s\n", + qemu_printf("TB hash occupancy %0.2f%% avg chain occ. Histogram: %s\= n", qdist_avg(&hst.occupancy) * 100, hgram); g_free(hgram); =20 @@ -2247,7 +2247,7 @@ static void print_qht_statistics(FILE *f, fprintf_fun= ction cpu_fprintf, hgram_opts |=3D QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE; } hgram =3D qdist_pr(&hst.chain, hgram_bins, hgram_opts); - cpu_fprintf(f, "TB hash avg chain %0.3f buckets. Histogram: %s\n", + qemu_printf("TB hash avg chain %0.3f buckets. Histogram: %s\n", qdist_avg(&hst.chain), hgram); g_free(hgram); } @@ -2285,7 +2285,7 @@ static gboolean tb_tree_stats_iter(gpointer key, gpoi= nter value, gpointer data) return false; } =20 -void dump_exec_info(FILE *f, fprintf_function cpu_fprintf) +void dump_exec_info(void) { struct tb_tree_stats tst =3D {}; struct qht_stats hst; @@ -2294,43 +2294,44 @@ void dump_exec_info(FILE *f, fprintf_function cpu_f= printf) tcg_tb_foreach(tb_tree_stats_iter, &tst); nb_tbs =3D tst.nb_tbs; /* XXX: avoid using doubles ? */ - cpu_fprintf(f, "Translation buffer state:\n"); + qemu_printf("Translation buffer state:\n"); /* * Report total code size including the padding and TB structs; * otherwise users might think "-tb-size" is not honoured. * For avg host size we use the precise numbers from tb_tree_stats tho= ugh. */ - cpu_fprintf(f, "gen code size %zu/%zu\n", + qemu_printf("gen code size %zu/%zu\n", tcg_code_size(), tcg_code_capacity()); - cpu_fprintf(f, "TB count %zu\n", nb_tbs); - cpu_fprintf(f, "TB avg target size %zu max=3D%zu bytes\n", + qemu_printf("TB count %zu\n", nb_tbs); + qemu_printf("TB avg target size %zu max=3D%zu bytes\n", nb_tbs ? tst.target_size / nb_tbs : 0, tst.max_target_size); - cpu_fprintf(f, "TB avg host size %zu bytes (expansion ratio: %0.1f)= \n", + qemu_printf("TB avg host size %zu bytes (expansion ratio: %0.1f)\n", nb_tbs ? tst.host_size / nb_tbs : 0, tst.target_size ? (double)tst.host_size / tst.target_size = : 0); - cpu_fprintf(f, "cross page TB count %zu (%zu%%)\n", tst.cross_page, - nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0); - cpu_fprintf(f, "direct jump count %zu (%zu%%) (2 jumps=3D%zu %zu%%)\= n", + qemu_printf("cross page TB count %zu (%zu%%)\n", tst.cross_page, + nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0); + qemu_printf("direct jump count %zu (%zu%%) (2 jumps=3D%zu %zu%%)\n", tst.direct_jmp_count, nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs : 0, tst.direct_jmp2_count, nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0); =20 qht_statistics_init(&tb_ctx.htable, &hst); - print_qht_statistics(f, cpu_fprintf, hst); + print_qht_statistics(hst); qht_statistics_destroy(&hst); =20 - cpu_fprintf(f, "\nStatistics:\n"); - cpu_fprintf(f, "TB flush count %u\n", + qemu_printf("\nStatistics:\n"); + qemu_printf("TB flush count %u\n", atomic_read(&tb_ctx.tb_flush_count)); - cpu_fprintf(f, "TB invalidate count %zu\n", tcg_tb_phys_invalidate_cou= nt()); + qemu_printf("TB invalidate count %zu\n", + tcg_tb_phys_invalidate_count()); =20 tlb_flush_counts(&flush_full, &flush_part, &flush_elide); - cpu_fprintf(f, "TLB full flushes %zu\n", flush_full); - cpu_fprintf(f, "TLB partial flushes %zu\n", flush_part); - cpu_fprintf(f, "TLB elided flushes %zu\n", flush_elide); - tcg_dump_info(f, cpu_fprintf); + qemu_printf("TLB full flushes %zu\n", flush_full); + qemu_printf("TLB partial flushes %zu\n", flush_part); + qemu_printf("TLB elided flushes %zu\n", flush_elide); + tcg_dump_info(); } =20 void dump_opcount_info(void) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 40f5edf4dc..da07ce311f 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -362,7 +362,7 @@ static inline bool tlb_hit(target_ulong tlb_addr, targe= t_ulong addr) return tlb_hit_page(tlb_addr, addr & TARGET_PAGE_MASK); } =20 -void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); +void dump_exec_info(void); void dump_opcount_info(void); #endif /* !CONFIG_USER_ONLY */ =20 diff --git a/monitor.c b/monitor.c index 30a7ffe32b..24e4d49d11 100644 --- a/monitor.c +++ b/monitor.c @@ -1318,7 +1318,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *q= dict) return; } =20 - dump_exec_info((FILE *)mon, monitor_fprintf); + dump_exec_info(); dump_drift_info((FILE *)mon, monitor_fprintf); } =20 diff --git a/tcg/tcg.c b/tcg/tcg.c index cc5f4e2a03..6a22c8746c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4015,7 +4015,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) } =20 #ifdef CONFIG_PROFILER -void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf) +void tcg_dump_info(void) { TCGProfile prof =3D {}; const TCGProfile *s; @@ -4029,52 +4029,53 @@ void tcg_dump_info(FILE *f, fprintf_function cpu_fp= rintf) tb_div_count =3D tb_count ? tb_count : 1; tot =3D s->interm_time + s->code_time; =20 - cpu_fprintf(f, "JIT cycles %" PRId64 " (%0.3f s at 2.4 GHz)\n= ", + qemu_printf("JIT cycles %" PRId64 " (%0.3f s at 2.4 GHz)\n", tot, tot / 2.4e9); - cpu_fprintf(f, "translated TBs %" PRId64 " (aborted=3D%" PRId64 "= %0.1f%%)\n",=20 + qemu_printf("translated TBs %" PRId64 " (aborted=3D%" PRId64 + " %0.1f%%)\n", tb_count, s->tb_count1 - tb_count, (double)(s->tb_count1 - s->tb_count) / (s->tb_count1 ? s->tb_count1 : 1) * 100.0); - cpu_fprintf(f, "avg ops/TB %0.1f max=3D%d\n",=20 + qemu_printf("avg ops/TB %0.1f max=3D%d\n", (double)s->op_count / tb_div_count, s->op_count_max); - cpu_fprintf(f, "deleted ops/TB %0.2f\n", + qemu_printf("deleted ops/TB %0.2f\n", (double)s->del_op_count / tb_div_count); - cpu_fprintf(f, "avg temps/TB %0.2f max=3D%d\n", + qemu_printf("avg temps/TB %0.2f max=3D%d\n", (double)s->temp_count / tb_div_count, s->temp_count_max); - cpu_fprintf(f, "avg host code/TB %0.1f\n", + qemu_printf("avg host code/TB %0.1f\n", (double)s->code_out_len / tb_div_count); - cpu_fprintf(f, "avg search data/TB %0.1f\n", + qemu_printf("avg search data/TB %0.1f\n", (double)s->search_out_len / tb_div_count); =20 - cpu_fprintf(f, "cycles/op %0.1f\n",=20 + qemu_printf("cycles/op %0.1f\n", s->op_count ? (double)tot / s->op_count : 0); - cpu_fprintf(f, "cycles/in byte %0.1f\n",=20 + qemu_printf("cycles/in byte %0.1f\n", s->code_in_len ? (double)tot / s->code_in_len : 0); - cpu_fprintf(f, "cycles/out byte %0.1f\n",=20 + qemu_printf("cycles/out byte %0.1f\n", s->code_out_len ? (double)tot / s->code_out_len : 0); - cpu_fprintf(f, "cycles/search byte %0.1f\n", + qemu_printf("cycles/search byte %0.1f\n", s->search_out_len ? (double)tot / s->search_out_len : 0); if (tot =3D=3D 0) { tot =3D 1; } - cpu_fprintf(f, " gen_interm time %0.1f%%\n",=20 + qemu_printf(" gen_interm time %0.1f%%\n", (double)s->interm_time / tot * 100.0); - cpu_fprintf(f, " gen_code time %0.1f%%\n",=20 + qemu_printf(" gen_code time %0.1f%%\n", (double)s->code_time / tot * 100.0); - cpu_fprintf(f, "optim./code time %0.1f%%\n", + qemu_printf("optim./code time %0.1f%%\n", (double)s->opt_time / (s->code_time ? s->code_time : 1) * 100.0); - cpu_fprintf(f, "liveness/code time %0.1f%%\n",=20 + qemu_printf("liveness/code time %0.1f%%\n", (double)s->la_time / (s->code_time ? s->code_time : 1) * 1= 00.0); - cpu_fprintf(f, "cpu_restore count %" PRId64 "\n", + qemu_printf("cpu_restore count %" PRId64 "\n", s->restore_count); - cpu_fprintf(f, " avg cycles %0.1f\n", + qemu_printf(" avg cycles %0.1f\n", s->restore_count ? (double)s->restore_time / s->restore_co= unt : 0); } #else -void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf) +void tcg_dump_info(void) { - cpu_fprintf(f, "[TCG profiler not compiled]\n"); + qemu_printf("[TCG profiler not compiled]\n"); } #endif =20 diff --git a/tcg/tcg.h b/tcg/tcg.h index 9f2b03f119..a394d78237 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1017,7 +1017,7 @@ int tcg_check_temp_count(void); #endif =20 int64_t tcg_cpu_exec_time(void); -void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf); +void tcg_dump_info(void); void tcg_dump_op_count(void); =20 #define TCG_CT_ALIAS 0x80 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621855; cv=none; d=zoho.com; s=zohoarc; b=ZENAQlIRgckmtV6lruC2FD86Oh8W+/SfBKyaYEuu//5Cx8g0tMRn4OgUcdk9Kwu7lZzjJBkMj+0dBSyLpP/62gb4Np4GUBkyPlhlsfSTBlzKX5DOXQm5XD3EF0jqihLf4tqLA8Q+lYBfXvcN+ut8ABm2w4RtxDNlDOyz2xm+m/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621855; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8Ffd7w6/STlarIp+lmB6AQnffxb+mXDXtWxXz1e8c9M=; b=W+vO1iEkc1cI1iVOn5hRMwo1Zuq3wYwXtcBWrCrZvAfJ07RFmc19MPhLob6lcfJXAJwxGDHCp2XL6Ym5NLEhqeWKzAs7uztgtS5QQ4BLwy3MqnSVOgvzxzx6oLK+xh6XIGMADryuQVKxC6YsJ5tn9pVjfF4mpphSh8rxhT99YNc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621855452126.42785864736243; Thu, 18 Apr 2019 14:10:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:47383 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEJ2-0003An-C1 for importer@patchew.org; Thu, 18 Apr 2019 17:10:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0e-0005EQ-W7 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0Z-0005Jt-21 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005DF-IQ for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFE2B916CA for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A183A5D9CC for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C1A83110D6C5; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:23 +0200 Message-Id: <20190418205135.6686-25-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Apr 2019 20:51:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 24/36] tcg: Simplify how dump_drift_info() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" dump_drift_info() takes an fprintf()-like callback and a FILE * to pass to it. Its only caller hmp_info_jit() passes monitor_fprintf() and a Monitor * cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-6-armbru@redhat.com> --- cpus.c | 15 +++++++++------ include/sysemu/cpus.h | 2 +- monitor.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cpus.c b/cpus.c index e83f72b48b..684aa9679a 100644 --- a/cpus.c +++ b/cpus.c @@ -31,6 +31,7 @@ #include "qapi/qapi-events-run-state.h" #include "qapi/qmp/qerror.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/sysemu.h" #include "sysemu/block-backend.h" #include "exec/gdbstub.h" @@ -2454,19 +2455,21 @@ void qmp_inject_nmi(Error **errp) nmi_monitor_handle(monitor_get_cpu_index(), errp); } =20 -void dump_drift_info(FILE *f, fprintf_function cpu_fprintf) +void dump_drift_info(void) { if (!use_icount) { return; } =20 - cpu_fprintf(f, "Host - Guest clock %"PRIi64" ms\n", + qemu_printf("Host - Guest clock %"PRIi64" ms\n", (cpu_get_clock() - cpu_get_icount())/SCALE_MS); if (icount_align_option) { - cpu_fprintf(f, "Max guest delay %"PRIi64" ms\n", -max_delay/SC= ALE_MS); - cpu_fprintf(f, "Max guest advance %"PRIi64" ms\n", max_advance/S= CALE_MS); + qemu_printf("Max guest delay %"PRIi64" ms\n", + -max_delay / SCALE_MS); + qemu_printf("Max guest advance %"PRIi64" ms\n", + max_advance / SCALE_MS); } else { - cpu_fprintf(f, "Max guest delay NA\n"); - cpu_fprintf(f, "Max guest advance NA\n"); + qemu_printf("Max guest delay NA\n"); + qemu_printf("Max guest advance NA\n"); } } diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index eea0010b53..ef13a120cc 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -19,7 +19,7 @@ extern int icount_align_option; /* drift information for info jit command */ extern int64_t max_delay; extern int64_t max_advance; -void dump_drift_info(FILE *f, fprintf_function cpu_fprintf); +void dump_drift_info(void); =20 /* Unblock cpu */ void qemu_cpu_kick_self(void); diff --git a/monitor.c b/monitor.c index 24e4d49d11..7573689585 100644 --- a/monitor.c +++ b/monitor.c @@ -1319,7 +1319,7 @@ static void hmp_info_jit(Monitor *mon, const QDict *q= dict) } =20 dump_exec_info(); - dump_drift_info((FILE *)mon, monitor_fprintf); + dump_drift_info(); } =20 static void hmp_info_opcount(Monitor *mon, const QDict *qdict) --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621942; cv=none; d=zoho.com; s=zohoarc; b=Jb+j/bFVRuwEAFgTtOitgJc/kMYvUNc+iV14A3SdYNRZUQkXF2khX46Wi4kPLczu/AU2HjzdXe87O6ecrIoCMsJjke1tNcMHW6UqFrN3s6SWVVBTTUtJGsy38PTze4l2KjO3E0eE1X92CzQ4xcutr+sGmkC/7EB+uc0y8+TvEv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621942; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YLq3qJwf50DdBWRF64UmeJ3OELkzaFeXzymUPiGabMM=; b=Z2DdelNcEVJCXdIqhnj6jzGdLDqUqD8VYe4Te0c40+/MfG8ufvuA+cKSkuyUUdIv7cSXdNZqeyPlH0NJeOP566hbIAFgLjGkSKmCWUbRkiFkrOJjy34FE98+m7YIpBEP28hHolPHbuTOkhlDYVppJzja17GEPzvLleSzpHJ3Q4s= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621942153770.1158486176205; Thu, 18 Apr 2019 14:12:22 -0700 (PDT) Received: from localhost ([127.0.0.1]:47401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEKR-0004Wq-3O for importer@patchew.org; Thu, 18 Apr 2019 17:12:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CS-4G for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005HI-Jo for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52862) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005Df-2K for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21F0EC04B94F for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB69660857 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C9411110CFEE; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:24 +0200 Message-Id: <20190418205135.6686-26-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 25/36] qsp: Simplify how qsp_report() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qsp_report() takes an fprintf()-like callback and a FILE * to pass to it. Its only caller hmp_sync_profile() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-7-armbru@redhat.com> --- include/block/qapi.h | 1 + include/qemu/qsp.h | 6 ++---- monitor.c | 2 +- util/qsp.c | 21 +++++++++++---------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/block/qapi.h b/include/block/qapi.h index 83bdb098bd..a891f43b9c 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -27,6 +27,7 @@ =20 #include "block/block.h" #include "block/snapshot.h" +#include "qemu/fprintf-fn.h" =20 BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, BlockDriverState *bs, Error **errp= ); diff --git a/include/qemu/qsp.h b/include/qemu/qsp.h index a94c464f90..bf36aabfa8 100644 --- a/include/qemu/qsp.h +++ b/include/qemu/qsp.h @@ -11,15 +11,13 @@ #ifndef QEMU_QSP_H #define QEMU_QSP_H =20 -#include "qemu/fprintf-fn.h" - enum QSPSortBy { QSP_SORT_BY_TOTAL_WAIT_TIME, QSP_SORT_BY_AVG_WAIT_TIME, }; =20 -void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max, - enum QSPSortBy sort_by, bool callsite_coalesce); +void qsp_report(size_t max, enum QSPSortBy sort_by, + bool callsite_coalesce); =20 bool qsp_is_enabled(void); void qsp_enable(void); diff --git a/monitor.c b/monitor.c index 7573689585..1650ceec3a 100644 --- a/monitor.c +++ b/monitor.c @@ -1336,7 +1336,7 @@ static void hmp_info_sync_profile(Monitor *mon, const= QDict *qdict) enum QSPSortBy sort_by; =20 sort_by =3D mean ? QSP_SORT_BY_AVG_WAIT_TIME : QSP_SORT_BY_TOTAL_WAIT_= TIME; - qsp_report((FILE *)mon, monitor_fprintf, max, sort_by, coalesce); + qsp_report(max, sort_by, coalesce); } =20 static void hmp_info_history(Monitor *mon, const QDict *qdict) diff --git a/util/qsp.c b/util/qsp.c index 410f1ba004..5264c97342 100644 --- a/util/qsp.c +++ b/util/qsp.c @@ -56,7 +56,9 @@ * Critical-Section Execution to Improve the Performance of Multithreaded * Applications", USENIX ATC'12. */ + #include "qemu/osdep.h" +#include "qemu/qemu-print.h" #include "qemu/thread.h" #include "qemu/timer.h" #include "qemu/qht.h" @@ -678,8 +680,7 @@ static gboolean qsp_tree_report(gpointer key, gpointer = value, gpointer udata) return FALSE; } =20 -static void -pr_report(const QSPReport *rep, FILE *f, fprintf_function pr) +static void pr_report(const QSPReport *rep) { char *dashes; size_t max_len =3D 0; @@ -702,15 +703,15 @@ pr_report(const QSPReport *rep, FILE *f, fprintf_func= tion pr) /* white space to leave to the right of "Call site" */ callsite_rspace =3D callsite_len - strlen("Call site"); =20 - pr(f, "Type Object Call site%*s Wait Time (s) " - " Count Average (us)\n", callsite_rspace, ""); + qemu_printf("Type Object Call site%*s Wait Time (s) " + " Count Average (us)\n", callsite_rspace, ""); =20 /* build a horizontal rule with dashes */ n_dashes =3D 79 + callsite_rspace; dashes =3D g_malloc(n_dashes + 1); memset(dashes, '-', n_dashes); dashes[n_dashes] =3D '\0'; - pr(f, "%s\n", dashes); + qemu_printf("%s\n", dashes); =20 for (i =3D 0; i < rep->n_entries; i++) { const QSPReportEntry *e =3D &rep->entries[i]; @@ -726,11 +727,11 @@ pr_report(const QSPReport *rep, FILE *f, fprintf_func= tion pr) e->callsite_at, callsite_len - (int)strlen(e->callsite_at),= "", e->time_s, e->n_acqs, e->ns_avg * 1e-3); - pr(f, "%s", s->str); + qemu_printf("%s", s->str); g_string_free(s, TRUE); } =20 - pr(f, "%s\n", dashes); + qemu_printf("%s\n", dashes); g_free(dashes); } =20 @@ -746,8 +747,8 @@ static void report_destroy(QSPReport *rep) g_free(rep->entries); } =20 -void qsp_report(FILE *f, fprintf_function cpu_fprintf, size_t max, - enum QSPSortBy sort_by, bool callsite_coalesce) +void qsp_report(size_t max, enum QSPSortBy sort_by, + bool callsite_coalesce) { GTree *tree =3D g_tree_new_full(qsp_tree_cmp, &sort_by, g_free, NULL); QSPReport rep; @@ -762,7 +763,7 @@ void qsp_report(FILE *f, fprintf_function cpu_fprintf, = size_t max, g_tree_foreach(tree, qsp_tree_report, &rep); g_tree_destroy(tree); =20 - pr_report(&rep, f, cpu_fprintf); + pr_report(&rep); report_destroy(&rep); } =20 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621955; cv=none; d=zoho.com; s=zohoarc; b=ZGePIR8+DzGfZDAMlVUYCJHQFn1fxAoZ6U8C3+pmtFRNJvjZGCtfCl2WZaZ5HdpbTpt08LUV3mP0+XrvZ8ZOkZ2NU44dsz3vhoOqfpuy0dawTBR9mDTjc0jtx7M4gOdi/RM5ghyGDsZtiFv2SYtP6eOGIYQJsoTC4TBisgJHlaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621955; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Th7sWkCP9+6Fu/2AwwIGLDE4uOy05x7fehfhaK6Wsfg=; b=gzBctPlUCuJHh2B6e60bVWRxjsODmrg7FQZIiF+7EYCxMa9EbfaGK/J1rxyShoMr/Sb6xTbp87A/BG5NQ0d3qS/s8rhezUizVvQ8Eol4ibvOQd/rLIuHwJ/qkNH4zdqcv5XFs0hSX5MowlPgGDE92rkf/i0pgWH98K+T+Oud5VM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621955930860.539937496184; Thu, 18 Apr 2019 14:12:35 -0700 (PDT) Received: from localhost ([127.0.0.1]:47407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEKg-0004fG-Pm for importer@patchew.org; Thu, 18 Apr 2019 17:12:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CI-3R for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005Gm-Ao for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33792) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0U-0005Dr-Qo for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AFCB301EA82 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C309619C7B for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D02DA110D016; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:25 +0200 Message-Id: <20190418205135.6686-27-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 26/36] block/qapi: Clean up how we print to monitor or stdout 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_snapshot_dump(), bdrv_image_info_specific_dump(), bdrv_image_info_dump() and their helpers take an fprintf()-like callback and a FILE * to pass to it. hmp.c passes monitor_printf() cast to fprintf_function and the current monitor cast to FILE *. qemu-img.c and qemu-io-cmds.c pass fprintf and stdout. The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-8-armbru@redhat.com> --- block/qapi.c | 120 ++++++++++++++++++++----------------------- hmp.c | 12 ++--- include/block/qapi.h | 10 ++-- qemu-img.c | 6 +-- qemu-io-cmds.c | 2 +- 5 files changed, 67 insertions(+), 83 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 21edab34fc..e3e74f898f 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -36,6 +36,7 @@ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" +#include "qemu/qemu-print.h" #include "sysemu/block-backend.h" #include "qemu/cutils.h" =20 @@ -660,8 +661,7 @@ static char *get_human_readable_size(char *buf, int buf= _size, int64_t size) return buf; } =20 -void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, - QEMUSnapshotInfo *sn) +void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) { char buf1[128], date_buf[128], clock_buf[128]; struct tm tm; @@ -669,9 +669,8 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, = void *f, int64_t secs; =20 if (!sn) { - func_fprintf(f, - "%-10s%-20s%7s%20s%15s", - "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); + qemu_printf("%-10s%-20s%7s%20s%15s", + "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); } else { ti =3D sn->date_sec; localtime_r(&ti, &tm); @@ -684,50 +683,46 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf= , void *f, (int)((secs / 60) % 60), (int)(secs % 60), (int)((sn->vm_clock_nsec / 1000000) % 1000)); - func_fprintf(f, - "%-10s%-20s%7s%20s%15s", - sn->id_str, sn->name, - get_human_readable_size(buf1, sizeof(buf1), - sn->vm_state_size), - date_buf, - clock_buf); + qemu_printf("%-10s%-20s%7s%20s%15s", + sn->id_str, sn->name, + get_human_readable_size(buf1, sizeof(buf1), + sn->vm_state_size), + date_buf, + clock_buf); } } =20 -static void dump_qdict(fprintf_function func_fprintf, void *f, int indenta= tion, - QDict *dict); -static void dump_qlist(fprintf_function func_fprintf, void *f, int indenta= tion, - QList *list); +static void dump_qdict(int indentation, QDict *dict); +static void dump_qlist(int indentation, QList *list); =20 -static void dump_qobject(fprintf_function func_fprintf, void *f, - int comp_indent, QObject *obj) +static void dump_qobject(int comp_indent, QObject *obj) { switch (qobject_type(obj)) { case QTYPE_QNUM: { QNum *value =3D qobject_to(QNum, obj); char *tmp =3D qnum_to_string(value); - func_fprintf(f, "%s", tmp); + qemu_printf("%s", tmp); g_free(tmp); break; } case QTYPE_QSTRING: { QString *value =3D qobject_to(QString, obj); - func_fprintf(f, "%s", qstring_get_str(value)); + qemu_printf("%s", qstring_get_str(value)); break; } case QTYPE_QDICT: { QDict *value =3D qobject_to(QDict, obj); - dump_qdict(func_fprintf, f, comp_indent, value); + dump_qdict(comp_indent, value); break; } case QTYPE_QLIST: { QList *value =3D qobject_to(QList, obj); - dump_qlist(func_fprintf, f, comp_indent, value); + dump_qlist(comp_indent, value); break; } case QTYPE_QBOOL: { QBool *value =3D qobject_to(QBool, obj); - func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false"= ); + qemu_printf("%s", qbool_get_bool(value) ? "true" : "false"); break; } default: @@ -735,8 +730,7 @@ static void dump_qobject(fprintf_function func_fprintf,= void *f, } } =20 -static void dump_qlist(fprintf_function func_fprintf, void *f, int indenta= tion, - QList *list) +static void dump_qlist(int indentation, QList *list) { const QListEntry *entry; int i =3D 0; @@ -744,17 +738,16 @@ static void dump_qlist(fprintf_function func_fprintf,= void *f, int indentation, for (entry =3D qlist_first(list); entry; entry =3D qlist_next(entry), = i++) { QType type =3D qobject_type(entry->value); bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); - func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i, - composite ? '\n' : ' '); - dump_qobject(func_fprintf, f, indentation + 1, entry->value); + qemu_printf("%*s[%i]:%c", indentation * 4, "", i, + composite ? '\n' : ' '); + dump_qobject(indentation + 1, entry->value); if (!composite) { - func_fprintf(f, "\n"); + qemu_printf("\n"); } } } =20 -static void dump_qdict(fprintf_function func_fprintf, void *f, int indenta= tion, - QDict *dict) +static void dump_qdict(int indentation, QDict *dict) { const QDictEntry *entry; =20 @@ -769,18 +762,17 @@ static void dump_qdict(fprintf_function func_fprintf,= void *f, int indentation, key[i] =3D entry->key[i] =3D=3D '-' ? ' ' : entry->key[i]; } key[i] =3D 0; - func_fprintf(f, "%*s%s:%c", indentation * 4, "", key, - composite ? '\n' : ' '); - dump_qobject(func_fprintf, f, indentation + 1, entry->value); + qemu_printf("%*s%s:%c", indentation * 4, "", key, + composite ? '\n' : ' '); + dump_qobject(indentation + 1, entry->value); if (!composite) { - func_fprintf(f, "\n"); + qemu_printf("\n"); } g_free(key); } } =20 -void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, - ImageInfoSpecific *info_spec) +void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec) { QObject *obj, *data; Visitor *v =3D qobject_output_visitor_new(&obj); @@ -788,13 +780,12 @@ void bdrv_image_info_specific_dump(fprintf_function f= unc_fprintf, void *f, visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort); visit_complete(v, &obj); data =3D qdict_get(qobject_to(QDict, obj), "data"); - dump_qobject(func_fprintf, f, 1, data); + dump_qobject(1, data); qobject_unref(obj); visit_free(v); } =20 -void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, - ImageInfo *info) +void bdrv_image_info_dump(ImageInfo *info) { char size_buf[128], dsize_buf[128]; if (!info->has_actual_size) { @@ -804,49 +795,48 @@ void bdrv_image_info_dump(fprintf_function func_fprin= tf, void *f, info->actual_size); } get_human_readable_size(size_buf, sizeof(size_buf), info->virtual_size= ); - func_fprintf(f, - "image: %s\n" - "file format: %s\n" - "virtual size: %s (%" PRId64 " bytes)\n" - "disk size: %s\n", - info->filename, info->format, size_buf, - info->virtual_size, - dsize_buf); + qemu_printf("image: %s\n" + "file format: %s\n" + "virtual size: %s (%" PRId64 " bytes)\n" + "disk size: %s\n", + info->filename, info->format, size_buf, + info->virtual_size, + dsize_buf); =20 if (info->has_encrypted && info->encrypted) { - func_fprintf(f, "encrypted: yes\n"); + qemu_printf("encrypted: yes\n"); } =20 if (info->has_cluster_size) { - func_fprintf(f, "cluster_size: %" PRId64 "\n", - info->cluster_size); + qemu_printf("cluster_size: %" PRId64 "\n", + info->cluster_size); } =20 if (info->has_dirty_flag && info->dirty_flag) { - func_fprintf(f, "cleanly shut down: no\n"); + qemu_printf("cleanly shut down: no\n"); } =20 if (info->has_backing_filename) { - func_fprintf(f, "backing file: %s", info->backing_filename); + qemu_printf("backing file: %s", info->backing_filename); if (!info->has_full_backing_filename) { - func_fprintf(f, " (cannot determine actual path)"); + qemu_printf(" (cannot determine actual path)"); } else if (strcmp(info->backing_filename, info->full_backing_filename) !=3D 0) { - func_fprintf(f, " (actual path: %s)", info->full_backing_filen= ame); + qemu_printf(" (actual path: %s)", info->full_backing_filename); } - func_fprintf(f, "\n"); + qemu_printf("\n"); if (info->has_backing_filename_format) { - func_fprintf(f, "backing file format: %s\n", - info->backing_filename_format); + qemu_printf("backing file format: %s\n", + info->backing_filename_format); } } =20 if (info->has_snapshots) { SnapshotInfoList *elem; =20 - func_fprintf(f, "Snapshot list:\n"); - bdrv_snapshot_dump(func_fprintf, f, NULL); - func_fprintf(f, "\n"); + qemu_printf("Snapshot list:\n"); + bdrv_snapshot_dump(NULL); + qemu_printf("\n"); =20 /* Ideally bdrv_snapshot_dump() would operate on SnapshotInfoList = but * we convert to the block layer's native QEMUSnapshotInfo for now. @@ -862,13 +852,13 @@ void bdrv_image_info_dump(fprintf_function func_fprin= tf, void *f, =20 pstrcpy(sn.id_str, sizeof(sn.id_str), elem->value->id); pstrcpy(sn.name, sizeof(sn.name), elem->value->name); - bdrv_snapshot_dump(func_fprintf, f, &sn); - func_fprintf(f, "\n"); + bdrv_snapshot_dump(&sn); + qemu_printf("\n"); } } =20 if (info->has_format_specific) { - func_fprintf(f, "Format specific information:\n"); - bdrv_image_info_specific_dump(func_fprintf, f, info->format_specif= ic); + qemu_printf("Format specific information:\n"); + bdrv_image_info_specific_dump(info->format_specific); } } diff --git a/hmp.c b/hmp.c index 8eec768088..4bb3af748e 100644 --- a/hmp.c +++ b/hmp.c @@ -580,8 +580,7 @@ static void print_block_info(Monitor *mon, BlockInfo *i= nfo, monitor_printf(mon, "\nImages:\n"); image_info =3D inserted->image; while (1) { - bdrv_image_info_dump((fprintf_function)monitor_printf, - mon, image_info); + bdrv_image_info_dump(image_info); if (image_info->has_backing_image) { image_info =3D image_info->backing_image; } else { @@ -1586,7 +1585,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qd= ict) monitor_printf(mon, "List of snapshots present on all disks:\n"); =20 if (total > 0) { - bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, NULL); + bdrv_snapshot_dump(NULL); monitor_printf(mon, "\n"); for (i =3D 0; i < total; i++) { sn =3D &sn_tab[global_snapshots[i]]; @@ -1594,7 +1593,7 @@ void hmp_info_snapshots(Monitor *mon, const QDict *qd= ict) * overwrite it. */ pstrcpy(sn->id_str, sizeof(sn->id_str), "--"); - bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, sn); + bdrv_snapshot_dump(sn); monitor_printf(mon, "\n"); } } else { @@ -1608,11 +1607,10 @@ void hmp_info_snapshots(Monitor *mon, const QDict *= qdict) monitor_printf(mon, "\nList of partial (non-loadable) snapshots on '%s'= :\n", image_entry->imagename); - bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, NULL); + bdrv_snapshot_dump(NULL); monitor_printf(mon, "\n"); QTAILQ_FOREACH(snapshot_entry, &image_entry->snapshots, next) { - bdrv_snapshot_dump((fprintf_function)monitor_printf, mon, - &snapshot_entry->sn); + bdrv_snapshot_dump(&snapshot_entry->sn); monitor_printf(mon, "\n"); } } diff --git a/include/block/qapi.h b/include/block/qapi.h index a891f43b9c..cd9410dee3 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -27,7 +27,6 @@ =20 #include "block/block.h" #include "block/snapshot.h" -#include "qemu/fprintf-fn.h" =20 BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, BlockDriverState *bs, Error **errp= ); @@ -38,10 +37,7 @@ void bdrv_query_image_info(BlockDriverState *bs, ImageInfo **p_info, Error **errp); =20 -void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, - QEMUSnapshotInfo *sn); -void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, - ImageInfoSpecific *info_spec); -void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, - ImageInfo *info); +void bdrv_snapshot_dump(QEMUSnapshotInfo *sn); +void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec); +void bdrv_image_info_dump(ImageInfo *info); #endif diff --git a/qemu-img.c b/qemu-img.c index c376e91ca0..d7fe546b85 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2483,11 +2483,11 @@ static void dump_snapshots(BlockDriverState *bs) if (nb_sns <=3D 0) return; printf("Snapshot list:\n"); - bdrv_snapshot_dump(fprintf, stdout, NULL); + bdrv_snapshot_dump(NULL); printf("\n"); for(i =3D 0; i < nb_sns; i++) { sn =3D &sn_tab[i]; - bdrv_snapshot_dump(fprintf, stdout, sn); + bdrv_snapshot_dump(sn); printf("\n"); } g_free(sn_tab); @@ -2536,7 +2536,7 @@ static void dump_human_image_info_list(ImageInfoList = *list) } delim =3D true; =20 - bdrv_image_info_dump(fprintf, stdout, elem->value); + bdrv_image_info_dump(elem->value); } } =20 diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 09750a23ce..8826bebaf6 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1699,7 +1699,7 @@ static int info_f(BlockBackend *blk, int argc, char *= *argv) } if (spec_info) { printf("Format specific information:\n"); - bdrv_image_info_specific_dump(fprintf, stdout, spec_info); + bdrv_image_info_specific_dump(spec_info); qapi_free_ImageInfoSpecific(spec_info); } =20 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621783; cv=none; d=zoho.com; s=zohoarc; b=DlZR2LYTzgnok5UJ0TQn81JVsXIm5oZREFdbB+tXV4VqJCDmSpixBQz5QwbZy4Ky7/jUCW2ENFWUO9SyO8PtwqKowbvBptrGs3mjvfPYpDKtLUcnCGA8+AQuJ/WfBP/zY4WphhAsNJJN2dj1XQRGXI6G3lP/IofKdy/HEmTdtwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621783; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uA3/52hYHycWYn9hDHX6jwcJb/8L6YS5DbypcxEbuoc=; b=jbwVIj/Cm+p6JyBBLKGyk96F4WmdTvfnpubzFSgGT4krnsjfIgJa3fyICE91y3AwhJrm5ejdfIpwoENUFiMRnq0ETKx8SV0HlWPoV2fIJyCgc7m2haSdRrAd8yfiCrue/AeJGqgvxBngMcK/h+oW4zBcLGXVBD93R2Sjm6S9cXU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621783850685.1274557375637; Thu, 18 Apr 2019 14:09:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:47352 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEHk-000277-Dc for importer@patchew.org; Thu, 18 Apr 2019 17:09:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CA-2I for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005GT-1N for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55348) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0U-0005E6-Hw for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F4BA81227 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D862D60BEC for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D734A110CFA9; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:26 +0200 Message-Id: <20190418205135.6686-28-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 27/36] memory: Clean up how mtree_info() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" mtree_info() takes an fprintf()-like callback and a FILE * to pass to it, and so do its helper functions. Passing around callback and argument is rather tiresome. Its only caller hmp_info_mtree() passes monitor_printf() cast to fprintf_function and the current monitor cast to FILE *. The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-9-armbru@redhat.com> --- exec.c | 40 ++++----- include/exec/memory-internal.h | 3 +- include/exec/memory.h | 3 +- memory.c | 156 ++++++++++++++++----------------- monitor.c | 3 +- 5 files changed, 98 insertions(+), 107 deletions(-) diff --git a/exec.c b/exec.c index 6ab62f4eee..85d15606f1 100644 --- a/exec.c +++ b/exec.c @@ -35,6 +35,7 @@ #include "qemu/timer.h" #include "qemu/config-file.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #if defined(CONFIG_USER_ONLY) #include "qemu.h" #else /* !CONFIG_USER_ONLY */ @@ -4117,42 +4118,41 @@ void page_size_init(void) =20 #if !defined(CONFIG_USER_ONLY) =20 -static void mtree_print_phys_entries(fprintf_function mon, void *f, - int start, int end, int skip, int ptr) +static void mtree_print_phys_entries(int start, int end, int skip, int ptr) { if (start =3D=3D end - 1) { - mon(f, "\t%3d ", start); + qemu_printf("\t%3d ", start); } else { - mon(f, "\t%3d..%-3d ", start, end - 1); + qemu_printf("\t%3d..%-3d ", start, end - 1); } - mon(f, " skip=3D%d ", skip); + qemu_printf(" skip=3D%d ", skip); if (ptr =3D=3D PHYS_MAP_NODE_NIL) { - mon(f, " ptr=3DNIL"); + qemu_printf(" ptr=3DNIL"); } else if (!skip) { - mon(f, " ptr=3D#%d", ptr); + qemu_printf(" ptr=3D#%d", ptr); } else { - mon(f, " ptr=3D[%d]", ptr); + qemu_printf(" ptr=3D[%d]", ptr); } - mon(f, "\n"); + qemu_printf("\n"); } =20 #define MR_SIZE(size) (int128_nz(size) ? (hwaddr)int128_get64( \ int128_sub((size), int128_one())) : 0) =20 -void mtree_print_dispatch(fprintf_function mon, void *f, - AddressSpaceDispatch *d, MemoryRegion *root) +void mtree_print_dispatch(AddressSpaceDispatch *d, MemoryRegion *root) { int i; =20 - mon(f, " Dispatch\n"); - mon(f, " Physical sections\n"); + qemu_printf(" Dispatch\n"); + qemu_printf(" Physical sections\n"); =20 for (i =3D 0; i < d->map.sections_nb; ++i) { MemoryRegionSection *s =3D d->map.sections + i; const char *names[] =3D { " [unassigned]", " [not dirty]", " [ROM]", " [watch]" }; =20 - mon(f, " #%d @" TARGET_FMT_plx ".." TARGET_FMT_plx " %s%s%s%s= %s", + qemu_printf(" #%d @" TARGET_FMT_plx ".." TARGET_FMT_plx + " %s%s%s%s%s", i, s->offset_within_address_space, s->offset_within_address_space + MR_SIZE(s->mr->size), @@ -4163,20 +4163,20 @@ void mtree_print_dispatch(fprintf_function mon, voi= d *f, s->mr->is_iommu ? " [iommu]" : ""); =20 if (s->mr->alias) { - mon(f, " alias=3D%s", s->mr->alias->name ? + qemu_printf(" alias=3D%s", s->mr->alias->name ? s->mr->alias->name : "noname"); } - mon(f, "\n"); + qemu_printf("\n"); } =20 - mon(f, " Nodes (%d bits per level, %d levels) ptr=3D[%d] skip=3D%d\= n", + qemu_printf(" Nodes (%d bits per level, %d levels) ptr=3D[%d] skip= =3D%d\n", P_L2_BITS, P_L2_LEVELS, d->phys_map.ptr, d->phys_map.skip); for (i =3D 0; i < d->map.nodes_nb; ++i) { int j, jprev; PhysPageEntry prev; Node *n =3D d->map.nodes + i; =20 - mon(f, " [%d]\n", i); + qemu_printf(" [%d]\n", i); =20 for (j =3D 0, jprev =3D 0, prev =3D *n[0]; j < ARRAY_SIZE(*n); ++j= ) { PhysPageEntry *pe =3D *n + j; @@ -4185,14 +4185,14 @@ void mtree_print_dispatch(fprintf_function mon, voi= d *f, continue; } =20 - mtree_print_phys_entries(mon, f, jprev, j, prev.skip, prev.ptr= ); + mtree_print_phys_entries(jprev, j, prev.skip, prev.ptr); =20 jprev =3D j; prev =3D *pe; } =20 if (jprev !=3D ARRAY_SIZE(*n)) { - mtree_print_phys_entries(mon, f, jprev, j, prev.skip, prev.ptr= ); + mtree_print_phys_entries(jprev, j, prev.skip, prev.ptr); } } } diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index bb08fa4d2f..d1a9dd1ec8 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -45,8 +45,7 @@ AddressSpaceDispatch *address_space_dispatch_new(FlatView= *fv); void address_space_dispatch_compact(AddressSpaceDispatch *d); void address_space_dispatch_free(AddressSpaceDispatch *d); =20 -void mtree_print_dispatch(fprintf_function mon, void *f, - struct AddressSpaceDispatch *d, +void mtree_print_dispatch(struct AddressSpaceDispatch *d, MemoryRegion *root); =20 struct page_collection; diff --git a/include/exec/memory.h b/include/exec/memory.h index 1625913f84..9144a47f57 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1720,8 +1720,7 @@ void memory_global_dirty_log_start(void); */ void memory_global_dirty_log_stop(void); =20 -void mtree_info(fprintf_function mon_printf, void *f, bool flatview, - bool dispatch_tree, bool owner); +void mtree_info(bool flatview, bool dispatch_tree, bool owner); =20 /** * memory_region_dispatch_read: perform a read directly to the specified diff --git a/memory.c b/memory.c index 9fbca52e05..bb2b71ee38 100644 --- a/memory.c +++ b/memory.c @@ -22,6 +22,7 @@ #include "qapi/visitor.h" #include "qemu/bitops.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qom/object.h" #include "trace-root.h" =20 @@ -2800,46 +2801,43 @@ typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegio= nListHead; int128_sub((size), int128_one())) : 0) #define MTREE_INDENT " " =20 -static void mtree_expand_owner(fprintf_function mon_printf, void *f, - const char *label, Object *obj) +static void mtree_expand_owner(const char *label, Object *obj) { DeviceState *dev =3D (DeviceState *) object_dynamic_cast(obj, TYPE_DEV= ICE); =20 - mon_printf(f, " %s:{%s", label, dev ? "dev" : "obj"); + qemu_printf(" %s:{%s", label, dev ? "dev" : "obj"); if (dev && dev->id) { - mon_printf(f, " id=3D%s", dev->id); + qemu_printf(" id=3D%s", dev->id); } else { gchar *canonical_path =3D object_get_canonical_path(obj); if (canonical_path) { - mon_printf(f, " path=3D%s", canonical_path); + qemu_printf(" path=3D%s", canonical_path); g_free(canonical_path); } else { - mon_printf(f, " type=3D%s", object_get_typename(obj)); + qemu_printf(" type=3D%s", object_get_typename(obj)); } } - mon_printf(f, "}"); + qemu_printf("}"); } =20 -static void mtree_print_mr_owner(fprintf_function mon_printf, void *f, - const MemoryRegion *mr) +static void mtree_print_mr_owner(const MemoryRegion *mr) { Object *owner =3D mr->owner; Object *parent =3D memory_region_owner((MemoryRegion *)mr); =20 if (!owner && !parent) { - mon_printf(f, " orphan"); + qemu_printf(" orphan"); return; } if (owner) { - mtree_expand_owner(mon_printf, f, "owner", owner); + mtree_expand_owner("owner", owner); } if (parent && parent !=3D owner) { - mtree_expand_owner(mon_printf, f, "parent", parent); + mtree_expand_owner("parent", parent); } } =20 -static void mtree_print_mr(fprintf_function mon_printf, void *f, - const MemoryRegion *mr, unsigned int level, +static void mtree_print_mr(const MemoryRegion *mr, unsigned int level, hwaddr base, MemoryRegionListHead *alias_print_queue, bool owner) @@ -2855,7 +2853,7 @@ static void mtree_print_mr(fprintf_function mon_print= f, void *f, } =20 for (i =3D 0; i < level; i++) { - mon_printf(f, MTREE_INDENT); + qemu_printf(MTREE_INDENT); } =20 cur_start =3D base + mr->addr; @@ -2867,7 +2865,7 @@ static void mtree_print_mr(fprintf_function mon_print= f, void *f, * user who is observing this. */ if (cur_start < base || cur_end < cur_start) { - mon_printf(f, "[DETECTED OVERFLOW!] "); + qemu_printf("[DETECTED OVERFLOW!] "); } =20 if (mr->alias) { @@ -2886,35 +2884,35 @@ static void mtree_print_mr(fprintf_function mon_pri= ntf, void *f, ml->mr =3D mr->alias; QTAILQ_INSERT_TAIL(alias_print_queue, ml, mrqueue); } - mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx - " (prio %d, %s%s): alias %s @%s " TARGET_FMT_plx - "-" TARGET_FMT_plx "%s", - cur_start, cur_end, - mr->priority, - mr->nonvolatile ? "nv-" : "", - memory_region_type((MemoryRegion *)mr), - memory_region_name(mr), - memory_region_name(mr->alias), - mr->alias_offset, - mr->alias_offset + MR_SIZE(mr->size), - mr->enabled ? "" : " [disabled]"); + qemu_printf(TARGET_FMT_plx "-" TARGET_FMT_plx + " (prio %d, %s%s): alias %s @%s " TARGET_FMT_plx + "-" TARGET_FMT_plx "%s", + cur_start, cur_end, + mr->priority, + mr->nonvolatile ? "nv-" : "", + memory_region_type((MemoryRegion *)mr), + memory_region_name(mr), + memory_region_name(mr->alias), + mr->alias_offset, + mr->alias_offset + MR_SIZE(mr->size), + mr->enabled ? "" : " [disabled]"); if (owner) { - mtree_print_mr_owner(mon_printf, f, mr); + mtree_print_mr_owner(mr); } } else { - mon_printf(f, - TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s%s): %s= %s", - cur_start, cur_end, - mr->priority, - mr->nonvolatile ? "nv-" : "", - memory_region_type((MemoryRegion *)mr), - memory_region_name(mr), - mr->enabled ? "" : " [disabled]"); + qemu_printf(TARGET_FMT_plx "-" TARGET_FMT_plx + " (prio %d, %s%s): %s%s", + cur_start, cur_end, + mr->priority, + mr->nonvolatile ? "nv-" : "", + memory_region_type((MemoryRegion *)mr), + memory_region_name(mr), + mr->enabled ? "" : " [disabled]"); if (owner) { - mtree_print_mr_owner(mon_printf, f, mr); + mtree_print_mr_owner(mr); } } - mon_printf(f, "\n"); + qemu_printf("\n"); =20 QTAILQ_INIT(&submr_print_queue); =20 @@ -2936,7 +2934,7 @@ static void mtree_print_mr(fprintf_function mon_print= f, void *f, } =20 QTAILQ_FOREACH(ml, &submr_print_queue, mrqueue) { - mtree_print_mr(mon_printf, f, ml->mr, level + 1, cur_start, + mtree_print_mr(ml->mr, level + 1, cur_start, alias_print_queue, owner); } =20 @@ -2946,8 +2944,6 @@ static void mtree_print_mr(fprintf_function mon_print= f, void *f, } =20 struct FlatViewInfo { - fprintf_function mon_printf; - void *f; int counter; bool dispatch_tree; bool owner; @@ -2959,70 +2955,71 @@ static void mtree_print_flatview(gpointer key, gpoi= nter value, FlatView *view =3D key; GArray *fv_address_spaces =3D value; struct FlatViewInfo *fvi =3D user_data; - fprintf_function p =3D fvi->mon_printf; - void *f =3D fvi->f; FlatRange *range =3D &view->ranges[0]; MemoryRegion *mr; int n =3D view->nr; int i; AddressSpace *as; =20 - p(f, "FlatView #%d\n", fvi->counter); + qemu_printf("FlatView #%d\n", fvi->counter); ++fvi->counter; =20 for (i =3D 0; i < fv_address_spaces->len; ++i) { as =3D g_array_index(fv_address_spaces, AddressSpace*, i); - p(f, " AS \"%s\", root: %s", as->name, memory_region_name(as->root= )); + qemu_printf(" AS \"%s\", root: %s", + as->name, memory_region_name(as->root)); if (as->root->alias) { - p(f, ", alias %s", memory_region_name(as->root->alias)); + qemu_printf(", alias %s", memory_region_name(as->root->alias)); } - p(f, "\n"); + qemu_printf("\n"); } =20 - p(f, " Root memory region: %s\n", + qemu_printf(" Root memory region: %s\n", view->root ? memory_region_name(view->root) : "(none)"); =20 if (n <=3D 0) { - p(f, MTREE_INDENT "No rendered FlatView\n\n"); + qemu_printf(MTREE_INDENT "No rendered FlatView\n\n"); return; } =20 while (n--) { mr =3D range->mr; if (range->offset_in_region) { - p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx " (prio %d, %s%s): %s @" TARGET_FMT_plx, - int128_get64(range->addr.start), - int128_get64(range->addr.start) + MR_SIZE(range->addr.size), - mr->priority, - range->nonvolatile ? "nv-" : "", - range->readonly ? "rom" : memory_region_type(mr), - memory_region_name(mr), - range->offset_in_region); + qemu_printf(MTREE_INDENT TARGET_FMT_plx "-" TARGET_FMT_plx + " (prio %d, %s%s): %s @" TARGET_FMT_plx, + int128_get64(range->addr.start), + int128_get64(range->addr.start) + + MR_SIZE(range->addr.size), + mr->priority, + range->nonvolatile ? "nv-" : "", + range->readonly ? "rom" : memory_region_type(mr), + memory_region_name(mr), + range->offset_in_region); } else { - p(f, MTREE_INDENT TARGET_FMT_plx "-" - TARGET_FMT_plx " (prio %d, %s%s): %s", - int128_get64(range->addr.start), - int128_get64(range->addr.start) + MR_SIZE(range->addr.size), - mr->priority, - range->nonvolatile ? "nv-" : "", - range->readonly ? "rom" : memory_region_type(mr), - memory_region_name(mr)); + qemu_printf(MTREE_INDENT TARGET_FMT_plx "-" TARGET_FMT_plx + " (prio %d, %s%s): %s", + int128_get64(range->addr.start), + int128_get64(range->addr.start) + + MR_SIZE(range->addr.size), + mr->priority, + range->nonvolatile ? "nv-" : "", + range->readonly ? "rom" : memory_region_type(mr), + memory_region_name(mr)); } if (fvi->owner) { - mtree_print_mr_owner(p, f, mr); + mtree_print_mr_owner(mr); } - p(f, "\n"); + qemu_printf("\n"); range++; } =20 #if !defined(CONFIG_USER_ONLY) if (fvi->dispatch_tree && view->root) { - mtree_print_dispatch(p, f, view->dispatch, view->root); + mtree_print_dispatch(view->dispatch, view->root); } #endif =20 - p(f, "\n"); + qemu_printf("\n"); } =20 static gboolean mtree_info_flatview_free(gpointer key, gpointer value, @@ -3037,8 +3034,7 @@ static gboolean mtree_info_flatview_free(gpointer key= , gpointer value, return true; } =20 -void mtree_info(fprintf_function mon_printf, void *f, bool flatview, - bool dispatch_tree, bool owner) +void mtree_info(bool flatview, bool dispatch_tree, bool owner) { MemoryRegionListHead ml_head; MemoryRegionList *ml, *ml2; @@ -3047,8 +3043,6 @@ void mtree_info(fprintf_function mon_printf, void *f,= bool flatview, if (flatview) { FlatView *view; struct FlatViewInfo fvi =3D { - .mon_printf =3D mon_printf, - .f =3D f, .counter =3D 0, .dispatch_tree =3D dispatch_tree, .owner =3D owner, @@ -3082,16 +3076,16 @@ void mtree_info(fprintf_function mon_printf, void *= f, bool flatview, QTAILQ_INIT(&ml_head); =20 QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { - mon_printf(f, "address-space: %s\n", as->name); - mtree_print_mr(mon_printf, f, as->root, 1, 0, &ml_head, owner); - mon_printf(f, "\n"); + qemu_printf("address-space: %s\n", as->name); + mtree_print_mr(as->root, 1, 0, &ml_head, owner); + qemu_printf("\n"); } =20 /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, mrqueue) { - mon_printf(f, "memory-region: %s\n", memory_region_name(ml->mr)); - mtree_print_mr(mon_printf, f, ml->mr, 1, 0, &ml_head, owner); - mon_printf(f, "\n"); + qemu_printf("memory-region: %s\n", memory_region_name(ml->mr)); + mtree_print_mr(ml->mr, 1, 0, &ml_head, owner); + qemu_printf("\n"); } =20 QTAILQ_FOREACH_SAFE(ml, &ml_head, mrqueue, ml2) { diff --git a/monitor.c b/monitor.c index 1650ceec3a..0819b99ef7 100644 --- a/monitor.c +++ b/monitor.c @@ -1907,8 +1907,7 @@ static void hmp_info_mtree(Monitor *mon, const QDict = *qdict) bool dispatch_tree =3D qdict_get_try_bool(qdict, "dispatch_tree", fals= e); bool owner =3D qdict_get_try_bool(qdict, "owner", false); =20 - mtree_info((fprintf_function)monitor_printf, mon, flatview, dispatch_t= ree, - owner); + mtree_info(flatview, dispatch_tree, owner); } =20 static void hmp_info_numa(Monitor *mon, const QDict *qdict) --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622049; cv=none; d=zoho.com; s=zohoarc; b=kJRPEkwoVM4w9OamZCOXodjmq5ZOMOsz0Mc6OJl7vN6lXGTcS9leY03U/zQr5z3Eo7nXg6uVnoTvmBiQiIV8zRNFe6MaU0sHj0fcB0DlgRNFVWGkwbkiUkpmwb+H7Liw8zRjfEYyTqYXF9BV2K5Mr/MwfbEnGXtRbFkGUT3Z5yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622049; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YKvNRkPc4A2mZb9GSiIMCvgMQysqbNDDNQ7icNBlalg=; b=KBZg6HpOpdAL9b9fOAipN79mvXqa3UEluULyDghfM4F+buYE1g27u3lmE2V6YEkZTjXSVC/XiQhXS6RutguCaHdIPUXQ/kmDaLzDccinfovSycZTI2Xn0o/1/3c98WuiqjIzmPXneKppSlW9OR6yXs3aiKvWrpqnGxfxJxBKViY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622049638792.3749719874072; Thu, 18 Apr 2019 14:14:09 -0700 (PDT) Received: from localhost ([127.0.0.1]:47419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEM4-0005kh-0r for importer@patchew.org; Thu, 18 Apr 2019 17:14:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0e-0005Du-6p for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005Gw-ES for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25644) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0U-0005EZ-SK for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B22177DCE0 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF9B160143 for ; Thu, 18 Apr 2019 20:51:40 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DFA52110CFAF; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:27 +0200 Message-Id: <20190418205135.6686-29-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 18 Apr 2019 20:51:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 28/36] target: Simplify how the TARGET_cpu_list() print 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The various TARGET_cpu_list() take an fprintf()-like callback and a FILE * to pass to it. Their callers (vl.c's main() via list_cpus(), bsd-user/main.c's main(), linux-user/main.c's main()) all pass fprintf() and stdout. Thus, the flexibility provided by the (rather tiresome) indirection isn't actually used. Drop the callback, and call qemu_printf() instead. Calling printf() would also work, but would make the code unsuitable for monitor context without making it simpler. Signed-off-by: Markus Armbruster Message-Id: <20190417191805.28198-10-armbru@redhat.com> Reviewed-by: Dr. David Alan Gilbert --- bsd-user/main.c | 2 +- cpus.c | 4 +-- include/exec/cpu-common.h | 13 --------- include/sysemu/cpus.h | 3 +- linux-user/main.c | 2 +- target/alpha/cpu.c | 15 ++++------ target/alpha/cpu.h | 2 +- target/arm/cpu.c | 1 - target/arm/cpu.h | 2 +- target/arm/helper.c | 15 ++++------ target/cris/cpu.c | 14 ++++----- target/cris/cpu.h | 2 +- target/hppa/cpu.c | 14 ++++----- target/hppa/cpu.h | 2 +- target/i386/cpu.c | 29 ++++++++----------- target/i386/cpu.h | 2 +- target/lm32/cpu.c | 14 ++++----- target/lm32/cpu.h | 2 +- target/m68k/cpu.h | 2 +- target/m68k/helper.c | 14 +++------ target/mips/cpu.h | 2 +- target/mips/translate.c | 1 + target/mips/translate_init.inc.c | 5 ++-- target/openrisc/cpu.c | 15 ++++------ target/openrisc/cpu.h | 2 +- target/ppc/cpu.h | 2 +- target/ppc/translate_init.inc.c | 26 +++++++---------- target/riscv/cpu.c | 17 +++-------- target/riscv/cpu.h | 2 +- target/s390x/cpu.h | 2 +- target/s390x/cpu_models.c | 21 ++++++-------- target/sh4/cpu.c | 17 +++-------- target/sh4/cpu.h | 2 +- target/sparc/cpu.c | 49 +++++++++++++++----------------- target/sparc/cpu.h | 2 +- target/tricore/cpu.h | 2 +- target/tricore/helper.c | 15 ++++------ target/xtensa/cpu.h | 2 +- target/xtensa/helper.c | 7 +++-- vl.c | 2 +- 40 files changed, 129 insertions(+), 218 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 8fd8ae4127..7657c6851d 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -819,7 +819,7 @@ int main(int argc, char **argv) if (is_help_option(cpu_model)) { /* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) - cpu_list(stdout, &fprintf); + cpu_list(); #endif exit(1); } diff --git a/cpus.c b/cpus.c index 684aa9679a..b4eecf70f0 100644 --- a/cpus.c +++ b/cpus.c @@ -2181,11 +2181,11 @@ int vm_stop_force_state(RunState state) } } =20 -void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg) +void list_cpus(const char *optarg) { /* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) - cpu_list(f, cpu_fprintf); + cpu_list(); #endif } =20 diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index cef8b88a2a..848a4b94ab 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -9,19 +9,6 @@ =20 #include "qemu/bswap.h" #include "qemu/queue.h" -#include "qemu/fprintf-fn.h" - -/** - * CPUListState: - * @cpu_fprintf: Print function. - * @file: File to print to using @cpu_fprint. - * - * State commonly used for iterating over CPU models. - */ -typedef struct CPUListState { - fprintf_function cpu_fprintf; - FILE *file; -} CPUListState; =20 /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ void qemu_init_cpu_list(void); diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index ef13a120cc..32c05f27e7 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -1,7 +1,6 @@ #ifndef QEMU_CPUS_H #define QEMU_CPUS_H =20 -#include "qemu/fprintf-fn.h" #include "qemu/timer.h" =20 /* cpus.c */ @@ -39,7 +38,7 @@ extern int smp_cores; extern int smp_threads; #endif =20 -void list_cpus(FILE *f, fprintf_function cpu_fprintf, const char *optarg); +void list_cpus(const char *optarg); =20 void qemu_tcg_configure(QemuOpts *opts, Error **errp); =20 diff --git a/linux-user/main.c b/linux-user/main.c index f9efe9ff6e..17387166ab 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -317,7 +317,7 @@ static void handle_arg_cpu(const char *arg) if (cpu_model =3D=3D NULL || is_help_option(cpu_model)) { /* XXX: implement xxx_cpu_list for targets that still miss it */ #if defined(cpu_list) - cpu_list(stdout, &fprintf); + cpu_list(); #endif exit(EXIT_FAILURE); } diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 1fd95d6c0f..ad3588a44a 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -21,6 +21,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "exec/exec-all.h" @@ -74,23 +75,17 @@ static void alpha_cpu_realizefn(DeviceState *dev, Error= **errp) static void alpha_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; - CPUListState *s =3D user_data; =20 - (*s->cpu_fprintf)(s->file, " %s\n", - object_class_get_name(oc)); + qemu_printf(" %s\n", object_class_get_name(oc)); } =20 -void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void alpha_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list_sorted(TYPE_ALPHA_CPU, false); - (*cpu_fprintf)(f, "Available CPUs:\n"); - g_slist_foreach(list, alpha_cpu_list_entry, &s); + qemu_printf("Available CPUs:\n"); + g_slist_foreach(list, alpha_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 7b50be785d..732764f23c 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -470,7 +470,7 @@ void alpha_translate_init(void); #define ALPHA_CPU_TYPE_NAME(model) model ALPHA_CPU_TYPE_SUFFIX #define CPU_RESOLVING_TYPE TYPE_ALPHA_CPU =20 -void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void alpha_cpu_list(void); /* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 4155782197..bb9fdc6304 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -20,7 +20,6 @@ =20 #include "qemu/osdep.h" #include "target/arm/idau.h" -#include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "cpu.h" diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d4d2836923..85c3bd642a 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1936,7 +1936,7 @@ static inline bool access_secure_reg(CPUARMState *env) (arm_is_secure(_env) && !arm_el_is_aa64((_env), 3))= , \ (_val)) =20 -void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void arm_cpu_list(void); uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, uint32_t cur_el, bool secure); =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index a36f4b3d69..57ef75b3fc 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10,6 +10,7 @@ #include "sysemu/sysemu.h" #include "qemu/bitops.h" #include "qemu/crc32c.h" +#include "qemu/qemu-print.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" #include "arm_ldst.h" @@ -6724,29 +6725,23 @@ static gint arm_cpu_list_compare(gconstpointer a, g= constpointer b) static void arm_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; - CPUListState *s =3D user_data; const char *typename; char *name; =20 typename =3D object_class_get_name(oc); name =3D g_strndup(typename, strlen(typename) - strlen("-" TYPE_ARM_CP= U)); - (*s->cpu_fprintf)(s->file, " %s\n", - name); + qemu_printf(" %s\n", name); g_free(name); } =20 -void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void arm_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list(TYPE_ARM_CPU, false); list =3D g_slist_sort(list, arm_cpu_list_compare); - (*cpu_fprintf)(f, "Available CPUs:\n"); - g_slist_foreach(list, arm_cpu_list_entry, &s); + qemu_printf("Available CPUs:\n"); + g_slist_foreach(list, arm_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/cris/cpu.c b/target/cris/cpu.c index a23aba2688..75729bfdd5 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -23,6 +23,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "mmu.h" @@ -103,27 +104,22 @@ static gint cris_cpu_list_compare(gconstpointer a, gc= onstpointer b) static void cris_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; - CPUListState *s =3D user_data; const char *typename =3D object_class_get_name(oc); char *name; =20 name =3D g_strndup(typename, strlen(typename) - strlen(CRIS_CPU_TYPE_S= UFFIX)); - (*s->cpu_fprintf)(s->file, " %s\n", name); + qemu_printf(" %s\n", name); g_free(name); } =20 -void cris_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void cris_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list(TYPE_CRIS_CPU, false); list =3D g_slist_sort(list, cris_cpu_list_compare); - (*cpu_fprintf)(f, "Available CPUs:\n"); - g_slist_foreach(list, cris_cpu_list_entry, &s); + qemu_printf("Available CPUs:\n"); + g_slist_foreach(list, cris_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/cris/cpu.h b/target/cris/cpu.h index 8bb1dbc989..3d11922fb2 100644 --- a/target/cris/cpu.h +++ b/target/cris/cpu.h @@ -308,6 +308,6 @@ static inline void cpu_get_tb_cpu_state(CPUCRISState *e= nv, target_ulong *pc, } =20 #define cpu_list cris_cpu_list -void cris_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void cris_cpu_list(void); =20 #endif diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 00bf444620..e64f48581e 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "exec/exec-all.h" @@ -113,22 +114,17 @@ static void hppa_cpu_realizefn(DeviceState *dev, Erro= r **errp) static void hppa_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; - CPUListState *s =3D user_data; =20 - (*s->cpu_fprintf)(s->file, " %s\n", object_class_get_name(oc)); + qemu_printf(" %s\n", object_class_get_name(oc)); } =20 -void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void hppa_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list_sorted(TYPE_HPPA_CPU, false); - (*cpu_fprintf)(f, "Available CPUs:\n"); - g_slist_foreach(list, hppa_cpu_list_entry, &s); + qemu_printf("Available CPUs:\n"); + g_slist_foreach(list, hppa_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index c062c7969c..db8c9b812c 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -272,7 +272,7 @@ void hppa_translate_init(void); =20 #define CPU_RESOLVING_TYPE TYPE_HPPA_CPU =20 -void hppa_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void hppa_cpu_list(void); =20 static inline target_ulong hppa_form_gva_psw(target_ureg psw, uint64_t spc, target_ureg off) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d6bb57d210..e1687f7547 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -21,6 +21,7 @@ #include "qemu/units.h" #include "qemu/cutils.h" #include "qemu/bitops.h" +#include "qemu/qemu-print.h" =20 #include "cpu.h" #include "exec/exec-all.h" @@ -3671,7 +3672,7 @@ static void x86_cpu_class_check_missing_features(X86C= PUClass *xcc, =20 /* Print all cpuid feature names in featureset */ -static void listflags(FILE *f, fprintf_function print, GList *features) +static void listflags(GList *features) { size_t len =3D 0; GList *tmp; @@ -3679,13 +3680,13 @@ static void listflags(FILE *f, fprintf_function pri= nt, GList *features) for (tmp =3D features; tmp; tmp =3D tmp->next) { const char *name =3D tmp->data; if ((len + strlen(name) + 1) >=3D 75) { - print(f, "\n"); + qemu_printf("\n"); len =3D 0; } - print(f, "%s%s", len =3D=3D 0 ? " " : " ", name); + qemu_printf("%s%s", len =3D=3D 0 ? " " : " ", name); len +=3D strlen(name) + 1; } - print(f, "\n"); + qemu_printf("\n"); } =20 /* Sort alphabetically by type name, respecting X86CPUClass::ordering. */ @@ -3721,32 +3722,26 @@ static void x86_cpu_list_entry(gpointer data, gpoin= ter user_data) { ObjectClass *oc =3D data; X86CPUClass *cc =3D X86_CPU_CLASS(oc); - CPUListState *s =3D user_data; char *name =3D x86_cpu_class_get_model_name(cc); const char *desc =3D cc->model_description; if (!desc && cc->cpu_def) { desc =3D cc->cpu_def->model_id; } =20 - (*s->cpu_fprintf)(s->file, "x86 %-20s %-48s\n", - name, desc); + qemu_printf("x86 %-20s %-48s\n", name, desc); g_free(name); } =20 /* list available CPU models and flags */ -void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void x86_cpu_list(void) { int i, j; - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; GList *names =3D NULL; =20 - (*cpu_fprintf)(f, "Available CPUs:\n"); + qemu_printf("Available CPUs:\n"); list =3D get_sorted_cpu_model_list(); - g_slist_foreach(list, x86_cpu_list_entry, &s); + g_slist_foreach(list, x86_cpu_list_entry, NULL); g_slist_free(list); =20 names =3D NULL; @@ -3761,9 +3756,9 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprin= tf) =20 names =3D g_list_sort(names, (GCompareFunc)strcmp); =20 - (*cpu_fprintf)(f, "\nRecognized CPUID flags:\n"); - listflags(f, cpu_fprintf, names); - (*cpu_fprintf)(f, "\n"); + qemu_printf("\nRecognized CPUID flags:\n"); + listflags(names); + qemu_printf("\n"); g_list_free(names); } =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 83fb522554..b39327dcb7 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1532,7 +1532,7 @@ int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t= *buf, int reg); void x86_cpu_exec_enter(CPUState *cpu); void x86_cpu_exec_exit(CPUState *cpu); =20 -void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void x86_cpu_list(void); int cpu_x86_support_mca_broadcast(CPUX86State *env); =20 int cpu_get_pic_interrupt(CPUX86State *s); diff --git a/target/lm32/cpu.c b/target/lm32/cpu.c index b7499cb627..282da19994 100644 --- a/target/lm32/cpu.c +++ b/target/lm32/cpu.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" =20 @@ -34,27 +35,22 @@ static void lm32_cpu_set_pc(CPUState *cs, vaddr value) static void lm32_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; - CPUListState *s =3D user_data; const char *typename =3D object_class_get_name(oc); char *name; =20 name =3D g_strndup(typename, strlen(typename) - strlen(LM32_CPU_TYPE_S= UFFIX)); - (*s->cpu_fprintf)(s->file, " %s\n", name); + qemu_printf(" %s\n", name); g_free(name); } =20 =20 -void lm32_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void lm32_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list_sorted(TYPE_LM32_CPU, false); - (*cpu_fprintf)(f, "Available CPUs:\n"); - g_slist_foreach(list, lm32_cpu_list_entry, &s); + qemu_printf("Available CPUs:\n"); + g_slist_foreach(list, lm32_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h index 66157eefe9..b8d539ead8 100644 --- a/target/lm32/cpu.h +++ b/target/lm32/cpu.h @@ -243,7 +243,7 @@ static inline lm32_wp_t lm32_wp_type(uint32_t dc, int i= dx) is returned if the signal was handled by the virtual CPU. */ int cpu_lm32_signal_handler(int host_signum, void *pinfo, void *puc); -void lm32_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void lm32_cpu_list(void); void lm32_translate_init(void); void cpu_lm32_set_phys_msb_ignore(CPULM32State *env, int value); void QEMU_NORETURN raise_exception(CPULM32State *env, int index); diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index f154565117..9c1f0a2458 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -499,7 +499,7 @@ static inline int m68k_feature(CPUM68KState *env, int f= eature) return (env->features & (1u << feature)) !=3D 0; } =20 -void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void m68k_cpu_list(void); =20 void register_m68k_insns (CPUM68KState *env); =20 diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 3e26d337bf..bb64cf15c0 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -22,9 +22,9 @@ #include "cpu.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" - #include "exec/helper-proto.h" #include "fpu/softfloat.h" +#include "qemu/qemu-print.h" =20 #define SIGNBIT (1u << 31) =20 @@ -49,28 +49,22 @@ static gint m68k_cpu_list_compare(gconstpointer a, gcon= stpointer b) static void m68k_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *c =3D data; - CPUListState *s =3D user_data; const char *typename; char *name; =20 typename =3D object_class_get_name(c); name =3D g_strndup(typename, strlen(typename) - strlen("-" TYPE_M68K_C= PU)); - (*s->cpu_fprintf)(s->file, "%s\n", - name); + qemu_printf("%s\n", name); g_free(name); } =20 -void m68k_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void m68k_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list(TYPE_M68K_CPU, false); list =3D g_slist_sort(list, m68k_cpu_list_compare); - g_slist_foreach(list, m68k_cpu_list_entry, &s); + g_slist_foreach(list, m68k_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/mips/cpu.h b/target/mips/cpu.h index a10eeb0de3..1f41cf66d5 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1065,7 +1065,7 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState = *env) =20 #define ENV_OFFSET offsetof(MIPSCPU, env) =20 -void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf); +void mips_cpu_list(void); =20 #define cpu_signal_handler cpu_mips_signal_handler #define cpu_list mips_cpu_list diff --git a/target/mips/translate.c b/target/mips/translate.c index 364bd6dc4f..d886a0c9b2 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -38,6 +38,7 @@ #include "trace-tcg.h" #include "exec/translator.h" #include "exec/log.h" +#include "qemu/qemu-print.h" =20 #define MIPS_DEBUG_DISAS 0 =20 diff --git a/target/mips/translate_init.inc.c b/target/mips/translate_init.= inc.c index bf559aff08..1c2d017d36 100644 --- a/target/mips/translate_init.inc.c +++ b/target/mips/translate_init.inc.c @@ -835,13 +835,12 @@ const mips_def_t mips_defs[] =3D }; const int mips_defs_number =3D ARRAY_SIZE(mips_defs); =20 -void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf) +void mips_cpu_list(void) { int i; =20 for (i =3D 0; i < ARRAY_SIZE(mips_defs); i++) { - (*cpu_fprintf)(f, "MIPS '%s'\n", - mips_defs[i].name); + qemu_printf("MIPS '%s'\n", mips_defs[i].name); } } =20 diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index 541b2a66c7..d125236977 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -19,6 +19,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" =20 @@ -180,30 +181,24 @@ static gint openrisc_cpu_list_compare(gconstpointer a= , gconstpointer b) static void openrisc_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; - CPUListState *s =3D user_data; const char *typename; char *name; =20 typename =3D object_class_get_name(oc); name =3D g_strndup(typename, strlen(typename) - strlen("-" TYPE_OPENRISC_CPU)); - (*s->cpu_fprintf)(s->file, " %s\n", - name); + qemu_printf(" %s\n", name); g_free(name); } =20 -void cpu_openrisc_list(FILE *f, fprintf_function cpu_fprintf) +void cpu_openrisc_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list(TYPE_OPENRISC_CPU, false); list =3D g_slist_sort(list, openrisc_cpu_list_compare); - (*cpu_fprintf)(f, "Available CPUs:\n"); - g_slist_foreach(list, openrisc_cpu_list_entry, &s); + qemu_printf("Available CPUs:\n"); + g_slist_foreach(list, openrisc_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index f1b31bc24a..9d2d49631e 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -336,7 +336,7 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpen= RISCState *env) =20 #define ENV_OFFSET offsetof(OpenRISCCPU, env) =20 -void cpu_openrisc_list(FILE *f, fprintf_function cpu_fprintf); +void cpu_openrisc_list(void); void openrisc_cpu_do_interrupt(CPUState *cpu); bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req); void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 0707177584..382a323c61 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1308,7 +1308,7 @@ void ppc_store_ptcr(CPUPPCState *env, target_ulong va= lue); #endif /* !defined(CONFIG_USER_ONLY) */ void ppc_store_msr (CPUPPCState *env, target_ulong value); =20 -void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf); +void ppc_cpu_list(void); =20 /* Time-base and decrementer management */ #ifndef NO_CPU_IO_DEFS diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 0bd555eb19..996356dd99 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -28,6 +28,7 @@ #include "mmu-hash32.h" #include "mmu-hash64.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qapi/error.h" #include "qapi/qmp/qnull.h" #include "qapi/visitor.h" @@ -10215,7 +10216,6 @@ static gint ppc_cpu_list_compare(gconstpointer a, g= constpointer b) static void ppc_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; - CPUListState *s =3D user_data; PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); DeviceClass *family =3D DEVICE_CLASS(ppc_cpu_get_family_class(pcc)); const char *typename =3D object_class_get_name(oc); @@ -10228,8 +10228,7 @@ static void ppc_cpu_list_entry(gpointer data, gpoin= ter user_data) =20 name =3D g_strndup(typename, strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); - (*s->cpu_fprintf)(s->file, "PowerPC %-16s PVR %08x\n", - name, pcc->pvr); + qemu_printf("PowerPC %-16s PVR %08x\n", name, pcc->pvr); for (i =3D 0; ppc_cpu_aliases[i].alias !=3D NULL; i++) { PowerPCCPUAlias *alias =3D &ppc_cpu_aliases[i]; ObjectClass *alias_oc =3D ppc_cpu_class_by_name(alias->model); @@ -10242,33 +10241,28 @@ static void ppc_cpu_list_entry(gpointer data, gpo= inter user_data) * avoid printing the wrong alias here and use "preferred" instead */ if (strcmp(alias->alias, family->desc) =3D=3D 0) { - (*s->cpu_fprintf)(s->file, - "PowerPC %-16s (alias for preferred %s CPU)\= n", - alias->alias, family->desc); + qemu_printf("PowerPC %-16s (alias for preferred %s CPU)\n", + alias->alias, family->desc); } else { - (*s->cpu_fprintf)(s->file, "PowerPC %-16s (alias for %s)\n", - alias->alias, name); + qemu_printf("PowerPC %-16s (alias for %s)\n", + alias->alias, name); } } g_free(name); } =20 -void ppc_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void ppc_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list(TYPE_POWERPC_CPU, false); list =3D g_slist_sort(list, ppc_cpu_list_compare); - g_slist_foreach(list, ppc_cpu_list_entry, &s); + g_slist_foreach(list, ppc_cpu_list_entry, NULL); g_slist_free(list); =20 #ifdef CONFIG_KVM - cpu_fprintf(f, "\n"); - cpu_fprintf(f, "PowerPC %-16s\n", "host"); + qemu_printf("\n"); + qemu_printf("PowerPC %-16s\n", "host"); #endif } =20 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index d61bce6d55..104e676ab0 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/qemu-print.h" #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" @@ -383,11 +384,6 @@ char *riscv_isa_string(RISCVCPU *cpu) return isa_str; } =20 -typedef struct RISCVCPUListState { - fprintf_function cpu_fprintf; - FILE *file; -} RISCVCPUListState; - static gint riscv_cpu_list_compare(gconstpointer a, gconstpointer b) { ObjectClass *class_a =3D (ObjectClass *)a; @@ -401,24 +397,19 @@ static gint riscv_cpu_list_compare(gconstpointer a, g= constpointer b) =20 static void riscv_cpu_list_entry(gpointer data, gpointer user_data) { - RISCVCPUListState *s =3D user_data; const char *typename =3D object_class_get_name(OBJECT_CLASS(data)); int len =3D strlen(typename) - strlen(RISCV_CPU_TYPE_SUFFIX); =20 - (*s->cpu_fprintf)(s->file, "%.*s\n", len, typename); + qemu_printf("%.*s\n", len, typename); } =20 -void riscv_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void riscv_cpu_list(void) { - RISCVCPUListState s =3D { - .cpu_fprintf =3D cpu_fprintf, - .file =3D f, - }; GSList *list; =20 list =3D object_class_get_list(TYPE_RISCV_CPU, false); list =3D g_slist_sort(list, riscv_cpu_list_compare); - g_slist_foreach(list, riscv_cpu_list_entry, &s); + g_slist_foreach(list, riscv_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 20bce8742e..7d9f48973f 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -264,7 +264,7 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr= addr, int riscv_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, int mmu_idx); char *riscv_isa_string(RISCVCPU *cpu); -void riscv_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void riscv_cpu_list(void); =20 #define cpu_signal_handler riscv_cpu_signal_handler #define cpu_list riscv_cpu_list diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index cb6d77053a..d8990c405a 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -753,7 +753,7 @@ static inline uint8_t s390_cpu_get_state(S390CPU *cpu) =20 =20 /* cpu_models.c */ -void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void s390_cpu_list(void); #define cpu_list s390_cpu_list void s390_set_qemu_cpu_model(uint16_t type, uint8_t gen, uint8_t ec_ga, const S390FeatInit feat_init); diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index eb125d4d0d..e5afa15512 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -18,6 +18,7 @@ #include "qapi/error.h" #include "qapi/visitor.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qapi/qmp/qerror.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qmp/qdict.h" @@ -308,7 +309,6 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint= 8_t gen, uint8_t ec_ga, =20 static void s390_print_cpu_model_list_entry(gpointer data, gpointer user_d= ata) { - CPUListState *s =3D user_data; const S390CPUClass *scc =3D S390_CPU_CLASS((ObjectClass *)data); char *name =3D g_strdup(object_class_get_name((ObjectClass *)data)); const char *details =3D ""; @@ -321,8 +321,7 @@ static void s390_print_cpu_model_list_entry(gpointer da= ta, gpointer user_data) =20 /* strip off the -s390x-cpu */ g_strrstr(name, "-" TYPE_S390_CPU)[0] =3D 0; - (*s->cpu_fprintf)(s->file, "s390 %-15s %-35s %s\n", name, scc->desc, - details); + qemu_printf("s390 %-15s %-35s %s\n", name, scc->desc, details); g_free(name); } =20 @@ -360,33 +359,29 @@ static gint s390_cpu_list_compare(gconstpointer a, gc= onstpointer b) return cc_a->is_static ? -1 : 1; } =20 -void s390_cpu_list(FILE *f, fprintf_function print) +void s390_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D print, - }; S390FeatGroup group; S390Feat feat; GSList *list; =20 list =3D object_class_get_list(TYPE_S390_CPU, false); list =3D g_slist_sort(list, s390_cpu_list_compare); - g_slist_foreach(list, s390_print_cpu_model_list_entry, &s); + g_slist_foreach(list, s390_print_cpu_model_list_entry, NULL); g_slist_free(list); =20 - (*print)(f, "\nRecognized feature flags:\n"); + qemu_printf("\nRecognized feature flags:\n"); for (feat =3D 0; feat < S390_FEAT_MAX; feat++) { const S390FeatDef *def =3D s390_feat_def(feat); =20 - (*print)(f, "%-20s %-50s\n", def->name, def->desc); + qemu_printf("%-20s %-50s\n", def->name, def->desc); } =20 - (*print)(f, "\nRecognized feature groups:\n"); + qemu_printf("\nRecognized feature groups:\n"); for (group =3D 0; group < S390_FEAT_GROUP_MAX; group++) { const S390FeatGroupDef *def =3D s390_feat_group_def(group); =20 - (*print)(f, "%-20s %-50s\n", def->name, def->desc); + qemu_printf("%-20s %-50s\n", def->name, def->desc); } } =20 diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index b9f393b7c7..da2799082e 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -21,6 +21,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu-common.h" #include "migration/vmstate.h" @@ -79,30 +80,20 @@ static void superh_cpu_disas_set_info(CPUState *cpu, di= sassemble_info *info) info->print_insn =3D print_insn_sh; } =20 -typedef struct SuperHCPUListState { - fprintf_function cpu_fprintf; - FILE *file; -} SuperHCPUListState; - static void superh_cpu_list_entry(gpointer data, gpointer user_data) { - SuperHCPUListState *s =3D user_data; const char *typename =3D object_class_get_name(OBJECT_CLASS(data)); int len =3D strlen(typename) - strlen(SUPERH_CPU_TYPE_SUFFIX); =20 - (*s->cpu_fprintf)(s->file, "%.*s\n", len, typename); + qemu_printf("%.*s\n", len, typename); } =20 -void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void sh4_cpu_list(void) { - SuperHCPUListState s =3D { - .cpu_fprintf =3D cpu_fprintf, - .file =3D f, - }; GSList *list; =20 list =3D object_class_get_list_sorted(TYPE_SUPERH_CPU, false); - g_slist_foreach(list, superh_cpu_list_entry, &s); + g_slist_foreach(list, superh_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 775b5743bf..3e43f0a1a5 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -247,7 +247,7 @@ int cpu_sh4_signal_handler(int host_signum, void *pinfo, int superh_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, in= t rw, int mmu_idx); =20 -void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void sh4_cpu_list(void); #if !defined(CONFIG_USER_ONLY) void cpu_sh4_invalidate_tlb(CPUSH4State *s); uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s, diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 4a4445bdf5..fd88a31806 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "cpu.h" -#include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" #include "qapi/visitor.h" @@ -556,47 +556,44 @@ static const char * const feature_name[] =3D { "gl", }; =20 -static void print_features(FILE *f, fprintf_function cpu_fprintf, - uint32_t features, const char *prefix) +static void print_features(uint32_t features, const char *prefix) { unsigned int i; =20 for (i =3D 0; i < ARRAY_SIZE(feature_name); i++) { if (feature_name[i] && (features & (1 << i))) { if (prefix) { - (*cpu_fprintf)(f, "%s", prefix); + qemu_printf("%s", prefix); } - (*cpu_fprintf)(f, "%s ", feature_name[i]); + qemu_printf("%s ", feature_name[i]); } } } =20 -void sparc_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void sparc_cpu_list(void) { unsigned int i; =20 for (i =3D 0; i < ARRAY_SIZE(sparc_defs); i++) { - (*cpu_fprintf)(f, "Sparc %16s IU " TARGET_FMT_lx - " FPU %08x MMU %08x NWINS %d ", - sparc_defs[i].name, - sparc_defs[i].iu_version, - sparc_defs[i].fpu_version, - sparc_defs[i].mmu_version, - sparc_defs[i].nwindows); - print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES & - ~sparc_defs[i].features, "-"); - print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES & - sparc_defs[i].features, "+"); - (*cpu_fprintf)(f, "\n"); + qemu_printf("Sparc %16s IU " TARGET_FMT_lx + " FPU %08x MMU %08x NWINS %d ", + sparc_defs[i].name, + sparc_defs[i].iu_version, + sparc_defs[i].fpu_version, + sparc_defs[i].mmu_version, + sparc_defs[i].nwindows); + print_features(CPU_DEFAULT_FEATURES & ~sparc_defs[i].features, "-"= ); + print_features(~CPU_DEFAULT_FEATURES & sparc_defs[i].features, "+"= ); + qemu_printf("\n"); } - (*cpu_fprintf)(f, "Default CPU feature flags (use '-' to remove): "); - print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES, NULL); - (*cpu_fprintf)(f, "\n"); - (*cpu_fprintf)(f, "Available CPU feature flags (use '+' to add): "); - print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES, NULL); - (*cpu_fprintf)(f, "\n"); - (*cpu_fprintf)(f, "Numerical features (use '=3D' to set): iu_version " - "fpu_version mmu_version nwindows\n"); + qemu_printf("Default CPU feature flags (use '-' to remove): "); + print_features(CPU_DEFAULT_FEATURES, NULL); + qemu_printf("\n"); + qemu_printf("Available CPU feature flags (use '+' to add): "); + print_features(~CPU_DEFAULT_FEATURES, NULL); + qemu_printf("\n"); + qemu_printf("Numerical features (use '=3D' to set): iu_version " + "fpu_version mmu_version nwindows\n"); } =20 static void cpu_print_cc(FILE *f, fprintf_function cpu_fprintf, diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 4972ebcfd4..ab9fa3ddbf 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -578,7 +578,7 @@ void cpu_raise_exception_ra(CPUSPARCState *, int, uintp= tr_t) QEMU_NORETURN; #ifndef NO_CPU_IO_DEFS /* cpu_init.c */ void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu); -void sparc_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void sparc_cpu_list(void); /* mmu_helper.c */ int sparc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int= rw, int mmu_idx); diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 00e69dc154..43d577ce8e 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -375,7 +375,7 @@ void fpu_set_state(CPUTriCoreState *env); =20 #define MMU_USER_IDX 2 =20 -void tricore_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void tricore_cpu_list(void); =20 #define cpu_signal_handler cpu_tricore_signal_handler #define cpu_list tricore_cpu_list diff --git a/target/tricore/helper.c b/target/tricore/helper.c index 0769046993..78ee87c9ea 100644 --- a/target/tricore/helper.c +++ b/target/tricore/helper.c @@ -20,6 +20,7 @@ #include "cpu.h" #include "exec/exec-all.h" #include "fpu/softfloat.h" +#include "qemu/qemu-print.h" =20 enum { TLBRET_DIRTY =3D -4, @@ -82,28 +83,22 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_u= long address, static void tricore_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; - CPUListState *s =3D user_data; const char *typename; char *name; =20 typename =3D object_class_get_name(oc); name =3D g_strndup(typename, strlen(typename) - strlen("-" TYPE_TRICOR= E_CPU)); - (*s->cpu_fprintf)(s->file, " %s\n", - name); + qemu_printf(" %s\n", name); g_free(name); } =20 -void tricore_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void tricore_cpu_list(void) { - CPUListState s =3D { - .file =3D f, - .cpu_fprintf =3D cpu_fprintf, - }; GSList *list; =20 list =3D object_class_get_list_sorted(TYPE_TRICORE_CPU, false); - (*cpu_fprintf)(f, "Available CPUs:\n"); - g_slist_foreach(list, tricore_cpu_list_entry, &s); + qemu_printf("Available CPUs:\n"); + g_slist_foreach(list, tricore_cpu_list_entry, NULL); g_slist_free(list); } =20 diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 4d8152682f..4aaf1f7bb2 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -600,7 +600,7 @@ void xtensa_irq_init(CPUXtensaState *env); qemu_irq *xtensa_get_extints(CPUXtensaState *env); qemu_irq xtensa_get_runstall(CPUXtensaState *env); int cpu_xtensa_signal_handler(int host_signum, void *pinfo, void *puc); -void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf); +void xtensa_cpu_list(void); void xtensa_sync_window_from_phys(CPUXtensaState *env); void xtensa_sync_phys_from_window(CPUXtensaState *env); void xtensa_rotate_window(CPUXtensaState *env, uint32_t delta); diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index f4867a9b56..5f37f378a3 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -31,6 +31,7 @@ #include "exec/gdbstub.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "qemu/host-utils.h" =20 static struct XtensaConfigList *xtensa_cores; @@ -228,12 +229,12 @@ void xtensa_breakpoint_handler(CPUState *cs) } } =20 -void xtensa_cpu_list(FILE *f, fprintf_function cpu_fprintf) +void xtensa_cpu_list(void) { XtensaConfigList *core =3D xtensa_cores; - cpu_fprintf(f, "Available CPUs:\n"); + qemu_printf("Available CPUs:\n"); for (; core; core =3D core->next) { - cpu_fprintf(f, " %s\n", core->config->name); + qemu_printf(" %s\n", core->config->name); } } =20 diff --git a/vl.c b/vl.c index 190c773176..ff5dfb6fbc 100644 --- a/vl.c +++ b/vl.c @@ -4051,7 +4051,7 @@ int main(int argc, char **argv, char **envp) } =20 if (cpu_model && is_help_option(cpu_model)) { - list_cpus(stdout, &fprintf, cpu_model); + list_cpus(cpu_model); exit(0); } =20 --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622837; cv=none; d=zoho.com; s=zohoarc; b=NvpUKJFBElMmSvrDOY1kHJVFqwG8Go49K3LmG6BQcB9RRtL2N+utUo5U4X4IBSMXBNx2+y7XDHHjrkVmk0lVcvnNc9SAuIYUlejB0yN+09TxaHZmNlibNDr6IKHQsBvCneap+5ElfsYi2DJP1L0HxzG2T6xgAmsL5OJF8JCWlx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622837; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=q/52kXTDdwKttZT7LVAYLfnpZ14frI2q2T7R3aRm3/Y=; b=HQYrHwUyWvDaGVYypLGiQDNhJZ4EfmZu0hR1qRmTpbdGs5dxISND5jbFFK5768ZRW3nCZdAajW+PeN0NQ5Fy/0ZSTQVVGZxcJXe/9jqpDhI6BKOpFFmA2q6guYL11RCOObAiUDMCq8ktUuRnk3qU27fiwXCWTssgjYX8dCljaEE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622837827489.8951456268546; Thu, 18 Apr 2019 14:27:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:47670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEYr-0007gB-Mv for importer@patchew.org; Thu, 18 Apr 2019 17:27:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0m-0005Mc-GY for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:52:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0i-0005Ss-Tb for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:52:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58662) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0g-0005G0-UI for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A97FBC02490F for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D77AC5D707 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E7905110CFC5; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:28 +0200 Message-Id: <20190418205135.6686-30-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 18 Apr 2019 20:51:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 29/36] target: Clean up how the dump_mmu() print 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The various dump_mmu() take an fprintf()-like callback and a FILE * to pass to it, and so do their helper functions. Passing around callback and argument is rather tiresome. Most dump_mmu() are called only by the target's hmp_info_tlb(). These all pass monitor_printf() cast to fprintf_function and the current monitor cast to FILE *. SPARC's dump_mmu() gets also called from target/sparc/ldst_helper.c a few times #ifdef DEBUG_MMU. These calls pass fprintf() and stdout. The type-punning is technically undefined behaviour, but works in practice. Clean up: drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-11-armbru@redhat.com> --- target/m68k/cpu.h | 3 +- target/m68k/helper.c | 115 ++++++++++++++++++------------------- target/m68k/monitor.c | 2 +- target/nios2/cpu.h | 2 +- target/nios2/mmu.c | 7 ++- target/nios2/monitor.c | 2 +- target/ppc/cpu.h | 2 +- target/ppc/mmu-hash64.c | 7 ++- target/ppc/mmu-hash64.h | 2 +- target/ppc/mmu_helper.c | 70 +++++++++++----------- target/ppc/monitor.c | 2 +- target/sparc/cpu.h | 2 +- target/sparc/ldst_helper.c | 18 +++--- target/sparc/mmu_helper.c | 97 +++++++++++++++---------------- target/sparc/monitor.c | 2 +- target/xtensa/cpu.h | 2 +- target/xtensa/mmu_helper.c | 24 ++++---- target/xtensa/monitor.c | 2 +- 18 files changed, 178 insertions(+), 183 deletions(-) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 9c1f0a2458..73952f6ece 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -573,5 +573,6 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *e= nv, target_ulong *pc, } } =20 -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUM68KState *env); +void dump_mmu(CPUM68KState *env); + #endif diff --git a/target/m68k/helper.c b/target/m68k/helper.c index bb64cf15c0..d958a34959 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -369,30 +369,28 @@ int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr add= ress, int size, int rw, =20 /* MMU: 68040 only */ =20 -static void print_address_zone(FILE *f, fprintf_function cpu_fprintf, - uint32_t logical, uint32_t physical, +static void print_address_zone(uint32_t logical, uint32_t physical, uint32_t size, int attr) { - cpu_fprintf(f, "%08x - %08x -> %08x - %08x %c ", + qemu_printf("%08x - %08x -> %08x - %08x %c ", logical, logical + size - 1, physical, physical + size - 1, attr & 4 ? 'W' : '-'); size >>=3D 10; if (size < 1024) { - cpu_fprintf(f, "(%d KiB)\n", size); + qemu_printf("(%d KiB)\n", size); } else { size >>=3D 10; if (size < 1024) { - cpu_fprintf(f, "(%d MiB)\n", size); + qemu_printf("(%d MiB)\n", size); } else { size >>=3D 10; - cpu_fprintf(f, "(%d GiB)\n", size); + qemu_printf("(%d GiB)\n", size); } } } =20 -static void dump_address_map(FILE *f, fprintf_function cpu_fprintf, - CPUM68KState *env, uint32_t root_pointer) +static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) { int i, j, k; int tic_size, tic_shift; @@ -454,7 +452,7 @@ static void dump_address_map(FILE *f, fprintf_function = cpu_fprintf, if (first_logical !=3D 0xffffffff) { size =3D last_logical + (1 << tic_shift) - first_logical; - print_address_zone(f, cpu_fprintf, first_logical, + print_address_zone(first_logical, first_physical, size, last_attr= ); } first_logical =3D logical; @@ -465,126 +463,125 @@ static void dump_address_map(FILE *f, fprintf_funct= ion cpu_fprintf, } if (first_logical !=3D logical || (attr & 4) !=3D (last_attr & 4)) { size =3D logical + (1 << tic_shift) - first_logical; - print_address_zone(f, cpu_fprintf, first_logical, first_physical, = size, - last_attr); + print_address_zone(first_logical, first_physical, size, last_attr); } } =20 #define DUMP_CACHEFLAGS(a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU: /* cachable, write-through */ \ - cpu_fprintf(f, "T"); \ + qemu_printf("T"); \ break; \ case M68K_DESC_CM_COPYBK: /* cachable, copyback */ \ - cpu_fprintf(f, "C"); \ + qemu_printf("C"); \ break; \ case M68K_DESC_CM_SERIAL: /* noncachable, serialized */ \ - cpu_fprintf(f, "S"); \ + qemu_printf("S"); \ break; \ case M68K_DESC_CM_NCACHE: /* noncachable */ \ - cpu_fprintf(f, "N"); \ + qemu_printf("N"); \ break; \ } =20 -static void dump_ttr(FILE *f, fprintf_function cpu_fprintf, uint32_t ttr) +static void dump_ttr(uint32_t ttr) { if ((ttr & M68K_TTR_ENABLED) =3D=3D 0) { - cpu_fprintf(f, "disabled\n"); + qemu_printf("disabled\n"); return; } - cpu_fprintf(f, "Base: 0x%08x Mask: 0x%08x Control: ", + qemu_printf("Base: 0x%08x Mask: 0x%08x Control: ", ttr & M68K_TTR_ADDR_BASE, (ttr & M68K_TTR_ADDR_MASK) << M68K_TTR_ADDR_MASK_SHIFT); switch (ttr & M68K_TTR_SFIELD) { case M68K_TTR_SFIELD_USER: - cpu_fprintf(f, "U"); + qemu_printf("U"); break; case M68K_TTR_SFIELD_SUPER: - cpu_fprintf(f, "S"); + qemu_printf("S"); break; default: - cpu_fprintf(f, "*"); + qemu_printf("*"); break; } DUMP_CACHEFLAGS(ttr); if (ttr & M68K_DESC_WRITEPROT) { - cpu_fprintf(f, "R"); + qemu_printf("R"); } else { - cpu_fprintf(f, "W"); + qemu_printf("W"); } - cpu_fprintf(f, " U: %d\n", (ttr & M68K_DESC_USERATTR) >> + qemu_printf(" U: %d\n", (ttr & M68K_DESC_USERATTR) >> M68K_DESC_USERATTR_SHIFT); } =20 -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUM68KState *env) +void dump_mmu(CPUM68KState *env) { if ((env->mmu.tcr & M68K_TCR_ENABLED) =3D=3D 0) { - cpu_fprintf(f, "Translation disabled\n"); + qemu_printf("Translation disabled\n"); return; } - cpu_fprintf(f, "Page Size: "); + qemu_printf("Page Size: "); if (env->mmu.tcr & M68K_TCR_PAGE_8K) { - cpu_fprintf(f, "8kB\n"); + qemu_printf("8kB\n"); } else { - cpu_fprintf(f, "4kB\n"); + qemu_printf("4kB\n"); } =20 - cpu_fprintf(f, "MMUSR: "); + qemu_printf("MMUSR: "); if (env->mmu.mmusr & M68K_MMU_B_040) { - cpu_fprintf(f, "BUS ERROR\n"); + qemu_printf("BUS ERROR\n"); } else { - cpu_fprintf(f, "Phy=3D%08x Flags: ", env->mmu.mmusr & 0xfffff000); + qemu_printf("Phy=3D%08x Flags: ", env->mmu.mmusr & 0xfffff000); /* flags found on the page descriptor */ if (env->mmu.mmusr & M68K_MMU_G_040) { - cpu_fprintf(f, "G"); /* Global */ + qemu_printf("G"); /* Global */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_S_040) { - cpu_fprintf(f, "S"); /* Supervisor */ + qemu_printf("S"); /* Supervisor */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_M_040) { - cpu_fprintf(f, "M"); /* Modified */ + qemu_printf("M"); /* Modified */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_WP_040) { - cpu_fprintf(f, "W"); /* Write protect */ + qemu_printf("W"); /* Write protect */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_T_040) { - cpu_fprintf(f, "T"); /* Transparent */ + qemu_printf("T"); /* Transparent */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } if (env->mmu.mmusr & M68K_MMU_R_040) { - cpu_fprintf(f, "R"); /* Resident */ + qemu_printf("R"); /* Resident */ } else { - cpu_fprintf(f, "."); + qemu_printf("."); } - cpu_fprintf(f, " Cache: "); + qemu_printf(" Cache: "); DUMP_CACHEFLAGS(env->mmu.mmusr); - cpu_fprintf(f, " U: %d\n", (env->mmu.mmusr >> 8) & 3); - cpu_fprintf(f, "\n"); + qemu_printf(" U: %d\n", (env->mmu.mmusr >> 8) & 3); + qemu_printf("\n"); } =20 - cpu_fprintf(f, "ITTR0: "); - dump_ttr(f, cpu_fprintf, env->mmu.ttr[M68K_ITTR0]); - cpu_fprintf(f, "ITTR1: "); - dump_ttr(f, cpu_fprintf, env->mmu.ttr[M68K_ITTR1]); - cpu_fprintf(f, "DTTR0: "); - dump_ttr(f, cpu_fprintf, env->mmu.ttr[M68K_DTTR0]); - cpu_fprintf(f, "DTTR1: "); - dump_ttr(f, cpu_fprintf, env->mmu.ttr[M68K_DTTR1]); + qemu_printf("ITTR0: "); + dump_ttr(env->mmu.ttr[M68K_ITTR0]); + qemu_printf("ITTR1: "); + dump_ttr(env->mmu.ttr[M68K_ITTR1]); + qemu_printf("DTTR0: "); + dump_ttr(env->mmu.ttr[M68K_DTTR0]); + qemu_printf("DTTR1: "); + dump_ttr(env->mmu.ttr[M68K_DTTR1]); =20 - cpu_fprintf(f, "SRP: 0x%08x\n", env->mmu.srp); - dump_address_map(f, cpu_fprintf, env, env->mmu.srp); + qemu_printf("SRP: 0x%08x\n", env->mmu.srp); + dump_address_map(env, env->mmu.srp); =20 - cpu_fprintf(f, "URP: 0x%08x\n", env->mmu.urp); - dump_address_map(f, cpu_fprintf, env, env->mmu.urp); + qemu_printf("URP: 0x%08x\n", env->mmu.urp); + dump_address_map(env, env->mmu.urp); } =20 static int check_TTR(uint32_t ttr, int *prot, target_ulong addr, diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c index db582a34ac..2055fe8a00 100644 --- a/target/m68k/monitor.c +++ b/target/m68k/monitor.c @@ -19,7 +19,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) return; } =20 - dump_mmu((FILE *)mon, (fprintf_function)monitor_printf, env1); + dump_mmu(env1); } =20 static const MonitorDef monitor_defs[] =3D { diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 047f3764b7..6fa993bb0d 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -212,7 +212,7 @@ static inline Nios2CPU *nios2_env_get_cpu(CPUNios2State= *env) void nios2_tcg_init(void); void nios2_cpu_do_interrupt(CPUState *cs); int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc); -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUNios2State *env); +void dump_mmu(CPUNios2State *env); void nios2_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fpr= intf, int flags); hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 69b71cba4a..5acf442d8b 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/qemu-print.h" #include "cpu.h" #include "exec/exec-all.h" #include "mmu.h" @@ -264,18 +265,18 @@ void mmu_init(CPUNios2State *env) mmu->tlb =3D g_new0(Nios2TLBEntry, cpu->tlb_num_entries); } =20 -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUNios2State *env) +void dump_mmu(CPUNios2State *env) { Nios2CPU *cpu =3D nios2_env_get_cpu(env); int i; =20 - cpu_fprintf(f, "MMU: ways %d, entries %d, pid bits %d\n", + qemu_printf("MMU: ways %d, entries %d, pid bits %d\n", cpu->tlb_num_ways, cpu->tlb_num_entries, cpu->pid_num_bits); =20 for (i =3D 0; i < cpu->tlb_num_entries; i++) { Nios2TLBEntry *entry =3D &env->mmu.tlb[i]; - cpu_fprintf(f, "TLB[%d] =3D %08X %08X %c VPN %05X " + qemu_printf("TLB[%d] =3D %08X %08X %c VPN %05X " "PID %02X %c PFN %05X %c%c%c%c\n", i, entry->tag, entry->data, (entry->tag & (1 << 10)) ? 'V' : '-', diff --git a/target/nios2/monitor.c b/target/nios2/monitor.c index 422c81656a..d5e3393716 100644 --- a/target/nios2/monitor.c +++ b/target/nios2/monitor.c @@ -31,5 +31,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) { CPUArchState *env1 =3D mon_get_cpu_env(); =20 - dump_mmu((FILE *)mon, (fprintf_function)monitor_printf, env1); + dump_mmu(env1); } diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 382a323c61..8572241364 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -2629,7 +2629,7 @@ static inline ppc_avr_t *cpu_avr_ptr(CPUPPCState *env= , int i) return (ppc_avr_t *)((uintptr_t)env + avr_full_offset(i)); } =20 -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUPPCState *env); +void dump_mmu(CPUPPCState *env); =20 void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len); #endif /* PPC_CPU_H */ diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c index a2b1ec5040..214149f65b 100644 --- a/target/ppc/mmu-hash64.c +++ b/target/ppc/mmu-hash64.c @@ -22,6 +22,7 @@ #include "exec/exec-all.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/hw_accel.h" #include "kvm_ppc.h" #include "mmu-hash64.h" @@ -71,7 +72,7 @@ static ppc_slb_t *slb_lookup(PowerPCCPU *cpu, target_ulon= g eaddr) return NULL; } =20 -void dump_slb(FILE *f, fprintf_function cpu_fprintf, PowerPCCPU *cpu) +void dump_slb(PowerPCCPU *cpu) { CPUPPCState *env =3D &cpu->env; int i; @@ -79,14 +80,14 @@ void dump_slb(FILE *f, fprintf_function cpu_fprintf, Po= werPCCPU *cpu) =20 cpu_synchronize_state(CPU(cpu)); =20 - cpu_fprintf(f, "SLB\tESID\t\t\tVSID\n"); + qemu_printf("SLB\tESID\t\t\tVSID\n"); for (i =3D 0; i < cpu->hash64_opts->slb_size; i++) { slbe =3D env->slb[i].esid; slbv =3D env->slb[i].vsid; if (slbe =3D=3D 0 && slbv =3D=3D 0) { continue; } - cpu_fprintf(f, "%d\t0x%016" PRIx64 "\t0x%016" PRIx64 "\n", + qemu_printf("%d\t0x%016" PRIx64 "\t0x%016" PRIx64 "\n", i, slbe, slbv); } } diff --git a/target/ppc/mmu-hash64.h b/target/ppc/mmu-hash64.h index 6b555b7220..5be7ad86db 100644 --- a/target/ppc/mmu-hash64.h +++ b/target/ppc/mmu-hash64.h @@ -4,7 +4,7 @@ #ifndef CONFIG_USER_ONLY =20 #ifdef TARGET_PPC64 -void dump_slb(FILE *f, fprintf_function cpu_fprintf, PowerPCCPU *cpu); +void dump_slb(PowerPCCPU *cpu); int ppc_store_slb(PowerPCCPU *cpu, target_ulong slot, target_ulong esid, target_ulong vsid); hwaddr ppc_hash64_get_phys_page_debug(PowerPCCPU *cpu, target_ulong addr); diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index 4a6be4d63b..ab72473eeb 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -29,6 +29,7 @@ #include "exec/log.h" #include "helper_regs.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "mmu-book3s-v3.h" #include "mmu-radix64.h" =20 @@ -1116,19 +1117,18 @@ static const char *book3e_tsize_to_str[32] =3D { "1T", "2T" }; =20 -static void mmubooke_dump_mmu(FILE *f, fprintf_function cpu_fprintf, - CPUPPCState *env) +static void mmubooke_dump_mmu(CPUPPCState *env) { ppcemb_tlb_t *entry; int i; =20 if (kvm_enabled() && !env->kvm_sw_tlb) { - cpu_fprintf(f, "Cannot access KVM TLB\n"); + qemu_printf("Cannot access KVM TLB\n"); return; } =20 - cpu_fprintf(f, "\nTLB:\n"); - cpu_fprintf(f, "Effective Physical Size PID Prot = " + qemu_printf("\nTLB:\n"); + qemu_printf("Effective Physical Size PID Prot = " "Attr\n"); =20 entry =3D &env->tlb.tlbe[0]; @@ -1153,22 +1153,21 @@ static void mmubooke_dump_mmu(FILE *f, fprintf_func= tion cpu_fprintf, } else { snprintf(size_buf, sizeof(size_buf), "%3" PRId64 "k", size / K= iB); } - cpu_fprintf(f, "0x%016" PRIx64 " 0x%016" PRIx64 " %s %-5u %08x %08= x\n", + qemu_printf("0x%016" PRIx64 " 0x%016" PRIx64 " %s %-5u %08x %08x\n= ", (uint64_t)ea, (uint64_t)pa, size_buf, (uint32_t)entry-= >PID, entry->prot, entry->attr); } =20 } =20 -static void mmubooke206_dump_one_tlb(FILE *f, fprintf_function cpu_fprintf, - CPUPPCState *env, int tlbn, int offse= t, +static void mmubooke206_dump_one_tlb(CPUPPCState *env, int tlbn, int offse= t, int tlbsize) { ppcmas_tlb_t *entry; int i; =20 - cpu_fprintf(f, "\nTLB%d:\n", tlbn); - cpu_fprintf(f, "Effective Physical Size TID TS SR= WX" + qemu_printf("\nTLB%d:\n", tlbn); + qemu_printf("Effective Physical Size TID TS SRWX" " URWX WIMGE U0123\n"); =20 entry =3D &env->tlb.tlbm[offset]; @@ -1185,7 +1184,7 @@ static void mmubooke206_dump_one_tlb(FILE *f, fprintf= _function cpu_fprintf, ea =3D entry->mas2 & ~(size - 1); pa =3D entry->mas7_3 & ~(size - 1); =20 - cpu_fprintf(f, "0x%016" PRIx64 " 0x%016" PRIx64 " %4s %-5u %1u S%= c%c%c" + qemu_printf("0x%016" PRIx64 " 0x%016" PRIx64 " %4s %-5u %1u S%c%c= %c" "U%c%c%c %c%c%c%c%c U%c%c%c%c\n", (uint64_t)ea, (uint64_t)pa, book3e_tsize_to_str[tsize], @@ -1209,14 +1208,13 @@ static void mmubooke206_dump_one_tlb(FILE *f, fprin= tf_function cpu_fprintf, } } =20 -static void mmubooke206_dump_mmu(FILE *f, fprintf_function cpu_fprintf, - CPUPPCState *env) +static void mmubooke206_dump_mmu(CPUPPCState *env) { int offset =3D 0; int i; =20 if (kvm_enabled() && !env->kvm_sw_tlb) { - cpu_fprintf(f, "Cannot access KVM TLB\n"); + qemu_printf("Cannot access KVM TLB\n"); return; } =20 @@ -1227,13 +1225,12 @@ static void mmubooke206_dump_mmu(FILE *f, fprintf_f= unction cpu_fprintf, continue; } =20 - mmubooke206_dump_one_tlb(f, cpu_fprintf, env, i, offset, size); + mmubooke206_dump_one_tlb(env, i, offset, size); offset +=3D size; } } =20 -static void mmu6xx_dump_BATs(FILE *f, fprintf_function cpu_fprintf, - CPUPPCState *env, int type) +static void mmu6xx_dump_BATs(CPUPPCState *env, int type) { target_ulong *BATlt, *BATut, *BATu, *BATl; target_ulong BEPIl, BEPIu, bl; @@ -1256,7 +1253,7 @@ static void mmu6xx_dump_BATs(FILE *f, fprintf_functio= n cpu_fprintf, BEPIu =3D *BATu & 0xF0000000; BEPIl =3D *BATu & 0x0FFE0000; bl =3D (*BATu & 0x00001FFC) << 15; - cpu_fprintf(f, "%s BAT%d BATu " TARGET_FMT_lx + qemu_printf("%s BAT%d BATu " TARGET_FMT_lx " BATl " TARGET_FMT_lx "\n\t" TARGET_FMT_lx " " TARGET_FMT_lx " " TARGET_FMT_lx "\n", type =3D=3D ACCESS_CODE ? "code" : "data", i, @@ -1264,44 +1261,43 @@ static void mmu6xx_dump_BATs(FILE *f, fprintf_funct= ion cpu_fprintf, } } =20 -static void mmu6xx_dump_mmu(FILE *f, fprintf_function cpu_fprintf, - CPUPPCState *env) +static void mmu6xx_dump_mmu(CPUPPCState *env) { PowerPCCPU *cpu =3D ppc_env_get_cpu(env); ppc6xx_tlb_t *tlb; target_ulong sr; int type, way, entry, i; =20 - cpu_fprintf(f, "HTAB base =3D 0x%"HWADDR_PRIx"\n", ppc_hash32_hpt_base= (cpu)); - cpu_fprintf(f, "HTAB mask =3D 0x%"HWADDR_PRIx"\n", ppc_hash32_hpt_mask= (cpu)); + qemu_printf("HTAB base =3D 0x%"HWADDR_PRIx"\n", ppc_hash32_hpt_base(cp= u)); + qemu_printf("HTAB mask =3D 0x%"HWADDR_PRIx"\n", ppc_hash32_hpt_mask(cp= u)); =20 - cpu_fprintf(f, "\nSegment registers:\n"); + qemu_printf("\nSegment registers:\n"); for (i =3D 0; i < 32; i++) { sr =3D env->sr[i]; if (sr & 0x80000000) { - cpu_fprintf(f, "%02d T=3D%d Ks=3D%d Kp=3D%d BUID=3D0x%03x " + qemu_printf("%02d T=3D%d Ks=3D%d Kp=3D%d BUID=3D0x%03x " "CNTLR_SPEC=3D0x%05x\n", i, sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0, sr & 0x20000000 ? 1 : 0, (uint32_t)((sr >> 20) & 0= x1FF), (uint32_t)(sr & 0xFFFFF)); } else { - cpu_fprintf(f, "%02d T=3D%d Ks=3D%d Kp=3D%d N=3D%d VSID=3D0x%0= 6x\n", i, + qemu_printf("%02d T=3D%d Ks=3D%d Kp=3D%d N=3D%d VSID=3D0x%06x\= n", i, sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0, sr & 0x20000000 ? 1 : 0, sr & 0x10000000 ? 1 : 0, (uint32_t)(sr & 0x00FFFFFF)); } } =20 - cpu_fprintf(f, "\nBATs:\n"); - mmu6xx_dump_BATs(f, cpu_fprintf, env, ACCESS_INT); - mmu6xx_dump_BATs(f, cpu_fprintf, env, ACCESS_CODE); + qemu_printf("\nBATs:\n"); + mmu6xx_dump_BATs(env, ACCESS_INT); + mmu6xx_dump_BATs(env, ACCESS_CODE); =20 if (env->id_tlbs !=3D 1) { - cpu_fprintf(f, "ERROR: 6xx MMU should have separated TLB" + qemu_printf("ERROR: 6xx MMU should have separated TLB" " for code and data\n"); } =20 - cpu_fprintf(f, "\nTLBs [EPN EPN + SIZE]\n"); + qemu_printf("\nTLBs [EPN EPN + SIZE]\n"); =20 for (type =3D 0; type < 2; type++) { for (way =3D 0; way < env->nb_ways; way++) { @@ -1310,7 +1306,7 @@ static void mmu6xx_dump_mmu(FILE *f, fprintf_function= cpu_fprintf, entry++) { =20 tlb =3D &env->tlb.tlb6[entry]; - cpu_fprintf(f, "%s TLB %02d/%02d way:%d %s [" + qemu_printf("%s TLB %02d/%02d way:%d %s [" TARGET_FMT_lx " " TARGET_FMT_lx "]\n", type ? "code" : "data", entry % env->nb_tlb, env->nb_tlb, way, @@ -1321,31 +1317,31 @@ static void mmu6xx_dump_mmu(FILE *f, fprintf_functi= on cpu_fprintf, } } =20 -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUPPCState *env) +void dump_mmu(CPUPPCState *env) { switch (env->mmu_model) { case POWERPC_MMU_BOOKE: - mmubooke_dump_mmu(f, cpu_fprintf, env); + mmubooke_dump_mmu(env); break; case POWERPC_MMU_BOOKE206: - mmubooke206_dump_mmu(f, cpu_fprintf, env); + mmubooke206_dump_mmu(env); break; case POWERPC_MMU_SOFT_6xx: case POWERPC_MMU_SOFT_74xx: - mmu6xx_dump_mmu(f, cpu_fprintf, env); + mmu6xx_dump_mmu(env); break; #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_2_03: case POWERPC_MMU_2_06: case POWERPC_MMU_2_07: - dump_slb(f, cpu_fprintf, ppc_env_get_cpu(env)); + dump_slb(ppc_env_get_cpu(env)); break; case POWERPC_MMU_3_00: if (ppc64_v3_radix(ppc_env_get_cpu(env))) { /* TODO - Unsupported */ } else { - dump_slb(f, cpu_fprintf, ppc_env_get_cpu(env)); + dump_slb(ppc_env_get_cpu(env)); break; } #endif diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c index 04deec8030..42e58163fc 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/monitor.c @@ -66,7 +66,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1); + dump_mmu(env1); } =20 const MonitorDef monitor_defs[] =3D { diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index ab9fa3ddbf..b298bd9c29 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -583,7 +583,7 @@ void sparc_cpu_list(void); int sparc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int= rw, int mmu_idx); target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmule= v); -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env); +void dump_mmu(CPUSPARCState *env); =20 #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr, diff --git a/target/sparc/ldst_helper.c b/target/sparc/ldst_helper.c index 5bc090213c..a7fcb84ac0 100644 --- a/target/sparc/ldst_helper.c +++ b/target/sparc/ldst_helper.c @@ -198,7 +198,7 @@ static void demap_tlb(SparcTLBEntry *tlb, target_ulong = demap_addr, replace_tlb_entry(&tlb[i], 0, 0, env1); #ifdef DEBUG_MMU DPRINTF_MMU("%s demap invalidated entry [%02u]\n", strmmu, i); - dump_mmu(stdout, fprintf, env1); + dump_mmu(env1); #endif } } @@ -260,7 +260,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb, replace_tlb_entry(&tlb[i], tlb_tag, tlb_tte, env1); #ifdef DEBUG_MMU DPRINTF_MMU("%s lru replaced invalid entry [%i]\n", strmmu, i); - dump_mmu(stdout, fprintf, env1); + dump_mmu(env1); #endif return; } @@ -279,7 +279,7 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb, #ifdef DEBUG_MMU DPRINTF_MMU("%s lru replaced unlocked %s entry [%i]\n", strmmu, (replace_used ? "used" : "unused"), i); - dump_mmu(stdout, fprintf, env1); + dump_mmu(env1); #endif return; } @@ -886,7 +886,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong add= r, uint64_t val, break; } #ifdef DEBUG_MMU - dump_mmu(stdout, fprintf, env); + dump_mmu(env); #endif } break; @@ -941,7 +941,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong add= r, uint64_t val, reg, oldreg, env->mmuregs[reg]); } #ifdef DEBUG_MMU - dump_mmu(stdout, fprintf, env); + dump_mmu(env); #endif } break; @@ -1634,7 +1634,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong a= ddr, target_ulong val, PRIx64 "\n", reg, oldreg, env->immuregs[reg]); } #ifdef DEBUG_MMU - dump_mmu(stdout, fprintf, env); + dump_mmu(env); #endif return; } @@ -1658,7 +1658,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong a= ddr, target_ulong val, } #ifdef DEBUG_MMU DPRINTF_MMU("immu data access replaced entry [%i]\n", i); - dump_mmu(stdout, fprintf, env); + dump_mmu(env); #endif return; } @@ -1718,7 +1718,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong a= ddr, target_ulong val, PRIx64 "\n", reg, oldreg, env->dmmuregs[reg]); } #ifdef DEBUG_MMU - dump_mmu(stdout, fprintf, env); + dump_mmu(env); #endif return; } @@ -1740,7 +1740,7 @@ void helper_st_asi(CPUSPARCState *env, target_ulong a= ddr, target_ulong val, } #ifdef DEBUG_MMU DPRINTF_MMU("dmmu data access replaced entry [%i]\n", i); - dump_mmu(stdout, fprintf, env); + dump_mmu(env); #endif return; } diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index 135a9c9d9b..afcc5b617d 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "qemu/qemu-print.h" #include "trace.h" =20 /* Sparc MMU emulation */ @@ -320,7 +321,7 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong= address, int mmulev) return 0; } =20 -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env) +void dump_mmu(CPUSPARCState *env) { CPUState *cs =3D CPU(sparc_env_get_cpu(env)); target_ulong va, va1, va2; @@ -330,29 +331,29 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, = CPUSPARCState *env) =20 pde_ptr =3D (env->mmuregs[1] << 4) + (env->mmuregs[2] << 2); pde =3D ldl_phys(cs->as, pde_ptr); - (*cpu_fprintf)(f, "Root ptr: " TARGET_FMT_plx ", ctx: %d\n", - (hwaddr)env->mmuregs[1] << 4, env->mmuregs[2]); + qemu_printf("Root ptr: " TARGET_FMT_plx ", ctx: %d\n", + (hwaddr)env->mmuregs[1] << 4, env->mmuregs[2]); for (n =3D 0, va =3D 0; n < 256; n++, va +=3D 16 * 1024 * 1024) { pde =3D mmu_probe(env, va, 2); if (pde) { pa =3D cpu_get_phys_page_debug(cs, va); - (*cpu_fprintf)(f, "VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_plx - " PDE: " TARGET_FMT_lx "\n", va, pa, pde); + qemu_printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_plx + " PDE: " TARGET_FMT_lx "\n", va, pa, pde); for (m =3D 0, va1 =3D va; m < 64; m++, va1 +=3D 256 * 1024) { pde =3D mmu_probe(env, va1, 1); if (pde) { pa =3D cpu_get_phys_page_debug(cs, va1); - (*cpu_fprintf)(f, " VA: " TARGET_FMT_lx ", PA: " - TARGET_FMT_plx " PDE: " TARGET_FMT_lx "= \n", - va1, pa, pde); + qemu_printf(" VA: " TARGET_FMT_lx ", PA: " + TARGET_FMT_plx " PDE: " TARGET_FMT_lx "\n", + va1, pa, pde); for (o =3D 0, va2 =3D va1; o < 64; o++, va2 +=3D 4 * 1= 024) { pde =3D mmu_probe(env, va2, 0); if (pde) { pa =3D cpu_get_phys_page_debug(cs, va2); - (*cpu_fprintf)(f, " VA: " TARGET_FMT_lx ", PA= : " - TARGET_FMT_plx " PTE: " - TARGET_FMT_lx "\n", - va2, pa, pde); + qemu_printf(" VA: " TARGET_FMT_lx ", PA: " + TARGET_FMT_plx " PTE: " + TARGET_FMT_lx "\n", + va2, pa, pde); } } } @@ -739,21 +740,21 @@ int sparc_cpu_handle_mmu_fault(CPUState *cs, vaddr ad= dress, int size, int rw, return 1; } =20 -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUSPARCState *env) +void dump_mmu(CPUSPARCState *env) { unsigned int i; const char *mask; =20 - (*cpu_fprintf)(f, "MMU contexts: Primary: %" PRId64 ", Secondary: %" - PRId64 "\n", - env->dmmu.mmu_primary_context, - env->dmmu.mmu_secondary_context); - (*cpu_fprintf)(f, "DMMU Tag Access: %" PRIx64 ", TSB Tag Target: %" PR= Ix64 - "\n", env->dmmu.tag_access, env->dmmu.tsb_tag_target); + qemu_printf("MMU contexts: Primary: %" PRId64 ", Secondary: %" + PRId64 "\n", + env->dmmu.mmu_primary_context, + env->dmmu.mmu_secondary_context); + qemu_printf("DMMU Tag Access: %" PRIx64 ", TSB Tag Target: %" PRIx64 + "\n", env->dmmu.tag_access, env->dmmu.tsb_tag_target); if ((env->lsu & DMMU_E) =3D=3D 0) { - (*cpu_fprintf)(f, "DMMU disabled\n"); + qemu_printf("DMMU disabled\n"); } else { - (*cpu_fprintf)(f, "DMMU dump\n"); + qemu_printf("DMMU dump\n"); for (i =3D 0; i < 64; i++) { switch (TTE_PGSIZE(env->dtlb[i].tte)) { default: @@ -771,26 +772,26 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, = CPUSPARCState *env) break; } if (TTE_IS_VALID(env->dtlb[i].tte)) { - (*cpu_fprintf)(f, "[%02u] VA: %" PRIx64 ", PA: %llx" - ", %s, %s, %s, %s, ctx %" PRId64 " %s\n", - i, - env->dtlb[i].tag & (uint64_t)~0x1fffULL, - TTE_PA(env->dtlb[i].tte), - mask, - TTE_IS_PRIV(env->dtlb[i].tte) ? "priv" : "u= ser", - TTE_IS_W_OK(env->dtlb[i].tte) ? "RW" : "RO", - TTE_IS_LOCKED(env->dtlb[i].tte) ? - "locked" : "unlocked", - env->dtlb[i].tag & (uint64_t)0x1fffULL, - TTE_IS_GLOBAL(env->dtlb[i].tte) ? - "global" : "local"); + qemu_printf("[%02u] VA: %" PRIx64 ", PA: %llx" + ", %s, %s, %s, %s, ctx %" PRId64 " %s\n", + i, + env->dtlb[i].tag & (uint64_t)~0x1fffULL, + TTE_PA(env->dtlb[i].tte), + mask, + TTE_IS_PRIV(env->dtlb[i].tte) ? "priv" : "user= ", + TTE_IS_W_OK(env->dtlb[i].tte) ? "RW" : "RO", + TTE_IS_LOCKED(env->dtlb[i].tte) ? + "locked" : "unlocked", + env->dtlb[i].tag & (uint64_t)0x1fffULL, + TTE_IS_GLOBAL(env->dtlb[i].tte) ? + "global" : "local"); } } } if ((env->lsu & IMMU_E) =3D=3D 0) { - (*cpu_fprintf)(f, "IMMU disabled\n"); + qemu_printf("IMMU disabled\n"); } else { - (*cpu_fprintf)(f, "IMMU dump\n"); + qemu_printf("IMMU dump\n"); for (i =3D 0; i < 64; i++) { switch (TTE_PGSIZE(env->itlb[i].tte)) { default: @@ -808,18 +809,18 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, = CPUSPARCState *env) break; } if (TTE_IS_VALID(env->itlb[i].tte)) { - (*cpu_fprintf)(f, "[%02u] VA: %" PRIx64 ", PA: %llx" - ", %s, %s, %s, ctx %" PRId64 " %s\n", - i, - env->itlb[i].tag & (uint64_t)~0x1fffULL, - TTE_PA(env->itlb[i].tte), - mask, - TTE_IS_PRIV(env->itlb[i].tte) ? "priv" : "u= ser", - TTE_IS_LOCKED(env->itlb[i].tte) ? - "locked" : "unlocked", - env->itlb[i].tag & (uint64_t)0x1fffULL, - TTE_IS_GLOBAL(env->itlb[i].tte) ? - "global" : "local"); + qemu_printf("[%02u] VA: %" PRIx64 ", PA: %llx" + ", %s, %s, %s, ctx %" PRId64 " %s\n", + i, + env->itlb[i].tag & (uint64_t)~0x1fffULL, + TTE_PA(env->itlb[i].tte), + mask, + TTE_IS_PRIV(env->itlb[i].tte) ? "priv" : "user= ", + TTE_IS_LOCKED(env->itlb[i].tte) ? + "locked" : "unlocked", + env->itlb[i].tag & (uint64_t)0x1fffULL, + TTE_IS_GLOBAL(env->itlb[i].tte) ? + "global" : "local"); } } } diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c index f3ca524ae9..3ec3b51a3d 100644 --- a/target/sparc/monitor.c +++ b/target/sparc/monitor.c @@ -36,7 +36,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1); + dump_mmu(env1); } =20 #ifndef TARGET_SPARC64 diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 4aaf1f7bb2..86f6d6d72c 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -673,7 +673,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool = update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access); void reset_mmu(CPUXtensaState *env); -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUXtensaState *env); +void dump_mmu(CPUXtensaState *env); =20 static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env) { diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index 2096fbbd9f..79a10da231 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -27,6 +27,7 @@ =20 #include "qemu/osdep.h" #include "qemu/main-loop.h" +#include "qemu/qemu-print.h" #include "qemu/units.h" #include "cpu.h" #include "exec/helper-proto.h" @@ -740,8 +741,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool = update_tlb, } } =20 -static void dump_tlb(FILE *f, fprintf_function cpu_fprintf, - CPUXtensaState *env, bool dtlb) +static void dump_tlb(CPUXtensaState *env, bool dtlb) { unsigned wi, ei; const xtensa_tlb *conf =3D @@ -780,13 +780,11 @@ static void dump_tlb(FILE *f, fprintf_function cpu_fp= rintf, =20 if (print_header) { print_header =3D false; - cpu_fprintf(f, "Way %u (%d %s)\n", wi, sz, sz_text); - cpu_fprintf(f, - "\tVaddr Paddr ASID Attr RWX = Cache\n" + qemu_printf("Way %u (%d %s)\n", wi, sz, sz_text); + qemu_printf("\tVaddr Paddr ASID Attr RWX = Cache\n" "\t---------- ---------- ---- ---- --- = -------\n"); } - cpu_fprintf(f, - "\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %-7s\= n", + qemu_printf("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %-7s\= n", entry->vaddr, entry->paddr, entry->asid, @@ -801,18 +799,18 @@ static void dump_tlb(FILE *f, fprintf_function cpu_fp= rintf, } } =20 -void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUXtensaState *env) +void dump_mmu(CPUXtensaState *env) { if (xtensa_option_bits_enabled(env->config, XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION) | XTENSA_OPTION_BIT(XTENSA_OPTION_MMU))) { =20 - cpu_fprintf(f, "ITLB:\n"); - dump_tlb(f, cpu_fprintf, env, false); - cpu_fprintf(f, "\nDTLB:\n"); - dump_tlb(f, cpu_fprintf, env, true); + qemu_printf("ITLB:\n"); + dump_tlb(env, false); + qemu_printf("\nDTLB:\n"); + dump_tlb(env, true); } else { - cpu_fprintf(f, "No TLB for this CPU core\n"); + qemu_printf("No TLB for this CPU core\n"); } } diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c index 2ee2b5b23e..cf7957bb63 100644 --- a/target/xtensa/monitor.c +++ b/target/xtensa/monitor.c @@ -35,5 +35,5 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict) monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu((FILE*)mon, (fprintf_function)monitor_printf, env1); + dump_mmu(env1); } --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621590; cv=none; d=zoho.com; s=zohoarc; b=Qem6d+6879js4rHttWIc8SHxjxtJd70n0ZtYLjWH4I14EEQlj/2Bg1st/RMK3kWlyw556H2XoRA8Ku+9oiCDItZ2/hT+yS+vqSaWvfzC0ITxrubBz7EtfSwOEUqAueB4InZpkd063J2CYKfZTnak9nED4SG0WKah+iZtdpUJZ6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621590; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bgnAQOP2jr2zdK/sh3kIyvg8syNqKg0D/O4DchvwxaU=; b=JB1QkQDyiIoe2MlykIgO6Wr+9ASeX+H3IM8/SqLEC86rrvCY7DkHOwsR1izQfiEo2LERkmMePzscxOzSIO6VRvGbP/LtG6ud3cghDzRnGOuGuNKx1ZMlykgpRk4V6lJCZ682djYLPRxVErM5NNcbBnR+UPD3e/OVjJecqxuqGRU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621590925564.598182901558; Thu, 18 Apr 2019 14:06:30 -0700 (PDT) Received: from localhost ([127.0.0.1]:47323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEEe-00081u-8U for importer@patchew.org; Thu, 18 Apr 2019 17:06:20 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CC-2m for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005Hg-M0 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47998) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005FG-4w for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42BB4D7813 for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE6EB60BE5 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EE55D110CFCD; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:29 +0200 Message-Id: <20190418205135.6686-31-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 18 Apr 2019 20:51:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 30/36] target/i386: Simplify how x86_cpu_dump_local_apic_state() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" x86_cpu_dump_local_apic_state() takes an fprintf()-like callback and a FILE * to pass to it, and so do its helper functions. Its only caller hmp_info_local_apic() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-12-armbru@redhat.com> --- target/i386/cpu.h | 3 +- target/i386/helper.c | 79 ++++++++++++++++++++----------------------- target/i386/monitor.c | 3 +- 3 files changed, 39 insertions(+), 46 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index b39327dcb7..139fe30960 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1924,8 +1924,7 @@ void enable_compat_apic_id_mode(void); #define APIC_DEFAULT_ADDRESS 0xfee00000 #define APIC_SPACE_SIZE 0x100000 =20 -void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags= ); +void x86_cpu_dump_local_apic_state(CPUState *cs, int flags); =20 /* cpu.c */ bool cpu_is_bsp(X86CPU *cpu); diff --git a/target/i386/helper.c b/target/i386/helper.c index e695f8ba7a..565391a9f6 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "qemu/qemu-print.h" #include "sysemu/kvm.h" #include "kvm_i386.h" #ifndef CONFIG_USER_ONLY @@ -231,12 +232,10 @@ static inline const char *dm2str(uint32_t dm) return str[dm]; } =20 -static void dump_apic_lvt(FILE *f, fprintf_function cpu_fprintf, - const char *name, uint32_t lvt, bool is_timer) +static void dump_apic_lvt(const char *name, uint32_t lvt, bool is_timer) { uint32_t dm =3D (lvt & APIC_LVT_DELIV_MOD) >> APIC_LVT_DELIV_MOD_SHIFT; - cpu_fprintf(f, - "%s\t 0x%08x %s %-5s %-6s %-7s %-12s %-6s", + qemu_printf("%s\t 0x%08x %s %-5s %-6s %-7s %-12s %-6s", name, lvt, lvt & APIC_LVT_INT_POLARITY ? "active-lo" : "active-hi", lvt & APIC_LVT_LEVEL_TRIGGER ? "level" : "edge", @@ -248,9 +247,9 @@ static void dump_apic_lvt(FILE *f, fprintf_function cpu= _fprintf, "tsc-deadline" : "one-shot", dm2str(dm)); if (dm !=3D APIC_DM_NMI) { - cpu_fprintf(f, " (vec %u)\n", lvt & APIC_VECTOR_MASK); + qemu_printf(" (vec %u)\n", lvt & APIC_VECTOR_MASK); } else { - cpu_fprintf(f, "\n"); + qemu_printf("\n"); } } =20 @@ -282,8 +281,7 @@ static inline void mask2str(char *str, uint32_t val, ui= nt8_t size) =20 #define MAX_LOGICAL_APIC_ID_MASK_SIZE 16 =20 -static void dump_apic_icr(FILE *f, fprintf_function cpu_fprintf, - APICCommonState *s, CPUX86State *env) +static void dump_apic_icr(APICCommonState *s, CPUX86State *env) { uint32_t icr =3D s->icr[0], icr2 =3D s->icr[1]; uint8_t dest_shorthand =3D \ @@ -293,16 +291,16 @@ static void dump_apic_icr(FILE *f, fprintf_function c= pu_fprintf, uint32_t dest_field; bool x2apic; =20 - cpu_fprintf(f, "ICR\t 0x%08x %s %s %s %s\n", + qemu_printf("ICR\t 0x%08x %s %s %s %s\n", icr, logical_mod ? "logical" : "physical", icr & APIC_ICR_TRIGGER_MOD ? "level" : "edge", icr & APIC_ICR_LEVEL ? "assert" : "de-assert", shorthand2str(dest_shorthand)); =20 - cpu_fprintf(f, "ICR2\t 0x%08x", icr2); + qemu_printf("ICR2\t 0x%08x", icr2); if (dest_shorthand !=3D 0) { - cpu_fprintf(f, "\n"); + qemu_printf("\n"); return; } x2apic =3D env->features[FEAT_1_ECX] & CPUID_EXT_X2APIC; @@ -310,9 +308,9 @@ static void dump_apic_icr(FILE *f, fprintf_function cpu= _fprintf, =20 if (!logical_mod) { if (x2apic) { - cpu_fprintf(f, " cpu %u (X2APIC ID)\n", dest_field); + qemu_printf(" cpu %u (X2APIC ID)\n", dest_field); } else { - cpu_fprintf(f, " cpu %u (APIC ID)\n", + qemu_printf(" cpu %u (APIC ID)\n", dest_field & APIC_LOGDEST_XAPIC_ID); } return; @@ -320,87 +318,84 @@ static void dump_apic_icr(FILE *f, fprintf_function c= pu_fprintf, =20 if (s->dest_mode =3D=3D 0xf) { /* flat mode */ mask2str(apic_id_str, icr2 >> APIC_ICR_DEST_SHIFT, 8); - cpu_fprintf(f, " mask %s (APIC ID)\n", apic_id_str); + qemu_printf(" mask %s (APIC ID)\n", apic_id_str); } else if (s->dest_mode =3D=3D 0) { /* cluster mode */ if (x2apic) { mask2str(apic_id_str, dest_field & APIC_LOGDEST_X2APIC_ID, 16); - cpu_fprintf(f, " cluster %u mask %s (X2APIC ID)\n", + qemu_printf(" cluster %u mask %s (X2APIC ID)\n", dest_field >> APIC_LOGDEST_X2APIC_SHIFT, apic_id_s= tr); } else { mask2str(apic_id_str, dest_field & APIC_LOGDEST_XAPIC_ID, 4); - cpu_fprintf(f, " cluster %u mask %s (APIC ID)\n", + qemu_printf(" cluster %u mask %s (APIC ID)\n", dest_field >> APIC_LOGDEST_XAPIC_SHIFT, apic_id_st= r); } } } =20 -static void dump_apic_interrupt(FILE *f, fprintf_function cpu_fprintf, - const char *name, uint32_t *ireg_tab, +static void dump_apic_interrupt(const char *name, uint32_t *ireg_tab, uint32_t *tmr_tab) { int i, empty =3D true; =20 - cpu_fprintf(f, "%s\t ", name); + qemu_printf("%s\t ", name); for (i =3D 0; i < 256; i++) { if (apic_get_bit(ireg_tab, i)) { - cpu_fprintf(f, "%u%s ", i, + qemu_printf("%u%s ", i, apic_get_bit(tmr_tab, i) ? "(level)" : ""); empty =3D false; } } - cpu_fprintf(f, "%s\n", empty ? "(none)" : ""); + qemu_printf("%s\n", empty ? "(none)" : ""); } =20 -void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +void x86_cpu_dump_local_apic_state(CPUState *cs, int flags) { X86CPU *cpu =3D X86_CPU(cs); APICCommonState *s =3D APIC_COMMON(cpu->apic_state); if (!s) { - cpu_fprintf(f, "local apic state not available\n"); + qemu_printf("local apic state not available\n"); return; } uint32_t *lvt =3D s->lvt; =20 - cpu_fprintf(f, "dumping local APIC state for CPU %-2u\n\n", + qemu_printf("dumping local APIC state for CPU %-2u\n\n", CPU(cpu)->cpu_index); - dump_apic_lvt(f, cpu_fprintf, "LVT0", lvt[APIC_LVT_LINT0], false); - dump_apic_lvt(f, cpu_fprintf, "LVT1", lvt[APIC_LVT_LINT1], false); - dump_apic_lvt(f, cpu_fprintf, "LVTPC", lvt[APIC_LVT_PERFORM], false); - dump_apic_lvt(f, cpu_fprintf, "LVTERR", lvt[APIC_LVT_ERROR], false); - dump_apic_lvt(f, cpu_fprintf, "LVTTHMR", lvt[APIC_LVT_THERMAL], false); - dump_apic_lvt(f, cpu_fprintf, "LVTT", lvt[APIC_LVT_TIMER], true); + dump_apic_lvt("LVT0", lvt[APIC_LVT_LINT0], false); + dump_apic_lvt("LVT1", lvt[APIC_LVT_LINT1], false); + dump_apic_lvt("LVTPC", lvt[APIC_LVT_PERFORM], false); + dump_apic_lvt("LVTERR", lvt[APIC_LVT_ERROR], false); + dump_apic_lvt("LVTTHMR", lvt[APIC_LVT_THERMAL], false); + dump_apic_lvt("LVTT", lvt[APIC_LVT_TIMER], true); =20 - cpu_fprintf(f, "Timer\t DCR=3D0x%x (divide by %u) initial_count =3D %u= \n", + qemu_printf("Timer\t DCR=3D0x%x (divide by %u) initial_count =3D %u\n", s->divide_conf & APIC_DCR_MASK, divider_conf(s->divide_conf), s->initial_count); =20 - cpu_fprintf(f, "SPIV\t 0x%08x APIC %s, focus=3D%s, spurious vec %u\n", + qemu_printf("SPIV\t 0x%08x APIC %s, focus=3D%s, spurious vec %u\n", s->spurious_vec, s->spurious_vec & APIC_SPURIO_ENABLED ? "enabled" : "disab= led", s->spurious_vec & APIC_SPURIO_FOCUS ? "on" : "off", s->spurious_vec & APIC_VECTOR_MASK); =20 - dump_apic_icr(f, cpu_fprintf, s, &cpu->env); + dump_apic_icr(s, &cpu->env); =20 - cpu_fprintf(f, "ESR\t 0x%08x\n", s->esr); + qemu_printf("ESR\t 0x%08x\n", s->esr); =20 - dump_apic_interrupt(f, cpu_fprintf, "ISR", s->isr, s->tmr); - dump_apic_interrupt(f, cpu_fprintf, "IRR", s->irr, s->tmr); + dump_apic_interrupt("ISR", s->isr, s->tmr); + dump_apic_interrupt("IRR", s->irr, s->tmr); =20 - cpu_fprintf(f, "\nAPR 0x%02x TPR 0x%02x DFR 0x%02x LDR 0x%02x", + qemu_printf("\nAPR 0x%02x TPR 0x%02x DFR 0x%02x LDR 0x%02x", s->arb_id, s->tpr, s->dest_mode, s->log_dest); if (s->dest_mode =3D=3D 0) { - cpu_fprintf(f, "(cluster %u: id %u)", + qemu_printf("(cluster %u: id %u)", s->log_dest >> APIC_LOGDEST_XAPIC_SHIFT, s->log_dest & APIC_LOGDEST_XAPIC_ID); } - cpu_fprintf(f, " PPR 0x%02x\n", apic_get_ppr(s)); + qemu_printf(" PPR 0x%02x\n", apic_get_ppr(s)); } #else -void x86_cpu_dump_local_apic_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +void x86_cpu_dump_local_apic_state(CPUState *cs, int flags) { } #endif /* !CONFIG_USER_ONLY */ diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 74a13c571b..56e2dbece7 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -664,8 +664,7 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qdi= ct) monitor_printf(mon, "No CPU available\n"); return; } - x86_cpu_dump_local_apic_state(cs, (FILE *)mon, monitor_fprintf, - CPU_DUMP_FPU); + x86_cpu_dump_local_apic_state(cs, CPU_DUMP_FPU); } =20 void hmp_info_io_apic(Monitor *mon, const QDict *qdict) --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622646; cv=none; d=zoho.com; s=zohoarc; b=EUDpurLzY2PI1ciO8yhi+veC2/qejfoUngHW/lK3rBXPv4l8ixX5VDD+St59pUIrGj+/fS6+bHoBMe9SfdS8qfup7Sz/sM9j3f2TqridYxpRpRfkkaZ2eEfp87KAs3NIWh18eJaxBFhOLsiRjidmBmdfsrCtVZsqQ3768hSQox0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622646; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HcYl+V4YgvTNySXbw6pmgwNfQ+UigZy8sI66UoFEla0=; b=JMsZmVey9WbjRSq8AvWNL0eNSW2JUymw+Pdk2CYoCoUBzs+CDO9ieesmB+8VCYO1KxDv1zoQvybZ2W5yXgpNBB/uZ2f1/+swlBL/xyA1xwKuGz5sP0rEqHQP0KFeRdh3ZXlyaCxdMMBnW9GAWSBuCHq/yQPEYcs6JrH5JOVuyo8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622646138831.5665983339906; Thu, 18 Apr 2019 14:24:06 -0700 (PDT) Received: from localhost ([127.0.0.1]:47606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEVm-0005Cr-Qc for importer@patchew.org; Thu, 18 Apr 2019 17:24:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0g-0005GL-Uo for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0f-0005PL-1r for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58656) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0d-0005FH-1z for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4715FC0270D3 for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6A5060143 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 017D3110CFD4; Thu, 18 Apr 2019 22:51:36 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:30 +0200 Message-Id: <20190418205135.6686-32-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 18 Apr 2019 20:51:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 31/36] qom/cpu: Simplify how CPUClass::dump_statistics() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" CPUClass method dump_statistics() takes an fprintf()-like callback and a FILE * to pass to it. Its only caller hmp_info_cpustats() (via cpu_dump_statistics()) passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Drop the callback, and call qemu_printf() instead. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-13-armbru@redhat.com> --- include/qom/cpu.h | 11 ++++------- monitor.c | 2 +- qom/cpu.c | 5 ++--- target/ppc/cpu.h | 3 +-- target/ppc/translate.c | 9 ++++----- 5 files changed, 12 insertions(+), 18 deletions(-) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 1d6099e5d4..31bafee2b1 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -184,8 +184,7 @@ typedef struct CPUClass { void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprint= f, int flags); GuestPanicInformation* (*get_crash_info)(CPUState *cpu); - void (*dump_statistics)(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); + void (*dump_statistics)(CPUState *cpu, int flags); int64_t (*get_arch_id)(CPUState *cpu); bool (*get_paging_enabled)(const CPUState *cpu); void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, @@ -576,14 +575,12 @@ void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_f= unction cpu_fprintf, /** * cpu_dump_statistics: * @cpu: The CPU whose state is to be dumped. - * @f: File to dump to. - * @cpu_fprintf: Function to dump with. * @flags: Flags what to dump. * - * Dumps CPU statistics. + * Dump CPU statistics to the current monitor if we have one, else to + * stdout. */ -void cpu_dump_statistics(CPUState *cpu, FILE *f, fprintf_function cpu_fpri= ntf, - int flags); +void cpu_dump_statistics(CPUState *cpu, int flags); =20 #ifndef CONFIG_USER_ONLY /** diff --git a/monitor.c b/monitor.c index 0819b99ef7..fb5b681099 100644 --- a/monitor.c +++ b/monitor.c @@ -1364,7 +1364,7 @@ static void hmp_info_cpustats(Monitor *mon, const QDi= ct *qdict) monitor_printf(mon, "No CPU available\n"); return; } - cpu_dump_statistics(cs, (FILE *)mon, &monitor_fprintf, 0); + cpu_dump_statistics(cs, 0); } =20 static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) diff --git a/qom/cpu.c b/qom/cpu.c index a8d2958956..029e7fe9b0 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -230,13 +230,12 @@ void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_f= unction cpu_fprintf, } } =20 -void cpu_dump_statistics(CPUState *cpu, FILE *f, fprintf_function cpu_fpri= ntf, - int flags) +void cpu_dump_statistics(CPUState *cpu, int flags) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 if (cc->dump_statistics) { - cc->dump_statistics(cpu, f, cpu_fprintf, flags); + cc->dump_statistics(cpu, flags); } } =20 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 8572241364..27a36b9605 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1270,8 +1270,7 @@ void ppc_cpu_do_interrupt(CPUState *cpu); bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req); void ppc_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprin= tf, int flags); -void ppc_cpu_dump_statistics(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); +void ppc_cpu_dump_statistics(CPUState *cpu, int flags); hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int ppc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int ppc_cpu_gdb_read_register_apple(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index badc1ae1a3..f99f27a134 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7593,8 +7593,7 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprint= f_function cpu_fprintf, #undef RFPL } =20 -void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, - fprintf_function cpu_fprintf, int flags) +void ppc_cpu_dump_statistics(CPUState *cs, int flags) { #if defined(DO_PPC_STATISTICS) PowerPCCPU *cpu =3D POWERPC_CPU(cs); @@ -7614,7 +7613,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, handler =3D t3[op3]; if (handler->count =3D=3D 0) continue; - cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: " + qemu_printf("%02x %02x %02x (%02x %04d) %16s: " "%016" PRIx64 " %" PRId64 "\n", op1, op2, op3, op1, (op3 << 5) | op2, handler->oname, @@ -7623,7 +7622,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, } else { if (handler->count =3D=3D 0) continue; - cpu_fprintf(f, "%02x %02x (%02x %04d) %16s: " + qemu_printf("%02x %02x (%02x %04d) %16s: " "%016" PRIx64 " %" PRId64 "\n", op1, op2, op1, op2, handler->oname, handler->count, handler->count); @@ -7632,7 +7631,7 @@ void ppc_cpu_dump_statistics(CPUState *cs, FILE*f, } else { if (handler->count =3D=3D 0) continue; - cpu_fprintf(f, "%02x (%02x ) %16s: %016" PRIx64 + qemu_printf("%02x (%02x ) %16s: %016" PRIx64 " %" PRId64 "\n", op1, op1, handler->oname, handler->count, handler->count); --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621202; cv=none; d=zoho.com; s=zohoarc; b=ahVgducEbFwd0HqNgSR8s5X40ZlFp66qA5Vl9B5DKUZw+BOB7KXTCgBv6CpLT0YV2sCnQyp9shqeT2bbqxdlYJyUWW6NHeXyAIp5spYZGMm+5Zw5zfGNUZF5lJTULUuAxR6OmFKvvC4mRlGaVWMGl0XTzn3dbjcjAokv9PC/94k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621202; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=RlfHhpef/ivfi1NjACrg6IP/99nEf9UaHFx11Ut86oc=; b=PWSZulR/b02WuDTwAn7MGRHRjBfj4SBAgZDIfwzPOGtctma0z6KZfZJhC7DXrV0acf6yUHHsPuiXMTz9JaSsy0823LrEApTwF7JS/XnoTWduJU/PTG4xdxUaXQ9NnF5TcvF/Yp6EsjmNFDNmhisEFMTlliLR/AhZn6RE8ExQ2Qk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621202477206.31768270287841; Thu, 18 Apr 2019 14:00:02 -0700 (PDT) Received: from localhost ([127.0.0.1]:47202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE8V-00032z-DN for importer@patchew.org; Thu, 18 Apr 2019 16:59:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CB-2L for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005Hy-Q6 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52866) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005Ev-9p for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27E27C066474 for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA84760148 for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 09D91110CFD7; Thu, 18 Apr 2019 22:51:37 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:31 +0200 Message-Id: <20190418205135.6686-33-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 18 Apr 2019 20:51:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 32/36] qemu-print: New qemu_fprintf(), qemu_vfprintf() 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Code that doesn't want to know about current monitor vs. stdout vs. stderr takes an fprintf_function callback and a FILE * argument to pass to it. Actual arguments are either fprintf() and stdout or stderr, or monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. New qemu_fprintf() and qemu_vprintf() address this need without type punning: they are like fprintf() and vfprintf(), except they print to the current monitor when passed a null FILE *. The next commits will put them to use. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-14-armbru@redhat.com> --- include/qemu/qemu-print.h | 4 ++++ util/qemu-print.c | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/qemu/qemu-print.h b/include/qemu/qemu-print.h index 8fed32bf42..40b596262f 100644 --- a/include/qemu/qemu-print.h +++ b/include/qemu/qemu-print.h @@ -16,4 +16,8 @@ int qemu_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); int qemu_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); =20 +int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap) + GCC_FMT_ATTR(2, 0); +int qemu_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3); + #endif diff --git a/util/qemu-print.c b/util/qemu-print.c index 86f9417af8..e79d6b8396 100644 --- a/util/qemu-print.c +++ b/util/qemu-print.c @@ -40,3 +40,30 @@ int qemu_printf(const char *fmt, ...) va_end(ap); return ret; } + +/* + * Print like vfprintf() + * Print to @stream if non-null, else to current monitor. + */ +int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap) +{ + if (!stream) { + return monitor_vprintf(cur_mon, fmt, ap); + } + return vfprintf(stream, fmt, ap); +} + +/* + * Print like fprintf(). + * Print to @stream if non-null, else to current monitor. + */ +int qemu_fprintf(FILE *stream, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret =3D qemu_vfprintf(stream, fmt, ap); + va_end(ap); + return ret; +} --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622256; cv=none; d=zoho.com; s=zohoarc; b=dkCx9jbT7IiKCQ0zeklRb0cOBo5EVQP0Ft5V4UxLFFj8c7XMa2dYfvlMF5qtwOPTyvOUSZKde8NiunUqxn+3gjXcWcReEkLUA/W1kxV55oPjI38Zs5Io3TegHNPEe1mVwKEee9pQ/B5EnSBw3N4f0TInpb8NDIHCGFDc1tbOaNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622256; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QkLu0tCO5qlogMsnFBqQxRQT9d2dtjvrsLiMup/iKBo=; b=fMN8HPto0dh0oklcaN2o9BIny/lHWQpKh4NNP8cPIl5jr4Wie24yYzfMpSLSc8/yAtPoQ2KslrXX4IfVBp/GDG/vayCbS7CDvzCzOvYVP/ABDOd0Qh11dAFflM75mQUcMt1R+jfA8I02W/W0Fo7FMWTASSD80vyP1hd79ROKW1s= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155562225608067.88330609842592; Thu, 18 Apr 2019 14:17:36 -0700 (PDT) Received: from localhost ([127.0.0.1]:47483 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEPU-0000CR-7Z for importer@patchew.org; Thu, 18 Apr 2019 17:17:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0s-0005RD-My for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:52:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0j-0005TH-0c for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:52:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56738) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0g-0005Gg-Vr for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F20693082E4E for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 003C65D9CC for ; Thu, 18 Apr 2019 20:51:41 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 12E6E110CFD8; Thu, 18 Apr 2019 22:51:37 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:32 +0200 Message-Id: <20190418205135.6686-34-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 18 Apr 2019 20:51:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 33/36] qom/cpu: Simplify how CPUClass:cpu_dump_state() prints 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" CPUClass method dump_statistics() takes an fprintf()-like callback and a FILE * to pass to it. Most callers pass fprintf() and stderr. log_cpu_state() passes fprintf() and qemu_log_file. hmp_info_registers() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The callback gets passed around a lot, which is tiresome. The type-punning around monitor_fprintf() is ugly. Drop the callback, and call qemu_fprintf() instead. Also gets rid of the type-punning, since qemu_fprintf() takes NULL instead of the current monitor cast to FILE *. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-15-armbru@redhat.com> --- accel/kvm/kvm-all.c | 4 +- bsd-user/main.c | 2 +- cpus.c | 2 +- exec.c | 2 +- include/exec/log.h | 2 +- include/qom/cpu.h | 11 +- linux-user/alpha/cpu_loop.c | 2 +- linux-user/cpu_loop-common.h | 2 +- linux-user/cris/cpu_loop.c | 2 +- linux-user/microblaze/cpu_loop.c | 4 +- linux-user/s390x/cpu_loop.c | 4 +- linux-user/sh4/cpu_loop.c | 2 +- linux-user/sparc/cpu_loop.c | 2 +- monitor.c | 4 +- qom/cpu.c | 6 +- target/alpha/cpu.h | 3 +- target/alpha/helper.c | 24 +-- target/arm/arm-semi.c | 2 +- target/arm/cpu.h | 3 +- target/arm/translate-a64.c | 82 ++++----- target/arm/translate.c | 58 +++---- target/arm/translate.h | 7 +- target/cris/cpu.h | 3 +- target/cris/helper.c | 2 +- target/cris/translate.c | 36 ++-- target/hppa/cpu.h | 2 +- target/hppa/helper.c | 24 +-- target/i386/cpu.h | 3 +- target/i386/hax-all.c | 4 +- target/i386/helper.c | 277 +++++++++++++++---------------- target/lm32/cpu.h | 3 +- target/lm32/translate.c | 36 ++-- target/m68k/cpu.h | 3 +- target/m68k/translate.c | 86 +++++----- target/microblaze/cpu.h | 3 +- target/microblaze/helper.c | 2 +- target/microblaze/translate.c | 39 ++--- target/mips/internal.h | 3 +- target/mips/translate.c | 76 ++++----- target/moxie/cpu.h | 3 +- target/moxie/helper.c | 2 +- target/moxie/translate.c | 22 +-- target/nios2/cpu.h | 3 +- target/nios2/helper.c | 2 +- target/nios2/translate.c | 24 +-- target/openrisc/cpu.h | 3 +- target/openrisc/translate.c | 11 +- target/ppc/cpu.h | 3 +- target/ppc/translate.c | 161 +++++++++--------- target/riscv/cpu.c | 37 ++--- target/s390x/helper.c | 42 ++--- target/s390x/internal.h | 3 +- target/sh4/cpu.h | 3 +- target/sh4/translate.c | 27 +-- target/sparc/cpu.c | 84 +++++----- target/sparc/cpu.h | 3 +- target/tilegx/cpu.c | 14 +- target/tricore/cpu.h | 3 +- target/tricore/translate.c | 26 +-- target/unicore32/cpu.h | 3 +- target/unicore32/translate.c | 39 +++-- target/xtensa/cpu.h | 3 +- target/xtensa/translate.c | 40 ++--- 63 files changed, 682 insertions(+), 711 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 241db496c3..524c4ddfbd 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1798,7 +1798,7 @@ static int kvm_handle_internal_error(CPUState *cpu, s= truct kvm_run *run) if (run->internal.suberror =3D=3D KVM_INTERNAL_ERROR_EMULATION) { fprintf(stderr, "emulation failure\n"); if (!kvm_arch_stop_on_emulation_error(cpu)) { - cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_CODE); + cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); return EXCP_INTERRUPT; } } @@ -2089,7 +2089,7 @@ int kvm_cpu_exec(CPUState *cpu) qemu_mutex_lock_iothread(); =20 if (ret < 0) { - cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_CODE); + cpu_dump_state(cpu, stderr, CPU_DUMP_CODE); vm_stop(RUN_STATE_INTERNAL_ERROR); } =20 diff --git a/bsd-user/main.c b/bsd-user/main.c index 7657c6851d..a8c807e8df 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -640,7 +640,7 @@ void cpu_loop(CPUSPARCState *env) badtrap: #endif printf ("Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit (1); } process_pending_signals (env); diff --git a/cpus.c b/cpus.c index b4eecf70f0..e58e7ab0f6 100644 --- a/cpus.c +++ b/cpus.c @@ -1010,7 +1010,7 @@ void hw_error(const char *fmt, ...) fprintf(stderr, "\n"); CPU_FOREACH(cpu) { fprintf(stderr, "CPU #%d:\n", cpu->cpu_index); - cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_FPU); + cpu_dump_state(cpu, stderr, CPU_DUMP_FPU); } va_end(ap); abort(); diff --git a/exec.c b/exec.c index 85d15606f1..2646207661 100644 --- a/exec.c +++ b/exec.c @@ -1256,7 +1256,7 @@ void cpu_abort(CPUState *cpu, const char *fmt, ...) fprintf(stderr, "qemu: fatal: "); vfprintf(stderr, fmt, ap); fprintf(stderr, "\n"); - cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_FPU | CPU_DUMP_CCOP); + cpu_dump_state(cpu, stderr, CPU_DUMP_FPU | CPU_DUMP_CCOP); if (qemu_log_separate()) { qemu_log_lock(); qemu_log("qemu: fatal: "); diff --git a/include/exec/log.h b/include/exec/log.h index c249307911..de067f173b 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -16,7 +16,7 @@ static inline void log_cpu_state(CPUState *cpu, int flags) { if (qemu_log_enabled()) { - cpu_dump_state(cpu, qemu_logfile, fprintf, flags); + cpu_dump_state(cpu, qemu_logfile, flags); } } =20 diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 31bafee2b1..9972e07786 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -26,7 +26,6 @@ #include "exec/memattrs.h" #include "qapi/qapi-types-run-state.h" #include "qemu/bitmap.h" -#include "qemu/fprintf-fn.h" #include "qemu/rcu_queue.h" #include "qemu/queue.h" #include "qemu/thread.h" @@ -181,8 +180,7 @@ typedef struct CPUClass { bool (*virtio_is_big_endian)(CPUState *cpu); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); - void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprint= f, - int flags); + void (*dump_state)(CPUState *cpu, FILE *, int flags); GuestPanicInformation* (*get_crash_info)(CPUState *cpu); void (*dump_statistics)(CPUState *cpu, int flags); int64_t (*get_arch_id)(CPUState *cpu); @@ -563,14 +561,11 @@ enum CPUDumpFlags { /** * cpu_dump_state: * @cpu: The CPU whose state is to be dumped. - * @f: File to dump to. - * @cpu_fprintf: Function to dump with. - * @flags: Flags what to dump. + * @f: If non-null, dump to this stream, else to current print sink. * * Dumps CPU state. */ -void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, - int flags); +void cpu_dump_state(CPUState *cpu, FILE *f, int flags); =20 /** * cpu_dump_statistics: diff --git a/linux-user/alpha/cpu_loop.c b/linux-user/alpha/cpu_loop.c index 824b6d6658..61992571e1 100644 --- a/linux-user/alpha/cpu_loop.c +++ b/linux-user/alpha/cpu_loop.c @@ -193,7 +193,7 @@ void cpu_loop(CPUAlphaState *env) break; default: fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); } process_pending_signals (env); diff --git a/linux-user/cpu_loop-common.h b/linux-user/cpu_loop-common.h index ffe3fe9ad5..c1d554a249 100644 --- a/linux-user/cpu_loop-common.h +++ b/linux-user/cpu_loop-common.h @@ -26,7 +26,7 @@ do { \ CPUState *cs =3D ENV_GET_CPU(env); \ fprintf(stderr, fmt , ## __VA_ARGS__); \ - cpu_dump_state(cs, stderr, fprintf, 0); \ + cpu_dump_state(cs, stderr, 0); \ if (qemu_log_separate()) { \ qemu_log(fmt, ## __VA_ARGS__); \ log_cpu_state(cs, 0); \ diff --git a/linux-user/cris/cpu_loop.c b/linux-user/cris/cpu_loop.c index dacf604c7d..af8c128bf8 100644 --- a/linux-user/cris/cpu_loop.c +++ b/linux-user/cris/cpu_loop.c @@ -74,7 +74,7 @@ void cpu_loop(CPUCRISState *env) break; default: fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); } process_pending_signals (env); diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_l= oop.c index c2190e15fd..076bdb9a61 100644 --- a/linux-user/microblaze/cpu_loop.c +++ b/linux-user/microblaze/cpu_loop.c @@ -107,7 +107,7 @@ void cpu_loop(CPUMBState *env) default: fprintf(stderr, "Unhandled hw-exception: 0x%" PRIx64 "= \n", env->sregs[SR_ESR] & ESR_EC_MASK); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); break; } @@ -123,7 +123,7 @@ void cpu_loop(CPUMBState *env) break; default: fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); } process_pending_signals (env); diff --git a/linux-user/s390x/cpu_loop.c b/linux-user/s390x/cpu_loop.c index 51b5412ea2..b8bd1c956c 100644 --- a/linux-user/s390x/cpu_loop.c +++ b/linux-user/s390x/cpu_loop.c @@ -124,7 +124,7 @@ void cpu_loop(CPUS390XState *env) =20 default: fprintf(stderr, "Unhandled program exception: %#x\n", n); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); } break; @@ -144,7 +144,7 @@ void cpu_loop(CPUS390XState *env) break; default: fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); } process_pending_signals (env); diff --git a/linux-user/sh4/cpu_loop.c b/linux-user/sh4/cpu_loop.c index 47e54b9b61..59cbbeda7e 100644 --- a/linux-user/sh4/cpu_loop.c +++ b/linux-user/sh4/cpu_loop.c @@ -76,7 +76,7 @@ void cpu_loop(CPUSH4State *env) break; default: fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); } process_pending_signals (env); diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 7d5b337b97..9e357229c0 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -278,7 +278,7 @@ void cpu_loop (CPUSPARCState *env) break; default: fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); exit(EXIT_FAILURE); } process_pending_signals (env); diff --git a/monitor.c b/monitor.c index fb5b681099..ad6cec54a1 100644 --- a/monitor.c +++ b/monitor.c @@ -1296,7 +1296,7 @@ static void hmp_info_registers(Monitor *mon, const QD= ict *qdict) if (all_cpus) { CPU_FOREACH(cs) { monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index); - cpu_dump_state(cs, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); + cpu_dump_state(cs, NULL, CPU_DUMP_FPU); } } else { cs =3D mon_get_cpu(); @@ -1306,7 +1306,7 @@ static void hmp_info_registers(Monitor *mon, const QD= ict *qdict) return; } =20 - cpu_dump_state(cs, (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); + cpu_dump_state(cs, NULL, CPU_DUMP_FPU); } } =20 diff --git a/qom/cpu.c b/qom/cpu.c index 029e7fe9b0..3c5493c96c 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -28,6 +28,7 @@ #include "exec/log.h" #include "exec/cpu-common.h" #include "qemu/error-report.h" +#include "qemu/qemu-print.h" #include "sysemu/sysemu.h" #include "hw/boards.h" #include "hw/qdev-properties.h" @@ -219,14 +220,13 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *c= pu) return res; } =20 -void cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf, - int flags) +void cpu_dump_state(CPUState *cpu, FILE *f, int flags) { CPUClass *cc =3D CPU_GET_CLASS(cpu); =20 if (cc->dump_state) { cpu_synchronize_state(cpu); - cc->dump_state(cpu, f, cpu_fprintf, flags); + cc->dump_state(cpu, f, flags); } } =20 diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 732764f23c..63bf3618ff 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -311,8 +311,7 @@ extern const struct VMStateDescription vmstate_alpha_cp= u; =20 void alpha_cpu_do_interrupt(CPUState *cpu); bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req); -void alpha_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fpri= ntf, - int flags); +void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags); hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int alpha_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 57e2c212b3..7201576aae 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -23,6 +23,7 @@ #include "exec/exec-all.h" #include "fpu/softfloat.h" #include "exec/helper-proto.h" +#include "qemu/qemu-print.h" =20 =20 #define CONVERT_BIT(X, SRC, DST) \ @@ -426,8 +427,7 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interru= pt_request) return false; } =20 -void alpha_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fpri= ntf, - int flags) +void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags) { static const char *linux_reg_names[] =3D { "v0 ", "t0 ", "t1 ", "t2 ", "t3 ", "t4 ", "t5 ", "t6 ", @@ -439,24 +439,24 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, fpri= ntf_function cpu_fprintf, CPUAlphaState *env =3D &cpu->env; int i; =20 - cpu_fprintf(f, " PC " TARGET_FMT_lx " PS %02x\n", - env->pc, extract32(env->flags, ENV_FLAG_PS_SHIFT, 8)); + qemu_fprintf(f, " PC " TARGET_FMT_lx " PS %02x\n", + env->pc, extract32(env->flags, ENV_FLAG_PS_SHIFT, 8)); for (i =3D 0; i < 31; i++) { - cpu_fprintf(f, "IR%02d %s " TARGET_FMT_lx "%c", i, - linux_reg_names[i], cpu_alpha_load_gr(env, i), - (i % 3) =3D=3D 2 ? '\n' : ' '); + qemu_fprintf(f, "IR%02d %s " TARGET_FMT_lx "%c", i, + linux_reg_names[i], cpu_alpha_load_gr(env, i), + (i % 3) =3D=3D 2 ? '\n' : ' '); } =20 - cpu_fprintf(f, "lock_a " TARGET_FMT_lx " lock_v " TARGET_FMT_lx "\= n", - env->lock_addr, env->lock_value); + qemu_fprintf(f, "lock_a " TARGET_FMT_lx " lock_v " TARGET_FMT_lx "= \n", + env->lock_addr, env->lock_value); =20 if (flags & CPU_DUMP_FPU) { for (i =3D 0; i < 31; i++) { - cpu_fprintf(f, "FIR%02d %016" PRIx64 "%c", i, env->fir[i], - (i % 3) =3D=3D 2 ? '\n' : ' '); + qemu_fprintf(f, "FIR%02d %016" PRIx64 "%c", i, env->fir[i], + (i % 3) =3D=3D 2 ? '\n' : ' '); } } - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } =20 /* This should only be called from translate, via gen_excp. diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c index b2b22d231e..8b5fd7bc6e 100644 --- a/target/arm/arm-semi.c +++ b/target/arm/arm-semi.c @@ -650,7 +650,7 @@ target_ulong do_arm_semihosting(CPUARMState *env) /* fall through -- invalid for A32/T32 */ default: fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr); - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); abort(); } } diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 85c3bd642a..f7f2f5a99c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -935,8 +935,7 @@ void arm_cpu_do_interrupt(CPUState *cpu); void arm_v7m_cpu_do_interrupt(CPUState *cpu); bool arm_cpu_exec_interrupt(CPUState *cpu, int int_req); =20 -void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprint= f, - int flags); +void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags); =20 hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index dcdeb80176..9dcc5ff3a3 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -27,6 +27,7 @@ #include "translate.h" #include "internals.h" #include "qemu/host-utils.h" +#include "qemu/qemu-print.h" =20 #include "exec/semihost.h" #include "exec/gen-icount.h" @@ -151,8 +152,7 @@ static void set_btype(DisasContext *s, int val) s->btype =3D -1; } =20 -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -161,13 +161,13 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int el =3D arm_current_el(env); const char *ns_status; =20 - cpu_fprintf(f, " PC=3D%016" PRIx64 " ", env->pc); + qemu_fprintf(f, " PC=3D%016" PRIx64 " ", env->pc); for (i =3D 0; i < 32; i++) { if (i =3D=3D 31) { - cpu_fprintf(f, " SP=3D%016" PRIx64 "\n", env->xregs[i]); + qemu_fprintf(f, " SP=3D%016" PRIx64 "\n", env->xregs[i]); } else { - cpu_fprintf(f, "X%02d=3D%016" PRIx64 "%s", i, env->xregs[i], - (i + 2) % 3 ? " " : "\n"); + qemu_fprintf(f, "X%02d=3D%016" PRIx64 "%s", i, env->xregs[i], + (i + 2) % 3 ? " " : "\n"); } } =20 @@ -176,29 +176,29 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, } else { ns_status =3D ""; } - cpu_fprintf(f, "PSTATE=3D%08x %c%c%c%c %sEL%d%c", - psr, - psr & PSTATE_N ? 'N' : '-', - psr & PSTATE_Z ? 'Z' : '-', - psr & PSTATE_C ? 'C' : '-', - psr & PSTATE_V ? 'V' : '-', - ns_status, - el, - psr & PSTATE_SP ? 'h' : 't'); + qemu_fprintf(f, "PSTATE=3D%08x %c%c%c%c %sEL%d%c", + psr, + psr & PSTATE_N ? 'N' : '-', + psr & PSTATE_Z ? 'Z' : '-', + psr & PSTATE_C ? 'C' : '-', + psr & PSTATE_V ? 'V' : '-', + ns_status, + el, + psr & PSTATE_SP ? 'h' : 't'); =20 if (cpu_isar_feature(aa64_bti, cpu)) { - cpu_fprintf(f, " BTYPE=3D%d", (psr & PSTATE_BTYPE) >> 10); + qemu_fprintf(f, " BTYPE=3D%d", (psr & PSTATE_BTYPE) >> 10); } if (!(flags & CPU_DUMP_FPU)) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); return; } if (fp_exception_el(env, el) !=3D 0) { - cpu_fprintf(f, " FPU disabled\n"); + qemu_fprintf(f, " FPU disabled\n"); return; } - cpu_fprintf(f, " FPCR=3D%08x FPSR=3D%08x\n", - vfp_get_fpcr(env), vfp_get_fpsr(env)); + qemu_fprintf(f, " FPCR=3D%08x FPSR=3D%08x\n", + vfp_get_fpcr(env), vfp_get_fpsr(env)); =20 if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) =3D= =3D 0) { int j, zcr_len =3D sve_zcr_len_for_el(env, el); @@ -206,11 +206,11 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, for (i =3D 0; i <=3D FFR_PRED_NUM; i++) { bool eol; if (i =3D=3D FFR_PRED_NUM) { - cpu_fprintf(f, "FFR=3D"); + qemu_fprintf(f, "FFR=3D"); /* It's last, so end the line. */ eol =3D true; } else { - cpu_fprintf(f, "P%02d=3D", i); + qemu_fprintf(f, "P%02d=3D", i); switch (zcr_len) { case 0: eol =3D i % 8 =3D=3D 7; @@ -235,46 +235,46 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, } else { digits =3D (zcr_len % 4 + 1) * 4; } - cpu_fprintf(f, "%0*" PRIx64 "%s", digits, - env->vfp.pregs[i].p[j], - j ? ":" : eol ? "\n" : " "); + qemu_fprintf(f, "%0*" PRIx64 "%s", digits, + env->vfp.pregs[i].p[j], + j ? ":" : eol ? "\n" : " "); } } =20 for (i =3D 0; i < 32; i++) { if (zcr_len =3D=3D 0) { - cpu_fprintf(f, "Z%02d=3D%016" PRIx64 ":%016" PRIx64 "%s", - i, env->vfp.zregs[i].d[1], - env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); + qemu_fprintf(f, "Z%02d=3D%016" PRIx64 ":%016" PRIx64 "%s", + i, env->vfp.zregs[i].d[1], + env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); } else if (zcr_len =3D=3D 1) { - cpu_fprintf(f, "Z%02d=3D%016" PRIx64 ":%016" PRIx64 - ":%016" PRIx64 ":%016" PRIx64 "\n", - i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d= [2], - env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]= ); + qemu_fprintf(f, "Z%02d=3D%016" PRIx64 ":%016" PRIx64 + ":%016" PRIx64 ":%016" PRIx64 "\n", + i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].= d[2], + env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0= ]); } else { for (j =3D zcr_len; j >=3D 0; j--) { bool odd =3D (zcr_len - j) % 2 !=3D 0; if (j =3D=3D zcr_len) { - cpu_fprintf(f, "Z%02d[%x-%x]=3D", i, j, j - 1); + qemu_fprintf(f, "Z%02d[%x-%x]=3D", i, j, j - 1); } else if (!odd) { if (j > 0) { - cpu_fprintf(f, " [%x-%x]=3D", j, j - 1); + qemu_fprintf(f, " [%x-%x]=3D", j, j - 1); } else { - cpu_fprintf(f, " [%x]=3D", j); + qemu_fprintf(f, " [%x]=3D", j); } } - cpu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", - env->vfp.zregs[i].d[j * 2 + 1], - env->vfp.zregs[i].d[j * 2], - odd || j =3D=3D 0 ? "\n" : ":"); + qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", + env->vfp.zregs[i].d[j * 2 + 1], + env->vfp.zregs[i].d[j * 2], + odd || j =3D=3D 0 ? "\n" : ":"); } } } } else { for (i =3D 0; i < 32; i++) { uint64_t *q =3D aa64_vfp_qreg(env, i); - cpu_fprintf(f, "Q%02d=3D%016" PRIx64 ":%016" PRIx64 "%s", - i, q[1], q[0], (i & 1 ? "\n" : " ")); + qemu_fprintf(f, "Q%02d=3D%016" PRIx64 ":%016" PRIx64 "%s", + i, q[1], q[0], (i & 1 ? "\n" : " ")); } } } diff --git a/target/arm/translate.c b/target/arm/translate.c index d408e4d7ef..d9e7bb737a 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -28,6 +28,7 @@ #include "tcg-op-gvec.h" #include "qemu/log.h" #include "qemu/bitops.h" +#include "qemu/qemu-print.h" #include "arm_ldst.h" #include "exec/semihost.h" =20 @@ -13772,24 +13773,23 @@ void gen_intermediate_code(CPUState *cpu, Transla= tionBlock *tb) translator_loop(ops, &dc.base, cpu, tb); } =20 -void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprint= f, - int flags) +void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; int i; =20 if (is_a64(env)) { - aarch64_cpu_dump_state(cs, f, cpu_fprintf, flags); + aarch64_cpu_dump_state(cs, f, flags); return; } =20 for(i=3D0;i<16;i++) { - cpu_fprintf(f, "R%02d=3D%08x", i, env->regs[i]); + qemu_fprintf(f, "R%02d=3D%08x", i, env->regs[i]); if ((i % 4) =3D=3D 3) - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); else - cpu_fprintf(f, " "); + qemu_fprintf(f, " "); } =20 if (arm_feature(env, ARM_FEATURE_M)) { @@ -13811,15 +13811,15 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fp= rintf_function cpu_fprintf, } } =20 - cpu_fprintf(f, "XPSR=3D%08x %c%c%c%c %c %s%s\n", - xpsr, - xpsr & XPSR_N ? 'N' : '-', - xpsr & XPSR_Z ? 'Z' : '-', - xpsr & XPSR_C ? 'C' : '-', - xpsr & XPSR_V ? 'V' : '-', - xpsr & XPSR_T ? 'T' : 'A', - ns_status, - mode); + qemu_fprintf(f, "XPSR=3D%08x %c%c%c%c %c %s%s\n", + xpsr, + xpsr & XPSR_N ? 'N' : '-', + xpsr & XPSR_Z ? 'Z' : '-', + xpsr & XPSR_C ? 'C' : '-', + xpsr & XPSR_V ? 'V' : '-', + xpsr & XPSR_T ? 'T' : 'A', + ns_status, + mode); } else { uint32_t psr =3D cpsr_read(env); const char *ns_status =3D ""; @@ -13829,15 +13829,15 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fp= rintf_function cpu_fprintf, ns_status =3D env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; } =20 - cpu_fprintf(f, "PSR=3D%08x %c%c%c%c %c %s%s%d\n", - psr, - psr & CPSR_N ? 'N' : '-', - psr & CPSR_Z ? 'Z' : '-', - psr & CPSR_C ? 'C' : '-', - psr & CPSR_V ? 'V' : '-', - psr & CPSR_T ? 'T' : 'A', - ns_status, - aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); + qemu_fprintf(f, "PSR=3D%08x %c%c%c%c %c %s%s%d\n", + psr, + psr & CPSR_N ? 'N' : '-', + psr & CPSR_Z ? 'Z' : '-', + psr & CPSR_C ? 'C' : '-', + psr & CPSR_V ? 'V' : '-', + psr & CPSR_T ? 'T' : 'A', + ns_status, + aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); } =20 if (flags & CPU_DUMP_FPU) { @@ -13850,12 +13850,12 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fp= rintf_function cpu_fprintf, } for (i =3D 0; i < numvfpregs; i++) { uint64_t v =3D *aa32_vfp_dreg(env, i); - cpu_fprintf(f, "s%02d=3D%08x s%02d=3D%08x d%02d=3D%016" PRIx64= "\n", - i * 2, (uint32_t)v, - i * 2 + 1, (uint32_t)(v >> 32), - i, v); + qemu_fprintf(f, "s%02d=3D%08x s%02d=3D%08x d%02d=3D%016" PRIx6= 4 "\n", + i * 2, (uint32_t)v, + i * 2 + 1, (uint32_t)(v >> 32), + i, v); } - cpu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); + qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); } } =20 diff --git a/target/arm/translate.h b/target/arm/translate.h index 912cc2a4a5..984617786d 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -166,8 +166,7 @@ static inline void disas_set_insn_syndrome(DisasContext= *s, uint32_t syn) #ifdef TARGET_AARCH64 void a64_translate_init(void); void gen_a64_set_pc_im(uint64_t val); -void aarch64_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags); +void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags); extern const TranslatorOps aarch64_translator_ops; #else static inline void a64_translate_init(void) @@ -178,9 +177,7 @@ static inline void gen_a64_set_pc_im(uint64_t val) { } =20 -static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, - int flags) +static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) { } #endif diff --git a/target/cris/cpu.h b/target/cris/cpu.h index 3d11922fb2..0fbe771639 100644 --- a/target/cris/cpu.h +++ b/target/cris/cpu.h @@ -207,8 +207,7 @@ void cris_cpu_do_interrupt(CPUState *cpu); void crisv10_cpu_do_interrupt(CPUState *cpu); bool cris_cpu_exec_interrupt(CPUState *cpu, int int_req); =20 -void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, - int flags); +void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags); =20 hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); =20 diff --git a/target/cris/helper.c b/target/cris/helper.c index b2dbb2075c..3939603c73 100644 --- a/target/cris/helper.c +++ b/target/cris/helper.c @@ -60,7 +60,7 @@ int cris_cpu_handle_mmu_fault(CPUState *cs, vaddr address= , int size, int rw, =20 cs->exception_index =3D 0xaa; cpu->env.pregs[PR_EDA] =3D address; - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); return 1; } =20 diff --git a/target/cris/translate.c b/target/cris/translate.c index 11b2c11174..96359c0d7d 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -33,6 +33,7 @@ #include "exec/cpu_ldst.h" #include "exec/translator.h" #include "crisv32-decode.h" +#include "qemu/qemu-print.h" =20 #include "exec/helper-gen.h" =20 @@ -3299,8 +3300,7 @@ void gen_intermediate_code(CPUState *cs, struct Trans= lationBlock *tb) #endif } =20 -void cris_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, - int flags) +void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags) { CRISCPU *cpu =3D CRIS_CPU(cs); CPUCRISState *env =3D &cpu->env; @@ -3308,7 +3308,7 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fprin= tf_function cpu_fprintf, const char **pregnames; int i; =20 - if (!env || !f) { + if (!env) { return; } if (env->pregs[PR_VR] < 32) { @@ -3319,40 +3319,40 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, fpr= intf_function cpu_fprintf, regnames =3D regnames_v32; } =20 - cpu_fprintf(f, "PC=3D%x CCS=3D%x btaken=3D%d btarget=3D%x\n" - "cc_op=3D%d cc_src=3D%d cc_dest=3D%d cc_result=3D%x cc_mask=3D= %x\n", - env->pc, env->pregs[PR_CCS], env->btaken, env->btarget, - env->cc_op, - env->cc_src, env->cc_dest, env->cc_result, env->cc_mask); + qemu_fprintf(f, "PC=3D%x CCS=3D%x btaken=3D%d btarget=3D%x\n" + "cc_op=3D%d cc_src=3D%d cc_dest=3D%d cc_result=3D%x cc_ma= sk=3D%x\n", + env->pc, env->pregs[PR_CCS], env->btaken, env->btarget, + env->cc_op, + env->cc_src, env->cc_dest, env->cc_result, env->cc_mask); =20 =20 for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "%s=3D%8.8x ", regnames[i], env->regs[i]); + qemu_fprintf(f, "%s=3D%8.8x ", regnames[i], env->regs[i]); if ((i + 1) % 4 =3D=3D 0) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } - cpu_fprintf(f, "\nspecial regs:\n"); + qemu_fprintf(f, "\nspecial regs:\n"); for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "%s=3D%8.8x ", pregnames[i], env->pregs[i]); + qemu_fprintf(f, "%s=3D%8.8x ", pregnames[i], env->pregs[i]); if ((i + 1) % 4 =3D=3D 0) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } if (env->pregs[PR_VR] >=3D 32) { uint32_t srs =3D env->pregs[PR_SRS]; - cpu_fprintf(f, "\nsupport function regs bank %x:\n", srs); + qemu_fprintf(f, "\nsupport function regs bank %x:\n", srs); if (srs < ARRAY_SIZE(env->sregs)) { for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "s%2.2d=3D%8.8x ", - i, env->sregs[srs][i]); + qemu_fprintf(f, "s%2.2d=3D%8.8x ", + i, env->sregs[srs][i]); if ((i + 1) % 4 =3D=3D 0) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } } } - cpu_fprintf(f, "\n\n"); + qemu_fprintf(f, "\n\n"); =20 } =20 diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index db8c9b812c..923346adb6 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -359,7 +359,7 @@ int hppa_cpu_gdb_read_register(CPUState *cpu, uint8_t *= buf, int reg); int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); -void hppa_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function, int); +void hppa_cpu_dump_state(CPUState *cs, FILE *f, int); #ifdef CONFIG_USER_ONLY int hppa_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, int midx); diff --git a/target/hppa/helper.c b/target/hppa/helper.c index ac750b62ef..11c61b3ca2 100644 --- a/target/hppa/helper.c +++ b/target/hppa/helper.c @@ -23,6 +23,7 @@ #include "fpu/softfloat.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "qemu/qemu-print.h" =20 target_ureg cpu_hppa_get_psw(CPUHPPAState *env) { @@ -76,8 +77,7 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ureg psw) } } =20 -void hppa_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +void hppa_cpu_dump_state(CPUState *cs, FILE *f, int flags) { HPPACPU *cpu =3D HPPA_CPU(cs); CPUHPPAState *env =3D &cpu->env; @@ -86,9 +86,9 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, char psw_c[20]; int i; =20 - cpu_fprintf(f, "IA_F " TARGET_FMT_lx " IA_B " TARGET_FMT_lx "\n", - hppa_form_gva_psw(psw, env->iasq_f, env->iaoq_f), - hppa_form_gva_psw(psw, env->iasq_b, env->iaoq_b)); + qemu_fprintf(f, "IA_F " TARGET_FMT_lx " IA_B " TARGET_FMT_lx "\n", + hppa_form_gva_psw(psw, env->iasq_f, env->iaoq_f), + hppa_form_gva_psw(psw, env->iasq_b, env->iaoq_b)); =20 psw_c[0] =3D (psw & PSW_W ? 'W' : '-'); psw_c[1] =3D (psw & PSW_E ? 'E' : '-'); @@ -111,20 +111,20 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, psw_c[18] =3D '\0'; psw_cb =3D ((env->psw_cb >> 4) & 0x01111111) | (env->psw_cb_msb << 28); =20 - cpu_fprintf(f, "PSW " TREG_FMT_lx " CB " TREG_FMT_lx " %s\n", - psw, psw_cb, psw_c); + qemu_fprintf(f, "PSW " TREG_FMT_lx " CB " TREG_FMT_lx " %s\n", + psw, psw_cb, psw_c); =20 for (i =3D 0; i < 32; i++) { - cpu_fprintf(f, "GR%02d " TREG_FMT_lx "%c", i, env->gr[i], - (i & 3) =3D=3D 3 ? '\n' : ' '); + qemu_fprintf(f, "GR%02d " TREG_FMT_lx "%c", i, env->gr[i], + (i & 3) =3D=3D 3 ? '\n' : ' '); } #ifndef CONFIG_USER_ONLY for (i =3D 0; i < 8; i++) { - cpu_fprintf(f, "SR%02d %08x%c", i, (uint32_t)(env->sr[i] >> 32), - (i & 3) =3D=3D 3 ? '\n' : ' '); + qemu_fprintf(f, "SR%02d %08x%c", i, (uint32_t)(env->sr[i] >> 32), + (i & 3) =3D=3D 3 ? '\n' : ' '); } #endif - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); =20 /* ??? FR */ } diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 139fe30960..828067bd1c 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1521,8 +1521,7 @@ int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunctio= n f, CPUState *cpu, void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list, Error **errp); =20 -void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprint= f, - int flags); +void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags); =20 hwaddr x86_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); =20 diff --git a/target/i386/hax-all.c b/target/i386/hax-all.c index b978a9b821..44b89c1d74 100644 --- a/target/i386/hax-all.c +++ b/target/i386/hax-all.c @@ -540,7 +540,7 @@ static int hax_vcpu_hax_exec(CPUArchState *env) ht->_exit_reason); qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); hax_vcpu_sync_state(env, 0); - cpu_dump_state(cpu, stderr, fprintf, 0); + cpu_dump_state(cpu, stderr, 0); ret =3D -1; break; case HAX_EXIT_HLT: @@ -571,7 +571,7 @@ static int hax_vcpu_hax_exec(CPUArchState *env) fprintf(stderr, "Unknown exit %x from HAX\n", ht->_exit_status= ); qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); hax_vcpu_sync_state(env, 0); - cpu_dump_state(cpu, stderr, fprintf, 0); + cpu_dump_state(cpu, stderr, 0); ret =3D 1; break; } diff --git a/target/i386/helper.c b/target/i386/helper.c index 565391a9f6..96336055f3 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -156,38 +156,41 @@ static const char *cc_op_str[CC_OP_NB] =3D { }; =20 static void -cpu_x86_dump_seg_cache(CPUX86State *env, FILE *f, fprintf_function cpu_fpr= intf, +cpu_x86_dump_seg_cache(CPUX86State *env, FILE *f, const char *name, struct SegmentCache *sc) { #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { - cpu_fprintf(f, "%-3s=3D%04x %016" PRIx64 " %08x %08x", name, - sc->selector, sc->base, sc->limit, sc->flags & 0x00fff= f00); + qemu_fprintf(f, "%-3s=3D%04x %016" PRIx64 " %08x %08x", name, + sc->selector, sc->base, sc->limit, + sc->flags & 0x00ffff00); } else #endif { - cpu_fprintf(f, "%-3s=3D%04x %08x %08x %08x", name, sc->selector, - (uint32_t)sc->base, sc->limit, sc->flags & 0x00ffff00); + qemu_fprintf(f, "%-3s=3D%04x %08x %08x %08x", name, sc->selector, + (uint32_t)sc->base, sc->limit, + sc->flags & 0x00ffff00); } =20 if (!(env->hflags & HF_PE_MASK) || !(sc->flags & DESC_P_MASK)) goto done; =20 - cpu_fprintf(f, " DPL=3D%d ", (sc->flags & DESC_DPL_MASK) >> DESC_DPL_S= HIFT); + qemu_fprintf(f, " DPL=3D%d ", + (sc->flags & DESC_DPL_MASK) >> DESC_DPL_SHIFT); if (sc->flags & DESC_S_MASK) { if (sc->flags & DESC_CS_MASK) { - cpu_fprintf(f, (sc->flags & DESC_L_MASK) ? "CS64" : - ((sc->flags & DESC_B_MASK) ? "CS32" : "CS16")); - cpu_fprintf(f, " [%c%c", (sc->flags & DESC_C_MASK) ? 'C' : '-', - (sc->flags & DESC_R_MASK) ? 'R' : '-'); + qemu_fprintf(f, (sc->flags & DESC_L_MASK) ? "CS64" : + ((sc->flags & DESC_B_MASK) ? "CS32" : "CS16")); + qemu_fprintf(f, " [%c%c", (sc->flags & DESC_C_MASK) ? 'C' : '-= ', + (sc->flags & DESC_R_MASK) ? 'R' : '-'); } else { - cpu_fprintf(f, - (sc->flags & DESC_B_MASK || env->hflags & HF_LMA_M= ASK) - ? "DS " : "DS16"); - cpu_fprintf(f, " [%c%c", (sc->flags & DESC_E_MASK) ? 'E' : '-', - (sc->flags & DESC_W_MASK) ? 'W' : '-'); + qemu_fprintf(f, (sc->flags & DESC_B_MASK + || env->hflags & HF_LMA_MASK) + ? "DS " : "DS16"); + qemu_fprintf(f, " [%c%c", (sc->flags & DESC_E_MASK) ? 'E' : '-= ', + (sc->flags & DESC_W_MASK) ? 'W' : '-'); } - cpu_fprintf(f, "%c]", (sc->flags & DESC_A_MASK) ? 'A' : '-'); + qemu_fprintf(f, "%c]", (sc->flags & DESC_A_MASK) ? 'A' : '-'); } else { static const char *sys_type_name[2][16] =3D { { /* 32 bit mode */ @@ -203,13 +206,12 @@ cpu_x86_dump_seg_cache(CPUX86State *env, FILE *f, fpr= intf_function cpu_fprintf, "Reserved", "IntGate64", "TrapGate64" } }; - cpu_fprintf(f, "%s", - sys_type_name[(env->hflags & HF_LMA_MASK) ? 1 : 0] - [(sc->flags & DESC_TYPE_MASK) - >> DESC_TYPE_SHIFT]); + qemu_fprintf(f, "%s", + sys_type_name[(env->hflags & HF_LMA_MASK) ? 1 : 0] + [(sc->flags & DESC_TYPE_MASK) >> DESC_TYPE_SHIFT]); } done: - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } =20 #ifndef CONFIG_USER_ONLY @@ -403,8 +405,7 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, int fl= ags) #define DUMP_CODE_BYTES_TOTAL 50 #define DUMP_CODE_BYTES_BACKWARD 20 =20 -void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprint= f, - int flags) +void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; @@ -415,109 +416,107 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fpri= ntf_function cpu_fprintf, eflags =3D cpu_compute_eflags(env); #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { - cpu_fprintf(f, - "RAX=3D%016" PRIx64 " RBX=3D%016" PRIx64 " RCX=3D%016"= PRIx64 " RDX=3D%016" PRIx64 "\n" - "RSI=3D%016" PRIx64 " RDI=3D%016" PRIx64 " RBP=3D%016"= PRIx64 " RSP=3D%016" PRIx64 "\n" - "R8 =3D%016" PRIx64 " R9 =3D%016" PRIx64 " R10=3D%016"= PRIx64 " R11=3D%016" PRIx64 "\n" - "R12=3D%016" PRIx64 " R13=3D%016" PRIx64 " R14=3D%016"= PRIx64 " R15=3D%016" PRIx64 "\n" - "RIP=3D%016" PRIx64 " RFL=3D%08x [%c%c%c%c%c%c%c] CPL= =3D%d II=3D%d A20=3D%d SMM=3D%d HLT=3D%d\n", - env->regs[R_EAX], - env->regs[R_EBX], - env->regs[R_ECX], - env->regs[R_EDX], - env->regs[R_ESI], - env->regs[R_EDI], - env->regs[R_EBP], - env->regs[R_ESP], - env->regs[8], - env->regs[9], - env->regs[10], - env->regs[11], - env->regs[12], - env->regs[13], - env->regs[14], - env->regs[15], - env->eip, eflags, - eflags & DF_MASK ? 'D' : '-', - eflags & CC_O ? 'O' : '-', - eflags & CC_S ? 'S' : '-', - eflags & CC_Z ? 'Z' : '-', - eflags & CC_A ? 'A' : '-', - eflags & CC_P ? 'P' : '-', - eflags & CC_C ? 'C' : '-', - env->hflags & HF_CPL_MASK, - (env->hflags >> HF_INHIBIT_IRQ_SHIFT) & 1, - (env->a20_mask >> 20) & 1, - (env->hflags >> HF_SMM_SHIFT) & 1, - cs->halted); + qemu_fprintf(f, "RAX=3D%016" PRIx64 " RBX=3D%016" PRIx64 " RCX=3D%= 016" PRIx64 " RDX=3D%016" PRIx64 "\n" + "RSI=3D%016" PRIx64 " RDI=3D%016" PRIx64 " RBP=3D%016= " PRIx64 " RSP=3D%016" PRIx64 "\n" + "R8 =3D%016" PRIx64 " R9 =3D%016" PRIx64 " R10=3D%016= " PRIx64 " R11=3D%016" PRIx64 "\n" + "R12=3D%016" PRIx64 " R13=3D%016" PRIx64 " R14=3D%016= " PRIx64 " R15=3D%016" PRIx64 "\n" + "RIP=3D%016" PRIx64 " RFL=3D%08x [%c%c%c%c%c%c%c] CPL= =3D%d II=3D%d A20=3D%d SMM=3D%d HLT=3D%d\n", + env->regs[R_EAX], + env->regs[R_EBX], + env->regs[R_ECX], + env->regs[R_EDX], + env->regs[R_ESI], + env->regs[R_EDI], + env->regs[R_EBP], + env->regs[R_ESP], + env->regs[8], + env->regs[9], + env->regs[10], + env->regs[11], + env->regs[12], + env->regs[13], + env->regs[14], + env->regs[15], + env->eip, eflags, + eflags & DF_MASK ? 'D' : '-', + eflags & CC_O ? 'O' : '-', + eflags & CC_S ? 'S' : '-', + eflags & CC_Z ? 'Z' : '-', + eflags & CC_A ? 'A' : '-', + eflags & CC_P ? 'P' : '-', + eflags & CC_C ? 'C' : '-', + env->hflags & HF_CPL_MASK, + (env->hflags >> HF_INHIBIT_IRQ_SHIFT) & 1, + (env->a20_mask >> 20) & 1, + (env->hflags >> HF_SMM_SHIFT) & 1, + cs->halted); } else #endif { - cpu_fprintf(f, "EAX=3D%08x EBX=3D%08x ECX=3D%08x EDX=3D%08x\n" - "ESI=3D%08x EDI=3D%08x EBP=3D%08x ESP=3D%08x\n" - "EIP=3D%08x EFL=3D%08x [%c%c%c%c%c%c%c] CPL=3D%d II=3D= %d A20=3D%d SMM=3D%d HLT=3D%d\n", - (uint32_t)env->regs[R_EAX], - (uint32_t)env->regs[R_EBX], - (uint32_t)env->regs[R_ECX], - (uint32_t)env->regs[R_EDX], - (uint32_t)env->regs[R_ESI], - (uint32_t)env->regs[R_EDI], - (uint32_t)env->regs[R_EBP], - (uint32_t)env->regs[R_ESP], - (uint32_t)env->eip, eflags, - eflags & DF_MASK ? 'D' : '-', - eflags & CC_O ? 'O' : '-', - eflags & CC_S ? 'S' : '-', - eflags & CC_Z ? 'Z' : '-', - eflags & CC_A ? 'A' : '-', - eflags & CC_P ? 'P' : '-', - eflags & CC_C ? 'C' : '-', - env->hflags & HF_CPL_MASK, - (env->hflags >> HF_INHIBIT_IRQ_SHIFT) & 1, - (env->a20_mask >> 20) & 1, - (env->hflags >> HF_SMM_SHIFT) & 1, - cs->halted); + qemu_fprintf(f, "EAX=3D%08x EBX=3D%08x ECX=3D%08x EDX=3D%08x\n" + "ESI=3D%08x EDI=3D%08x EBP=3D%08x ESP=3D%08x\n" + "EIP=3D%08x EFL=3D%08x [%c%c%c%c%c%c%c] CPL=3D%d II= =3D%d A20=3D%d SMM=3D%d HLT=3D%d\n", + (uint32_t)env->regs[R_EAX], + (uint32_t)env->regs[R_EBX], + (uint32_t)env->regs[R_ECX], + (uint32_t)env->regs[R_EDX], + (uint32_t)env->regs[R_ESI], + (uint32_t)env->regs[R_EDI], + (uint32_t)env->regs[R_EBP], + (uint32_t)env->regs[R_ESP], + (uint32_t)env->eip, eflags, + eflags & DF_MASK ? 'D' : '-', + eflags & CC_O ? 'O' : '-', + eflags & CC_S ? 'S' : '-', + eflags & CC_Z ? 'Z' : '-', + eflags & CC_A ? 'A' : '-', + eflags & CC_P ? 'P' : '-', + eflags & CC_C ? 'C' : '-', + env->hflags & HF_CPL_MASK, + (env->hflags >> HF_INHIBIT_IRQ_SHIFT) & 1, + (env->a20_mask >> 20) & 1, + (env->hflags >> HF_SMM_SHIFT) & 1, + cs->halted); } =20 for(i =3D 0; i < 6; i++) { - cpu_x86_dump_seg_cache(env, f, cpu_fprintf, seg_name[i], - &env->segs[i]); + cpu_x86_dump_seg_cache(env, f, seg_name[i], &env->segs[i]); } - cpu_x86_dump_seg_cache(env, f, cpu_fprintf, "LDT", &env->ldt); - cpu_x86_dump_seg_cache(env, f, cpu_fprintf, "TR", &env->tr); + cpu_x86_dump_seg_cache(env, f, "LDT", &env->ldt); + cpu_x86_dump_seg_cache(env, f, "TR", &env->tr); =20 #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { - cpu_fprintf(f, "GDT=3D %016" PRIx64 " %08x\n", - env->gdt.base, env->gdt.limit); - cpu_fprintf(f, "IDT=3D %016" PRIx64 " %08x\n", - env->idt.base, env->idt.limit); - cpu_fprintf(f, "CR0=3D%08x CR2=3D%016" PRIx64 " CR3=3D%016" PRIx64= " CR4=3D%08x\n", - (uint32_t)env->cr[0], - env->cr[2], - env->cr[3], - (uint32_t)env->cr[4]); + qemu_fprintf(f, "GDT=3D %016" PRIx64 " %08x\n", + env->gdt.base, env->gdt.limit); + qemu_fprintf(f, "IDT=3D %016" PRIx64 " %08x\n", + env->idt.base, env->idt.limit); + qemu_fprintf(f, "CR0=3D%08x CR2=3D%016" PRIx64 " CR3=3D%016" PRIx6= 4 " CR4=3D%08x\n", + (uint32_t)env->cr[0], + env->cr[2], + env->cr[3], + (uint32_t)env->cr[4]); for(i =3D 0; i < 4; i++) - cpu_fprintf(f, "DR%d=3D%016" PRIx64 " ", i, env->dr[i]); - cpu_fprintf(f, "\nDR6=3D%016" PRIx64 " DR7=3D%016" PRIx64 "\n", - env->dr[6], env->dr[7]); + qemu_fprintf(f, "DR%d=3D%016" PRIx64 " ", i, env->dr[i]); + qemu_fprintf(f, "\nDR6=3D%016" PRIx64 " DR7=3D%016" PRIx64 "\n", + env->dr[6], env->dr[7]); } else #endif { - cpu_fprintf(f, "GDT=3D %08x %08x\n", - (uint32_t)env->gdt.base, env->gdt.limit); - cpu_fprintf(f, "IDT=3D %08x %08x\n", - (uint32_t)env->idt.base, env->idt.limit); - cpu_fprintf(f, "CR0=3D%08x CR2=3D%08x CR3=3D%08x CR4=3D%08x\n", - (uint32_t)env->cr[0], - (uint32_t)env->cr[2], - (uint32_t)env->cr[3], - (uint32_t)env->cr[4]); + qemu_fprintf(f, "GDT=3D %08x %08x\n", + (uint32_t)env->gdt.base, env->gdt.limit); + qemu_fprintf(f, "IDT=3D %08x %08x\n", + (uint32_t)env->idt.base, env->idt.limit); + qemu_fprintf(f, "CR0=3D%08x CR2=3D%08x CR3=3D%08x CR4=3D%08x\n", + (uint32_t)env->cr[0], + (uint32_t)env->cr[2], + (uint32_t)env->cr[3], + (uint32_t)env->cr[4]); for(i =3D 0; i < 4; i++) { - cpu_fprintf(f, "DR%d=3D" TARGET_FMT_lx " ", i, env->dr[i]); + qemu_fprintf(f, "DR%d=3D" TARGET_FMT_lx " ", i, env->dr[i]); } - cpu_fprintf(f, "\nDR6=3D" TARGET_FMT_lx " DR7=3D" TARGET_FMT_lx "\= n", - env->dr[6], env->dr[7]); + qemu_fprintf(f, "\nDR6=3D" TARGET_FMT_lx " DR7=3D" TARGET_FMT_lx "= \n", + env->dr[6], env->dr[7]); } if (flags & CPU_DUMP_CCOP) { if ((unsigned)env->cc_op < CC_OP_NB) @@ -526,55 +525,55 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprint= f_function cpu_fprintf, snprintf(cc_op_name, sizeof(cc_op_name), "[%d]", env->cc_op); #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { - cpu_fprintf(f, "CCS=3D%016" PRIx64 " CCD=3D%016" PRIx64 " CCO= =3D%-8s\n", - env->cc_src, env->cc_dst, - cc_op_name); + qemu_fprintf(f, "CCS=3D%016" PRIx64 " CCD=3D%016" PRIx64 " CCO= =3D%-8s\n", + env->cc_src, env->cc_dst, + cc_op_name); } else #endif { - cpu_fprintf(f, "CCS=3D%08x CCD=3D%08x CCO=3D%-8s\n", - (uint32_t)env->cc_src, (uint32_t)env->cc_dst, - cc_op_name); + qemu_fprintf(f, "CCS=3D%08x CCD=3D%08x CCO=3D%-8s\n", + (uint32_t)env->cc_src, (uint32_t)env->cc_dst, + cc_op_name); } } - cpu_fprintf(f, "EFER=3D%016" PRIx64 "\n", env->efer); + qemu_fprintf(f, "EFER=3D%016" PRIx64 "\n", env->efer); if (flags & CPU_DUMP_FPU) { int fptag; fptag =3D 0; for(i =3D 0; i < 8; i++) { fptag |=3D ((!env->fptags[i]) << i); } - cpu_fprintf(f, "FCW=3D%04x FSW=3D%04x [ST=3D%d] FTW=3D%02x MXCSR= =3D%08x\n", - env->fpuc, - (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11, - env->fpstt, - fptag, - env->mxcsr); + qemu_fprintf(f, "FCW=3D%04x FSW=3D%04x [ST=3D%d] FTW=3D%02x MXCSR= =3D%08x\n", + env->fpuc, + (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11, + env->fpstt, + fptag, + env->mxcsr); for(i=3D0;i<8;i++) { CPU_LDoubleU u; u.d =3D env->fpregs[i].d; - cpu_fprintf(f, "FPR%d=3D%016" PRIx64 " %04x", - i, u.l.lower, u.l.upper); + qemu_fprintf(f, "FPR%d=3D%016" PRIx64 " %04x", + i, u.l.lower, u.l.upper); if ((i & 1) =3D=3D 1) - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); else - cpu_fprintf(f, " "); + qemu_fprintf(f, " "); } if (env->hflags & HF_CS64_MASK) nb =3D 16; else nb =3D 8; for(i=3D0;ixmm_regs[i].ZMM_L(3), - env->xmm_regs[i].ZMM_L(2), - env->xmm_regs[i].ZMM_L(1), - env->xmm_regs[i].ZMM_L(0)); + qemu_fprintf(f, "XMM%02d=3D%08x%08x%08x%08x", + i, + env->xmm_regs[i].ZMM_L(3), + env->xmm_regs[i].ZMM_L(2), + env->xmm_regs[i].ZMM_L(1), + env->xmm_regs[i].ZMM_L(0)); if ((i & 1) =3D=3D 1) - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); else - cpu_fprintf(f, " "); + qemu_fprintf(f, " "); } } if (flags & CPU_DUMP_CODE) { @@ -583,17 +582,17 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprint= f_function cpu_fprintf, uint8_t code; char codestr[3]; =20 - cpu_fprintf(f, "Code=3D"); + qemu_fprintf(f, "Code=3D"); for (i =3D 0; i < DUMP_CODE_BYTES_TOTAL; i++) { if (cpu_memory_rw_debug(cs, base - offs + i, &code, 1, 0) =3D= =3D 0) { snprintf(codestr, sizeof(codestr), "%02x", code); } else { snprintf(codestr, sizeof(codestr), "??"); } - cpu_fprintf(f, "%s%s%s%s", i > 0 ? " " : "", - i =3D=3D offs ? "<" : "", codestr, i =3D=3D offs ?= ">" : ""); + qemu_fprintf(f, "%s%s%s%s", i > 0 ? " " : "", + i =3D=3D offs ? "<" : "", codestr, i =3D=3D offs = ? ">" : ""); } - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } =20 diff --git a/target/lm32/cpu.h b/target/lm32/cpu.h index b8d539ead8..9b1e6c2d58 100644 --- a/target/lm32/cpu.h +++ b/target/lm32/cpu.h @@ -219,8 +219,7 @@ extern const struct VMStateDescription vmstate_lm32_cpu; =20 void lm32_cpu_do_interrupt(CPUState *cpu); bool lm32_cpu_exec_interrupt(CPUState *cs, int int_req); -void lm32_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fpri= ntf, - int flags); +void lm32_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr lm32_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int lm32_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int lm32_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/lm32/translate.c b/target/lm32/translate.c index b32feb7564..b8b5e12e63 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -24,6 +24,7 @@ #include "exec/exec-all.h" #include "exec/translator.h" #include "tcg-op.h" +#include "qemu/qemu-print.h" =20 #include "exec/cpu_ldst.h" #include "hw/lm32/lm32_pic.h" @@ -1161,38 +1162,37 @@ void gen_intermediate_code(CPUState *cs, struct Tra= nslationBlock *tb) #endif } =20 -void lm32_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, - int flags) +void lm32_cpu_dump_state(CPUState *cs, FILE *f, int flags) { LM32CPU *cpu =3D LM32_CPU(cs); CPULM32State *env =3D &cpu->env; int i; =20 - if (!env || !f) { + if (!env) { return; } =20 - cpu_fprintf(f, "IN: PC=3D%x %s\n", - env->pc, lookup_symbol(env->pc)); + qemu_fprintf(f, "IN: PC=3D%x %s\n", + env->pc, lookup_symbol(env->pc)); =20 - cpu_fprintf(f, "ie=3D%8.8x (IE=3D%x EIE=3D%x BIE=3D%x) im=3D%8.8x ip= =3D%8.8x\n", - env->ie, - (env->ie & IE_IE) ? 1 : 0, - (env->ie & IE_EIE) ? 1 : 0, - (env->ie & IE_BIE) ? 1 : 0, - lm32_pic_get_im(env->pic_state), - lm32_pic_get_ip(env->pic_state)); - cpu_fprintf(f, "eba=3D%8.8x deba=3D%8.8x\n", - env->eba, - env->deba); + qemu_fprintf(f, "ie=3D%8.8x (IE=3D%x EIE=3D%x BIE=3D%x) im=3D%8.8x ip= =3D%8.8x\n", + env->ie, + (env->ie & IE_IE) ? 1 : 0, + (env->ie & IE_EIE) ? 1 : 0, + (env->ie & IE_BIE) ? 1 : 0, + lm32_pic_get_im(env->pic_state), + lm32_pic_get_ip(env->pic_state)); + qemu_fprintf(f, "eba=3D%8.8x deba=3D%8.8x\n", + env->eba, + env->deba); =20 for (i =3D 0; i < 32; i++) { - cpu_fprintf(f, "r%2.2d=3D%8.8x ", i, env->regs[i]); + qemu_fprintf(f, "r%2.2d=3D%8.8x ", i, env->regs[i]); if ((i + 1) % 4 =3D=3D 0) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } - cpu_fprintf(f, "\n\n"); + qemu_fprintf(f, "\n\n"); } =20 void restore_state_to_opc(CPULM32State *env, TranslationBlock *tb, diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 73952f6ece..ad41608341 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -179,8 +179,7 @@ static inline M68kCPU *m68k_env_get_cpu(CPUM68KState *e= nv) =20 void m68k_cpu_do_interrupt(CPUState *cpu); bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req); -void m68k_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fpri= ntf, - int flags); +void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int m68k_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 6217a683f1..3b2280b48b 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -24,6 +24,7 @@ #include "exec/exec-all.h" #include "tcg-op.h" #include "qemu/log.h" +#include "qemu/qemu-print.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" =20 @@ -6187,76 +6188,75 @@ static double floatx80_to_double(CPUM68KState *env,= uint16_t high, uint64_t low) return u.d; } =20 -void m68k_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, - int flags) +void m68k_cpu_dump_state(CPUState *cs, FILE *f, int flags) { M68kCPU *cpu =3D M68K_CPU(cs); CPUM68KState *env =3D &cpu->env; int i; uint16_t sr; for (i =3D 0; i < 8; i++) { - cpu_fprintf(f, "D%d =3D %08x A%d =3D %08x " - "F%d =3D %04x %016"PRIx64" (%12g)\n", - i, env->dregs[i], i, env->aregs[i], - i, env->fregs[i].l.upper, env->fregs[i].l.lower, - floatx80_to_double(env, env->fregs[i].l.upper, - env->fregs[i].l.lower)); + qemu_fprintf(f, "D%d =3D %08x A%d =3D %08x " + "F%d =3D %04x %016"PRIx64" (%12g)\n", + i, env->dregs[i], i, env->aregs[i], + i, env->fregs[i].l.upper, env->fregs[i].l.lower, + floatx80_to_double(env, env->fregs[i].l.upper, + env->fregs[i].l.lower)); } - cpu_fprintf (f, "PC =3D %08x ", env->pc); + qemu_fprintf(f, "PC =3D %08x ", env->pc); sr =3D env->sr | cpu_m68k_get_ccr(env); - cpu_fprintf(f, "SR =3D %04x T:%x I:%x %c%c %c%c%c%c%c\n", - sr, (sr & SR_T) >> SR_T_SHIFT, (sr & SR_I) >> SR_I_SHIFT, - (sr & SR_S) ? 'S' : 'U', (sr & SR_M) ? '%' : 'I', - (sr & CCF_X) ? 'X' : '-', (sr & CCF_N) ? 'N' : '-', - (sr & CCF_Z) ? 'Z' : '-', (sr & CCF_V) ? 'V' : '-', - (sr & CCF_C) ? 'C' : '-'); - cpu_fprintf(f, "FPSR =3D %08x %c%c%c%c ", env->fpsr, - (env->fpsr & FPSR_CC_A) ? 'A' : '-', - (env->fpsr & FPSR_CC_I) ? 'I' : '-', - (env->fpsr & FPSR_CC_Z) ? 'Z' : '-', - (env->fpsr & FPSR_CC_N) ? 'N' : '-'); - cpu_fprintf(f, "\n " - "FPCR =3D %04x ", env->fpcr); + qemu_fprintf(f, "SR =3D %04x T:%x I:%x %c%c %c%c%c%c%c\n", + sr, (sr & SR_T) >> SR_T_SHIFT, (sr & SR_I) >> SR_I_SHIFT, + (sr & SR_S) ? 'S' : 'U', (sr & SR_M) ? '%' : 'I', + (sr & CCF_X) ? 'X' : '-', (sr & CCF_N) ? 'N' : '-', + (sr & CCF_Z) ? 'Z' : '-', (sr & CCF_V) ? 'V' : '-', + (sr & CCF_C) ? 'C' : '-'); + qemu_fprintf(f, "FPSR =3D %08x %c%c%c%c ", env->fpsr, + (env->fpsr & FPSR_CC_A) ? 'A' : '-', + (env->fpsr & FPSR_CC_I) ? 'I' : '-', + (env->fpsr & FPSR_CC_Z) ? 'Z' : '-', + (env->fpsr & FPSR_CC_N) ? 'N' : '-'); + qemu_fprintf(f, "\n " + "FPCR =3D %04x ", env->fpcr); switch (env->fpcr & FPCR_PREC_MASK) { case FPCR_PREC_X: - cpu_fprintf(f, "X "); + qemu_fprintf(f, "X "); break; case FPCR_PREC_S: - cpu_fprintf(f, "S "); + qemu_fprintf(f, "S "); break; case FPCR_PREC_D: - cpu_fprintf(f, "D "); + qemu_fprintf(f, "D "); break; } switch (env->fpcr & FPCR_RND_MASK) { case FPCR_RND_N: - cpu_fprintf(f, "RN "); + qemu_fprintf(f, "RN "); break; case FPCR_RND_Z: - cpu_fprintf(f, "RZ "); + qemu_fprintf(f, "RZ "); break; case FPCR_RND_M: - cpu_fprintf(f, "RM "); + qemu_fprintf(f, "RM "); break; case FPCR_RND_P: - cpu_fprintf(f, "RP "); + qemu_fprintf(f, "RP "); break; } - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); #ifdef CONFIG_SOFTMMU - cpu_fprintf(f, "%sA7(MSP) =3D %08x %sA7(USP) =3D %08x %sA7(ISP) =3D %0= 8x\n", - env->current_sp =3D=3D M68K_SSP ? "->" : " ", env->sp[M68K= _SSP], - env->current_sp =3D=3D M68K_USP ? "->" : " ", env->sp[M68K= _USP], - env->current_sp =3D=3D M68K_ISP ? "->" : " ", env->sp[M68K= _ISP]); - cpu_fprintf(f, "VBR =3D 0x%08x\n", env->vbr); - cpu_fprintf(f, "SFC =3D %x DFC %x\n", env->sfc, env->dfc); - cpu_fprintf(f, "SSW %08x TCR %08x URP %08x SRP %08x\n", - env->mmu.ssw, env->mmu.tcr, env->mmu.urp, env->mmu.srp); - cpu_fprintf(f, "DTTR0/1: %08x/%08x ITTR0/1: %08x/%08x\n", - env->mmu.ttr[M68K_DTTR0], env->mmu.ttr[M68K_DTTR1], - env->mmu.ttr[M68K_ITTR0], env->mmu.ttr[M68K_ITTR1]); - cpu_fprintf(f, "MMUSR %08x, fault at %08x\n", - env->mmu.mmusr, env->mmu.ar); + qemu_fprintf(f, "%sA7(MSP) =3D %08x %sA7(USP) =3D %08x %sA7(ISP) =3D %= 08x\n", + env->current_sp =3D=3D M68K_SSP ? "->" : " ", env->sp[M6= 8K_SSP], + env->current_sp =3D=3D M68K_USP ? "->" : " ", env->sp[M6= 8K_USP], + env->current_sp =3D=3D M68K_ISP ? "->" : " ", env->sp[M6= 8K_ISP]); + qemu_fprintf(f, "VBR =3D 0x%08x\n", env->vbr); + qemu_fprintf(f, "SFC =3D %x DFC %x\n", env->sfc, env->dfc); + qemu_fprintf(f, "SSW %08x TCR %08x URP %08x SRP %08x\n", + env->mmu.ssw, env->mmu.tcr, env->mmu.urp, env->mmu.srp); + qemu_fprintf(f, "DTTR0/1: %08x/%08x ITTR0/1: %08x/%08x\n", + env->mmu.ttr[M68K_DTTR0], env->mmu.ttr[M68K_DTTR1], + env->mmu.ttr[M68K_ITTR0], env->mmu.ttr[M68K_ITTR1]); + qemu_fprintf(f, "MMUSR %08x, fault at %08x\n", + env->mmu.mmusr, env->mmu.ar); #endif } =20 diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index 792bbc97c7..f20e796865 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -328,8 +328,7 @@ static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState = *env) =20 void mb_cpu_do_interrupt(CPUState *cs); bool mb_cpu_exec_interrupt(CPUState *cs, int int_req); -void mb_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprint= f, - int flags); +void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int mb_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index bc753793ec..9848e31d7f 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -42,7 +42,7 @@ int mb_cpu_handle_mmu_fault(CPUState *cs, vaddr address, = int size, int rw, int mmu_idx) { cs->exception_index =3D 0xaa; - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); return 1; } =20 diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 78ca265b04..bc2712ddbd 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -28,6 +28,7 @@ #include "exec/cpu_ldst.h" #include "exec/helper-gen.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" =20 #include "trace-tcg.h" #include "exec/log.h" @@ -1785,36 +1786,36 @@ void gen_intermediate_code(CPUState *cs, struct Tra= nslationBlock *tb) assert(!dc->abort_at_next_insn); } =20 -void mb_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, - int flags) +void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags) { MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); CPUMBState *env =3D &cpu->env; int i; =20 - if (!env || !f) + if (!env) { return; + } =20 - cpu_fprintf(f, "IN: PC=3D%" PRIx64 " %s\n", - env->sregs[SR_PC], lookup_symbol(env->sregs[SR_PC])); - cpu_fprintf(f, "rmsr=3D%" PRIx64 " resr=3D%" PRIx64 " rear=3D%" PRIx64= " " - "debug=3D%x imm=3D%x iflags=3D%x fsr=3D%" PRIx64 "\n", - env->sregs[SR_MSR], env->sregs[SR_ESR], env->sregs[SR_EAR], - env->debug, env->imm, env->iflags, env->sregs[SR_FSR]); - cpu_fprintf(f, "btaken=3D%d btarget=3D%" PRIx64 " mode=3D%s(saved=3D%s= ) " - "eip=3D%d ie=3D%d\n", - env->btaken, env->btarget, - (env->sregs[SR_MSR] & MSR_UM) ? "user" : "kernel", - (env->sregs[SR_MSR] & MSR_UMS) ? "user" : "kernel", - (bool)(env->sregs[SR_MSR] & MSR_EIP), - (bool)(env->sregs[SR_MSR] & MSR_IE)); + qemu_fprintf(f, "IN: PC=3D%" PRIx64 " %s\n", + env->sregs[SR_PC], lookup_symbol(env->sregs[SR_PC])); + qemu_fprintf(f, "rmsr=3D%" PRIx64 " resr=3D%" PRIx64 " rear=3D%" PRIx6= 4 " " + "debug=3D%x imm=3D%x iflags=3D%x fsr=3D%" PRIx64 "\n", + env->sregs[SR_MSR], env->sregs[SR_ESR], env->sregs[SR_EAR= ], + env->debug, env->imm, env->iflags, env->sregs[SR_FSR]); + qemu_fprintf(f, "btaken=3D%d btarget=3D%" PRIx64 " mode=3D%s(saved=3D%= s) " + "eip=3D%d ie=3D%d\n", + env->btaken, env->btarget, + (env->sregs[SR_MSR] & MSR_UM) ? "user" : "kernel", + (env->sregs[SR_MSR] & MSR_UMS) ? "user" : "kernel", + (bool)(env->sregs[SR_MSR] & MSR_EIP), + (bool)(env->sregs[SR_MSR] & MSR_IE)); =20 for (i =3D 0; i < 32; i++) { - cpu_fprintf(f, "r%2.2d=3D%8.8x ", i, env->regs[i]); + qemu_fprintf(f, "r%2.2d=3D%8.8x ", i, env->regs[i]); if ((i + 1) % 4 =3D=3D 0) - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } - cpu_fprintf(f, "\n\n"); + qemu_fprintf(f, "\n\n"); } =20 void mb_tcg_init(void) diff --git a/target/mips/internal.h b/target/mips/internal.h index 8f6fc919d5..286e3888ab 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -76,8 +76,7 @@ enum CPUMIPSMSADataFormat { =20 void mips_cpu_do_interrupt(CPUState *cpu); bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req); -void mips_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fpri= ntf, - int flags); +void mips_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr mips_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int mips_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int mips_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/mips/translate.c b/target/mips/translate.c index d886a0c9b2..7849d53977 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -29728,8 +29728,7 @@ void gen_intermediate_code(CPUState *cs, struct Tra= nslationBlock *tb) translator_loop(&mips_tr_ops, &ctx.base, cs, tb); } =20 -static void fpu_dump_state(CPUMIPSState *env, FILE *f, fprintf_function fp= u_fprintf, - int flags) +static void fpu_dump_state(CPUMIPSState *env, FILE *f, int flags) { int i; int is_fpu64 =3D !!(env->hflags & MIPS_HFLAG_F64); @@ -29737,68 +29736,69 @@ static void fpu_dump_state(CPUMIPSState *env, FIL= E *f, fprintf_function fpu_fpri #define printfpr(fp) \ do { \ if (is_fpu64) \ - fpu_fprintf(f, "w:%08x d:%016" PRIx64 \ - " fd:%13g fs:%13g psu: %13g\n", \ - (fp)->w[FP_ENDIAN_IDX], (fp)->d, \ - (double)(fp)->fd, \ - (double)(fp)->fs[FP_ENDIAN_IDX], \ - (double)(fp)->fs[!FP_ENDIAN_IDX]); \ + qemu_fprintf(f, "w:%08x d:%016" PRIx64 \ + " fd:%13g fs:%13g psu: %13g\n", \ + (fp)->w[FP_ENDIAN_IDX], (fp)->d, \ + (double)(fp)->fd, \ + (double)(fp)->fs[FP_ENDIAN_IDX], \ + (double)(fp)->fs[!FP_ENDIAN_IDX]); \ else { \ fpr_t tmp; \ tmp.w[FP_ENDIAN_IDX] =3D (fp)->w[FP_ENDIAN_IDX]; \ tmp.w[!FP_ENDIAN_IDX] =3D ((fp) + 1)->w[FP_ENDIAN_IDX]; \ - fpu_fprintf(f, "w:%08x d:%016" PRIx64 \ - " fd:%13g fs:%13g psu:%13g\n", \ - tmp.w[FP_ENDIAN_IDX], tmp.d, \ - (double)tmp.fd, \ - (double)tmp.fs[FP_ENDIAN_IDX], \ - (double)tmp.fs[!FP_ENDIAN_IDX]); \ + qemu_fprintf(f, "w:%08x d:%016" PRIx64 \ + " fd:%13g fs:%13g psu:%13g\n", \ + tmp.w[FP_ENDIAN_IDX], tmp.d, \ + (double)tmp.fd, \ + (double)tmp.fs[FP_ENDIAN_IDX], \ + (double)tmp.fs[!FP_ENDIAN_IDX]); \ } \ } while(0) =20 =20 - fpu_fprintf(f, "CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%= 02x\n", - env->active_fpu.fcr0, env->active_fpu.fcr31, is_fpu64, - get_float_exception_flags(&env->active_fpu.fp_status)); + qemu_fprintf(f, + "CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%02= x\n", + env->active_fpu.fcr0, env->active_fpu.fcr31, is_fpu64, + get_float_exception_flags(&env->active_fpu.fp_status)); for (i =3D 0; i < 32; (is_fpu64) ? i++ : (i +=3D 2)) { - fpu_fprintf(f, "%3s: ", fregnames[i]); + qemu_fprintf(f, "%3s: ", fregnames[i]); printfpr(&env->active_fpu.fpr[i]); } =20 #undef printfpr } =20 -void mips_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, - int flags) +void mips_cpu_dump_state(CPUState *cs, FILE *f, int flags) { MIPSCPU *cpu =3D MIPS_CPU(cs); CPUMIPSState *env =3D &cpu->env; int i; =20 - cpu_fprintf(f, "pc=3D0x" TARGET_FMT_lx " HI=3D0x" TARGET_FMT_lx - " LO=3D0x" TARGET_FMT_lx " ds %04x " - TARGET_FMT_lx " " TARGET_FMT_ld "\n", - env->active_tc.PC, env->active_tc.HI[0], env->active_tc.LO= [0], - env->hflags, env->btarget, env->bcond); + qemu_fprintf(f, "pc=3D0x" TARGET_FMT_lx " HI=3D0x" TARGET_FMT_lx + " LO=3D0x" TARGET_FMT_lx " ds %04x " + TARGET_FMT_lx " " TARGET_FMT_ld "\n", + env->active_tc.PC, env->active_tc.HI[0], env->active_tc.L= O[0], + env->hflags, env->btarget, env->bcond); for (i =3D 0; i < 32; i++) { if ((i & 3) =3D=3D 0) - cpu_fprintf(f, "GPR%02d:", i); - cpu_fprintf(f, " %s " TARGET_FMT_lx, regnames[i], env->active_tc.g= pr[i]); + qemu_fprintf(f, "GPR%02d:", i); + qemu_fprintf(f, " %s " TARGET_FMT_lx, + regnames[i], env->active_tc.gpr[i]); if ((i & 3) =3D=3D 3) - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } =20 - cpu_fprintf(f, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_FM= T_lx "\n", - env->CP0_Status, env->CP0_Cause, env->CP0_EPC); - cpu_fprintf(f, " Config0 0x%08x Config1 0x%08x LLAddr 0x%016" - PRIx64 "\n", - env->CP0_Config0, env->CP0_Config1, env->CP0_LLAddr); - cpu_fprintf(f, " Config2 0x%08x Config3 0x%08x\n", - env->CP0_Config2, env->CP0_Config3); - cpu_fprintf(f, " Config4 0x%08x Config5 0x%08x\n", - env->CP0_Config4, env->CP0_Config5); + qemu_fprintf(f, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" TARGET_F= MT_lx "\n", + env->CP0_Status, env->CP0_Cause, env->CP0_EPC); + qemu_fprintf(f, " Config0 0x%08x Config1 0x%08x LLAddr 0x%016" + PRIx64 "\n", + env->CP0_Config0, env->CP0_Config1, env->CP0_LLAddr); + qemu_fprintf(f, " Config2 0x%08x Config3 0x%08x\n", + env->CP0_Config2, env->CP0_Config3); + qemu_fprintf(f, " Config4 0x%08x Config5 0x%08x\n", + env->CP0_Config4, env->CP0_Config5); if ((flags & CPU_DUMP_FPU) && (env->hflags & MIPS_HFLAG_FPU)) { - fpu_dump_state(env, f, cpu_fprintf, flags); + fpu_dump_state(env, f, flags); } } =20 diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h index 080df4ee6f..f3b6d83ae7 100644 --- a/target/moxie/cpu.h +++ b/target/moxie/cpu.h @@ -112,8 +112,7 @@ static inline MoxieCPU *moxie_env_get_cpu(CPUMoxieState= *env) #define ENV_OFFSET offsetof(MoxieCPU, env) =20 void moxie_cpu_do_interrupt(CPUState *cs); -void moxie_cpu_dump_state(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); +void moxie_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr moxie_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void moxie_translate_init(void); int cpu_moxie_signal_handler(int host_signum, void *pinfo, diff --git a/target/moxie/helper.c b/target/moxie/helper.c index f3d8ee7d6b..287a45232c 100644 --- a/target/moxie/helper.c +++ b/target/moxie/helper.c @@ -101,7 +101,7 @@ int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr addr= ess, int size, =20 cs->exception_index =3D 0xaa; cpu->env.debug1 =3D address; - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); return 1; } =20 diff --git a/target/moxie/translate.c b/target/moxie/translate.c index 68ca223e22..dd055c4ca5 100644 --- a/target/moxie/translate.c +++ b/target/moxie/translate.c @@ -28,6 +28,7 @@ #include "disas/disas.h" #include "tcg-op.h" #include "exec/cpu_ldst.h" +#include "qemu/qemu-print.h" =20 #include "exec/helper-proto.h" #include "exec/helper-gen.h" @@ -69,24 +70,23 @@ static int extract_branch_offset(int opcode) return (((signed short)((opcode & ((1 << 10) - 1)) << 6)) >> 6) << 1; } =20 -void moxie_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fpri= ntf, - int flags) +void moxie_cpu_dump_state(CPUState *cs, FILE *f, int flags) { MoxieCPU *cpu =3D MOXIE_CPU(cs); CPUMoxieState *env =3D &cpu->env; int i; - cpu_fprintf(f, "pc=3D0x%08x\n", env->pc); - cpu_fprintf(f, "$fp=3D0x%08x $sp=3D0x%08x $r0=3D0x%08x $r1=3D0x%08x\n", - env->gregs[0], env->gregs[1], env->gregs[2], env->gregs[3]= ); + qemu_fprintf(f, "pc=3D0x%08x\n", env->pc); + qemu_fprintf(f, "$fp=3D0x%08x $sp=3D0x%08x $r0=3D0x%08x $r1=3D0x%08x\n= ", + env->gregs[0], env->gregs[1], env->gregs[2], env->gregs[3= ]); for (i =3D 4; i < 16; i +=3D 4) { - cpu_fprintf(f, "$r%d=3D0x%08x $r%d=3D0x%08x $r%d=3D0x%08x $r%d=3D0= x%08x\n", - i-2, env->gregs[i], i-1, env->gregs[i + 1], - i, env->gregs[i + 2], i+1, env->gregs[i + 3]); + qemu_fprintf(f, "$r%d=3D0x%08x $r%d=3D0x%08x $r%d=3D0x%08x $r%d=3D= 0x%08x\n", + i - 2, env->gregs[i], i - 1, env->gregs[i + 1], + i, env->gregs[i + 2], i + 1, env->gregs[i + 3]); } for (i =3D 4; i < 16; i +=3D 4) { - cpu_fprintf(f, "sr%d=3D0x%08x sr%d=3D0x%08x sr%d=3D0x%08x sr%d=3D0= x%08x\n", - i-2, env->sregs[i], i-1, env->sregs[i + 1], - i, env->sregs[i + 2], i+1, env->sregs[i + 3]); + qemu_fprintf(f, "sr%d=3D0x%08x sr%d=3D0x%08x sr%d=3D0x%08x sr%d=3D= 0x%08x\n", + i - 2, env->sregs[i], i - 1, env->sregs[i + 1], + i, env->sregs[i + 2], i + 1, env->sregs[i + 3]); } } =20 diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 6fa993bb0d..4e8eb7d2ca 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -213,8 +213,7 @@ void nios2_tcg_init(void); void nios2_cpu_do_interrupt(CPUState *cs); int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc); void dump_mmu(CPUNios2State *env); -void nios2_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fpr= intf, - int flags); +void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/nios2/helper.c b/target/nios2/helper.c index a8b8ec662a..a633fa03ee 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -42,7 +42,7 @@ int nios2_cpu_handle_mmu_fault(CPUState *cs, vaddr addres= s, int size, cs->exception_index =3D 0xaa; /* Page 0x1000 is kuser helper */ if (address < 0x1000 || address >=3D 0x2000) { - cpu_dump_state(cs, stderr, fprintf, 0); + cpu_dump_state(cs, stderr, 0); } return 1; } diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 7fa03ed05a..f0bbf78a32 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -31,6 +31,7 @@ #include "exec/log.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" =20 /* is_jmp field values */ #define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */ @@ -914,33 +915,32 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb) #endif } =20 -void nios2_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fpri= ntf, - int flags) +void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) { Nios2CPU *cpu =3D NIOS2_CPU(cs); CPUNios2State *env =3D &cpu->env; int i; =20 - if (!env || !f) { + if (!env) { return; } =20 - cpu_fprintf(f, "IN: PC=3D%x %s\n", - env->regs[R_PC], lookup_symbol(env->regs[R_PC])); + qemu_fprintf(f, "IN: PC=3D%x %s\n", + env->regs[R_PC], lookup_symbol(env->regs[R_PC])); =20 for (i =3D 0; i < NUM_CORE_REGS; i++) { - cpu_fprintf(f, "%9s=3D%8.8x ", regnames[i], env->regs[i]); + qemu_fprintf(f, "%9s=3D%8.8x ", regnames[i], env->regs[i]); if ((i + 1) % 4 =3D=3D 0) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } #if !defined(CONFIG_USER_ONLY) - cpu_fprintf(f, " mmu write: VPN=3D%05X PID %02X TLBACC %08X\n", - env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK, - (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4, - env->mmu.tlbacc_wr); + qemu_fprintf(f, " mmu write: VPN=3D%05X PID %02X TLBACC %08X\n", + env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK, + (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4, + env->mmu.tlbacc_wr); #endif - cpu_fprintf(f, "\n\n"); + qemu_fprintf(f, "\n\n"); } =20 void nios2_tcg_init(void) diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 9d2d49631e..a50861955a 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -339,8 +339,7 @@ static inline OpenRISCCPU *openrisc_env_get_cpu(CPUOpen= RISCState *env) void cpu_openrisc_list(void); void openrisc_cpu_do_interrupt(CPUState *cpu); bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req); -void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); +void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int openrisc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 89680f882d..a88502fdc1 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -26,6 +26,7 @@ #include "qemu-common.h" #include "qemu/log.h" #include "qemu/bitops.h" +#include "qemu/qemu-print.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" =20 @@ -1415,18 +1416,16 @@ void gen_intermediate_code(CPUState *cs, struct Tra= nslationBlock *tb) translator_loop(&openrisc_tr_ops, &ctx.base, cs, tb); } =20 -void openrisc_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, - int flags) +void openrisc_cpu_dump_state(CPUState *cs, FILE *f, int flags) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); CPUOpenRISCState *env =3D &cpu->env; int i; =20 - cpu_fprintf(f, "PC=3D%08x\n", env->pc); + qemu_fprintf(f, "PC=3D%08x\n", env->pc); for (i =3D 0; i < 32; ++i) { - cpu_fprintf(f, "R%02d=3D%08x%c", i, cpu_get_gpr(env, i), - (i % 4) =3D=3D 3 ? '\n' : ' '); + qemu_fprintf(f, "R%02d=3D%08x%c", i, cpu_get_gpr(env, i), + (i % 4) =3D=3D 3 ? '\n' : ' '); } } =20 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 27a36b9605..d5259f7dd3 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1268,8 +1268,7 @@ struct PPCVirtualHypervisorClass { =20 void ppc_cpu_do_interrupt(CPUState *cpu); bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req); -void ppc_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprin= tf, - int flags); +void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); void ppc_cpu_dump_statistics(CPUState *cpu, int flags); hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int ppc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/ppc/translate.c b/target/ppc/translate.c index f99f27a134..93d77a2626 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7414,8 +7414,7 @@ GEN_HANDLER2_E(trechkpt, "trechkpt", 0x1F, 0x0E, 0x1F= , 0x03FFF800, \ =20 /*************************************************************************= ****/ /* Misc PowerPC helpers */ -void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprint= f, - int flags) +void ppc_cpu_dump_state(CPUState *cs, FILE *f, int flags) { #define RGPL 4 #define RFPL 4 @@ -7424,37 +7423,37 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fpri= ntf_function cpu_fprintf, CPUPPCState *env =3D &cpu->env; int i; =20 - cpu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR " - TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n", - env->nip, env->lr, env->ctr, cpu_read_xer(env), - cs->cpu_index); - cpu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF " - TARGET_FMT_lx " iidx %d didx %d\n", - env->msr, env->spr[SPR_HID0], - env->hflags, env->immu_idx, env->dmmu_idx); + qemu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR " + TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n", + env->nip, env->lr, env->ctr, cpu_read_xer(env), + cs->cpu_index); + qemu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF " + TARGET_FMT_lx " iidx %d didx %d\n", + env->msr, env->spr[SPR_HID0], + env->hflags, env->immu_idx, env->dmmu_idx); #if !defined(NO_TIMER_DUMP) - cpu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 + qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 #if !defined(CONFIG_USER_ONLY) - " DECR " TARGET_FMT_lu + " DECR " TARGET_FMT_lu #endif - "\n", - cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) + "\n", + cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) #if !defined(CONFIG_USER_ONLY) - , cpu_ppc_load_decr(env) + , cpu_ppc_load_decr(env) #endif - ); + ); #endif for (i =3D 0; i < 32; i++) { if ((i & (RGPL - 1)) =3D=3D 0) - cpu_fprintf(f, "GPR%02d", i); - cpu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i)); + qemu_fprintf(f, "GPR%02d", i); + qemu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i)); if ((i & (RGPL - 1)) =3D=3D (RGPL - 1)) - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } - cpu_fprintf(f, "CR "); + qemu_fprintf(f, "CR "); for (i =3D 0; i < 8; i++) - cpu_fprintf(f, "%01x", env->crf[i]); - cpu_fprintf(f, " ["); + qemu_fprintf(f, "%01x", env->crf[i]); + qemu_fprintf(f, " ["); for (i =3D 0; i < 8; i++) { char a =3D '-'; if (env->crf[i] & 0x08) @@ -7463,74 +7462,74 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fpri= ntf_function cpu_fprintf, a =3D 'G'; else if (env->crf[i] & 0x02) a =3D 'E'; - cpu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); + qemu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); } - cpu_fprintf(f, " ] RES " TARGET_FMT_lx "\n", - env->reserve_addr); + qemu_fprintf(f, " ] RES " TARGET_FMT_lx "\n", + env->reserve_addr); =20 if (flags & CPU_DUMP_FPU) { for (i =3D 0; i < 32; i++) { if ((i & (RFPL - 1)) =3D=3D 0) { - cpu_fprintf(f, "FPR%02d", i); + qemu_fprintf(f, "FPR%02d", i); } - cpu_fprintf(f, " %016" PRIx64, *cpu_fpr_ptr(env, i)); + qemu_fprintf(f, " %016" PRIx64, *cpu_fpr_ptr(env, i)); if ((i & (RFPL - 1)) =3D=3D (RFPL - 1)) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } - cpu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr); + qemu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr); } =20 #if !defined(CONFIG_USER_ONLY) - cpu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx - " PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n", - env->spr[SPR_SRR0], env->spr[SPR_SRR1], - env->spr[SPR_PVR], env->spr[SPR_VRSAVE]); + qemu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx + " PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n", + env->spr[SPR_SRR0], env->spr[SPR_SRR1], + env->spr[SPR_PVR], env->spr[SPR_VRSAVE]); =20 - cpu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx - " SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n", - env->spr[SPR_SPRG0], env->spr[SPR_SPRG1], - env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]); + qemu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx + " SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n", + env->spr[SPR_SPRG0], env->spr[SPR_SPRG1], + env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]); =20 - cpu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx - " SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n", - env->spr[SPR_SPRG4], env->spr[SPR_SPRG5], - env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]); + qemu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx + " SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n", + env->spr[SPR_SPRG4], env->spr[SPR_SPRG5], + env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]); =20 #if defined(TARGET_PPC64) if (env->excp_model =3D=3D POWERPC_EXCP_POWER7 || env->excp_model =3D=3D POWERPC_EXCP_POWER8 || env->excp_model =3D=3D POWERPC_EXCP_POWER9) { - cpu_fprintf(f, "HSRR0 " TARGET_FMT_lx " HSRR1 " TARGET_FMT_lx "\n", - env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]); + qemu_fprintf(f, "HSRR0 " TARGET_FMT_lx " HSRR1 " TARGET_FMT_lx "\n= ", + env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]); } #endif if (env->excp_model =3D=3D POWERPC_EXCP_BOOKE) { - cpu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx - " MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "= \n", - env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1], - env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]= ); + qemu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx + " MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n= ", + env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1], + env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1= ]); =20 - cpu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx - " ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "= \n", - env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR], - env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]); + qemu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx + " ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n= ", + env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR], + env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]); =20 - cpu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx - " IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "= \n", - env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR], - env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]); + qemu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx + " IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n= ", + env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR], + env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]); =20 - cpu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx - " EPR " TARGET_FMT_lx "\n", - env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8], - env->spr[SPR_BOOKE_EPR]); + qemu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx + " EPR " TARGET_FMT_lx "\n", + env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8], + env->spr[SPR_BOOKE_EPR]); =20 /* FSL-specific */ - cpu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx - " PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "= \n", - env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1], - env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]); + qemu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx + " PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n= ", + env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1], + env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]); =20 /* * IVORs are left out as they are large and do not change often -- @@ -7540,12 +7539,12 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fpri= ntf_function cpu_fprintf, =20 #if defined(TARGET_PPC64) if (env->flags & POWERPC_FLAG_CFAR) { - cpu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar); + qemu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar); } #endif =20 if (env->spr_cb[SPR_LPCR].name) - cpu_fprintf(f, " LPCR " TARGET_FMT_lx "\n", env->spr[SPR_LPCR]); + qemu_fprintf(f, " LPCR " TARGET_FMT_lx "\n", env->spr[SPR_LPCR]); =20 switch (env->mmu_model) { case POWERPC_MMU_32B: @@ -7560,29 +7559,29 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fpri= ntf_function cpu_fprintf, case POWERPC_MMU_3_00: #endif if (env->spr_cb[SPR_SDR1].name) { /* SDR1 Exists */ - cpu_fprintf(f, " SDR1 " TARGET_FMT_lx " ", env->spr[SPR_SDR1]); + qemu_fprintf(f, " SDR1 " TARGET_FMT_lx " ", env->spr[SPR_SDR1]= ); } if (env->spr_cb[SPR_PTCR].name) { /* PTCR Exists */ - cpu_fprintf(f, " PTCR " TARGET_FMT_lx " ", env->spr[SPR_PTCR]); + qemu_fprintf(f, " PTCR " TARGET_FMT_lx " ", env->spr[SPR_PTCR]= ); } - cpu_fprintf(f, " DAR " TARGET_FMT_lx " DSISR " TARGET_FMT_lx "\n= ", - env->spr[SPR_DAR], env->spr[SPR_DSISR]); + qemu_fprintf(f, " DAR " TARGET_FMT_lx " DSISR " TARGET_FMT_lx "\= n", + env->spr[SPR_DAR], env->spr[SPR_DSISR]); break; case POWERPC_MMU_BOOKE206: - cpu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx - " MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "= \n", - env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1], - env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]); + qemu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx + " MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n= ", + env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1], + env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]); =20 - cpu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx - " MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "= \n", - env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6], - env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]); + qemu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx + " MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n= ", + env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6], + env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]); =20 - cpu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx - " TLB1CFG " TARGET_FMT_lx "\n", - env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG], - env->spr[SPR_BOOKE_TLB1CFG]); + qemu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx + " TLB1CFG " TARGET_FMT_lx "\n", + env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG], + env->spr[SPR_BOOKE_TLB1CFG]); break; default: break; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 104e676ab0..1bcf4eaeb8 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -194,40 +194,39 @@ static ObjectClass *riscv_cpu_class_by_name(const cha= r *cpu_model) return oc; } =20 -static void riscv_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; int i; =20 - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "pc ", env->pc); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "pc ", env->pc); #ifndef CONFIG_USER_ONLY - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid); - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", env->mstatus); - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ", - (target_ulong)atomic_read(&env->mip)); - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mie ", env->mie); - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mideleg ", env->mideleg); - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "medeleg ", env->medeleg); - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtvec ", env->mtvec); - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mepc ", env->mepc); - cpu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mcause ", env->mcause); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", env->mstatus); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ", + (target_ulong)atomic_read(&env->mip)); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mie ", env->mie); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mideleg ", env->mideleg); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "medeleg ", env->medeleg); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtvec ", env->mtvec); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mepc ", env->mepc); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mcause ", env->mcause); #endif =20 for (i =3D 0; i < 32; i++) { - cpu_fprintf(f, " %s " TARGET_FMT_lx, - riscv_int_regnames[i], env->gpr[i]); + qemu_fprintf(f, " %s " TARGET_FMT_lx, + riscv_int_regnames[i], env->gpr[i]); if ((i & 3) =3D=3D 3) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } if (flags & CPU_DUMP_FPU) { for (i =3D 0; i < 32; i++) { - cpu_fprintf(f, " %s %016" PRIx64, - riscv_fpr_regnames[i], env->fpr[i]); + qemu_fprintf(f, " %s %016" PRIx64, + riscv_fpr_regnames[i], env->fpr[i]); if ((i & 3) =3D=3D 3) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } } diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 8e9573221c..f957a2c830 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -23,6 +23,7 @@ #include "internal.h" #include "exec/gdbstub.h" #include "qemu/timer.h" +#include "qemu/qemu-print.h" #include "hw/s390x/ioinst.h" #include "sysemu/hw_accel.h" #ifndef CONFIG_USER_ONLY @@ -313,65 +314,64 @@ int s390_store_adtl_status(S390CPU *cpu, hwaddr addr,= hwaddr len) } #endif /* CONFIG_USER_ONLY */ =20 -void s390_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprin= tf, - int flags) +void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags) { S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; int i; =20 if (env->cc_op > 3) { - cpu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64 " cc %= 15s\n", - env->psw.mask, env->psw.addr, cc_name(env->cc_op)); + qemu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64 " cc = %15s\n", + env->psw.mask, env->psw.addr, cc_name(env->cc_op)); } else { - cpu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64 " cc %= 02x\n", - env->psw.mask, env->psw.addr, env->cc_op); + qemu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64 " cc = %02x\n", + env->psw.mask, env->psw.addr, env->cc_op); } =20 for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "R%02d=3D%016" PRIx64, i, env->regs[i]); + qemu_fprintf(f, "R%02d=3D%016" PRIx64, i, env->regs[i]); if ((i % 4) =3D=3D 3) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } else { - cpu_fprintf(f, " "); + qemu_fprintf(f, " "); } } =20 if (flags & CPU_DUMP_FPU) { if (s390_has_feat(S390_FEAT_VECTOR)) { for (i =3D 0; i < 32; i++) { - cpu_fprintf(f, "V%02d=3D%016" PRIx64 "%016" PRIx64 "%c", - i, env->vregs[i][0].ll, env->vregs[i][1].ll, - i % 2 ? '\n' : ' '); + qemu_fprintf(f, "V%02d=3D%016" PRIx64 "%016" PRIx64 "%c", + i, env->vregs[i][0].ll, env->vregs[i][1].ll, + i % 2 ? '\n' : ' '); } } else { for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "F%02d=3D%016" PRIx64 "%c", - i, get_freg(env, i)->ll, - (i % 4) =3D=3D 3 ? '\n' : ' '); + qemu_fprintf(f, "F%02d=3D%016" PRIx64 "%c", + i, get_freg(env, i)->ll, + (i % 4) =3D=3D 3 ? '\n' : ' '); } } } =20 #ifndef CONFIG_USER_ONLY for (i =3D 0; i < 16; i++) { - cpu_fprintf(f, "C%02d=3D%016" PRIx64, i, env->cregs[i]); + qemu_fprintf(f, "C%02d=3D%016" PRIx64, i, env->cregs[i]); if ((i % 4) =3D=3D 3) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } else { - cpu_fprintf(f, " "); + qemu_fprintf(f, " "); } } #endif =20 #ifdef DEBUG_INLINE_BRANCHES for (i =3D 0; i < CC_OP_MAX; i++) { - cpu_fprintf(f, " %15s =3D %10ld\t%10ld\n", cc_name(i), - inline_branch_miss[i], inline_branch_hit[i]); + qemu_fprintf(f, " %15s =3D %10ld\t%10ld\n", cc_name(i), + inline_branch_miss[i], inline_branch_hit[i]); } #endif =20 - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } =20 const char *cc_name(enum cc_op cc_op) diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 3b4855c175..26575f2130 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -292,8 +292,7 @@ void s390_cpu_gdb_init(CPUState *cs); =20 =20 /* helper.c */ -void s390_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fpri= ntf, - int flags); +void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr s390_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); hwaddr s390_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr); uint64_t get_psw_mask(CPUS390XState *env); diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 3e43f0a1a5..84b08ff640 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -232,8 +232,7 @@ static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *en= v) =20 void superh_cpu_do_interrupt(CPUState *cpu); bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req); -void superh_cpu_dump_state(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); +void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int superh_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/sh4/translate.c b/target/sh4/translate.c index ab254b0e8d..cffc6919d0 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -30,6 +30,7 @@ #include "exec/translator.h" #include "trace-tcg.h" #include "exec/log.h" +#include "qemu/qemu-print.h" =20 =20 typedef struct DisasContext { @@ -156,32 +157,32 @@ void sh4_translate_init(void) fregnames[i]); } =20 -void superh_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +void superh_cpu_dump_state(CPUState *cs, FILE *f, int flags) { SuperHCPU *cpu =3D SUPERH_CPU(cs); CPUSH4State *env =3D &cpu->env; int i; - cpu_fprintf(f, "pc=3D0x%08x sr=3D0x%08x pr=3D0x%08x fpscr=3D0x%08x\n", - env->pc, cpu_read_sr(env), env->pr, env->fpscr); - cpu_fprintf(f, "spc=3D0x%08x ssr=3D0x%08x gbr=3D0x%08x vbr=3D0x%08x\n", - env->spc, env->ssr, env->gbr, env->vbr); - cpu_fprintf(f, "sgr=3D0x%08x dbr=3D0x%08x delayed_pc=3D0x%08x fpul=3D0= x%08x\n", - env->sgr, env->dbr, env->delayed_pc, env->fpul); + + qemu_fprintf(f, "pc=3D0x%08x sr=3D0x%08x pr=3D0x%08x fpscr=3D0x%08x\n", + env->pc, cpu_read_sr(env), env->pr, env->fpscr); + qemu_fprintf(f, "spc=3D0x%08x ssr=3D0x%08x gbr=3D0x%08x vbr=3D0x%08x\n= ", + env->spc, env->ssr, env->gbr, env->vbr); + qemu_fprintf(f, "sgr=3D0x%08x dbr=3D0x%08x delayed_pc=3D0x%08x fpul=3D= 0x%08x\n", + env->sgr, env->dbr, env->delayed_pc, env->fpul); for (i =3D 0; i < 24; i +=3D 4) { - cpu_fprintf(f, "r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08x\n", + qemu_printf("r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08x\n= ", i, env->gregs[i], i + 1, env->gregs[i + 1], i + 2, env->gregs[i + 2], i + 3, env->gregs[i + 3]); } if (env->flags & DELAY_SLOT) { - cpu_fprintf(f, "in delay slot (delayed_pc=3D0x%08x)\n", + qemu_printf("in delay slot (delayed_pc=3D0x%08x)\n", env->delayed_pc); } else if (env->flags & DELAY_SLOT_CONDITIONAL) { - cpu_fprintf(f, "in conditional delay slot (delayed_pc=3D0x%08x)\n", + qemu_printf("in conditional delay slot (delayed_pc=3D0x%08x)\n", env->delayed_pc); } else if (env->flags & DELAY_SLOT_RTE) { - cpu_fprintf(f, "in rte delay slot (delayed_pc=3D0x%08x)\n", - env->delayed_pc); + qemu_fprintf(f, "in rte delay slot (delayed_pc=3D0x%08x)\n", + env->delayed_pc); } } =20 diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index fd88a31806..4654c2a6a0 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -596,12 +596,11 @@ void sparc_cpu_list(void) "fpu_version mmu_version nwindows\n"); } =20 -static void cpu_print_cc(FILE *f, fprintf_function cpu_fprintf, - uint32_t cc) +static void cpu_print_cc(FILE *f, uint32_t cc) { - cpu_fprintf(f, "%c%c%c%c", cc & PSR_NEG ? 'N' : '-', - cc & PSR_ZERO ? 'Z' : '-', cc & PSR_OVF ? 'V' : '-', - cc & PSR_CARRY ? 'C' : '-'); + qemu_fprintf(f, "%c%c%c%c", cc & PSR_NEG ? 'N' : '-', + cc & PSR_ZERO ? 'Z' : '-', cc & PSR_OVF ? 'V' : '-', + cc & PSR_CARRY ? 'C' : '-'); } =20 #ifdef TARGET_SPARC64 @@ -610,35 +609,34 @@ static void cpu_print_cc(FILE *f, fprintf_function cp= u_fprintf, #define REGS_PER_LINE 8 #endif =20 -void sparc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fpri= ntf, - int flags) +void sparc_cpu_dump_state(CPUState *cs, FILE *f, int flags) { SPARCCPU *cpu =3D SPARC_CPU(cs); CPUSPARCState *env =3D &cpu->env; int i, x; =20 - cpu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env-= >pc, - env->npc); + qemu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env= ->pc, + env->npc); =20 for (i =3D 0; i < 8; i++) { if (i % REGS_PER_LINE =3D=3D 0) { - cpu_fprintf(f, "%%g%d-%d:", i, i + REGS_PER_LINE - 1); + qemu_fprintf(f, "%%g%d-%d:", i, i + REGS_PER_LINE - 1); } - cpu_fprintf(f, " " TARGET_FMT_lx, env->gregs[i]); + qemu_fprintf(f, " " TARGET_FMT_lx, env->gregs[i]); if (i % REGS_PER_LINE =3D=3D REGS_PER_LINE - 1) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } for (x =3D 0; x < 3; x++) { for (i =3D 0; i < 8; i++) { if (i % REGS_PER_LINE =3D=3D 0) { - cpu_fprintf(f, "%%%c%d-%d: ", - x =3D=3D 0 ? 'o' : (x =3D=3D 1 ? 'l' : 'i'), - i, i + REGS_PER_LINE - 1); + qemu_fprintf(f, "%%%c%d-%d: ", + x =3D=3D 0 ? 'o' : (x =3D=3D 1 ? 'l' : 'i'), + i, i + REGS_PER_LINE - 1); } - cpu_fprintf(f, TARGET_FMT_lx " ", env->regwptr[i + x * 8]); + qemu_fprintf(f, TARGET_FMT_lx " ", env->regwptr[i + x * 8]); if (i % REGS_PER_LINE =3D=3D REGS_PER_LINE - 1) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } } @@ -646,42 +644,42 @@ void sparc_cpu_dump_state(CPUState *cs, FILE *f, fpri= ntf_function cpu_fprintf, if (flags & CPU_DUMP_FPU) { for (i =3D 0; i < TARGET_DPREGS; i++) { if ((i & 3) =3D=3D 0) { - cpu_fprintf(f, "%%f%02d: ", i * 2); + qemu_fprintf(f, "%%f%02d: ", i * 2); } - cpu_fprintf(f, " %016" PRIx64, env->fpr[i].ll); + qemu_fprintf(f, " %016" PRIx64, env->fpr[i].ll); if ((i & 3) =3D=3D 3) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } } } =20 #ifdef TARGET_SPARC64 - cpu_fprintf(f, "pstate: %08x ccr: %02x (icc: ", env->pstate, - (unsigned)cpu_get_ccr(env)); - cpu_print_cc(f, cpu_fprintf, cpu_get_ccr(env) << PSR_CARRY_SHIFT); - cpu_fprintf(f, " xcc: "); - cpu_print_cc(f, cpu_fprintf, cpu_get_ccr(env) << (PSR_CARRY_SHIFT - 4)= ); - cpu_fprintf(f, ") asi: %02x tl: %d pil: %x gl: %d\n", env->asi, env->t= l, - env->psrpil, env->gl); - cpu_fprintf(f, "tbr: " TARGET_FMT_lx " hpstate: " TARGET_FMT_lx " htba= : " - TARGET_FMT_lx "\n", env->tbr, env->hpstate, env->htba); - cpu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate: %d " - "cleanwin: %d cwp: %d\n", - env->cansave, env->canrestore, env->otherwin, env->wstate, - env->cleanwin, env->nwindows - 1 - env->cwp); - cpu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx " fprs: " - TARGET_FMT_lx "\n", env->fsr, env->y, env->fprs); + qemu_fprintf(f, "pstate: %08x ccr: %02x (icc: ", env->pstate, + (unsigned)cpu_get_ccr(env)); + cpu_print_cc(f, cpu_get_ccr(env) << PSR_CARRY_SHIFT); + qemu_fprintf(f, " xcc: "); + cpu_print_cc(f, cpu_get_ccr(env) << (PSR_CARRY_SHIFT - 4)); + qemu_fprintf(f, ") asi: %02x tl: %d pil: %x gl: %d\n", env->asi, env->= tl, + env->psrpil, env->gl); + qemu_fprintf(f, "tbr: " TARGET_FMT_lx " hpstate: " TARGET_FMT_lx " htb= a: " + TARGET_FMT_lx "\n", env->tbr, env->hpstate, env->htba); + qemu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate: %d " + "cleanwin: %d cwp: %d\n", + env->cansave, env->canrestore, env->otherwin, env->wstate, + env->cleanwin, env->nwindows - 1 - env->cwp); + qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx " fprs: " + TARGET_FMT_lx "\n", env->fsr, env->y, env->fprs); =20 #else - cpu_fprintf(f, "psr: %08x (icc: ", cpu_get_psr(env)); - cpu_print_cc(f, cpu_fprintf, cpu_get_psr(env)); - cpu_fprintf(f, " SPE: %c%c%c) wim: %08x\n", env->psrs ? 'S' : '-', - env->psrps ? 'P' : '-', env->psret ? 'E' : '-', - env->wim); - cpu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx "\n", - env->fsr, env->y); + qemu_fprintf(f, "psr: %08x (icc: ", cpu_get_psr(env)); + cpu_print_cc(f, cpu_get_psr(env)); + qemu_fprintf(f, " SPE: %c%c%c) wim: %08x\n", env->psrs ? 'S' : '-', + env->psrps ? 'P' : '-', env->psret ? 'E' : '-', + env->wim); + qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx "\n", + env->fsr, env->y); #endif - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } =20 static void sparc_cpu_set_pc(CPUState *cs, vaddr value) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index b298bd9c29..85b9665ccc 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -564,8 +564,7 @@ extern const struct VMStateDescription vmstate_sparc_cp= u; #endif =20 void sparc_cpu_do_interrupt(CPUState *cpu); -void sparc_cpu_dump_state(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); +void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int sparc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/tilegx/cpu.c b/target/tilegx/cpu.c index bfe9be59b5..b9d37105fa 100644 --- a/target/tilegx/cpu.c +++ b/target/tilegx/cpu.c @@ -24,9 +24,9 @@ #include "qemu-common.h" #include "hw/qdev-properties.h" #include "linux-user/syscall_defs.h" +#include "qemu/qemu-print.h" =20 -static void tilegx_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +static void tilegx_cpu_dump_state(CPUState *cs, FILE *f, int flags) { static const char * const reg_names[TILEGX_R_COUNT] =3D { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", @@ -43,12 +43,12 @@ static void tilegx_cpu_dump_state(CPUState *cs, FILE *f, int i; =20 for (i =3D 0; i < TILEGX_R_COUNT; i++) { - cpu_fprintf(f, "%-4s" TARGET_FMT_lx "%s", - reg_names[i], env->regs[i], - (i % 4) =3D=3D 3 ? "\n" : " "); + qemu_fprintf(f, "%-4s" TARGET_FMT_lx "%s", + reg_names[i], env->regs[i], + (i % 4) =3D=3D 3 ? "\n" : " "); } - cpu_fprintf(f, "PC " TARGET_FMT_lx " CEX " TARGET_FMT_lx "\n\n", - env->pc, env->spregs[TILEGX_SPR_CMPEXCH]); + qemu_fprintf(f, "PC " TARGET_FMT_lx " CEX " TARGET_FMT_lx "\n\n", + env->pc, env->spregs[TILEGX_SPR_CMPEXCH]); } =20 static ObjectClass *tilegx_cpu_class_by_name(const char *cpu_model) diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 43d577ce8e..64d1a9c75e 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -224,8 +224,7 @@ static inline TriCoreCPU *tricore_env_get_cpu(CPUTriCor= eState *env) #define ENV_OFFSET offsetof(TriCoreCPU, env) =20 hwaddr tricore_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -void tricore_cpu_dump_state(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); +void tricore_cpu_dump_state(CPUState *cpu, FILE *f, int flags); =20 =20 #define MASK_PCXI_PCPN 0xff000000 diff --git a/target/tricore/translate.c b/target/tricore/translate.c index b12c391be5..352f52bb4a 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -24,6 +24,7 @@ #include "exec/exec-all.h" #include "tcg-op.h" #include "exec/cpu_ldst.h" +#include "qemu/qemu-print.h" =20 #include "exec/helper-proto.h" #include "exec/helper-gen.h" @@ -88,8 +89,7 @@ enum { MODE_UU =3D 3, }; =20 -void tricore_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +void tricore_cpu_dump_state(CPUState *cs, FILE *f, int flags) { TriCoreCPU *cpu =3D TRICORE_CPU(cs); CPUTriCoreState *env =3D &cpu->env; @@ -98,26 +98,26 @@ void tricore_cpu_dump_state(CPUState *cs, FILE *f, =20 psw =3D psw_read(env); =20 - cpu_fprintf(f, "PC: " TARGET_FMT_lx, env->PC); - cpu_fprintf(f, " PSW: " TARGET_FMT_lx, psw); - cpu_fprintf(f, " ICR: " TARGET_FMT_lx, env->ICR); - cpu_fprintf(f, "\nPCXI: " TARGET_FMT_lx, env->PCXI); - cpu_fprintf(f, " FCX: " TARGET_FMT_lx, env->FCX); - cpu_fprintf(f, " LCX: " TARGET_FMT_lx, env->LCX); + qemu_fprintf(f, "PC: " TARGET_FMT_lx, env->PC); + qemu_fprintf(f, " PSW: " TARGET_FMT_lx, psw); + qemu_fprintf(f, " ICR: " TARGET_FMT_lx, env->ICR); + qemu_fprintf(f, "\nPCXI: " TARGET_FMT_lx, env->PCXI); + qemu_fprintf(f, " FCX: " TARGET_FMT_lx, env->FCX); + qemu_fprintf(f, " LCX: " TARGET_FMT_lx, env->LCX); =20 for (i =3D 0; i < 16; ++i) { if ((i & 3) =3D=3D 0) { - cpu_fprintf(f, "\nGPR A%02d:", i); + qemu_fprintf(f, "\nGPR A%02d:", i); } - cpu_fprintf(f, " " TARGET_FMT_lx, env->gpr_a[i]); + qemu_fprintf(f, " " TARGET_FMT_lx, env->gpr_a[i]); } for (i =3D 0; i < 16; ++i) { if ((i & 3) =3D=3D 0) { - cpu_fprintf(f, "\nGPR D%02d:", i); + qemu_fprintf(f, "\nGPR D%02d:", i); } - cpu_fprintf(f, " " TARGET_FMT_lx, env->gpr_d[i]); + qemu_fprintf(f, " " TARGET_FMT_lx, env->gpr_d[i]); } - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } =20 /* diff --git a/target/unicore32/cpu.h b/target/unicore32/cpu.h index 735d3ae9dc..24abe5e5c0 100644 --- a/target/unicore32/cpu.h +++ b/target/unicore32/cpu.h @@ -97,8 +97,7 @@ static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32= State *env) =20 void uc32_cpu_do_interrupt(CPUState *cpu); bool uc32_cpu_exec_interrupt(CPUState *cpu, int int_req); -void uc32_cpu_dump_state(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); +void uc32_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr uc32_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); =20 #define ASR_M (0x1f) diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index 002569ff3b..dfe41c9069 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -17,6 +17,7 @@ #include "qemu/log.h" #include "exec/cpu_ldst.h" #include "exec/translator.h" +#include "qemu/qemu-print.h" =20 #include "exec/helper-proto.h" #include "exec/helper-gen.h" @@ -2043,8 +2044,7 @@ static const char *cpu_mode_names[16] =3D { =20 #undef UCF64_DUMP_STATE #ifdef UCF64_DUMP_STATE -static void cpu_dump_state_ucf64(CPUUniCore32State *env, FILE *f, - fprintf_function cpu_fprintf, int flags) +static void cpu_dump_state_ucf64(CPUUniCore32State *env, int flags) { int i; union { @@ -2064,20 +2064,19 @@ static void cpu_dump_state_ucf64(CPUUniCore32State = *env, FILE *f, s0.i =3D d.l.lower; s1.i =3D d.l.upper; d0.f64 =3D d.d; - cpu_fprintf(f, "s%02d=3D%08x(%8g) s%02d=3D%08x(%8g)", - i * 2, (int)s0.i, s0.s, - i * 2 + 1, (int)s1.i, s1.s); - cpu_fprintf(f, " d%02d=3D%" PRIx64 "(%8g)\n", - i, (uint64_t)d0.f64, d0.d); + qemu_fprintf(f, "s%02d=3D%08x(%8g) s%02d=3D%08x(%8g)", + i * 2, (int)s0.i, s0.s, + i * 2 + 1, (int)s1.i, s1.s); + qemu_fprintf(f, " d%02d=3D%" PRIx64 "(%8g)\n", + i, (uint64_t)d0.f64, d0.d); } - cpu_fprintf(f, "FPSCR: %08x\n", (int)env->ucf64.xregs[UC32_UCF64_FPSCR= ]); + qemu_fprintf(f, "FPSCR: %08x\n", (int)env->ucf64.xregs[UC32_UCF64_FPSC= R]); } #else #define cpu_dump_state_ucf64(env, file, pr, flags) do { } while (0) #endif =20 -void uc32_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +void uc32_cpu_dump_state(CPUState *cs, FILE *f, int flags) { UniCore32CPU *cpu =3D UNICORE32_CPU(cs); CPUUniCore32State *env =3D &cpu->env; @@ -2085,21 +2084,21 @@ void uc32_cpu_dump_state(CPUState *cs, FILE *f, uint32_t psr; =20 for (i =3D 0; i < 32; i++) { - cpu_fprintf(f, "R%02d=3D%08x", i, env->regs[i]); + qemu_fprintf(f, "R%02d=3D%08x", i, env->regs[i]); if ((i % 4) =3D=3D 3) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); } else { - cpu_fprintf(f, " "); + qemu_fprintf(f, " "); } } psr =3D cpu_asr_read(env); - cpu_fprintf(f, "PSR=3D%08x %c%c%c%c %s\n", - psr, - psr & (1 << 31) ? 'N' : '-', - psr & (1 << 30) ? 'Z' : '-', - psr & (1 << 29) ? 'C' : '-', - psr & (1 << 28) ? 'V' : '-', - cpu_mode_names[psr & 0xf]); + qemu_fprintf(f, "PSR=3D%08x %c%c%c%c %s\n", + psr, + psr & (1 << 31) ? 'N' : '-', + psr & (1 << 30) ? 'Z' : '-', + psr & (1 << 29) ? 'C' : '-', + psr & (1 << 28) ? 'V' : '-', + cpu_mode_names[psr & 0xf]); =20 if (flags & CPU_DUMP_FPU) { cpu_dump_state_ucf64(env, f, cpu_fprintf, flags); diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 86f6d6d72c..5d23e1345b 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -560,8 +560,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwa= ddr physaddr, vaddr addr, unsigned size, MMUAccessType access_= type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t reta= ddr); -void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, - fprintf_function cpu_fprintf, int flags); +void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags); hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void xtensa_count_regs(const XtensaConfig *config, unsigned *n_regs, unsigned *n_core_regs); diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 65561d2c49..43a5e94daa 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -35,6 +35,7 @@ #include "disas/disas.h" #include "tcg-op.h" #include "qemu/log.h" +#include "qemu/qemu-print.h" #include "sysemu/sysemu.h" #include "exec/cpu_ldst.h" #include "exec/semihost.h" @@ -1640,60 +1641,61 @@ void gen_intermediate_code(CPUState *cpu, Translati= onBlock *tb) translator_loop(&xtensa_translator_ops, &dc.base, cpu, tb); } =20 -void xtensa_cpu_dump_state(CPUState *cs, FILE *f, - fprintf_function cpu_fprintf, int flags) +void xtensa_cpu_dump_state(CPUState *cs, FILE *f, int flags) { XtensaCPU *cpu =3D XTENSA_CPU(cs); CPUXtensaState *env =3D &cpu->env; int i, j; =20 - cpu_fprintf(f, "PC=3D%08x\n\n", env->pc); + qemu_fprintf(f, "PC=3D%08x\n\n", env->pc); =20 for (i =3D j =3D 0; i < 256; ++i) { if (xtensa_option_bits_enabled(env->config, sregnames[i].opt_bits)= ) { - cpu_fprintf(f, "%12s=3D%08x%c", sregnames[i].name, env->sregs[= i], - (j++ % 4) =3D=3D 3 ? '\n' : ' '); + qemu_fprintf(f, "%12s=3D%08x%c", + sregnames[i].name, env->sregs[i], + (j++ % 4) =3D=3D 3 ? '\n' : ' '); } } =20 - cpu_fprintf(f, (j % 4) =3D=3D 0 ? "\n" : "\n\n"); + qemu_fprintf(f, (j % 4) =3D=3D 0 ? "\n" : "\n\n"); =20 for (i =3D j =3D 0; i < 256; ++i) { if (xtensa_option_bits_enabled(env->config, uregnames[i].opt_bits)= ) { - cpu_fprintf(f, "%s=3D%08x%c", uregnames[i].name, env->uregs[i], - (j++ % 4) =3D=3D 3 ? '\n' : ' '); + qemu_fprintf(f, "%s=3D%08x%c", + uregnames[i].name, env->uregs[i], + (j++ % 4) =3D=3D 3 ? '\n' : ' '); } } =20 - cpu_fprintf(f, (j % 4) =3D=3D 0 ? "\n" : "\n\n"); + qemu_fprintf(f, (j % 4) =3D=3D 0 ? "\n" : "\n\n"); =20 for (i =3D 0; i < 16; ++i) { - cpu_fprintf(f, " A%02d=3D%08x%c", i, env->regs[i], - (i % 4) =3D=3D 3 ? '\n' : ' '); + qemu_fprintf(f, " A%02d=3D%08x%c", + i, env->regs[i], (i % 4) =3D=3D 3 ? '\n' : ' '); } =20 xtensa_sync_phys_from_window(env); - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); =20 for (i =3D 0; i < env->config->nareg; ++i) { - cpu_fprintf(f, "AR%02d=3D%08x ", i, env->phys_regs[i]); + qemu_fprintf(f, "AR%02d=3D%08x ", i, env->phys_regs[i]); if (i % 4 =3D=3D 3) { bool ws =3D (env->sregs[WINDOW_START] & (1 << (i / 4))) !=3D 0; bool cw =3D env->sregs[WINDOW_BASE] =3D=3D i / 4; =20 - cpu_fprintf(f, "%c%c\n", ws ? '<' : ' ', cw ? '=3D' : ' '); + qemu_fprintf(f, "%c%c\n", ws ? '<' : ' ', cw ? '=3D' : ' '); } } =20 if ((flags & CPU_DUMP_FPU) && xtensa_option_enabled(env->config, XTENSA_OPTION_FP_COPROCESSOR)) { - cpu_fprintf(f, "\n"); + qemu_fprintf(f, "\n"); =20 for (i =3D 0; i < 16; ++i) { - cpu_fprintf(f, "F%02d=3D%08x (%+10.8e)%c", i, - float32_val(env->fregs[i].f32[FP_F32_LOW]), - *(float *)(env->fregs[i].f32 + FP_F32_LOW), - (i % 2) =3D=3D 1 ? '\n' : ' '); + qemu_fprintf(f, "F%02d=3D%08x (%+10.8e)%c", i, + float32_val(env->fregs[i].f32[FP_F32_LOW]), + *(float *)(env->fregs[i].f32 + FP_F32_LOW), + (i % 2) =3D=3D 1 ? '\n' : ' '); } } } --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621768; cv=none; d=zoho.com; s=zohoarc; b=kIIZAYJbGLOVmdELKMwcCktbit2xq/tCEfWcy/MiW/HF+TRNk3XEI8HeA9/PVzhjusOorouIItM7W7oDcRLh6CzJdaVnCxBU+sbLhstQA+HwJ27x60gZBwEr5nzRUnQvBwr9c4QyjS7kt4bRg0G70NtH3B1uIuafJxBEpWo174Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621768; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=v++NZSi5adrguCjGMAWLXkNlBXDfltiTn5W5qWkuOF0=; b=T1P9sctBr9Iy03eHxMo/cTxafFrTFMGtqoRFZERz/aoYirciBGRRO/QbWmDUJzM9aErLdhdgFhmzUhyGcph8N9HWJjiUZ5IzPOb8lp3Y+kEhhKkcNjtwA3D1x/l0i3AG1Eg+WGOXqbr2TQJxQn4L472yh/2h+ETfDfNvhXZRCTQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555621768992169.21458372287407; Thu, 18 Apr 2019 14:09:28 -0700 (PDT) Received: from localhost ([127.0.0.1]:47343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEHb-00021R-08 for importer@patchew.org; Thu, 18 Apr 2019 17:09:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54735) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0d-0005CF-2z for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005HW-L6 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55352) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005F3-1v for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3422281233 for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0592F5C206 for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1C30C110CFDC; Thu, 18 Apr 2019 22:51:37 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:33 +0200 Message-Id: <20190418205135.6686-35-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 18 Apr 2019 20:51:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 34/36] monitor: Clean up how monitor_disas() funnels output to monitor 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" INIT_DISASSEMBLE_INFO() takes an fprintf()-like callback and a FILE * to pass to it. monitor_disas() passes monitor_fprintf() and the current monitor cast to FILE *. monitor_fprintf() casts it right back, and is otherwise identical to monitor_printf(). The type-punning is ugly. Pass qemu_fprintf() and NULL instead. monitor_fprintf() is now unused; delete it. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-16-armbru@redhat.com> [Commit message typo corrected] --- disas.c | 3 ++- include/monitor/monitor.h | 1 - monitor.c | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/disas.c b/disas.c index d9aa713a40..d15cceb863 100644 --- a/disas.c +++ b/disas.c @@ -3,6 +3,7 @@ #include "qemu-common.h" #include "disas/bfd.h" #include "elf.h" +#include "qemu/qemu-print.h" =20 #include "cpu.h" #include "disas/disas.h" @@ -609,7 +610,7 @@ void monitor_disas(Monitor *mon, CPUState *cpu, int count, i; CPUDebug s; =20 - INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf); + INIT_DISASSEMBLE_INFO(s.info, NULL, qemu_fprintf); =20 s.cpu =3D cpu; s.info.read_memory_func diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 316a168c41..86656297f1 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -31,7 +31,6 @@ int monitor_fd_param(Monitor *mon, const char *fdname, Er= ror **errp); int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); int monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3); -int monitor_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3); void monitor_flush(Monitor *mon); int monitor_set_cpu(int cpu_index); int monitor_get_cpu_index(void); diff --git a/monitor.c b/monitor.c index ad6cec54a1..9b5f10b475 100644 --- a/monitor.c +++ b/monitor.c @@ -480,17 +480,6 @@ int monitor_printf(Monitor *mon, const char *fmt, ...) return ret; } =20 -int monitor_fprintf(FILE *stream, const char *fmt, ...) -{ - int ret; - - va_list ap; - va_start(ap, fmt); - ret =3D monitor_vprintf((Monitor *)stream, fmt, ap); - va_end(ap); - return ret; -} - static void qmp_send_response(Monitor *mon, const QDict *rsp) { const QObject *data =3D QOBJECT(rsp); --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555622755; cv=none; d=zoho.com; s=zohoarc; b=JgJUSDGjj+0hycWAyWJA4eXsM5A3Hk+vZ8FzDrpUydlMqR4NK9x705GcEfvV1UcEKXEpuUXeeBns6ihDF/UbixAQaxAF677yAY7YvQGLFuAPVd0rQtJFP3zwnKNDAIWeTYWmenpalWjyrd1W9yTmaX6ZfJxGccki8ZH0rG6bpQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555622755; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=fsE7D9HE7guI2SD2MUnJrFBbwOZawGt2Fn+TSxJ39ow=; b=EmyeexVtXJ4z5yFyaTR839RTUKqhJYvPbeQgiQr5aeIc9GY0q8XKLDC124u260aac1x7yBVuiXu8ihVnoLimkU/w/SUIiVp1U+x98MOx6ljyV30QGGANMTXf3RiSFnKiH3ixT9iBJPTsScwf6ADfxzEJ3sIYlKOe/ujEKU/Loyo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1555622755064498.77785125981177; Thu, 18 Apr 2019 14:25:55 -0700 (PDT) Received: from localhost ([127.0.0.1]:47651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHEXU-0006YS-To for importer@patchew.org; Thu, 18 Apr 2019 17:25:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54851) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0g-0005GG-TW for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0d-0005My-40 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0X-0005FZ-Ha for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6186F7DCC2 for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08E025D70A; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 23BCB110CF82; Thu, 18 Apr 2019 22:51:37 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:34 +0200 Message-Id: <20190418205135.6686-36-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 18 Apr 2019 20:51:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 35/36] disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h 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: , Cc: Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit dc99065b5f9 (v0.1.0) added dis-asm.h from binutils. Commit 43d4145a986 (v0.1.5) inlined bfd.h into dis-asm.h to remove the dependency on binutils. Commit 76cad71136b (v1.4.0) moved dis-asm.h to include/disas/bfd.h. The new name is confusing when you try to match against (pre GPLv3+) binutils. Rename it back. Keep it in the same directory, of course. Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Message-Id: <20190417191805.28198-17-armbru@redhat.com> Reviewed-by: Dr. David Alan Gilbert --- disas.c | 2 +- disas/alpha.c | 2 +- disas/arm-a64.cc | 2 +- disas/arm.c | 2 +- disas/cris.c | 2 +- disas/hppa.c | 2 +- disas/i386.c | 2 +- disas/lm32.c | 2 +- disas/m68k.c | 2 +- disas/microblaze.c | 2 +- disas/mips.c | 2 +- disas/moxie.c | 2 +- disas/nanomips.cpp | 2 +- disas/nios2.c | 2 +- disas/ppc.c | 2 +- disas/riscv.c | 2 +- disas/s390.c | 2 +- disas/sh4.c | 2 +- disas/sparc.c | 2 +- disas/tci.c | 2 +- disas/xtensa.c | 2 +- include/disas/{bfd.h =3D> dis-asm.h} | 0 include/qom/cpu.h | 2 +- target/openrisc/disas.c | 2 +- target/ppc/translate_init.inc.c | 2 +- 25 files changed, 24 insertions(+), 24 deletions(-) rename include/disas/{bfd.h =3D> dis-asm.h} (100%) diff --git a/disas.c b/disas.c index d15cceb863..41ad0102e2 100644 --- a/disas.c +++ b/disas.c @@ -1,7 +1,7 @@ /* General "disassemble this chunk" code. Used for debugging. */ #include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "elf.h" #include "qemu/qemu-print.h" =20 diff --git a/disas/alpha.c b/disas/alpha.c index a0c9ecd49d..3db90fa665 100644 --- a/disas/alpha.c +++ b/disas/alpha.c @@ -20,7 +20,7 @@ along with this file; see the file COPYING. If not, see . */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 /* MAX is redefined below, so remove any previous definition. */ #undef MAX diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc index 9280950ce3..9fa779e175 100644 --- a/disas/arm-a64.cc +++ b/disas/arm-a64.cc @@ -19,7 +19,7 @@ =20 extern "C" { #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" } =20 #include "vixl/a64/disasm-a64.h" diff --git a/disas/arm.c b/disas/arm.c index 17ea120b44..7d940f2396 100644 --- a/disas/arm.c +++ b/disas/arm.c @@ -23,7 +23,7 @@ for things we don't care about. */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 #define ARM_EXT_V1 0 #define ARM_EXT_V2 0 diff --git a/disas/cris.c b/disas/cris.c index 2dd56deea4..bf9eafc415 100644 --- a/disas/cris.c +++ b/disas/cris.c @@ -20,7 +20,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "target/cris/opcode-cris.h" =20 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - = 1) =3D=3D 0) diff --git a/disas/hppa.c b/disas/hppa.c index a2d371fdb1..2dbd1fc445 100644 --- a/disas/hppa.c +++ b/disas/hppa.c @@ -19,7 +19,7 @@ along with this program; if not, see . */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 /* HP PA-RISC SOM object file format: definitions internal to BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, diff --git a/disas/i386.c b/disas/i386.c index fc03b9f06a..4c1f0f877b 100644 --- a/disas/i386.c +++ b/disas/i386.c @@ -32,7 +32,7 @@ the Intel manual for details. */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "qemu/cutils.h" =20 /* include/opcode/i386.h r1.78 */ diff --git a/disas/lm32.c b/disas/lm32.c index fcc2cde23d..c0ef8160fe 100644 --- a/disas/lm32.c +++ b/disas/lm32.c @@ -19,7 +19,7 @@ */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 typedef enum { LM32_OP_SRUI =3D 0, LM32_OP_NORI, LM32_OP_MULI, LM32_OP_SH, LM32_OP_LB, diff --git a/disas/m68k.c b/disas/m68k.c index e544c7137f..863409c67c 100644 --- a/disas/m68k.c +++ b/disas/m68k.c @@ -4,7 +4,7 @@ #include "qemu/osdep.h" #include =20 -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 /* **** floatformat.h from sourceware.org CVS 2005-08-14. */ /* IEEE floating point support declarations, for GDB, the GNU Debugger. diff --git a/disas/microblaze.c b/disas/microblaze.c index c23605043a..0b89b9c4fa 100644 --- a/disas/microblaze.c +++ b/disas/microblaze.c @@ -577,7 +577,7 @@ static const char pvr_register_prefix[] =3D "rpvr"; =20 #endif /* MICROBLAZE_OPC */ =20 -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 #define get_field_rd(instr) get_field(instr, RD_MASK, RD_LOW) #define get_field_r1(instr) get_field(instr, RA_MASK, RA_LOW) diff --git a/disas/mips.c b/disas/mips.c index 97f661a37e..dfefe5e589 100644 --- a/disas/mips.c +++ b/disas/mips.c @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public= License along with this program; if not, see . */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 /* mips.h. Mips opcode list for GDB, the GNU debugger. Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2= 003 diff --git a/disas/moxie.c b/disas/moxie.c index 70b49ed74b..e94ab4c33d 100644 --- a/disas/moxie.c +++ b/disas/moxie.c @@ -18,7 +18,7 @@ #define STATIC_TABLE #define DEFINE_TABLE =20 -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 static void *stream; =20 diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp index c8495b1a19..90e63b8367 100644 --- a/disas/nanomips.cpp +++ b/disas/nanomips.cpp @@ -29,7 +29,7 @@ =20 extern "C" { #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" } =20 #include diff --git a/disas/nios2.c b/disas/nios2.c index de11f04cc4..c3e82140c7 100644 --- a/disas/nios2.c +++ b/disas/nios2.c @@ -36,7 +36,7 @@ =20 /*#include "bfd.h"*/ #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 =20 /*************************************************************************= *** diff --git a/disas/ppc.c b/disas/ppc.c index da1140ba2b..a545437de9 100644 --- a/disas/ppc.c +++ b/disas/ppc.c @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public= License along with this file; see the file COPYING. If not, see . */ #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #define BFD_DEFAULT_TARGET_SIZE 64 =20 /* ppc.h -- Header file for PowerPC opcode table diff --git a/disas/riscv.c b/disas/riscv.c index 27546dd790..59a9b0437a 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -18,7 +18,7 @@ */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 =20 /* types */ diff --git a/disas/s390.c b/disas/s390.c index 6393860239..b1f4e2a0c1 100644 --- a/disas/s390.c +++ b/disas/s390.c @@ -22,7 +22,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 /* include/opcode/s390.h revision 1.9 */ /* s390.h -- Header file for S390 opcode table diff --git a/disas/sh4.c b/disas/sh4.c index 6b66176bed..55ef865a36 100644 --- a/disas/sh4.c +++ b/disas/sh4.c @@ -16,7 +16,7 @@ along with this program; if not, see . */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 #define DEFINE_TABLE =20 diff --git a/disas/sparc.c b/disas/sparc.c index f120f4e86d..5689533ce1 100644 --- a/disas/sparc.c +++ b/disas/sparc.c @@ -27,7 +27,7 @@ see . */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" =20 /* The SPARC opcode table (and other related data) is defined in the opcodes library in sparc-opc.c. If you change anything here, make diff --git a/disas/tci.c b/disas/tci.c index 1cdf5eeafc..f1d6c6b469 100644 --- a/disas/tci.c +++ b/disas/tci.c @@ -19,7 +19,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "tcg/tcg.h" =20 /* Disassemble TCI bytecode. */ diff --git a/disas/xtensa.c b/disas/xtensa.c index 5e3870b9ad..d7dda8c2d6 100644 --- a/disas/xtensa.c +++ b/disas/xtensa.c @@ -26,7 +26,7 @@ */ =20 #include "qemu/osdep.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "hw/xtensa/xtensa-isa.h" =20 int print_insn_xtensa(bfd_vma memaddr, struct disassemble_info *info) diff --git a/include/disas/bfd.h b/include/disas/dis-asm.h similarity index 100% rename from include/disas/bfd.h rename to include/disas/dis-asm.h diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9972e07786..e9bec3a5bc 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -21,7 +21,7 @@ #define QEMU_CPU_H =20 #include "hw/qdev-core.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "exec/hwaddr.h" #include "exec/memattrs.h" #include "qapi/qapi-types-run-state.h" diff --git a/target/openrisc/disas.c b/target/openrisc/disas.c index bc63093ee9..5923b2429e 100644 --- a/target/openrisc/disas.c +++ b/target/openrisc/disas.c @@ -19,7 +19,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "qemu/bitops.h" #include "cpu.h" =20 diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 996356dd99..20a64f3b77 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -18,7 +18,7 @@ * License along with this library; if not, see . */ =20 -#include "disas/bfd.h" +#include "disas/dis-asm.h" #include "exec/gdbstub.h" #include "kvm_ppc.h" #include "sysemu/arch_init.h" --=20 2.17.2 From nobody Mon Apr 29 11:06:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1555621474; cv=none; d=zoho.com; s=zohoarc; b=nPuS7mHvC93z1SfTBYw7+XTHrw/zRJDAGZ0vA8wiQ73/2Z2DDY7IqatSehta3azSsTg9Y1Vznvt0bgwSje3w/qS2lZxOLBjMUIubm1bVJU/LOc8kjVehW68dGTNymSRRRbzBxIFjBVM12+sNte72tSISOrF6890waurq7dSdZk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1555621474; h=Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=tMBZsFG7hT0sE6wyd14d1nbsJpo6/orfSrjhnQPY9iE=; b=ObypL+OW5sIVnFraOif34S7kBo2KF8dkeGN7cTtE6hoHBtnQOPgTt6A3zT/AjEV4mPMW3fZkd2RM4xYGyaCQU2/Kals5Dr4eF9SNrG14Cvrfjltc0RN3PYA3mEeKsefka85pAUxM8NoEVYbJ8LlSsxPzA6eAu5rHp2XKQc7g5II= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15556214746001013.5785520139339; Thu, 18 Apr 2019 14:04:34 -0700 (PDT) Received: from localhost ([127.0.0.1]:47266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHECs-0006hu-KF for importer@patchew.org; Thu, 18 Apr 2019 17:04:30 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHE0Z-00057j-G6 for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHE0V-0005HN-KW for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33966) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHE0V-0005F6-2Z for qemu-devel@nongnu.org; Thu, 18 Apr 2019 16:51:43 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 39B3519CBCD for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09A7C19C79 for ; Thu, 18 Apr 2019 20:51:42 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2A512110CF8A; Thu, 18 Apr 2019 22:51:37 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2019 22:51:35 +0200 Message-Id: <20190418205135.6686-37-armbru@redhat.com> In-Reply-To: <20190418205135.6686-1-armbru@redhat.com> References: <20190418205135.6686-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 18 Apr 2019 20:51:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-4.1 36/36] include: Move fprintf_function to disas/ 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The previous commits have eliminated fprintf_function outside disassemblers, simplifying code and cleaning up the ugly type-punning fprintf_function seems to attract. Move fprintf_function to include/disas/dis-asm.h to reduce the temptation to abuse it. I considered renaming it to fprintf_ftype (reverting that part of commit 6e2d864edf5, v0.14.0) to get us closer to binutils, but I figure the fork is too distant to make this worthwhile. Signed-off-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Message-Id: <20190417191805.28198-18-armbru@redhat.com> --- include/disas/dis-asm.h | 5 +++-- include/qemu/fprintf-fn.h | 14 -------------- 2 files changed, 3 insertions(+), 16 deletions(-) delete mode 100644 include/qemu/fprintf-fn.h diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h index 41b61c85f9..9240ec32c2 100644 --- a/include/disas/dis-asm.h +++ b/include/disas/dis-asm.h @@ -9,8 +9,6 @@ #ifndef DISAS_BFD_H #define DISAS_BFD_H =20 -#include "qemu/fprintf-fn.h" - typedef void *PTR; typedef uint64_t bfd_vma; typedef int64_t bfd_signed_vma; @@ -243,6 +241,9 @@ typedef struct symbol_cache_entry } udata; } asymbol; =20 +typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) + GCC_FMT_ATTR(2, 3); + enum dis_insn_type { dis_noninsn, /* Not a valid instruction */ dis_nonbranch, /* Not a branch instruction */ diff --git a/include/qemu/fprintf-fn.h b/include/qemu/fprintf-fn.h deleted file mode 100644 index 9068a960b3..0000000000 --- a/include/qemu/fprintf-fn.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Typedef for fprintf-alike function pointers. - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - */ - -#ifndef QEMU_FPRINTF_FN_H -#define QEMU_FPRINTF_FN_H - -typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) - GCC_FMT_ATTR(2, 3); - -#endif --=20 2.17.2