From nobody Sun May 12 02:59:48 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=1683734038; cv=none; d=zohomail.com; s=zohoarc; b=KWFRVTFjHbacQvm43S7PhlC6lQSVqtfhAr79nbUyIKP5GacNuxZEUmQogpstHQLw0CuuajIUF5pem5+8qxxzSqOAkJ0Fl17ZxlZkcdEWmRmgo2CBx851GykJmclcvxdFr8Rbm71ZzlFW4YwFa4agq8YZMyOTT3m76S9le9VaLVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683734038; 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=GuI9OnpIiD+w0k07S0dmYYpQrmGPfKuDmKUIYtzB2PA=; b=QgFt+O8L9RkRAArTDs8Kql0rycU0E9OJetBy4bMrzb6Q4GDoDSreChSa7VaSsNrUoQ3bVQ2f4L0yRxd6hO7ujchpXXzo9KQiUdwZ3WAp2xyDUndbZBV0Ob1wWQK4R2pgGfXGTjZOh0fy/qp81ezxfH6cRvdovrLOc3CKSrS3MCM= 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 1683734038861214.79330113889262; Wed, 10 May 2023 08:53:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwm7H-00030m-TB; Wed, 10 May 2023 11:52: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 1pwm7F-0002zS-UK for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:33 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwm7B-0004T2-Nm for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:31 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f42ba32e24so15465605e9.3 for ; Wed, 10 May 2023 08:52:29 -0700 (PDT) Received: from stoup.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n23-20020a7bc5d7000000b003ee74c25f12sm23157946wmk.35.2023.05.10.08.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 08:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683733948; x=1686325948; 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=GuI9OnpIiD+w0k07S0dmYYpQrmGPfKuDmKUIYtzB2PA=; b=RPP39WSgX4rdWd1fca6h28WNNGUtyFNtMh9KJwGWiS3ejp9McbhhX4J4j7p1KU8NfM yWBRp0kRf9lHiCPPNqDFa4yKtnu6KJL8act1mO9mew20M1Zga3ObVGG3fOxj68l/2V/0 6uBefTUt8+QJ/k9KMwAR1RB2G5COfghk+uwF4DeESHj6G9TZK/tDIbwZ3+3RZ1710Rcn OBknzqJOO1BGzJLZQxcWJ7IUAwXTXgFyY3Tvej7udZdyrwNajahoiux0Pp5Qxk9Cujjy TgrSBiIma+Li+FHp1ejdw5ePKTqOgPhcgeb2Qdaqv8p841xr3orfuiB5UM0PNZEkGdRX EVfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683733948; x=1686325948; 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=GuI9OnpIiD+w0k07S0dmYYpQrmGPfKuDmKUIYtzB2PA=; b=Chx42VW8s8zmEAoHkP2vF/VbuF2rOjNl/y8G3D/1dMNx4TFHn8VuXHseUnxNTKqBGM US/WZmp8rwyDT0GH1QcwT8/2/2MoyNy1tpoCgfd/slnJGZiOPgawgQCMMSevjF3/72G2 xYKI3swvbL7PpcKxFhVvjLoOplq4MiFnxPAeO4miyyd4/uHVUn9WmLYNWV6HfPxV0UTi QBSC11PjMhCGUy9jISVSRWe8PSTtDFGtLmYbumaW0C+xBDvyNOTZ3BTKQ4/jq0h1ASbU FKvMBo6cg6s78rzYCd3AST9NDy8dHeAHU0/krnNO+aVMx7IVnhA1vDekC1+F8dn0sooT 4c0Q== X-Gm-Message-State: AC+VfDx5bTqGBEGm3qioYeae9msbqsgzwgCib581EaINyxi6O5OKHKjV DvZKt6nyHS/FGkWM47wCFBl+YtiyYuNe9JJDs40B1g== X-Google-Smtp-Source: ACHHUZ6rRD/LvE2/RrWilz8bTPRhBKvePwVPVwpkqkxzx5Dc1r3HD5ytGi9jki6yAPYIf5/oSE7hPQ== X-Received: by 2002:a05:600c:2059:b0:3f4:2492:a91f with SMTP id p25-20020a05600c205900b003f42492a91fmr8116849wmg.27.1683733947820; Wed, 10 May 2023 08:52:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, Thomas Huth Subject: [PATCH v3 1/5] disas: Move disas.c to disas/ Date: Wed, 10 May 2023 16:52:22 +0100 Message-Id: <20230510155226.647756-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510155226.647756-1-richard.henderson@linaro.org> References: <20230510155226.647756-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::330; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x330.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: 1683734039806100003 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> --- 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 0149bd634f..7c7799c9ee 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 Sun May 12 02:59:48 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=1683734050; cv=none; d=zohomail.com; s=zohoarc; b=grWnFQWM9aXUTsdNQts+nsAUovgIwTbg6RaKvJh+HJjk1QLpsFP5AAOYFdWl3GMr1/huCLr4LSD61itnQXpHCulkT+V6IWvMajsUWoOG2Cg2BG3ftXPqKVkFweaURNEu7auy6aevdsWRaMlU/WhPjVA1DF2m3onDHFQj0zJwkGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683734050; 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=zWigtf17KjwZZZIDJgIm8WolKEqh/Em8HBWg1HHvtUY=; b=UPpaPjHvc2XiGcJHOgMD31MHsPwsABj/e+EZFtcU7rCDkQ8yn5kvFiSIoGCWPP0o1UOrQFOH5p/aWB8tsZvi4AFKyzLG3YrrcQ5DNbi9KaDyUPVmrnJYWWfmyojjmTsIw9qIT4swlrAAUim4/A+cLdmOBJ5yOZaHx+hV28lsOkw= 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 1683734050534906.8995594592966; Wed, 10 May 2023 08:54:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwm7I-000310-3T; Wed, 10 May 2023 11:52:36 -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 1pwm7F-0002zT-Ub for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:33 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwm7B-0004UR-TC for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:31 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f41d087b24so33500865e9.1 for ; Wed, 10 May 2023 08:52:29 -0700 (PDT) Received: from stoup.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n23-20020a7bc5d7000000b003ee74c25f12sm23157946wmk.35.2023.05.10.08.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 08:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683733948; x=1686325948; 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=zWigtf17KjwZZZIDJgIm8WolKEqh/Em8HBWg1HHvtUY=; b=Ke/51h/x0piipQ0SAV1UjL8R4SoMXAg5WLXaBs37i04OM2RUBxN+2HAu7GMjO3h5YP EokTTAun+4CCg/UnhOuF3P2UK4IRMKr6tlgQ5uYm+tWbq9pUNJP3gb1BHVDBcSaGgP6X q71abwvGUN7rxNBH9PwNrXko0UiVH8rxf5/QujIfziwx6SAr0JObBFmeu5DqHEWBZAf/ tC0UC8iDqz+eA0xkwcFpe956JfExwuyzd/PPMG9FR3AUE5zoSi4kFAd6YBjXA0/xLwTC d20A/JCBZXqwIr6V2OKt8j8h/HWX9TDL9gE15rTcoDZdK8NZAl6+wA3cLRmqpCLyVVut +wBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683733948; x=1686325948; 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=zWigtf17KjwZZZIDJgIm8WolKEqh/Em8HBWg1HHvtUY=; b=W5/hIj3FhOwZA5yIyaaQrVCTekvBnQiA/H/MR4sHgzGGadr7CBxyut1hi7WDZAG+4f DUItTSGL/W9pmEpb+buvjIVuMyRqcy3mFTE3EhnFiFzuQ9oulpx1IsitJeOEpFTfdys7 u+h8xAKOdquYMwX2Wign7cDaX8QDhAo9gSmgKaoJzoeI1OQ2OKKc9vHHnhqBcenaV4mx dC8Gl+K0pBAjkqzLhJufKVjq5bPB/chhkLHhbWWBZy6/ivS7hZSsVFyQC1TvlQYACw2C DmrvzeBKlDyVvIBsfApCBIw7xqktJ6xA/dP8YYO0Fds+ekfw934r1BKnOkn2TAK+0Dlw g0BA== X-Gm-Message-State: AC+VfDxuZUsW8v9IeUXEtgd/uVPAUUXqnXd9lJafBYW47TmnmHgH8iTe 9zK3mPWTnhQrfVg+a88gR9TJDZTYpzn9gt9QXx9JNQ== X-Google-Smtp-Source: ACHHUZ6S24q7VkiJJ4IbV64yZmGEpnVotGsKQjtlaJSCeg7faLvTcXBgZqLjt3rqxpT4bdXIR17Z6g== X-Received: by 2002:a05:6000:1c4:b0:2f5:ace2:8737 with SMTP id t4-20020a05600001c400b002f5ace28737mr11431643wrx.32.1683733948514; Wed, 10 May 2023 08:52:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, Thomas Huth Subject: [PATCH v3 2/5] disas: Remove target_ulong from the interface Date: Wed, 10 May 2023 16:52:23 +0100 Message-Id: <20230510155226.647756-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510155226.647756-1-richard.henderson@linaro.org> References: <20230510155226.647756-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::332; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x332.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: 1683734051954100001 Content-Type: text/plain; charset="utf-8" Use uint64_t for the pc, and size_t for the size. Reviewed-by: Thomas Huth Signed-off-by: Richard Henderson Message-Id: <20230503072331.1747057-81-richard.henderson@linaro.org> --- 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 Sun May 12 02:59:48 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=1683734013; cv=none; d=zohomail.com; s=zohoarc; b=djMlhQul+t18N+BAFlqCUhk1IuwafhDmwkHwdTG8IKNucCTiNaRVpGLhJ6aVffSDFmKt/JvH/uF8jQjA+Ynwp71Lun1438fnHh6wMj9hGIIECRdTLmmgEBmbvWX/twUmyJKZuW7Fir2lMxxj6I3fvbLMmSH1SM4f00c4Tm0vi9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683734013; 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=k0TM1g44354ic1y4O4+NwF8y7JckP2X3gli00OPq4QxuU0pCjnxhw0wFNm+WdjemZRxvUl4/6HNY/q1qAdCpHmK+kUOVY0J+mNnEqhrW9rECKIih3hN26x7yfVpEM6Y3gTo9TrTgRaGWQpCFltI9lQFL4l8LwYpTLEVUvUFC56E= 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 1683734013807187.18346340218784; Wed, 10 May 2023 08:53:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwm7H-00030R-LN; Wed, 10 May 2023 11:52: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 1pwm7F-0002zU-Ud for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:33 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwm7C-0004UV-C9 for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:31 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f423ac6e2dso28743145e9.2 for ; Wed, 10 May 2023 08:52:30 -0700 (PDT) Received: from stoup.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n23-20020a7bc5d7000000b003ee74c25f12sm23157946wmk.35.2023.05.10.08.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 08:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683733949; x=1686325949; 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=h3bisDW9bIxtAUAucN+PvcNVVKcrQjZ4LyVdRRsuYdJ75a4o0g4aQFOrJj/bOKOOBV UamU+ZMS5L15+9TeYmL0PpD2vSPFMU5DCQW0lhxwKRMCW50n13Th9Ytd5iquyCN6CeOQ wnrTDHxQ+qrLSAlXedMOu7xkDJtpaO74IsfNgoV1PwUA+Mn6NeC5tr2csLKAfaX4g9Yv UAbQcfGNSpvLS7lbHuIAmkTJY3XstUq79iHo5WzhcsrwRup0CZvNmuNDnzGTTEy6Lnd0 tAYE/A8vvbOzA2/cG1vvjj5BPsyU39wUdEdw2OL7M+KQ5a4bXt1zh4NMxkbTKX7Jw3Hx BcBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683733949; x=1686325949; 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=QmJF3C3PH/1ir1xv9tE5cGraILS6cvIQWkyOLVzXR9KnQQ8g3kMcqnRMk9abbyTuBd th5k198EExwmXGAFQIPx0tdPfu+rFpSrp3fhNpaj/YD25PiXjixcVqKohQakX3f1m5yY sfcenut8Pj9jt+gxWCbRiRFMlPowgGbZc58eguVLz2h3NVicQ9xkfKOIsHbIgwpOh2vP 0TOhhEuGAdvemqreuPJuf806z79+uh3bKyAF37vAc/CzW8GTmlvt/HeK2CV1uO8u2r2p vmrrJEqTAf7yGgSavyQkz+/fq0jfEpJ028IuxlgyPzJmeOlP5IsJAMrdN68d8591K7kh WHNg== X-Gm-Message-State: AC+VfDzICKOdCkT1qKPzzUvFcQ9qCsXaAmSaqtJ+cJAqb0un9HejXQ6G BXLRQrXVwmVNou3Sit9+cIzLV5Fu+hltgLiMUKzLlQ== X-Google-Smtp-Source: ACHHUZ5Lhf9HTaGEu22FIo2Je0p2tAXJxGMhZiVjVMHdjOuLnO8Ovl0255KlP6YXTtZM07uX3SC09w== X-Received: by 2002:a1c:f402:0:b0:3f3:3a81:32b with SMTP id z2-20020a1cf402000000b003f33a81032bmr12547239wma.15.1683733949040; Wed, 10 May 2023 08:52:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, Thomas Huth Subject: [PATCH v3 3/5] disas: Remove target-specific headers Date: Wed, 10 May 2023 16:52:24 +0100 Message-Id: <20230510155226.647756-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510155226.647756-1-richard.henderson@linaro.org> References: <20230510155226.647756-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::330; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x330.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: 1683734015645100008 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 Sun May 12 02:59:48 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=1683734012; cv=none; d=zohomail.com; s=zohoarc; b=NjT40qnfwbzQn0u3TSmJYn8C6q2jEcs/7PLYli/diiZXKfZ75czs3HBZ1im3uXMm2y3mvzM54ymVnmx7MdzF3PLBSo6CRSufQJFCdcSZLYocXrKwfLfUeciOZbqE/lt3vAXc+zavHRNQG35lzNm3guaw2ZbcF2UXH6K4ighv60M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683734012; 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=afgvvt2mEnbYffaRVT+ikKLu+J5+NN7Q7LWy/8ocp6g=; b=TL9u7ECbR7hwq80JiZuGBnSgdcbAWo8wjMqeJYfqv7yD7GBnDERuOT7JsQeF5CQ1HXxQCd0KFGeKo1zr4Zp34lQ3YE6iYJc2+czRXk5+J7ahrun09/slhs86aFJvbgiLhFDwoEBP4Dzjg7EB2POsdZMJh92kK8b0SOmGf5/2s1o= 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 1683734012662825.496372007177; Wed, 10 May 2023 08:53:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwm7J-00031r-5C; Wed, 10 May 2023 11:52:37 -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 1pwm7H-00030S-Kq for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:35 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwm7F-0004Ua-NA for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:35 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f420618d5bso30918025e9.1 for ; Wed, 10 May 2023 08:52:30 -0700 (PDT) Received: from stoup.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n23-20020a7bc5d7000000b003ee74c25f12sm23157946wmk.35.2023.05.10.08.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 08:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683733949; x=1686325949; 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=afgvvt2mEnbYffaRVT+ikKLu+J5+NN7Q7LWy/8ocp6g=; b=TetpG3zoFcKBxPNamTMDnC/Yua72RrxSdWn354Q2mwkoB0usAgN179vl/pWpW40lMH TubxYwB7JV5t+pt7l1eQpZQWJFliy2FI6Lxp9Vsknv2OUlr5qSr4H7R9kybxgottti6e X2CViOe2u0UQpSDaCjbxlTJI4KLuFrLUiBWdpA1jwsFGYObwoPBOUawF8+J9tIxG8D9Z j5m8YC1Bws/JpBC7EPiqPfVHCu7BXY0hkwy8IfR4Xx69RGkJEJR+C2DD2+8qnnEjkkc3 X/6cv1W/RhZD6EH3gCnpb0gtiJ3CUSgSR/Lh4F0uqGBahTXabrvi+w8DHhhRNrxPrYSh mvHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683733949; x=1686325949; 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=afgvvt2mEnbYffaRVT+ikKLu+J5+NN7Q7LWy/8ocp6g=; b=aY715mrw+8rxYnkJXVioj8NWvC5MzPhpz8Frp+JGROnSuahb2Y46ZIqGHmhLtsATud 3cT1MwqVynaF1xgWvsHH9tYU66HM6OLRSEm7paGJWl/EUJkFgdCjm0rsO5oxKlvIpyF1 I/unZbgXnJR1R5AuNS/F8QwjXPxbPo+W5YthvQlrMpBBqPm0O8RkqqV4IrmZM93+uiID GBMVj86fX8PFEALpKgrMnQXdb1Z4NrtCXEIkUrucxbrHZ0kAQhV53cDN7FH8lN8x/+Lp 20sCQQLG4NhxnZrWDVRXRW96SHspWPoScBOpYqbodmgUEe9Ppj1OL3UvCFZm/x2EM6I8 xqpQ== X-Gm-Message-State: AC+VfDyVkAWMPVu0IRpcDOPliTP+FOA6rRGKAoFpBJLauRevWVeIABNX apQs2DsIebH6opx4D/u9eAGz2V2jz781r5T+ps2Rjg== X-Google-Smtp-Source: ACHHUZ5+67xmSspNZ1jOWfbONSgbfVCdR5NClzGL0u6E7OLQi3keW77ltWbX2VGWWAMy8+4eoOFG7Q== X-Received: by 2002:a1c:f418:0:b0:3f1:6f52:74d with SMTP id z24-20020a1cf418000000b003f16f52074dmr11996589wma.39.1683733949622; Wed, 10 May 2023 08:52:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, Thomas Huth Subject: [PATCH v3 4/5] disas: Move softmmu specific code to separate file Date: Wed, 10 May 2023 16:52:25 +0100 Message-Id: <20230510155226.647756-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510155226.647756-1-richard.henderson@linaro.org> References: <20230510155226.647756-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::335; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x335.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: 1683734013714100001 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 Message-Id: <20230508133745.109463-2-thuth@redhat.com> [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 Sun May 12 02:59:48 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=1683734033; cv=none; d=zohomail.com; s=zohoarc; b=E0Kv8T+169q1zmvq53PPH+GnTnmWqR5o1p8/8Gh4pIRomTq8ol9I1YvYm1yyAryOW38QIINDlNPURs+p5S3ugePRnRCNHCjqTm6VPawOoZzdY/+IlDIJMG+xNc2FsYGe/aQeIbp0w7L9zADBo6JicBjGB5DayctdSpNRkQHItXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683734033; 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=s3KN+seF7jjUQ0aZUOoQd455lccivu+NPR8pleIjoaE=; b=JTL4d7Pz69uW5uE/89DTRxPIsK1EZgaFi5gtuV8K0viO4CkWAwvohx9yoUkvHGKOFhSNgydLUiQtzCX8SKb0zghu3U59/tAfK8DSjxbhp/14j7kSILqUUsS0dMF3TwxfGKLWGFLtkt4LwLV5nhZ9DeaaT4ipPuAOE6919yYmwGQ= 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 1683734033375329.04222668646185; Wed, 10 May 2023 08:53:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwm7I-00031g-IN; Wed, 10 May 2023 11:52:36 -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 1pwm7H-000303-AT for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:35 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pwm7F-0004Um-Ne for qemu-devel@nongnu.org; Wed, 10 May 2023 11:52:35 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f42711865eso24839265e9.0 for ; Wed, 10 May 2023 08:52:31 -0700 (PDT) Received: from stoup.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id n23-20020a7bc5d7000000b003ee74c25f12sm23157946wmk.35.2023.05.10.08.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 08:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683733950; x=1686325950; 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=s3KN+seF7jjUQ0aZUOoQd455lccivu+NPR8pleIjoaE=; b=RH3M9dg3HECxPDlQVK0HjX64IZREphg4UkGZZxBb+40mav5c+YNDlUDn/RNehXNp1b rwaRI3Uch+B4QRol22wzqpVe6Pv1KTmlaXSHCOLN8BEPGP6Rz75oWbEDzIvN8zAdpUB8 eJM1hQY26E31KZUjvtR73rCJlRaHPF8dW0olnxwB8r/8OuNUZjQSWYI4bT4dAZ8hUt9J 2ncBaN0O6vkA3sERG9tex9VEVqAL2+A6i63pFHGWmQwH3LfO3fRLzbf2hbIYVY3oexZb yop+T8mSzQ3bBkQ0QEWsgXEpKgh/foIZLPbM+AoWaCkU4Pxr1uNnrDzDqMNtEoHI+Duv D3tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683733950; x=1686325950; 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=s3KN+seF7jjUQ0aZUOoQd455lccivu+NPR8pleIjoaE=; b=lKaxOb1bUbl/A9J1LEjuKLBHXhhdhFbavhYUae44oSO+oSzAv8ZCjmJ7KpzkTjL2RY GeD2+d8NIcQf354XB7LwRDLAb8qzjfb+nOpvetpMVUn+bykIHG1yA6LjTwoa2sAHFz1q bsxwdIkiG3Zk42ZGyC/yySIesaIfYVEEtoMO/VWTsUApEvbC56O3cvlA915YFTF5/o+D T5aMS+Z4pIVNO5vih12A1eY9yuObs6b5pYfKx6aWpVVmNq9Kq2MDYiv+twJNiLnZQ/2C iXQnvnuSVy3tpyCwArss1OQ6/z1pL2c1agafxwj8o33XFwp3Qq+xAqpMHYwrzt3ssXb7 gTOA== X-Gm-Message-State: AC+VfDzh4yjcI7lDBluWGzBFA2AiovWcZdi8Tnf2epSpG/IEyKBi4shJ vFXk2VDHojpm/b1vDC1PJrj055w0uXqRTJf+qkbzhQ== X-Google-Smtp-Source: ACHHUZ4mjnKa9ZwnO8BItaKP7AjGsXgr4i71ChksDmQ/ox1sw3MPBK/WZM3isePv5sBVNgpdPAQyXA== X-Received: by 2002:a05:600c:b4b:b0:3f4:2897:4eb7 with SMTP id k11-20020a05600c0b4b00b003f428974eb7mr6060581wmr.38.1683733950113; Wed, 10 May 2023 08:52:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, Thomas Huth Subject: [PATCH v3 5/5] disas: Move disas.c into the target-independent source set Date: Wed, 10 May 2023 16:52:26 +0100 Message-Id: <20230510155226.647756-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230510155226.647756-1-richard.henderson@linaro.org> References: <20230510155226.647756-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::331; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x331.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: 1683734033780100005 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 Message-Id: <20230508133745.109463-3-thuth@redhat.com> [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..832727e4b3 100644 --- a/disas/meson.build +++ b/disas/meson.build @@ -11,6 +11,7 @@ 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'), capstone]) +common_ss.add(files('disas.c')) =20 softmmu_ss.add(files('disas-mon.c')) -specific_ss.add(files('disas.c'), capstone) +specific_ss.add(capstone) --=20 2.34.1