From nobody Tue Feb 10 02:04:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506005195151538.0117107592635; Thu, 21 Sep 2017 07:46:35 -0700 (PDT) Received: from localhost ([::1]:54070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dv2kK-0002sZ-T0 for importer@patchew.org; Thu, 21 Sep 2017 10:46:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dv2jX-0002YI-Ob for qemu-devel@nongnu.org; Thu, 21 Sep 2017 10:45:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dv2jT-0003XC-Hi for qemu-devel@nongnu.org; Thu, 21 Sep 2017 10:45:43 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:45482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dv2jT-0003WZ-B4 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 10:45:39 -0400 Received: by mail-wm0-x22d.google.com with SMTP id q124so2569742wmb.0 for ; Thu, 21 Sep 2017 07:45:39 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 137sm2269348wmp.7.2017.09.21.07.45.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 07:45:36 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 5DBDB3E05A7; Thu, 21 Sep 2017 15:45:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1CdUT8HMJmkAR7b7iMMG+la/pcLaXdcXqx70gOJy2D8=; b=QvLNHe/hGJO6F4NYaubp5Qrr13aN8oo72PuBxwE5NCThnAyvVWdPH6I0UD7QOnmayG uE8DHZpudpRjUyEKZO2Cvrzkvr+/tpA84grJ7THMrwwDEmVr6vajHQVSPv1KwLDkh9Db VGqn3nTUasz319J6c3sQcR6AkwNA7gJAqQEGM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1CdUT8HMJmkAR7b7iMMG+la/pcLaXdcXqx70gOJy2D8=; b=pW/FN7aIz6RQdKKj/nPz+rFcdHEFJOFn9M7UGe1l1nZhwhoxsRFPFaa23871pDFAJ3 Iue4HMd314Z8taf814WA25aS1izObgofXFdIqFkpgCPlysNysqVTfiBcyE7nHNnCQfbt InbOy/jzoN5yz1SYrY0N/bNdEjCXXpPwE4I8GZM5avLlhLliJ8pKYSV98Vi+0aJHXw77 pN82EtmLS9QQCk1XpanwNMzhe0pczSSgVUu2AsrLBewny9rymIfsVHm1/pZrOTYVKR9a RjciMiQncv5pWXx+GvEF6i3SS1Opy+7zEln17IgXmbhCkuQsN/bu+ZZmPIlQvrT/GjVf edQw== X-Gm-Message-State: AHPjjUjXr9TowBTxjsikCt8G66FIGjZ8Tp5HurO5KO6GziTaJyT/q5T1 g3r+6gWgKgU089n7IDn7JW59CA== X-Google-Smtp-Source: AOwi7QAWjDCzfyTVD1c6BmBbb9UDOYSq9xbjNl1U6dADeBEXSYHN238YtVliQLU8CXFpFmt51yB6Fg== X-Received: by 10.28.236.212 with SMTP id h81mr1230626wmi.42.1506005137867; Thu, 21 Sep 2017 07:45:37 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 15:45:34 +0100 Message-Id: <20170921144534.22674-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22d Subject: [Qemu-devel] [RFC PATCH] monitor: add info translate (HACK!) 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: Peter Crosthwaite , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Currently investigating translation involves enabling debugging flags and potentially generating large amounts of debug information and sifting through it. -dfilter helps but often you want to investigate what's going on in a live system. This patch is an attempt at that. It adds a "info translate" command which is passed an address. It then grabs the tb_lock, fiddles with the loglevel flags and then does a un-cached translation, spewing the output on stderr. There are a number of open questions: - there is currently no safe way to re-direct log output - messing with internal qemu_loglevel flags is *eewww* - we don't deal with translation flags We could deal with the inherent racey behaviour by pushing the output to a async safe function. It also might make sense to be able to introspect what TB's exist in a given range and then use that information to re-run the translation live. Signed-off-by: Alex Benn=C3=A9e --- accel/tcg/translate-all.c | 23 +++++++++++++++++++++++ hmp-commands-info.hx | 16 ++++++++++++++++ include/exec/cpu-all.h | 2 ++ monitor.c | 15 +++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 2d1ed06065..09fc698bb0 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1947,6 +1947,29 @@ void dump_opcount_info(FILE *f, fprintf_function cpu= _fprintf) tcg_dump_op_count(f, cpu_fprintf); } =20 +/* + * To dump translation info we temporally translate the given address + * while tweak the log flags to dump information. + * + * It might make more sense to push this off to an safe async function + * to do this in a less racey manner. + */ + +void dump_translate_info(FILE *f, fprintf_function cpu_fprintf, + target_ulong addr, int flags) +{ + int old_flags =3D qemu_loglevel; + + /* grab the lock, currently that means no other translation */ + tb_lock(); + qemu_loglevel =3D flags; + + tb_gen_code(first_cpu, addr, 0, 0, CF_NOCACHE | CF_IGNORE_ICOUNT); + + qemu_loglevel =3D old_flags; + tb_unlock(); +} + #else /* CONFIG_USER_ONLY */ =20 void cpu_interrupt(CPUState *cpu, int mask) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 1c6772597d..68f64aff7e 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -292,6 +292,22 @@ STEXI @item info opcount @findex opcount Show dynamic compiler opcode counters +ETEXI + +#if defined(CONFIG_TCG) + { + .name =3D "translate", + .args_type =3D "addr:l,flags:s", + .params =3D "addr [flags]", + .help =3D "show translation info", + .cmd =3D hmp_info_translate, + }, +#endif + +STEXI +@item info translate +@findex translate +Show dynamic compiler info. ETEXI =20 { diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index ffe43d5654..456fd03f44 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -340,6 +340,8 @@ CPUArchState *cpu_copy(CPUArchState *env); =20 void dump_exec_info(FILE *f, fprintf_function cpu_fprintf); void dump_opcount_info(FILE *f, fprintf_function cpu_fprintf); +void dump_translate_info(FILE *f, fprintf_function cpu_fprintf, + target_ulong addr, int flags); #endif /* !CONFIG_USER_ONLY */ =20 int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, diff --git a/monitor.c b/monitor.c index cd831eaab4..f0cdd54cfb 100644 --- a/monitor.c +++ b/monitor.c @@ -1115,6 +1115,21 @@ static void hmp_info_opcount(Monitor *mon, const QDi= ct *qdict) { dump_opcount_info((FILE *)mon, monitor_fprintf); } + +static void hmp_info_translate(Monitor *mon, const QDict *qdict) +{ + target_ulong addr; + + if (!tcg_enabled()) { + error_report("translation information is only available with accel= =3Dtcg"); + return; + } + + addr =3D qdict_get_int(qdict, "addr"); + + dump_translate_info((FILE *)mon, monitor_fprintf, addr, + CPU_LOG_TB_IN_ASM | CPU_LOG_TB_OUT_ASM | CPU_LOG_T= B_OP); +} #endif =20 static void hmp_info_history(Monitor *mon, const QDict *qdict) --=20 2.14.1