From patchwork Tue May 9 16:33:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 680215 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2385508wrs; Tue, 9 May 2023 09:34:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qKo5RfCN5mqX4j30URlDAidVO5NLZZXd35y3y7tuB3ojEO1WIJQkWGosPw8Bzxzyh/oed X-Received: by 2002:a05:6214:40f:b0:5f1:6892:743c with SMTP id z15-20020a056214040f00b005f16892743cmr22006621qvx.24.1683650069804; Tue, 09 May 2023 09:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683650069; cv=none; d=google.com; s=arc-20160816; b=dOQnAkLUjcjjolCsBG1HSqYGgXRiOscpL7oBudIswjSAk6a79jQkWJJIy3CyaocN39 XCtuY6TpSFKM6NdTwFks64Wl7kSbCWw43gs1jFKzDQFv0eKyTJCd6YTCE8B0kclhcezk fP+pzrUfdSjT2rYtBq0IQFjh2dC4dpOhdYtzDBsmcLka3ZdOOAl/foMgc/iAEp4nCsdZ +xb4/UvW845ttULGzmdL6pHOitEiB3CR1/TcAZEOjoqqMo/JQuw8KOxJoE1fjXyXbqgZ o+ezonnKIpXOyQlOQbehTFJgmJqCkto6K2t6RhH/bPVURinyyA6iXgwvEDqfLIvCZYys OzkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tk/Olu2Bf85J93sQfImDeFqS8c5LlV3FpMEjcgGhhmo=; b=F76xXK0EvjXAtR1cKVsUchormw9HC2LIBWFw8qiQ9YiHXZ+NOxf3oba7gCbMOE85qy kDnjbppOVMkO48yxm2dTQok/1SlKUxYsUSXrv9KDpvJNqflhhzP5MH7gjGqJB/Q/xR/o pbU9l7AYrlQgGqNJwQ/LJVGq5pRmTb+n01tNfRrGRWT+o5DIhaiz8WHzR5vkNry5U3FE oteahWjWxOAsbbvV1rc5SOsUasfGLrO/bRHOuKxSKXFpq1tWQvjBNtESzyWEbVs09z0Q NagCFNkb8kqKm7K1c2mDxwCcxAfK9g5f8Ua9jiuHypGyA5aeS8KYajpcurvGoUJ/JrFF 1CMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eGCKOfei; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f2-20020a056214076200b006212d563342si755235qvz.283.2023.05.09.09.34.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 May 2023 09:34:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eGCKOfei; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Thomas Huth Signed-off-by: Richard Henderson Message-Id: <20230503072331.1747057-80-richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé --- meson.build | 3 --- disas.c => disas/disas.c | 0 disas/meson.build | 4 +++- 3 files changed, 3 insertions(+), 4 deletions(-) rename disas.c => 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')) subdir('softmmu') -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=99696 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('riscv.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) From patchwork Tue May 9 16:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 680213 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2385190wrs; Tue, 9 May 2023 09:33:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75vXXA1/MyhfI1N02RPh6bumtA+Jrrp0Qmehl7CCFJBJ1y+ClkJbRScQyWaKCGrOtbryF0 X-Received: by 2002:a05:622a:11c3:b0:3ef:2fbd:90c3 with SMTP id n3-20020a05622a11c300b003ef2fbd90c3mr22595471qtk.37.1683650032666; Tue, 09 May 2023 09:33:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683650032; cv=none; d=google.com; s=arc-20160816; b=b7PS2SJ4XwDvALOqmQavPnTRCq/n2u3y+rDllRaDG+zgxPHcSFJLrql9PQi+YUQJbp vqsVk8JklJpQeXQb1hXvoN9OZoUrtrKe0LOkRA82oHI60PLU5S/0O2LMQhQZceiATdnv a5gN12LAWeRuCmBtYZra9RGxHtfSaE/fVRYlCE+ae7guyLyiSyPzIOMVPeIe6t+LG0b+ Vhbd7HuuIbT4AIsUd2HGa0Ry3sb9nwnNtu4giV0xsWsJLg3UWutOJDcFa0mzpxB61aF3 460SyG/9sUaeVHz3Ua304L36Rl2MUUFu5DiOGXwzsUS0b+nCHKnMj1/0e4dkqITvYoX8 ozrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rGlQDLvqKUT4+MDaEXLHZhgv8xrgNwzz15sJXDY+k8U=; b=nOKWi/55nIT6dfkeZVKWvaYJ4mpeJbje+np87ZFYOAh3YhYZGwpgmwuPuQxyQhzyet t5+oAYGzJQU9uzRszfjEZnm9rtvgAYVu/ASnygnkWj9xjgIKTwgS+GemOIqboD182/F3 MNuPlIUQ3Zaz1as8VcSUexnQAnNyJcMCilxmfwB/8rTEnArUWHaE/UjAHxW2gWnqsXSF TQV+2HJl5gpBdR3i5SAdT3t0sx7OK2tA9Ll9u3/9W5HNvrmAzlSXjGeFp8AsGhJs5rXI zcSVRjF47hr0X1IU4S+Bu6NfhNGrkP/F+AmHtvnCN71SjozUHWs30amPyd/RR6QqsPeW WdpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n9gQkaJU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j3-20020a37c243000000b0072fd5e31f18si3927863qkm.390.2023.05.09.09.33.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 May 2023 09:33:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n9gQkaJU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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" /* 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); -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); char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size); /* 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 struct syminfo; struct elf32_sym; struct elf64_sym; -#if defined(CONFIG_USER_ONLY) -typedef const char *(*lookup_symbol_t)(struct syminfo *s, target_ulong orig_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_addr); 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, static int symfind(const void *s0, const void *s1) { - target_ulong addr = *(target_ulong *)s0; + __typeof(sym->st_value) addr = *(uint64_t *)s0; struct elf_sym *sym = (struct elf_sym *)s1; int result = 0; + if (addr < sym->st_value) { result = -1; } else if (addr >= sym->st_value + sym->st_size) { @@ -363,7 +364,7 @@ static int symfind(const void *s0, const void *s1) return result; } -static const char *lookup_symbolxx(struct syminfo *s, target_ulong orig_addr) +static const char *lookup_symbolxx(struct syminfo *s, uint64_t orig_addr) { #if ELF_CLASS == ELFCLASS32 struct elf_sym *syms = 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) } /* 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; @@ -226,7 +225,7 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code, } for (pc = code; size > 0; pc += count, size -= count) { - fprintf(out, "0x" TARGET_FMT_lx ": ", pc); + fprintf(out, "0x%08" PRIx64 ": ", pc); count = 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) } /* 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 size) } /* 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 = ""; struct syminfo *s; @@ -356,8 +355,8 @@ physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, } /* 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, } 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; } for (i = 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 = 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, struct image_info *info, static int symfind(const void *s0, const void *s1) { - target_ulong addr = *(target_ulong *)s0; struct elf_sym *sym = (struct elf_sym *)s1; + __typeof(sym->st_value) addr = *(uint64_t *)s0; int result = 0; + if (addr < sym->st_value) { result = -1; } else if (addr >= sym->st_value + sym->st_size) { @@ -3338,7 +3339,7 @@ static int symfind(const void *s0, const void *s1) return result; } -static const char *lookup_symbolxx(struct syminfo *s, target_ulong orig_addr) +static const char *lookup_symbolxx(struct syminfo *s, uint64_t orig_addr) { #if ELF_CLASS == ELFCLASS32 struct elf_sym *syms = s->disas_symtab.elf32; From patchwork Tue May 9 16:33:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 680218 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2385751wrs; Tue, 9 May 2023 09:35:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72/S2t/wzLx4Iset8vpANWvTW7iLCf6ZNJhb/vqI2MKOkAN0hiqRAgOjy+5Vol7xzZ2zNt X-Received: by 2002:a05:622a:198b:b0:3ef:2db1:6e44 with SMTP id u11-20020a05622a198b00b003ef2db16e44mr21848986qtc.23.1683650101222; Tue, 09 May 2023 09:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683650101; cv=none; d=google.com; s=arc-20160816; b=tjYc/fEbd28OUO5lugvQZ5a1vSGEjQFAQbuQRzD8CyFzRg4AsFRUFeo8RbEB1S1RfU 3MSKHpnhsV8MBGuXmvxC9nMbnIMFRIrhYY8qc6+NYlY0inlXs+wd4ojFE1sJNBZd3P9B CV/QxNstdoCjro/pnDCr6GQATbP6T/pdmxBWGhALIxigGZrO3Ve0UMI2vBNDOI7Rlzzz O8BFI3wJyc4/VklZE4UlEXRHdWkaEkKEp28Lj4Xn6NfTGsvPfYGEnO3HkTuelxuBM6Bw ggCPTmZcNyxkYPF7zrYOD+6z7IHlUzBcnmLFG3tTdeD+d+07eATLIftcN+oIaHKAOUTV 44QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cpop6LoNqSh03hm8vCAMJ2YCthnibtXTEV61F8HsXUQ=; b=iwJ+u1Pjviu2M+o3pcYAH6CQRlFc/VHYBbHe8re1fTf17WuogJpEEFF5hh5qXxThLC t/IROFhtSa9E8dyV+Qqk0NQkIDFA2JdWCaQqG6QGzwXTrfNnPiIW3LuYHCZ3QZ0lTwk2 zen60xiKLickavaSmDj+l/Ob40mD8CizdZkJCK19TCYYRelEO1VofjNdHuJQJSKGMRUT 81Y/HjBnoksxu+Ts66uh+/8lG5rDP05F4KGjtCJBqfQRXULHVxKvP01FX3bvb2YGfDCT H3xCS7+swYrkLtk12rAI5iVCieIUDhkmF9HK4Zu/1cMz+LCA6dby4eCPEgm7aUEwYA7k 0w6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gnbku9bU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l19-20020a05622a051300b003d4618572cfsi662583qtx.290.2023.05.09.09.35.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 May 2023 09:35:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gnbku9bU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 -#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 size); /* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol(uint64_t orig_addr); -#endif 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" typedef struct CPUDebug { struct disassemble_info info; From patchwork Tue May 9 16:33:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 680214 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2385403wrs; Tue, 9 May 2023 09:34:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62vIp5Bvpll53YzBL9kmOyXpiNxepqCtcF3dM9B9S5kmh64ceLVp0jgAoCjSgGe26BMrzJ X-Received: by 2002:a05:622a:349:b0:3f3:9489:1c33 with SMTP id r9-20020a05622a034900b003f394891c33mr7984444qtw.36.1683650057546; Tue, 09 May 2023 09:34:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683650057; cv=none; d=google.com; s=arc-20160816; b=hxFEH/usX19yDxO/7YmuzmBKoY3eRzwk/xEemKcXIIqhGHb7xvHTtmdMb9z/bEWnp5 dftI4UOSsYDlKjc8dq4Q7NJDWPE5F4apnfmrFJMTXrjliVcIFRGy/CkvwBiLtCS6tep8 LSe6/PP284kL6OnGq+F3aeJZEk+FhMN9m0DZBOMXjXLnbAbzmi08kwy/Ibb60VqJYpF9 aAzLvOc5IKBubXTjR8kyfdDE+ql8+AjaONFvRn+thjoVjPWjklgSGkBw6sk7flD1UGx5 Ypoja+Zu34BMpvGNvgiFD/EzDs65q+ch5QjxJfBY+t/knRnUup0M7D5iQGWdiegHyyfy mW0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JHlvoUuo7umR5TkZZj4NdZf0miPVK+cLHtVt5b6lJNg=; b=WjBHiZW/vFkcQCVhZb4erHu1YeAB8wDtyo3pQEQBypoPs7ftytKSIehE4ZTtVzAhp/ 7pbn7wypRL6P6E+AQ6He/kEx3O9gVsMDbtRkosXRKNdvAVqHq3WpV3cdN4urUfNk9Dz4 M4GY62pt0AYFN/4ZzFYUwn5CItGV6uqT3oxcfCw/rrQXnTzLfc96q0+wHL/H+cy2Xl4r OeC3UaI3Ye77yAynwepzrbAywmJafpOfpPhs2L4iA6fjue9PpokuC9VphfkG8GXmnekZ ZL4PQJ4cdzpiDtWP7rC5adcgE0uOueedkQTxpB18aNFZ3OjdmPvmHZwUNS/NFN3Oj+4d RjtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UKY9bPyd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g9-20020ac87f49000000b003bfc37f6c5asi706701qtk.189.2023.05.09.09.34.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 May 2023 09:34:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UKY9bPyd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = container_of(info, CPUDebug, info); + MemTxResult res; + + res = address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED, + myaddr, length); + return res == 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 = g_string_new(""); + + disas_initialize_debug_target(&s, cpu); + s.info.fprintf_func = disas_gstring_printf; + s.info.stream = (FILE *)ds; /* abuse this slot */ + + if (is_physical) { + s.info.read_memory_func = physical_read_memory; + } + s.info.buffer_vma = pc; + + if (s.info.cap_arch >= 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 = 0; i < nb_insn; i++) { + g_string_append_printf(ds, "0x%08" PRIx64 ": ", pc); + count = s.info.print_insn(pc, &s.info); + g_string_append_c(ds, '\n'); + if (count < 0) { + break; + } + pc += 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" -typedef struct CPUDebug { - struct disassemble_info info; - CPUState *cpu; -} CPUDebug; - /* Filled in by elfload.c. Simplistic, but will do for now. */ struct syminfo *syminfos = NULL; @@ -120,7 +115,7 @@ static void initialize_debug(CPUDebug *s) s->info.symbol_at_address_func = symbol_at_address; } -static void initialize_debug_target(CPUDebug *s, CPUState *cpu) +void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu) { initialize_debug(s); @@ -211,7 +206,7 @@ void target_disas(FILE *out, CPUState *cpu, uint64_t code, size_t size) int count; CPUDebug s; - initialize_debug_target(&s, cpu); + disas_initialize_debug_target(&s, cpu); s.info.fprintf_func = fprintf; s.info.stream = out; s.info.buffer_vma = code; @@ -241,8 +236,7 @@ void target_disas(FILE *out, CPUState *cpu, uint64_t code, size_t size) } } -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 = (GString *)stream; @@ -272,8 +266,8 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size) CPUDebug s; GString *ds = g_string_new(NULL); - initialize_debug_target(&s, cpu); - s.info.fprintf_func = gstring_printf; + disas_initialize_debug_target(&s, cpu); + s.info.fprintf_func = disas_gstring_printf; s.info.stream = (FILE *)ds; /* abuse this slot */ s.info.buffer_vma = addr; s.info.buffer_length = size; @@ -338,61 +332,3 @@ const char *lookup_symbol(uint64_t orig_addr) 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 = container_of(info, CPUDebug, info); - MemTxResult res; - - res = address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED, - myaddr, length); - return res == 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 = g_string_new(""); - - initialize_debug_target(&s, cpu); - s.info.fprintf_func = gstring_printf; - s.info.stream = (FILE *)ds; /* abuse this slot */ - - if (is_physical) { - s.info.read_memory_func = physical_read_memory; - } - s.info.buffer_vma = pc; - - if (s.info.cap_arch >= 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 = 0; i < nb_insn; i++) { - g_string_append_printf(ds, "0x%08" PRIx64 ": ", pc); - count = s.info.print_insn(pc, &s.info); - g_string_append_c(ds, '\n'); - if (count < 0) { - break; - } - pc += 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('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]) +softmmu_ss.add(files('disas-mon.c')) specific_ss.add(files('disas.c'), capstone) From patchwork Tue May 9 16:33:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 680216 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp2385565wrs; Tue, 9 May 2023 09:34:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rjOHkCzm3Ygg3N9ATk0+AMlh4iCqlrVytGG4WktVDZ/oPMaAupQoH/WoORjxreCtz+klW X-Received: by 2002:a05:6214:c21:b0:616:4b40:5ea9 with SMTP id a1-20020a0562140c2100b006164b405ea9mr19317054qvd.40.1683650076115; Tue, 09 May 2023 09:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683650076; cv=none; d=google.com; s=arc-20160816; b=mJVaOg+BTUcGlsCtKPm1jPDiFU9AQbhQkBcabeVtredn2Yn3LN0ADi9AZd+0BdxeBH jcSnn/qgd4nu3wPU6O53A2cETW9rBx/t/su7NslVQcNxRxf0KFkcHzsnxHeYqhJiRfLI RBcl3QhkAeVoBg8g+21q3p7pXf87+wKHYoSfYiHzMpu9SMzHWR5InKCVGAe2dwXYFuC/ aCJba5z3FMs97CuSFUXPm/xFQdWk2d/2NEjUrtJiOUxZFuVlKwckX8shMbCkX2il2UjV C6zHyXPfk/zNcSHtpgX5BE4xuIy7JpCdp7pGb6z1WqoTdx8N/jiEh/vu0Oo3PUArNJ+o G2Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W+SaM45fJjjrZx4VerTDH0Q2oMsolSB5YGX0v3CeRBk=; b=WUZAuq9HfN4XkTSYz02UG1S8bLGKXTZySn0ksmS2DLJVmSNQvzuHdMTaoefOsbAq5n GNlj4v8V1ZpkH/vsC65diD6AhLuEh6VRTYYW/cp/AAjxmf2Ra3a5xwirsacA94sIvfy6 TTnPN+7LkRgCX6tltkhqiA6FXBUYKljOwNAqzQ5DluP5crWxllNX1Ehb880eaC6rH+qC aZ+ElPGMtugEHvnnBFGVeoN65U7PSdXlqsg84/MxKD8FJTI9xWfT34iFD5pxE5hcLjVK 9ATnto+9noqCK0Mp5c6NRfUZR2uFsAnb4MAdIshV0rU2Ib0zYp+dfu7s5QKZSlt35Cw5 MtYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=amXXTvRu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m13-20020ae9e00d000000b0074e0afc9e87si4131923qkk.262.2023.05.09.09.34.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 May 2023 09:34:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=amXXTvRu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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, CPUState *cpu) s->cpu = cpu; s->info.read_memory_func = target_read_memory; s->info.print_address_func = print_address; -#if TARGET_BIG_ENDIAN - s->info.endian = BFD_ENDIAN_BIG; -#else - s->info.endian = BFD_ENDIAN_LITTLE; -#endif + if (target_words_bigendian()) { + s->info.endian = BFD_ENDIAN_BIG; + } else { + s->info.endian = BFD_ENDIAN_LITTLE; + } CPUClass *cc = 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]) 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)