From patchwork Tue Jul 15 11:42:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 33659 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 831FF20CAD for ; Tue, 15 Jul 2014 11:42:34 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id kx10sf32656143pab.8 for ; Tue, 15 Jul 2014 04:42:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=TuU5QMs8/RJ39m9f/W2vO0FrDl4na/qJ7MTdic4qCZ8=; b=hUDBzLr/f/dzyBDDaUYrsbuZhlnfpi7KHXkAP7K7YGjgescqpJlbdUNHs93pxYFrJg Gbw9HW9wVuESvzknXiwPGpKpwkdHbPv8k4aFB8kcP8AyRvO1lLB9PmyehCCx86nA6JWu Wv1LGfjqeLMBxXb8lqEgrH839AqWkvrXIlI9C2FHbamMkX0Wc9d4EA4GXZ8hJzsnbsxy raQ4W0j6Ta6EcXo+/7E/SuBctaYfsA0iQBh/hg9SEG5WjRHP/++ZGl6CusgcWkW5ytCr XJzi5UAdLkMcbBzJvj8PI9n3JIHVy1OB0bSuvfYPhFdZBobNXeDTNM0GUB6nSFkF6BLu RsRw== X-Gm-Message-State: ALoCoQnzcUrs6iafusI+UbS+PXHtWhZCYp/FpTB36YSZzbcdxYFUy3d0Xd5AOhdkEPcWF1AwvfoH X-Received: by 10.66.252.166 with SMTP id zt6mr10567571pac.1.1405424553825; Tue, 15 Jul 2014 04:42:33 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.210 with SMTP id 76ls63204qgp.33.gmail; Tue, 15 Jul 2014 04:42:33 -0700 (PDT) X-Received: by 10.58.243.1 with SMTP id wu1mr8552772vec.27.1405424553697; Tue, 15 Jul 2014 04:42:33 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id p10si6567279vck.17.2014.07.15.04.42.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Jul 2014 04:42:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hu12so4713231vcb.20 for ; Tue, 15 Jul 2014 04:42:33 -0700 (PDT) X-Received: by 10.58.228.74 with SMTP id sg10mr20931621vec.6.1405424553588; Tue, 15 Jul 2014 04:42:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp207552vcb; Tue, 15 Jul 2014 04:42:33 -0700 (PDT) X-Received: by 10.224.167.136 with SMTP id q8mr32214754qay.35.1405424553211; Tue, 15 Jul 2014 04:42:33 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id ep6si19930132qcb.14.2014.07.15.04.42.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Jul 2014 04:42:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:34065 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X717w-0001e5-TC for patch@linaro.org; Tue, 15 Jul 2014 07:42:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7175-0000r4-Eo for qemu-devel@nongnu.org; Tue, 15 Jul 2014 07:41:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X716x-0003Xs-PO for qemu-devel@nongnu.org; Tue, 15 Jul 2014 07:41:39 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:59340 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X716x-0003XE-JW for qemu-devel@nongnu.org; Tue, 15 Jul 2014 07:41:31 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1X71Cw-0007um-Iq; Tue, 15 Jul 2014 13:47:42 +0200 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: stefanha@redhat.com Date: Tue, 15 Jul 2014 12:42:20 +0100 Message-Id: <1405424541-21803-3-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1405424541-21803-1-git-send-email-alex.bennee@linaro.org> References: <1405424541-21803-1-git-send-email-alex.bennee@linaro.org> X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, mohamad.gebai@gmail.com Subject: [Qemu-devel] [PATCH v2 2/3] trace: add some tcg tracing support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This adds a couple of tcg specific trace-events which are useful for tracing execution though tcg generated blocks. It's been tested with lttng user space tracing but is generic enough for all systems. The tcg events are: * translate_block - when a subject block is translated * exec_tb - when a translated block is entered * exec_tb_exit - when we exit the translated code * exec_tb_nocache - special case translations Of course we can only trace the entrance to the first block of a chain as each block will jump directly to the next when it can. See the -d nochain patch to allow more complete tracing at the expense of performance. --- v2 - rebase diff --git a/cpu-exec.c b/cpu-exec.c index 38e5f02..45ef77b 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -18,6 +18,7 @@ */ #include "config.h" #include "cpu.h" +#include "trace.h" #include "disas/disas.h" #include "tcg.h" #include "qemu/atomic.h" @@ -65,6 +66,9 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, uint8_t *tb_ptr) #endif /* DEBUG_DISAS */ next_tb = tcg_qemu_tb_exec(env, tb_ptr); + trace_exec_tb_exit( (void *) (next_tb & ~TB_EXIT_MASK), + next_tb & TB_EXIT_MASK); + if ((next_tb & TB_EXIT_MASK) > TB_EXIT_IDX1) { /* We didn't start executing this TB (eg because the instruction * counter hit zero); we must restore the guest PC to the address @@ -105,6 +109,7 @@ static void cpu_exec_nocache(CPUArchState *env, int max_cycles, max_cycles); cpu->current_tb = tb; /* execute the generated code */ + trace_exec_tb_nocache(tb, tb->pc); cpu_tb_exec(cpu, tb->tc_ptr); cpu->current_tb = NULL; tb_phys_invalidate(tb, -1); @@ -637,6 +642,7 @@ int cpu_exec(CPUArchState *env) cpu->current_tb = tb; barrier(); if (likely(!cpu->exit_request)) { + trace_exec_tb(tb, tb->pc); tc_ptr = tb->tc_ptr; /* execute the generated code */ next_tb = cpu_tb_exec(cpu, tc_ptr); diff --git a/trace-events b/trace-events index 709de68..f8cc35f 100644 --- a/trace-events +++ b/trace-events @@ -1237,6 +1237,14 @@ kvm_failed_spr_get(int str, const char *msg) "Warning: Unable to retrieve SPR %d kvm_failed_reg_get(uint64_t id, const char *msg) "Warning: Unable to retrieve ONEREG %" PRIu64 " from KVM: %s" kvm_failed_reg_set(uint64_t id, const char *msg) "Warning: Unable to set ONEREG %" PRIu64 " to KVM: %s" +# cpu-exec.c +exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%x" +exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%x" +exec_tb_exit(void *next_tb, unsigned int flags) "tb:%p flags=%x" + +# translate-all.c +translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%x, tb_code:%p" + # memory.c memory_region_ops_read(void *mr, uint64_t addr, uint64_t value, unsigned size) "mr %p addr %#"PRIx64" value %#"PRIx64" size %u" memory_region_ops_write(void *mr, uint64_t addr, uint64_t value, unsigned size) "mr %p addr %#"PRIx64" value %#"PRIx64" size %u" diff --git a/translate-all.c b/translate-all.c index 11d3f28..a11c083 100644 --- a/translate-all.c +++ b/translate-all.c @@ -34,6 +34,7 @@ #include "qemu-common.h" #define NO_CPU_IO_DEFS #include "cpu.h" +#include "trace.h" #include "disas/disas.h" #include "tcg.h" #if defined(CONFIG_USER_ONLY) @@ -177,6 +178,8 @@ int cpu_gen_code(CPUArchState *env, TranslationBlock *tb, int *gen_code_size_ptr gen_intermediate_code(env, tb); + trace_translate_block(tb, tb->pc, tb->tc_ptr); + /* generate machine code */ gen_code_buf = tb->tc_ptr; tb->tb_next_offset[0] = 0xffff;