From nobody Sat May 11 09:00:17 2024 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=1683650070; cv=none; d=zohomail.com; s=zohoarc; b=eQCxR93R3DKsi2cbyXlEP1SMKw65R8k+jdd37XAkOf75jIGuhWJCTE55Rd/Aq3tVNJKr95DuQtfSNMXYVYM7yNmqKqDjWgUqi5e23A3NedQGE0NKzSb9u0gNyqTUlwTDksKVIiLfLhM3KxizILR6SdO4kMIrFeCAOxcbmFMLOKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683650070; h=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=tk/Olu2Bf85J93sQfImDeFqS8c5LlV3FpMEjcgGhhmo=; b=VmPMgZ1WjBiALNzVsFWm86BzoLxqB9DEPtEngqNLcN9+Q0fu6+/szegr8NSa6Zd4FJhawYOOw0nEOgQ3E/GAfe5d56dkPPLhiENOEz2Gvtu+Sn9oXsKq/w95+k2KUwZcq8pn3kmGspturyuDPJqgqTwtiEuhIstawzvSPP8tjQ0= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683650070175335.56814887946166; Tue, 9 May 2023 09:34:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwQHO-0004gj-9Z; Tue, 09 May 2023 12:33:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwQHM-0004g6-He for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:32 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwQHJ-0007W4-UD for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:32 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3062b101ae1so3922549f8f.2 for ; Tue, 09 May 2023 09:33:29 -0700 (PDT) Received: from stoup.. ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e1-20020adfdbc1000000b0030795249ffasm7393298wrj.92.2023.05.09.09.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 09:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683650008; x=1686242008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tk/Olu2Bf85J93sQfImDeFqS8c5LlV3FpMEjcgGhhmo=; b=eGCKOfeiqbtPsifTphZYfQauUGLIJZYYRwJbi4KDonDeSbGSz+g0XdLaYQPGcZFqSC jbloXOO9BmEl01/gd1yl63TCQzRVQfKoGvRMlokGvsFPJqM2g0kgYXEaLFk8oEzoS7zb Gm5cIidv+QJNFhZenOmeB+DxdDJpOaNjFMF/blWqVBNQCqNrh8I9cSlbvBdDaMMvP8o6 AzcuFwsTtpMNXP5J1dSgEqMweDQdwQdidjDECqfpHGIbxR7IN7udkAOLxSAJOt5vKIni zJNdAL9eJCMVkTW78RgofXPYY/7T1gSzpP2t13DgZepYjjOB5FsvpKAR+Jswgog1whdA PG6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683650008; x=1686242008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tk/Olu2Bf85J93sQfImDeFqS8c5LlV3FpMEjcgGhhmo=; b=WV3LStnObpqdf6qlT66pcG9ZNT+LmNvdSLQ3zYjC5XXhQXf14MrznUF/Q1nY8gOf/f 0m6rv836IlWnFuXzzq+Ru+24ew2XyLBox2hS8NbXa1g2jGDmG7nOq3qa0dQJV/kUSUZ/ x4KFsJ4Fvs7MZez5QAn6aPBJCP0nkrZGNpZ8G+MvjbR2N4v+ET45vOIcQ1GN0n4gkwrD bYttrqErq1ONSUzl3YQCAGV+zJoWmlct1ehxy2W701PsSCakteVKC9USXLi8VUMZy6W4 zP8cH0xfd2UwjszhjPn8SjMRXFsxx+dO1GQh4cRhSNGeQcdFCr+uaXr1YnoYyKEpFSIB 7mGA== X-Gm-Message-State: AC+VfDxKA4tdrpllJyC50+dSqyU3nf9bymsPo1Mlq4uHYiXIBMcgJLxs 7tEhKVAtORht3oIw829SaA05sJX1gvcb6mIHISvuKQ== X-Google-Smtp-Source: ACHHUZ7AImXL/d+ISao7ILFDt3aDEFwAV2kNJ1dHcKUORAPYBKLxptlgZaUspUFUe5PJ5WMcrnhibQ== X-Received: by 2002:a05:6000:1148:b0:306:36e7:db27 with SMTP id d8-20020a056000114800b0030636e7db27mr10225513wrx.16.1683650008443; Tue, 09 May 2023 09:33:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: anjo@rev.ng, philmd@linaro.org, thuth@redhat.com Subject: [PATCH v2 1/5] disas: Move disas.c to disas/ Date: Tue, 9 May 2023 17:33:22 +0100 Message-Id: <20230509163326.121090-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509163326.121090-1-richard.henderson@linaro.org> References: <20230509163326.121090-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42d.google.com 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683650072008100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Thomas Huth Signed-off-by: Richard Henderson Message-Id: <20230503072331.1747057-80-richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- meson.build | 3 --- disas.c =3D> disas/disas.c | 0 disas/meson.build | 4 +++- 3 files changed, 3 insertions(+), 4 deletions(-) rename disas.c =3D> disas/disas.c (100%) diff --git a/meson.build b/meson.build index 229eb585f7..d56358b65f 100644 --- a/meson.build +++ b/meson.build @@ -3152,9 +3152,6 @@ specific_ss.add(files('cpu.c')) =20 subdir('softmmu') =20 -common_ss.add(capstone) -specific_ss.add(files('disas.c'), capstone) - # Work around a gcc bug/misfeature wherein constant propagation looks # through an alias: # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99696 diff --git a/disas.c b/disas/disas.c similarity index 100% rename from disas.c rename to disas/disas.c diff --git a/disas/meson.build b/disas/meson.build index c865bdd882..cbf6315f25 100644 --- a/disas/meson.build +++ b/disas/meson.build @@ -10,4 +10,6 @@ common_ss.add(when: 'CONFIG_RISCV_DIS', if_true: files('r= iscv.c')) common_ss.add(when: 'CONFIG_SH4_DIS', if_true: files('sh4.c')) common_ss.add(when: 'CONFIG_SPARC_DIS', if_true: files('sparc.c')) common_ss.add(when: 'CONFIG_XTENSA_DIS', if_true: files('xtensa.c')) -common_ss.add(when: capstone, if_true: files('capstone.c')) +common_ss.add(when: capstone, if_true: [files('capstone.c'), capstone]) + +specific_ss.add(files('disas.c'), capstone) --=20 2.34.1 From nobody Sat May 11 09:00:17 2024 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=1683650033; cv=none; d=zohomail.com; s=zohoarc; b=cHjINyNUckD5DqasSOL1CAoo3t+fyn+AoiynJaR9bvu7qoSIeNKrIMor6ZdoORMpdiK2CSTP2wql1rtvQAJRfsWaJSudBxcTofVAXnKkGLteuJAMIYWFzC0qv2649h08bcuEW+EZ6FiTxImQ+YhwXTJ5ypta5+seReYo2+cQues= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683650033; h=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=rGlQDLvqKUT4+MDaEXLHZhgv8xrgNwzz15sJXDY+k8U=; b=MrD0c6paBhkIPWz/nk38O2OFoyODfSzh+ut+0tvaRcPPGAUYBxTSPjKYTmWkP801Ih/GNqxiSsBbTZULpgBhK45ci/QFT+gcnsk5eJRIvcnau0hm7nLvXsBscy+m7auzM7Z+vskNremWJbV7eTXBnwbfDCQ0pkUCorPE2NuKQ/g= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168365003344674.27605809753527; Tue, 9 May 2023 09:33:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwQHO-0004gr-Sx; Tue, 09 May 2023 12:33:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwQHM-0004gG-RP for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:32 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwQHK-0007W8-PP for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:32 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-30771c68a9eso5397087f8f.2 for ; Tue, 09 May 2023 09:33:30 -0700 (PDT) Received: from stoup.. ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e1-20020adfdbc1000000b0030795249ffasm7393298wrj.92.2023.05.09.09.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 09:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683650009; x=1686242009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rGlQDLvqKUT4+MDaEXLHZhgv8xrgNwzz15sJXDY+k8U=; b=n9gQkaJUio5C9LeNKNDVP3HadzEUExANS2bxUS4+BhYwFv5dj2IwA0JJxpK4TT3+2a TklcGADdrko/17VcRub4nGTrzKkJ4bTDrDbETCGvn89q4WJEss5Q+oJkMCbykZRJUrhA MjKo4LtLT2KA6J+XXUWw5MJziVwA116099jaKm8I6/RHktTtF2DqjMnb95xascM/hIL2 Nx+J4FZyb7k8Ts5fuQSraT102dcpVsuvEC4yBXZyQQyzFwJpDMyJBFGklPtpyEvClBv5 f3YI/++l55krloSau3pSzMlR89DkAHX74dQ93aF8kAmsytchbwWhwOebdo9I2Fk0fxhT Vugw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683650009; x=1686242009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rGlQDLvqKUT4+MDaEXLHZhgv8xrgNwzz15sJXDY+k8U=; b=KrFOE64Gt7ZPRByxSj0/N7ZCM6YsrioDCOf9ssOC39PMKDUCRsYztagh6Ux6opB+8K TDvO+jISkXyC5oTuWv/KOzkGGoNCe8Ry8f1MYwWneDTOFxVT70k9TxI8qHuSyKgvFmAF NE5Q8F1wBlvKKvCRYJrUXd+QNLY154wKhZ/XpHrZDthIUitDaW8mADWoxqT61QyDNKMx xW1SZgBCeAyU1SChbYV/85dRhGEIF2iDeYT+NhZj0Sxt4YEtxV7fTWhSCn5jjFgE2i2A AstRd58T+MtzmMpw16HuE3q8pn2I2CFVftAwhSpR2LUtB+9A8LmbHY6BaSNJV0aMSoBb cjDw== X-Gm-Message-State: AC+VfDy3UEUxGQSkF4U7kT/ViXHpZ3NakxfTNOQ82oRGffr8QI17U2BG scM0IxCXE59xUgSf5m7pk4eqQNVUGUIe23IUOSAicw== X-Google-Smtp-Source: ACHHUZ6m3GYcC5XniH4TzRIVGDGZFcCPZ1EIFXdfc+P6D2WgUDi8773P+LAERrsMEKNP0gBhntdB3A== X-Received: by 2002:adf:ff85:0:b0:307:92e8:ec60 with SMTP id j5-20020adfff85000000b0030792e8ec60mr5630096wrr.39.1683650009133; Tue, 09 May 2023 09:33:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: anjo@rev.ng, philmd@linaro.org, thuth@redhat.com Subject: [PATCH v2 2/5] disas: Remove target_ulong from the interface Date: Tue, 9 May 2023 17:33:23 +0100 Message-Id: <20230509163326.121090-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509163326.121090-1-richard.henderson@linaro.org> References: <20230509163326.121090-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42d.google.com 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683650035652100003 Content-Type: text/plain; charset="utf-8" Use uint64_t for the pc, and size_t for the size. Signed-off-by: Richard Henderson Message-Id: <20230503072331.1747057-81-richard.henderson@linaro.org> Reviewed-by: Thomas Huth --- include/disas/disas.h | 17 ++++++----------- bsd-user/elfload.c | 5 +++-- disas/disas.c | 19 +++++++++---------- linux-user/elfload.c | 5 +++-- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/include/disas/disas.h b/include/disas/disas.h index d363e95ede..6c394e0b09 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -7,28 +7,23 @@ #include "cpu.h" =20 /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, const void *code, unsigned long size); -void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size); +void disas(FILE *out, const void *code, size_t size); +void target_disas(FILE *out, CPUState *cpu, uint64_t code, size_t size); =20 -void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical); +void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc, + int nb_insn, bool is_physical); =20 char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size); =20 /* Look up symbol for debugging purpose. Returns "" if unknown. */ -const char *lookup_symbol(target_ulong orig_addr); +const char *lookup_symbol(uint64_t orig_addr); #endif =20 struct syminfo; struct elf32_sym; struct elf64_sym; =20 -#if defined(CONFIG_USER_ONLY) -typedef const char *(*lookup_symbol_t)(struct syminfo *s, target_ulong ori= g_addr); -#else -typedef const char *(*lookup_symbol_t)(struct syminfo *s, hwaddr orig_addr= ); -#endif +typedef const char *(*lookup_symbol_t)(struct syminfo *s, uint64_t orig_ad= dr); =20 struct syminfo { lookup_symbol_t lookup_symbol; diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c index fbcdc94b96..2e76f0d3b5 100644 --- a/bsd-user/elfload.c +++ b/bsd-user/elfload.c @@ -352,9 +352,10 @@ static abi_ulong load_elf_interp(struct elfhdr *interp= _elf_ex, =20 static int symfind(const void *s0, const void *s1) { - target_ulong addr =3D *(target_ulong *)s0; + __typeof(sym->st_value) addr =3D *(uint64_t *)s0; struct elf_sym *sym =3D (struct elf_sym *)s1; int result =3D 0; + if (addr < sym->st_value) { result =3D -1; } else if (addr >=3D sym->st_value + sym->st_size) { @@ -363,7 +364,7 @@ static int symfind(const void *s0, const void *s1) return result; } =20 -static const char *lookup_symbolxx(struct syminfo *s, target_ulong orig_ad= dr) +static const char *lookup_symbolxx(struct syminfo *s, uint64_t orig_addr) { #if ELF_CLASS =3D=3D ELFCLASS32 struct elf_sym *syms =3D s->disas_symtab.elf32; diff --git a/disas/disas.c b/disas/disas.c index b087c12c47..f5e95043cf 100644 --- a/disas/disas.c +++ b/disas/disas.c @@ -204,10 +204,9 @@ static void initialize_debug_host(CPUDebug *s) } =20 /* Disassemble this for me please... (debugging). */ -void target_disas(FILE *out, CPUState *cpu, target_ulong code, - target_ulong size) +void target_disas(FILE *out, CPUState *cpu, uint64_t code, size_t size) { - target_ulong pc; + uint64_t pc; int count; CPUDebug s; =20 @@ -226,7 +225,7 @@ void target_disas(FILE *out, CPUState *cpu, target_ulon= g code, } =20 for (pc =3D code; size > 0; pc +=3D count, size -=3D count) { - fprintf(out, "0x" TARGET_FMT_lx ": ", pc); + fprintf(out, "0x%08" PRIx64 ": ", pc); count =3D s.info.print_insn(pc, &s.info); fprintf(out, "\n"); if (count < 0) @@ -292,7 +291,7 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t= size) } =20 /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, const void *code, unsigned long size) +void disas(FILE *out, const void *code, size_t size) { uintptr_t pc; int count; @@ -324,7 +323,7 @@ void disas(FILE *out, const void *code, unsigned long s= ize) } =20 /* Look up symbol for debugging purpose. Returns "" if unknown. */ -const char *lookup_symbol(target_ulong orig_addr) +const char *lookup_symbol(uint64_t orig_addr) { const char *symbol =3D ""; struct syminfo *s; @@ -356,8 +355,8 @@ physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr,= int length, } =20 /* Disassembler for the monitor. */ -void monitor_disas(Monitor *mon, CPUState *cpu, - target_ulong pc, int nb_insn, int is_physical) +void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc, + int nb_insn, bool is_physical) { int count, i; CPUDebug s; @@ -378,13 +377,13 @@ void monitor_disas(Monitor *mon, CPUState *cpu, } =20 if (!s.info.print_insn) { - monitor_printf(mon, "0x" TARGET_FMT_lx + monitor_printf(mon, "0x%08" PRIx64 ": Asm output not supported on this arch\n", pc); return; } =20 for (i =3D 0; i < nb_insn; i++) { - g_string_append_printf(ds, "0x" TARGET_FMT_lx ": ", pc); + g_string_append_printf(ds, "0x%08" PRIx64 ": ", pc); count =3D s.info.print_insn(pc, &s.info); g_string_append_c(ds, '\n'); if (count < 0) { diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 703f7434a0..80085b8a30 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3327,9 +3327,10 @@ static void load_elf_interp(const char *filename, st= ruct image_info *info, =20 static int symfind(const void *s0, const void *s1) { - target_ulong addr =3D *(target_ulong *)s0; struct elf_sym *sym =3D (struct elf_sym *)s1; + __typeof(sym->st_value) addr =3D *(uint64_t *)s0; int result =3D 0; + if (addr < sym->st_value) { result =3D -1; } else if (addr >=3D sym->st_value + sym->st_size) { @@ -3338,7 +3339,7 @@ static int symfind(const void *s0, const void *s1) return result; } =20 -static const char *lookup_symbolxx(struct syminfo *s, target_ulong orig_ad= dr) +static const char *lookup_symbolxx(struct syminfo *s, uint64_t orig_addr) { #if ELF_CLASS =3D=3D ELFCLASS32 struct elf_sym *syms =3D s->disas_symtab.elf32; --=20 2.34.1 From nobody Sat May 11 09:00:17 2024 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=1683650102; cv=none; d=zohomail.com; s=zohoarc; b=ZfJdzs3aZMt/TZxaYkm2wsg74WV6lIjcW4eGGxYLjU2y3vivFy0J8UZOBwPVPOKntLKTt5s04tO7r3x0RBa1G8cc0AIlXr2MnwMwjUJCtvabx383fqEqUUAGmVAh+5UANvah3ZjvGFDmEAdwQlV51JpoQ8x9zxRx/WHHbRFN5/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683650102; h=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=Cpop6LoNqSh03hm8vCAMJ2YCthnibtXTEV61F8HsXUQ=; b=SP6kEb+ozyWllgfVp3roN2iq+ESqgVZVP0uo7ncZstlxgB3nCOhiv+GGLkPDy3EVWgYnHYdu/3kCFCMUvLI8BCi13luPNweosicRIFWnqr+JBnScS3UkhUst3f/m51yaRY+8pQXhhmODVl93IDboMIVF+ywx+GjqWHtQw9cmiR8= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683650101843816.442914222601; Tue, 9 May 2023 09:35:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwQHP-0004hE-4l; Tue, 09 May 2023 12:33:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwQHM-0004gK-SE for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:32 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwQHL-0007WC-2A for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:32 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3063208beedso5805546f8f.1 for ; Tue, 09 May 2023 09:33:30 -0700 (PDT) Received: from stoup.. ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e1-20020adfdbc1000000b0030795249ffasm7393298wrj.92.2023.05.09.09.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 09:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683650009; x=1686242009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cpop6LoNqSh03hm8vCAMJ2YCthnibtXTEV61F8HsXUQ=; b=Gnbku9bU8tkmG9/1YTCWcWsvrvchaT08/PvOC9S0ptmWnC6a/zhQjFkQoGH0HAyzO7 qgtXLl+zupYiNBnsGIW5/k972QRVOvDV5njCan85s0PaJo5vDGE6CNZ4GOqm8u7XLPv+ O83u+0gHzha54lZXoAxdQSyBu7V8xJcI+bnH7SnRNbrmYWgBDs4vnhyVPS4gu6zutULD cPlDb4WknMZn5InwQ3Zx+3Fsfz3pOw+M37xCf63V6tbog5XE4B7l3LOV7fstQfWCL+sD 7xTy9ChPG3+5EQHKfVfr5fsyjszn8upYPCEkjrp0Z3O5KpzTc6OIxqErrlYqSriyfOAT huFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683650009; x=1686242009; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cpop6LoNqSh03hm8vCAMJ2YCthnibtXTEV61F8HsXUQ=; b=H0RMx1VbEgFpl7AAlEgn5qC62XT9RkLZsCqcQNSXBpq7ZMmZ6iANGFAM/MH/b1lxHN fuEBRF+Rz+DZBwGOCJOJxho+206EOjmSsIYWH7F4YK8GHemmwOVgzMqCFbkL7RcOH3qe p80fSUXFlhpECDX5DTD65HGY1GINOBJTlXeqltBRxtFKSasa7ZAUuq4Mz0GLFMYh5aYs GYDTP5QWn8XJj9Ykir2h6adi9sA2BzyrXvGPaTjaOSzNi1BMhcdgrPFaWpkDc1lKQy+b urYux4qgRXXIqKvumoM5127zxUbrq1dcFNYDy3SwlnKsAxZcy7/fd/Hxb9TYCWCyaTiu eOkA== X-Gm-Message-State: AC+VfDySeXHzGRswmaiFwBfq5xVrp8K/cqqVqosakqKGF0jC4M+qaEKr WHdZOuS+7wvpp8c0nYmEnaj9AdeQVeUL6Ao4KB1f2g== X-Google-Smtp-Source: ACHHUZ7QTlB12sNI4EsYgmugi92LM2uBhTLDDvQ3QdU8lqbHTffSv8rpUjoqrD+yMW3Ry1PN1fUfww== X-Received: by 2002:adf:f145:0:b0:2ef:b052:1296 with SMTP id y5-20020adff145000000b002efb0521296mr11668763wro.22.1683650009736; Tue, 09 May 2023 09:33:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: anjo@rev.ng, philmd@linaro.org, thuth@redhat.com Subject: [PATCH v2 3/5] disas: Remove target-specific headers Date: Tue, 9 May 2023 17:33:24 +0100 Message-Id: <20230509163326.121090-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509163326.121090-1-richard.henderson@linaro.org> References: <20230509163326.121090-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x429.google.com 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683650104257100003 Content-Type: text/plain; charset="utf-8" Reviewed-by: Thomas Huth Signed-off-by: Richard Henderson Message-Id: <20230503072331.1747057-83-richard.henderson@linaro.org> --- include/disas/disas.h | 6 ------ disas/disas.c | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/disas/disas.h b/include/disas/disas.h index 6c394e0b09..176775eff7 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -1,11 +1,6 @@ #ifndef QEMU_DISAS_H #define QEMU_DISAS_H =20 -#include "exec/hwaddr.h" - -#ifdef NEED_CPU_H -#include "cpu.h" - /* Disassemble this for me please... (debugging). */ void disas(FILE *out, const void *code, size_t size); void target_disas(FILE *out, CPUState *cpu, uint64_t code, size_t size); @@ -17,7 +12,6 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t s= ize); =20 /* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol(uint64_t orig_addr); -#endif =20 struct syminfo; struct elf32_sym; diff --git a/disas/disas.c b/disas/disas.c index f5e95043cf..a709831e8d 100644 --- a/disas/disas.c +++ b/disas/disas.c @@ -3,9 +3,10 @@ #include "disas/dis-asm.h" #include "elf.h" #include "qemu/qemu-print.h" - #include "disas/disas.h" #include "disas/capstone.h" +#include "hw/core/cpu.h" +#include "exec/memory.h" =20 typedef struct CPUDebug { struct disassemble_info info; --=20 2.34.1 From nobody Sat May 11 09:00:17 2024 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=1683650057; cv=none; d=zohomail.com; s=zohoarc; b=ehfN0DAABTXOHiZ8amEIJmyGpM2debTxk9PSEwP6ZJrtMiLREf+p1iZyNhRnej/6GgVFRdYhGDj48uURn5qsQz8oie0g4Pa/eXSL6rY/qI2SCWSxeIFegDyjmBG3Sxi3v45q3MH0vzKS2p6YGsXbSXOEQk6/brv4BCpJgcMJE8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683650057; h=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=JHlvoUuo7umR5TkZZj4NdZf0miPVK+cLHtVt5b6lJNg=; b=AD6s5qCnjGXSXpgCWtPVV2igv903TvEPYdKtUY2UabeZtD9XBNTyMIbBhZ8XIsrOn14rakRxM/xtNYwV3S0fpHOuHDDwy2HnPijMWYV5lNgecrJtwTYAUvfSF6ejO4ojGvE5l4miXElPIyYLv9Xm+6SLfDZD8QkYa8hFx8fxf2w= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683650057827446.10651203682664; Tue, 9 May 2023 09:34:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwQHS-0004ib-ID; Tue, 09 May 2023 12:33:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwQHQ-0004hn-Ao for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:36 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwQHL-0007WM-VL for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:35 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3078cc99232so3177241f8f.3 for ; Tue, 09 May 2023 09:33:31 -0700 (PDT) Received: from stoup.. ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e1-20020adfdbc1000000b0030795249ffasm7393298wrj.92.2023.05.09.09.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 09:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683650010; x=1686242010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JHlvoUuo7umR5TkZZj4NdZf0miPVK+cLHtVt5b6lJNg=; b=UKY9bPydCrEpftce+hGUO9TJV2rN/u8sjwhENyTGGmfriAJ/oQ0VfsfVBIqAjNfsIo u4qu76S6K4wm+QjPeo+gzvIjhSjNgZp5z9u42SYzyiHpcEKEaGPVFgix56RsM5QW2I1g 4tvjCgnCjfgw4rZSIHxDxTGlPjqwllJee1DMwE32xx1wQhM57xHDEYvI+icb8Rr0iHIe eQrnUsaZJX9/LKyac+jFbsA9rPRkB1mmRU9+IsII1hC+0vd6sCfQDyow3NIyPkihS4wW 1l4+TcoSIhAbAcoKuxF2z0e48/aJSBblGQER48Hs7DM9WOztIILbfa3ftHvdivGhAlU8 D4vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683650010; x=1686242010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JHlvoUuo7umR5TkZZj4NdZf0miPVK+cLHtVt5b6lJNg=; b=VzR7XX394WRa30BOoVOaXuuZT+0EHvBQ8l8GhcLDgWxB/lg5mrpdf8nFvsXg3D3qoV db5ROrO9UaV0t4djKQay3Cuz4bLviRa7d4KEHm06+xjo8mvCB5yHIcsyc48C1xfWWElO rEzuAfeNFvWOUrQB/Z/DJ7xIuiBUjImGu6sCu82ra8c44wreFJrMwD+GyqQAyx75TlLf xlUwRC9B3G5uspikFhF4UO24DT/Zlu6PHW6iA0fqTexylADbWOPBjKLHT2TSxLUmVl71 FgZ+flMpsCWgB/MS71nFr88kTI1ijay8nSvRLI9ILWeK+WzKzvyO5go17G7DSrfZbiuo Qdlg== X-Gm-Message-State: AC+VfDy+YYQ0/TWg3CtGc7laf6rZ0601MYMa4CZYfQCrPnxhEFL7V8MK oTWkzHWWYLxT7/niE8IKqCGDTwvg9OHgmePVwmgPpQ== X-Google-Smtp-Source: ACHHUZ5FjdXLz+aWPyJkBDXsdJ0+EuJM6cNyL4TR8kBVRzFicyqrlQHpfIn1xUQT+oQAH/wp28hINA== X-Received: by 2002:adf:f492:0:b0:307:a36b:e7b1 with SMTP id l18-20020adff492000000b00307a36be7b1mr2510667wro.5.1683650010377; Tue, 09 May 2023 09:33:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: anjo@rev.ng, philmd@linaro.org, thuth@redhat.com Subject: [PATCH v2 4/5] disas: Move softmmu specific code to separate file Date: Tue, 9 May 2023 17:33:25 +0100 Message-Id: <20230509163326.121090-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509163326.121090-1-richard.henderson@linaro.org> References: <20230509163326.121090-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::42b; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42b.google.com 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, T_PDS_OTHER_BAD_TLD=0.01, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683650059712100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth We'd like to move disas.c into the common code source set, where CONFIG_USER_ONLY is not available anymore. So we have to move the related code into a separate file instead. Signed-off-by: Thomas Huth [rth: Type change done in a separate patch] Signed-off-by: Richard Henderson --- disas/disas-internal.h | 21 ++++++++++++ disas/disas-mon.c | 65 ++++++++++++++++++++++++++++++++++++ disas/disas.c | 76 ++++-------------------------------------- disas/meson.build | 1 + 4 files changed, 93 insertions(+), 70 deletions(-) create mode 100644 disas/disas-internal.h create mode 100644 disas/disas-mon.c diff --git a/disas/disas-internal.h b/disas/disas-internal.h new file mode 100644 index 0000000000..84a01f126f --- /dev/null +++ b/disas/disas-internal.h @@ -0,0 +1,21 @@ +/* + * Definitions used internally in the disassembly code + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef DISAS_INTERNAL_H +#define DISAS_INTERNAL_H + +#include "disas/dis-asm.h" + +typedef struct CPUDebug { + struct disassemble_info info; + CPUState *cpu; +} CPUDebug; + +void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu); +int disas_gstring_printf(FILE *stream, const char *fmt, ...) + G_GNUC_PRINTF(2, 3); + +#endif diff --git a/disas/disas-mon.c b/disas/disas-mon.c new file mode 100644 index 0000000000..48ac492c6c --- /dev/null +++ b/disas/disas-mon.c @@ -0,0 +1,65 @@ +/* + * Functions related to disassembly from the monitor + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "disas-internal.h" +#include "disas/disas.h" +#include "exec/memory.h" +#include "hw/core/cpu.h" +#include "monitor/monitor.h" + +static int +physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, + struct disassemble_info *info) +{ + CPUDebug *s =3D container_of(info, CPUDebug, info); + MemTxResult res; + + res =3D address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED, + myaddr, length); + return res =3D=3D MEMTX_OK ? 0 : EIO; +} + +/* Disassembler for the monitor. */ +void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc, + int nb_insn, bool is_physical) +{ + int count, i; + CPUDebug s; + g_autoptr(GString) ds =3D g_string_new(""); + + disas_initialize_debug_target(&s, cpu); + s.info.fprintf_func =3D disas_gstring_printf; + s.info.stream =3D (FILE *)ds; /* abuse this slot */ + + if (is_physical) { + s.info.read_memory_func =3D physical_read_memory; + } + s.info.buffer_vma =3D pc; + + if (s.info.cap_arch >=3D 0 && cap_disas_monitor(&s.info, pc, nb_insn))= { + monitor_puts(mon, ds->str); + return; + } + + if (!s.info.print_insn) { + monitor_printf(mon, "0x%08" PRIx64 + ": Asm output not supported on this arch\n", pc); + return; + } + + for (i =3D 0; i < nb_insn; i++) { + g_string_append_printf(ds, "0x%08" PRIx64 ": ", pc); + count =3D s.info.print_insn(pc, &s.info); + g_string_append_c(ds, '\n'); + if (count < 0) { + break; + } + pc +=3D count; + } + + monitor_puts(mon, ds->str); +} diff --git a/disas/disas.c b/disas/disas.c index a709831e8d..5e7401bb6f 100644 --- a/disas/disas.c +++ b/disas/disas.c @@ -1,6 +1,6 @@ /* General "disassemble this chunk" code. Used for debugging. */ #include "qemu/osdep.h" -#include "disas/dis-asm.h" +#include "disas/disas-internal.h" #include "elf.h" #include "qemu/qemu-print.h" #include "disas/disas.h" @@ -8,11 +8,6 @@ #include "hw/core/cpu.h" #include "exec/memory.h" =20 -typedef struct CPUDebug { - struct disassemble_info info; - CPUState *cpu; -} CPUDebug; - /* Filled in by elfload.c. Simplistic, but will do for now. */ struct syminfo *syminfos =3D NULL; =20 @@ -120,7 +115,7 @@ static void initialize_debug(CPUDebug *s) s->info.symbol_at_address_func =3D symbol_at_address; } =20 -static void initialize_debug_target(CPUDebug *s, CPUState *cpu) +void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu) { initialize_debug(s); =20 @@ -211,7 +206,7 @@ void target_disas(FILE *out, CPUState *cpu, uint64_t co= de, size_t size) int count; CPUDebug s; =20 - initialize_debug_target(&s, cpu); + disas_initialize_debug_target(&s, cpu); s.info.fprintf_func =3D fprintf; s.info.stream =3D out; s.info.buffer_vma =3D code; @@ -241,8 +236,7 @@ void target_disas(FILE *out, CPUState *cpu, uint64_t co= de, size_t size) } } =20 -static int G_GNUC_PRINTF(2, 3) -gstring_printf(FILE *stream, const char *fmt, ...) +int disas_gstring_printf(FILE *stream, const char *fmt, ...) { /* We abuse the FILE parameter to pass a GString. */ GString *s =3D (GString *)stream; @@ -272,8 +266,8 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t= size) CPUDebug s; GString *ds =3D g_string_new(NULL); =20 - initialize_debug_target(&s, cpu); - s.info.fprintf_func =3D gstring_printf; + disas_initialize_debug_target(&s, cpu); + s.info.fprintf_func =3D disas_gstring_printf; s.info.stream =3D (FILE *)ds; /* abuse this slot */ s.info.buffer_vma =3D addr; s.info.buffer_length =3D size; @@ -338,61 +332,3 @@ const char *lookup_symbol(uint64_t orig_addr) =20 return symbol; } - -#if !defined(CONFIG_USER_ONLY) - -#include "monitor/monitor.h" - -static int -physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, - struct disassemble_info *info) -{ - CPUDebug *s =3D container_of(info, CPUDebug, info); - MemTxResult res; - - res =3D address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED, - myaddr, length); - return res =3D=3D MEMTX_OK ? 0 : EIO; -} - -/* Disassembler for the monitor. */ -void monitor_disas(Monitor *mon, CPUState *cpu, uint64_t pc, - int nb_insn, bool is_physical) -{ - int count, i; - CPUDebug s; - g_autoptr(GString) ds =3D g_string_new(""); - - initialize_debug_target(&s, cpu); - s.info.fprintf_func =3D gstring_printf; - s.info.stream =3D (FILE *)ds; /* abuse this slot */ - - if (is_physical) { - s.info.read_memory_func =3D physical_read_memory; - } - s.info.buffer_vma =3D pc; - - if (s.info.cap_arch >=3D 0 && cap_disas_monitor(&s.info, pc, nb_insn))= { - monitor_puts(mon, ds->str); - return; - } - - if (!s.info.print_insn) { - monitor_printf(mon, "0x%08" PRIx64 - ": Asm output not supported on this arch\n", pc); - return; - } - - for (i =3D 0; i < nb_insn; i++) { - g_string_append_printf(ds, "0x%08" PRIx64 ": ", pc); - count =3D s.info.print_insn(pc, &s.info); - g_string_append_c(ds, '\n'); - if (count < 0) { - break; - } - pc +=3D count; - } - - monitor_puts(mon, ds->str); -} -#endif diff --git a/disas/meson.build b/disas/meson.build index cbf6315f25..f40230c58f 100644 --- a/disas/meson.build +++ b/disas/meson.build @@ -12,4 +12,5 @@ common_ss.add(when: 'CONFIG_SPARC_DIS', if_true: files('s= parc.c')) common_ss.add(when: 'CONFIG_XTENSA_DIS', if_true: files('xtensa.c')) common_ss.add(when: capstone, if_true: [files('capstone.c'), capstone]) =20 +softmmu_ss.add(files('disas-mon.c')) specific_ss.add(files('disas.c'), capstone) --=20 2.34.1 From nobody Sat May 11 09:00:17 2024 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=1683650076; cv=none; d=zohomail.com; s=zohoarc; b=cw5npuAkSrVk4YZK9fJJUwdHQhJ1Cs0Nq4LFmYbEpCefJtsByR7kItr4JtkBgM/yJMba1f9fumfGfyyACKH8gTipqyLHciSBQZcE1vbRH8L01HhN67hUJJisJPU8ch8emb5905lAzgIs9oE1N6rabwH4at/Eb2KA0eD3nHhhk5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683650076; h=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=W+SaM45fJjjrZx4VerTDH0Q2oMsolSB5YGX0v3CeRBk=; b=CU7CdKJ8R73k3tZ7MjNAjcdDlf6+3yAq8M6XOK8+F21yuqpPtoUFH3TcWyr6HgV4V+Pqmej+PFFhYS7Dd1TU9B2tsaJwOngUOtp9MJxBYgF6BBaPicJ/Zes9s1mt/fGtl1vdjQriEgi7ngyWScvVCeirPenIE8dgVs06Igf1we0= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1683650076556763.646202943006; Tue, 9 May 2023 09:34:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwQHV-0004jY-Ta; Tue, 09 May 2023 12:33:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwQHQ-0004i2-PP for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:37 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwQHM-0007WS-Jg for qemu-devel@nongnu.org; Tue, 09 May 2023 12:33:36 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3078aa0b152so2371252f8f.3 for ; Tue, 09 May 2023 09:33:32 -0700 (PDT) Received: from stoup.. ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e1-20020adfdbc1000000b0030795249ffasm7393298wrj.92.2023.05.09.09.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 09:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683650011; x=1686242011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W+SaM45fJjjrZx4VerTDH0Q2oMsolSB5YGX0v3CeRBk=; b=amXXTvRuif87bzxC31rxpUdOTiBC3MsinQ2kkCs4txGKXwF93f80p4OipKCy/pi85h ZMVaKmiAVHb612PoBbdNRwJk7g5AVrjqNx/d87sJuIR8HPy3CLjioNI38ytm8fhHCcrG bp6BJtiamYuSDH97ozxAa5h7U5C1Lvy3aHDWFfzmH1WUlSrkUwKWj6qYH2usqVW7/vas kxgqgaFy1byYR2X0+4EZal3KFWLvHGyZzyXZJcqV5pf1qsZ25lqbOyVkISLjIAfuUig/ /I1XLV8oweUlY+sj5O3/H6ZWYDC0Gd4487vWL6N8fiLu/E9XsLPw95KJGDQYSdrKfNgD 3I5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683650011; x=1686242011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W+SaM45fJjjrZx4VerTDH0Q2oMsolSB5YGX0v3CeRBk=; b=VCHVhc6iie0GIXluB9/OUrCezWaoVvjfQzPlvzk8QMwk1AevD1hEWkEtnVpD6AhSFf h6FAeV6PUaWOgWDwsXJCnGOe+snfFF+riBDMFloI66Ec+6PgbM3mSrue9zMGpWumuR4N S8fyDK1VwkPIvYuSwIp1oJGkx0ju6S6DVFmNcIr4sLby7jsIWCSzi2pcgMRExVWsBHg0 ACvFpAb+ZJeOWKnGByNo0gLRQQKQM+/YkiVp4I+902QwPGIiDfYmFFDl/JYfV4WFbPfd nqCY7mcKWwd/3RKK1QqnNeGkK5lvVp11XELpyubU1ZzwfrADyK8Oq1kxgCK5RmyyFnrw u3mg== X-Gm-Message-State: AC+VfDyb9xZ+/TbnbmEPcRp1b+AZBW2HtkxMF1An+BMZ0+Nq9+0peWti IvK4uH6ceBzf9/3Y5+LDUZeqIw3SCWDohLBsxPM/pQ== X-Google-Smtp-Source: ACHHUZ4xZtfMs7YDmORYKGBy7DGgpajRG9EQV1eU3UNrIhwsrAqFAxJvP1pKktp+W3FQ9ry2IP3wKA== X-Received: by 2002:adf:e787:0:b0:2f0:6192:92db with SMTP id n7-20020adfe787000000b002f0619292dbmr9131320wrm.46.1683650011084; Tue, 09 May 2023 09:33:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: anjo@rev.ng, philmd@linaro.org, thuth@redhat.com Subject: [PATCH v2 5/5] disas: Move disas.c into the target-independent source set Date: Tue, 9 May 2023 17:33:26 +0100 Message-Id: <20230509163326.121090-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230509163326.121090-1-richard.henderson@linaro.org> References: <20230509163326.121090-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2a00:1450:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-wr1-x42a.google.com 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1683650077693100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth By using target_words_bigendian() instead of an ifdef, we can build this code once. Signed-off-by: Thomas Huth [rth: Type change done in a separate patch] Signed-off-by: Richard Henderson --- disas/disas.c | 10 +++++----- disas/meson.build | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/disas/disas.c b/disas/disas.c index 5e7401bb6f..954b385a82 100644 --- a/disas/disas.c +++ b/disas/disas.c @@ -122,11 +122,11 @@ void disas_initialize_debug_target(CPUDebug *s, CPUSt= ate *cpu) s->cpu =3D cpu; s->info.read_memory_func =3D target_read_memory; s->info.print_address_func =3D print_address; -#if TARGET_BIG_ENDIAN - s->info.endian =3D BFD_ENDIAN_BIG; -#else - s->info.endian =3D BFD_ENDIAN_LITTLE; -#endif + if (target_words_bigendian()) { + s->info.endian =3D BFD_ENDIAN_BIG; + } else { + s->info.endian =3D BFD_ENDIAN_LITTLE; + } =20 CPUClass *cc =3D CPU_GET_CLASS(cpu); if (cc->disas_set_info) { diff --git a/disas/meson.build b/disas/meson.build index f40230c58f..2ae44691fa 100644 --- a/disas/meson.build +++ b/disas/meson.build @@ -13,4 +13,5 @@ common_ss.add(when: 'CONFIG_XTENSA_DIS', if_true: files('= xtensa.c')) common_ss.add(when: capstone, if_true: [files('capstone.c'), capstone]) =20 softmmu_ss.add(files('disas-mon.c')) -specific_ss.add(files('disas.c'), capstone) +common_ss.add(files('disas.c'), capstone) +specific_ss.add(capstone) --=20 2.34.1