From nobody Fri Dec 19 20:13:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1600797133; cv=none; d=zohomail.com; s=zohoarc; b=aUN0VEm4X/qvR3mc/diY6uWMOK32n+3C3dJNg9ADKLZClI8PWP/bd3/gFnO973e8g968BnbRtux+gC7KyBR8GiOa4YoigUoZRJJFUxnN2s4z+qpKs/T4K6Fg9+2caYa58KX9FMXtcLZUVpD9NMGSA9OSDQePUwKL4HHYzdZtnQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600797133; 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; bh=CzXADkkcwqXZtobMqRgIZ6k008MJ95TKA8X3VHJ5T3U=; b=NJr4h8kAzwIBfsnTK72VhlfZBueXrt9XwIZeaEbB6bMWbxQt9Tmdtb5xwr2wqqnAqUrgVcn58P9d37ByP+40CFyYuuYCdiDdo27FLuAiXY1yFAiWPb2vtgpKoEoZqq6B40dbFRriYzjFEXggOSZeVwbcb8+v0v+C0LOf/y82lrw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass 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 1600797133626705.3476543799691; Tue, 22 Sep 2020 10:52:13 -0700 (PDT) Received: from localhost ([::1]:56372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKmSa-0003J8-5v for importer@patchew.org; Tue, 22 Sep 2020 13:52:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKmOf-0007yD-6W for qemu-devel@nongnu.org; Tue, 22 Sep 2020 13:48:09 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:40152) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKmOW-0004Ks-7i for qemu-devel@nongnu.org; Tue, 22 Sep 2020 13:48:07 -0400 Received: by mail-pg1-x52d.google.com with SMTP id k133so7810101pgc.7 for ; Tue, 22 Sep 2020 10:47:52 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id r1sm14825310pgl.66.2020.09.22.10.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 10:47:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CzXADkkcwqXZtobMqRgIZ6k008MJ95TKA8X3VHJ5T3U=; b=pXl4JIWdqO+G90JBZGgr51GEsVfBjrIMi/z5bvv4pJ3x8rj6ugGUqnB8/XzawS8NZO r2blOOhMXYLS5FQWjq72k4BCeuhhx9lUL53QWgo598aqBunR6tva+JB356DfpiNlqIIA 3I0eztV0m9frnssLO1z711MDVMSE0S+IW44Ie/7DviAQTFOEPPnspIiIi0Ergw85DYlv d+gkNE4asJfM6mRqcd9c+OoeWLGOvfgU0gsQTKtPBGPOSeSBIGQ2/mONxR1jM4yEBU0N 1473eWmHm7I5h+CX3QbgRRIydi8cijLly8RQF6U3LuL1nFanDMzJb/1Qi2yZeZD9TiMw xzvQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=CzXADkkcwqXZtobMqRgIZ6k008MJ95TKA8X3VHJ5T3U=; b=bnEBF9vyJY+YUvrqHGWKDynntwzsGiQ6gjmCRIG8j0jABUMPpKg6egHSo6TzJ8igoE R9Ww2VS+CLNkIr8p8qvGbEJluzH8x1jY39cCSIaTWjyv6bkeQhOa5XIIt2Tl36CmKxaZ 9TzR80jyvbderjJQ7MFyfqCC7RrOTya3tErfOwbbh1EQjAdIO6ziQ15UOCnmU2YY+0WB lDku0HHHQ7T7Z5XxWkdAPcxWe1r41BMDc3QoaPTG7Q3ky1vmt++kUmSCgdbPfHnNf+WE WFFC0a3TLO/MHdqMr3BLnJcq7qDd10bkHA7223r4dEvSI/DbkuBFYnocdTDpV/ZR8e1S AgWQ== X-Gm-Message-State: AOAM533IBPjqY5bLsmKM6NcV/WEFPJXD6I5Qvr3zCUG6UbcKbLWiqWMv RUu0ez+YpsgfK7JzSb/ph3+cIOttClXHAw== X-Google-Smtp-Source: ABdhPJxeOt/K4mKPisiJoAFF2GJFHZCvC457NNe/ITK8x5enway30MPhzQSnODDNeMiVlwQuqrbI6Q== X-Received: by 2002:a17:902:b186:b029:d1:cc21:9a7d with SMTP id s6-20020a170902b186b02900d1cc219a7dmr5637042plr.8.1600796870648; Tue, 22 Sep 2020 10:47:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 04/11] disas: Move host asm annotations to tb_gen_code Date: Tue, 22 Sep 2020 10:47:34 -0700 Message-Id: <20200922174741.475876-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922174741.475876-1-richard.henderson@linaro.org> References: <20200922174741.475876-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Thomas Huth , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Instead of creating GStrings and passing them into log_disas, just print the annotations directly in tb_gen_code. Fix the annotations for the slow paths of the TB, after the part implementing the final guest instruction. Reviewed-by: Thomas Huth Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- include/disas/disas.h | 2 +- include/exec/log.h | 4 ++-- accel/tcg/translate-all.c | 24 +++++++++++++++--------- disas.c | 29 +++++++++-------------------- tcg/tcg.c | 4 ++-- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/include/disas/disas.h b/include/disas/disas.h index 1b6e035e32..36c33f6f19 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -7,7 +7,7 @@ #include "cpu.h" =20 /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, void *code, unsigned long size, const char *note); +void disas(FILE *out, void *code, unsigned long size); void target_disas(FILE *out, CPUState *cpu, target_ulong code, target_ulong size); =20 diff --git a/include/exec/log.h b/include/exec/log.h index 3ed797c1c8..fcc7b9e00b 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -56,13 +56,13 @@ static inline void log_target_disas(CPUState *cpu, targ= et_ulong start, rcu_read_unlock(); } =20 -static inline void log_disas(void *code, unsigned long size, const char *n= ote) +static inline void log_disas(void *code, unsigned long size) { QemuLogFile *logfile; rcu_read_lock(); logfile =3D atomic_rcu_read(&qemu_logfile); if (logfile) { - disas(logfile->fd, code, size, note); + disas(logfile->fd, code, size); } rcu_read_unlock(); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 2d83013633..2874104a6a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1815,10 +1815,9 @@ TranslationBlock *tb_gen_code(CPUState *cpu, qemu_log_in_addr_range(tb->pc)) { FILE *logfile =3D qemu_log_lock(); int code_size, data_size =3D 0; - g_autoptr(GString) note =3D g_string_new("[tb header & initial ins= truction]"); - size_t chunk_start =3D 0; + size_t chunk_start; int insn =3D 0; - qemu_log("OUT: [size=3D%d]\n", gen_code_size); + if (tcg_ctx->data_gen_ptr) { code_size =3D tcg_ctx->data_gen_ptr - tb->tc.ptr; data_size =3D gen_code_size - code_size; @@ -1827,26 +1826,33 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } =20 /* Dump header and the first instruction */ + qemu_log("OUT: [size=3D%d]\n", gen_code_size); + qemu_log(" -- guest addr 0x" TARGET_FMT_lx " + tb prologue\n", + tcg_ctx->gen_insn_data[insn][0]); chunk_start =3D tcg_ctx->gen_insn_end_off[insn]; - log_disas(tb->tc.ptr, chunk_start, note->str); + log_disas(tb->tc.ptr, chunk_start); =20 /* * Dump each instruction chunk, wrapping up empty chunks into * the next instruction. The whole array is offset so the * first entry is the beginning of the 2nd instruction. */ - while (insn <=3D tb->icount && chunk_start < code_size) { + while (insn < tb->icount) { size_t chunk_end =3D tcg_ctx->gen_insn_end_off[insn]; if (chunk_end > chunk_start) { - g_string_printf(note, "[guest addr: " TARGET_FMT_lx "]", - tcg_ctx->gen_insn_data[insn][0]); - log_disas(tb->tc.ptr + chunk_start, chunk_end - chunk_star= t, - note->str); + qemu_log(" -- guest addr 0x" TARGET_FMT_lx "\n", + tcg_ctx->gen_insn_data[insn][0]); + log_disas(tb->tc.ptr + chunk_start, chunk_end - chunk_star= t); chunk_start =3D chunk_end; } insn++; } =20 + if (chunk_start < code_size) { + qemu_log(" -- tb slow paths + alignment\n"); + log_disas(tb->tc.ptr + chunk_start, code_size - chunk_start); + } + /* Finally dump any data we may have after the block */ if (data_size) { int i; diff --git a/disas.c b/disas.c index c1397d3933..a4304e8137 100644 --- a/disas.c +++ b/disas.c @@ -262,8 +262,7 @@ static void cap_dump_insn_units(disassemble_info *info,= cs_insn *insn, } } =20 -static void cap_dump_insn(disassemble_info *info, cs_insn *insn, - const char *note) +static void cap_dump_insn(disassemble_info *info, cs_insn *insn) { fprintf_function print =3D info->fprintf_func; int i, n, split; @@ -284,11 +283,7 @@ static void cap_dump_insn(disassemble_info *info, cs_i= nsn *insn, } =20 /* Print the actual instruction. */ - print(info->stream, " %-8s %s", insn->mnemonic, insn->op_str); - if (note) { - print(info->stream, "\t\t%s", note); - } - print(info->stream, "\n"); + print(info->stream, " %-8s %s\n", insn->mnemonic, insn->op_str); =20 /* Dump any remaining part of the insn on subsequent lines. */ for (i =3D split; i < n; i +=3D split) { @@ -320,7 +315,7 @@ static bool cap_disas_target(disassemble_info *info, ui= nt64_t pc, size_t size) size -=3D tsize; =20 while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { - cap_dump_insn(info, insn, NULL); + cap_dump_insn(info, insn); } =20 /* If the target memory is not consumed, go back for more... */ @@ -349,8 +344,7 @@ static bool cap_disas_target(disassemble_info *info, ui= nt64_t pc, size_t size) } =20 /* Disassemble SIZE bytes at CODE for the host. */ -static bool cap_disas_host(disassemble_info *info, void *code, size_t size, - const char *note) +static bool cap_disas_host(disassemble_info *info, void *code, size_t size) { csh handle; const uint8_t *cbuf; @@ -366,8 +360,7 @@ static bool cap_disas_host(disassemble_info *info, void= *code, size_t size, pc =3D (uintptr_t)code; =20 while (cs_disasm_iter(handle, &cbuf, &size, &pc, insn)) { - cap_dump_insn(info, insn, note); - note =3D NULL; + cap_dump_insn(info, insn); } if (size !=3D 0) { (*info->fprintf_func)(info->stream, @@ -411,7 +404,7 @@ static bool cap_disas_monitor(disassemble_info *info, u= int64_t pc, int count) csize +=3D tsize; =20 if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { - cap_dump_insn(info, insn, NULL); + cap_dump_insn(info, insn); if (--count <=3D 0) { break; } @@ -425,7 +418,7 @@ static bool cap_disas_monitor(disassemble_info *info, u= int64_t pc, int count) #endif /* !CONFIG_USER_ONLY */ #else # define cap_disas_target(i, p, s) false -# define cap_disas_host(i, p, s, n) false +# define cap_disas_host(i, p, s) false # define cap_disas_monitor(i, p, c) false # define cap_disas_plugin(i, p, c) false #endif /* CONFIG_CAPSTONE */ @@ -595,7 +588,7 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t= size) } =20 /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, void *code, unsigned long size, const char *note) +void disas(FILE *out, void *code, unsigned long size) { uintptr_t pc; int count; @@ -673,7 +666,7 @@ void disas(FILE *out, void *code, unsigned long size, c= onst char *note) print_insn =3D print_insn_hppa; #endif =20 - if (s.info.cap_arch >=3D 0 && cap_disas_host(&s.info, code, size, note= )) { + if (s.info.cap_arch >=3D 0 && cap_disas_host(&s.info, code, size)) { return; } =20 @@ -683,10 +676,6 @@ void disas(FILE *out, void *code, unsigned long size, = const char *note) for (pc =3D (uintptr_t)code; size > 0; pc +=3D count, size -=3D count)= { fprintf(out, "0x%08" PRIxPTR ": ", pc); count =3D print_insn(pc, &s.info); - if (note) { - fprintf(out, "\t\t%s", note); - note =3D NULL; - } fprintf(out, "\n"); if (count < 0) { break; diff --git a/tcg/tcg.c b/tcg/tcg.c index 62f299e36e..9a111ce604 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1101,7 +1101,7 @@ void tcg_prologue_init(TCGContext *s) size_t data_size =3D prologue_size - code_size; size_t i; =20 - log_disas(buf0, code_size, NULL); + log_disas(buf0, code_size); =20 for (i =3D 0; i < data_size; i +=3D sizeof(tcg_target_ulong)) { if (sizeof(tcg_target_ulong) =3D=3D 8) { @@ -1115,7 +1115,7 @@ void tcg_prologue_init(TCGContext *s) } } } else { - log_disas(buf0, prologue_size, NULL); + log_disas(buf0, prologue_size); } qemu_log("\n"); qemu_log_flush(); --=20 2.25.1