From patchwork Sun Sep 10 16:23:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 812163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xqxFb66sgz9rxm for ; Mon, 11 Sep 2017 02:23:47 +1000 (AEST) Received: from localhost ([::1]:53561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr51N-00075F-Jr for incoming@patchwork.ozlabs.org; Sun, 10 Sep 2017 12:23:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr513-00074o-MM for qemu-devel@nongnu.org; Sun, 10 Sep 2017 12:23:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dr50z-0003wf-N7 for qemu-devel@nongnu.org; Sun, 10 Sep 2017 12:23:25 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:57795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr50z-0003wR-C1 for qemu-devel@nongnu.org; Sun, 10 Sep 2017 12:23:21 -0400 Received: from correu-2.ac.upc.es (correu-2.ac.upc.es [147.83.30.92]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id v8AGNKNV020412; Sun, 10 Sep 2017 18:23:20 +0200 Received: from localhost (unknown [132.68.137.153]) by correu-2.ac.upc.es (Postfix) with ESMTPSA id D1E531683; Sun, 10 Sep 2017 18:23:14 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Sun, 10 Sep 2017 19:23:13 +0300 Message-Id: <150506059354.19604.5050182852156612042.stgit@frigg.lan> X-Mailer: git-send-email 2.14.1 In-Reply-To: <150505986682.19604.11937392314067517230.stgit@frigg.lan> References: <150505986682.19604.11937392314067517230.stgit@frigg.lan> User-Agent: StGit/0.18 MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id v8AGNKNV020412 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH 3/7] trace: Add event "guest_inst_info_before" 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 , Richard Henderson , Stefan Hajnoczi , Peter Crosthwaite Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: LluĂ­s Vilanova --- accel/tcg/translator.c | 18 ++++++++++++++++++ trace-events | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 287d27b4f7..6598931171 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -70,6 +70,8 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, while (true) { target_ulong pc_insn = db->pc_next; + TCGv_i32 insn_size_tcg = 0; + int insn_size_opcode_idx; db->num_insns++; ops->insn_start(db, cpu); @@ -99,6 +101,16 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, trace_guest_bbl_before_tcg(cpu, tcg_ctx.tcg_env, db->pc_first); } trace_guest_inst_before_tcg(cpu, tcg_ctx.tcg_env, pc_insn); + if (TRACE_GUEST_INST_INFO_BEFORE_EXEC_ENABLED) { + insn_size_tcg = tcg_temp_new_i32(); + insn_size_opcode_idx = tcg_op_buf_count(); + tcg_gen_movi_i32(insn_size_tcg, 0xdeadbeef); + + trace_guest_inst_info_before_tcg( + cpu, tcg_ctx.tcg_env, pc_insn, insn_size_tcg); + + tcg_temp_free_i32(insn_size_tcg); + } /* Disassemble one instruction. The translate_insn hook should update db->pc_next and db->is_jmp to indicate what should be @@ -113,6 +125,12 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db, ops->translate_insn(db, cpu); } + /* Tracing after (patched values) */ + if (TRACE_GUEST_INST_INFO_BEFORE_EXEC_ENABLED) { + unsigned int insn_size = db->pc_next - pc_insn; + tcg_set_insn_param(insn_size_opcode_idx, 1, insn_size); + } + /* Stop translation if translate_insn so indicated. */ if (db->is_jmp != DISAS_NEXT) { break; diff --git a/trace-events b/trace-events index 46457c6158..4e61697297 100644 --- a/trace-events +++ b/trace-events @@ -107,6 +107,15 @@ vcpu tcg guest_bbl_before(uint64_t vaddr) "vaddr=0x%016"PRIx64, "vaddr=0x%016"PR # Targets: TCG(all) vcpu tcg guest_inst_before(uint64_t vaddr) "vaddr=0x%016"PRIx64, "vaddr=0x%016"PRIx64 +# @vaddr: Instruction's virtual address +# @size: Instruction's size in bytes +# +# Same as 'guest_inst_before', with additional information. +# +# Mode: user, softmmu +# Targets: TCG(all) +disable vcpu tcg guest_inst_info_before(uint64_t vaddr, TCGv_i32 size) "vaddr=0x%016"PRIx64, "vaddr=0x%016"PRIx64" size=%d" + # @vaddr: Access' virtual address. # @info : Access' information (see below). #