From patchwork Fri Mar 3 02:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658445 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225166wrb; Thu, 2 Mar 2023 18:58:41 -0800 (PST) X-Google-Smtp-Source: AK7set/sYuXBVhOX7r1l26nv6iCTvxItRpQr+0P08g3eZHug6TMAIDVc6tdFAP5t1xGxyQLC01CP X-Received: by 2002:a05:622a:38a:b0:3bf:d7f8:4f85 with SMTP id j10-20020a05622a038a00b003bfd7f84f85mr823882qtx.12.1677812321694; Thu, 02 Mar 2023 18:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812321; cv=none; d=google.com; s=arc-20160816; b=q76joN2gvngUAfS3tijJgFNwPGWEEF2yZdRDnSqWZ67m/wgHZMG/y2mw3E9fHNjvUk +B1ABiA0M90ovaDHoQZfU8E5g2SCNtFciiJdPn0wLB8zyJtN+42U/eK5nKSEFlDFfLQy 4E+7w0rjvxAMhXjwLCUrJaCdSNUcGTNMK+LFaHsBXbpA3OwV1GEEnlLvOi55RhGH2dtc qScqwN2hiDk6XpB8s5MxhMRoAsIJyzsOiJN747370gHO+i8mwSgMbeISQvjNCzaXa1zu 4RIVX17LYTxctQ37K8Td+xoDHpsy7kFrtegu1gI/QeUgPGd01G9ScZzDDdaWVa8IHKQK UL0g== 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=TEtYCrcrznZmhowtmX9YimePEBwlx4D0eZxGxnMge0Q=; b=t2s6hanpG3WIc7JumGHE6ikRb/BZ8HyUh3MEPup85vkffmVB/Nb1z9uDYll9oEkAX3 7epOrcH7ahilzHOpRvK5S19RwcNC2uXCyNPgC/G7Km+i1pxIsS2ujy+Ziziup3+X6ByA lcsXE7L9aV/fjFU2eFl+qtnLr66uaOITQeijEEIPz1M/KxMQAP+yiq23OOeP3LEtZR5g t/YAkoC7ZFZcoUPD0p3Ym8t5PBC82sml9oYABbq4xXy8XFrITQfN5aT2nmTfV8b92qM5 /dfTjrbfBumhxJrOblzg1s0l3OnVEiVtsDzvx2s8MUltxJbYBwo+QibGpuKTHP7OUufj SZvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=laxhOAuF; 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 j15-20020a05620a288f00b007429c021b74si971260qkp.536.2023.03.02.18.58.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:58:41 -0800 (PST) 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=laxhOAuF; 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 1pXvcg-0007Qv-Nr; Thu, 02 Mar 2023 21:58:18 -0500 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 1pXvcZ-0007P9-Iq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:11 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcY-0001lc-2t for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:11 -0500 Received: by mail-pj1-x102c.google.com with SMTP id l1so1173378pjt.2 for ; Thu, 02 Mar 2023 18:58:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812288; 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=TEtYCrcrznZmhowtmX9YimePEBwlx4D0eZxGxnMge0Q=; b=laxhOAuFtXBcu0sBUJuq2dfEL2+Obz/NrMQk961r+Lee8PZj0qEv0vI/gqs45oQckg d3z2b4e/TbNXtGh4/N9ZNnpAr5KviD5crFxNX4l04WYVYM0Ko0NbGtBi864/TRgMbnCW FpX/3yO7qEr6Qn56szPTPaGV3yhefCe7pI53eCJ+LVm4ewTgnNc3Mfawp4XekAXMVABR kZ3MBQVcoWzNEsS5i1QuU97oeDarjSlivtyUuVe4i2W3895wuWBZEQC3urt3a/RHmlGh bDUrTt6NDIpNLItQs0tRiKbvSkGZ14byQ4oFuEQLOoisqfVadGaQwlCsVdNFRxu/19aZ 4Sog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812288; 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=TEtYCrcrznZmhowtmX9YimePEBwlx4D0eZxGxnMge0Q=; b=vtum7JNweegHi70FYMCoUwh67xO5XOMK6PYmKO8B7Cphb+S9moOq/BBejQrpnJapLg 7gmD5IvLcWeKbK5L+Un4ar4q7uP7R/nY6UyZ8UfY91yaDAc3d2HhZeZwYsZwNJk41XRg r7vQHWFyCKcWsjYF3+iqPSuMhqBUYtLA1hdtb5pBAt4olDA94o0TsMBZL+aOiQbEmWp2 Oef6MA4pqDDhMTfCYaZVeiBn9ozdY1eGAgB3z3rcyWPZGWSY8nUeHtxBEYr2HRUFXj/7 Vgl95ukvwjZ0MYE1Shn5XaKQeZD+ssZSsvcHIHbxvd3d5eWY9EhEHUg9iSZ9GJEy1QhX Ys5Q== X-Gm-Message-State: AO0yUKWVmXbcfnVNtwu/di2/cxVy3D+CxKidc2zHj8wDgmJkf/jgK564 Dkj1Qiv8V7L7hwF8IcrhYKAcaDEyBsMsQL4tDsM= X-Received: by 2002:a17:903:228b:b0:19c:bae2:681a with SMTP id b11-20020a170903228b00b0019cbae2681amr448690plh.66.1677812288352; Thu, 02 Mar 2023 18:58:08 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Bin Meng , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 01/29] gdbstub/internals.h: clean up include guard Date: Thu, 2 Mar 2023 18:57:37 -0800 Message-Id: <20230303025805.625589-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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 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: Alex Bennée Use something more specific to avoid name clashes. Reviewed-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-2-alex.bennee@linaro.org> --- gdbstub/internals.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b23999f951..7df0e11c47 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -6,8 +6,8 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef _INTERNALS_H_ -#define _INTERNALS_H_ +#ifndef GDBSTUB_INTERNALS_H +#define GDBSTUB_INTERNALS_H #include "exec/cpu-common.h" @@ -16,4 +16,4 @@ int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len); int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len); void gdb_breakpoint_remove_all(CPUState *cs); -#endif /* _INTERNALS_H_ */ +#endif /* GDBSTUB_INTERNALS_H */ From patchwork Fri Mar 3 02:57:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658455 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225833wrb; Thu, 2 Mar 2023 19:00:34 -0800 (PST) X-Google-Smtp-Source: AK7set9mBJJm22jbSeLQ4zuaQPZfhRpfysMpcT4way71NTfPCMBcF04H6nzJ98ZYgALgEo+zNqVn X-Received: by 2002:a05:6214:3012:b0:56e:a88f:70d0 with SMTP id ke18-20020a056214301200b0056ea88f70d0mr439572qvb.27.1677812434010; Thu, 02 Mar 2023 19:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812433; cv=none; d=google.com; s=arc-20160816; b=pYF4WwtDu6HqGtNFoe8jYlBEz86FeZl5WrkUkXhzH7szdLhahVjiFAPqMC0PmWMrlM UgNkDd2WinF+6PQuqCNOoP3FrkMsWWZGeg9rAW+clUbqQ4NIDe4DsPKbgZa7DrmK9mc1 /HCVk7LYcxvgUZlM21SdKXiat+qNlKU092nUV1s1PpNr40crybAs3meQ9VALm75OVFjm 2hZhbu7y12s274yDnCeH000xNTCsRp9wdUs7nZXHuf4nVALctdrNCWA7DbSClhbMwdSE dhAsH4BmLfwxLKDHCyqV962bZoUuvCgK+NUHY6rELf+1Q/Iui/t5JrW/wPtAJ933tPtA FHUA== 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=d4wGdJDq5Z3S9B978lEtV+HF+zdV67+9n1J0Csb0VjI=; b=J1xqcbxpAdig51WrOT4W3ucWxN4OEi8YFjHuMdu3MY6S7+z6HdnwQ4BL/onX3/yhdw m+XcDWhZBsnuCrRgtQN9oQhU2a3AsbUODM3T0MyKyo4tK3ZuH5lKejilNhdqC/fjOb8P lBe50EwntpHIWL09BFCP5+Zl+iOkqZntL2CcJFGyGLJKwc4StLjGQM6DTkc2+hHTeqtt XA9LzJ9pu3D1AL9O0incvLobTvbjBN6CH0CxHFrNi8EFaQ7cwSR+oiTw056iqfiX4HBx ng29jLx2eZvWdO7UU201JcTJ72fPpfJnyzVGXzv4yjBs6LlwFi+VtdPgUCZysBrN0+4X B+Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o7QGBGw1; 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 bi5-20020a05620a318500b00742700dd7casi900218qkb.514.2023.03.02.19.00.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:33 -0800 (PST) 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=o7QGBGw1; 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 1pXvch-0007Rr-Rr; Thu, 02 Mar 2023 21:58:19 -0500 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 1pXvcb-0007Pc-FB for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:13 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcZ-0001mZ-Vz for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:13 -0500 Received: by mail-pj1-x102b.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so4851459pjh.0 for ; Thu, 02 Mar 2023 18:58:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812289; 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=d4wGdJDq5Z3S9B978lEtV+HF+zdV67+9n1J0Csb0VjI=; b=o7QGBGw1fd+TnjQWqbJR6B/4Dd9rjnnS/qRyFuN1FgRjAY+cVWVtYfj7edzy92ro7v 3VvREFo3nWDg6tii5xNeN/elmpsr6D00O+GZcuUbBLT/Ap3gkt09mVrgIKHKI3X19yAw S7UwrL1RLgZlWFseMRBEq1msZd9f/RSt4OvXXXdq56hwPLoyKSuAcav5RHXqjl7+k8T4 OHsVMyxsLW4pDn+lv9PbW60oowUHHFvjdLvGgCOi/YeMq1ck98N+VG31q4FjyEnQpW8w WTDA0SHO0q0VehV44fXZsnoUdxNVg57nx9GE63D/upzKrACNvQP5KIZYt01LR9WghjRp ui7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812289; 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=d4wGdJDq5Z3S9B978lEtV+HF+zdV67+9n1J0Csb0VjI=; b=hKikqd95CqrelHTqeebXXKBxU0tTdU4akX+WQr7aiyl03qSg4Og3zh2DpDqrvgQC6R QndeiTX3Z4dF3+wNZxZ9JHi9FRw4+vrK8vgxjz6adsJJxLi3YnSnlIbUJrrSKbdeqizM cgSZkrF9hs/yLUKN5B2xfR6H9lJ/wjTSs4oJR/Xn4f5muVUAP3EGETH4GQEDp5JhSPq2 +xamHBxLX0cLAZ4ipsOTLhqy3Zc5R3U+A+XEp0rH+s+AhOmiJztgKGwrVcYfq20TTn3B c8rlddGLq9f3MDtsYGRkcX1ctZItHmDun98io1puHoMrlGOFUxMXqOHb+87jEqc7kdfm 1CnA== X-Gm-Message-State: AO0yUKXPp5nGHm49y4fmnu3JCsG6puKM1WPadNZzlY5Jwvp/x7e5bcxf N/CHt9beT+4vH7YmJcn1xInOu/WvmVuqbXLt/Wg= X-Received: by 2002:a17:903:283:b0:19c:d309:4612 with SMTP id j3-20020a170903028300b0019cd3094612mr655758plr.6.1677812289333; Thu, 02 Mar 2023 18:58:09 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 02/29] gdbstub: fix-up copyright and license files Date: Thu, 2 Mar 2023 18:57:38 -0800 Message-Id: <20230303025805.625589-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 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: Alex Bennée When I started splitting gdbstub apart I was a little too boilerplate with my file headers. Fix up to carry over Fabrice's copyright and the LGPL license header. Fixes: ae7467b1ac (gdbstub: move breakpoint logic to accel ops) Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-3-alex.bennee@linaro.org> --- gdbstub/softmmu.c | 3 ++- gdbstub/user.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 129575e510..05db6f8a9f 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -4,9 +4,10 @@ * Debug integration depends on support from the individual * accelerators so most of this involves calling the ops helpers. * + * Copyright (c) 2003-2005 Fabrice Bellard * Copyright (c) 2022 Linaro Ltd * - * SPDX-License-Identifier: GPL-2.0-or-later + * SPDX-License-Identifier: LGPL-2.0+ */ #include "qemu/osdep.h" diff --git a/gdbstub/user.c b/gdbstub/user.c index 484bd8f461..09a18fb23b 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -3,9 +3,10 @@ * * We know for user-mode we are using TCG so we can call stuff directly. * + * Copyright (c) 2003-2005 Fabrice Bellard * Copyright (c) 2022 Linaro Ltd * - * SPDX-License-Identifier: GPL-2.0-or-later + * SPDX-License-Identifier: LGPL-2.0+ */ #include "qemu/osdep.h" From patchwork Fri Mar 3 02:57:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658471 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226821wrb; Thu, 2 Mar 2023 19:02:38 -0800 (PST) X-Google-Smtp-Source: AK7set8TMPCxHhvOjZuWMIq/UZWtam8bptxmuf9heuWd0uNBeDvjYkPasP9gdCWKrnj1GvXsVdg0 X-Received: by 2002:ad4:596d:0:b0:56f:154:250e with SMTP id eq13-20020ad4596d000000b0056f0154250emr593101qvb.35.1677812558053; Thu, 02 Mar 2023 19:02:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812558; cv=none; d=google.com; s=arc-20160816; b=OdpBrV7LfWDYBzXG2dRkYNWFbeIdQSOv7gcL+JqLy0BoUc0pNZTtdtoZDf+Uy5P0AI NHPVZjoI/cM6Z3syIFQgZc89C4eEQwBuvs9R9nJJme8As8qTMyjQFPOwjwztE5bM1J1L AFJoAyleEKS6rOf+3CD3JWDPnSIp5Z2cXaOcQkLIN6XnT9uuNapEtKVFq8fgLrnGocdj CZBoMqgbEmrzrfRIk8T/J5QqtSMcwQZJpTFeNKOL1Q+4mLc7L7JNfgHUcRZDN2wVd9+E aeoxbNahgcNlCa/lWGcfauefK/k8O6rFiXfBIH82RQOrcPpZsYthvRf1tKqip4ymVZar t/SQ== 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=OEtCGKXwc5R5woyG/cv3/9an/+vnS/RcluuE2Zr/HR4=; b=FOM4bwfNfyaO1e89NP9Pj1eU32NB36B9IPpWAiH9rx6DBY6ahsuKfyj3FYVHXdiX58 ISG/dELNBObHF4X2Yl59GI5joT9nhcB1jJ9G5TTykc5M0KJh18n/VA4N4JNv8TFeXyQp dRDlvGTdMy/TbAT7yu6iDxLQjlV+uuFYhmLHJWAOQepH9IBnq+0urzCL5RtshGNb9iHu E1hbCtyR/ysZ2ZrPfgW4NG+oAlJfWDfaNLvheuSvKZj+B1TDV9Av9WiL9c5h0H/2iEN/ AMNl7ljaDMK9sNzT16GqVWdQFU6+08JND8jw+KD563nHgMsE035aTDcUjcOo3T/Amc9i 1vIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ma6jETDK; 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 m4-20020a0cdb84000000b0057237542cd4si737111qvk.153.2023.03.02.19.02.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:02:38 -0800 (PST) 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=ma6jETDK; 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 1pXvco-0007VU-14; Thu, 02 Mar 2023 21:58:26 -0500 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 1pXvcb-0007Pd-KC for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:13 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcZ-0001o8-Vq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:13 -0500 Received: by mail-pl1-x62a.google.com with SMTP id i10so1322252plr.9 for ; Thu, 02 Mar 2023 18:58:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812290; 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=OEtCGKXwc5R5woyG/cv3/9an/+vnS/RcluuE2Zr/HR4=; b=ma6jETDKNQbGFVQe7d9Ly+86QJKjlO8SZVCIATBQ96evOAQsbbseHBXbj+L4gD0Zey secRSGC7JhPGlHaW4TtbBiz3UZJZirGYRdwYY+p65AHQ1a+BYG3ry3CsG0FHNEOpErp6 BMsjoToi24PE1CLzTrxaS5+rlTt/aKgqOExwcE06/n0IZAmva8+4Zoc5MFkAEWACPnGy WmBXuGxBwAijCOzBK6hTNEQHQQ1Jtp0d3/MIAYGjz5cDkA5YKXScvRBhySVnwPFz6/yE Qz1AxzEfRhH5kWXDM6xM7VM5rtZfzQT4PxVrNnYOwS6Q5ESD9f+TwqskBkBgPe4q1mRR qM3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812290; 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=OEtCGKXwc5R5woyG/cv3/9an/+vnS/RcluuE2Zr/HR4=; b=FfV5V+woj1SyIjZlH0wX1srJs1W+gF/Mn8tY6/SMXB4u5qjQ4X4ZKkMS9GF63biDz+ Fy6qtzY20nXLxGKDa2GjSix6JWSp5JUP+6Bun3UX2GZZoOc4hNl6y/4MGg4TgJR1Ozfm +wxKyxZO/3aLxki19cut4M/0Wrg8KJJK5Xtff0G/CxGPHh7SPekCw5GepcoHX0T2qWxL VuV4q4A4Aa21RVy75bHg9tT8K7rPiLNbP8iVTMFHpWhF+cGt5b47fE3vRSPmxGemuXsZ 4huaA/JVE6iG9N9L63dBNMF6r1WMnFvm5qiQ0byxVRwHqEzIStpsIuiwqWQafXQNlXRD yVAQ== X-Gm-Message-State: AO0yUKWtlVrf2gzaI0FbOoPj1cUXIuE8g0if0maV13abIGoUssehbQHk vDGV0YY1CHCzxZCeBRtinc24TjqVaMhTVEgPuxw= X-Received: by 2002:a17:903:11c3:b0:19e:6657:2c21 with SMTP id q3-20020a17090311c300b0019e66572c21mr516711plh.7.1677812290351; Thu, 02 Mar 2023 18:58:10 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 03/29] gdbstub: Make syscall_complete/[gs]et_reg target-agnostic typedefs Date: Thu, 2 Mar 2023 18:57:39 -0800 Message-Id: <20230303025805.625589-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 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: Philippe Mathieu-Daudé Prototypes using gdb_syscall_complete_cb() or gdb_?et_reg_cb() don't depend on "cpu.h", thus are not target-specific. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20221214143659.62133-1-philmd@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-4-alex.bennee@linaro.org> --- include/exec/gdbstub.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index f667014888..1636fb3841 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -71,9 +71,6 @@ struct gdb_timeval { uint64_t tv_usec; /* microsecond */ } QEMU_PACKED; -#ifdef NEED_CPU_H -#include "cpu.h" - typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int err); /** @@ -126,6 +123,7 @@ int gdb_handlesig(CPUState *, int); void gdb_signalled(CPUArchState *, int); void gdbserver_fork(CPUState *); #endif + /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); @@ -133,6 +131,9 @@ void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, int num_regs, const char *xml, int g_pos); +#ifdef NEED_CPU_H +#include "cpu.h" + /* * The GDB remote protocol transfers values in target byte order. As * the gdbstub may be batching up several register values we always From patchwork Fri Mar 3 02:57:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658453 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225816wrb; Thu, 2 Mar 2023 19:00:32 -0800 (PST) X-Google-Smtp-Source: AK7set//7EZv+JXCLSQPqTjFrS3ju5tKvN4mYMlGjml2v6ngs+FIaLE+dzrEQOolk0QNAWq81akK X-Received: by 2002:ac8:5f08:0:b0:3bf:a6db:6108 with SMTP id x8-20020ac85f08000000b003bfa6db6108mr758819qta.53.1677812432567; Thu, 02 Mar 2023 19:00:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812432; cv=none; d=google.com; s=arc-20160816; b=JeROyvKtzzXBeS/w6wihIQkE6+nL7q5IBKQLFA73AUoyobLY7JQ3XfO7E0y8lXfmss g31qzZfD5mU4+olKqTAvxGREZKSs7lmjE8gv3vvI145r01irNeVGB5/1hzzzOdpri8Nc 5XGDLPanoLYr1aQ1IUJrpaqhTF+fhci8L7e/Ir232snRhETV/9W/0YNO0TVEn8uuFBP6 kN18r/iRxnj2wRT8ETXGQnecI/VxnUZsPvycZLAUCpA7g0naE/XnKvfSzoinzK2dmVXf upZfwY6QRJoe27XDeH4TLyV5+QfK8bhY5fIrYbZTcqRKFvuiExHDPL/q9jvVWKCn3AEI DMVw== 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=vbTFZ1f//WCKqJl3a99CsWy+g64MYDHqVH/YBzELWfQ=; b=KgJzu+VqYn4R/+4f5hR91fGlU7YEHr4OKNsw7x0/9emEgWgE4VT4FCJPp3FyN+qxlo xZzhHxcxsqkFaz7jIZ6tKo8Q2ilD9osE/rI9CtjY3Rx/XouRlYeLmgJHesbSugZ1/GYd 080G4T8VHcb8B5S6coMakqBlPmsHr6bgv5ezwQPrqgUYhoaVXO0oUXBuUDYeG7xWwDRQ pISbtHgrk0p8ILbZGIqC79aAqCo4CBGZTuwA5A5QPe6gxAVkVRdNdlx2uz/VYGDaj2Oo JLQ1xR4gLM+spSmqImBiAKx3T6yEmt1ApN1lqYSF+j9NVE8mWTM2iZlA2dXfN4wIqMEV xqeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PdQhN+5W; 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 n16-20020a05622a11d000b003bcf7d8df93si913526qtk.431.2023.03.02.19.00.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:32 -0800 (PST) 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=PdQhN+5W; 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 1pXvcn-0007VL-Iw; Thu, 02 Mar 2023 21:58:25 -0500 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 1pXvce-0007QL-Iu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:17 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvca-0001oU-Qu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:14 -0500 Received: by mail-pj1-x102d.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so4851499pjh.0 for ; Thu, 02 Mar 2023 18:58:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812291; 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=vbTFZ1f//WCKqJl3a99CsWy+g64MYDHqVH/YBzELWfQ=; b=PdQhN+5WzOLuvf9oh8UeVRam1saPkfblLm1VMWgrwjxS/M8iEYkEcNHkvXnguipXtn +4EJkwyxPCsL1BTwrH+5i0XeSPAwxx1Ii55QYn/P4d29SGhOy1PVm+CbggSGZpHVsE8N CrE8q7ofNAAZwiZxx+E2sGX+zqWEX7JpdXWz8Dfv7tbCvgSxnxLmgjE7VHyxI4rvJpnS 5XjqV0VUqyBfaoLuMZOc5TtW5FylxiE6+2Ztn9XMxGuSOp98ZAvgXhwDEVhOcnTn5h8F v1pjo27tqzB95TCXl5XEcLu9EFfP89dMRWdh4NMKU1vqOFqF2yjqVkOTSNOkIrpYgiuw Jorw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812291; 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=vbTFZ1f//WCKqJl3a99CsWy+g64MYDHqVH/YBzELWfQ=; b=mzocMwjyN6JiIEiKIFVZPp0REzGVDGus9kSbRo+A78eJgyM9PchlQLxN671PdGlh/L NGrv0L8IuzkUzvVsruzD1TbfNJI/FBMY0C/+d3nEfksOl0+zuyw0KrLX4GkpEEpkrLY9 XqmGUNdoQuiu5r7aLzii2rw9r5d1H9rq07I+3ZDQ/7dp+USfm+hZ3A7LEwesfclNKPDd CFvx0s9j057wDR0Fl2rqhzI8EuzTYWOZSiKgscJAoAYH8RryBGnAyK5XT00LHiSVEzk+ thpNAiE2fO31Optzv3OcEAJcLL3uI9MYJ96nV/5iJHkGhGJ4Hub1qOD38hto6llqlYmo sTqw== X-Gm-Message-State: AO0yUKVFqU9zWwpeSIkdnkw7EQMXHOAlbDyw1tPRHT7sqlKnkmZb/pMl 9cCFKLiQqVqkd//SXfQPd1LbKOSCHLAY4CJ4hq4= X-Received: by 2002:a17:903:22ce:b0:19d:90f:6c6c with SMTP id y14-20020a17090322ce00b0019d090f6c6cmr698619plg.17.1677812291174; Thu, 02 Mar 2023 18:58:11 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 04/29] gdbstub: clean-up indent on gdb_exit Date: Thu, 2 Mar 2023 18:57:40 -0800 Message-Id: <20230303025805.625589-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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 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: Alex Bennée Otherwise checkpatch will throw a hissy fit on the later patches that split this function up. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20230302190846.2593720-5-alex.bennee@linaro.org> --- gdbstub/gdbstub.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index fb9c49e0fd..63b56f0027 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -3021,27 +3021,27 @@ static void gdb_read_byte(uint8_t ch) /* Tell the remote gdb that the process has exited. */ void gdb_exit(int code) { - char buf[4]; + char buf[4]; - if (!gdbserver_state.init) { - return; - } + if (!gdbserver_state.init) { + return; + } #ifdef CONFIG_USER_ONLY - if (gdbserver_state.socket_path) { - unlink(gdbserver_state.socket_path); - } - if (gdbserver_state.fd < 0) { - return; - } + if (gdbserver_state.socket_path) { + unlink(gdbserver_state.socket_path); + } + if (gdbserver_state.fd < 0) { + return; + } #endif - trace_gdbstub_op_exiting((uint8_t)code); + trace_gdbstub_op_exiting((uint8_t)code); - snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(buf); + snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); + put_packet(buf); #ifndef CONFIG_USER_ONLY - qemu_chr_fe_deinit(&gdbserver_state.chr, true); + qemu_chr_fe_deinit(&gdbserver_state.chr, true); #endif } From patchwork Fri Mar 3 02:57:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658449 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225266wrb; Thu, 2 Mar 2023 18:59:08 -0800 (PST) X-Google-Smtp-Source: AK7set/auwXEdCDN24i6Lk5Ju7B2N3WeE3X0ZIrcXQMpSQCacFR44IFX0WNStVWUwB2FeIUKtCU5 X-Received: by 2002:a05:622a:54e:b0:3bf:c86b:3d2a with SMTP id m14-20020a05622a054e00b003bfc86b3d2amr659213qtx.9.1677812348419; Thu, 02 Mar 2023 18:59:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812348; cv=none; d=google.com; s=arc-20160816; b=UI6Lo7ocA6CS5LQztm8nAbXtI7RBQz3RnhrsZ2wCpvLhFH2m/z1Kn1svYt4xMkcsJg AlBhc65HJ4e9YhMZyc5mBHJHz7UjB3ZpqhIQE4Vv/pM/8Wyd3WuS8SmZR3WhejGw8XOC V9bozJLEdWV62e3u26CMtm3mAW94QTxYSeiiOMO0EhwBDa7Nd6FO7IVrzuJVo+uFixaR FIBMNW9lpUDSKMho+KMWdohVFb0UQGjcQD3Q+uFDxxWRNG6o4wnbUjHvIbVRUQ99D2fI 9mAqOuFyGRzzQvdJf6N01q7ZUWbJ1NymZrqYU5XKJV/yQQ3V26GIVrurJPdDSxaZ0b6I AR9Q== 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=4pRbYqRY0VGEczpozM4adTEzmEIYOjfBRmRXe4bR2kk=; b=YtWo83tfbZY7G0othoceOpicDlHOZBRnkhkTWpDD489f8LKPVvcMMMMsUVxgvRpY3K F/ULq4cOc5l5zp1/K6SAnieFwe5Vs3dFVcZL10Q+eQi5NBJ5NKy82jWHsNIJlG+qqGV1 3+RiyoeaDd5eA4nADKM9lI1LnXNA9HJZOF79apGm++JU4huZm22YqnLln1J4x5Y7bqwZ d4eoykqaU6qzsXrvLMHOf/WlfCCqvT00w8JhJTkACbcly3TAc4QyXOQkjrF//QSwDyGb /v2hpOcZ9dkYhvBarqaRx/YB+dEJLBgLiNExXAFeekYFgfOoVKWBG3jLc0c1ZndNZQWv Gifg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Lj5VwkC/"; 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 d15-20020a05622a05cf00b003b637d3f3e5si896035qtb.402.2023.03.02.18.59.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:59:08 -0800 (PST) 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="Lj5VwkC/"; 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 1pXvci-0007S5-HA; Thu, 02 Mar 2023 21:58:20 -0500 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 1pXvce-0007QM-It for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:17 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcb-0001oX-GX for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:15 -0500 Received: by mail-pj1-x1029.google.com with SMTP id x20-20020a17090a8a9400b00233ba727724so4666977pjn.1 for ; Thu, 02 Mar 2023 18:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812292; 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=4pRbYqRY0VGEczpozM4adTEzmEIYOjfBRmRXe4bR2kk=; b=Lj5VwkC/JiuoekgfDDEN6rCbPaZzybHf4YEMCtoVZyd3aHa2sJp40EwJesaX/t7sno ErQ3TXBmoN71VPiIHWmTqomf3jFXgz2lnXwc1vX2cFMgYirSKfMk06GaKD9zYCN1gS2l R8ZDI44gQOfbHYQmUDmDLvGZZy2P6zMCZZQKvovod+IRujRtNNlxfnd5Nd6YP32AgiQc 3jhLLl7GlcT5BlFHR60B9WTkYx/+KgZszjqtbYHxAUyqA2rUpBHY4eC/oggJ8+LtKGCQ eRxz5wm50d/iJNNPmheco6OFIL+To8t+e6VPENh3zatklKVNWiXB8GUnvZuLOPhhhYbG U0Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812292; 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=4pRbYqRY0VGEczpozM4adTEzmEIYOjfBRmRXe4bR2kk=; b=eEmPPGDif4aJsyXInyeldC1O+XkJkW1zNdLLv3DsoOvMk2xlr4hBUBK6YMB4oNPemR px8K6OgTyekkPPaceELYqiZwNBfhQELdrx4pTt26RB8K31ikNMQs9BpWKTflQYoB0dWc owPIVQiZMZhp9qvwAwruxgUmg7kE62O3xF8mxiaMUHkHwfoFWgpUj10HQrJoldF2ARxd 5ydMsAF4oBwbGsf3OpM6Yav086ybkIDqxJl3X0Eh6ZLrHsXbWgGDUcvYbx8QmMJDZODE 8qO1H6IfaiwX36bfbZsEmdY2QMyvPZYz6In/+0ezVwINni5v3oKm1qnbZcNsey+m+vWq I7pA== X-Gm-Message-State: AO0yUKVRmuTN8R+zriHtWW2qt5UPLHZ7wG/01TTNoLWF5TOXuUFzdQ+5 1TaPoGYhxErJV9irGXkReLMOZOKKBBij4sAAWQQ= X-Received: by 2002:a17:902:bc42:b0:19c:faaf:b9d6 with SMTP id t2-20020a170902bc4200b0019cfaafb9d6mr499760plz.8.1677812291901; Thu, 02 Mar 2023 18:58:11 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 05/29] gdbstub: define separate user/system structures Date: Thu, 2 Mar 2023 18:57:41 -0800 Message-Id: <20230303025805.625589-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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 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: Alex Bennée In preparation for moving user/softmmu specific bits from the main gdbstub file we need to separate the connection details into a user/softmmu state. As these will eventually be defined in their own files we move them out of the common GDBState structure. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-6-alex.bennee@linaro.org> --- gdbstub/gdbstub.c | 94 ++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 41 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 63b56f0027..1e6f8978b5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -341,6 +341,22 @@ enum RSState { RS_CHKSUM1, RS_CHKSUM2, }; + +#ifdef CONFIG_USER_ONLY +typedef struct { + int fd; + char *socket_path; + int running_state; +} GDBUserState; +static GDBUserState gdbserver_user_state; +#else +typedef struct { + CharBackend chr; + Chardev *mon_chr; +} GDBSystemState; +static GDBSystemState gdbserver_system_state; +#endif + typedef struct GDBState { bool init; /* have we been initialised? */ CPUState *c_cpu; /* current CPU for step/continue ops */ @@ -353,14 +369,6 @@ typedef struct GDBState { int line_csum; /* checksum at the end of the packet */ GByteArray *last_packet; int signal; -#ifdef CONFIG_USER_ONLY - int fd; - char *socket_path; - int running_state; -#else - CharBackend chr; - Chardev *mon_chr; -#endif bool multiprocess; GDBProcess *processes; int process_num; @@ -412,15 +420,17 @@ static int get_char(void) int ret; for(;;) { - ret = recv(gdbserver_state.fd, &ch, 1, 0); + ret = recv(gdbserver_user_state.fd, &ch, 1, 0); if (ret < 0) { - if (errno == ECONNRESET) - gdbserver_state.fd = -1; - if (errno != EINTR) + if (errno == ECONNRESET) { + gdbserver_user_state.fd = -1; + } + if (errno != EINTR) { return -1; + } } else if (ret == 0) { - close(gdbserver_state.fd); - gdbserver_state.fd = -1; + close(gdbserver_user_state.fd); + gdbserver_user_state.fd = -1; return -1; } else { break; @@ -479,7 +489,7 @@ static inline void gdb_continue(void) { #ifdef CONFIG_USER_ONLY - gdbserver_state.running_state = 1; + gdbserver_user_state.running_state = 1; trace_gdbstub_op_continue(); #else if (!runstate_needs_reset()) { @@ -508,7 +518,7 @@ static int gdb_continue_partial(char *newstates) cpu_single_step(cpu, gdbserver_state.sstep_flags); } } - gdbserver_state.running_state = 1; + gdbserver_user_state.running_state = 1; #else int flag = 0; @@ -560,7 +570,7 @@ static void put_buffer(const uint8_t *buf, int len) int ret; while (len > 0) { - ret = send(gdbserver_state.fd, buf, len, 0); + ret = send(gdbserver_user_state.fd, buf, len, 0); if (ret < 0) { if (errno != EINTR) return; @@ -572,7 +582,7 @@ static void put_buffer(const uint8_t *buf, int len) #else /* XXX this blocks entire thread. Rewrite to use * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&gdbserver_state.chr, buf, len); + qemu_chr_fe_write_all(&gdbserver_system_state.chr, buf, len); #endif } @@ -2094,7 +2104,8 @@ static void handle_query_rcmd(GArray *params, void *user_ctx) len = len / 2; hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); - qemu_chr_be_write(gdbserver_state.mon_chr, gdbserver_state.mem_buf->data, + qemu_chr_be_write(gdbserver_system_state.mon_chr, + gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len); put_packet("OK"); } @@ -3027,10 +3038,10 @@ void gdb_exit(int code) return; } #ifdef CONFIG_USER_ONLY - if (gdbserver_state.socket_path) { - unlink(gdbserver_state.socket_path); + if (gdbserver_user_state.socket_path) { + unlink(gdbserver_user_state.socket_path); } - if (gdbserver_state.fd < 0) { + if (gdbserver_user_state.fd < 0) { return; } #endif @@ -3041,7 +3052,7 @@ void gdb_exit(int code) put_packet(buf); #ifndef CONFIG_USER_ONLY - qemu_chr_fe_deinit(&gdbserver_state.chr, true); + qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); #endif } @@ -3077,7 +3088,7 @@ gdb_handlesig(CPUState *cpu, int sig) char buf[256]; int n; - if (!gdbserver_state.init || gdbserver_state.fd < 0) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return sig; } @@ -3095,15 +3106,15 @@ gdb_handlesig(CPUState *cpu, int sig) } /* put_packet() might have detected that the peer terminated the connection. */ - if (gdbserver_state.fd < 0) { + if (gdbserver_user_state.fd < 0) { return sig; } sig = 0; gdbserver_state.state = RS_IDLE; - gdbserver_state.running_state = 0; - while (gdbserver_state.running_state == 0) { - n = read(gdbserver_state.fd, buf, 256); + gdbserver_user_state.running_state = 0; + while (gdbserver_user_state.running_state == 0) { + n = read(gdbserver_user_state.fd, buf, 256); if (n > 0) { int i; @@ -3114,9 +3125,9 @@ gdb_handlesig(CPUState *cpu, int sig) /* XXX: Connection closed. Should probably wait for another connection before continuing. */ if (n == 0) { - close(gdbserver_state.fd); + close(gdbserver_user_state.fd); } - gdbserver_state.fd = -1; + gdbserver_user_state.fd = -1; return sig; } } @@ -3130,7 +3141,7 @@ void gdb_signalled(CPUArchState *env, int sig) { char buf[4]; - if (!gdbserver_state.init || gdbserver_state.fd < 0) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } @@ -3145,7 +3156,7 @@ static void gdb_accept_init(int fd) gdbserver_state.processes[0].attached = true; gdbserver_state.c_cpu = gdb_first_attached_cpu(); gdbserver_state.g_cpu = gdbserver_state.c_cpu; - gdbserver_state.fd = fd; + gdbserver_user_state.fd = fd; gdb_has_xml = false; } @@ -3277,7 +3288,7 @@ int gdbserver_start(const char *port_or_path) if (port > 0 && gdb_accept_tcp(gdb_fd)) { return 0; } else if (gdb_accept_socket(gdb_fd)) { - gdbserver_state.socket_path = g_strdup(port_or_path); + gdbserver_user_state.socket_path = g_strdup(port_or_path); return 0; } @@ -3289,11 +3300,11 @@ int gdbserver_start(const char *port_or_path) /* Disable gdb stub for child processes. */ void gdbserver_fork(CPUState *cpu) { - if (!gdbserver_state.init || gdbserver_state.fd < 0) { + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { return; } - close(gdbserver_state.fd); - gdbserver_state.fd = -1; + close(gdbserver_user_state.fd); + gdbserver_user_state.fd = -1; cpu_breakpoint_remove_all(cpu, BP_GDB); cpu_watchpoint_remove_all(cpu, BP_GDB); } @@ -3487,21 +3498,22 @@ int gdbserver_start(const char *device) NULL, NULL, &error_abort); monitor_init_hmp(mon_chr, false, &error_abort); } else { - qemu_chr_fe_deinit(&gdbserver_state.chr, true); - mon_chr = gdbserver_state.mon_chr; + qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); + mon_chr = gdbserver_system_state.mon_chr; reset_gdbserver_state(); } create_processes(&gdbserver_state); if (chr) { - qemu_chr_fe_init(&gdbserver_state.chr, chr, &error_abort); - qemu_chr_fe_set_handlers(&gdbserver_state.chr, gdb_chr_can_receive, + qemu_chr_fe_init(&gdbserver_system_state.chr, chr, &error_abort); + qemu_chr_fe_set_handlers(&gdbserver_system_state.chr, + gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event, NULL, &gdbserver_state, NULL, true); } gdbserver_state.state = chr ? RS_IDLE : RS_INACTIVE; - gdbserver_state.mon_chr = mon_chr; + gdbserver_system_state.mon_chr = mon_chr; gdbserver_state.current_syscall_cb = NULL; return 0; From patchwork Fri Mar 3 02:57:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658447 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225240wrb; Thu, 2 Mar 2023 18:59:04 -0800 (PST) X-Google-Smtp-Source: AK7set/Juhhx27PGnmi5FRMLI1SbvJCEYdI/6mHnf5cPBh7JXR3qYqdRzVzhHTuBaSX4YJ7d04Cy X-Received: by 2002:a05:622a:114:b0:3b6:2f0d:1925 with SMTP id u20-20020a05622a011400b003b62f0d1925mr600392qtw.64.1677812343856; Thu, 02 Mar 2023 18:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812343; cv=none; d=google.com; s=arc-20160816; b=fv6OIO1L7b7g8OkJU5RAcvcyY1gSJIsllDWOfwh++mVeVaUh+MfZmDNvvH37O7DfM7 0ugI7kWvrdLnfiwWpykThiHFh8ODjrjWpyf3+rWuHMFf6lGFtToXuXYGLm3Cyf9WIt+5 8l6rv1qC8ObZI/U8NRcS8QxHHvFaZRdDwRBxzTew7r1Zq+x5UeQnI2h6iH9jWpbLAT+t mZSiyRLFcpUm6n1Y9G1DSg4x/7truSOG/Y0ZXRLDX4uoO5gtOzAh1WR00ZFE4Xu8VBM3 NiPTiv3ntk4K5l1IzSrxAaE911JJAClmGpFlUplaWrhFJhkZmUdR8lBNPlqrmNPiJcwJ +aFg== 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=afKJl9J8dwmJwl5uT+DP4MXGN3pCqi29VExi2VZVhL8=; b=m9SFdLd0SLsjUnACq4vhQN5g/1C8QC3yf96BDqGmDX9btgfTpFVskQJ0htu+p9NV2w qG4tNNuihpZY6zMuBa/1/75YVDMvSHgAjVsZg4TqTj5OAmozWeRDVOKtznGBnMbzU8aM nSqgDyRsIpNBlWbaJGQkd/Epr5R36o5xH7AbmiL+f4H6WVSl+pBwdW71qX3a/kqe9fsD 2ChKfNfr10xTas1QHGXT0wZOT8rX8W3Iu4lXqESbwHbxw4bsr9eNjEvenRf5N9la789o S4yU27H2cgNGrkpmURd0AAcjY3ItI5SJEvBVGmTa8wmM+7jYOFjRSXX9zmn3OYXs3MBv 8fpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="g3/qSbu6"; 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 10-20020ac84e8a000000b003b9fc920075si990924qtp.199.2023.03.02.18.59.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:59:03 -0800 (PST) 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="g3/qSbu6"; 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 1pXvci-0007Sd-TY; Thu, 02 Mar 2023 21:58:20 -0500 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 1pXvcg-0007Qa-1F for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:18 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcd-0001od-VT for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:17 -0500 Received: by mail-pl1-x62a.google.com with SMTP id a9so1308359plh.11 for ; Thu, 02 Mar 2023 18:58:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812293; 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=afKJl9J8dwmJwl5uT+DP4MXGN3pCqi29VExi2VZVhL8=; b=g3/qSbu6whqbjnjm/Zgt8MiU15NnECCLDiJJjMIkCF/VSOc5/dq5RM5u+5/UIStxMn KkCuxY3VlewnU8yHIwNFjoAnQwZ8Q0sRtLJterV47Won0Obe8Kv3VqyBi+OmXGJ0icaH 0DvEHhPHJNVuEeOnwC2I/Ltg6mjyNwmRBiOHiQ1Hu7we8krjsXt39PFvbR3qHC3qXBH6 122qZvNpKC6686ozVKaqDfQdQOlaptb6NDqF/qUBXJyM20IKnPriOXVoLfrrQbCSw61b H6lrf4ZIYfuwzMlFiqL3UYCdZQNFufegKjTuX3JubpqavOvquKpb1PUFhzGA+7zeFMuS 272A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812293; 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=afKJl9J8dwmJwl5uT+DP4MXGN3pCqi29VExi2VZVhL8=; b=btEmpp1CjE60HQmAqc6bt4HnUJ2q5Q9IeEWfvBZwVdTTOY9Lh/LRPLGHzDxB+vfPsK XaMr7zHWrZxtrYKBbjOVhgUyyvcZZohQKel5/c9LU/+nRStQ0H2wEQ774mVDCMmaxpM3 vX+/xsf0mTSOZXrl+2SOc1HEyYinqrRKjus/XzqfiE2SkZEQf3NsK6i0/1ZyKkFGnc/z 9Dl5nVsTolrMxeonsN4Sd+TKhIXWzmp4hC1I4SgPIGEhp1G2AFvvBsEzy/FZ4WHPViST Ut9UF4UNCnOx56WmWGi9YzOHuzUUouGfkgijbh81ceLZVCvag5tVn0ejZ565AFRqhUQN E/HA== X-Gm-Message-State: AO0yUKUiaange7KMK4O30MnpVneW6cDXWyZlTEobkvtsnv296gYzr797 OMpflfHwpFzrh9LyNREWH25rxkH1LBZs2n8DES4= X-Received: by 2002:a17:902:db0b:b0:19e:524a:657 with SMTP id m11-20020a170902db0b00b0019e524a0657mr457407plx.56.1677812292624; Thu, 02 Mar 2023 18:58:12 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 06/29] gdbstub: move GDBState to shared internals header Date: Thu, 2 Mar 2023 18:57:42 -0800 Message-Id: <20230303025805.625589-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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 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: Alex Bennée We are about to split softmmu and user mode helpers into different files. To facilitate this we will need to share access to the GDBState between those files. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-7-alex.bennee@linaro.org> --- gdbstub/internals.h | 50 +++++++++++++++++++++++++++++++++++++++++++++ gdbstub/gdbstub.c | 42 ------------------------------------- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 7df0e11c47..32daaf73a3 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -11,6 +11,56 @@ #include "exec/cpu-common.h" +#define MAX_PACKET_LENGTH 4096 + +/* + * Shared structures and definitions + */ + +typedef struct GDBProcess { + uint32_t pid; + bool attached; + + char target_xml[1024]; +} GDBProcess; + +enum RSState { + RS_INACTIVE, + RS_IDLE, + RS_GETLINE, + RS_GETLINE_ESC, + RS_GETLINE_RLE, + RS_CHKSUM1, + RS_CHKSUM2, +}; + +typedef struct GDBState { + bool init; /* have we been initialised? */ + CPUState *c_cpu; /* current CPU for step/continue ops */ + CPUState *g_cpu; /* current CPU for other ops */ + CPUState *query_cpu; /* for q{f|s}ThreadInfo */ + enum RSState state; /* parsing state */ + char line_buf[MAX_PACKET_LENGTH]; + int line_buf_index; + int line_sum; /* running checksum */ + int line_csum; /* checksum at the end of the packet */ + GByteArray *last_packet; + int signal; + bool multiprocess; + GDBProcess *processes; + int process_num; + char syscall_buf[256]; + gdb_syscall_complete_cb current_syscall_cb; + GString *str_buf; + GByteArray *mem_buf; + int sstep_flags; + int supported_sstep_flags; +} GDBState; + +/* + * Break/Watch point support - there is an implementation for softmmu + * and user mode. + */ bool gdb_supports_guest_debug(void); int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len); int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 1e6f8978b5..ef506faa8e 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -41,8 +41,6 @@ #include "hw/boards.h" #endif -#define MAX_PACKET_LENGTH 4096 - #include "qemu/sockets.h" #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" @@ -325,23 +323,6 @@ typedef struct GDBRegisterState { struct GDBRegisterState *next; } GDBRegisterState; -typedef struct GDBProcess { - uint32_t pid; - bool attached; - - char target_xml[1024]; -} GDBProcess; - -enum RSState { - RS_INACTIVE, - RS_IDLE, - RS_GETLINE, - RS_GETLINE_ESC, - RS_GETLINE_RLE, - RS_CHKSUM1, - RS_CHKSUM2, -}; - #ifdef CONFIG_USER_ONLY typedef struct { int fd; @@ -357,29 +338,6 @@ typedef struct { static GDBSystemState gdbserver_system_state; #endif -typedef struct GDBState { - bool init; /* have we been initialised? */ - CPUState *c_cpu; /* current CPU for step/continue ops */ - CPUState *g_cpu; /* current CPU for other ops */ - CPUState *query_cpu; /* for q{f|s}ThreadInfo */ - enum RSState state; /* parsing state */ - char line_buf[MAX_PACKET_LENGTH]; - int line_buf_index; - int line_sum; /* running checksum */ - int line_csum; /* checksum at the end of the packet */ - GByteArray *last_packet; - int signal; - bool multiprocess; - GDBProcess *processes; - int process_num; - char syscall_buf[256]; - gdb_syscall_complete_cb current_syscall_cb; - GString *str_buf; - GByteArray *mem_buf; - int sstep_flags; - int supported_sstep_flags; -} GDBState; - static GDBState gdbserver_state; static void init_gdbserver_state(void) From patchwork Fri Mar 3 02:57:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658466 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226609wrb; Thu, 2 Mar 2023 19:02:09 -0800 (PST) X-Google-Smtp-Source: AK7set/IpDL6VS+9MpP0qH0rx1Nz7r4U5EzMbYi2IiN/pXfm93onpvb/2L23cXTtTEb4TJ9YIj3k X-Received: by 2002:a05:6214:21cd:b0:56e:a556:f28f with SMTP id d13-20020a05621421cd00b0056ea556f28fmr703342qvh.34.1677812528878; Thu, 02 Mar 2023 19:02:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812528; cv=none; d=google.com; s=arc-20160816; b=LESgZQzf8PU/LsHIe0XPAzhLX4T3pdzubFPaH2irmn34ApSdoyYaS4Nl59iogTqvad skcxNAT45aG8kEsOnWz1nxn3ZMLD3eF/DHwXy2e8mAtA4jSB7XEULNpz+fIEI5knJFY/ 2R30pZFQBj/DZU12M4MXe0Y8kT+LawPAWgC9eXX+cI2B2wQKGey2Ecm7ODtC5v/JD4ei TyqJwvmEntODxBUEcLunq4KojpZJMIvj18HVVvDTF6xpaMJO885lhAH3FQZul7iXmBa4 WVJHRdrQWmNNN/nFsf3DUh29QXraBHyL11GIBphwPHJ5QqGCc3+RwAMabCXDf/LkzAdU xqQQ== 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=B9W3wFs03k7dis/zJ2ZqM32MFlhRl5WhqJ+IbJHjQRQ=; b=iFVcglF10okmwmWJ3dSDV3vssqsNwbTlJlRBkG7zmUK8NVw6/eccGA9A4Td9JWv9qU 7GMSTUkAxF6DdsqubJHmP6XrqGJRsprCbMNbpVM9KY0IKadgfIW+6UxmgU+cY7Qd/0ry P0qT2oWT4ELVMtTnGtMiFIQfsXpQHPEBlJgA/Bp47dVjAlAZTPkE35Jf1Ky/dWXX0TLL utMlUTqRq4CGDs85DO8cBat7jjGcKwBAX91URwxYcmgtZn3Aq5PIHuF75XPGqMeMRD0r 9hJ1/2jU5Y6WOAdl/PE04i5hhDMtGeAB+RBJIfZOmmzIfDNraV7pbwJSvA55N0n6Lz8U n9CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AhMuzVjn; 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 bp20-20020a05620a459400b007426a8bc6d1si1051152qkb.112.2023.03.02.19.02.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:02:08 -0800 (PST) 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=AhMuzVjn; 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 1pXvco-0007VV-1o; Thu, 02 Mar 2023 21:58:26 -0500 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 1pXvcg-0007RS-T1 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:18 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvce-0001ou-BT for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:18 -0500 Received: by mail-pj1-x1031.google.com with SMTP id x34so1209780pjj.0 for ; Thu, 02 Mar 2023 18:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812293; 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=B9W3wFs03k7dis/zJ2ZqM32MFlhRl5WhqJ+IbJHjQRQ=; b=AhMuzVjn+9fvkhe/m4AycOCKTsYEm/L1A0zDs4Mv5SC3NaUjvuZZ2v3LZetGiVumoR Ik4td76+JYrIqbDfz8I17oTdosHRo64Ztja+PdiyltSRE/d/JQh+mugpaRaaGqGRqKb/ 9HyH9ptuxonKCE9OWrCw7TSe+M0JJbmt8tKjSzlE1YkznTh807MgMYtUDTziSrrvdJ8k D9YjCjXGoFF9omZE9gPS13zdqPO9JE8wJ1rxQFAyimLRFbZUPgCQXz4n0elMW1YxuMqJ rcEaXvGRw6yW66+rac7NKHxKpHuibzhkHf8jb2HYxPTDY1Eg0hEbDFXIs6LvZyfalve4 ifHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812293; 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=B9W3wFs03k7dis/zJ2ZqM32MFlhRl5WhqJ+IbJHjQRQ=; b=bo/qBw1y/LyLhq1Tsw2fMADS0YHp1hqA3X//hkQYstJJVFBGY/RKsRWoaBk+d1EUSd jEM9a4uh7KuG/3mrX1MsgDQYSlIb7JlJMI8tSXCdCDzQOD2cXVnN3H7sTnEV6TIhOBBH u86qGsOYT3oNsvtDF6GKNNXjvYu4Qn4Vns6Z/kZXkUG5ppe89XUzDF0wLfH45UHcjxHx Nu8w+Lk5sBjU4919iaCQBAVQ8LEhHtxMi6D2SaHnUwLipck3ahXnqXBRwuKollhVbkJ4 oN/AEv2CCclL3P+chfF7E8m+NztVVIra8tFIrHg4dtam7rHF4yUfUOXjviOopQDfapjn WyrA== X-Gm-Message-State: AO0yUKVhRaUKhxTExfR4xLnoUTsbraMk0ugRRGRx7Aq2D+rJB4yuUuAF IZGNRKH6tjPlCPKKBE/t2lzgsnO3SbLFjb4SVGE= X-Received: by 2002:a17:902:740a:b0:19c:bcb1:d75c with SMTP id g10-20020a170902740a00b0019cbcb1d75cmr425836pll.30.1677812293548; Thu, 02 Mar 2023 18:58:13 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 07/29] includes: move tb_flush into its own header Date: Thu, 2 Mar 2023 18:57:43 -0800 Message-Id: <20230303025805.625589-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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 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: Alex Bennée This aids subsystems (like gdbstub) that want to trigger a flush without pulling target specific headers. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-8-alex.bennee@linaro.org> --- MAINTAINERS | 1 + include/exec/exec-all.h | 1 - include/exec/tb-flush.h | 26 ++++++++++++++++++++++++++ linux-user/user-internals.h | 1 + accel/stubs/tcg-stub.c | 1 + accel/tcg/tb-maint.c | 1 + accel/tcg/translate-all.c | 1 + cpu.c | 1 + gdbstub/gdbstub.c | 2 ++ hw/ppc/spapr_hcall.c | 1 + plugins/core.c | 1 + plugins/loader.c | 2 +- target/alpha/sys_helper.c | 1 + target/riscv/csr.c | 1 + 14 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 include/exec/tb-flush.h diff --git a/MAINTAINERS b/MAINTAINERS index 76662969d7..234800e3dc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -136,6 +136,7 @@ F: docs/devel/decodetree.rst F: docs/devel/tcg* F: include/exec/cpu*.h F: include/exec/exec-all.h +F: include/exec/tb-flush.h F: include/exec/helper*.h F: include/sysemu/cpus.h F: include/sysemu/tcg.h diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index e09254333d..ad9eb6067b 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -677,7 +677,6 @@ void tb_invalidate_phys_addr(target_ulong addr); #else void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr, MemTxAttrs attrs); #endif -void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end); void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr); diff --git a/include/exec/tb-flush.h b/include/exec/tb-flush.h new file mode 100644 index 0000000000..d92d06565b --- /dev/null +++ b/include/exec/tb-flush.h @@ -0,0 +1,26 @@ +/* + * tb-flush prototype for use by the rest of the system. + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef _TB_FLUSH_H_ +#define _TB_FLUSH_H_ + +/** + * tb_flush() - flush all translation blocks + * @cs: CPUState (must be valid, but treated as anonymous pointer) + * + * Used to flush all the translation blocks in the system. Sometimes + * it is simpler to flush everything than work out which individual + * translations are now invalid and ensure they are not called + * anymore. + * + * tb_flush() takes care of running the flush in an exclusive context + * if it is not already running in one. This means no guest code will + * run until this complete. + */ +void tb_flush(CPUState *cs); + +#endif /* _TB_FLUSH_H_ */ diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index 3576da413f..9333db4f51 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -20,6 +20,7 @@ #include "exec/user/thunk.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "qemu/log.h" extern char *exec_path; diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c index 96af23dc5d..813695b402 100644 --- a/accel/stubs/tcg-stub.c +++ b/accel/stubs/tcg-stub.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" +#include "exec/tb-flush.h" #include "exec/exec-all.h" void tb_flush(CPUState *cpu) diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index efefa08ee1..7246c1c46b 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -22,6 +22,7 @@ #include "exec/cputlb.h" #include "exec/log.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "exec/translate-all.h" #include "sysemu/tcg.h" #include "tcg/tcg.h" diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 4b5abc0f44..7096e68406 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -47,6 +47,7 @@ #include "exec/cputlb.h" #include "exec/translate-all.h" #include "exec/translator.h" +#include "exec/tb-flush.h" #include "qemu/bitmap.h" #include "qemu/qemu-print.h" #include "qemu/main-loop.h" diff --git a/cpu.c b/cpu.c index 2e9f931249..e6abc6c76c 100644 --- a/cpu.c +++ b/cpu.c @@ -36,6 +36,7 @@ #include "exec/replay-core.h" #include "exec/cpu-common.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "exec/translate-all.h" #include "exec/log.h" #include "hw/core/accel-cpu.h" diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ef506faa8e..abb1777e73 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -47,6 +47,8 @@ #include "semihosting/semihost.h" #include "exec/exec-all.h" #include "exec/replay-core.h" +#include "exec/tb-flush.h" +#include "exec/hwaddr.h" #include "internals.h" diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 925ff523cc..ec4def62f8 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -8,6 +8,7 @@ #include "qemu/module.h" #include "qemu/error-report.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "helper_regs.h" #include "hw/ppc/ppc.h" #include "hw/ppc/spapr.h" diff --git a/plugins/core.c b/plugins/core.c index e04ffa1ba4..04632886b9 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -24,6 +24,7 @@ #include "exec/cpu-common.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "exec/helper-proto.h" #include "tcg/tcg.h" #include "tcg/tcg-op.h" diff --git a/plugins/loader.c b/plugins/loader.c index 88c30bde2d..809f3f9b13 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -29,7 +29,7 @@ #include "qemu/plugin.h" #include "qemu/memalign.h" #include "hw/core/cpu.h" -#include "exec/exec-all.h" +#include "exec/tb-flush.h" #ifndef CONFIG_USER_ONLY #include "hw/boards.h" #endif diff --git a/target/alpha/sys_helper.c b/target/alpha/sys_helper.c index 25f6cb8894..c83c92dd4c 100644 --- a/target/alpha/sys_helper.c +++ b/target/alpha/sys_helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "exec/helper-proto.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 1b0a0c1693..74c64d4902 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -25,6 +25,7 @@ #include "time_helper.h" #include "qemu/main-loop.h" #include "exec/exec-all.h" +#include "exec/tb-flush.h" #include "sysemu/cpu-timers.h" #include "qemu/guest-random.h" #include "qapi/error.h" From patchwork Fri Mar 3 02:57:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658443 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225163wrb; Thu, 2 Mar 2023 18:58:41 -0800 (PST) X-Google-Smtp-Source: AK7set/lmJ2efjeuiXcaastTnWXcHTJZaJOGoEfu+GTK//nRKwUZWvmQ2hM4MQGl4PvpURS86TF4 X-Received: by 2002:a05:6214:2a46:b0:56b:79fa:e6d9 with SMTP id jf6-20020a0562142a4600b0056b79fae6d9mr715722qvb.31.1677812321582; Thu, 02 Mar 2023 18:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812321; cv=none; d=google.com; s=arc-20160816; b=GRU91Ye1Lq84vcT2mrInn9yx3ubcQSpZTk+NZ8tWQlB3jlkbwbZssv3docWHgDYrVp wd0iAhOmS8lqDuAUfo4Q3kqPa884u6BJIXd9j/U9VSz/eHacHj6lT8XmJDGNTfXULlfK +6AN/I3hIMqfvNHMGnQXZSR7ZKLrJ6JmuOl5PH5qZCoNHzp/ulieVOv2poyIYi5P+jV9 jY/C+SmGkY06YQw8ikm6VPtxO68vlEEeEtF2oHND6FLEapq0WRxPvTJ7+r4SgVTNDdzk IkPP4lHUrYEt2v609LVwK90aqaz78tfHSIpkK7hNFPv5+WENLUJjFWkU8Kvl0v9ePoB9 ZDtQ== 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=oyetBuVHUOfnAjdQZE3Kw0yqpOK6LZBVb4ZSB9EDZrj0NuVLXDsTgpB69Uay33OoRB lZMFrVUu+kLyhhd2srGeHJ5j72n65CjXN/dEdktNBpCpuM2x7kt70nHwdixHmfl2sFl1 KC6l9Y/BrlL0QyEi50snRG526UJVOiWGOdImHseGlxsuSkG275V2ZDDncrBYvdv9heWE pkVfwHbhFisTbsuWjfB2ZUcoeuY/2tanK/jY7Zf2hUzsaay4Wpq56kf1icELUg7qrhGy +yYJIH4RBYtNEoxhQv3wpbZALlESPpwvkED3oZF+z+8pGvHVhwP9+/AQHPvyEa0U9/5B h0Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NUnIy20L; 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 k7-20020a05622a03c700b003b9b60dd798si967481qtx.761.2023.03.02.18.58.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:58:41 -0800 (PST) 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=NUnIy20L; 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 1pXvcj-0007T7-KN; Thu, 02 Mar 2023 21:58:21 -0500 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 1pXvch-0007Rn-Lu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:19 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvce-0001mZ-Bf for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:19 -0500 Received: by mail-pj1-x102b.google.com with SMTP id m8-20020a17090a4d8800b002377bced051so4851598pjh.0 for ; Thu, 02 Mar 2023 18:58:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812294; 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=NUnIy20LGnEP/1vY3HMnYooszgnMBv2svb75F64iQhCevUdpJc+szWcujV3BgNfMKV E7ieC0VjgVljadSCgf8Q6Ne/mJE8E4kdo7jAdv+vxmIs17BF+e0UVnegC9ohwoCMW+8z A54S27MJpCPkd2g1Irc33pIZ99HbMBVUFofaqQKUIrKg5OM+XzoV4dbZLY1bsWhbLKlL JoANFIe4+UANDC/q5Xe4im8CmmigxbKIY9Ss9GhyKE4YmzMXs0yDMYzblQESfDGhRnEF MTGmEUZW7Tv4e9A+5rClanHWtw+JhpzAXiA5rlRdCIwNzVtXJuHUWx7BF8Aa5FqQvgiM RMeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812294; 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=Ml/lxlPsGZ237YP0vQijC9mH3S52wrxh+gLuRleZguY=; b=NOsG8qnL+RnJZagE8XyqJT1n/tYfAsGLMoNwDI6hYQU5UubeITaKEbogS3xcuAYjJE vEkwgHFDsKbylKavEJxfi26z2FWCixGVc5MexqbiwKetYjqFe/Yf/MVAixFVlo44ad/N 45pvLnNIMVx6jXQcx9k73MJYKmFwNMT84xj8hxvy4cgzhDUp+hQtaVvFze1wwq3o+WRv BYcpJQYCSdhKE+gDAOxCLb/+2V8blZChvMKe3Uh5+uYKcO7TZhfB+eP0WohIWJ1YZIAE pz/GbjdoTSaPVxXJikE/YMIsdn1Z00G0k7RDmiPiQeqCV7PaGgJBGxcT7Mz6B6GJ/d9U vAtw== X-Gm-Message-State: AO0yUKVQUMTn/6m7X1Vvgt1xGZ3impyTXIy+UxkqIVNRK5KJ4Do737+W dmyFJeQJuGAtzkdpwA02x0o9m69zP/8NsDAj5XM= X-Received: by 2002:a17:902:c40b:b0:19e:8bfe:7d68 with SMTP id k11-20020a170902c40b00b0019e8bfe7d68mr711206plk.11.1677812294264; Thu, 02 Mar 2023 18:58:14 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 08/29] gdbstub: move fromhex/tohex routines to internals Date: Thu, 2 Mar 2023 18:57:44 -0800 Message-Id: <20230303025805.625589-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 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: Alex Bennée These will be needed from multiple places in the code. They are declared as inline so move to the header and fix up to modern coding style. The only other place that messes with hex stuff at the moment is the URI handling in utils but that would be more code churn so leave for now. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-9-alex.bennee@linaro.org> --- gdbstub/internals.h | 27 +++++++++++++++++++++++++++ gdbstub/gdbstub.c | 20 -------------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 32daaf73a3..b4620f99c4 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -57,6 +57,33 @@ typedef struct GDBState { int supported_sstep_flags; } GDBState; + +/* + * Inline utility function, convert from int to hex and back + */ + +static inline int fromhex(int v) +{ + if (v >= '0' && v <= '9') { + return v - '0'; + } else if (v >= 'A' && v <= 'F') { + return v - 'A' + 10; + } else if (v >= 'a' && v <= 'f') { + return v - 'a' + 10; + } else { + return 0; + } +} + +static inline int tohex(int v) +{ + if (v < 10) { + return v + '0'; + } else { + return v - 10 + 'a'; + } +} + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index abb1777e73..ba46ed73b3 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -546,26 +546,6 @@ static void put_buffer(const uint8_t *buf, int len) #endif } -static inline int fromhex(int v) -{ - if (v >= '0' && v <= '9') - return v - '0'; - else if (v >= 'A' && v <= 'F') - return v - 'A' + 10; - else if (v >= 'a' && v <= 'f') - return v - 'a' + 10; - else - return 0; -} - -static inline int tohex(int v) -{ - if (v < 10) - return v + '0'; - else - return v - 10 + 'a'; -} - /* writes 2*len+1 bytes in buf */ static void memtohex(GString *buf, const uint8_t *mem, int len) { From patchwork Fri Mar 3 02:57:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658448 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225236wrb; Thu, 2 Mar 2023 18:59:03 -0800 (PST) X-Google-Smtp-Source: AK7set/YJbLAhLfnIoPJnVbrV37XZ75xYqys5NbRnc3dFKDKl2azrayVHqSZo9TgIqCQrVCYy7Nd X-Received: by 2002:a05:6214:1cc8:b0:56e:fb4c:c1a5 with SMTP id g8-20020a0562141cc800b0056efb4cc1a5mr592006qvd.18.1677812343534; Thu, 02 Mar 2023 18:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812343; cv=none; d=google.com; s=arc-20160816; b=uQbcAAu4sqjcf8y3Shn+pYNkkKs2ldicl12xVm4zsviDFly3uEqmBiqzArUcL2eVdD of0wvzW/vt+qgptc4vP71JMBBIn9LZTdVP0+lxNHyy/1XU+34/302EBOyTdW/Y6e98dV fedXrKBCBwVU3aqKmL2LoEMPlETbQxyp1QaoRFJLKWu5e6Q9RCFQLzkuPLbbuCyFjQqi 3hNJYBvwJ/3mmBMTNjTHNH7ZiKp+9ijRxUNP4SH99uDh2srWhfHmDKkrMkldUKCKeJ0o WlEiRUAMjE24Ovrp27H7oUMuDzIZ3ngPJcz0Je7MrKtsTS7Shu9O1N+s3ckAZbBr6mkB XlXw== 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=lNe1YMP2dmWkf8DanyKvPtkKJTZWMU8+m3WZiOqSMdY=; b=pnEbC9f8+qRc6SSNtV8Ww5UIiemnmP/vPzA8kCiiHrDqqtJL2+5JP1RK36DasVDYG6 MQpZ/ugonVYxxsexVKWitZn0CMTpKOuXADSYmmJ4ag+PGsKyqGaA0GdRyvvC7SLlGDgE akUqAeP0mc0nfbYVBF0EeI2LyCPp4lsDwHLMjiWPZKlY39q6NOc6lis77USMAcrKCoAx dK11IGngP0bd5lwQxfcnDLl6znesFdProGIJd6UdJpGWiB+gmlY84iDJLGg4RR/OhLdE c+yi1+ZKHQ7lGyJncV90r70mpRrG4hcdkbItPeVvmQklrjxPBEHynRx7Jfx7zWm63S62 lRwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oG4ekm8K; 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 y19-20020a0cf153000000b0053426d91114si734459qvl.281.2023.03.02.18.59.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:59:03 -0800 (PST) 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=oG4ekm8K; 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 1pXvck-0007Td-CV; Thu, 02 Mar 2023 21:58:22 -0500 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 1pXvcj-0007Sn-7F for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcf-0001pC-2o for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:20 -0500 Received: by mail-pl1-x62b.google.com with SMTP id p20so1298654plw.13 for ; Thu, 02 Mar 2023 18:58:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812295; 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=lNe1YMP2dmWkf8DanyKvPtkKJTZWMU8+m3WZiOqSMdY=; b=oG4ekm8Kno02Kd2FEYFBM7xmhXH5GrZANFw0vFbzLC6v8aAf4MGOJeWUC0CESB3AtD 1J+aLrVN+kGVfuzgN2Pv9u+3UZzUhOBkT+HICSfr5sMCq4eh10nhtpjYganohcfYYyLc Yc9itX4H3Zawd7SZlGvpjePqgdD8vi/1/vUmaS80qZdO6PIZ/NwIDdwCYRbKj20b3dkQ VrNosRN4cRSkc4s/peewzx1Zbz994hcKhjtShbo69EXVMDoqm8cScIsiM2Dxyf29cFtZ AJJpJtp0d+YWSpF15nHWv06Fdpw+icX2z38xQ2ym+xiLmWyD8h2pCqlrk+4q8XWJpv5U Yk0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812295; 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=lNe1YMP2dmWkf8DanyKvPtkKJTZWMU8+m3WZiOqSMdY=; b=U6G0+qHyqjHPxqDLu0FfM+U0sFAjURT/1W8bbpuIMu17ocVrYlYSq0eUfERA7NaXXW by5ebNmksOeFdnwXEOskSuxqA0CnCrU5t2xU0zgGAnZSpGBZ/XvNBRFrS+gs9T73b9Pw 1Sy5rkdHY1ERITas4qBwjHyPTFreztjAV+EnRNMQRnlb/UEml5ysCxD7vfiVGaDwN7l4 o4CCBaZmQHvWpofNqGSb5Lo8PsadYh0+Je74D9ZfdBg8oymbvXxrF/yisvphBSyrysW/ ImZVaeb8AjJbjQppIuUQQYKezZynRe7ynJJMmFPUEz2vys653MCZuxFymQfyuw+py6vS 9CfA== X-Gm-Message-State: AO0yUKUGJAx9jFAMx2/S2+xkcuMYUzFdQs7iGKVJv92mhdaS9qIT7PLX 79dFHYKkMeLbf9qfWYYk3X3vBIb98Q7O3Sz1cpg= X-Received: by 2002:a17:902:d4cc:b0:19b:dbf7:f9ca with SMTP id o12-20020a170902d4cc00b0019bdbf7f9camr804850plg.0.1677812295291; Thu, 02 Mar 2023 18:58:15 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 09/29] gdbstub: make various helpers visible to the rest of the module Date: Thu, 2 Mar 2023 18:57:45 -0800 Message-Id: <20230303025805.625589-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 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: Alex Bennée We will be needing to use these helpers between the user and softmmu files so declare them in the headers, add a system prefix and remove static from the implementations. Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-10-alex.bennee@linaro.org> --- gdbstub/internals.h | 25 ++++ gdbstub/gdbstub.c | 276 ++++++++++++++++++++++---------------------- 2 files changed, 165 insertions(+), 136 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b4620f99c4..cf76627cf7 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -84,6 +84,31 @@ static inline int tohex(int v) } } +/* + * Connection helpers for both softmmu and user backends + */ + +void gdb_put_strbuf(void); +int gdb_put_packet(const char *buf); +int gdb_put_packet_binary(const char *buf, int len, bool dump); +void gdb_hextomem(GByteArray *mem, const char *buf, int len); +void gdb_memtohex(GString *buf, const uint8_t *mem, int len); +void gdb_memtox(GString *buf, const char *mem, int len); +void gdb_read_byte(uint8_t ch); + +/* utility helpers */ +CPUState *gdb_first_attached_cpu(void); +void gdb_append_thread_id(CPUState *cpu, GString *buf); +int gdb_get_cpu_index(CPUState *cpu); + +void gdb_init_gdbserver_state(void); +void gdb_create_default_process(GDBState *s); + +/* + * Helpers with separate softmmu and user implementations + */ +void gdb_put_buffer(const uint8_t *buf, int len); + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ba46ed73b3..f59ab12cc3 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -85,12 +85,13 @@ static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } -/* Return the GDB index for a given vCPU state. +/* + * Return the GDB index for a given vCPU state. * * For user mode this is simply the thread id. In system mode GDB * numbers CPUs from 1 as 0 is reserved as an "any cpu" index. */ -static inline int cpu_gdb_index(CPUState *cpu) +int gdb_get_cpu_index(CPUState *cpu) { #if defined(CONFIG_USER_ONLY) TaskState *ts = (TaskState *) cpu->opaque; @@ -342,7 +343,7 @@ static GDBSystemState gdbserver_system_state; static GDBState gdbserver_state; -static void init_gdbserver_state(void) +void gdb_init_gdbserver_state(void) { g_assert(!gdbserver_state.init); memset(&gdbserver_state, 0, sizeof(GDBState)); @@ -524,7 +525,7 @@ static int gdb_continue_partial(char *newstates) return res; } -static void put_buffer(const uint8_t *buf, int len) +void gdb_put_buffer(const uint8_t *buf, int len) { #ifdef CONFIG_USER_ONLY int ret; @@ -547,7 +548,7 @@ static void put_buffer(const uint8_t *buf, int len) } /* writes 2*len+1 bytes in buf */ -static void memtohex(GString *buf, const uint8_t *mem, int len) +void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { int i, c; for(i = 0; i < len; i++) { @@ -558,7 +559,7 @@ static void memtohex(GString *buf, const uint8_t *mem, int len) g_string_append_c(buf, '\0'); } -static void hextomem(GByteArray *mem, const char *buf, int len) +void gdb_hextomem(GByteArray *mem, const char *buf, int len) { int i; @@ -603,7 +604,7 @@ static void hexdump(const char *buf, int len, } /* return -1 if error, 0 if OK */ -static int put_packet_binary(const char *buf, int len, bool dump) +int gdb_put_packet_binary(const char *buf, int len, bool dump) { int csum, i; uint8_t footer[3]; @@ -627,7 +628,7 @@ static int put_packet_binary(const char *buf, int len, bool dump) footer[2] = tohex((csum) & 0xf); g_byte_array_append(gdbserver_state.last_packet, footer, 3); - put_buffer(gdbserver_state.last_packet->data, + gdb_put_buffer(gdbserver_state.last_packet->data, gdbserver_state.last_packet->len); #ifdef CONFIG_USER_ONLY @@ -644,20 +645,20 @@ static int put_packet_binary(const char *buf, int len, bool dump) } /* return -1 if error, 0 if OK */ -static int put_packet(const char *buf) +int gdb_put_packet(const char *buf) { trace_gdbstub_io_reply(buf); - return put_packet_binary(buf, strlen(buf), false); + return gdb_put_packet_binary(buf, strlen(buf), false); } -static void put_strbuf(void) +void gdb_put_strbuf(void) { - put_packet(gdbserver_state.str_buf->str); + gdb_put_packet(gdbserver_state.str_buf->str); } /* Encode data using the encoding for 'x' packets. */ -static void memtox(GString *buf, const char *mem, int len) +void gdb_memtox(GString *buf, const char *mem, int len) { char c; @@ -714,7 +715,7 @@ static CPUState *find_cpu(uint32_t thread_id) CPUState *cpu; CPU_FOREACH(cpu) { - if (cpu_gdb_index(cpu) == thread_id) { + if (gdb_get_cpu_index(cpu) == thread_id) { return cpu; } } @@ -768,7 +769,7 @@ static CPUState *gdb_next_attached_cpu(CPUState *cpu) } /* Return the first attached cpu */ -static CPUState *gdb_first_attached_cpu(void) +CPUState *gdb_first_attached_cpu(void) { CPUState *cpu = first_cpu; GDBProcess *process = gdb_get_cpu_process(cpu); @@ -982,13 +983,13 @@ static void gdb_set_cpu_pc(target_ulong pc) cpu_set_pc(cpu, pc); } -static void gdb_append_thread_id(CPUState *cpu, GString *buf) +void gdb_append_thread_id(CPUState *cpu, GString *buf) { if (gdbserver_state.multiprocess) { g_string_append_printf(buf, "p%02x.%02x", - gdb_get_cpu_pid(cpu), cpu_gdb_index(cpu)); + gdb_get_cpu_pid(cpu), gdb_get_cpu_index(cpu)); } else { - g_string_append_printf(buf, "%02x", cpu_gdb_index(cpu)); + g_string_append_printf(buf, "%02x", gdb_get_cpu_index(cpu)); } } @@ -1359,7 +1360,7 @@ static void run_cmd_parser(const char *data, const GdbCmdParseEntry *cmd) /* In case there was an error during the command parsing we must * send a NULL packet to indicate the command is not supported */ if (process_string_cmd(NULL, data, cmd, 1)) { - put_packet(""); + gdb_put_packet(""); } } @@ -1370,7 +1371,7 @@ static void handle_detach(GArray *params, void *user_ctx) if (gdbserver_state.multiprocess) { if (!params->len) { - put_packet("E22"); + gdb_put_packet("E22"); return; } @@ -1394,7 +1395,7 @@ static void handle_detach(GArray *params, void *user_ctx) gdb_syscall_mode = GDB_SYS_DISABLED; gdb_continue(); } - put_packet("OK"); + gdb_put_packet("OK"); } static void handle_thread_alive(GArray *params, void *user_ctx) @@ -1402,23 +1403,23 @@ static void handle_thread_alive(GArray *params, void *user_ctx) CPUState *cpu; if (!params->len) { - put_packet("E22"); + gdb_put_packet("E22"); return; } if (get_param(params, 0)->thread_id.kind == GDB_READ_THREAD_ERR) { - put_packet("E22"); + gdb_put_packet("E22"); return; } cpu = gdb_get_cpu(get_param(params, 0)->thread_id.pid, get_param(params, 0)->thread_id.tid); if (!cpu) { - put_packet("E22"); + gdb_put_packet("E22"); return; } - put_packet("OK"); + gdb_put_packet("OK"); } static void handle_continue(GArray *params, void *user_ctx) @@ -1455,24 +1456,24 @@ static void handle_set_thread(GArray *params, void *user_ctx) CPUState *cpu; if (params->len != 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } if (get_param(params, 1)->thread_id.kind == GDB_READ_THREAD_ERR) { - put_packet("E22"); + gdb_put_packet("E22"); return; } if (get_param(params, 1)->thread_id.kind != GDB_ONE_THREAD) { - put_packet("OK"); + gdb_put_packet("OK"); return; } cpu = gdb_get_cpu(get_param(params, 1)->thread_id.pid, get_param(params, 1)->thread_id.tid); if (!cpu) { - put_packet("E22"); + gdb_put_packet("E22"); return; } @@ -1483,14 +1484,14 @@ static void handle_set_thread(GArray *params, void *user_ctx) switch (get_param(params, 0)->opcode) { case 'c': gdbserver_state.c_cpu = cpu; - put_packet("OK"); + gdb_put_packet("OK"); break; case 'g': gdbserver_state.g_cpu = cpu; - put_packet("OK"); + gdb_put_packet("OK"); break; default: - put_packet("E22"); + gdb_put_packet("E22"); break; } } @@ -1500,7 +1501,7 @@ static void handle_insert_bp(GArray *params, void *user_ctx) int res; if (params->len != 3) { - put_packet("E22"); + gdb_put_packet("E22"); return; } @@ -1509,14 +1510,14 @@ static void handle_insert_bp(GArray *params, void *user_ctx) get_param(params, 1)->val_ull, get_param(params, 2)->val_ull); if (res >= 0) { - put_packet("OK"); + gdb_put_packet("OK"); return; } else if (res == -ENOSYS) { - put_packet(""); + gdb_put_packet(""); return; } - put_packet("E22"); + gdb_put_packet("E22"); } static void handle_remove_bp(GArray *params, void *user_ctx) @@ -1524,7 +1525,7 @@ static void handle_remove_bp(GArray *params, void *user_ctx) int res; if (params->len != 3) { - put_packet("E22"); + gdb_put_packet("E22"); return; } @@ -1533,14 +1534,14 @@ static void handle_remove_bp(GArray *params, void *user_ctx) get_param(params, 1)->val_ull, get_param(params, 2)->val_ull); if (res >= 0) { - put_packet("OK"); + gdb_put_packet("OK"); return; } else if (res == -ENOSYS) { - put_packet(""); + gdb_put_packet(""); return; } - put_packet("E22"); + gdb_put_packet("E22"); } /* @@ -1559,20 +1560,20 @@ static void handle_set_reg(GArray *params, void *user_ctx) int reg_size; if (!gdb_has_xml) { - put_packet(""); + gdb_put_packet(""); return; } if (params->len != 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } reg_size = strlen(get_param(params, 1)->data) / 2; - hextomem(gdbserver_state.mem_buf, get_param(params, 1)->data, reg_size); + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 1)->data, reg_size); gdb_write_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf->data, get_param(params, 0)->val_ull); - put_packet("OK"); + gdb_put_packet("OK"); } static void handle_get_reg(GArray *params, void *user_ctx) @@ -1580,12 +1581,12 @@ static void handle_get_reg(GArray *params, void *user_ctx) int reg_size; if (!gdb_has_xml) { - put_packet(""); + gdb_put_packet(""); return; } if (!params->len) { - put_packet("E14"); + gdb_put_packet("E14"); return; } @@ -1593,53 +1594,54 @@ static void handle_get_reg(GArray *params, void *user_ctx) gdbserver_state.mem_buf, get_param(params, 0)->val_ull); if (!reg_size) { - put_packet("E14"); + gdb_put_packet("E14"); return; } else { g_byte_array_set_size(gdbserver_state.mem_buf, reg_size); } - memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, reg_size); - put_strbuf(); + gdb_memtohex(gdbserver_state.str_buf, + gdbserver_state.mem_buf->data, reg_size); + gdb_put_strbuf(); } static void handle_write_mem(GArray *params, void *user_ctx) { if (params->len != 3) { - put_packet("E22"); + gdb_put_packet("E22"); return; } - /* hextomem() reads 2*len bytes */ + /* gdb_hextomem() reads 2*len bytes */ if (get_param(params, 1)->val_ull > strlen(get_param(params, 2)->data) / 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } - hextomem(gdbserver_state.mem_buf, get_param(params, 2)->data, + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 2)->data, get_param(params, 1)->val_ull); if (target_memory_rw_debug(gdbserver_state.g_cpu, get_param(params, 0)->val_ull, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len, true)) { - put_packet("E14"); + gdb_put_packet("E14"); return; } - put_packet("OK"); + gdb_put_packet("OK"); } static void handle_read_mem(GArray *params, void *user_ctx) { if (params->len != 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } - /* memtohex() doubles the required space */ + /* gdb_memtohex() doubles the required space */ if (get_param(params, 1)->val_ull > MAX_PACKET_LENGTH / 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } @@ -1650,13 +1652,13 @@ static void handle_read_mem(GArray *params, void *user_ctx) get_param(params, 0)->val_ull, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len, false)) { - put_packet("E14"); + gdb_put_packet("E14"); return; } - memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, + gdb_memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len); - put_strbuf(); + gdb_put_strbuf(); } static void handle_write_all_regs(GArray *params, void *user_ctx) @@ -1671,7 +1673,7 @@ static void handle_write_all_regs(GArray *params, void *user_ctx) cpu_synchronize_state(gdbserver_state.g_cpu); len = strlen(get_param(params, 0)->data) / 2; - hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); registers = gdbserver_state.mem_buf->data; for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0; addr++) { @@ -1679,7 +1681,7 @@ static void handle_write_all_regs(GArray *params, void *user_ctx) len -= reg_size; registers += reg_size; } - put_packet("OK"); + gdb_put_packet("OK"); } static void handle_read_all_regs(GArray *params, void *user_ctx) @@ -1696,8 +1698,8 @@ static void handle_read_all_regs(GArray *params, void *user_ctx) } g_assert(len == gdbserver_state.mem_buf->len); - memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, len); - put_strbuf(); + gdb_memtohex(gdbserver_state.str_buf, gdbserver_state.mem_buf->data, len); + gdb_put_strbuf(); } static void handle_file_io(GArray *params, void *user_ctx) @@ -1748,7 +1750,7 @@ static void handle_file_io(GArray *params, void *user_ctx) } if (params->len >= 3 && get_param(params, 2)->opcode == (uint8_t)'C') { - put_packet("T02"); + gdb_put_packet("T02"); return; } @@ -1768,7 +1770,7 @@ static void handle_step(GArray *params, void *user_ctx) static void handle_backward(GArray *params, void *user_ctx) { if (!stub_can_reverse()) { - put_packet("E22"); + gdb_put_packet("E22"); } if (params->len == 1) { switch (get_param(params, 0)->opcode) { @@ -1776,26 +1778,26 @@ static void handle_backward(GArray *params, void *user_ctx) if (replay_reverse_step()) { gdb_continue(); } else { - put_packet("E14"); + gdb_put_packet("E14"); } return; case 'c': if (replay_reverse_continue()) { gdb_continue(); } else { - put_packet("E14"); + gdb_put_packet("E14"); } return; } } /* Default invalid command */ - put_packet(""); + gdb_put_packet(""); } static void handle_v_cont_query(GArray *params, void *user_ctx) { - put_packet("vCont;c;C;s;S"); + gdb_put_packet("vCont;c;C;s;S"); } static void handle_v_cont(GArray *params, void *user_ctx) @@ -1808,9 +1810,9 @@ static void handle_v_cont(GArray *params, void *user_ctx) res = gdb_handle_vcont(get_param(params, 0)->data); if ((res == -EINVAL) || (res == -ERANGE)) { - put_packet("E22"); + gdb_put_packet("E22"); } else if (res) { - put_packet(""); + gdb_put_packet(""); } } @@ -1842,13 +1844,13 @@ static void handle_v_attach(GArray *params, void *user_ctx) gdb_append_thread_id(cpu, gdbserver_state.str_buf); g_string_append_c(gdbserver_state.str_buf, ';'); cleanup: - put_strbuf(); + gdb_put_strbuf(); } static void handle_v_kill(GArray *params, void *user_ctx) { /* Kill the target */ - put_packet("OK"); + gdb_put_packet("OK"); error_report("QEMU: Terminated via GDBstub"); gdb_exit(0); exit(0); @@ -1889,7 +1891,7 @@ static void handle_v_commands(GArray *params, void *user_ctx) if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_v_commands_table, ARRAY_SIZE(gdb_v_commands_table))) { - put_packet(""); + gdb_put_packet(""); } } @@ -1907,7 +1909,7 @@ static void handle_query_qemu_sstepbits(GArray *params, void *user_ctx) SSTEP_NOTIMER); } - put_strbuf(); + gdb_put_strbuf(); } static void handle_set_qemu_sstep(GArray *params, void *user_ctx) @@ -1921,19 +1923,19 @@ static void handle_set_qemu_sstep(GArray *params, void *user_ctx) new_sstep_flags = get_param(params, 0)->val_ul; if (new_sstep_flags & ~gdbserver_state.supported_sstep_flags) { - put_packet("E22"); + gdb_put_packet("E22"); return; } gdbserver_state.sstep_flags = new_sstep_flags; - put_packet("OK"); + gdb_put_packet("OK"); } static void handle_query_qemu_sstep(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "0x%x", gdbserver_state.sstep_flags); - put_strbuf(); + gdb_put_strbuf(); } static void handle_query_curr_tid(GArray *params, void *user_ctx) @@ -1950,19 +1952,19 @@ static void handle_query_curr_tid(GArray *params, void *user_ctx) cpu = get_first_cpu_in_process(process); g_string_assign(gdbserver_state.str_buf, "QC"); gdb_append_thread_id(cpu, gdbserver_state.str_buf); - put_strbuf(); + gdb_put_strbuf(); } static void handle_query_threads(GArray *params, void *user_ctx) { if (!gdbserver_state.query_cpu) { - put_packet("l"); + gdb_put_packet("l"); return; } g_string_assign(gdbserver_state.str_buf, "m"); gdb_append_thread_id(gdbserver_state.query_cpu, gdbserver_state.str_buf); - put_strbuf(); + gdb_put_strbuf(); gdbserver_state.query_cpu = gdb_next_attached_cpu(gdbserver_state.query_cpu); } @@ -1979,7 +1981,7 @@ static void handle_query_thread_extra(GArray *params, void *user_ctx) if (!params->len || get_param(params, 0)->thread_id.kind == GDB_READ_THREAD_ERR) { - put_packet("E22"); + gdb_put_packet("E22"); return; } @@ -2004,8 +2006,8 @@ static void handle_query_thread_extra(GArray *params, void *user_ctx) cpu->halted ? "halted " : "running"); } trace_gdbstub_op_extra_info(rs->str); - memtohex(gdbserver_state.str_buf, (uint8_t *)rs->str, rs->len); - put_strbuf(); + gdb_memtohex(gdbserver_state.str_buf, (uint8_t *)rs->str, rs->len); + gdb_put_strbuf(); } #ifdef CONFIG_USER_ONLY @@ -2021,7 +2023,7 @@ static void handle_query_offsets(GArray *params, void *user_ctx) ts->info->code_offset, ts->info->data_offset, ts->info->data_offset); - put_strbuf(); + gdb_put_strbuf(); } #else static void handle_query_rcmd(GArray *params, void *user_ctx) @@ -2030,24 +2032,24 @@ static void handle_query_rcmd(GArray *params, void *user_ctx) int len; if (!params->len) { - put_packet("E22"); + gdb_put_packet("E22"); return; } len = strlen(get_param(params, 0)->data); if (len % 2) { - put_packet("E01"); + gdb_put_packet("E01"); return; } g_assert(gdbserver_state.mem_buf->len == 0); len = len / 2; - hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); qemu_chr_be_write(gdbserver_system_state.mon_chr, gdbserver_state.mem_buf->data, gdbserver_state.mem_buf->len); - put_packet("OK"); + gdb_put_packet("OK"); } #endif @@ -2078,7 +2080,7 @@ static void handle_query_supported(GArray *params, void *user_ctx) } g_string_append(gdbserver_state.str_buf, ";vContSupported+;multiprocess+"); - put_strbuf(); + gdb_put_strbuf(); } static void handle_query_xfer_features(GArray *params, void *user_ctx) @@ -2090,14 +2092,14 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) const char *p; if (params->len < 3) { - put_packet("E22"); + gdb_put_packet("E22"); return; } process = gdb_get_cpu_process(gdbserver_state.g_cpu); cc = CPU_GET_CLASS(gdbserver_state.g_cpu); if (!cc->gdb_core_xml_file) { - put_packet(""); + gdb_put_packet(""); return; } @@ -2105,7 +2107,7 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) p = get_param(params, 0)->data; xml = get_feature_xml(p, &p, process); if (!xml) { - put_packet("E00"); + gdb_put_packet("E00"); return; } @@ -2113,7 +2115,7 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) len = get_param(params, 2)->val_ul; total_len = strlen(xml); if (addr > total_len) { - put_packet("E00"); + gdb_put_packet("E00"); return; } @@ -2123,13 +2125,13 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) if (len < total_len - addr) { g_string_assign(gdbserver_state.str_buf, "m"); - memtox(gdbserver_state.str_buf, xml + addr, len); + gdb_memtox(gdbserver_state.str_buf, xml + addr, len); } else { g_string_assign(gdbserver_state.str_buf, "l"); - memtox(gdbserver_state.str_buf, xml + addr, total_len - addr); + gdb_memtox(gdbserver_state.str_buf, xml + addr, total_len - addr); } - put_packet_binary(gdbserver_state.str_buf->str, + gdb_put_packet_binary(gdbserver_state.str_buf->str, gdbserver_state.str_buf->len, true); } @@ -2140,7 +2142,7 @@ static void handle_query_xfer_auxv(GArray *params, void *user_ctx) unsigned long offset, len, saved_auxv, auxv_len; if (params->len < 2) { - put_packet("E22"); + gdb_put_packet("E22"); return; } @@ -2151,7 +2153,7 @@ static void handle_query_xfer_auxv(GArray *params, void *user_ctx) auxv_len = ts->info->auxv_len; if (offset >= auxv_len) { - put_packet("E00"); + gdb_put_packet("E00"); return; } @@ -2169,20 +2171,20 @@ static void handle_query_xfer_auxv(GArray *params, void *user_ctx) g_byte_array_set_size(gdbserver_state.mem_buf, len); if (target_memory_rw_debug(gdbserver_state.g_cpu, saved_auxv + offset, gdbserver_state.mem_buf->data, len, false)) { - put_packet("E14"); + gdb_put_packet("E14"); return; } - memtox(gdbserver_state.str_buf, - (const char *)gdbserver_state.mem_buf->data, len); - put_packet_binary(gdbserver_state.str_buf->str, - gdbserver_state.str_buf->len, true); + gdb_memtox(gdbserver_state.str_buf, + (const char *)gdbserver_state.mem_buf->data, len); + gdb_put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); } #endif static void handle_query_attached(GArray *params, void *user_ctx) { - put_packet(GDB_ATTACHED); + gdb_put_packet(GDB_ATTACHED); } static void handle_query_qemu_supported(GArray *params, void *user_ctx) @@ -2191,7 +2193,7 @@ static void handle_query_qemu_supported(GArray *params, void *user_ctx) #ifndef CONFIG_USER_ONLY g_string_append(gdbserver_state.str_buf, ";PhyMemMode"); #endif - put_strbuf(); + gdb_put_strbuf(); } #ifndef CONFIG_USER_ONLY @@ -2199,13 +2201,13 @@ static void handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); - put_strbuf(); + gdb_put_strbuf(); } static void handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) { if (!params->len) { - put_packet("E22"); + gdb_put_packet("E22"); return; } @@ -2214,7 +2216,7 @@ static void handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) } else { phy_memory_mode = 1; } - put_packet("OK"); + gdb_put_packet("OK"); } #endif @@ -2347,7 +2349,7 @@ static void handle_gen_query(GArray *params, void *user_ctx) if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_query_table, ARRAY_SIZE(gdb_gen_query_table))) { - put_packet(""); + gdb_put_packet(""); } } @@ -2366,7 +2368,7 @@ static void handle_gen_set(GArray *params, void *user_ctx) if (process_string_cmd(NULL, get_param(params, 0)->data, gdb_gen_set_table, ARRAY_SIZE(gdb_gen_set_table))) { - put_packet(""); + gdb_put_packet(""); } } @@ -2375,7 +2377,7 @@ static void handle_target_halt(GArray *params, void *user_ctx) g_string_printf(gdbserver_state.str_buf, "T%02xthread:", GDB_SIGNAL_TRAP); gdb_append_thread_id(gdbserver_state.c_cpu, gdbserver_state.str_buf); g_string_append_c(gdbserver_state.str_buf, ';'); - put_strbuf(); + gdb_put_strbuf(); /* * Remove all the breakpoints when this query is issued, * because gdb is doing an initial connect and the state @@ -2392,7 +2394,7 @@ static int gdb_handle_packet(const char *line_buf) switch (line_buf[0]) { case '!': - put_packet("OK"); + gdb_put_packet("OK"); break; case '?': { @@ -2619,7 +2621,7 @@ static int gdb_handle_packet(const char *line_buf) break; default: /* put empty packet */ - put_packet(""); + gdb_put_packet(""); break; } @@ -2660,7 +2662,7 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) } /* Is there a GDB syscall waiting to be sent? */ if (gdbserver_state.current_syscall_cb) { - put_packet(gdbserver_state.syscall_buf); + gdb_put_packet(gdbserver_state.syscall_buf); return; } @@ -2685,7 +2687,7 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) type = ""; break; } - trace_gdbstub_hit_watchpoint(type, cpu_gdb_index(cpu), + trace_gdbstub_hit_watchpoint(type, gdb_get_cpu_index(cpu), (target_ulong)cpu->watchpoint_hit->vaddr); g_string_printf(buf, "T%02xthread:%s;%swatch:" TARGET_FMT_lx ";", GDB_SIGNAL_TRAP, tid->str, type, @@ -2733,7 +2735,7 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) g_string_printf(buf, "T%02xthread:%s;", ret, tid->str); send_packet: - put_packet(buf->str); + gdb_put_packet(buf->str); /* disable single step if it was enabled */ cpu_single_step(cpu, 0); @@ -2794,7 +2796,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) } *p = 0; #ifdef CONFIG_USER_ONLY - put_packet(gdbserver_state.syscall_buf); + gdb_put_packet(gdbserver_state.syscall_buf); /* Return control to gdb for it to process the syscall request. * Since the protocol requires that gdb hands control back to us * using a "here are the results" F packet, we don't need to check @@ -2822,7 +2824,7 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) va_end(va); } -static void gdb_read_byte(uint8_t ch) +void gdb_read_byte(uint8_t ch) { uint8_t reply; @@ -2832,7 +2834,7 @@ static void gdb_read_byte(uint8_t ch) of a new command then abandon the previous response. */ if (ch == '-') { trace_gdbstub_err_got_nack(); - put_buffer(gdbserver_state.last_packet->data, + gdb_put_buffer(gdbserver_state.last_packet->data, gdbserver_state.last_packet->len); } else if (ch == '+') { trace_gdbstub_io_got_ack(); @@ -2954,12 +2956,12 @@ static void gdb_read_byte(uint8_t ch) trace_gdbstub_err_checksum_incorrect(gdbserver_state.line_sum, gdbserver_state.line_csum); /* send NAK reply */ reply = '-'; - put_buffer(&reply, 1); + gdb_put_buffer(&reply, 1); gdbserver_state.state = RS_IDLE; } else { /* send ACK reply */ reply = '+'; - put_buffer(&reply, 1); + gdb_put_buffer(&reply, 1); gdbserver_state.state = gdb_handle_packet(gdbserver_state.line_buf); } break; @@ -2989,7 +2991,7 @@ void gdb_exit(int code) trace_gdbstub_op_exiting((uint8_t)code); snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - put_packet(buf); + gdb_put_packet(buf); #ifndef CONFIG_USER_ONLY qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); @@ -3001,7 +3003,7 @@ void gdb_exit(int code) * part of a CPU cluster). Note that if this process contains no CPUs, it won't * be attachable and thus will be invisible to the user. */ -static void create_default_process(GDBState *s) +void gdb_create_default_process(GDBState *s) { GDBProcess *process; int max_pid = 0; @@ -3042,10 +3044,12 @@ gdb_handlesig(CPUState *cpu, int sig) "T%02xthread:", target_signal_to_gdb(sig)); gdb_append_thread_id(cpu, gdbserver_state.str_buf); g_string_append_c(gdbserver_state.str_buf, ';'); - put_strbuf(); + gdb_put_strbuf(); } - /* put_packet() might have detected that the peer terminated the - connection. */ + /* + * gdb_put_packet() might have detected that the peer terminated the + * connection. + */ if (gdbserver_user_state.fd < 0) { return sig; } @@ -3086,13 +3090,13 @@ void gdb_signalled(CPUArchState *env, int sig) } snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); - put_packet(buf); + gdb_put_packet(buf); } static void gdb_accept_init(int fd) { - init_gdbserver_state(); - create_default_process(&gdbserver_state); + gdb_init_gdbserver_state(); + gdb_create_default_process(&gdbserver_state); gdbserver_state.processes[0].attached = true; gdbserver_state.c_cpu = gdb_first_attached_cpu(); gdbserver_state.g_cpu = gdbserver_state.c_cpu; @@ -3292,8 +3296,8 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event) static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) { g_autoptr(GString) hex_buf = g_string_new("O"); - memtohex(hex_buf, buf, len); - put_packet(hex_buf->str); + gdb_memtohex(hex_buf, buf, len); + gdb_put_packet(hex_buf->str); return len; } @@ -3379,7 +3383,7 @@ static void create_processes(GDBState *s) qsort(gdbserver_state.processes, gdbserver_state.process_num, sizeof(gdbserver_state.processes[0]), pid_order); } - create_default_process(s); + gdb_create_default_process(s); } int gdbserver_start(const char *device) @@ -3429,7 +3433,7 @@ int gdbserver_start(const char *device) } if (!gdbserver_state.init) { - init_gdbserver_state(); + gdb_init_gdbserver_state(); qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); From patchwork Fri Mar 3 02:57:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658454 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225807wrb; Thu, 2 Mar 2023 19:00:31 -0800 (PST) X-Google-Smtp-Source: AK7set9N3rt8yjSONC5Vk0uaCwMmgSZQmMEzP+rZOmpWS/VIMewHv0ITTS0oUnkBlemY5ICyx5a2 X-Received: by 2002:a05:6214:5003:b0:577:6271:a05d with SMTP id jo3-20020a056214500300b005776271a05dmr191772qvb.3.1677812431370; Thu, 02 Mar 2023 19:00:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812431; cv=none; d=google.com; s=arc-20160816; b=GLgfDWGQenChR98sM75GhKjOdu3rxQadmXz5NBM8g3eQQBsrBPqADNKeMJFFRO4Fq/ tgHX7ZG8bnGC1q+rWBUDS3bvMwiiI5OQiUvUb8Es9iYRLfHlEDJgBNZKl3WKr2lfilbs KFewZa7iOzRDl6xacy2oaZ8IiBwRXyud4ZptTHlnF4di4MxdS65FacIXxmt67HWdnVXt h5HfSqqCiNc+yS/9RAdU0J/Ahl0XK8wZmaW/WQQmF/pwkH2prxq+w9JiTDHdpBQFmf5I BucpnDWhQUBRCY8HH5+K0+jqn0v4P3Lf777VLZ+74q9yDRfQVzrIK0MBjfWum5HWI/Uc dYKQ== 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=Dr5ZJ6RSvGIveGs5vu2KHNRRPm2g/6dLEOqHDvmuzV8=; b=s/PNTKN2pvAXdDvV/qmzPmlYiuYgfbHmNv2KxPvZRnS/9TbKNlPKcfGflf8fhTfQvQ nDqxfal7BW4Emfgepf2hPGuO82bBSHRFAnrFMKDWfWb+ESisDWW/HplBUNucTYp28i+B Yw6eug8TV9DdBWy+CAvqv4+PJNK7ow+xIDwpRXIFB+CjW2z6m7JXuhXs17WmcsbhVLE1 vCiFOhN9t6VIMQec7ZQ7faqdZtv7QsOMPUHqW0B1rn0qXv3kmvsbtsZdB4qtCELTX0jh RqkSBsDGoyqJyPUvZdJFvuWbvy4yLW4qSGbeVeq+F+jQyqFwPs7MSV6lgK2FudLR1MQm FWcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ShwwhJUs; 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 v16-20020a0cdd90000000b005703b7b6b94si678368qvk.438.2023.03.02.19.00.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:31 -0800 (PST) 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=ShwwhJUs; 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 1pXvcl-0007UM-Al; Thu, 02 Mar 2023 21:58:23 -0500 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 1pXvcj-0007St-AW for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcf-0001pQ-Pi for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: by mail-pl1-x644.google.com with SMTP id p6so1415418plf.0 for ; Thu, 02 Mar 2023 18:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812296; 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=Dr5ZJ6RSvGIveGs5vu2KHNRRPm2g/6dLEOqHDvmuzV8=; b=ShwwhJUsNmfpTE2RP634dXN3y7m4S9uHyD5HGSywLW/qOgmtXrmpwG7XfriWEqrW/J i97jC7D+jsodkcIUwb1xyA9qRrv+i9WeF/JrWzcFB/OgH5rG5upzTI1hkwgj81JIsSZj Qa3SEg6d3fnn+/E2lXe9iWa7iXlwvP6u0fjPt1jDVUP7gzAwwKQl1QKVFnCCJYkUIxg7 tYB/VuJ7/EmOsYrU3/1y7NxEjh1Bq5jjjeMa5Ydzk8neLVwdVg6CUHACtR+FwSTFsyHs k8JwT6bsBthysICvy3GhwklaRt/4wHYelQWxCWx/ZAKJObgB325CRvMhYhUCTxOc6Wck 01zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812296; 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=Dr5ZJ6RSvGIveGs5vu2KHNRRPm2g/6dLEOqHDvmuzV8=; b=RYnwt28kHYOKOxXZRTn5bTTxg++xZcX+pndlRW/lPB2pKH6s4yM0QFRaycYqfHsBJg 0xjoeTxTThvL0wSmA/2Yb3Tpqm3cn3xC/KqguiJi5bBLiHdPMpbTeFnNkSbohr3+tQs+ EN9tHkgI+IPWCIfG/lO7zzxOvuSMbqHEHk9vEmvuS33g9VYrGm+MztOXNnN3xwsIrF+z eUjJKiIs1W1AuWn4gfFIB/QnfuQAqdYVMPvTXhE1QRAA181yKvGMw8JCi980fMRyCCeJ p5MBxNkT5y3xrV5GiCPL9E9AU2cc3+0wwJi+T06zBWmy15tSa+xuEBS1N4pt3EmHO8WL I18Q== X-Gm-Message-State: AO0yUKWVpqguNDAHcug9DZBH2LrPQ+4nak164cat5rZULjnmcqENAfBV DO/tLgYTsWFfIUKWv67Uf/QM2nW5r2+kv0DSVScFkA== X-Received: by 2002:a17:902:ec88:b0:19a:e762:a1af with SMTP id x8-20020a170902ec8800b0019ae762a1afmr3993421plg.33.1677812296125; Thu, 02 Mar 2023 18:58:16 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Fabiano Rosas Subject: [PATCH v4.5 10/29] gdbstub: move chunk of softmmu functionality to own file Date: Thu, 2 Mar 2023 18:57:46 -0800 Message-Id: <20230303025805.625589-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x644.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 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: Alex Bennée This is mostly code motion but a number of things needed to be done for this minimal patch set: - move shared structures to internals.h - splitting some functions into user and softmmu versions - fixing a few casting issues to keep softmmu common More CONFIG_USER_ONLY stuff will be handled in a following patches. Reviewed-by: Richard Henderson Reviewed-by: Fabiano Rosas Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-11-alex.bennee@linaro.org> --- gdbstub/internals.h | 43 ++++- gdbstub/gdbstub.c | 421 +----------------------------------------- gdbstub/softmmu.c | 423 +++++++++++++++++++++++++++++++++++++++++++ gdbstub/trace-events | 4 +- 4 files changed, 478 insertions(+), 413 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index cf76627cf7..83989af859 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -17,6 +17,18 @@ * Shared structures and definitions */ +enum { + GDB_SIGNAL_0 = 0, + GDB_SIGNAL_INT = 2, + GDB_SIGNAL_QUIT = 3, + GDB_SIGNAL_TRAP = 5, + GDB_SIGNAL_ABRT = 6, + GDB_SIGNAL_ALRM = 14, + GDB_SIGNAL_IO = 23, + GDB_SIGNAL_XCPU = 24, + GDB_SIGNAL_UNKNOWN = 143 +}; + typedef struct GDBProcess { uint32_t pid; bool attached; @@ -57,6 +69,8 @@ typedef struct GDBState { int supported_sstep_flags; } GDBState; +/* lives in main gdbstub.c */ +extern GDBState gdbserver_state; /* * Inline utility function, convert from int to hex and back @@ -101,7 +115,6 @@ CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); int gdb_get_cpu_index(CPUState *cpu); -void gdb_init_gdbserver_state(void); void gdb_create_default_process(GDBState *s); /* @@ -109,6 +122,34 @@ void gdb_create_default_process(GDBState *s); */ void gdb_put_buffer(const uint8_t *buf, int len); +/* + * Command handlers - either softmmu or user only + */ +void gdb_init_gdbserver_state(void); + +typedef enum GDBThreadIdKind { + GDB_ONE_THREAD = 0, + GDB_ALL_THREADS, /* One process, all threads */ + GDB_ALL_PROCESSES, + GDB_READ_THREAD_ERR +} GDBThreadIdKind; + +typedef union GdbCmdVariant { + const char *data; + uint8_t opcode; + unsigned long val_ul; + unsigned long long val_ull; + struct { + GDBThreadIdKind kind; + uint32_t pid; + uint32_t tid; + } thread_id; +} GdbCmdVariant; + +#define get_param(p, i) (&g_array_index(p, GdbCmdVariant, i)) + +void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */ + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index f59ab12cc3..4b939c689c 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -24,8 +24,6 @@ */ #include "qemu/osdep.h" -#include "qapi/error.h" -#include "qemu/error-report.h" #include "qemu/ctype.h" #include "qemu/cutils.h" #include "qemu/module.h" @@ -34,9 +32,6 @@ #ifdef CONFIG_USER_ONLY #include "qemu.h" #else -#include "monitor/monitor.h" -#include "chardev/char.h" -#include "chardev/char-fe.h" #include "hw/cpu/cluster.h" #include "hw/boards.h" #endif @@ -88,30 +83,15 @@ static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, /* * Return the GDB index for a given vCPU state. * - * For user mode this is simply the thread id. In system mode GDB - * numbers CPUs from 1 as 0 is reserved as an "any cpu" index. + * For user mode this is simply the thread id. */ +#if defined(CONFIG_USER_ONLY) int gdb_get_cpu_index(CPUState *cpu) { -#if defined(CONFIG_USER_ONLY) TaskState *ts = (TaskState *) cpu->opaque; return ts ? ts->ts_tid : -1; -#else - return cpu->cpu_index + 1; -#endif } - -enum { - GDB_SIGNAL_0 = 0, - GDB_SIGNAL_INT = 2, - GDB_SIGNAL_QUIT = 3, - GDB_SIGNAL_TRAP = 5, - GDB_SIGNAL_ABRT = 6, - GDB_SIGNAL_ALRM = 14, - GDB_SIGNAL_IO = 23, - GDB_SIGNAL_XCPU = 24, - GDB_SIGNAL_UNKNOWN = 143 -}; +#endif #ifdef CONFIG_USER_ONLY @@ -333,15 +313,9 @@ typedef struct { int running_state; } GDBUserState; static GDBUserState gdbserver_user_state; -#else -typedef struct { - CharBackend chr; - Chardev *mon_chr; -} GDBSystemState; -static GDBSystemState gdbserver_system_state; #endif -static GDBState gdbserver_state; +GDBState gdbserver_state; void gdb_init_gdbserver_state(void) { @@ -362,15 +336,6 @@ void gdb_init_gdbserver_state(void) gdbserver_state.sstep_flags &= gdbserver_state.supported_sstep_flags; } -#ifndef CONFIG_USER_ONLY -static void reset_gdbserver_state(void) -{ - g_free(gdbserver_state.processes); - gdbserver_state.processes = NULL; - gdbserver_state.process_num = 0; -} -#endif - bool gdb_has_xml; #ifdef CONFIG_USER_ONLY @@ -446,7 +411,7 @@ static bool stub_can_reverse(void) } /* Resume execution. */ -static inline void gdb_continue(void) +static void gdb_continue(void) { #ifdef CONFIG_USER_ONLY @@ -525,9 +490,9 @@ static int gdb_continue_partial(char *newstates) return res; } +#ifdef CONFIG_USER_ONLY void gdb_put_buffer(const uint8_t *buf, int len) { -#ifdef CONFIG_USER_ONLY int ret; while (len > 0) { @@ -540,12 +505,8 @@ void gdb_put_buffer(const uint8_t *buf, int len) len -= ret; } } -#else - /* XXX this blocks entire thread. Rewrite to use - * qemu_chr_fe_write and background I/O callbacks */ - qemu_chr_fe_write_all(&gdbserver_system_state.chr, buf, len); -#endif } +#endif /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) @@ -993,13 +954,6 @@ void gdb_append_thread_id(CPUState *cpu, GString *buf) } } -typedef enum GDBThreadIdKind { - GDB_ONE_THREAD = 0, - GDB_ALL_THREADS, /* One process, all threads */ - GDB_ALL_PROCESSES, - GDB_READ_THREAD_ERR -} GDBThreadIdKind; - static GDBThreadIdKind read_thread_id(const char *buf, const char **end_buf, uint32_t *pid, uint32_t *tid) { @@ -1180,20 +1134,6 @@ out: return res; } -typedef union GdbCmdVariant { - const char *data; - uint8_t opcode; - unsigned long val_ul; - unsigned long long val_ull; - struct { - GDBThreadIdKind kind; - uint32_t pid; - uint32_t tid; - } thread_id; -} GdbCmdVariant; - -#define get_param(p, i) (&g_array_index(p, GdbCmdVariant, i)) - static const char *cmd_next_param(const char *param, const char delimiter) { static const char all_delimiters[] = ",;:="; @@ -2025,32 +1965,6 @@ static void handle_query_offsets(GArray *params, void *user_ctx) ts->info->data_offset); gdb_put_strbuf(); } -#else -static void handle_query_rcmd(GArray *params, void *user_ctx) -{ - const guint8 zero = 0; - int len; - - if (!params->len) { - gdb_put_packet("E22"); - return; - } - - len = strlen(get_param(params, 0)->data); - if (len % 2) { - gdb_put_packet("E01"); - return; - } - - g_assert(gdbserver_state.mem_buf->len == 0); - len = len / 2; - gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); - g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); - qemu_chr_be_write(gdbserver_system_state.mon_chr, - gdbserver_state.mem_buf->data, - gdbserver_state.mem_buf->len); - gdb_put_packet("OK"); -} #endif static void handle_query_supported(GArray *params, void *user_ctx) @@ -2264,7 +2178,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { }, #else { - .handler = handle_query_rcmd, + .handler = gdb_handle_query_rcmd, .cmd = "Rcmd,", .cmd_startswith = 1, .schema = "s0" @@ -2648,100 +2562,6 @@ void gdb_set_stop_cpu(CPUState *cpu) gdbserver_state.g_cpu = cpu; } -#ifndef CONFIG_USER_ONLY -static void gdb_vm_state_change(void *opaque, bool running, RunState state) -{ - CPUState *cpu = gdbserver_state.c_cpu; - g_autoptr(GString) buf = g_string_new(NULL); - g_autoptr(GString) tid = g_string_new(NULL); - const char *type; - int ret; - - if (running || gdbserver_state.state == RS_INACTIVE) { - return; - } - /* Is there a GDB syscall waiting to be sent? */ - if (gdbserver_state.current_syscall_cb) { - gdb_put_packet(gdbserver_state.syscall_buf); - return; - } - - if (cpu == NULL) { - /* No process attached */ - return; - } - - gdb_append_thread_id(cpu, tid); - - switch (state) { - case RUN_STATE_DEBUG: - if (cpu->watchpoint_hit) { - switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { - case BP_MEM_READ: - type = "r"; - break; - case BP_MEM_ACCESS: - type = "a"; - break; - default: - type = ""; - break; - } - trace_gdbstub_hit_watchpoint(type, gdb_get_cpu_index(cpu), - (target_ulong)cpu->watchpoint_hit->vaddr); - g_string_printf(buf, "T%02xthread:%s;%swatch:" TARGET_FMT_lx ";", - GDB_SIGNAL_TRAP, tid->str, type, - (target_ulong)cpu->watchpoint_hit->vaddr); - cpu->watchpoint_hit = NULL; - goto send_packet; - } else { - trace_gdbstub_hit_break(); - } - tb_flush(cpu); - ret = GDB_SIGNAL_TRAP; - break; - case RUN_STATE_PAUSED: - trace_gdbstub_hit_paused(); - ret = GDB_SIGNAL_INT; - break; - case RUN_STATE_SHUTDOWN: - trace_gdbstub_hit_shutdown(); - ret = GDB_SIGNAL_QUIT; - break; - case RUN_STATE_IO_ERROR: - trace_gdbstub_hit_io_error(); - ret = GDB_SIGNAL_IO; - break; - case RUN_STATE_WATCHDOG: - trace_gdbstub_hit_watchdog(); - ret = GDB_SIGNAL_ALRM; - break; - case RUN_STATE_INTERNAL_ERROR: - trace_gdbstub_hit_internal_error(); - ret = GDB_SIGNAL_ABRT; - break; - case RUN_STATE_SAVE_VM: - case RUN_STATE_RESTORE_VM: - return; - case RUN_STATE_FINISH_MIGRATE: - ret = GDB_SIGNAL_XCPU; - break; - default: - trace_gdbstub_hit_unknown(state); - ret = GDB_SIGNAL_UNKNOWN; - break; - } - gdb_set_stop_cpu(cpu); - g_string_printf(buf, "T%02xthread:%s;", ret, tid->str); - -send_packet: - gdb_put_packet(buf->str); - - /* disable single step if it was enabled */ - cpu_single_step(cpu, 0); -} -#endif - /* Send a gdb syscall request. This accepts limited printf-style format specifiers, specifically: %x - target_ulong argument printed in hex. @@ -2971,6 +2791,7 @@ void gdb_read_byte(uint8_t ch) } } +#ifdef CONFIG_USER_ONLY /* Tell the remote gdb that the process has exited. */ void gdb_exit(int code) { @@ -2979,24 +2800,19 @@ void gdb_exit(int code) if (!gdbserver_state.init) { return; } -#ifdef CONFIG_USER_ONLY if (gdbserver_user_state.socket_path) { unlink(gdbserver_user_state.socket_path); } if (gdbserver_user_state.fd < 0) { return; } -#endif trace_gdbstub_op_exiting((uint8_t)code); snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); gdb_put_packet(buf); - -#ifndef CONFIG_USER_ONLY - qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); -#endif } +#endif /* * Create the process that will contain all the "orphan" CPUs (that are not @@ -3252,221 +3068,4 @@ void gdbserver_fork(CPUState *cpu) cpu_breakpoint_remove_all(cpu, BP_GDB); cpu_watchpoint_remove_all(cpu, BP_GDB); } -#else -static int gdb_chr_can_receive(void *opaque) -{ - /* We can handle an arbitrarily large amount of data. - Pick the maximum packet size, which is as good as anything. */ - return MAX_PACKET_LENGTH; -} - -static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) -{ - int i; - - for (i = 0; i < size; i++) { - gdb_read_byte(buf[i]); - } -} - -static void gdb_chr_event(void *opaque, QEMUChrEvent event) -{ - int i; - GDBState *s = (GDBState *) opaque; - - switch (event) { - case CHR_EVENT_OPENED: - /* Start with first process attached, others detached */ - for (i = 0; i < s->process_num; i++) { - s->processes[i].attached = !i; - } - - s->c_cpu = gdb_first_attached_cpu(); - s->g_cpu = s->c_cpu; - - vm_stop(RUN_STATE_PAUSED); - replay_gdb_attached(); - gdb_has_xml = false; - break; - default: - break; - } -} - -static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) -{ - g_autoptr(GString) hex_buf = g_string_new("O"); - gdb_memtohex(hex_buf, buf, len); - gdb_put_packet(hex_buf->str); - return len; -} - -#ifndef _WIN32 -static void gdb_sigterm_handler(int signal) -{ - if (runstate_is_running()) { - vm_stop(RUN_STATE_PAUSED); - } -} -#endif - -static void gdb_monitor_open(Chardev *chr, ChardevBackend *backend, - bool *be_opened, Error **errp) -{ - *be_opened = false; -} - -static void char_gdb_class_init(ObjectClass *oc, void *data) -{ - ChardevClass *cc = CHARDEV_CLASS(oc); - - cc->internal = true; - cc->open = gdb_monitor_open; - cc->chr_write = gdb_monitor_write; -} - -#define TYPE_CHARDEV_GDB "chardev-gdb" - -static const TypeInfo char_gdb_type_info = { - .name = TYPE_CHARDEV_GDB, - .parent = TYPE_CHARDEV, - .class_init = char_gdb_class_init, -}; - -static int find_cpu_clusters(Object *child, void *opaque) -{ - if (object_dynamic_cast(child, TYPE_CPU_CLUSTER)) { - GDBState *s = (GDBState *) opaque; - CPUClusterState *cluster = CPU_CLUSTER(child); - GDBProcess *process; - - s->processes = g_renew(GDBProcess, s->processes, ++s->process_num); - - process = &s->processes[s->process_num - 1]; - - /* - * GDB process IDs -1 and 0 are reserved. To avoid subtle errors at - * runtime, we enforce here that the machine does not use a cluster ID - * that would lead to PID 0. - */ - assert(cluster->cluster_id != UINT32_MAX); - process->pid = cluster->cluster_id + 1; - process->attached = false; - process->target_xml[0] = '\0'; - - return 0; - } - - return object_child_foreach(child, find_cpu_clusters, opaque); -} - -static int pid_order(const void *a, const void *b) -{ - GDBProcess *pa = (GDBProcess *) a; - GDBProcess *pb = (GDBProcess *) b; - - if (pa->pid < pb->pid) { - return -1; - } else if (pa->pid > pb->pid) { - return 1; - } else { - return 0; - } -} - -static void create_processes(GDBState *s) -{ - object_child_foreach(object_get_root(), find_cpu_clusters, s); - - if (gdbserver_state.processes) { - /* Sort by PID */ - qsort(gdbserver_state.processes, gdbserver_state.process_num, sizeof(gdbserver_state.processes[0]), pid_order); - } - - gdb_create_default_process(s); -} - -int gdbserver_start(const char *device) -{ - trace_gdbstub_op_start(device); - - char gdbstub_device_name[128]; - Chardev *chr = NULL; - Chardev *mon_chr; - - if (!first_cpu) { - error_report("gdbstub: meaningless to attach gdb to a " - "machine without any CPU."); - return -1; - } - - if (!gdb_supports_guest_debug()) { - error_report("gdbstub: current accelerator doesn't support guest debugging"); - return -1; - } - - if (!device) - return -1; - if (strcmp(device, "none") != 0) { - if (strstart(device, "tcp:", NULL)) { - /* enforce required TCP attributes */ - snprintf(gdbstub_device_name, sizeof(gdbstub_device_name), - "%s,wait=off,nodelay=on,server=on", device); - device = gdbstub_device_name; - } -#ifndef _WIN32 - else if (strcmp(device, "stdio") == 0) { - struct sigaction act; - - memset(&act, 0, sizeof(act)); - act.sa_handler = gdb_sigterm_handler; - sigaction(SIGINT, &act, NULL); - } -#endif - /* - * FIXME: it's a bit weird to allow using a mux chardev here - * and implicitly setup a monitor. We may want to break this. - */ - chr = qemu_chr_new_noreplay("gdb", device, true, NULL); - if (!chr) - return -1; - } - - if (!gdbserver_state.init) { - gdb_init_gdbserver_state(); - - qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); - - /* Initialize a monitor terminal for gdb */ - mon_chr = qemu_chardev_new(NULL, TYPE_CHARDEV_GDB, - NULL, NULL, &error_abort); - monitor_init_hmp(mon_chr, false, &error_abort); - } else { - qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); - mon_chr = gdbserver_system_state.mon_chr; - reset_gdbserver_state(); - } - - create_processes(&gdbserver_state); - - if (chr) { - qemu_chr_fe_init(&gdbserver_system_state.chr, chr, &error_abort); - qemu_chr_fe_set_handlers(&gdbserver_system_state.chr, - gdb_chr_can_receive, - gdb_chr_receive, gdb_chr_event, - NULL, &gdbserver_state, NULL, true); - } - gdbserver_state.state = chr ? RS_IDLE : RS_INACTIVE; - gdbserver_system_state.mon_chr = mon_chr; - gdbserver_state.current_syscall_cb = NULL; - - return 0; -} - -static void register_types(void) -{ - type_register_static(&char_gdb_type_info); -} - -type_init(register_types); #endif diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 05db6f8a9f..86a94f1519 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -11,10 +11,433 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/cutils.h" #include "exec/gdbstub.h" +#include "exec/hwaddr.h" +#include "exec/tb-flush.h" #include "sysemu/cpus.h" +#include "sysemu/runstate.h" +#include "sysemu/replay.h" +#include "hw/core/cpu.h" +#include "hw/cpu/cluster.h" +#include "hw/boards.h" +#include "chardev/char.h" +#include "chardev/char-fe.h" +#include "monitor/monitor.h" +#include "trace.h" #include "internals.h" +/* System emulation specific state */ +typedef struct { + CharBackend chr; + Chardev *mon_chr; +} GDBSystemState; + +GDBSystemState gdbserver_system_state; + +static void reset_gdbserver_state(void) +{ + g_free(gdbserver_state.processes); + gdbserver_state.processes = NULL; + gdbserver_state.process_num = 0; +} + +/* + * Return the GDB index for a given vCPU state. + * + * In system mode GDB numbers CPUs from 1 as 0 is reserved as an "any + * cpu" index. + */ +int gdb_get_cpu_index(CPUState *cpu) +{ + return cpu->cpu_index + 1; +} + +/* + * GDB Connection management. For system emulation we do all of this + * via our existing Chardev infrastructure which allows us to support + * network and unix sockets. + */ + +void gdb_put_buffer(const uint8_t *buf, int len) +{ + /* + * XXX this blocks entire thread. Rewrite to use + * qemu_chr_fe_write and background I/O callbacks + */ + qemu_chr_fe_write_all(&gdbserver_system_state.chr, buf, len); +} + +static void gdb_chr_event(void *opaque, QEMUChrEvent event) +{ + int i; + GDBState *s = (GDBState *) opaque; + + switch (event) { + case CHR_EVENT_OPENED: + /* Start with first process attached, others detached */ + for (i = 0; i < s->process_num; i++) { + s->processes[i].attached = !i; + } + + s->c_cpu = gdb_first_attached_cpu(); + s->g_cpu = s->c_cpu; + + vm_stop(RUN_STATE_PAUSED); + replay_gdb_attached(); + gdb_has_xml = false; + break; + default: + break; + } +} + +static void gdb_vm_state_change(void *opaque, bool running, RunState state) +{ + CPUState *cpu = gdbserver_state.c_cpu; + g_autoptr(GString) buf = g_string_new(NULL); + g_autoptr(GString) tid = g_string_new(NULL); + const char *type; + int ret; + + if (running || gdbserver_state.state == RS_INACTIVE) { + return; + } + /* Is there a GDB syscall waiting to be sent? */ + if (gdbserver_state.current_syscall_cb) { + gdb_put_packet(gdbserver_state.syscall_buf); + return; + } + + if (cpu == NULL) { + /* No process attached */ + return; + } + + gdb_append_thread_id(cpu, tid); + + switch (state) { + case RUN_STATE_DEBUG: + if (cpu->watchpoint_hit) { + switch (cpu->watchpoint_hit->flags & BP_MEM_ACCESS) { + case BP_MEM_READ: + type = "r"; + break; + case BP_MEM_ACCESS: + type = "a"; + break; + default: + type = ""; + break; + } + trace_gdbstub_hit_watchpoint(type, + gdb_get_cpu_index(cpu), + cpu->watchpoint_hit->vaddr); + g_string_printf(buf, "T%02xthread:%s;%swatch:%" VADDR_PRIx ";", + GDB_SIGNAL_TRAP, tid->str, type, + cpu->watchpoint_hit->vaddr); + cpu->watchpoint_hit = NULL; + goto send_packet; + } else { + trace_gdbstub_hit_break(); + } + tb_flush(cpu); + ret = GDB_SIGNAL_TRAP; + break; + case RUN_STATE_PAUSED: + trace_gdbstub_hit_paused(); + ret = GDB_SIGNAL_INT; + break; + case RUN_STATE_SHUTDOWN: + trace_gdbstub_hit_shutdown(); + ret = GDB_SIGNAL_QUIT; + break; + case RUN_STATE_IO_ERROR: + trace_gdbstub_hit_io_error(); + ret = GDB_SIGNAL_IO; + break; + case RUN_STATE_WATCHDOG: + trace_gdbstub_hit_watchdog(); + ret = GDB_SIGNAL_ALRM; + break; + case RUN_STATE_INTERNAL_ERROR: + trace_gdbstub_hit_internal_error(); + ret = GDB_SIGNAL_ABRT; + break; + case RUN_STATE_SAVE_VM: + case RUN_STATE_RESTORE_VM: + return; + case RUN_STATE_FINISH_MIGRATE: + ret = GDB_SIGNAL_XCPU; + break; + default: + trace_gdbstub_hit_unknown(state); + ret = GDB_SIGNAL_UNKNOWN; + break; + } + gdb_set_stop_cpu(cpu); + g_string_printf(buf, "T%02xthread:%s;", ret, tid->str); + +send_packet: + gdb_put_packet(buf->str); + + /* disable single step if it was enabled */ + cpu_single_step(cpu, 0); +} + +#ifndef _WIN32 +static void gdb_sigterm_handler(int signal) +{ + if (runstate_is_running()) { + vm_stop(RUN_STATE_PAUSED); + } +} +#endif + +static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len) +{ + g_autoptr(GString) hex_buf = g_string_new("O"); + gdb_memtohex(hex_buf, buf, len); + gdb_put_packet(hex_buf->str); + return len; +} + +static void gdb_monitor_open(Chardev *chr, ChardevBackend *backend, + bool *be_opened, Error **errp) +{ + *be_opened = false; +} + +static void char_gdb_class_init(ObjectClass *oc, void *data) +{ + ChardevClass *cc = CHARDEV_CLASS(oc); + + cc->internal = true; + cc->open = gdb_monitor_open; + cc->chr_write = gdb_monitor_write; +} + +#define TYPE_CHARDEV_GDB "chardev-gdb" + +static const TypeInfo char_gdb_type_info = { + .name = TYPE_CHARDEV_GDB, + .parent = TYPE_CHARDEV, + .class_init = char_gdb_class_init, +}; + +static int gdb_chr_can_receive(void *opaque) +{ + /* + * We can handle an arbitrarily large amount of data. + * Pick the maximum packet size, which is as good as anything. + */ + return MAX_PACKET_LENGTH; +} + +static void gdb_chr_receive(void *opaque, const uint8_t *buf, int size) +{ + int i; + + for (i = 0; i < size; i++) { + gdb_read_byte(buf[i]); + } +} + +static int find_cpu_clusters(Object *child, void *opaque) +{ + if (object_dynamic_cast(child, TYPE_CPU_CLUSTER)) { + GDBState *s = (GDBState *) opaque; + CPUClusterState *cluster = CPU_CLUSTER(child); + GDBProcess *process; + + s->processes = g_renew(GDBProcess, s->processes, ++s->process_num); + + process = &s->processes[s->process_num - 1]; + + /* + * GDB process IDs -1 and 0 are reserved. To avoid subtle errors at + * runtime, we enforce here that the machine does not use a cluster ID + * that would lead to PID 0. + */ + assert(cluster->cluster_id != UINT32_MAX); + process->pid = cluster->cluster_id + 1; + process->attached = false; + process->target_xml[0] = '\0'; + + return 0; + } + + return object_child_foreach(child, find_cpu_clusters, opaque); +} + +static int pid_order(const void *a, const void *b) +{ + GDBProcess *pa = (GDBProcess *) a; + GDBProcess *pb = (GDBProcess *) b; + + if (pa->pid < pb->pid) { + return -1; + } else if (pa->pid > pb->pid) { + return 1; + } else { + return 0; + } +} + +static void create_processes(GDBState *s) +{ + object_child_foreach(object_get_root(), find_cpu_clusters, s); + + if (gdbserver_state.processes) { + /* Sort by PID */ + qsort(gdbserver_state.processes, + gdbserver_state.process_num, + sizeof(gdbserver_state.processes[0]), + pid_order); + } + + gdb_create_default_process(s); +} + +int gdbserver_start(const char *device) +{ + trace_gdbstub_op_start(device); + + char gdbstub_device_name[128]; + Chardev *chr = NULL; + Chardev *mon_chr; + + if (!first_cpu) { + error_report("gdbstub: meaningless to attach gdb to a " + "machine without any CPU."); + return -1; + } + + if (!gdb_supports_guest_debug()) { + error_report("gdbstub: current accelerator doesn't " + "support guest debugging"); + return -1; + } + + if (!device) { + return -1; + } + if (strcmp(device, "none") != 0) { + if (strstart(device, "tcp:", NULL)) { + /* enforce required TCP attributes */ + snprintf(gdbstub_device_name, sizeof(gdbstub_device_name), + "%s,wait=off,nodelay=on,server=on", device); + device = gdbstub_device_name; + } +#ifndef _WIN32 + else if (strcmp(device, "stdio") == 0) { + struct sigaction act; + + memset(&act, 0, sizeof(act)); + act.sa_handler = gdb_sigterm_handler; + sigaction(SIGINT, &act, NULL); + } +#endif + /* + * FIXME: it's a bit weird to allow using a mux chardev here + * and implicitly setup a monitor. We may want to break this. + */ + chr = qemu_chr_new_noreplay("gdb", device, true, NULL); + if (!chr) { + return -1; + } + } + + if (!gdbserver_state.init) { + gdb_init_gdbserver_state(); + + qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); + + /* Initialize a monitor terminal for gdb */ + mon_chr = qemu_chardev_new(NULL, TYPE_CHARDEV_GDB, + NULL, NULL, &error_abort); + monitor_init_hmp(mon_chr, false, &error_abort); + } else { + qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); + mon_chr = gdbserver_system_state.mon_chr; + reset_gdbserver_state(); + } + + create_processes(&gdbserver_state); + + if (chr) { + qemu_chr_fe_init(&gdbserver_system_state.chr, chr, &error_abort); + qemu_chr_fe_set_handlers(&gdbserver_system_state.chr, + gdb_chr_can_receive, + gdb_chr_receive, gdb_chr_event, + NULL, &gdbserver_state, NULL, true); + } + gdbserver_state.state = chr ? RS_IDLE : RS_INACTIVE; + gdbserver_system_state.mon_chr = mon_chr; + gdbserver_state.current_syscall_cb = NULL; + + return 0; +} + +static void register_types(void) +{ + type_register_static(&char_gdb_type_info); +} + +type_init(register_types); + +/* Tell the remote gdb that the process has exited. */ +void gdb_exit(int code) +{ + char buf[4]; + + if (!gdbserver_state.init) { + return; + } + + trace_gdbstub_op_exiting((uint8_t)code); + + snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); + gdb_put_packet(buf); + + qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); +} + +/* + * Softmmu specific command helpers + */ +void gdb_handle_query_rcmd(GArray *params, void *user_ctx) +{ + const guint8 zero = 0; + int len; + + if (!params->len) { + gdb_put_packet("E22"); + return; + } + + len = strlen(get_param(params, 0)->data); + if (len % 2) { + gdb_put_packet("E01"); + return; + } + + g_assert(gdbserver_state.mem_buf->len == 0); + len = len / 2; + gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); + g_byte_array_append(gdbserver_state.mem_buf, &zero, 1); + qemu_chr_be_write(gdbserver_system_state.mon_chr, + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len); + gdb_put_packet("OK"); +} + +/* + * Break/Watch point helpers + */ + bool gdb_supports_guest_debug(void) { const AccelOpsClass *ops = cpus_get_accel(); diff --git a/gdbstub/trace-events b/gdbstub/trace-events index 03f0c303bf..0c18a4d70a 100644 --- a/gdbstub/trace-events +++ b/gdbstub/trace-events @@ -7,7 +7,6 @@ gdbstub_op_continue(void) "Continuing all CPUs" gdbstub_op_continue_cpu(int cpu_index) "Continuing CPU %d" gdbstub_op_stepping(int cpu_index) "Stepping CPU %d" gdbstub_op_extra_info(const char *info) "Thread extra info: %s" -gdbstub_hit_watchpoint(const char *type, int cpu_gdb_index, uint64_t vaddr) "Watchpoint hit, type=\"%s\" cpu=%d, vaddr=0x%" PRIx64 "" gdbstub_hit_internal_error(void) "RUN_STATE_INTERNAL_ERROR" gdbstub_hit_break(void) "RUN_STATE_DEBUG" gdbstub_hit_paused(void) "RUN_STATE_PAUSED" @@ -27,3 +26,6 @@ gdbstub_err_invalid_repeat(uint8_t ch) "got invalid RLE count: 0x%02x" gdbstub_err_invalid_rle(void) "got invalid RLE sequence" gdbstub_err_checksum_invalid(uint8_t ch) "got invalid command checksum digit: 0x%02x" gdbstub_err_checksum_incorrect(uint8_t expected, uint8_t got) "got command packet with incorrect checksum, expected=0x%02x, received=0x%02x" + +# softmmu.c +gdbstub_hit_watchpoint(const char *type, int cpu_gdb_index, uint64_t vaddr) "Watchpoint hit, type=\"%s\" cpu=%d, vaddr=0x%" PRIx64 "" From patchwork Fri Mar 3 02:57:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658450 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225442wrb; Thu, 2 Mar 2023 18:59:40 -0800 (PST) X-Google-Smtp-Source: AK7set8f2gIbg5+dWS5GLntLM5NaIPPv4OXKZQ/JpalMAk5Lgh2ky+ZNiJAYonlfnU8Y+H2M6X9b X-Received: by 2002:ac8:5c02:0:b0:3b8:525e:15ec with SMTP id i2-20020ac85c02000000b003b8525e15ecmr947653qti.27.1677812380791; Thu, 02 Mar 2023 18:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812380; cv=none; d=google.com; s=arc-20160816; b=MJQjSqdGYQlfZ36iksftJF0TbxGQNzpm1mZamRxiDArgoXXMpTkw7VEpmHPkeeFVRZ 6KyvwoF/vujgd/SagEM2oKB/Eyzix+KFb1fzStkVvJne9/DiGi/LlNxCgOJKZqSuAidv UpWDdoIj985ZFe+ISF0yiI3LNs1AmPjaW+CtyvDp5O886tVRwgDNCN+KOqQAaFAVdVyA 1WjoMZFE+TFjn/+SwMMcddx9VZ/QUfx3gGIRYe0iqLFTNQFqPi8etq97NwB7ePqqwFoC eglGQvG70T+3JEqTbYq8zPCwySLztMud9vf3sAJzWltrP3dfx42NP4jzA9OlAuzkG1Iv CwoA== 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=ZtobSpYZ6l+5unCyBqtXSqtTCL27TdAYvJ1i9vgXn+c=; b=KMXJYVe5gdnsH/BOEwEbUW/zO0yNWnuGCOkZvaK2JUHgB3PbJA7vH5VCtcRchP3dy3 Sc4Crf6d0R2vMsHwkUPkra/Z95JuhwnusQLigumIUbFxWyeKz1puA6MEIMjUab5LaKG1 TyHvv6z2GWwPY2W4kb4YivZcm7jXn3Ab56yJs+cUhnmgMMHKX9S8MIsqq/Y+KcsKAv15 jIyikwIBYfkQUTel76kdYd3sZCGldO64/T4l+c85I0eZ6HivuJtZ2BM3C2lgaolS4oOF fdFQal2cU1NmmPdUyIrQ5o8P36uuUxUMhvFQy7seQGO7XsbrfnRJ7QL45OknPjqTkJ4e UWCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wsQ3XtYy; 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 br44-20020a05620a462c00b0071a74355a29si1127067qkb.289.2023.03.02.18.59.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:59:40 -0800 (PST) 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=wsQ3XtYy; 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 1pXvcm-0007Ux-B5; Thu, 02 Mar 2023 21:58:24 -0500 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 1pXvck-0007Ts-Mk for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcg-0001pV-Eu for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: by mail-pj1-x102b.google.com with SMTP id x34so1209887pjj.0 for ; Thu, 02 Mar 2023 18:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812297; 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=ZtobSpYZ6l+5unCyBqtXSqtTCL27TdAYvJ1i9vgXn+c=; b=wsQ3XtYy2cMbgf8n7Kse/Y8XE7F5pNktBfjQhYyflUU77JH/awpfZS3QHq4kkRMtSA tf87QXsT7ZHLIbvh9xiE0M+ZUYzXtbC0y0qE5G44kkMBSDiS+dzbFVkPlZc7ie+s2i2D WrSUlQzi1nHJQ0gEri9/ZCr9t5JWAEWL+GkhHtdYb5Kpfd6D/7jvxb61iiN8YfBgCH3I eAdipevqIH/JuGtELdMo+swiKwsHzLfwE1ygmjdr3LRy7zYIMUUZOui3YCeNgYWBKEYM E3ivJ3FaX6tLjXJhVYbl2E5WHBq6+A+zAND3f3HKbCOcG44ql2dqcpVe+0oPf+Ahgo7A ifIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812297; 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=ZtobSpYZ6l+5unCyBqtXSqtTCL27TdAYvJ1i9vgXn+c=; b=qYDvO4Q4iAo3vapgk1v7e0BZSnGr+6jaMWU78seqZSBV2xN5qeFOGyD7sDbBJmYSzB v8Z6lW0rf82sJyvjsnRQdpXKzZ5NDIoSe4EDs3eaW3SkIS6UMSF5eRP7qa0BtSPZAFcy laByeEh8hw7GYEWGisOuZOaBvSMlbYTU//TV8sYn/Dw/Pf3IqC/mX4QvFxFMVZYE7ead iw06a3xgs/zU/Svao1zG25Yy3KCEB5dBwW2aQO5+pZcYfXEpMABJpUk5wOoccbJYHzne ce51m7sK5HCtfpm1U8LpFOuQRjUvdLuxusJ2+pXENJQaLxoGAhYK8YJKp5tBqpswAgFf D6Ag== X-Gm-Message-State: AO0yUKXRzMwEBY7B2uGcKTjB7g+AENMqf4PsnHh0pDCey0e4lwxx43zk FB2uWMUe9zn9ZaPNPzHM5FTy3QGK8KouToZsPZk= X-Received: by 2002:a17:902:c94c:b0:19b:33c0:4091 with SMTP id i12-20020a170902c94c00b0019b33c04091mr547789pla.52.1677812297006; Thu, 02 Mar 2023 18:58:17 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Fabiano Rosas Subject: [PATCH v4.5 11/29] gdbstub: move chunks of user code into own files Date: Thu, 2 Mar 2023 18:57:47 -0800 Message-Id: <20230303025805.625589-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 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: Alex Bennée The process was pretty similar to the softmmu move except we take the time to split stuff between user.c and user-target.c to avoid as much target specific compilation as possible. We also start to make use of our shiny new header scheme so the user-only helpers can be included without the rest of the exec/gsbstub.h cruft. As before we split some functions into user and softmmu versions Reviewed-by: Fabiano Rosas Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-12-alex.bennee@linaro.org> --- MAINTAINERS | 1 + gdbstub/internals.h | 18 ++ include/exec/gdbstub.h | 21 -- include/gdbstub/user.h | 43 +++ gdbstub/gdbstub.c | 678 +---------------------------------------- gdbstub/softmmu.c | 90 ++++++ gdbstub/user-target.c | 283 +++++++++++++++++ gdbstub/user.c | 344 +++++++++++++++++++++ linux-user/main.c | 1 + linux-user/signal.c | 2 +- gdbstub/meson.build | 3 + 11 files changed, 788 insertions(+), 696 deletions(-) create mode 100644 include/gdbstub/user.h create mode 100644 gdbstub/user-target.c diff --git a/MAINTAINERS b/MAINTAINERS index 234800e3dc..c7a8e2307f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2735,6 +2735,7 @@ S: Maintained F: docs/system/gdb.rst F: gdbstub/* F: include/exec/gdbstub.h +F: include/gdbstub/* F: gdb-xml/ F: tests/tcg/multiarch/gdbstub/ F: scripts/feature_to_c.sh diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 83989af859..6bd6a05657 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -117,6 +117,22 @@ int gdb_get_cpu_index(CPUState *cpu); void gdb_create_default_process(GDBState *s); +/* signal mapping, common for softmmu, specialised for user-mode */ +int gdb_signal_to_target(int sig); +int gdb_target_signal_to_gdb(int sig); + +int gdb_get_char(void); /* user only */ + +/** + * gdb_continue() - handle continue in mode specific way. + */ +void gdb_continue(void); + +/** + * gdb_continue_partial() - handle partial continue in mode specific way. + */ +int gdb_continue_partial(char *newstates); + /* * Helpers with separate softmmu and user implementations */ @@ -149,6 +165,8 @@ typedef union GdbCmdVariant { #define get_param(p, i) (&g_array_index(p, GdbCmdVariant, i)) void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */ +void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */ +void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */ /* * Break/Watch point support - there is an implementation for softmmu diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 1636fb3841..8fff5450ed 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -103,27 +103,6 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va); int use_gdb_syscalls(void); -#ifdef CONFIG_USER_ONLY -/** - * gdb_handlesig: yield control to gdb - * @cpu: CPU - * @sig: if non-zero, the signal number which caused us to stop - * - * This function yields control to gdb, when a user-mode-only target - * needs to stop execution. If @sig is non-zero, then we will send a - * stop packet to tell gdb that we have stopped because of this signal. - * - * This function will block (handling protocol requests from gdb) - * until gdb tells us to continue target execution. When it does - * return, the return value is a signal to deliver to the target, - * or 0 if no signal should be delivered, ie the signal that caused - * us to stop should be ignored. - */ -int gdb_handlesig(CPUState *, int); -void gdb_signalled(CPUArchState *, int); -void gdbserver_fork(CPUState *); -#endif - /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); typedef int (*gdb_set_reg_cb)(CPUArchState *env, uint8_t *buf, int reg); diff --git a/include/gdbstub/user.h b/include/gdbstub/user.h new file mode 100644 index 0000000000..d392e510c5 --- /dev/null +++ b/include/gdbstub/user.h @@ -0,0 +1,43 @@ +/* + * gdbstub user-mode only APIs + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: LGPL-2.0+ + */ + +#ifndef GDBSTUB_USER_H +#define GDBSTUB_USER_H + +/** + * gdb_handlesig() - yield control to gdb + * @cpu: CPU + * @sig: if non-zero, the signal number which caused us to stop + * + * This function yields control to gdb, when a user-mode-only target + * needs to stop execution. If @sig is non-zero, then we will send a + * stop packet to tell gdb that we have stopped because of this signal. + * + * This function will block (handling protocol requests from gdb) + * until gdb tells us to continue target execution. When it does + * return, the return value is a signal to deliver to the target, + * or 0 if no signal should be delivered, ie the signal that caused + * us to stop should be ignored. + */ +int gdb_handlesig(CPUState *, int); + +/** + * gdb_signalled() - inform remote gdb of sig exit + * @as: current CPUArchState + * @sig: signal number + */ +void gdb_signalled(CPUArchState *as, int sig); + +/** + * gdbserver_fork() - disable gdb stub for child processes. + * @cs: CPU + */ +void gdbserver_fork(CPUState *cs); + + +#endif /* GDBSTUB_USER_H */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 4b939c689c..6907bdc99c 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -30,13 +30,12 @@ #include "trace.h" #include "exec/gdbstub.h" #ifdef CONFIG_USER_ONLY -#include "qemu.h" +#include "gdbstub/user.h" #else #include "hw/cpu/cluster.h" #include "hw/boards.h" #endif -#include "qemu/sockets.h" #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" #include "semihosting/semihost.h" @@ -80,223 +79,6 @@ static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } -/* - * Return the GDB index for a given vCPU state. - * - * For user mode this is simply the thread id. - */ -#if defined(CONFIG_USER_ONLY) -int gdb_get_cpu_index(CPUState *cpu) -{ - TaskState *ts = (TaskState *) cpu->opaque; - return ts ? ts->ts_tid : -1; -} -#endif - -#ifdef CONFIG_USER_ONLY - -/* Map target signal numbers to GDB protocol signal numbers and vice - * versa. For user emulation's currently supported systems, we can - * assume most signals are defined. - */ - -static int gdb_signal_table[] = { - 0, - TARGET_SIGHUP, - TARGET_SIGINT, - TARGET_SIGQUIT, - TARGET_SIGILL, - TARGET_SIGTRAP, - TARGET_SIGABRT, - -1, /* SIGEMT */ - TARGET_SIGFPE, - TARGET_SIGKILL, - TARGET_SIGBUS, - TARGET_SIGSEGV, - TARGET_SIGSYS, - TARGET_SIGPIPE, - TARGET_SIGALRM, - TARGET_SIGTERM, - TARGET_SIGURG, - TARGET_SIGSTOP, - TARGET_SIGTSTP, - TARGET_SIGCONT, - TARGET_SIGCHLD, - TARGET_SIGTTIN, - TARGET_SIGTTOU, - TARGET_SIGIO, - TARGET_SIGXCPU, - TARGET_SIGXFSZ, - TARGET_SIGVTALRM, - TARGET_SIGPROF, - TARGET_SIGWINCH, - -1, /* SIGLOST */ - TARGET_SIGUSR1, - TARGET_SIGUSR2, -#ifdef TARGET_SIGPWR - TARGET_SIGPWR, -#else - -1, -#endif - -1, /* SIGPOLL */ - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, - -1, -#ifdef __SIGRTMIN - __SIGRTMIN + 1, - __SIGRTMIN + 2, - __SIGRTMIN + 3, - __SIGRTMIN + 4, - __SIGRTMIN + 5, - __SIGRTMIN + 6, - __SIGRTMIN + 7, - __SIGRTMIN + 8, - __SIGRTMIN + 9, - __SIGRTMIN + 10, - __SIGRTMIN + 11, - __SIGRTMIN + 12, - __SIGRTMIN + 13, - __SIGRTMIN + 14, - __SIGRTMIN + 15, - __SIGRTMIN + 16, - __SIGRTMIN + 17, - __SIGRTMIN + 18, - __SIGRTMIN + 19, - __SIGRTMIN + 20, - __SIGRTMIN + 21, - __SIGRTMIN + 22, - __SIGRTMIN + 23, - __SIGRTMIN + 24, - __SIGRTMIN + 25, - __SIGRTMIN + 26, - __SIGRTMIN + 27, - __SIGRTMIN + 28, - __SIGRTMIN + 29, - __SIGRTMIN + 30, - __SIGRTMIN + 31, - -1, /* SIGCANCEL */ - __SIGRTMIN, - __SIGRTMIN + 32, - __SIGRTMIN + 33, - __SIGRTMIN + 34, - __SIGRTMIN + 35, - __SIGRTMIN + 36, - __SIGRTMIN + 37, - __SIGRTMIN + 38, - __SIGRTMIN + 39, - __SIGRTMIN + 40, - __SIGRTMIN + 41, - __SIGRTMIN + 42, - __SIGRTMIN + 43, - __SIGRTMIN + 44, - __SIGRTMIN + 45, - __SIGRTMIN + 46, - __SIGRTMIN + 47, - __SIGRTMIN + 48, - __SIGRTMIN + 49, - __SIGRTMIN + 50, - __SIGRTMIN + 51, - __SIGRTMIN + 52, - __SIGRTMIN + 53, - __SIGRTMIN + 54, - __SIGRTMIN + 55, - __SIGRTMIN + 56, - __SIGRTMIN + 57, - __SIGRTMIN + 58, - __SIGRTMIN + 59, - __SIGRTMIN + 60, - __SIGRTMIN + 61, - __SIGRTMIN + 62, - __SIGRTMIN + 63, - __SIGRTMIN + 64, - __SIGRTMIN + 65, - __SIGRTMIN + 66, - __SIGRTMIN + 67, - __SIGRTMIN + 68, - __SIGRTMIN + 69, - __SIGRTMIN + 70, - __SIGRTMIN + 71, - __SIGRTMIN + 72, - __SIGRTMIN + 73, - __SIGRTMIN + 74, - __SIGRTMIN + 75, - __SIGRTMIN + 76, - __SIGRTMIN + 77, - __SIGRTMIN + 78, - __SIGRTMIN + 79, - __SIGRTMIN + 80, - __SIGRTMIN + 81, - __SIGRTMIN + 82, - __SIGRTMIN + 83, - __SIGRTMIN + 84, - __SIGRTMIN + 85, - __SIGRTMIN + 86, - __SIGRTMIN + 87, - __SIGRTMIN + 88, - __SIGRTMIN + 89, - __SIGRTMIN + 90, - __SIGRTMIN + 91, - __SIGRTMIN + 92, - __SIGRTMIN + 93, - __SIGRTMIN + 94, - __SIGRTMIN + 95, - -1, /* SIGINFO */ - -1, /* UNKNOWN */ - -1, /* DEFAULT */ - -1, - -1, - -1, - -1, - -1, - -1 -#endif -}; -#else -/* In system mode we only need SIGINT and SIGTRAP; other signals - are not yet supported. */ - -enum { - TARGET_SIGINT = 2, - TARGET_SIGTRAP = 5 -}; - -static int gdb_signal_table[] = { - -1, - -1, - TARGET_SIGINT, - -1, - -1, - TARGET_SIGTRAP -}; -#endif - -#ifdef CONFIG_USER_ONLY -static int target_signal_to_gdb (int sig) -{ - int i; - for (i = 0; i < ARRAY_SIZE (gdb_signal_table); i++) - if (gdb_signal_table[i] == sig) - return i; - return GDB_SIGNAL_UNKNOWN; -} -#endif - -static int gdb_signal_to_target (int sig) -{ - if (sig < ARRAY_SIZE (gdb_signal_table)) - return gdb_signal_table[sig]; - else - return -1; -} - typedef struct GDBRegisterState { int base_reg; int num_regs; @@ -306,15 +88,6 @@ typedef struct GDBRegisterState { struct GDBRegisterState *next; } GDBRegisterState; -#ifdef CONFIG_USER_ONLY -typedef struct { - int fd; - char *socket_path; - int running_state; -} GDBUserState; -static GDBUserState gdbserver_user_state; -#endif - GDBState gdbserver_state; void gdb_init_gdbserver_state(void) @@ -338,34 +111,6 @@ void gdb_init_gdbserver_state(void) bool gdb_has_xml; -#ifdef CONFIG_USER_ONLY - -static int get_char(void) -{ - uint8_t ch; - int ret; - - for(;;) { - ret = recv(gdbserver_user_state.fd, &ch, 1, 0); - if (ret < 0) { - if (errno == ECONNRESET) { - gdbserver_user_state.fd = -1; - } - if (errno != EINTR) { - return -1; - } - } else if (ret == 0) { - close(gdbserver_user_state.fd); - gdbserver_user_state.fd = -1; - return -1; - } else { - break; - } - } - return ch; -} -#endif - /* * Return true if there is a GDB currently connected to the stub * and attached to a CPU @@ -410,104 +155,6 @@ static bool stub_can_reverse(void) #endif } -/* Resume execution. */ -static void gdb_continue(void) -{ - -#ifdef CONFIG_USER_ONLY - gdbserver_user_state.running_state = 1; - trace_gdbstub_op_continue(); -#else - if (!runstate_needs_reset()) { - trace_gdbstub_op_continue(); - vm_start(); - } -#endif -} - -/* - * Resume execution, per CPU actions. For user-mode emulation it's - * equivalent to gdb_continue. - */ -static int gdb_continue_partial(char *newstates) -{ - CPUState *cpu; - int res = 0; -#ifdef CONFIG_USER_ONLY - /* - * This is not exactly accurate, but it's an improvement compared to the - * previous situation, where only one CPU would be single-stepped. - */ - CPU_FOREACH(cpu) { - if (newstates[cpu->cpu_index] == 's') { - trace_gdbstub_op_stepping(cpu->cpu_index); - cpu_single_step(cpu, gdbserver_state.sstep_flags); - } - } - gdbserver_user_state.running_state = 1; -#else - int flag = 0; - - if (!runstate_needs_reset()) { - bool step_requested = false; - CPU_FOREACH(cpu) { - if (newstates[cpu->cpu_index] == 's') { - step_requested = true; - break; - } - } - - if (vm_prepare_start(step_requested)) { - return 0; - } - - CPU_FOREACH(cpu) { - switch (newstates[cpu->cpu_index]) { - case 0: - case 1: - break; /* nothing to do here */ - case 's': - trace_gdbstub_op_stepping(cpu->cpu_index); - cpu_single_step(cpu, gdbserver_state.sstep_flags); - cpu_resume(cpu); - flag = 1; - break; - case 'c': - trace_gdbstub_op_continue_cpu(cpu->cpu_index); - cpu_resume(cpu); - flag = 1; - break; - default: - res = -1; - break; - } - } - } - if (flag) { - qemu_clock_enable(QEMU_CLOCK_VIRTUAL, true); - } -#endif - return res; -} - -#ifdef CONFIG_USER_ONLY -void gdb_put_buffer(const uint8_t *buf, int len) -{ - int ret; - - while (len > 0) { - ret = send(gdbserver_user_state.fd, buf, len, 0); - if (ret < 0) { - if (errno != EINTR) - return; - } else { - buf += ret; - len -= ret; - } - } -} -#endif - /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { @@ -593,7 +240,7 @@ int gdb_put_packet_binary(const char *buf, int len, bool dump) gdbserver_state.last_packet->len); #ifdef CONFIG_USER_ONLY - i = get_char(); + i = gdb_get_char(); if (i < 0) return -1; if (i == '+') @@ -1950,23 +1597,6 @@ static void handle_query_thread_extra(GArray *params, void *user_ctx) gdb_put_strbuf(); } -#ifdef CONFIG_USER_ONLY -static void handle_query_offsets(GArray *params, void *user_ctx) -{ - TaskState *ts; - - ts = gdbserver_state.c_cpu->opaque; - g_string_printf(gdbserver_state.str_buf, - "Text=" TARGET_ABI_FMT_lx - ";Data=" TARGET_ABI_FMT_lx - ";Bss=" TARGET_ABI_FMT_lx, - ts->info->code_offset, - ts->info->data_offset, - ts->info->data_offset); - gdb_put_strbuf(); -} -#endif - static void handle_query_supported(GArray *params, void *user_ctx) { CPUClass *cc; @@ -2049,53 +1679,6 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) gdbserver_state.str_buf->len, true); } -#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER) -static void handle_query_xfer_auxv(GArray *params, void *user_ctx) -{ - TaskState *ts; - unsigned long offset, len, saved_auxv, auxv_len; - - if (params->len < 2) { - gdb_put_packet("E22"); - return; - } - - offset = get_param(params, 0)->val_ul; - len = get_param(params, 1)->val_ul; - ts = gdbserver_state.c_cpu->opaque; - saved_auxv = ts->info->saved_auxv; - auxv_len = ts->info->auxv_len; - - if (offset >= auxv_len) { - gdb_put_packet("E00"); - return; - } - - if (len > (MAX_PACKET_LENGTH - 5) / 2) { - len = (MAX_PACKET_LENGTH - 5) / 2; - } - - if (len < auxv_len - offset) { - g_string_assign(gdbserver_state.str_buf, "m"); - } else { - g_string_assign(gdbserver_state.str_buf, "l"); - len = auxv_len - offset; - } - - g_byte_array_set_size(gdbserver_state.mem_buf, len); - if (target_memory_rw_debug(gdbserver_state.g_cpu, saved_auxv + offset, - gdbserver_state.mem_buf->data, len, false)) { - gdb_put_packet("E14"); - return; - } - - gdb_memtox(gdbserver_state.str_buf, - (const char *)gdbserver_state.mem_buf->data, len); - gdb_put_packet_binary(gdbserver_state.str_buf->str, - gdbserver_state.str_buf->len, true); -} -#endif - static void handle_query_attached(GArray *params, void *user_ctx) { gdb_put_packet(GDB_ATTACHED); @@ -2173,7 +1756,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { }, #ifdef CONFIG_USER_ONLY { - .handler = handle_query_offsets, + .handler = gdb_handle_query_offsets, .cmd = "Offsets", }, #else @@ -2203,7 +1786,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { }, #if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER) { - .handler = handle_query_xfer_auxv, + .handler = gdb_handle_query_xfer_auxv, .cmd = "Xfer:auxv:read::", .cmd_startswith = 1, .schema = "l,l0" @@ -2791,29 +2374,6 @@ void gdb_read_byte(uint8_t ch) } } -#ifdef CONFIG_USER_ONLY -/* Tell the remote gdb that the process has exited. */ -void gdb_exit(int code) -{ - char buf[4]; - - if (!gdbserver_state.init) { - return; - } - if (gdbserver_user_state.socket_path) { - unlink(gdbserver_user_state.socket_path); - } - if (gdbserver_user_state.fd < 0) { - return; - } - - trace_gdbstub_op_exiting((uint8_t)code); - - snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); - gdb_put_packet(buf); -} -#endif - /* * Create the process that will contain all the "orphan" CPUs (that are not * part of a CPU cluster). Note that if this process contains no CPUs, it won't @@ -2839,233 +2399,3 @@ void gdb_create_default_process(GDBState *s) process->target_xml[0] = '\0'; } -#ifdef CONFIG_USER_ONLY -int -gdb_handlesig(CPUState *cpu, int sig) -{ - char buf[256]; - int n; - - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { - return sig; - } - - /* disable single step if it was enabled */ - cpu_single_step(cpu, 0); - tb_flush(cpu); - - if (sig != 0) { - gdb_set_stop_cpu(cpu); - g_string_printf(gdbserver_state.str_buf, - "T%02xthread:", target_signal_to_gdb(sig)); - gdb_append_thread_id(cpu, gdbserver_state.str_buf); - g_string_append_c(gdbserver_state.str_buf, ';'); - gdb_put_strbuf(); - } - /* - * gdb_put_packet() might have detected that the peer terminated the - * connection. - */ - if (gdbserver_user_state.fd < 0) { - return sig; - } - - sig = 0; - gdbserver_state.state = RS_IDLE; - gdbserver_user_state.running_state = 0; - while (gdbserver_user_state.running_state == 0) { - n = read(gdbserver_user_state.fd, buf, 256); - if (n > 0) { - int i; - - for (i = 0; i < n; i++) { - gdb_read_byte(buf[i]); - } - } else { - /* XXX: Connection closed. Should probably wait for another - connection before continuing. */ - if (n == 0) { - close(gdbserver_user_state.fd); - } - gdbserver_user_state.fd = -1; - return sig; - } - } - sig = gdbserver_state.signal; - gdbserver_state.signal = 0; - return sig; -} - -/* Tell the remote gdb that the process has exited due to SIG. */ -void gdb_signalled(CPUArchState *env, int sig) -{ - char buf[4]; - - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { - return; - } - - snprintf(buf, sizeof(buf), "X%02x", target_signal_to_gdb(sig)); - gdb_put_packet(buf); -} - -static void gdb_accept_init(int fd) -{ - gdb_init_gdbserver_state(); - gdb_create_default_process(&gdbserver_state); - gdbserver_state.processes[0].attached = true; - gdbserver_state.c_cpu = gdb_first_attached_cpu(); - gdbserver_state.g_cpu = gdbserver_state.c_cpu; - gdbserver_user_state.fd = fd; - gdb_has_xml = false; -} - -static bool gdb_accept_socket(int gdb_fd) -{ - int fd; - - for(;;) { - fd = accept(gdb_fd, NULL, NULL); - if (fd < 0 && errno != EINTR) { - perror("accept socket"); - return false; - } else if (fd >= 0) { - qemu_set_cloexec(fd); - break; - } - } - - gdb_accept_init(fd); - return true; -} - -static int gdbserver_open_socket(const char *path) -{ - struct sockaddr_un sockaddr = {}; - int fd, ret; - - fd = socket(AF_UNIX, SOCK_STREAM, 0); - if (fd < 0) { - perror("create socket"); - return -1; - } - - sockaddr.sun_family = AF_UNIX; - pstrcpy(sockaddr.sun_path, sizeof(sockaddr.sun_path) - 1, path); - ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); - if (ret < 0) { - perror("bind socket"); - close(fd); - return -1; - } - ret = listen(fd, 1); - if (ret < 0) { - perror("listen socket"); - close(fd); - return -1; - } - - return fd; -} - -static bool gdb_accept_tcp(int gdb_fd) -{ - struct sockaddr_in sockaddr = {}; - socklen_t len; - int fd; - - for(;;) { - len = sizeof(sockaddr); - fd = accept(gdb_fd, (struct sockaddr *)&sockaddr, &len); - if (fd < 0 && errno != EINTR) { - perror("accept"); - return false; - } else if (fd >= 0) { - qemu_set_cloexec(fd); - break; - } - } - - /* set short latency */ - if (socket_set_nodelay(fd)) { - perror("setsockopt"); - close(fd); - return false; - } - - gdb_accept_init(fd); - return true; -} - -static int gdbserver_open_port(int port) -{ - struct sockaddr_in sockaddr; - int fd, ret; - - fd = socket(PF_INET, SOCK_STREAM, 0); - if (fd < 0) { - perror("socket"); - return -1; - } - qemu_set_cloexec(fd); - - socket_set_fast_reuse(fd); - - sockaddr.sin_family = AF_INET; - sockaddr.sin_port = htons(port); - sockaddr.sin_addr.s_addr = 0; - ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); - if (ret < 0) { - perror("bind"); - close(fd); - return -1; - } - ret = listen(fd, 1); - if (ret < 0) { - perror("listen"); - close(fd); - return -1; - } - - return fd; -} - -int gdbserver_start(const char *port_or_path) -{ - int port = g_ascii_strtoull(port_or_path, NULL, 10); - int gdb_fd; - - if (port > 0) { - gdb_fd = gdbserver_open_port(port); - } else { - gdb_fd = gdbserver_open_socket(port_or_path); - } - - if (gdb_fd < 0) { - return -1; - } - - if (port > 0 && gdb_accept_tcp(gdb_fd)) { - return 0; - } else if (gdb_accept_socket(gdb_fd)) { - gdbserver_user_state.socket_path = g_strdup(port_or_path); - return 0; - } - - /* gone wrong */ - close(gdb_fd); - return -1; -} - -/* Disable gdb stub for child processes. */ -void gdbserver_fork(CPUState *cpu) -{ - if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { - return; - } - close(gdbserver_user_state.fd); - gdbserver_user_state.fd = -1; - cpu_breakpoint_remove_all(cpu, BP_GDB); - cpu_watchpoint_remove_all(cpu, BP_GDB); -} -#endif diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 86a94f1519..a6c196ade6 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -434,6 +434,96 @@ void gdb_handle_query_rcmd(GArray *params, void *user_ctx) gdb_put_packet("OK"); } +/* + * Execution state helpers + */ + +void gdb_continue(void) +{ + if (!runstate_needs_reset()) { + trace_gdbstub_op_continue(); + vm_start(); + } +} + +/* + * Resume execution, per CPU actions. + */ +int gdb_continue_partial(char *newstates) +{ + CPUState *cpu; + int res = 0; + int flag = 0; + + if (!runstate_needs_reset()) { + bool step_requested = false; + CPU_FOREACH(cpu) { + if (newstates[cpu->cpu_index] == 's') { + step_requested = true; + break; + } + } + + if (vm_prepare_start(step_requested)) { + return 0; + } + + CPU_FOREACH(cpu) { + switch (newstates[cpu->cpu_index]) { + case 0: + case 1: + break; /* nothing to do here */ + case 's': + trace_gdbstub_op_stepping(cpu->cpu_index); + cpu_single_step(cpu, gdbserver_state.sstep_flags); + cpu_resume(cpu); + flag = 1; + break; + case 'c': + trace_gdbstub_op_continue_cpu(cpu->cpu_index); + cpu_resume(cpu); + flag = 1; + break; + default: + res = -1; + break; + } + } + } + if (flag) { + qemu_clock_enable(QEMU_CLOCK_VIRTUAL, true); + } + return res; +} + +/* + * Signal Handling - in system mode we only need SIGINT and SIGTRAP; other + * signals are not yet supported. + */ + +enum { + TARGET_SIGINT = 2, + TARGET_SIGTRAP = 5 +}; + +static int gdb_signal_table[] = { + -1, + -1, + TARGET_SIGINT, + -1, + -1, + TARGET_SIGTRAP +}; + +int gdb_signal_to_target(int sig) +{ + if (sig < ARRAY_SIZE(gdb_signal_table)) { + return gdb_signal_table[sig]; + } else { + return -1; + } +} + /* * Break/Watch point helpers */ diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c new file mode 100644 index 0000000000..fa0e59ec9a --- /dev/null +++ b/gdbstub/user-target.c @@ -0,0 +1,283 @@ +/* + * Target specific user-mode handling + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: LGPL-2.0+ + */ + +#include "qemu/osdep.h" +#include "exec/gdbstub.h" +#include "qemu.h" +#include "internals.h" + +/* + * Map target signal numbers to GDB protocol signal numbers and vice + * versa. For user emulation's currently supported systems, we can + * assume most signals are defined. + */ + +static int gdb_signal_table[] = { + 0, + TARGET_SIGHUP, + TARGET_SIGINT, + TARGET_SIGQUIT, + TARGET_SIGILL, + TARGET_SIGTRAP, + TARGET_SIGABRT, + -1, /* SIGEMT */ + TARGET_SIGFPE, + TARGET_SIGKILL, + TARGET_SIGBUS, + TARGET_SIGSEGV, + TARGET_SIGSYS, + TARGET_SIGPIPE, + TARGET_SIGALRM, + TARGET_SIGTERM, + TARGET_SIGURG, + TARGET_SIGSTOP, + TARGET_SIGTSTP, + TARGET_SIGCONT, + TARGET_SIGCHLD, + TARGET_SIGTTIN, + TARGET_SIGTTOU, + TARGET_SIGIO, + TARGET_SIGXCPU, + TARGET_SIGXFSZ, + TARGET_SIGVTALRM, + TARGET_SIGPROF, + TARGET_SIGWINCH, + -1, /* SIGLOST */ + TARGET_SIGUSR1, + TARGET_SIGUSR2, +#ifdef TARGET_SIGPWR + TARGET_SIGPWR, +#else + -1, +#endif + -1, /* SIGPOLL */ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, +#ifdef __SIGRTMIN + __SIGRTMIN + 1, + __SIGRTMIN + 2, + __SIGRTMIN + 3, + __SIGRTMIN + 4, + __SIGRTMIN + 5, + __SIGRTMIN + 6, + __SIGRTMIN + 7, + __SIGRTMIN + 8, + __SIGRTMIN + 9, + __SIGRTMIN + 10, + __SIGRTMIN + 11, + __SIGRTMIN + 12, + __SIGRTMIN + 13, + __SIGRTMIN + 14, + __SIGRTMIN + 15, + __SIGRTMIN + 16, + __SIGRTMIN + 17, + __SIGRTMIN + 18, + __SIGRTMIN + 19, + __SIGRTMIN + 20, + __SIGRTMIN + 21, + __SIGRTMIN + 22, + __SIGRTMIN + 23, + __SIGRTMIN + 24, + __SIGRTMIN + 25, + __SIGRTMIN + 26, + __SIGRTMIN + 27, + __SIGRTMIN + 28, + __SIGRTMIN + 29, + __SIGRTMIN + 30, + __SIGRTMIN + 31, + -1, /* SIGCANCEL */ + __SIGRTMIN, + __SIGRTMIN + 32, + __SIGRTMIN + 33, + __SIGRTMIN + 34, + __SIGRTMIN + 35, + __SIGRTMIN + 36, + __SIGRTMIN + 37, + __SIGRTMIN + 38, + __SIGRTMIN + 39, + __SIGRTMIN + 40, + __SIGRTMIN + 41, + __SIGRTMIN + 42, + __SIGRTMIN + 43, + __SIGRTMIN + 44, + __SIGRTMIN + 45, + __SIGRTMIN + 46, + __SIGRTMIN + 47, + __SIGRTMIN + 48, + __SIGRTMIN + 49, + __SIGRTMIN + 50, + __SIGRTMIN + 51, + __SIGRTMIN + 52, + __SIGRTMIN + 53, + __SIGRTMIN + 54, + __SIGRTMIN + 55, + __SIGRTMIN + 56, + __SIGRTMIN + 57, + __SIGRTMIN + 58, + __SIGRTMIN + 59, + __SIGRTMIN + 60, + __SIGRTMIN + 61, + __SIGRTMIN + 62, + __SIGRTMIN + 63, + __SIGRTMIN + 64, + __SIGRTMIN + 65, + __SIGRTMIN + 66, + __SIGRTMIN + 67, + __SIGRTMIN + 68, + __SIGRTMIN + 69, + __SIGRTMIN + 70, + __SIGRTMIN + 71, + __SIGRTMIN + 72, + __SIGRTMIN + 73, + __SIGRTMIN + 74, + __SIGRTMIN + 75, + __SIGRTMIN + 76, + __SIGRTMIN + 77, + __SIGRTMIN + 78, + __SIGRTMIN + 79, + __SIGRTMIN + 80, + __SIGRTMIN + 81, + __SIGRTMIN + 82, + __SIGRTMIN + 83, + __SIGRTMIN + 84, + __SIGRTMIN + 85, + __SIGRTMIN + 86, + __SIGRTMIN + 87, + __SIGRTMIN + 88, + __SIGRTMIN + 89, + __SIGRTMIN + 90, + __SIGRTMIN + 91, + __SIGRTMIN + 92, + __SIGRTMIN + 93, + __SIGRTMIN + 94, + __SIGRTMIN + 95, + -1, /* SIGINFO */ + -1, /* UNKNOWN */ + -1, /* DEFAULT */ + -1, + -1, + -1, + -1, + -1, + -1 +#endif +}; + +int gdb_signal_to_target(int sig) +{ + if (sig < ARRAY_SIZE(gdb_signal_table)) { + return gdb_signal_table[sig]; + } else { + return -1; + } +} + +int gdb_target_signal_to_gdb(int sig) +{ + int i; + for (i = 0; i < ARRAY_SIZE(gdb_signal_table); i++) { + if (gdb_signal_table[i] == sig) { + return i; + } + } + return GDB_SIGNAL_UNKNOWN; +} + +int gdb_get_cpu_index(CPUState *cpu) +{ + TaskState *ts = (TaskState *) cpu->opaque; + return ts ? ts->ts_tid : -1; +} + +/* + * User-mode specific command helpers + */ + +void gdb_handle_query_offsets(GArray *params, void *user_ctx) +{ + TaskState *ts; + + ts = gdbserver_state.c_cpu->opaque; + g_string_printf(gdbserver_state.str_buf, + "Text=" TARGET_ABI_FMT_lx + ";Data=" TARGET_ABI_FMT_lx + ";Bss=" TARGET_ABI_FMT_lx, + ts->info->code_offset, + ts->info->data_offset, + ts->info->data_offset); + gdb_put_strbuf(); +} + +#if defined(CONFIG_LINUX) +/* Partial user only duplicate of helper in gdbstub.c */ +static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, + uint8_t *buf, int len, bool is_write) +{ + CPUClass *cc; + cc = CPU_GET_CLASS(cpu); + if (cc->memory_rw_debug) { + return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + } + return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); +} + +void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx) +{ + TaskState *ts; + unsigned long offset, len, saved_auxv, auxv_len; + + if (params->len < 2) { + gdb_put_packet("E22"); + return; + } + + offset = get_param(params, 0)->val_ul; + len = get_param(params, 1)->val_ul; + ts = gdbserver_state.c_cpu->opaque; + saved_auxv = ts->info->saved_auxv; + auxv_len = ts->info->auxv_len; + + if (offset >= auxv_len) { + gdb_put_packet("E00"); + return; + } + + if (len > (MAX_PACKET_LENGTH - 5) / 2) { + len = (MAX_PACKET_LENGTH - 5) / 2; + } + + if (len < auxv_len - offset) { + g_string_assign(gdbserver_state.str_buf, "m"); + } else { + g_string_assign(gdbserver_state.str_buf, "l"); + len = auxv_len - offset; + } + + g_byte_array_set_size(gdbserver_state.mem_buf, len); + if (target_memory_rw_debug(gdbserver_state.g_cpu, saved_auxv + offset, + gdbserver_state.mem_buf->data, len, false)) { + gdb_put_packet("E14"); + return; + } + + gdb_memtox(gdbserver_state.str_buf, + (const char *)gdbserver_state.mem_buf->data, len); + gdb_put_packet_binary(gdbserver_state.str_buf->str, + gdbserver_state.str_buf->len, true); +} +#endif diff --git a/gdbstub/user.c b/gdbstub/user.c index 09a18fb23b..23b2e726f6 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -10,10 +10,354 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/sockets.h" +#include "exec/hwaddr.h" +#include "exec/tb-flush.h" #include "exec/gdbstub.h" +#include "gdbstub/user.h" #include "hw/core/cpu.h" +#include "trace.h" #include "internals.h" +/* User-mode specific state */ +typedef struct { + int fd; + char *socket_path; + int running_state; +} GDBUserState; + +static GDBUserState gdbserver_user_state; + +int gdb_get_char(void) +{ + uint8_t ch; + int ret; + + for (;;) { + ret = recv(gdbserver_user_state.fd, &ch, 1, 0); + if (ret < 0) { + if (errno == ECONNRESET) { + gdbserver_user_state.fd = -1; + } + if (errno != EINTR) { + return -1; + } + } else if (ret == 0) { + close(gdbserver_user_state.fd); + gdbserver_user_state.fd = -1; + return -1; + } else { + break; + } + } + return ch; +} + +void gdb_put_buffer(const uint8_t *buf, int len) +{ + int ret; + + while (len > 0) { + ret = send(gdbserver_user_state.fd, buf, len, 0); + if (ret < 0) { + if (errno != EINTR) { + return; + } + } else { + buf += ret; + len -= ret; + } + } +} + +/* Tell the remote gdb that the process has exited. */ +void gdb_exit(int code) +{ + char buf[4]; + + if (!gdbserver_state.init) { + return; + } + if (gdbserver_user_state.socket_path) { + unlink(gdbserver_user_state.socket_path); + } + if (gdbserver_user_state.fd < 0) { + return; + } + + trace_gdbstub_op_exiting((uint8_t)code); + + snprintf(buf, sizeof(buf), "W%02x", (uint8_t)code); + gdb_put_packet(buf); +} + +int gdb_handlesig(CPUState *cpu, int sig) +{ + char buf[256]; + int n; + + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + return sig; + } + + /* disable single step if it was enabled */ + cpu_single_step(cpu, 0); + tb_flush(cpu); + + if (sig != 0) { + gdb_set_stop_cpu(cpu); + g_string_printf(gdbserver_state.str_buf, + "T%02xthread:", gdb_target_signal_to_gdb(sig)); + gdb_append_thread_id(cpu, gdbserver_state.str_buf); + g_string_append_c(gdbserver_state.str_buf, ';'); + gdb_put_strbuf(); + } + /* + * gdb_put_packet() might have detected that the peer terminated the + * connection. + */ + if (gdbserver_user_state.fd < 0) { + return sig; + } + + sig = 0; + gdbserver_state.state = RS_IDLE; + gdbserver_user_state.running_state = 0; + while (gdbserver_user_state.running_state == 0) { + n = read(gdbserver_user_state.fd, buf, 256); + if (n > 0) { + int i; + + for (i = 0; i < n; i++) { + gdb_read_byte(buf[i]); + } + } else { + /* + * XXX: Connection closed. Should probably wait for another + * connection before continuing. + */ + if (n == 0) { + close(gdbserver_user_state.fd); + } + gdbserver_user_state.fd = -1; + return sig; + } + } + sig = gdbserver_state.signal; + gdbserver_state.signal = 0; + return sig; +} + +/* Tell the remote gdb that the process has exited due to SIG. */ +void gdb_signalled(CPUArchState *env, int sig) +{ + char buf[4]; + + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + return; + } + + snprintf(buf, sizeof(buf), "X%02x", gdb_target_signal_to_gdb(sig)); + gdb_put_packet(buf); +} + +static void gdb_accept_init(int fd) +{ + gdb_init_gdbserver_state(); + gdb_create_default_process(&gdbserver_state); + gdbserver_state.processes[0].attached = true; + gdbserver_state.c_cpu = gdb_first_attached_cpu(); + gdbserver_state.g_cpu = gdbserver_state.c_cpu; + gdbserver_user_state.fd = fd; + gdb_has_xml = false; +} + +static bool gdb_accept_socket(int gdb_fd) +{ + int fd; + + for (;;) { + fd = accept(gdb_fd, NULL, NULL); + if (fd < 0 && errno != EINTR) { + perror("accept socket"); + return false; + } else if (fd >= 0) { + qemu_set_cloexec(fd); + break; + } + } + + gdb_accept_init(fd); + return true; +} + +static int gdbserver_open_socket(const char *path) +{ + struct sockaddr_un sockaddr = {}; + int fd, ret; + + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd < 0) { + perror("create socket"); + return -1; + } + + sockaddr.sun_family = AF_UNIX; + pstrcpy(sockaddr.sun_path, sizeof(sockaddr.sun_path) - 1, path); + ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); + if (ret < 0) { + perror("bind socket"); + close(fd); + return -1; + } + ret = listen(fd, 1); + if (ret < 0) { + perror("listen socket"); + close(fd); + return -1; + } + + return fd; +} + +static bool gdb_accept_tcp(int gdb_fd) +{ + struct sockaddr_in sockaddr = {}; + socklen_t len; + int fd; + + for (;;) { + len = sizeof(sockaddr); + fd = accept(gdb_fd, (struct sockaddr *)&sockaddr, &len); + if (fd < 0 && errno != EINTR) { + perror("accept"); + return false; + } else if (fd >= 0) { + qemu_set_cloexec(fd); + break; + } + } + + /* set short latency */ + if (socket_set_nodelay(fd)) { + perror("setsockopt"); + close(fd); + return false; + } + + gdb_accept_init(fd); + return true; +} + +static int gdbserver_open_port(int port) +{ + struct sockaddr_in sockaddr; + int fd, ret; + + fd = socket(PF_INET, SOCK_STREAM, 0); + if (fd < 0) { + perror("socket"); + return -1; + } + qemu_set_cloexec(fd); + + socket_set_fast_reuse(fd); + + sockaddr.sin_family = AF_INET; + sockaddr.sin_port = htons(port); + sockaddr.sin_addr.s_addr = 0; + ret = bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); + if (ret < 0) { + perror("bind"); + close(fd); + return -1; + } + ret = listen(fd, 1); + if (ret < 0) { + perror("listen"); + close(fd); + return -1; + } + + return fd; +} + +int gdbserver_start(const char *port_or_path) +{ + int port = g_ascii_strtoull(port_or_path, NULL, 10); + int gdb_fd; + + if (port > 0) { + gdb_fd = gdbserver_open_port(port); + } else { + gdb_fd = gdbserver_open_socket(port_or_path); + } + + if (gdb_fd < 0) { + return -1; + } + + if (port > 0 && gdb_accept_tcp(gdb_fd)) { + return 0; + } else if (gdb_accept_socket(gdb_fd)) { + gdbserver_user_state.socket_path = g_strdup(port_or_path); + return 0; + } + + /* gone wrong */ + close(gdb_fd); + return -1; +} + +/* Disable gdb stub for child processes. */ +void gdbserver_fork(CPUState *cpu) +{ + if (!gdbserver_state.init || gdbserver_user_state.fd < 0) { + return; + } + close(gdbserver_user_state.fd); + gdbserver_user_state.fd = -1; + cpu_breakpoint_remove_all(cpu, BP_GDB); + /* no cpu_watchpoint_remove_all for user-mode */ +} + +/* + * Execution state helpers + */ + +void gdb_continue(void) +{ + gdbserver_user_state.running_state = 1; + trace_gdbstub_op_continue(); +} + +/* + * Resume execution, for user-mode emulation it's equivalent to + * gdb_continue. + */ +int gdb_continue_partial(char *newstates) +{ + CPUState *cpu; + int res = 0; + /* + * This is not exactly accurate, but it's an improvement compared to the + * previous situation, where only one CPU would be single-stepped. + */ + CPU_FOREACH(cpu) { + if (newstates[cpu->cpu_index] == 's') { + trace_gdbstub_op_stepping(cpu->cpu_index); + cpu_single_step(cpu, gdbserver_state.sstep_flags); + } + } + gdbserver_user_state.running_state = 1; + return res; +} + +/* + * Break/Watch point helpers + */ + bool gdb_supports_guest_debug(void) { /* user-mode == TCG == supported */ diff --git a/linux-user/main.c b/linux-user/main.c index 4ff30ff980..75dbb52788 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -40,6 +40,7 @@ #include "qemu/plugin.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" +#include "gdbstub/user.h" #include "tcg/tcg.h" #include "qemu/timer.h" #include "qemu/envlist.h" diff --git a/linux-user/signal.c b/linux-user/signal.c index 098f3a787d..748a98f3e5 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -18,7 +18,7 @@ */ #include "qemu/osdep.h" #include "qemu/bitops.h" -#include "exec/gdbstub.h" +#include "gdbstub/user.h" #include "hw/core/tcg-cpu-ops.h" #include diff --git a/gdbstub/meson.build b/gdbstub/meson.build index fc895a2c39..773bd4b9c9 100644 --- a/gdbstub/meson.build +++ b/gdbstub/meson.build @@ -7,3 +7,6 @@ specific_ss.add(files('gdbstub.c')) softmmu_ss.add(files('softmmu.c')) user_ss.add(files('user.c')) + +# The user-target is specialised by the guest +specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-target.c')) From patchwork Fri Mar 3 02:57:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658460 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226015wrb; Thu, 2 Mar 2023 19:00:55 -0800 (PST) X-Google-Smtp-Source: AK7set+28Mx1OOUjZvr4yCgWHpc+IiPw/JaxPX4MfJejQ6dD6yGevbPD6e9BfOoTw+gJuTylRxa7 X-Received: by 2002:ac8:5b84:0:b0:3bf:d48e:26c4 with SMTP id a4-20020ac85b84000000b003bfd48e26c4mr742457qta.39.1677812455347; Thu, 02 Mar 2023 19:00:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812455; cv=none; d=google.com; s=arc-20160816; b=1LIjqE9Xv032v7MC0+t2AjEEzCtaj+mwPP3lHv+jTb2IEALTQIBbGIrda+pXrLGJ/e gMzTQBfs9eGEP6UfJDWhy4Aft4NJJQdDxtr8MJD2CbmtkhqlRokfmCv5KgrNR4NKuMjA /fXPry5mjwh7OcLa4lVoAVpi7vJgFJtZhcFQodj26mJwF6hGnUPZvN52+xd27kdR8fdG zFqMFNtJdWO+a2zkUnE//pIxjFu8n8c57ZQbUQLDnhk1VnXDGfx1xpPlmtzLrguEhhx4 L5EUVhvVyqBDX7vXxnZzng9ZF3Xcl1zvl/bmTQ+XiUOsAeaZQ42hBSLBc4gitfZmFGqf mvSw== 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=mzQlLd9zUuaRJux4t6YnHFCedCjY2bATUZGlQrOk4kk=; b=psp7vOqsWZtQsYUdELZgOL13WNrcQBe4DJdZDgJjM0dIBa9x4SaILRh82M+rGkD3fE 65/fcxboV1EQ3nlyB4Zw0Ru9H6WQVgPRl8UyFuxVIBnGMuGHRvlBzwG8nI2hwOzL5qK3 Iw0hfARouTL+okp1ajrG7Bt6+XDIlj5sjr5nW9mw+Mbl/M4x4DE3/VhfsOeDVnqLpy1l lA8V3tLavduxQVaueHS7eaBwX+l2fwyYrAODxFrZ9MzoSGzrsvRDjWMbV3JDTnN7AncY z0LNppNXUT7yRYf1djlXvP68NqVHhd67jDaqakfCWVcnly0ESU54XQ34aaUmLT1sb2/K /drg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qq5GgzVX; 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 z13-20020ac87f8d000000b003b9a47ccfc5si988561qtj.313.2023.03.02.19.00.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:55 -0800 (PST) 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=qq5GgzVX; 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 1pXvcm-0007Ut-43; Thu, 02 Mar 2023 21:58:24 -0500 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 1pXvcj-0007Sh-2k for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvch-0001pk-EY for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:20 -0500 Received: by mail-pl1-x632.google.com with SMTP id ky4so1363141plb.3 for ; Thu, 02 Mar 2023 18:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812298; 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=mzQlLd9zUuaRJux4t6YnHFCedCjY2bATUZGlQrOk4kk=; b=qq5GgzVXiFtb7paXe24HRWNpHl4VWdQqJbfqpdqEnYKpVQHUVCyEzd6csff+ybYZTp ZqUiugksfFt9qSpL17V2Vghs0Gt/1Wn6ICdVbKu8d6wGY47fM+sF6ZEJniMMNPORRiif eLzLMEcapxYvd+PflyyKBH5G5rb7lI9fXaKMmO+7cDGFKcMdzpD33D7Y9oWA+OYpkBjl 16S5b6UfwDBuR/YVPHb8BMp+LXqYO1fR9DAl4qZ4uviwpK1kltmfE525Q4yEAaMD3d5T SGWPdyL949YyeVe65aZGJvbkZMHAvEkIPQHiVxc2/l35QGofSa16ZgildD9FgCvQwzCl Laig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812298; 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=mzQlLd9zUuaRJux4t6YnHFCedCjY2bATUZGlQrOk4kk=; b=ohO5DNfBn4BxChxRBwjk9eIWBM0d9eudKorCjaSaY8ETp2gP7C8ljyUSryy7hggYw4 lUjtQXEYnvw5qUwpT9Ii0O8L8uIsKDller2yGscwz9eqQ5953/nsZ4zr83OyDF6fPROx a+YmvdAY4Zimx9KImLsKwZKYEaqrFnlEZvGbqi8j3/XzbmxYCTJv1xejDkYa/JU9BxpP bXxEEwVGwVNUFLbDjgnXlZS3lcf4s83xlStzTdfMxfi/28RaQu5EjRKsS3LF0PVlbzbA PL3BlL2OF0rrRMBsWGcIX7pLKhWoPjhPewKERZXRez0d2SKAobt7id7uN/7r2voE5HH1 5KpQ== X-Gm-Message-State: AO0yUKWibLZ7B7BrotORvDq0TQgj3wpFvSUjMJxx9/y7pYhRL43cq+is wcPPfyPbljnNkxuxM6qGbwxecFbAnlib01KdLNA= X-Received: by 2002:a17:903:32cf:b0:19a:8e52:ce0 with SMTP id i15-20020a17090332cf00b0019a8e520ce0mr585261plr.58.1677812297862; Thu, 02 Mar 2023 18:58:17 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 12/29] gdbstub: rationalise signal mapping in softmmu Date: Thu, 2 Mar 2023 18:57:48 -0800 Message-Id: <20230303025805.625589-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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 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: Alex Bennée We don't really need a table for mapping two symbols. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-13-alex.bennee@linaro.org> --- gdbstub/softmmu.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index a6c196ade6..6796761fd9 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -506,20 +506,14 @@ enum { TARGET_SIGTRAP = 5 }; -static int gdb_signal_table[] = { - -1, - -1, - TARGET_SIGINT, - -1, - -1, - TARGET_SIGTRAP -}; - int gdb_signal_to_target(int sig) { - if (sig < ARRAY_SIZE(gdb_signal_table)) { - return gdb_signal_table[sig]; - } else { + switch (sig) { + case 2: + return TARGET_SIGINT; + case 5: + return TARGET_SIGTRAP; + default: return -1; } } From patchwork Fri Mar 3 02:57:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658467 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226619wrb; Thu, 2 Mar 2023 19:02:10 -0800 (PST) X-Google-Smtp-Source: AK7set80lZj7CeVSXB80/NwpFaoHZ+q5Wgs2oAdKh3W4/LZP51SVa2CFvYlk97WO/o/aEYlk5mrl X-Received: by 2002:a05:622a:151:b0:3b9:e3fc:5689 with SMTP id v17-20020a05622a015100b003b9e3fc5689mr693804qtw.58.1677812530394; Thu, 02 Mar 2023 19:02:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812530; cv=none; d=google.com; s=arc-20160816; b=Lxc3TfXa6VPzU/F9KI8ZawAsbMgNUvedL4rf4L4K8dw7K0ZxCri4y7TC4EdhOd1e6t 2w4cI5on3aw51fK0N9l/Ma2nUTZmwrWTOQ16ZqudqtPWDAF5iVlfWAUVrQX4lki6XDxr 1kYznGTScB1F430Fs6fP4OnmZ5DsbkCmM9HYy/G3AXFVSZKCrQOmDOfZO3yoxzXAytd5 yuNE200PPxtXGp1WkR/daUaogODzvfTj2zpnu7SXrboVSzFlQgh7CJqkmWYYqaLmoVI2 DDKL4cBthp1rFCCE/w1rMoVN0fpvsnXm439z1nsv9jlV8otfQjNZWoiKy4iGxCo+WJFf dmMw== 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=i8K3kd1epFLcngP3OVVEwMxdfQQsYRllTEo6D15ORfYX5hAmpOPw98PlA3/ZBmpBD/ TTULjMfiQDYQ9CNm6Ia/RpVwRtz5Foc8cftJh65LoRJ6SCMHFzVHvxp+iL4f+2r3gd5i EPSAWd0ebLFwlRXQazTVmlhYjeR+EUBe0yWGXdwyahV1OY6f4L2HDl4aTPGKYAA2s3lM //TY2pFlpMYFm84UQfbhnR4smVh4WWzjezNIMC4Q6zCGSst8SnqEhtVAAUCbZDcxhsO/ dRgkuYLDtDViG7OseNoOIQvHOA2nQxV8yf0D9dGGK+SfswubAJ3Wm6UfIzgCH8NlxvxX wsWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tNoX1P+A; 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 m6-20020a05620a290600b0071d2670ade9si1078921qkp.28.2023.03.02.19.02.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:02:10 -0800 (PST) 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=tNoX1P+A; 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 1pXvcm-0007VA-Qt; Thu, 02 Mar 2023 21:58:24 -0500 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 1pXvck-0007TV-3c for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvci-0001q5-4C for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:21 -0500 Received: by mail-pl1-x62c.google.com with SMTP id z2so1304041plf.12 for ; Thu, 02 Mar 2023 18:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812298; 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=tNoX1P+AvR2lfZ4RIfaACCRNfL9YBFi+v/pdn6GOD03pA1IIjwvKKxQ3iKrA80f4BF J5WwOV6pM5Kj9QTT70nAUfY0WH5Tc516ekin8mh3QCWHY8AdGRLQPQbg0G66Ex7bQ21J jM1AFPM+UO53i8BLwOHJKtJInML/xDmdZr/ziZ6OndFdJd+QDRPd1kl9nboE7sAhe0l8 igyzZV4XHK8Sn8WWVtKhscG9b/g2r+NYQhRxDrYj8RjGgfLvzWWhsxERBfsSLQ8epUxZ GAntPsDBp1XwW+/P98RL2NAy2PoxIXLLNnkFz7OeaBMm9Ifpunggak3jVwtx/t6mAX2v NUQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812298; 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=/+3AuyYbBOFfNGlTwYutk3FT3tOPA6yE1qNXUHzrdi8=; b=pTkFutbMFcMGy6eYG4CJDOUKD1Ys3pijNvpMLWVIeHs03n5imELxuXnfqr9HRNdciw zaAx/H3DEIbnD1jbTAuAp9wk/rWSO1XMKhcWy+KGa1d+M0JYxqRCJz+urik4AiOrAdv9 NVygwydpvf7szQjzH/Go/WS2UCkZaJnrgqXMP4DsRGid0JjjHxEwyHA1jKGB1UMAg5gl xb4L+9Am3UtxE5sNZC7V6ZDGxE0wHfzTkBRegaDyBWSBmZ+y3cUt8nBIXTnMdq7PfOOK GRNJ0o3EiIaUJ//qS8DM1LvUehthACX9L1spsboIpnwdIqUU6gRA6qQM8P1ZlC8K/J7K 6Maw== X-Gm-Message-State: AO0yUKUYs2yivZjZFb6H+5Atj6+tIgReU+LSu9qTz7jZS1iUrtzox59R Rh8N925aTCIScAvSloscVO5+frypBcrv2iVX9+Q= X-Received: by 2002:a17:902:e842:b0:19e:4173:38b3 with SMTP id t2-20020a170902e84200b0019e417338b3mr611153plg.46.1677812298579; Thu, 02 Mar 2023 18:58:18 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 13/29] gdbstub: abstract target specific details from gdb_put_packet_binary Date: Thu, 2 Mar 2023 18:57:49 -0800 Message-Id: <20230303025805.625589-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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 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: Alex Bennée We unfortunately handle the checking of packet acknowledgement differently for user and softmmu modes. Abstract the user mode stuff behind gdb_got_immediate_ack with a stub for softmmu. Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-14-alex.bennee@linaro.org> --- gdbstub/internals.h | 15 +++++++++++++++ gdbstub/gdbstub.c | 10 ++-------- gdbstub/softmmu.c | 8 ++++++++ gdbstub/user.c | 19 +++++++++++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 6bd6a05657..6534e373cb 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -110,6 +110,21 @@ void gdb_memtohex(GString *buf, const uint8_t *mem, int len); void gdb_memtox(GString *buf, const char *mem, int len); void gdb_read_byte(uint8_t ch); +/* + * Packet acknowledgement - we handle this slightly differently + * between user and softmmu mode, mainly to deal with the differences + * between the flexible chardev and the direct fd approaches. + * + * We currently don't support a negotiated QStartNoAckMode + */ + +/** + * gdb_got_immediate_ack() - check ok to continue + * + * Returns true to continue, false to re-transmit for user only, the + * softmmu stub always returns true. + */ +bool gdb_got_immediate_ack(void); /* utility helpers */ CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 6907bdc99c..0476ee7039 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -239,15 +239,9 @@ int gdb_put_packet_binary(const char *buf, int len, bool dump) gdb_put_buffer(gdbserver_state.last_packet->data, gdbserver_state.last_packet->len); -#ifdef CONFIG_USER_ONLY - i = gdb_get_char(); - if (i < 0) - return -1; - if (i == '+') + if (gdb_got_immediate_ack()) { break; -#else - break; -#endif + } } return 0; } diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 6796761fd9..04e75449a2 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -55,6 +55,14 @@ int gdb_get_cpu_index(CPUState *cpu) return cpu->cpu_index + 1; } +/* + * We check the status of the last message in the chardev receive code + */ +bool gdb_got_immediate_ack(void) +{ + return true; +} + /* * GDB Connection management. For system emulation we do all of this * via our existing Chardev infrastructure which allows us to support diff --git a/gdbstub/user.c b/gdbstub/user.c index 23b2e726f6..0c8cd028b1 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -54,6 +54,25 @@ int gdb_get_char(void) return ch; } +bool gdb_got_immediate_ack(void) +{ + int i; + + i = gdb_get_char(); + if (i < 0) { + /* no response, continue anyway */ + return true; + } + + if (i == '+') { + /* received correctly, continue */ + return true; + } + + /* anything else, including '-' then try again */ + return false; +} + void gdb_put_buffer(const uint8_t *buf, int len) { int ret; From patchwork Fri Mar 3 02:57:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658464 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226353wrb; Thu, 2 Mar 2023 19:01:33 -0800 (PST) X-Google-Smtp-Source: AK7set9pyeR5hXYujObdjEqYcBXY2WPsGIirIuBqiRfLoioVD+R7/P0dM7F8iJt/X3K73SSxtbS/ X-Received: by 2002:ad4:5b86:0:b0:56e:9317:eb9a with SMTP id 6-20020ad45b86000000b0056e9317eb9amr615880qvp.29.1677812493664; Thu, 02 Mar 2023 19:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812493; cv=none; d=google.com; s=arc-20160816; b=pqcwst+uNJo7CjxtxDZvLkogiUq/hBfF6cFrhyuR6Gw+5EIQdSdA0aZg9WFLP+GVGb g+eIhS/X87pz5f44QcoQyxrjAhczLh6aHtTT4ZwcLHPztjx7jV5nFCGGRtYr0YhWP5+W L0UpY4owO5Vz3K8GvhyJRmaOr2oPL3tKux4Tf6XXTpwiSJDwnB0dvLa8mA2Wy3QgSBRH feJBXtp+QthW/+xgP2dfpU9cExLqc4blC4PW/0herSbdnt3uFJGymuflTg//TnkL/oMY REumdyryAaxXO+Fi1/31zmHXxTVzbl/I86kPqxe3rzXzgmKyrJaRvTSKLi+tfnQk2vD8 WBVg== 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=eLmx2eJEzrcuefRjyJcG44ypWKcZev5YnQRPSJMGOkQ=; b=I19bFuimKYiUHPaiaCUtSPaCzsDvb74F6/YWUu4sGgCD99sxRJtwJ1wcqQYlNnj3g6 KWr6+LvhvQhivNu6bK/kErsCt6gNdyOzO2bGB9aKG2NrsgN1vGY8A63yYO290Qx9VoUV /aTfYLlqgMUau7v/hj44apmRW7Rr3kd4DEyI3PdSeEHJCpz9GJVXACXX3FFWx0GOA0rz Hxe6r/TGAkCtALgoj/GLg5QmDSKEQ4/0YCOWTMLowR9fzSYrRlvbbQE3jCRCICoHeOFe SAKadDyLp4qf62Mk/XPGJiK7H3vbjK5IinIFK4v0ZDy0cVxcCWENCthjqjR1oqLzz1y7 w/Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EOPJ71RO; 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 d19-20020a05620a241300b0073ba6e7f4f8si1070348qkn.262.2023.03.02.19.01.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:01:33 -0800 (PST) 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=EOPJ71RO; 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 1pXvco-0007WB-Lx; Thu, 02 Mar 2023 21:58:26 -0500 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 1pXvck-0007Tj-EM for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvci-0001qG-K0 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:22 -0500 Received: by mail-pj1-x102d.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so967570pjp.2 for ; Thu, 02 Mar 2023 18:58:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812299; 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=eLmx2eJEzrcuefRjyJcG44ypWKcZev5YnQRPSJMGOkQ=; b=EOPJ71RO/fkKGs8g/MCBwM9kCbc4f0MSBSeB76VvG/FL1T2K3brPGOGy7hcuzXe/vR f72pPwH6MTef97wJDPBDUXxCQ8t9RFUZDKbfbwTDr+bvzAAqQsKIzmCSUcjSViE0leSz 4PxO/y8/6cRnkPy+khNhYa6slCol9HHz0R0H31EcKl2zmeyGg1CFk1nLGYocXj5/tw7O QSCBx46kpW11tCJOb4leHCf7bXcf7JAyfoUY9buCI4yBj98M+GalTZ754D+a/TMwnNyJ viOoq3NKZ7K9dw5ttw6tP2hE8m79FBXPU4n1pedg0/eYVs0RBQBSlTY6qzTYhCapsI6I 4qUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812299; 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=eLmx2eJEzrcuefRjyJcG44ypWKcZev5YnQRPSJMGOkQ=; b=4FJnqgPJdgj0Bqmc7d63r86c8sh2cvIZhOEFN8OuczTvng5ioAbUxEsj/UZgVj7SEs rSJ1vwCuXTTax+CLCb1+iYsUUpzLvVtBXj9KZSWlLhyKyal+ur09jR89kQPRmpMotxVe bT76en8g8T/ELQg0uTbWVGG0sKv9MylVSyboVZC7rjo33Qp0XxYBq2t1pWcLNnIuL55a /R+NlRmTNp3IUN8ZEe8a5EzfElePfKXDWZKRTs/2QZdnQ9eS7uxWIu/S/m4bLW65PykO E7A29MkLkaKVVt+l1GUPgJnxTDgB9DnIZysR2FvRr8apNMkOojf4zNemIyxZdWSPNC2T aGBQ== X-Gm-Message-State: AO0yUKUVwEYhZudTBHd+opQf3m3FFu1M2e9qII8X9aQMzwwUu6TOgk8D wn3mup2YzQmg8dETrc0QkO244yaOXillDQ5F8rU= X-Received: by 2002:a17:902:f54b:b0:19c:f16c:5cb4 with SMTP id h11-20020a170902f54b00b0019cf16c5cb4mr653004plf.1.1677812299238; Thu, 02 Mar 2023 18:58:19 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 14/29] gdbstub: specialise handle_query_attached Date: Thu, 2 Mar 2023 18:57:50 -0800 Message-Id: <20230303025805.625589-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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 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: Alex Bennée In both user and softmmu cases we are just replying with a constant. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-15-alex.bennee@linaro.org> --- gdbstub/internals.h | 4 +++- gdbstub/gdbstub.c | 15 ++------------- gdbstub/softmmu.c | 5 +++++ gdbstub/user.c | 5 +++++ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 6534e373cb..20caacd744 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -154,7 +154,7 @@ int gdb_continue_partial(char *newstates); void gdb_put_buffer(const uint8_t *buf, int len); /* - * Command handlers - either softmmu or user only + * Command handlers - either specialised or softmmu or user only */ void gdb_init_gdbserver_state(void); @@ -183,6 +183,8 @@ void gdb_handle_query_rcmd(GArray *params, void *user_ctx); /* softmmu */ void gdb_handle_query_offsets(GArray *params, void *user_ctx); /* user */ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */ +void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 0476ee7039..52d1769f57 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -46,12 +46,6 @@ #include "internals.h" -#ifdef CONFIG_USER_ONLY -#define GDB_ATTACHED "0" -#else -#define GDB_ATTACHED "1" -#endif - #ifndef CONFIG_USER_ONLY static int phy_memory_mode; #endif @@ -1673,11 +1667,6 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx) gdbserver_state.str_buf->len, true); } -static void handle_query_attached(GArray *params, void *user_ctx) -{ - gdb_put_packet(GDB_ATTACHED); -} - static void handle_query_qemu_supported(GArray *params, void *user_ctx) { g_string_printf(gdbserver_state.str_buf, "sstepbits;sstep"); @@ -1787,12 +1776,12 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { }, #endif { - .handler = handle_query_attached, + .handler = gdb_handle_query_attached, .cmd = "Attached:", .cmd_startswith = 1 }, { - .handler = handle_query_attached, + .handler = gdb_handle_query_attached, .cmd = "Attached", }, { diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 04e75449a2..7c180b779a 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -446,6 +446,11 @@ void gdb_handle_query_rcmd(GArray *params, void *user_ctx) * Execution state helpers */ +void gdb_handle_query_attached(GArray *params, void *user_ctx) +{ + gdb_put_packet("1"); +} + void gdb_continue(void) { if (!runstate_needs_reset()) { diff --git a/gdbstub/user.c b/gdbstub/user.c index 0c8cd028b1..c0fd83b373 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -345,6 +345,11 @@ void gdbserver_fork(CPUState *cpu) * Execution state helpers */ +void gdb_handle_query_attached(GArray *params, void *user_ctx) +{ + gdb_put_packet("0"); +} + void gdb_continue(void) { gdbserver_user_state.running_state = 1; From patchwork Fri Mar 3 02:57:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658470 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226766wrb; Thu, 2 Mar 2023 19:02:30 -0800 (PST) X-Google-Smtp-Source: AK7set/jUuMw23XdKHQGp0QkUjyzflsCcSHNWDuDyTYD6OMlTv7pEseU1fkWNbqoYy/2FFq2hmIi X-Received: by 2002:a05:622a:354:b0:3bf:a1f0:4c8 with SMTP id r20-20020a05622a035400b003bfa1f004c8mr644058qtw.65.1677812549850; Thu, 02 Mar 2023 19:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812549; cv=none; d=google.com; s=arc-20160816; b=osSsucoNpte/ZWhaBqzDSZFf6NhqcBiDudTLHH3lgZdSp+iuy5iaMp7lB9qKKMOukl BA5129AxISBAC2IqQj2pm41HAHxk+DPVKItsWDMKhRK6mbebWyqF5tdSKHMLG9mMkdVk uQ11GQ0IrELQypFAfSmcF08kdq0EAP9SLmF6CRqxLzM6hZ2mrPpq/YpjUhTPVgXx8sfo N4zq1rTeqSxIRvaTIpwLdxIFXMqPwqRADosxGr/bENggCPdoKtztBeT1W6dBYNLZDczy e20hvBA47V4HSZWimdg5gpeIH4jcu/jk8WRLG4032Zq6ZJtTY84EczncrvcybN2ySHdc yTlQ== 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=gsYB/ur4MioSCASzY7iISb0rzEcvUMh2PpjKeCB3a8Y=; b=fY2meO8hbB/ncz1qCXIyV/lKwA4S0mN8XbF5Ke7wmghgdShU4GTR8pUa7AzH0APcsW MVceRgBU7ZhfmxP4W1//Pm8fLPTV2OunUmw95XmcPphGk0e6GJb1V8k3birPyod2tnUL e9/YXBhOFMp0dnPX9BGVQWe1mAwjjmW5CPHg14jc+tWztUKTw7uJgU0rLC1IwlyE3Zvv YKV1yPR93/iT0MDyxVL7yS5w6aEcIBdwFaD38bYGRaQNcFxjryA0Nriqn86AZSM4HI+K Afhkuvb30lvbnJOmuJyqRntLpOZmroXFQK2MXBuGTCFmnJiHYbB78VUm4AgVV8pT/vMG crlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N2KvnZpy; 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 w7-20020a05620a424700b0073b49db0dd7si968115qko.636.2023.03.02.19.02.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:02:29 -0800 (PST) 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=N2KvnZpy; 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 1pXvcn-0007VJ-E8; Thu, 02 Mar 2023 21:58:25 -0500 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 1pXvcl-0007UR-CS for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcj-0001qW-DO for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: by mail-pj1-x1031.google.com with SMTP id kb15so1177007pjb.1 for ; Thu, 02 Mar 2023 18:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812300; 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=gsYB/ur4MioSCASzY7iISb0rzEcvUMh2PpjKeCB3a8Y=; b=N2KvnZpymBBvzZkQ9N8dAq8fMc3eIlfbboZ1jj8uK5+OgxnHnBJN5H7GPI+YCZsx/w gMrl1ILq5fKIjfhpbU7PDTQQUDuZNilgUqf/6gaYsJeEhp8Dc+kLrkXBqi1oOEfr4Xbh hZ2KBRQmroCU/wEN1+U6v8+EhlnaNgxGyEdc/YkVk8+gWLw/rr8H38njU9ogcveHsCQO ArNXGLBwoMZYmuH8Q0VXcrrp0KbzgEjQZzC8rFCLDUSpBJPR2iyEd0rbVZ0ak8MyK3Rk 8c0ithjDAxKD/n31yJC4bE3c0fghrdlrv2Y4VVg4XSFvG3MULDzsOJdrqBqBv72FgbVp Ahng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812300; 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=gsYB/ur4MioSCASzY7iISb0rzEcvUMh2PpjKeCB3a8Y=; b=2XClq/1sLomy0S3timSJJ4IexLgl6H15cWsKKxEcFb47sKKhhHRSY1izNwOKPk6odx tW2uivDgjqcNNacZspbJkXNg5kth9a6erTRoehaSJjWgOk66hECs30/gX4KHulvzchYc btADZGB9s7sjQ0uzZBjvowbNppC5cdA4Hfhi3spQwCNIuDvBuPYjjF5BKWKY7oRrzZaT 5uNMCDbOGkQ1z/mlCd58vnV1TjzCL8jNkMNotkzEuDOkOnDzmPCS8mGPWnh25jyBpojQ Nyre5UloCuaYrDDDp37Pg6/6ka+YQOoIs446KVwdX62UIDQQTydl+KqbJ99EHykKdD+n uuGQ== X-Gm-Message-State: AO0yUKWhlHCb3LkIxeEkTCtG+TgK5RNwu49qaUXEws/nDDKSP7nZ2xsv cZ9lzbWTGRAW40C3Yu9YbD3eV2f2fBCXRj/dJLc= X-Received: by 2002:a17:902:e5d2:b0:19a:75b8:f50c with SMTP id u18-20020a170902e5d200b0019a75b8f50cmr570890plf.31.1677812300071; Thu, 02 Mar 2023 18:58:20 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 15/29] gdbstub: specialise target_memory_rw_debug Date: Thu, 2 Mar 2023 18:57:51 -0800 Message-Id: <20230303025805.625589-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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 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: Alex Bennée The two implementations are different enough to encourage having a specialisation and we can move some of the softmmu only stuff out of gdbstub. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-16-alex.bennee@linaro.org> --- gdbstub/internals.h | 19 ++++++++++++ gdbstub/gdbstub.c | 73 +++++++-------------------------------------- gdbstub/softmmu.c | 51 +++++++++++++++++++++++++++++++ gdbstub/user.c | 15 ++++++++++ 4 files changed, 96 insertions(+), 62 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 20caacd744..d8c0292d99 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -185,6 +185,10 @@ void gdb_handle_query_xfer_auxv(GArray *params, void *user_ctx); /*user */ void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ +/* softmmu only */ +void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx); +void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx); + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. @@ -194,4 +198,19 @@ int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len); int gdb_breakpoint_remove(CPUState *cs, int type, vaddr addr, vaddr len); void gdb_breakpoint_remove_all(CPUState *cs); +/** + * gdb_target_memory_rw_debug() - handle debug access to memory + * @cs: CPUState + * @addr: nominal address, could be an entire physical address + * @buf: data + * @len: length of access + * @is_write: is it a write operation + * + * This function is specialised depending on the mode we are running + * in. For softmmu guests we can switch the interpretation of the + * address to a physical address. + */ +int gdb_target_memory_rw_debug(CPUState *cs, hwaddr addr, + uint8_t *buf, int len, bool is_write); + #endif /* GDBSTUB_INTERNALS_H */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 52d1769f57..ed38ab0aaa 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -46,33 +46,6 @@ #include "internals.h" -#ifndef CONFIG_USER_ONLY -static int phy_memory_mode; -#endif - -static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, - uint8_t *buf, int len, bool is_write) -{ - CPUClass *cc; - -#ifndef CONFIG_USER_ONLY - if (phy_memory_mode) { - if (is_write) { - cpu_physical_memory_write(addr, buf, len); - } else { - cpu_physical_memory_read(addr, buf, len); - } - return 0; - } -#endif - - cc = CPU_GET_CLASS(cpu); - if (cc->memory_rw_debug) { - return cc->memory_rw_debug(cpu, addr, buf, len, is_write); - } - return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); -} - typedef struct GDBRegisterState { int base_reg; int num_regs; @@ -1195,11 +1168,11 @@ static void handle_write_mem(GArray *params, void *user_ctx) } gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 2)->data, - get_param(params, 1)->val_ull); - if (target_memory_rw_debug(gdbserver_state.g_cpu, - get_param(params, 0)->val_ull, - gdbserver_state.mem_buf->data, - gdbserver_state.mem_buf->len, true)) { + get_param(params, 1)->val_ull); + if (gdb_target_memory_rw_debug(gdbserver_state.g_cpu, + get_param(params, 0)->val_ull, + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len, true)) { gdb_put_packet("E14"); return; } @@ -1223,10 +1196,10 @@ static void handle_read_mem(GArray *params, void *user_ctx) g_byte_array_set_size(gdbserver_state.mem_buf, get_param(params, 1)->val_ull); - if (target_memory_rw_debug(gdbserver_state.g_cpu, - get_param(params, 0)->val_ull, - gdbserver_state.mem_buf->data, - gdbserver_state.mem_buf->len, false)) { + if (gdb_target_memory_rw_debug(gdbserver_state.g_cpu, + get_param(params, 0)->val_ull, + gdbserver_state.mem_buf->data, + gdbserver_state.mem_buf->len, false)) { gdb_put_packet("E14"); return; } @@ -1676,30 +1649,6 @@ static void handle_query_qemu_supported(GArray *params, void *user_ctx) gdb_put_strbuf(); } -#ifndef CONFIG_USER_ONLY -static void handle_query_qemu_phy_mem_mode(GArray *params, - void *user_ctx) -{ - g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); - gdb_put_strbuf(); -} - -static void handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) -{ - if (!params->len) { - gdb_put_packet("E22"); - return; - } - - if (!get_param(params, 0)->val_ul) { - phy_memory_mode = 0; - } else { - phy_memory_mode = 1; - } - gdb_put_packet("OK"); -} -#endif - static const GdbCmdParseEntry gdb_gen_query_set_common_table[] = { /* Order is important if has same prefix */ { @@ -1790,7 +1739,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { }, #ifndef CONFIG_USER_ONLY { - .handler = handle_query_qemu_phy_mem_mode, + .handler = gdb_handle_query_qemu_phy_mem_mode, .cmd = "qemu.PhyMemMode", }, #endif @@ -1806,7 +1755,7 @@ static const GdbCmdParseEntry gdb_gen_set_table[] = { }, #ifndef CONFIG_USER_ONLY { - .handler = handle_set_qemu_phy_mem_mode, + .handler = gdb_handle_set_qemu_phy_mem_mode, .cmd = "qemu.PhyMemMode:", .cmd_startswith = 1, .schema = "l0" diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 7c180b779a..ab2d182654 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -413,9 +413,60 @@ void gdb_exit(int code) qemu_chr_fe_deinit(&gdbserver_system_state.chr, true); } +/* + * Memory access + */ +static int phy_memory_mode; + +int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, + uint8_t *buf, int len, bool is_write) +{ + CPUClass *cc; + + if (phy_memory_mode) { + if (is_write) { + cpu_physical_memory_write(addr, buf, len); + } else { + cpu_physical_memory_read(addr, buf, len); + } + return 0; + } + + cc = CPU_GET_CLASS(cpu); + if (cc->memory_rw_debug) { + return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + } + + return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); +} + + /* * Softmmu specific command helpers */ + +void gdb_handle_query_qemu_phy_mem_mode(GArray *params, + void *user_ctx) +{ + g_string_printf(gdbserver_state.str_buf, "%d", phy_memory_mode); + gdb_put_strbuf(); +} + +void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx) +{ + if (!params->len) { + gdb_put_packet("E22"); + return; + } + + if (!get_param(params, 0)->val_ul) { + phy_memory_mode = 0; + } else { + phy_memory_mode = 1; + } + gdb_put_packet("OK"); +} + void gdb_handle_query_rcmd(GArray *params, void *user_ctx) { const guint8 zero = 0; diff --git a/gdbstub/user.c b/gdbstub/user.c index c0fd83b373..92663d971c 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -378,6 +378,21 @@ int gdb_continue_partial(char *newstates) return res; } +/* + * Memory access helpers + */ +int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, + uint8_t *buf, int len, bool is_write) +{ + CPUClass *cc; + + cc = CPU_GET_CLASS(cpu); + if (cc->memory_rw_debug) { + return cc->memory_rw_debug(cpu, addr, buf, len, is_write); + } + return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); +} + /* * Break/Watch point helpers */ From patchwork Fri Mar 3 02:57:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658463 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226228wrb; Thu, 2 Mar 2023 19:01:18 -0800 (PST) X-Google-Smtp-Source: AK7set9SNOMqbwThC/ynjyuqh819f5JEbzjBoF2o++k1jocucTCwnt1w5AYGdmzCZ203rTfiv83f X-Received: by 2002:ac8:4e4a:0:b0:3b9:f4a0:e600 with SMTP id e10-20020ac84e4a000000b003b9f4a0e600mr704716qtw.60.1677812478216; Thu, 02 Mar 2023 19:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812478; cv=none; d=google.com; s=arc-20160816; b=m1LHxNB3TfL1JGxp62FFdO4RyyZpWmRMSSk6SBzLGpbGm5h2m/0QZDBBjtavEcN+8z hwjBFEb4XSwwylnxu78ClqgycZ8TXV5w6H4t4kCzPvu0o+To0HxkGXQ3ncFNAe7qp29v ZaYK4tlcSWeKzFb8rCklqQhqtRv0sx9XDD6+Gk/pOqLgilvBAaA0SnNixYRZu4E3KAib epFYGwFdz5iK96Ll9H3YJOxXulszoNLMYuJPJJlRwBLUbXRJcSpKbNrNuUft6m69Md5A VoMWtBrvpxEoE2lT5Utu83CDF0EXB3GMvmDURgP1o0o1yAP3CNyAGx/hXeA46T9sPtDI Y04w== 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=0RJIg00y/BLwJT+k/hiSB5cxap6R4zeMUcvwTCmvvhvuCzC7/MF8ek7vNztAEH4Kq4 sfH16hcUrcrmJKKevusAr9TS0Z80XlGO+L7CVzS2oLqtodjUvES7zkpKdLRjLYHu7otK RB8kjKgxlqQpP1VRonzSqEGz6i7b8aCo9ARQ2JTDz0D0vWkJ6pxx79Te5Aqbjy5R3h8J 4FDl33FEWu2iiEmy1h7gAG1uxPaHgF0/MP/G5NlaNfstagBNOgRQUnt5s2xl+ldQf3r2 SPZnrVVIgPOqHT0vgYKJeKKgiBwtOJlsaVqEFI1oWkXls6F48mFcH7RXTTmRZJbKJ+fN t1Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KksIPJN2; 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 b15-20020ac801cf000000b003b68cf4ae53si878532qtg.505.2023.03.02.19.01.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:01:18 -0800 (PST) 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=KksIPJN2; 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 1pXvco-0007WE-MB; Thu, 02 Mar 2023 21:58:26 -0500 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 1pXvcl-0007Ua-E0 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcj-0001ou-MD for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:23 -0500 Received: by mail-pj1-x1031.google.com with SMTP id x34so1210009pjj.0 for ; Thu, 02 Mar 2023 18:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812301; 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=KksIPJN2jDvsGZjjtxBd96APwfcAAkQTUQzr5RgyG8to8hnhVD8BrCWSKVulK20iQP f+BmpEiWOKM11NT1kWWYWJjFQtBvK+ubSTe0uwRVxU+tWNEnNML8Y8w5qgumyE1e4Jpt oC09KQaZM1WzOLHF6iuiiWVAECsz4krJj9tpXl4HzWJqBwRt73fE1GvM/fExZA2HGdWC 3zs79m+Rtz1Idl8ezm1DpwcDtRPEnNzCZ1xW+6WwL2rQyB19Ez+bxBW9Ji+HvdWRkFI1 mVYPdzPFOMFklEo1D8XOWNWVf1MgakrDNT+3ogxZTKwzxz+KMcCdquMEx0YKftNDCIxd 56jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812301; 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=3WIxe+smKoqvvD+KwVzWzoBm2ZPTc7NcUurnb42ciEE=; b=V3ekmxUJeY8eYz4/DEQcnA6ad1l3M0jAFPURhz81RswLEPcmuiDVpUfPtt48DMpTbL vJFdVT9cxJrxQPpgFd6OPM1UZLx2PGHA6kLWH4LLN5c/R7268bx93GcAGUv2wpjiw5A+ p1UkU8wwTfCLLHOHyzbWV1P1gkQ+A0p4HXszSRzXtXnKSZszvYFg5IFTWbRkqq4GDxmK CVaDH2w3RezA6IJL/d/dhCnsNqjUW85e+MoXHQJxUVscKD4FGzivAVxPmKqQ2fhtkYXN ZC4bdoBkqqi8mn5Sr5sMyuV7wOdmjeRp5s9yw41SoZVgcX7n2F2elmc7p5MNn5QBEHB6 4lVw== X-Gm-Message-State: AO0yUKVlZAqLsP2iIgKmI2jzpAl4aqId82rEAuVo2wVtfLH4qoGos0Z4 cBRn0IUNtXH0vjnBWELTs04AU9EmIBB0Tjmimbo= X-Received: by 2002:a17:903:1d2:b0:19c:be07:4af2 with SMTP id e18-20020a17090301d200b0019cbe074af2mr594838plh.45.1677812300880; Thu, 02 Mar 2023 18:58:20 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 16/29] gdbstub: introduce gdb_get_max_cpus Date: Thu, 2 Mar 2023 18:57:52 -0800 Message-Id: <20230303025805.625589-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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 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: Alex Bennée This is needed for handling vcont packets as the way of calculating max cpus vhanges between user and softmmu mode. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-17-alex.bennee@linaro.org> --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 11 +---------- gdbstub/softmmu.c | 9 +++++++++ gdbstub/user.c | 17 +++++++++++++++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index d8c0292d99..26a6468a69 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -129,6 +129,7 @@ bool gdb_got_immediate_ack(void); CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); int gdb_get_cpu_index(CPUState *cpu); +unsigned int gdb_get_max_cpus(void); /* both */ void gdb_create_default_process(GDBState *s); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ed38ab0aaa..1b783100c2 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -624,16 +624,7 @@ static int gdb_handle_vcont(const char *p) GDBProcess *process; CPUState *cpu; GDBThreadIdKind kind; -#ifdef CONFIG_USER_ONLY - int max_cpus = 1; /* global variable max_cpus exists only in system mode */ - - CPU_FOREACH(cpu) { - max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus; - } -#else - MachineState *ms = MACHINE(qdev_get_machine()); - unsigned int max_cpus = ms->smp.max_cpus; -#endif + unsigned int max_cpus = gdb_get_max_cpus(); /* uninitialised CPUs stay 0 */ newstates = g_new0(char, max_cpus); diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index ab2d182654..3a5587d387 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -440,6 +440,15 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } +/* + * cpu helpers + */ + +unsigned int gdb_get_max_cpus(void) +{ + MachineState *ms = MACHINE(qdev_get_machine()); + return ms->smp.max_cpus; +} /* * Softmmu specific command helpers diff --git a/gdbstub/user.c b/gdbstub/user.c index 92663d971c..e10988a62b 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -393,6 +393,23 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr, return cpu_memory_rw_debug(cpu, addr, buf, len, is_write); } +/* + * cpu helpers + */ + +unsigned int gdb_get_max_cpus(void) +{ + CPUState *cpu; + unsigned int max_cpus = 1; + + CPU_FOREACH(cpu) { + max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus; + } + + return max_cpus; +} + + /* * Break/Watch point helpers */ From patchwork Fri Mar 3 02:57:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658472 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226841wrb; Thu, 2 Mar 2023 19:02:40 -0800 (PST) X-Google-Smtp-Source: AK7set8RuT+D1U6+qydAH0Fp47aarATj1Rt+JzHcJBKRmk7cD641JwEhztVbBJC8tOedCrH6lxsQ X-Received: by 2002:a05:622a:2cc:b0:3bf:de2e:6165 with SMTP id a12-20020a05622a02cc00b003bfde2e6165mr650218qtx.56.1677812560239; Thu, 02 Mar 2023 19:02:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812560; cv=none; d=google.com; s=arc-20160816; b=Uc8M0Qr06zOODUD0hbsw/cM2Gt1Hpkatly3ae24NTP4MHIi2uqUf1KRHnmz7w4x4fB hpMm7+0KKAdwnwjSJVr6wV1L/mZd8Q2oYs0s0CcJYByVIfgiBL/hGErOUYk8+BNgTSwF bYWTsdXNhDvKL98mZPLntoTNnj84Qgs+VQ5iWYa+lnZaieoE5Tb/csIKivnTr9b2IjvK 9A2+h/hkVPZOvwY+WlJTociwbhpV1Qr/btWHzcR2XwiBsHjSjo3gaz616l6Z+3yFNL9Y AlED7TYPLZHTRpqJw3i95vukxxM6UlLmTXWfpu6VOWogXQEFiS+Ty9I4gg9G9Rh6mA1S BBEg== 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=IZ1Q69yObMWzKVjZpAHDz6uWngdi7nRVdbETM5dlXlg=; b=jPDHOPApJeMkwmPo9iJBrZiK+g2B0tfMPKpHsp6SfgmvkdFp0/B6UTV7D7+XO3x7cB 8Kh1IBfx7yM7fM/wu4lqSVUUAM/24ojFZ69mLNL0A5C7ERtG0ug+M0gNDwOPd6L7Hylb nlCHZrrbQYUCEdV3GKRpegAEVzJvIcLF3C6qr7CFMISp/GJDPDGdV2t8470pZ8N/z9lA ALGdYsFRVozPkrzOgDWPDlhvBaDiEBNl2JsbYayczVqsTYOCclf07eWdPZWgvwJCLetS 0N1SYYTTdyzDBttp4rjticqiu87Xqvmu2r/hZjhPafKkD3KZ/C6lzLTJUCL8OjBXQUtR Azxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xo0UXvk1; 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 bp20-20020a05620a459400b007424e7e1e07si1112599qkb.303.2023.03.02.19.02.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:02:40 -0800 (PST) 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=xo0UXvk1; 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 1pXvco-0007Va-8O; Thu, 02 Mar 2023 21:58:26 -0500 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 1pXvcn-0007VB-0x for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:25 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcl-0001r7-8m for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:24 -0500 Received: by mail-pl1-x62d.google.com with SMTP id h8so1315993plf.10 for ; Thu, 02 Mar 2023 18:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812302; 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=IZ1Q69yObMWzKVjZpAHDz6uWngdi7nRVdbETM5dlXlg=; b=xo0UXvk1TGZ1HfUuDaj07iZE2n10h20QkBB1xcTnOwUvjTcn1L+eavlpIIMeh8/0fx e6Kybe/IJluDRHGee0fDAdRkvj4uZVx074uZcyRgfNJytG0Qsoh4oxzgZdW4IaBzSC+M GrNZVWBOfS9i4YsXnTvWmHL9ajRevmOxTpLtHdfDk1Y82nvaCJZlvZb1HvYxXJzgTdnS f6W5lIvaeQXo97Rpx364i7rWU9hplhFux/kfOFp7H8rkUDpL3c9ozn1FxMBYU5Xlmjth 9Eo7CudXVGZNx1xQrLKv9TNwyf1txnl5LogXrCUSWu0qIBmwulZIvBGmVAgUXBIVT+8n qjTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812302; 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=IZ1Q69yObMWzKVjZpAHDz6uWngdi7nRVdbETM5dlXlg=; b=fIPtwx4gLjM3CTzf0PZslqmKHzT2cHEYDNQ2Ys67OElCzmAX/wTF5AwveglaQx5pPF iNKzhUWmk+BjNkzNIiiBcLdsLqPD1FeHY025O9BFUsSwR2Z2bZ8n3k2FpUrKAPCoAlBG eUwcnLHA709TqDBYtgtYn6fzVN/7kIEkh2hiEQmbnGrUw9pvxx+M62pMdcmk1eGXK3wf GfNlG3zBrcfB9rxGraYOEyu3M+tlwSnjWPZTw7aBIZBHiDgLNujoIWLv/W777Sx+QMiw Eumaf0q3RN1hUPBTgTK/3IgFOzsql+/bnQDT8Bd6fj5CIui95LdrOWY16/5z7WnSB0b+ d+9A== X-Gm-Message-State: AO0yUKX1WEkx7NCrtP3XUfbyHtmKN3Pz/d8srQmsq5zd7Da9LivSKDQ9 K6WU8kb47IM8OVotWOwgmvI04ZukRoABWbWsmAo= X-Received: by 2002:a17:902:c94f:b0:19e:73df:b0e9 with SMTP id i15-20020a170902c94f00b0019e73dfb0e9mr560756pla.21.1677812301696; Thu, 02 Mar 2023 18:58:21 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 17/29] gdbstub: specialise stub_can_reverse Date: Thu, 2 Mar 2023 18:57:53 -0800 Message-Id: <20230303025805.625589-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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 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: Alex Bennée Currently we only support replay for softmmu mode so it is a constant false for user-mode. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-18-alex.bennee@linaro.org> --- gdbstub/internals.h | 1 + gdbstub/gdbstub.c | 13 ++----------- gdbstub/softmmu.c | 5 +++++ gdbstub/user.c | 5 +++++ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 26a6468a69..be0eef4850 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -130,6 +130,7 @@ CPUState *gdb_first_attached_cpu(void); void gdb_append_thread_id(CPUState *cpu, GString *buf); int gdb_get_cpu_index(CPUState *cpu); unsigned int gdb_get_max_cpus(void); /* both */ +bool gdb_can_reverse(void); /* softmmu, stub for user */ void gdb_create_default_process(GDBState *s); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 1b783100c2..7301466ff5 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -113,15 +113,6 @@ int use_gdb_syscalls(void) return gdb_syscall_mode == GDB_SYS_ENABLED; } -static bool stub_can_reverse(void) -{ -#ifdef CONFIG_USER_ONLY - return false; -#else - return replay_mode == REPLAY_MODE_PLAY; -#endif -} - /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { @@ -1308,7 +1299,7 @@ static void handle_step(GArray *params, void *user_ctx) static void handle_backward(GArray *params, void *user_ctx) { - if (!stub_can_reverse()) { + if (!gdb_can_reverse()) { gdb_put_packet("E22"); } if (params->len == 1) { @@ -1559,7 +1550,7 @@ static void handle_query_supported(GArray *params, void *user_ctx) g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+"); } - if (stub_can_reverse()) { + if (gdb_can_reverse()) { g_string_append(gdbserver_state.str_buf, ";ReverseStep+;ReverseContinue+"); } diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 3a5587d387..d2863d0663 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -450,6 +450,11 @@ unsigned int gdb_get_max_cpus(void) return ms->smp.max_cpus; } +bool gdb_can_reverse(void) +{ + return replay_mode == REPLAY_MODE_PLAY; +} + /* * Softmmu specific command helpers */ diff --git a/gdbstub/user.c b/gdbstub/user.c index e10988a62b..3f6183e66a 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -409,6 +409,11 @@ unsigned int gdb_get_max_cpus(void) return max_cpus; } +/* replay not supported for user-mode */ +bool gdb_can_reverse(void) +{ + return false; +} /* * Break/Watch point helpers From patchwork Fri Mar 3 02:57:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658459 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226010wrb; Thu, 2 Mar 2023 19:00:55 -0800 (PST) X-Google-Smtp-Source: AK7set+IlbibEjYSCdCdbwyCtR9ifaeC2nUi+PWqoAgaP66DfsfdtWxOq8MJZxYrCSbacdNCicTP X-Received: by 2002:a05:6214:405:b0:56e:bb5b:3dfc with SMTP id z5-20020a056214040500b0056ebb5b3dfcmr602838qvx.38.1677812454690; Thu, 02 Mar 2023 19:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812454; cv=none; d=google.com; s=arc-20160816; b=X3IEYyzlHRvluo+8Zv4RgHcU69L4P8xQHqwwkg3Kmtzq02j+S57Du9pAH5Cyq3/Ln9 Rat9/hpoIPKl/LZtryDfSQGowcwa0Pqu6vXL0PqaFuT+grlq/HSh+rYDlfAmJ03fPMmI 0JPm7brn0e526aytw5f/Zn0ibMGXxYSwJIs4MGBBWQ1J+iJxnL5eXK101IVxem2p6+b7 10FUst+ko7E5loqWNoINrq7sHIZyRZ0wioXoFQ2rmm3qvHLqWjb/B3OBG09zSbt1o9Rl UmB7oxCLDaZCuPWdcmnu9qr4GbJ3jbeSEOtEGgTtoHvqXjO8NFWWuY9/SRvMvw/nB6st 3r0w== 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=Wh4TGmta6KxxW4dXBB2Rrca4W4QJFWocfsDlY9pkBAI=; b=w24oCrsYvjbo7yW6QGGTsY+0t7TfvCWq2RwaAF9zLM8GNhjArj7fbbWCcdjpyb+6Uw wXDmAQDoZ5NWuA1u9Qx7SI+srUe/gwKmN5hXM9QVm0zoPuEloeKCagh1DoWIz+TwyP0I 81iVkvi9V6w3dytJzh57VqrGm77j2p7cjhWDy8iU9EBhWXsxwUQ6n04BjRovZEh7GdSd qBWHDlJWXYOszvRkvPWWkqINwa1e8T7QNHX3e+/0udgi7sBQcjEL8zYpO5qJn5PiIbwH JAAcBH2oIVW/lvfyeL0qNb+v7jZdgww459h0fmUW37RPIcSMmfn7eIbXRWwFC/ohGi7Z cNeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZDa5PO+z; 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 q19-20020a0ce213000000b005722e511df1si676482qvl.194.2023.03.02.19.00.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:54 -0800 (PST) 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=ZDa5PO+z; 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 1pXvcp-0007XL-Sp; Thu, 02 Mar 2023 21:58:27 -0500 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 1pXvco-0007Vk-CV for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:26 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcl-0001s6-Vq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:26 -0500 Received: by mail-pl1-x62b.google.com with SMTP id a2so1357344plm.4 for ; Thu, 02 Mar 2023 18:58:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812302; 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=Wh4TGmta6KxxW4dXBB2Rrca4W4QJFWocfsDlY9pkBAI=; b=ZDa5PO+zBCiVL2e0e6EO7+8jePdHFOXeUPD3s/Qks0ANq4FahMk39oKhOwOV2EFNLo 6u6YKkrJgXrAXbJa0VshPjxP2iEzox31MckeA+yYbaxgj+RIP8D43Ihxpo6WxEmmGdOj 0tb0UNFbTAieu8M0lHBMo0K7/a9v44UByCd5oGRDMZgDNBlZyrfhtX9WJ9pN2sr2TXYX mgrYxt5lkficjeoSQkVwLqfmvq1x57njBR7dY7NRul2/zABzYrb4gwObrJPoF+dLwySt 1BqkwmIM6h/2leA32kAnkqUg5FZ+SNc6MQm7wWbnTeyeWUlW7GDv/xOokxedqVcvV0zA 0xHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812302; 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=Wh4TGmta6KxxW4dXBB2Rrca4W4QJFWocfsDlY9pkBAI=; b=tyIbFpmZEXxDXnBsSosKJUaBLXGQA+A5Ym2W4FExn/CqB4lc0qh6avw72kv6BKvLOK Kt604+v779ue4onRTEZC9le2z4DY8OL6/d8a5hipMBtVntoM5TQGevFyXe/rGBee7a+t g4KH7Y+pXhVZ+rFVCxXkoHBAyJ2lSfP7LRdqs+qtmzbND3gRQ4sa+9scR6rCm9BprxdP jLijfG3PsRwAvS91Koogo37Bq1GxvKY7/D1tT61jRad4RWvpjFRLKgXLEqno+wKF9jtb ENvQntruJodWpj7IUQCSXFfiwk5BYFMf0d5u3p7zzmRxJFavXK0VddxQDcnGSrlZoJJr gRcg== X-Gm-Message-State: AO0yUKW6YJEzmSQF+NjCC+YpCN0zEIFMWVEGfszEE7wS5rWlpMTh4dcE DOsRN8FI3kDz2Z0UHJIM2YGITMcmM+0SdMLm2aM= X-Received: by 2002:a17:902:e54f:b0:19c:b4e3:c65b with SMTP id n15-20020a170902e54f00b0019cb4e3c65bmr659386plf.8.1677812302499; Thu, 02 Mar 2023 18:58:22 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 18/29] gdbstub: fix address type of gdb_set_cpu_pc Date: Thu, 2 Mar 2023 18:57:54 -0800 Message-Id: <20230303025805.625589-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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 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: Alex Bennée The underlying call uses vaddr and the comms API uses unsigned long long which will always fit. We don't need to deal in target_ulong here. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-19-alex.bennee@linaro.org> --- gdbstub/gdbstub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 7301466ff5..b8aead03bd 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -535,7 +535,7 @@ static void gdb_process_breakpoint_remove_all(GDBProcess *p) } -static void gdb_set_cpu_pc(target_ulong pc) +static void gdb_set_cpu_pc(vaddr pc) { CPUState *cpu = gdbserver_state.c_cpu; @@ -1290,7 +1290,7 @@ static void handle_file_io(GArray *params, void *user_ctx) static void handle_step(GArray *params, void *user_ctx) { if (params->len) { - gdb_set_cpu_pc((target_ulong)get_param(params, 0)->val_ull); + gdb_set_cpu_pc(get_param(params, 0)->val_ull); } cpu_single_step(gdbserver_state.c_cpu, gdbserver_state.sstep_flags); From patchwork Fri Mar 3 02:57:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658461 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226029wrb; Thu, 2 Mar 2023 19:00:56 -0800 (PST) X-Google-Smtp-Source: AK7set8gXv5eVbWxJsH3SjgcLCP61WBEHSKGFNjmjhfQ99dRzH2z+A549QzjgTLHnALz6WXDTW3z X-Received: by 2002:a05:6214:262e:b0:56e:c1f5:137d with SMTP id gv14-20020a056214262e00b0056ec1f5137dmr674521qvb.29.1677812456654; Thu, 02 Mar 2023 19:00:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812456; cv=none; d=google.com; s=arc-20160816; b=RpVc5H9dOchSqJ6PQ+wr9osTpDr47wk4boQcWCf2YSu/llPdAwofOd7FUOMowHXvAF Sx60Ppj8ngqFg3fVfXM1/g9mWS+Wn7C13dKu8+N9oCOFPZoqeRD5i7b7pcVDnm/lfwv3 lFgv6gS6uMVZOzvmjPhCL1YcAqEWEwrGa0xz3ERd08kZQmxdHZ+3ln/R0/mxrP0Zriwb UFJG1FW6FsSLJ/qDhzcg/erFrY6Wy9phEAJK8UIeTfj9J+gWD5zGBKxUr3Ovr6xQDsHV X6c9lhr1apir6Gg8vCjQRtnskINfN1YKsuxewP8A5pPgGq8hnVt8JOkXPDho/6/bfjQM RaLA== 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=KJ4GfexeOkE0loC2ShPfg/ZNhK8OhXGDTJcqqyP7xeg=; b=gIag6FxVXZHPSk3H5/aw6fq5KxDMIVeoDHAMb6ShnVqUrNj4/bO1wYD6muC05Mimmk 26u9ovWaVEvFqiDI5rYvWsRL/MAv1KYz7+T52khcji2p+AqmROHbV6Z5/atSLVEqUBeB C57igNlZo6keegrEgdK+4PiC+EiqZ8GHIx8g+CX8uqhptowzZnKi16BblPI5GZfH4NyQ CVwVN6johpSymXmBEmDS3dWg2huyN6qxXb8hXlHe9CEpQlbpigrhUJy7vxOBAajH0OFL FHxQG4IRkTGhZjkkIZYnAwHOHNmkcMW1nspyTUixn2roONcjUUeioP0gaLOtrUNeb+we GwEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WvfKREH7; 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 z205-20020a3765d6000000b007250f6f7202si928884qkb.209.2023.03.02.19.00.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:56 -0800 (PST) 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=WvfKREH7; 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 1pXvcp-0007Wk-AN; Thu, 02 Mar 2023 21:58:27 -0500 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 1pXvcn-0007VM-Ib for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:25 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcl-0001q5-Uz for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:25 -0500 Received: by mail-pl1-x62c.google.com with SMTP id z2so1304207plf.12 for ; Thu, 02 Mar 2023 18:58:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812303; 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=KJ4GfexeOkE0loC2ShPfg/ZNhK8OhXGDTJcqqyP7xeg=; b=WvfKREH74zSU6SOrM+cbWJhy58mfCltqdqf9hbiCj/XijbahjhE9aP6rL52vvdvrp7 iXHjug+5eeg72ws8OgHS0HhW8GT0/FvTROCm0BqO4EAHjsBhFVlawWnunbvHlHWVvUv2 lVIOA+xTMsBzmMLlvX1izslg/aGeLH1ncac2wCFKSp6zq/kbITmAF/e1nNt49oNuiQGc 24hrgD5ub/kDk98VaGBB5fTxoQqn1EjPcIWrXC3Gog3rCoQVm0wJkEjCZd98cL0JCvxV 2rjFQLwqcpPU2GX0qJpFaFcMf47fkiB0Pqco34uBVRcPC041J2MRAGb8x8cdjQv5zR3B Gmzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812303; 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=KJ4GfexeOkE0loC2ShPfg/ZNhK8OhXGDTJcqqyP7xeg=; b=U3Jjw+pSH6lRDiszb/7ODSY3UCcYMH+y1INP/AAKC6cUDXhIT0au24ypn5Kvlc20tD dfc93kWZB7N9gbDYUqjR333a/9OD5+ugZiF/X/twhAx+m66oECXAWM4F78F66bx6tH/d 8sRnmwYnXZhhUKMZRHhyhLFaMD0iSa2WV5QeIxBIpb4f5Tb0gvULQp+RPQnV/Q18gioo pXW1/2OoiEyp6o6Hghwl2HjiFCqxVxPhIpJrWFRm1NXJPGG+E6C7PKA2XqVC3YuVLLRB 0hjKXsj/fiXslokTszJouNJa/NJoQ9Cf4C/ChIK7x2tuWi+ibjafn3fWi7+jhKqbfKo7 nhQw== X-Gm-Message-State: AO0yUKVWXB/OYFVkkc1dtxQfAgJUgoWvwtLzjf0sM+xzHANXi1XksECT QIBwdh+duJe3UyhaqVvOyEJ1GonBLMOwchJcGqs= X-Received: by 2002:a17:902:e549:b0:19e:76c4:2d30 with SMTP id n9-20020a170902e54900b0019e76c42d30mr542646plf.61.1677812303207; Thu, 02 Mar 2023 18:58:23 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 19/29] gdbstub: don't use target_ulong while handling registers Date: Thu, 2 Mar 2023 18:57:55 -0800 Message-Id: <20230303025805.625589-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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 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: Alex Bennée This is a hangover from the original code. addr is misleading as it is only really a register id. While len will never exceed MAX_PACKET_LENGTH I've used size_t as that is what strlen returns. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-20-alex.bennee@linaro.org> --- gdbstub/gdbstub.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index b8aead03bd..f1504af44f 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -1193,7 +1193,8 @@ static void handle_read_mem(GArray *params, void *user_ctx) static void handle_write_all_regs(GArray *params, void *user_ctx) { - target_ulong addr, len; + int reg_id; + size_t len; uint8_t *registers; int reg_size; @@ -1205,9 +1206,10 @@ static void handle_write_all_regs(GArray *params, void *user_ctx) len = strlen(get_param(params, 0)->data) / 2; gdb_hextomem(gdbserver_state.mem_buf, get_param(params, 0)->data, len); registers = gdbserver_state.mem_buf->data; - for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0; - addr++) { - reg_size = gdb_write_register(gdbserver_state.g_cpu, registers, addr); + for (reg_id = 0; + reg_id < gdbserver_state.g_cpu->gdb_num_g_regs && len > 0; + reg_id++) { + reg_size = gdb_write_register(gdbserver_state.g_cpu, registers, reg_id); len -= reg_size; registers += reg_size; } @@ -1216,15 +1218,16 @@ static void handle_write_all_regs(GArray *params, void *user_ctx) static void handle_read_all_regs(GArray *params, void *user_ctx) { - target_ulong addr, len; + int reg_id; + size_t len; cpu_synchronize_state(gdbserver_state.g_cpu); g_byte_array_set_size(gdbserver_state.mem_buf, 0); len = 0; - for (addr = 0; addr < gdbserver_state.g_cpu->gdb_num_g_regs; addr++) { + for (reg_id = 0; reg_id < gdbserver_state.g_cpu->gdb_num_g_regs; reg_id++) { len += gdb_read_register(gdbserver_state.g_cpu, gdbserver_state.mem_buf, - addr); + reg_id); } g_assert(len == gdbserver_state.mem_buf->len); From patchwork Fri Mar 3 02:57:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658457 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225873wrb; Thu, 2 Mar 2023 19:00:38 -0800 (PST) X-Google-Smtp-Source: AK7set/6jtOVnaZSCUr58XdFrbecpkPOvoTvbypKyIhlHcLaqxPnJ2EHkm9JXvateqWhVcQSt3Ow X-Received: by 2002:a05:6214:238e:b0:572:5a16:51c0 with SMTP id fw14-20020a056214238e00b005725a1651c0mr661369qvb.16.1677812438353; Thu, 02 Mar 2023 19:00:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812438; cv=none; d=google.com; s=arc-20160816; b=m/chJz2A9uiTSAd5n1YxF6yiIoU1t+I6prNh7ju68ZV7IFzDnZVRR8u3wUNkDg1Yxb GPFeU4phIG1iOLiQLOKM7/vRXmFAOjtVmJByVHZd8z579Fitr6PfcVdgUMc9Ey1zlSus pVt3Smkh6+G75/FmDMscdSlVhXny3kNekE3FzDENOvpLIpikWjzIJRrkhEQ7Nh8v9FAW ETYW6sms+GLvn7j0fykIOCiPis5T5dtOkOUBiRKFX/9s+RjG8jzlxTt3TYNK16WV+U2/ e5phPjE8BR7Cd5ZAkIxm/4BfIWufL/a8+Y6+V6aSNZ03sAbm8FW07Efm5oDH4ORSRTdG 4Jhg== 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=CMWr8hu2DUhhMopayYGFX1AvPPyHQPBspx9QuL7Pv04=; b=js51LbITDrN8I07Z+7I0smjBL63DbDywkoYEFKS+2Ly9a0G/HbIFidFP85xKR1jHhC BpNtWaddhGxWjpgzUcYDrU4DlvQ8LJBbCEu5L4g3c9XtA6u7J5Qrc7irZbuvubw08lxb oAHv54Y/lF70su4c4kJYM32Rpe8cVsEZzAVDaLhp2eumYHVo5aimHAiN9YAWjtN2hvWw PQCRWh4jfKucZS52Yna8v6/WU+4f45S5pJ7LvuUfLoNUMkYIvD4vxha3kWmYl3kPbdXP z5GSi1BPubUZBe9iOUKrygroV+gubFrKER97g7q/VRSxNnj/bAGQACWjlPFB8Dr9v/hZ Y7Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j1xzuovA; 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 w19-20020ac857d3000000b003b9b6ab38f3si1035275qta.441.2023.03.02.19.00.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:38 -0800 (PST) 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=j1xzuovA; 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 1pXvcs-0007as-HX; Thu, 02 Mar 2023 21:58:30 -0500 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 1pXvcr-0007a5-05 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:29 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcn-0001t1-Qn for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:28 -0500 Received: by mail-pl1-x635.google.com with SMTP id n6so1349474plf.5 for ; Thu, 02 Mar 2023 18:58:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812304; 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=CMWr8hu2DUhhMopayYGFX1AvPPyHQPBspx9QuL7Pv04=; b=j1xzuovAaNsIROvcsbkqSGUMectFMHoRYkFqSPO4SGGp/lqqs0ZQQam1Yu0c1EnS2B ypI50q2hAqR8uRMSzO0fk65OuSed7QyWkOAaObgJpkIscUy3VLoe4Je3gMS3tNfbhKnh S0nVrwkBYc4ZnwPfWRjJ5NY+A6/alXVSppoqj8SlL/R2dm1pSoFlMy1/vnO9VACo0c+m 7VUCxRMx6KTAn+cmBTziqkAOx4Pm14tBPSN0EI6hIsHZZPWzB/JBXZyzi4zKfbqkWopC EWBkdI7t+P3h84fCBgoCPc7DdVdzZISjipoVlAqK0dP4HE74nwh+WV53rwlAfkDqClAj bwuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812304; 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=CMWr8hu2DUhhMopayYGFX1AvPPyHQPBspx9QuL7Pv04=; b=bFAqqcUtJ0fX5Bw3p/aLHopJjkV4xy3om6ZGcTYhXkA+Ba4MvIb3PDwK7uYTnO3ISx gOp//HGnKKVABLpdZ5oqA5+t9y9lafAdAOAwuAeCijToeXx6CTvmk1DSmcfKec0JctyF +E+ljMDARQdABYr6UVQGvRElQSX3vkx1yooVLgm1E/CAgCbzjcdzx/0bBqQkdlbftJ1n HY+bw4cUpIGJWrhg8Y3m2SqrBLDAxLigQn+mZniN0644Rp8ydPBxul0ZxlauBIMh3CsT FIAblcL2r5r2CSwMJy34Ltp+BtqyeXhecR6nJiJg81Yzb2FfiImcpLpkuNIMSHKqQb3D vY1w== X-Gm-Message-State: AO0yUKUeB0oqPRFyc+vDZFQAH3uHEeYfjax8ZfP/mrZzqUYM/5tlU7V8 L2rCprKFHoVOG1mBCaEMnvKZhGnJ4vIdJ+zWohk= X-Received: by 2002:a17:902:8bcb:b0:19e:664e:fcaf with SMTP id r11-20020a1709028bcb00b0019e664efcafmr546141plo.0.1677812304142; Thu, 02 Mar 2023 18:58:24 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Taylor Simpson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 20/29] gdbstub: move register helpers into standalone include Date: Thu, 2 Mar 2023 18:57:56 -0800 Message-Id: <20230303025805.625589-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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 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: Alex Bennée These inline helpers are all used by target specific code so move them out of the general header so we don't needlessly pollute the rest of the API with target specific stuff. Note we have to include cpu.h in semihosting as it was relying on a side effect before. Reviewed-by: Taylor Simpson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-21-alex.bennee@linaro.org> --- include/exec/gdbstub.h | 86 --------------------- include/gdbstub/helpers.h | 103 +++++++++++++++++++++++++ semihosting/syscalls.c | 1 + target/alpha/gdbstub.c | 2 +- target/arm/gdbstub.c | 1 + target/arm/gdbstub64.c | 2 +- target/arm/tcg/helper-a64.c | 2 +- target/arm/tcg/m_helper.c | 1 + target/avr/gdbstub.c | 2 +- target/cris/gdbstub.c | 2 +- target/hexagon/gdbstub.c | 2 +- target/hppa/gdbstub.c | 2 +- target/i386/gdbstub.c | 2 +- target/i386/whpx/whpx-all.c | 2 +- target/loongarch/gdbstub.c | 1 + target/m68k/gdbstub.c | 2 +- target/m68k/helper.c | 1 + target/m68k/m68k-semi.c | 1 + target/microblaze/gdbstub.c | 2 +- target/mips/gdbstub.c | 2 +- target/mips/tcg/sysemu/mips-semi.c | 1 + target/nios2/cpu.c | 2 +- target/nios2/nios2-semi.c | 1 + target/openrisc/gdbstub.c | 2 +- target/openrisc/interrupt.c | 2 +- target/openrisc/mmu.c | 2 +- target/ppc/cpu_init.c | 2 +- target/ppc/gdbstub.c | 1 + target/riscv/gdbstub.c | 1 + target/rx/gdbstub.c | 2 +- target/s390x/gdbstub.c | 1 + target/s390x/helper.c | 2 +- target/sh4/gdbstub.c | 2 +- target/sparc/gdbstub.c | 2 +- target/tricore/gdbstub.c | 2 +- target/xtensa/core-dc232b.c | 2 +- target/xtensa/core-dc233c.c | 2 +- target/xtensa/core-de212.c | 2 +- target/xtensa/core-de233_fpu.c | 2 +- target/xtensa/core-dsp3400.c | 2 +- target/xtensa/core-fsf.c | 2 +- target/xtensa/core-lx106.c | 2 +- target/xtensa/core-sample_controller.c | 2 +- target/xtensa/core-test_kc705_be.c | 2 +- target/xtensa/core-test_mmuhifi_c3.c | 2 +- target/xtensa/gdbstub.c | 2 +- target/xtensa/helper.c | 2 +- target/xtensa/import_core.sh | 2 +- 48 files changed, 149 insertions(+), 121 deletions(-) create mode 100644 include/gdbstub/helpers.h diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index 8fff5450ed..bb8a3928dd 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -110,92 +110,6 @@ void gdb_register_coprocessor(CPUState *cpu, gdb_get_reg_cb get_reg, gdb_set_reg_cb set_reg, int num_regs, const char *xml, int g_pos); -#ifdef NEED_CPU_H -#include "cpu.h" - -/* - * The GDB remote protocol transfers values in target byte order. As - * the gdbstub may be batching up several register values we always - * append to the array. - */ - -static inline int gdb_get_reg8(GByteArray *buf, uint8_t val) -{ - g_byte_array_append(buf, &val, 1); - return 1; -} - -static inline int gdb_get_reg16(GByteArray *buf, uint16_t val) -{ - uint16_t to_word = tswap16(val); - g_byte_array_append(buf, (uint8_t *) &to_word, 2); - return 2; -} - -static inline int gdb_get_reg32(GByteArray *buf, uint32_t val) -{ - uint32_t to_long = tswap32(val); - g_byte_array_append(buf, (uint8_t *) &to_long, 4); - return 4; -} - -static inline int gdb_get_reg64(GByteArray *buf, uint64_t val) -{ - uint64_t to_quad = tswap64(val); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); - return 8; -} - -static inline int gdb_get_reg128(GByteArray *buf, uint64_t val_hi, - uint64_t val_lo) -{ - uint64_t to_quad; -#if TARGET_BIG_ENDIAN - to_quad = tswap64(val_hi); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); - to_quad = tswap64(val_lo); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); -#else - to_quad = tswap64(val_lo); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); - to_quad = tswap64(val_hi); - g_byte_array_append(buf, (uint8_t *) &to_quad, 8); -#endif - return 16; -} - -static inline int gdb_get_zeroes(GByteArray *array, size_t len) -{ - guint oldlen = array->len; - g_byte_array_set_size(array, oldlen + len); - memset(array->data + oldlen, 0, len); - - return len; -} - -/** - * gdb_get_reg_ptr: get pointer to start of last element - * @len: length of element - * - * This is a helper function to extract the pointer to the last - * element for additional processing. Some front-ends do additional - * dynamic swapping of the elements based on CPU state. - */ -static inline uint8_t * gdb_get_reg_ptr(GByteArray *buf, int len) -{ - return buf->data + buf->len - len; -} - -#if TARGET_LONG_BITS == 64 -#define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) -#define ldtul_p(addr) ldq_p(addr) -#else -#define gdb_get_regl(buf, val) gdb_get_reg32(buf, val) -#define ldtul_p(addr) ldl_p(addr) -#endif - -#endif /* NEED_CPU_H */ - /** * gdbserver_start: start the gdb server * @port_or_device: connection spec for gdb diff --git a/include/gdbstub/helpers.h b/include/gdbstub/helpers.h new file mode 100644 index 0000000000..c573aef2dc --- /dev/null +++ b/include/gdbstub/helpers.h @@ -0,0 +1,103 @@ +/* + * gdbstub helpers + * + * These are all used by the various frontends and have to be host + * aware to ensure things are store in target order. + * + * Copyright (c) 2022 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _GDBSTUB_HELPERS_H_ +#define _GDBSTUB_HELPERS_H_ + +#ifdef NEED_CPU_H +#include "cpu.h" + +/* + * The GDB remote protocol transfers values in target byte order. As + * the gdbstub may be batching up several register values we always + * append to the array. + */ + +static inline int gdb_get_reg8(GByteArray *buf, uint8_t val) +{ + g_byte_array_append(buf, &val, 1); + return 1; +} + +static inline int gdb_get_reg16(GByteArray *buf, uint16_t val) +{ + uint16_t to_word = tswap16(val); + g_byte_array_append(buf, (uint8_t *) &to_word, 2); + return 2; +} + +static inline int gdb_get_reg32(GByteArray *buf, uint32_t val) +{ + uint32_t to_long = tswap32(val); + g_byte_array_append(buf, (uint8_t *) &to_long, 4); + return 4; +} + +static inline int gdb_get_reg64(GByteArray *buf, uint64_t val) +{ + uint64_t to_quad = tswap64(val); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + return 8; +} + +static inline int gdb_get_reg128(GByteArray *buf, uint64_t val_hi, + uint64_t val_lo) +{ + uint64_t to_quad; +#if TARGET_BIG_ENDIAN + to_quad = tswap64(val_hi); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + to_quad = tswap64(val_lo); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); +#else + to_quad = tswap64(val_lo); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); + to_quad = tswap64(val_hi); + g_byte_array_append(buf, (uint8_t *) &to_quad, 8); +#endif + return 16; +} + +static inline int gdb_get_zeroes(GByteArray *array, size_t len) +{ + guint oldlen = array->len; + g_byte_array_set_size(array, oldlen + len); + memset(array->data + oldlen, 0, len); + + return len; +} + +/** + * gdb_get_reg_ptr: get pointer to start of last element + * @len: length of element + * + * This is a helper function to extract the pointer to the last + * element for additional processing. Some front-ends do additional + * dynamic swapping of the elements based on CPU state. + */ +static inline uint8_t *gdb_get_reg_ptr(GByteArray *buf, int len) +{ + return buf->data + buf->len - len; +} + +#if TARGET_LONG_BITS == 64 +#define gdb_get_regl(buf, val) gdb_get_reg64(buf, val) +#define ldtul_p(addr) ldq_p(addr) +#else +#define gdb_get_regl(buf, val) gdb_get_reg32(buf, val) +#define ldtul_p(addr) ldl_p(addr) +#endif + +#else +#error "gdbstub helpers should only be included by target specific code" +#endif + +#endif /* _GDBSTUB_HELPERS_H_ */ diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index e89992cf90..d69078899a 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -8,6 +8,7 @@ #include "qemu/osdep.h" #include "exec/gdbstub.h" +#include "cpu.h" #include "semihosting/guestfd.h" #include "semihosting/syscalls.h" #include "semihosting/console.h" diff --git a/target/alpha/gdbstub.c b/target/alpha/gdbstub.c index 7db14f4431..0f8fa150f8 100644 --- a/target/alpha/gdbstub.c +++ b/target/alpha/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" int alpha_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c index 2f806512d0..05d6eb802a 100644 --- a/target/arm/gdbstub.c +++ b/target/arm/gdbstub.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "internals.h" #include "cpregs.h" diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c index 07a6746944..48d2888b6f 100644 --- a/target/arm/gdbstub64.c +++ b/target/arm/gdbstub64.c @@ -20,7 +20,7 @@ #include "qemu/log.h" #include "cpu.h" #include "internals.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" int aarch64_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index 0972a4bdd0..c3edf163be 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "exec/helper-proto.h" #include "qemu/host-utils.h" #include "qemu/log.h" diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index f94e87e728..e05da83af5 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "internals.h" +#include "gdbstub/helpers.h" #include "exec/helper-proto.h" #include "qemu/main-loop.h" #include "qemu/bitops.h" diff --git a/target/avr/gdbstub.c b/target/avr/gdbstub.c index 1c1b908c92..150344d8b9 100644 --- a/target/avr/gdbstub.c +++ b/target/avr/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" int avr_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/cris/gdbstub.c b/target/cris/gdbstub.c index 2418d575b1..25c0ca33a5 100644 --- a/target/cris/gdbstub.c +++ b/target/cris/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" int crisv10_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/hexagon/gdbstub.c b/target/hexagon/gdbstub.c index d152d01bfe..46083da620 100644 --- a/target/hexagon/gdbstub.c +++ b/target/hexagon/gdbstub.c @@ -16,7 +16,7 @@ */ #include "qemu/osdep.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "cpu.h" #include "internal.h" diff --git a/target/hppa/gdbstub.c b/target/hppa/gdbstub.c index 729c37b2ca..48a514384f 100644 --- a/target/hppa/gdbstub.c +++ b/target/hppa/gdbstub.c @@ -19,7 +19,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" int hppa_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/i386/gdbstub.c b/target/i386/gdbstub.c index 786971284a..ebb000df6a 100644 --- a/target/i386/gdbstub.c +++ b/target/i386/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "include/gdbstub/helpers.h" #ifdef TARGET_X86_64 static const int gpr_map[16] = { diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 3d0c0b375f..52af81683c 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -12,7 +12,7 @@ #include "cpu.h" #include "exec/address-spaces.h" #include "exec/ioport.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/accel.h" #include "sysemu/whpx.h" #include "sysemu/cpus.h" diff --git a/target/loongarch/gdbstub.c b/target/loongarch/gdbstub.c index a4d1e28e36..fa3e034d15 100644 --- a/target/loongarch/gdbstub.c +++ b/target/loongarch/gdbstub.c @@ -10,6 +10,7 @@ #include "cpu.h" #include "internals.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" uint64_t read_fcc(CPULoongArchState *env) { diff --git a/target/m68k/gdbstub.c b/target/m68k/gdbstub.c index eb2d030e14..1e5f033a12 100644 --- a/target/m68k/gdbstub.c +++ b/target/m68k/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" int m68k_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 4621cf2402..3b3a6ea8bd 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -23,6 +23,7 @@ #include "exec/exec-all.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h" +#include "gdbstub/helpers.h" #include "fpu/softfloat.h" #include "qemu/qemu-print.h" diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index 87b1314925..f753710d7d 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -21,6 +21,7 @@ #include "cpu.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "semihosting/syscalls.h" #include "semihosting/softmmu-uaccess.h" #include "hw/boards.h" diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c index 8143fcae88..29ac6e9c0f 100644 --- a/target/microblaze/gdbstub.c +++ b/target/microblaze/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" /* * GDB expects SREGs in the following order: diff --git a/target/mips/gdbstub.c b/target/mips/gdbstub.c index f1c2a2cf6d..62d7b72407 100644 --- a/target/mips/gdbstub.c +++ b/target/mips/gdbstub.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "internal.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "fpu_helper.h" int mips_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 85f0567a7f..4e6e759057 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -21,6 +21,7 @@ #include "cpu.h" #include "qemu/log.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "semihosting/softmmu-uaccess.h" #include "semihosting/semihost.h" #include "semihosting/console.h" diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index cff30823da..bc5cbf81c2 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -23,7 +23,7 @@ #include "qapi/error.h" #include "cpu.h" #include "exec/log.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "hw/qdev-properties.h" static void nios2_cpu_set_pc(CPUState *cs, vaddr value) diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index f76e8588c5..113b3f22aa 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "semihosting/syscalls.h" #include "semihosting/softmmu-uaccess.h" #include "qemu/log.h" diff --git a/target/openrisc/gdbstub.c b/target/openrisc/gdbstub.c index 095bf76c12..d1074a0581 100644 --- a/target/openrisc/gdbstub.c +++ b/target/openrisc/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" int openrisc_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index c31c6f12c4..3887812810 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -21,7 +21,7 @@ #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #ifndef CONFIG_USER_ONLY #include "hw/loader.h" diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 0b8afdbacf..603c26715e 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -22,7 +22,7 @@ #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "hw/loader.h" diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index d62ffe8a6f..0ce2e3c91d 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "disas/dis-asm.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "kvm_ppc.h" #include "sysemu/cpus.h" #include "sysemu/hw_accel.h" diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c index 1a0b9ca82c..d2bc1d7c53 100644 --- a/target/ppc/gdbstub.c +++ b/target/ppc/gdbstub.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "internal.h" static int ppc_gdb_register_len_apple(int n) diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 6e7bbdbd5e..a542683901 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -18,6 +18,7 @@ #include "qemu/osdep.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "cpu.h" struct TypeSize { diff --git a/target/rx/gdbstub.c b/target/rx/gdbstub.c index 7eb2059a84..d7e0e6689b 100644 --- a/target/rx/gdbstub.c +++ b/target/rx/gdbstub.c @@ -17,7 +17,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" int rx_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) { diff --git a/target/s390x/gdbstub.c b/target/s390x/gdbstub.c index a5d69d0e0b..0cb69395b4 100644 --- a/target/s390x/gdbstub.c +++ b/target/s390x/gdbstub.c @@ -23,6 +23,7 @@ #include "s390x-internal.h" #include "exec/exec-all.h" #include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/bitops.h" #include "sysemu/hw_accel.h" #include "sysemu/tcg.h" diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 473c8e51b0..2b363aa959 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -21,7 +21,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "s390x-internal.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/timer.h" #include "hw/s390x/ioinst.h" #include "hw/s390x/pv.h" diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index 3488f68e32..d8e199fc06 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" /* Hint: Use "set architecture sh4" in GDB to see fpu registers */ /* FIXME: We should use XML for this. */ diff --git a/target/sparc/gdbstub.c b/target/sparc/gdbstub.c index 5d1e808e8c..a1c8fdc4d5 100644 --- a/target/sparc/gdbstub.c +++ b/target/sparc/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #ifdef TARGET_ABI32 #define gdb_get_rega(buf, val) gdb_get_reg32(buf, val) diff --git a/target/tricore/gdbstub.c b/target/tricore/gdbstub.c index 3a27a7e65d..e8f8e5e6ea 100644 --- a/target/tricore/gdbstub.c +++ b/target/tricore/gdbstub.c @@ -18,7 +18,7 @@ */ #include "qemu/osdep.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #define LCX_REGNUM 32 diff --git a/target/xtensa/core-dc232b.c b/target/xtensa/core-dc232b.c index c982d09c24..9aba2667e3 100644 --- a/target/xtensa/core-dc232b.c +++ b/target/xtensa/core-dc232b.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "qemu/timer.h" diff --git a/target/xtensa/core-dc233c.c b/target/xtensa/core-dc233c.c index 595ab9a90f..9b0a625063 100644 --- a/target/xtensa/core-dc233c.c +++ b/target/xtensa/core-dc233c.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-dc233c/core-isa.h" diff --git a/target/xtensa/core-de212.c b/target/xtensa/core-de212.c index 50c995ba79..b08fe22e65 100644 --- a/target/xtensa/core-de212.c +++ b/target/xtensa/core-de212.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-de212/core-isa.h" diff --git a/target/xtensa/core-de233_fpu.c b/target/xtensa/core-de233_fpu.c index 41af8057fb..8845cdb592 100644 --- a/target/xtensa/core-de233_fpu.c +++ b/target/xtensa/core-de233_fpu.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-de233_fpu/core-isa.h" diff --git a/target/xtensa/core-dsp3400.c b/target/xtensa/core-dsp3400.c index 81e425c568..c0f94b9e27 100644 --- a/target/xtensa/core-dsp3400.c +++ b/target/xtensa/core-dsp3400.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-dsp3400/core-isa.h" diff --git a/target/xtensa/core-fsf.c b/target/xtensa/core-fsf.c index 3327c50b4f..310be8d61f 100644 --- a/target/xtensa/core-fsf.c +++ b/target/xtensa/core-fsf.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-fsf/core-isa.h" diff --git a/target/xtensa/core-lx106.c b/target/xtensa/core-lx106.c index 7a771d09a6..7f71d088f3 100644 --- a/target/xtensa/core-lx106.c +++ b/target/xtensa/core-lx106.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-lx106/core-isa.h" diff --git a/target/xtensa/core-sample_controller.c b/target/xtensa/core-sample_controller.c index fd5de5576b..8867001aac 100644 --- a/target/xtensa/core-sample_controller.c +++ b/target/xtensa/core-sample_controller.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-sample_controller/core-isa.h" diff --git a/target/xtensa/core-test_kc705_be.c b/target/xtensa/core-test_kc705_be.c index 294c16f2f4..bd082f49aa 100644 --- a/target/xtensa/core-test_kc705_be.c +++ b/target/xtensa/core-test_kc705_be.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-test_kc705_be/core-isa.h" diff --git a/target/xtensa/core-test_mmuhifi_c3.c b/target/xtensa/core-test_mmuhifi_c3.c index c0e5d32d1e..3090dd01ed 100644 --- a/target/xtensa/core-test_mmuhifi_c3.c +++ b/target/xtensa/core-test_mmuhifi_c3.c @@ -27,7 +27,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-test_mmuhifi_c3/core-isa.h" diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index b6696063e5..4b3bfb7e59 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -19,7 +19,7 @@ */ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/log.h" enum { diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index 2aa9777a8e..dbeb97a953 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -29,7 +29,7 @@ #include "qemu/log.h" #include "cpu.h" #include "exec/exec-all.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "exec/helper-proto.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" diff --git a/target/xtensa/import_core.sh b/target/xtensa/import_core.sh index b4c15556c2..17dfec8957 100755 --- a/target/xtensa/import_core.sh +++ b/target/xtensa/import_core.sh @@ -41,7 +41,7 @@ tar -xf "$OVERLAY" -O binutils/xtensa-modules.c | \ cat < "${TARGET}.c" #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/helpers.h" #include "qemu/host-utils.h" #include "core-$NAME/core-isa.h" From patchwork Fri Mar 3 02:57:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658469 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226749wrb; Thu, 2 Mar 2023 19:02:27 -0800 (PST) X-Google-Smtp-Source: AK7set9U5KF77UFokj3AN7NwBqOWeLHkIX6a+kxKV+iUFYyRnZ8xFLY/5cebpxL+4hRc3udFgcpx X-Received: by 2002:ad4:5d69:0:b0:56c:37a:58b2 with SMTP id fn9-20020ad45d69000000b0056c037a58b2mr807894qvb.15.1677812547555; Thu, 02 Mar 2023 19:02:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812547; cv=none; d=google.com; s=arc-20160816; b=vp6PI3bOdQnY5K/gq/wYxbnbxdWnvdYNe07Nn2XSd7OpFSb6smjIACszVqR8iiFvp9 eLwgrGeowtjD25tW6gzQyfJQP/5cO+4mXou2IvGFb1qeRDE5vSA98xLQ4UU8d+z+1biA Anmg2utOGN1scteH1bVjacc2tIGD/LOq7Tf6+71WOlq5GtdYBpmHowofrPMCAvDsjydc tmlba1Viv3dBmQNc2cbXhX1BIBJddLbKCN2CyneKVDS3gdF+/Hu1+DZm1jk5vCOSlmy+ eW5EWmJLWfrdRxkZVYMVG6IwEf61FvclcF+9yF80OThGlJEYW1XXWf0M8we/DM0jsazc NJ1Q== 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=oTgZp/DZKamIAO2jWKpBJfhOTy0YYMt8DRlfYchj4Zw=; b=Ptov9GxEQtiLoNmXxo+ISdupdFUDmwBlE9lbj+T5wkqaE/fy26+Bw1WdbuDdrseZqL VU/2vlXY+4MrCnV+Gs2D/TUdy97ebV6JmovPtdj3tJRIm357E3/5it/uAXOD0xxV58hK Kwim0zuZdasfco3xfvh5QFN8Cwt8QEQmA2MRf2wSUtPJctdjCqrM0CQcbpiZjh9yhhR8 FnIB4dw50SkdTaiwwKLzACwTpttUPlxCTpT6oXvDkUw8ZoFWEZu0qQUhCSTXnIjPa3zw YneIbZf3i0EEneg32tg8+a61MJf9XwMvcAaAgJ9D02/j9jJ6PTwfs+kJ29Wonwu1Pobj +6Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nqWBY8yV; 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 n6-20020a05620a294600b0071a758b5e70si1040736qkp.299.2023.03.02.19.02.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:02:27 -0800 (PST) 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=nqWBY8yV; 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 1pXvct-0007bx-Vt; Thu, 02 Mar 2023 21:58:32 -0500 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 1pXvcs-0007ac-6x for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvco-0001tJ-RO for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:29 -0500 Received: by mail-pj1-x1034.google.com with SMTP id h11-20020a17090a2ecb00b00237c740335cso947927pjs.3 for ; Thu, 02 Mar 2023 18:58:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812305; 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=oTgZp/DZKamIAO2jWKpBJfhOTy0YYMt8DRlfYchj4Zw=; b=nqWBY8yVwX3rT6bnvSZ2VdW1YMPRcNcjVOtThI5QRQ/1x9BleEIXpLPx6JMITW7agb hXDkMxZ8U93XPcxeEb5zq9OTyLY4OlrMo7iLaw6gTRBU84HrxXSobReFpeWRuZ7gRnQ5 iYZthb60r8oukvF4Q040Y2gNoH0sVbSepWObCyacunHPAHlDLOZUbKDYR+29CdoNVgi1 SFOuI2Av3m4BC6w+012Z3Vk/pUTSAoOC4pb7UHLFEDCe7SU60sB7Cu81w6N5AZrTY8vI /z1+shOI3F+jjWSsj+CSZF/ywrkEZDqL2RjSm1QCf2MXj4U9ihvMvHPUHdvxKJyPGw36 IwHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812305; 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=oTgZp/DZKamIAO2jWKpBJfhOTy0YYMt8DRlfYchj4Zw=; b=O9jJGgO/3029ihcriDJ6MvgsGrMXAxLSVjcGzpltxevMH/3xbYjuIF3qMzKh+UtzQR VT3wlo0+/H+21ODc9VH5zjigE4gRXpNBkXp1tbkH+m3KTPH7LGKaUsoStsHydrN0+ZfL ILBBelictljGtR7rVXPvCXIG/ZDhg5w5kcRggINf4SIn/0zkszNPNggElt/nZufqRJHw dSK7ywY5Z0gjmz1b68Mw69frldOml45GFJvdH1LneKkfuWrWwa84K39/P2NqdGl948Ic scDzFKAjkx8VhyXlWQjnpGEc3e4+OkuDRLjIE9vYJT5PVqNOsEomGcKr4SVeju4SKf9v AySw== X-Gm-Message-State: AO0yUKVuN3715K1Njy+ispCgzw0nCo8mmAbeedSnTz+14niRZTt4D4Mf qmVwo8Z/gfdnaZIqRRQ6o10edSIWYAavoeHEIsk= X-Received: by 2002:a17:902:d48b:b0:19a:7622:23e5 with SMTP id c11-20020a170902d48b00b0019a762223e5mr715260plg.4.1677812305031; Thu, 02 Mar 2023 18:58:25 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 21/29] gdbstub: move syscall handling to new file Date: Thu, 2 Mar 2023 18:57:57 -0800 Message-Id: <20230303025805.625589-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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 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: Alex Bennée Our GDB syscall support is the last chunk of code that needs target specific support so move it to a new file. We take the opportunity to move the syscall state into its own singleton instance and add in a few helpers for the main gdbstub to interact with the module. I also moved the gdb_exit() declaration into syscalls.h as it feels pretty related and most of the callers of it treat it as such. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-22-alex.bennee@linaro.org> --- gdbstub/internals.h | 8 +- include/exec/gdbstub.h | 102 ------------- include/gdbstub/syscalls.h | 124 +++++++++++++++ gdbstub/gdbstub.c | 177 +--------------------- gdbstub/softmmu.c | 7 +- gdbstub/syscalls.c | 234 +++++++++++++++++++++++++++++ gdbstub/user.c | 1 + linux-user/exit.c | 2 +- semihosting/arm-compat-semi.c | 1 + semihosting/guestfd.c | 2 +- semihosting/syscalls.c | 2 +- softmmu/runstate.c | 2 +- target/m68k/m68k-semi.c | 2 +- target/mips/tcg/sysemu/mips-semi.c | 2 +- target/nios2/nios2-semi.c | 2 +- gdbstub/meson.build | 4 + 16 files changed, 384 insertions(+), 288 deletions(-) create mode 100644 include/gdbstub/syscalls.h create mode 100644 gdbstub/syscalls.c diff --git a/gdbstub/internals.h b/gdbstub/internals.h index be0eef4850..8db61f7fb4 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -61,8 +61,6 @@ typedef struct GDBState { bool multiprocess; GDBProcess *processes; int process_num; - char syscall_buf[256]; - gdb_syscall_complete_cb current_syscall_cb; GString *str_buf; GByteArray *mem_buf; int sstep_flags; @@ -191,6 +189,12 @@ void gdb_handle_query_attached(GArray *params, void *user_ctx); /* both */ void gdb_handle_query_qemu_phy_mem_mode(GArray *params, void *user_ctx); void gdb_handle_set_qemu_phy_mem_mode(GArray *params, void *user_ctx); +/* sycall handling */ +void gdb_handle_file_io(GArray *params, void *user_ctx); +bool gdb_handled_syscall(void); +void gdb_disable_syscalls(void); +void gdb_syscall_reset(void); + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h index bb8a3928dd..7d743fe1e9 100644 --- a/include/exec/gdbstub.h +++ b/include/exec/gdbstub.h @@ -10,98 +10,6 @@ #define GDB_WATCHPOINT_READ 3 #define GDB_WATCHPOINT_ACCESS 4 -/* For gdb file i/o remote protocol open flags. */ -#define GDB_O_RDONLY 0 -#define GDB_O_WRONLY 1 -#define GDB_O_RDWR 2 -#define GDB_O_APPEND 8 -#define GDB_O_CREAT 0x200 -#define GDB_O_TRUNC 0x400 -#define GDB_O_EXCL 0x800 - -/* For gdb file i/o remote protocol errno values */ -#define GDB_EPERM 1 -#define GDB_ENOENT 2 -#define GDB_EINTR 4 -#define GDB_EBADF 9 -#define GDB_EACCES 13 -#define GDB_EFAULT 14 -#define GDB_EBUSY 16 -#define GDB_EEXIST 17 -#define GDB_ENODEV 19 -#define GDB_ENOTDIR 20 -#define GDB_EISDIR 21 -#define GDB_EINVAL 22 -#define GDB_ENFILE 23 -#define GDB_EMFILE 24 -#define GDB_EFBIG 27 -#define GDB_ENOSPC 28 -#define GDB_ESPIPE 29 -#define GDB_EROFS 30 -#define GDB_ENAMETOOLONG 91 -#define GDB_EUNKNOWN 9999 - -/* For gdb file i/o remote protocol lseek whence. */ -#define GDB_SEEK_SET 0 -#define GDB_SEEK_CUR 1 -#define GDB_SEEK_END 2 - -/* For gdb file i/o stat/fstat. */ -typedef uint32_t gdb_mode_t; -typedef uint32_t gdb_time_t; - -struct gdb_stat { - uint32_t gdb_st_dev; /* device */ - uint32_t gdb_st_ino; /* inode */ - gdb_mode_t gdb_st_mode; /* protection */ - uint32_t gdb_st_nlink; /* number of hard links */ - uint32_t gdb_st_uid; /* user ID of owner */ - uint32_t gdb_st_gid; /* group ID of owner */ - uint32_t gdb_st_rdev; /* device type (if inode device) */ - uint64_t gdb_st_size; /* total size, in bytes */ - uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ - uint64_t gdb_st_blocks; /* number of blocks allocated */ - gdb_time_t gdb_st_atime; /* time of last access */ - gdb_time_t gdb_st_mtime; /* time of last modification */ - gdb_time_t gdb_st_ctime; /* time of last change */ -} QEMU_PACKED; - -struct gdb_timeval { - gdb_time_t tv_sec; /* second */ - uint64_t tv_usec; /* microsecond */ -} QEMU_PACKED; - -typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int err); - -/** - * gdb_do_syscall: - * @cb: function to call when the system call has completed - * @fmt: gdb syscall format string - * ...: list of arguments to interpolate into @fmt - * - * Send a GDB syscall request. This function will return immediately; - * the callback function will be called later when the remote system - * call has completed. - * - * @fmt should be in the 'call-id,parameter,parameter...' format documented - * for the F request packet in the GDB remote protocol. A limited set of - * printf-style format specifiers is supported: - * %x - target_ulong argument printed in hex - * %lx - 64-bit argument printed in hex - * %s - string pointer (target_ulong) and length (int) pair - */ -void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); -/** - * gdb_do_syscallv: - * @cb: function to call when the system call has completed - * @fmt: gdb syscall format string - * @va: arguments to interpolate into @fmt - * - * As gdb_do_syscall, but taking a va_list rather than a variable - * argument list. - */ -void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va); -int use_gdb_syscalls(void); /* Get or set a register. Returns the size of the register. */ typedef int (*gdb_get_reg_cb)(CPUArchState *env, GByteArray *buf, int reg); @@ -120,16 +28,6 @@ void gdb_register_coprocessor(CPUState *cpu, */ int gdbserver_start(const char *port_or_device); -/** - * gdb_exit: exit gdb session, reporting inferior status - * @code: exit code reported - * - * This closes the session and sends a final packet to GDB reporting - * the exit status of the program. It also cleans up any connections - * detritus before returning. - */ -void gdb_exit(int code); - void gdb_set_stop_cpu(CPUState *cpu); /** diff --git a/include/gdbstub/syscalls.h b/include/gdbstub/syscalls.h new file mode 100644 index 0000000000..5851a2c706 --- /dev/null +++ b/include/gdbstub/syscalls.h @@ -0,0 +1,124 @@ +/* + * GDB Syscall support + * + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: LGPL-2.0+ + */ + +#ifndef _SYSCALLS_H_ +#define _SYSCALLS_H_ + +/* For gdb file i/o remote protocol open flags. */ +#define GDB_O_RDONLY 0 +#define GDB_O_WRONLY 1 +#define GDB_O_RDWR 2 +#define GDB_O_APPEND 8 +#define GDB_O_CREAT 0x200 +#define GDB_O_TRUNC 0x400 +#define GDB_O_EXCL 0x800 + +/* For gdb file i/o remote protocol errno values */ +#define GDB_EPERM 1 +#define GDB_ENOENT 2 +#define GDB_EINTR 4 +#define GDB_EBADF 9 +#define GDB_EACCES 13 +#define GDB_EFAULT 14 +#define GDB_EBUSY 16 +#define GDB_EEXIST 17 +#define GDB_ENODEV 19 +#define GDB_ENOTDIR 20 +#define GDB_EISDIR 21 +#define GDB_EINVAL 22 +#define GDB_ENFILE 23 +#define GDB_EMFILE 24 +#define GDB_EFBIG 27 +#define GDB_ENOSPC 28 +#define GDB_ESPIPE 29 +#define GDB_EROFS 30 +#define GDB_ENAMETOOLONG 91 +#define GDB_EUNKNOWN 9999 + +/* For gdb file i/o remote protocol lseek whence. */ +#define GDB_SEEK_SET 0 +#define GDB_SEEK_CUR 1 +#define GDB_SEEK_END 2 + +/* For gdb file i/o stat/fstat. */ +typedef uint32_t gdb_mode_t; +typedef uint32_t gdb_time_t; + +struct gdb_stat { + uint32_t gdb_st_dev; /* device */ + uint32_t gdb_st_ino; /* inode */ + gdb_mode_t gdb_st_mode; /* protection */ + uint32_t gdb_st_nlink; /* number of hard links */ + uint32_t gdb_st_uid; /* user ID of owner */ + uint32_t gdb_st_gid; /* group ID of owner */ + uint32_t gdb_st_rdev; /* device type (if inode device) */ + uint64_t gdb_st_size; /* total size, in bytes */ + uint64_t gdb_st_blksize; /* blocksize for filesystem I/O */ + uint64_t gdb_st_blocks; /* number of blocks allocated */ + gdb_time_t gdb_st_atime; /* time of last access */ + gdb_time_t gdb_st_mtime; /* time of last modification */ + gdb_time_t gdb_st_ctime; /* time of last change */ +} QEMU_PACKED; + +struct gdb_timeval { + gdb_time_t tv_sec; /* second */ + uint64_t tv_usec; /* microsecond */ +} QEMU_PACKED; + +typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int err); + +/** + * gdb_do_syscall: + * @cb: function to call when the system call has completed + * @fmt: gdb syscall format string + * ...: list of arguments to interpolate into @fmt + * + * Send a GDB syscall request. This function will return immediately; + * the callback function will be called later when the remote system + * call has completed. + * + * @fmt should be in the 'call-id,parameter,parameter...' format documented + * for the F request packet in the GDB remote protocol. A limited set of + * printf-style format specifiers is supported: + * %x - target_ulong argument printed in hex + * %lx - 64-bit argument printed in hex + * %s - string pointer (target_ulong) and length (int) pair + */ +void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); + +/** + * gdb_do_syscallv: + * @cb: function to call when the system call has completed + * @fmt: gdb syscall format string + * @va: arguments to interpolate into @fmt + * + * As gdb_do_syscall, but taking a va_list rather than a variable + * argument list. + */ +void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va); + +/** + * use_gdb_syscalls() - report if GDB should be used for syscalls + * + * This is mostly driven by the semihosting mode the user configures + * but assuming GDB is allowed by that we report true if GDB is + * connected to the stub. + */ +int use_gdb_syscalls(void); + +/** + * gdb_exit: exit gdb session, reporting inferior status + * @code: exit code reported + * + * This closes the session and sends a final packet to GDB reporting + * the exit status of the program. It also cleans up any connections + * detritus before returning. + */ +void gdb_exit(int code); + +#endif /* _SYSCALLS_H_ */ diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index f1504af44f..e264ed04e7 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -29,6 +29,7 @@ #include "qemu/module.h" #include "trace.h" #include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #ifdef CONFIG_USER_ONLY #include "gdbstub/user.h" #else @@ -38,7 +39,6 @@ #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" -#include "semihosting/semihost.h" #include "exec/exec-all.h" #include "exec/replay-core.h" #include "exec/tb-flush.h" @@ -78,41 +78,6 @@ void gdb_init_gdbserver_state(void) bool gdb_has_xml; -/* - * Return true if there is a GDB currently connected to the stub - * and attached to a CPU - */ -static bool gdb_attached(void) -{ - return gdbserver_state.init && gdbserver_state.c_cpu; -} - -static enum { - GDB_SYS_UNKNOWN, - GDB_SYS_ENABLED, - GDB_SYS_DISABLED, -} gdb_syscall_mode; - -/* Decide if either remote gdb syscalls or native file IO should be used. */ -int use_gdb_syscalls(void) -{ - SemihostingTarget target = semihosting_get_target(); - if (target == SEMIHOSTING_TARGET_NATIVE) { - /* -semihosting-config target=native */ - return false; - } else if (target == SEMIHOSTING_TARGET_GDB) { - /* -semihosting-config target=gdb */ - return true; - } - - /* -semihosting-config target=auto */ - /* On the first call check if gdb is connected and remember. */ - if (gdb_syscall_mode == GDB_SYS_UNKNOWN) { - gdb_syscall_mode = gdb_attached() ? GDB_SYS_ENABLED : GDB_SYS_DISABLED; - } - return gdb_syscall_mode == GDB_SYS_ENABLED; -} - /* writes 2*len+1 bytes in buf */ void gdb_memtohex(GString *buf, const uint8_t *mem, int len) { @@ -922,7 +887,7 @@ static void handle_detach(GArray *params, void *user_ctx) if (!gdbserver_state.c_cpu) { /* No more process attached */ - gdb_syscall_mode = GDB_SYS_DISABLED; + gdb_disable_syscalls(); gdb_continue(); } gdb_put_packet("OK"); @@ -1235,60 +1200,6 @@ static void handle_read_all_regs(GArray *params, void *user_ctx) gdb_put_strbuf(); } -static void handle_file_io(GArray *params, void *user_ctx) -{ - if (params->len >= 1 && gdbserver_state.current_syscall_cb) { - uint64_t ret; - int err; - - ret = get_param(params, 0)->val_ull; - if (params->len >= 2) { - err = get_param(params, 1)->val_ull; - } else { - err = 0; - } - - /* Convert GDB error numbers back to host error numbers. */ -#define E(X) case GDB_E##X: err = E##X; break - switch (err) { - case 0: - break; - E(PERM); - E(NOENT); - E(INTR); - E(BADF); - E(ACCES); - E(FAULT); - E(BUSY); - E(EXIST); - E(NODEV); - E(NOTDIR); - E(ISDIR); - E(INVAL); - E(NFILE); - E(MFILE); - E(FBIG); - E(NOSPC); - E(SPIPE); - E(ROFS); - E(NAMETOOLONG); - default: - err = EINVAL; - break; - } -#undef E - - gdbserver_state.current_syscall_cb(gdbserver_state.c_cpu, ret, err); - gdbserver_state.current_syscall_cb = NULL; - } - - if (params->len >= 3 && get_param(params, 2)->opcode == (uint8_t)'C') { - gdb_put_packet("T02"); - return; - } - - gdb_continue(); -} static void handle_step(GArray *params, void *user_ctx) { @@ -1894,7 +1805,7 @@ static int gdb_handle_packet(const char *line_buf) case 'F': { static const GdbCmdParseEntry file_io_cmd_desc = { - .handler = handle_file_io, + .handler = gdb_handle_file_io, .cmd = "F", .cmd_startswith = 1, .schema = "L,L,o0" @@ -2062,88 +1973,6 @@ void gdb_set_stop_cpu(CPUState *cpu) gdbserver_state.g_cpu = cpu; } -/* Send a gdb syscall request. - This accepts limited printf-style format specifiers, specifically: - %x - target_ulong argument printed in hex. - %lx - 64-bit argument printed in hex. - %s - string pointer (target_ulong) and length (int) pair. */ -void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) -{ - char *p; - char *p_end; - target_ulong addr; - uint64_t i64; - - if (!gdb_attached()) { - return; - } - - gdbserver_state.current_syscall_cb = cb; -#ifndef CONFIG_USER_ONLY - vm_stop(RUN_STATE_DEBUG); -#endif - p = &gdbserver_state.syscall_buf[0]; - p_end = &gdbserver_state.syscall_buf[sizeof(gdbserver_state.syscall_buf)]; - *(p++) = 'F'; - while (*fmt) { - if (*fmt == '%') { - fmt++; - switch (*fmt++) { - case 'x': - addr = va_arg(va, target_ulong); - p += snprintf(p, p_end - p, TARGET_FMT_lx, addr); - break; - case 'l': - if (*(fmt++) != 'x') - goto bad_format; - i64 = va_arg(va, uint64_t); - p += snprintf(p, p_end - p, "%" PRIx64, i64); - break; - case 's': - addr = va_arg(va, target_ulong); - p += snprintf(p, p_end - p, TARGET_FMT_lx "/%x", - addr, va_arg(va, int)); - break; - default: - bad_format: - error_report("gdbstub: Bad syscall format string '%s'", - fmt - 1); - break; - } - } else { - *(p++) = *(fmt++); - } - } - *p = 0; -#ifdef CONFIG_USER_ONLY - gdb_put_packet(gdbserver_state.syscall_buf); - /* Return control to gdb for it to process the syscall request. - * Since the protocol requires that gdb hands control back to us - * using a "here are the results" F packet, we don't need to check - * gdb_handlesig's return value (which is the signal to deliver if - * execution was resumed via a continue packet). - */ - gdb_handlesig(gdbserver_state.c_cpu, 0); -#else - /* In this case wait to send the syscall packet until notification that - the CPU has stopped. This must be done because if the packet is sent - now the reply from the syscall request could be received while the CPU - is still in the running state, which can cause packets to be dropped - and state transition 'T' packets to be sent while the syscall is still - being processed. */ - qemu_cpu_kick(gdbserver_state.c_cpu); -#endif -} - -void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) -{ - va_list va; - - va_start(va, fmt); - gdb_do_syscallv(cb, fmt, va); - va_end(va); -} - void gdb_read_byte(uint8_t ch) { uint8_t reply; diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index d2863d0663..d3152fb6e7 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -15,6 +15,7 @@ #include "qemu/error-report.h" #include "qemu/cutils.h" #include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "exec/hwaddr.h" #include "exec/tb-flush.h" #include "sysemu/cpus.h" @@ -113,9 +114,9 @@ static void gdb_vm_state_change(void *opaque, bool running, RunState state) if (running || gdbserver_state.state == RS_INACTIVE) { return; } + /* Is there a GDB syscall waiting to be sent? */ - if (gdbserver_state.current_syscall_cb) { - gdb_put_packet(gdbserver_state.syscall_buf); + if (gdb_handled_syscall()) { return; } @@ -384,7 +385,7 @@ int gdbserver_start(const char *device) } gdbserver_state.state = chr ? RS_IDLE : RS_INACTIVE; gdbserver_system_state.mon_chr = mon_chr; - gdbserver_state.current_syscall_cb = NULL; + gdb_syscall_reset(); return 0; } diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c new file mode 100644 index 0000000000..f15b210958 --- /dev/null +++ b/gdbstub/syscalls.c @@ -0,0 +1,234 @@ +/* + * GDB Syscall Handling + * + * GDB can execute syscalls on the guests behalf, currently used by + * the various semihosting extensions. As this interfaces with a guest + * ABI we need to build it per-guest (although in reality its a 32 or + * 64 bit target_ulong that is the only difference). + * + * Copyright (c) 2003-2005 Fabrice Bellard + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: LGPL-2.0+ + */ + +#include "qemu/osdep.h" +#include "cpu.h" +#include "semihosting/semihost.h" +#include "sysemu/runstate.h" +#include "gdbstub/user.h" +#include "gdbstub/syscalls.h" +#include "trace.h" +#include "internals.h" + +/* Syscall specific state */ +typedef struct { + char syscall_buf[256]; + gdb_syscall_complete_cb current_syscall_cb; +} GDBSyscallState; + +static GDBSyscallState gdbserver_syscall_state; + +/* + * Return true if there is a GDB currently connected to the stub + * and attached to a CPU + */ +static bool gdb_attached(void) +{ + return gdbserver_state.init && gdbserver_state.c_cpu; +} + +static enum { + GDB_SYS_UNKNOWN, + GDB_SYS_ENABLED, + GDB_SYS_DISABLED, +} gdb_syscall_mode; + +/* Decide if either remote gdb syscalls or native file IO should be used. */ +int use_gdb_syscalls(void) +{ + SemihostingTarget target = semihosting_get_target(); + if (target == SEMIHOSTING_TARGET_NATIVE) { + /* -semihosting-config target=native */ + return false; + } else if (target == SEMIHOSTING_TARGET_GDB) { + /* -semihosting-config target=gdb */ + return true; + } + + /* -semihosting-config target=auto */ + /* On the first call check if gdb is connected and remember. */ + if (gdb_syscall_mode == GDB_SYS_UNKNOWN) { + gdb_syscall_mode = gdb_attached() ? GDB_SYS_ENABLED : GDB_SYS_DISABLED; + } + return gdb_syscall_mode == GDB_SYS_ENABLED; +} + +/* called when the stub detaches */ +void gdb_disable_syscalls(void) +{ + gdb_syscall_mode = GDB_SYS_DISABLED; +} + +void gdb_syscall_reset(void) +{ + gdbserver_syscall_state.current_syscall_cb = NULL; +} + +bool gdb_handled_syscall(void) +{ + if (gdbserver_syscall_state.current_syscall_cb) { + gdb_put_packet(gdbserver_syscall_state.syscall_buf); + return true; + } + + return false; +} + +/* + * Send a gdb syscall request. + * This accepts limited printf-style format specifiers, specifically: + * %x - target_ulong argument printed in hex. + * %lx - 64-bit argument printed in hex. + * %s - string pointer (target_ulong) and length (int) pair. + */ +void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) +{ + char *p; + char *p_end; + target_ulong addr; + uint64_t i64; + + if (!gdb_attached()) { + return; + } + + gdbserver_syscall_state.current_syscall_cb = cb; +#ifndef CONFIG_USER_ONLY + vm_stop(RUN_STATE_DEBUG); +#endif + p = &gdbserver_syscall_state.syscall_buf[0]; + p_end = &gdbserver_syscall_state.syscall_buf[sizeof(gdbserver_syscall_state.syscall_buf)]; + *(p++) = 'F'; + while (*fmt) { + if (*fmt == '%') { + fmt++; + switch (*fmt++) { + case 'x': + addr = va_arg(va, target_ulong); + p += snprintf(p, p_end - p, TARGET_FMT_lx, addr); + break; + case 'l': + if (*(fmt++) != 'x') { + goto bad_format; + } + i64 = va_arg(va, uint64_t); + p += snprintf(p, p_end - p, "%" PRIx64, i64); + break; + case 's': + addr = va_arg(va, target_ulong); + p += snprintf(p, p_end - p, TARGET_FMT_lx "/%x", + addr, va_arg(va, int)); + break; + default: + bad_format: + error_report("gdbstub: Bad syscall format string '%s'", + fmt - 1); + break; + } + } else { + *(p++) = *(fmt++); + } + } + *p = 0; +#ifdef CONFIG_USER_ONLY + gdb_put_packet(gdbserver_syscall_state.syscall_buf); + /* + * Return control to gdb for it to process the syscall request. + * Since the protocol requires that gdb hands control back to us + * using a "here are the results" F packet, we don't need to check + * gdb_handlesig's return value (which is the signal to deliver if + * execution was resumed via a continue packet). + */ + gdb_handlesig(gdbserver_state.c_cpu, 0); +#else + /* + * In this case wait to send the syscall packet until notification that + * the CPU has stopped. This must be done because if the packet is sent + * now the reply from the syscall request could be received while the CPU + * is still in the running state, which can cause packets to be dropped + * and state transition 'T' packets to be sent while the syscall is still + * being processed. + */ + qemu_cpu_kick(gdbserver_state.c_cpu); +#endif +} + +void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + gdb_do_syscallv(cb, fmt, va); + va_end(va); +} + +/* + * GDB Command Handlers + */ + +void gdb_handle_file_io(GArray *params, void *user_ctx) +{ + if (params->len >= 1 && gdbserver_syscall_state.current_syscall_cb) { + uint64_t ret; + int err; + + ret = get_param(params, 0)->val_ull; + if (params->len >= 2) { + err = get_param(params, 1)->val_ull; + } else { + err = 0; + } + + /* Convert GDB error numbers back to host error numbers. */ +#define E(X) case GDB_E##X: err = E##X; break + switch (err) { + case 0: + break; + E(PERM); + E(NOENT); + E(INTR); + E(BADF); + E(ACCES); + E(FAULT); + E(BUSY); + E(EXIST); + E(NODEV); + E(NOTDIR); + E(ISDIR); + E(INVAL); + E(NFILE); + E(MFILE); + E(FBIG); + E(NOSPC); + E(SPIPE); + E(ROFS); + E(NAMETOOLONG); + default: + err = EINVAL; + break; + } +#undef E + + gdbserver_syscall_state.current_syscall_cb(gdbserver_state.c_cpu, + ret, err); + gdbserver_syscall_state.current_syscall_cb = NULL; + } + + if (params->len >= 3 && get_param(params, 2)->opcode == (uint8_t)'C') { + gdb_put_packet("T02"); + return; + } + + gdb_continue(); +} diff --git a/gdbstub/user.c b/gdbstub/user.c index 3f6183e66a..3da410e221 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -15,6 +15,7 @@ #include "exec/hwaddr.h" #include "exec/tb-flush.h" #include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "gdbstub/user.h" #include "hw/core/cpu.h" #include "trace.h" diff --git a/linux-user/exit.c b/linux-user/exit.c index 607b6da9fc..fd49d76f45 100644 --- a/linux-user/exit.c +++ b/linux-user/exit.c @@ -18,7 +18,7 @@ */ #include "qemu/osdep.h" #include "accel/tcg/perf.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "qemu.h" #include "user-internals.h" #ifdef CONFIG_GPROF diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index 62d8bae97f..564fe17f75 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -34,6 +34,7 @@ #include "qemu/osdep.h" #include "qemu/timer.h" #include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "semihosting/semihost.h" #include "semihosting/console.h" #include "semihosting/common-semi.h" diff --git a/semihosting/guestfd.c b/semihosting/guestfd.c index b05c52f26f..acb86b50dd 100644 --- a/semihosting/guestfd.c +++ b/semihosting/guestfd.c @@ -9,7 +9,7 @@ */ #include "qemu/osdep.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "semihosting/semihost.h" #include "semihosting/guestfd.h" #ifdef CONFIG_USER_ONLY diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index d69078899a..42080ffdda 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -7,8 +7,8 @@ */ #include "qemu/osdep.h" -#include "exec/gdbstub.h" #include "cpu.h" +#include "gdbstub/syscalls.h" #include "semihosting/guestfd.h" #include "semihosting/syscalls.h" #include "semihosting/console.h" diff --git a/softmmu/runstate.c b/softmmu/runstate.c index f9ad88e6a7..6ee622841d 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -30,7 +30,7 @@ #include "crypto/cipher.h" #include "crypto/init.h" #include "exec/cpu-common.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "hw/boards.h" #include "migration/misc.h" #include "migration/postcopy-ram.h" diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c index f753710d7d..88ad9ba814 100644 --- a/target/m68k/m68k-semi.c +++ b/target/m68k/m68k-semi.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "gdbstub/helpers.h" #include "semihosting/syscalls.h" #include "semihosting/softmmu-uaccess.h" diff --git a/target/mips/tcg/sysemu/mips-semi.c b/target/mips/tcg/sysemu/mips-semi.c index 4e6e759057..f3735df7b9 100644 --- a/target/mips/tcg/sysemu/mips-semi.c +++ b/target/mips/tcg/sysemu/mips-semi.c @@ -20,7 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "qemu/log.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "gdbstub/helpers.h" #include "semihosting/softmmu-uaccess.h" #include "semihosting/semihost.h" diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 113b3f22aa..3738774976 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -23,7 +23,7 @@ #include "qemu/osdep.h" #include "cpu.h" -#include "exec/gdbstub.h" +#include "gdbstub/syscalls.h" #include "gdbstub/helpers.h" #include "semihosting/syscalls.h" #include "semihosting/softmmu-uaccess.h" diff --git a/gdbstub/meson.build b/gdbstub/meson.build index 773bd4b9c9..c876222b9c 100644 --- a/gdbstub/meson.build +++ b/gdbstub/meson.build @@ -5,6 +5,10 @@ # specific_ss.add(files('gdbstub.c')) + +# These have to built to the target ABI +specific_ss.add(files('syscalls.c')) + softmmu_ss.add(files('softmmu.c')) user_ss.add(files('user.c')) From patchwork Fri Mar 3 02:57:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658468 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226691wrb; Thu, 2 Mar 2023 19:02:19 -0800 (PST) X-Google-Smtp-Source: AK7set8Ae2Vkf0V9t16VYqrBLTCn3c5l8yXcD7S53UKjRu2cdj3ar4vtG88qzFWhMdMg74oFeA7F X-Received: by 2002:a05:622a:1823:b0:3bf:bb2c:449c with SMTP id t35-20020a05622a182300b003bfbb2c449cmr883322qtc.15.1677812539636; Thu, 02 Mar 2023 19:02:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812539; cv=none; d=google.com; s=arc-20160816; b=QuNehnyJUiz6Yhon68o8H7Y9qsUyLZEubw1qxgq7qOgAG4mHw6ucZszmmfs10FF58I WffgXDUrCFIj4cu57vWsPhfkBEBogNSdeJiZGX44+dDIMicMLd8Noo2ubXATDgkvO/yw AxfsEwT08Oddv+32WbFuKMIzQairSEVLN48d6pFMltk5565wwu3mW1tCu7RCXQz7lqYb e05wkWpE4s9XmuHQq19gAN6GbquJfEmNbeWl/+6Mg0Ek5UaRnypAyJuhY48MYqtNS/0y a8RXbrnbANQVkkUX29QXLaB9BCQZtLdkdSeNv4svDN7f+7jR3360OXmWVmGh77gqAyo0 pgtA== 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=pf0gnzU22Lq1Q1Kv39Okh1QPjAe7PNl3a36TYlU7/jI=; b=sV6osIb1pSVxFPMbaLAZii/VorzNKDMDfNYTh1PlIjwjPdgMLz4yuQdC0W7LdC3PUL NLUUx7Rh6c767tIDDwmZvEwVXp9JcHTJ3/qlSnIunTQYITl5+z5/QPqfkYYJWNhAUoqO uGU4Zuha0V2jDY1AkMa6FkYFxh4X3VxswIEvqzZGrUSs7a6T+H74+x3O3NMPLDaHxCNH 4kOIyDwla1omYbOt1av6wjVcK00GkmG9FqDVWcYyvETODauBdURdiowrsxLCVcEPweL2 a33qRTkYhKKYyHt6HbwENYdZTaxHqkDaluKK9Pu7iq6Lngm0tBtcrSpK/Rz4U7YTx6tv SMNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VF7U7mEJ; 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 r15-20020a37a80f000000b007023e988bdcsi949224qke.1.2023.03.02.19.02.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:02:19 -0800 (PST) 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=VF7U7mEJ; 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 1pXvct-0007bN-Ae; Thu, 02 Mar 2023 21:58:31 -0500 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 1pXvcr-0007a7-3B for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:29 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcp-0001tO-A1 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:28 -0500 Received: by mail-pj1-x1035.google.com with SMTP id h11-20020a17090a2ecb00b00237c740335cso947939pjs.3 for ; Thu, 02 Mar 2023 18:58:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812306; 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=pf0gnzU22Lq1Q1Kv39Okh1QPjAe7PNl3a36TYlU7/jI=; b=VF7U7mEJYwo4wJH8QP5k/Lpj5n48C59nIe3K1GWafjnexVPbchkUezF9lbR1RBhODF gXsWtCoFvnpo5H/e28jBCiSX+pG6UT7cMRa6Pxlt6+OvWfVVapKxLob60NiD1GK3PlIV nVt2ewVwq6Wj0Hv9DffOab0tHHvxnFYnPwJ4Bvj429A8G3oZweIsZTVMM0WTrdQYs8b5 2F2x35daleTzlrRwKkAcizkoVyTQKscOHTmR++Dw+RdWyYQtcV+8xhpJKoS1Jka5w5ef jFCnUt3zlXhjSDp5Tehc6cRHxa1gGCtvgiaEphrjKLx55YD8wyc+OsOXMgzWMerrFn1B 5GQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812306; 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=pf0gnzU22Lq1Q1Kv39Okh1QPjAe7PNl3a36TYlU7/jI=; b=dU+9r1QKL8vMFS8I833CIqVi2sjoykFHaxa4BqdjjQH4yRbAKQAhU65PwgzRTEBtsT 5Dw+XfFhPnluPHpbsRitXWxxjrzDOTWLjWZ2kXb59wOSKVfosMA33JTwIKEi4Y1cXcTI gxFpADONdlkSs+W31VyeNnNIgaNSnXafb4nmyRUCZuvr/45UolulPXANwTdGuoUPLHFj cVt3R4rOI9Xh7z8g70s2WU7W9uAbEEY8XCMo8+8fz/pm/U4TSr/fiV+LVJxArQ+Xe04I Voe8LoyrBPburdMJ5xXbLLu8sJInCUjMERRa4CFlPsOUrCTTOkp+5HklChE4oJGcdEm3 R52A== X-Gm-Message-State: AO0yUKXNt7NpmlxrfmFSJtmAi0f+PUSUI+0HFpaNIHYrJdhXRximFbMq 5xlAYmCQi4VmplsN7F4A5MjSM/jSc/uJwR0P4hg= X-Received: by 2002:a17:902:d4cc:b0:19b:dbf7:f9ca with SMTP id o12-20020a170902d4cc00b0019bdbf7f9camr805339plg.0.1677812305829; Thu, 02 Mar 2023 18:58:25 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 22/29] gdbstub: only compile gdbstub twice for whole build Date: Thu, 2 Mar 2023 18:57:58 -0800 Message-Id: <20230303025805.625589-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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 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: Alex Bennée Now we have removed any target specific bits from the core gdbstub code we only need to build it twice. We have to jump a few meson hoops to manually define the CONFIG_USER_ONLY symbol but it seems to work. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-23-alex.bennee@linaro.org> --- gdbstub/gdbstub.c | 4 +--- gdbstub/meson.build | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index e264ed04e7..d9e9bf9294 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -39,9 +39,7 @@ #include "sysemu/hw_accel.h" #include "sysemu/runstate.h" -#include "exec/exec-all.h" #include "exec/replay-core.h" -#include "exec/tb-flush.h" #include "exec/hwaddr.h" #include "internals.h" @@ -1612,7 +1610,7 @@ static const GdbCmdParseEntry gdb_gen_query_table[] = { .cmd_startswith = 1, .schema = "s:l,l0" }, -#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX_USER) +#if defined(CONFIG_USER_ONLY) && defined(CONFIG_LINUX) { .handler = gdb_handle_query_xfer_auxv, .cmd = "Xfer:auxv:read::", diff --git a/gdbstub/meson.build b/gdbstub/meson.build index c876222b9c..d679c7ab86 100644 --- a/gdbstub/meson.build +++ b/gdbstub/meson.build @@ -4,13 +4,35 @@ # types such as hwaddr. # -specific_ss.add(files('gdbstub.c')) +# We need to build the core gdb code via a library to be able to tweak +# cflags so: + +gdb_user_ss = ss.source_set() +gdb_softmmu_ss = ss.source_set() + +# We build two versions of gdbstub, one for each mode +gdb_user_ss.add(files('gdbstub.c', 'user.c')) +gdb_softmmu_ss.add(files('gdbstub.c', 'softmmu.c')) + +gdb_user_ss = gdb_user_ss.apply(config_host, strict: false) +gdb_softmmu_ss = gdb_softmmu_ss.apply(config_host, strict: false) + +libgdb_user = static_library('gdb_user', + gdb_user_ss.sources() + genh, + name_suffix: 'fa', + c_args: '-DCONFIG_USER_ONLY') + +libgdb_softmmu = static_library('gdb_softmmu', + gdb_softmmu_ss.sources() + genh, + name_suffix: 'fa') + +gdb_user = declare_dependency(link_whole: libgdb_user) +user_ss.add(gdb_user) +gdb_softmmu = declare_dependency(link_whole: libgdb_softmmu) +softmmu_ss.add(gdb_softmmu) # These have to built to the target ABI specific_ss.add(files('syscalls.c')) -softmmu_ss.add(files('softmmu.c')) -user_ss.add(files('user.c')) - # The user-target is specialised by the guest specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-target.c')) From patchwork Fri Mar 3 02:57:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658452 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225760wrb; Thu, 2 Mar 2023 19:00:26 -0800 (PST) X-Google-Smtp-Source: AK7set9bFLP5bydx7Qud6M1JxHQZUURUZ4Cf/R0WNb9INfDuiIIPZ8uekEFShxkalirUaEM+hi0d X-Received: by 2002:ac8:5dd2:0:b0:3b9:2b0:5e7f with SMTP id e18-20020ac85dd2000000b003b902b05e7fmr646516qtx.32.1677812426175; Thu, 02 Mar 2023 19:00:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812426; cv=none; d=google.com; s=arc-20160816; b=P6/aCCbbJ+hiZFCj7CPxA8MTFOcNXHD8BgV756zVlhCCecGh/v9+ckEVwx5j24wFtS zQPdPndg7pNZfaqws2vOBnmWcczxNGfiENogKB01fVDGHTuVVikXbeKO//U05YE1Sh5j IfCR2BoLxJIqoU275BYnzYZbrinF0h0oQhu9Gb5b7HKqnp6ukYFD2Q+bRKibVkrDy9RD fjRRwoS5iTJll02Opay1VmE9GaGx5UHnZR7mtGe7+Tk/8Wv+r/gXTWr3jkB+AFo8RAim KcW1QZarKlXNCP2u2ZhGC08I4JySgNTvsQjCx8e0xwrj+YsrT7o5nTaaCsJARNu5jCSu B+Iw== 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=DyucSr1+mDuhxSYgjTJ7OboyUx9A5mZckDpsrPxpF7I=; b=XsMcFimFXlm/rZTdujm6ARcv6Li3JlIafT4sUOqivj+q0Ebmt4mtdp6sqkAa6UKx3l FvijkaAFRq8hoywL9UYqV1fK4bi/AW4MXJgu4cKWjnb6uFUX5oh5bxbvzu8Nm2QNEmyD FPS0vX8bEQA0gKkWyZz2DUHiN8+cGGQeKlb1i9GIbhIUo2Ia3VdBV6IfZ6p4q5LvoV5Q ag71MJHAhpu7+PxJRBY9t4uRci2KhwAeVcKAx6vnW1+b91m+2l2jSsiCVygW2UKPEtau X5IqYBR1bpVFUulki2Zv3KHN9qDafRcMxPRe3byRbt1IZcMr5q+TNsYQmLoG2zQYQ/B9 ljww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KfqJioYD; 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 n9-20020a05622a040900b003ba15b2d1f9si959715qtx.604.2023.03.02.19.00.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:26 -0800 (PST) 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=KfqJioYD; 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 1pXvcu-0007cH-HX; Thu, 02 Mar 2023 21:58:32 -0500 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 1pXvcs-0007b6-Qq for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcq-0001tX-4F for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: by mail-pl1-x62f.google.com with SMTP id p6so1415782plf.0 for ; Thu, 02 Mar 2023 18:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812306; 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=DyucSr1+mDuhxSYgjTJ7OboyUx9A5mZckDpsrPxpF7I=; b=KfqJioYD/XSiAq/2scJYp5XLqWjcGKgbbCuVRIRVRkMQDXwNJbTnRZXEg12a9hVJ7N 4SBvdN06vI1YdN/wrIqb2YPpQsGjV1fnm9rL897dxRnpbLGC7l5Byn0bxzSE0BZw36fM zThfYBVEiVcs4QpybbnmxclbtoEiHv27Oj9Bn9dQw+OR2kbKYS7krz+nPUtoioUsZNf6 IqRk8W7lwJolVwFk+Ex4zuH5T55CozrCrJTOgp+xAK2SYSWDlrTKcnP/lIYSUG8BQfWj 4+VcH3J5zMzvpeG2kfb8SsltiIYQK4kiM1et2G6dvXRf+PSiDM/yWTiGVBIQw/zvwAKi K4DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812306; 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=DyucSr1+mDuhxSYgjTJ7OboyUx9A5mZckDpsrPxpF7I=; b=uED7xHlqoeIdS2uhxbsUGp1KTEfs/xeOGE0o4T+yq+BFMAl3ix29l4tJ6VhJ+eoGqD wLYhcJKoRE8tl8u6bQHzyeGozke/AeF8v4GN1IPcWh+fM0R1FMdsgdKYN/oyAMVwCcJ8 Jwhy1U7lv4I8Qu/SOn+QQtkyfyyJ7j9N9QY/qMA0Tc14ZSXmkOv4ncbwOOZC7IEDTCHx ADnkXG4W+i7GwiYEUUWuSnebYFfHvPzoxTd0SM3VgrgvSVnZUjbWqSZ2Xy6g+UwqubrL eN4nXtkFqq65TGx/j9ZIsttcRzykVfZFEbbJ1qAZX6tREpX1tgBsEgCJQiux7GXb0cUu JQTQ== X-Gm-Message-State: AO0yUKX042Yrq2tHnPoGkLn03R3gT9QONbXAMQ5OzmLeJObX+0ml2PGJ keaH6GcP2ZO0erXMiyeay3gMHnZJYJTmnJi03/g= X-Received: by 2002:a17:902:e5c8:b0:19d:1dfe:eab4 with SMTP id u8-20020a170902e5c800b0019d1dfeeab4mr529330plf.41.1677812306558; Thu, 02 Mar 2023 18:58:26 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Paolo Bonzini Subject: [PATCH v4.5 23/29] testing: probe gdb for supported architectures ahead of time Date: Thu, 2 Mar 2023 18:57:59 -0800 Message-Id: <20230303025805.625589-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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 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: Alex Bennée Currently when we encounter a gdb that is old or not built with multiarch in mind we fail rather messily. Try and improve the situation by probing ahead of time and setting HOST_GDB_SUPPORTS_ARCH=y in the relevant tcg configs. We can then skip and give a more meaningful message if we don't run the test. Cc: Paolo Bonzini Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20230302190846.2593720-24-alex.bennee@linaro.org> --- MAINTAINERS | 1 + configure | 8 ++ scripts/probe-gdb-support.py | 88 +++++++++++++++++++ tests/tcg/aarch64/Makefile.target | 2 +- tests/tcg/multiarch/Makefile.target | 5 ++ .../multiarch/system/Makefile.softmmu-target | 6 +- tests/tcg/s390x/Makefile.target | 2 +- 7 files changed, 109 insertions(+), 3 deletions(-) create mode 100755 scripts/probe-gdb-support.py diff --git a/MAINTAINERS b/MAINTAINERS index c7a8e2307f..8d0113b8f9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2739,6 +2739,7 @@ F: include/gdbstub/* F: gdb-xml/ F: tests/tcg/multiarch/gdbstub/ F: scripts/feature_to_c.sh +F: scripts/probe-gdb-support.py Memory API M: Paolo Bonzini diff --git a/configure b/configure index 50a0b80b27..f0cd3923f3 100755 --- a/configure +++ b/configure @@ -230,6 +230,7 @@ stack_protector="" safe_stack="" use_containers="yes" gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb") +gdb_arches="" if test -e "$source_path/.git" then @@ -2392,6 +2393,7 @@ if test -n "$gdb_bin"; then gdb_version=$($gdb_bin --version | head -n 1) if version_ge ${gdb_version##* } 9.1; then echo "HAVE_GDB_BIN=$gdb_bin" >> $config_host_mak + gdb_arches=$("$source_path/scripts/probe-gdb-support.py" $gdb_bin) else gdb_bin="" fi @@ -2516,6 +2518,12 @@ for target in $target_list; do write_target_makefile "build-tcg-tests-$target" >> "$config_target_mak" echo "BUILD_STATIC=$build_static" >> "$config_target_mak" echo "QEMU=$PWD/$qemu" >> "$config_target_mak" + + # will GDB work with these binaries? + if test "${gdb_arches#*$arch}" != "$gdb_arches"; then + echo "HOST_GDB_SUPPORTS_ARCH=y" >> "$config_target_mak" + fi + echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> Makefile.prereqs tcg_tests_targets="$tcg_tests_targets $target" fi diff --git a/scripts/probe-gdb-support.py b/scripts/probe-gdb-support.py new file mode 100755 index 0000000000..35219f555c --- /dev/null +++ b/scripts/probe-gdb-support.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 +# coding: utf-8 +# +# Probe gdb for supported architectures. +# +# This is required to support testing of the gdbstub as its hard to +# handle errors gracefully during the test. Instead this script when +# passed a GDB binary will probe its architecture support and return a +# string of supported arches, stripped of guff. +# +# Copyright 2023 Linaro Ltd +# +# Author: Alex Bennée +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import argparse +import re +from subprocess import check_output, STDOUT + +# mappings from gdb arch to QEMU target +mappings = { + "alpha" : "alpha", + "aarch64" : ["aarch64", "aarch64_be"], + "armv7": "arm", + "armv8-a" : ["aarch64", "aarch64_be"], + "avr" : "avr", + "cris" : "cris", + # hexagon? + "hppa1.0" : "hppa", + "i386" : "i386", + "i386:x86-64" : "x86_64", + "Loongarch64" : "loongarch64", + "m68k" : "m68k", + "MicroBlaze" : "microblaze", + "mips:isa64" : ["mips64", "mips64el"], + "nios2" : "nios2", + "or1k" : "or1k", + "powerpc:common" : "ppc", + "powerpc:common64" : ["ppc64", "ppc64le"], + "riscv:rv32" : "riscv32", + "riscv:rv64" : "riscv64", + "s390:64-bit" : "s390x", + "sh4" : ["sh4", "sh4eb"], + "sparc": "sparc", + "sparc:v8plus": "sparc32plus", + "sparc:v9a" : "sparc64", + # no tricore in upstream gdb + "xtensa" : ["xtensa", "xtensaeb"] +} + +def do_probe(gdb): + gdb_out = check_output([gdb, + "-ex", "set architecture", + "-ex", "quit"], stderr=STDOUT) + + m = re.search(r"Valid arguments are (.*)", + gdb_out.decode("utf-8")) + + valid_arches = set() + + if m.group(1): + for arch in m.group(1).split(", "): + if arch in mappings: + mapping = mappings[arch] + if isinstance(mapping, str): + valid_arches.add(mapping) + else: + for entry in mapping: + valid_arches.add(entry) + + return valid_arches + +def main() -> None: + parser = argparse.ArgumentParser(description='Probe GDB Architectures') + parser.add_argument('gdb', help='Path to GDB binary.') + + args = parser.parse_args() + + supported = do_probe(args.gdb) + + print(" ".join(supported)) + +if __name__ == '__main__': + main() diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index db122ab4ff..9e91a20b0d 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -81,7 +81,7 @@ sha512-vector: sha512.c TESTS += sha512-vector -ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py run-gdbstub-sysregs: sysregs diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index ae8b3d7268..373db69648 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -64,6 +64,7 @@ run-test-mmap-%: test-mmap $(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages)) ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py run-gdbstub-sha1: sha1 @@ -87,6 +88,10 @@ run-gdbstub-thread-breakpoint: testthread --bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \ hitting a breakpoint on non-main thread) +else +run-gdbstub-%: + $(call skip-test, "gdbstub test $*", "no guest arch support") +endif else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") diff --git a/tests/tcg/multiarch/system/Makefile.softmmu-target b/tests/tcg/multiarch/system/Makefile.softmmu-target index 368b64d531..5f432c95f3 100644 --- a/tests/tcg/multiarch/system/Makefile.softmmu-target +++ b/tests/tcg/multiarch/system/Makefile.softmmu-target @@ -15,6 +15,7 @@ MULTIARCH_TEST_SRCS=$(wildcard $(MULTIARCH_SYSTEM_SRC)/*.c) MULTIARCH_TESTS = $(patsubst $(MULTIARCH_SYSTEM_SRC)/%.c, %, $(MULTIARCH_TEST_SRCS)) ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py run-gdbstub-memory: memory @@ -26,7 +27,10 @@ run-gdbstub-memory: memory "-monitor none -display none -chardev file$(COMMA)path=$<.out$(COMMA)id=output $(QEMU_OPTS)" \ --bin $< --test $(MULTIARCH_SRC)/gdbstub/memory.py, \ softmmu gdbstub support) - +else +run-gdbstub-%: + $(call skip-test, "gdbstub test $*", "no guest arch support") +endif else run-gdbstub-%: $(call skip-test, "gdbstub test $*", "need working gdb") diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target index 72ad309b27..b7f576f983 100644 --- a/tests/tcg/s390x/Makefile.target +++ b/tests/tcg/s390x/Makefile.target @@ -51,7 +51,7 @@ $(Z15_TESTS): CFLAGS+=-march=z15 -O2 TESTS+=$(Z15_TESTS) endif -ifneq ($(HAVE_GDB_BIN),) +ifeq ($(HOST_GDB_SUPPORTS_ARCH),y) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py run-gdbstub-signals-s390x: signals-s390x From patchwork Fri Mar 3 02:58:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658465 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226485wrb; Thu, 2 Mar 2023 19:01:51 -0800 (PST) X-Google-Smtp-Source: AK7set9vPP+bB6fOTuCskMmFgZmRUPOCKKbEfp6af+AJ1kqDOyzNXo6zggOUfABegbmJ00gic1UC X-Received: by 2002:ac8:5acd:0:b0:3bf:b896:ff72 with SMTP id d13-20020ac85acd000000b003bfb896ff72mr604098qtd.68.1677812511568; Thu, 02 Mar 2023 19:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812511; cv=none; d=google.com; s=arc-20160816; b=SD3WnZK9yHraArofZJkHha9tDLLV7jiJENS/I/AW3sf9qJgmuWnMUYGY5wqrm9nBre ydTgTUShRltMkYxSYOHQXkI8LzocRd8vCOnP3wAf3n/Eghne/HoTvnWxlo4cGR45jY3u jzBnhwgNNDtqTFQ1F/MiVfEAP7/HRSLgByUFVcTvI7mvBiHj+y+lzKSfdr22iXncwLUe FgUB/TPt0BS43eAvpk0wAtGgja5tzN/VjsTt8fm0mvXhKQvtfZ5lJWw1ieYSbSCtFnqy Cj1IBE1Lt5B17OS9gOLs/F+w1ypI5EW9CMngaj6yv7Zn/uffLiJ9eHyouPSnst0mALCJ V9oA== 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=KRaITTDPU/D6klVb43sMtjcQy7hN+w0/N4+Vvipb27U=; b=I4tlilEIuR72l8N1GCYxspxp8+pZPWXqNlf3u3dUcvFBY2YcRxVWlk2JH+bjdS+8M8 by9V3083kUoP0iIfZLg1SuNhI/d/4nqkLAuAZ40lxB0FN7CJmzMfITHC46KfUgBj1653 XwuNNcBwRhQcAUw5BSGZYh3hquLraikUNCHvMQtRx4oyRdMdQCqCxbtG/6EhpX1sZBR7 9M/fgsl75Q2Irv+jT/j2w32xpzcQ512uAhHVyS6a8iC00O7lXrQV7+MroAZDxpZ207LA etYzG/0SzQ1IswgmbDJW9lG0lTQjet4A+89+zsurWXWDX8r9DzwWT3mTzrzy4ZxQOoGy cdww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gp+rIZIT; 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 l20-20020a05622a175400b003b86be9c604si1011149qtk.301.2023.03.02.19.01.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:01:51 -0800 (PST) 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=gp+rIZIT; 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 1pXvcu-0007cA-Cz; Thu, 02 Mar 2023 21:58:32 -0500 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 1pXvcs-0007ax-J4 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcq-0001ta-Po for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: by mail-pl1-x630.google.com with SMTP id n6so1349585plf.5 for ; Thu, 02 Mar 2023 18:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812307; 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=KRaITTDPU/D6klVb43sMtjcQy7hN+w0/N4+Vvipb27U=; b=gp+rIZITTpoVxoZKl80/YVSUEdXSkc1kvrWIKz/5Jj9skHq5OWGrmscm6uuN8bP0bl 8QGo/BGPaPzvMeWWgzCz5HqzFPnMb9n9duFJ8uG/9LughwRXvI+lP5G7XMNAbTORHTnG MgH1W2fsbzZiPhmWvvYHgXp7jKC6U6kxfjB51N4Zh/iKuTd9aftisZOgZWdGfc6SqYbo mBSb0AX90zOLUAFyDKlHuNuFeF8HLy3/Gf5zLxY9PhbtIAX3dxUwQQ4mxKRKwWyTFjkn LtDP0OKRnSHhx8gph17UTIgE6YnEo2JKnil5Vn7jsJNO665/LaLfNIrI+6doporIpCUz M+Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812307; 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=KRaITTDPU/D6klVb43sMtjcQy7hN+w0/N4+Vvipb27U=; b=2i1tWpDBdObyEtPi1mQtPRBWtFEy+ICeieYnvAh0/DMFU+X3MGG1wfPQHzZ7UsFFk2 UEj+kxtTzKrl5tSEccrkT32Ml5iuXLmYY82Ra1mdKuWHgA3zi+6JYEWPpj/101RhJXNU D1IB+exLLJQ0MBU2MqLkg/cVb86IgGx8/SNv29LBGnyHcUTQLjefzA8CcyfeF2J8rNsF KHJOFL75TXv+YDea0DHcjWkuKp90ADIPOwIo8mzK4gx/dN1zYtm75zxeCny+/QBqStPG h25Fr81VW28RRQ7knO6yzU/iuYjBsVHsebEQyKpK1raBqNbDbd/BLguV42ZW3ixEkzKC s5Wg== X-Gm-Message-State: AO0yUKWkILSFz8+JVpgLFAC419HuMBQvL6JfnFBOPu+QTUNPUrrbn5hI xOGlzSvUS5mJJ+XL2kq9IFnxaH6P3S7A4vzuzOw= X-Received: by 2002:a17:902:db01:b0:19b:c37:25e7 with SMTP id m1-20020a170902db0100b0019b0c3725e7mr431698plx.66.1677812307293; Thu, 02 Mar 2023 18:58:27 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 24/29] include: split target_long definition from cpu-defs Date: Thu, 2 Mar 2023 18:58:00 -0800 Message-Id: <20230303025805.625589-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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 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: Alex Bennée While we will continue to include this via cpu-defs it is useful to be able to define this separately for 32 and 64 bit versions of an otherwise target independent compilation unit. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-25-alex.bennee@linaro.org> --- MAINTAINERS | 1 + include/exec/cpu-defs.h | 19 +---------------- include/exec/target_long.h | 42 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 include/exec/target_long.h diff --git a/MAINTAINERS b/MAINTAINERS index 8d0113b8f9..3ef68cd0cf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -137,6 +137,7 @@ F: docs/devel/tcg* F: include/exec/cpu*.h F: include/exec/exec-all.h F: include/exec/tb-flush.h +F: include/exec/target_long.h F: include/exec/helper*.h F: include/sysemu/cpus.h F: include/sysemu/tcg.h diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h index be920d4208..cd8aa177cc 100644 --- a/include/exec/cpu-defs.h +++ b/include/exec/cpu-defs.h @@ -55,24 +55,7 @@ # endif #endif -#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) - -/* target_ulong is the type of a virtual address */ -#if TARGET_LONG_SIZE == 4 -typedef int32_t target_long; -typedef uint32_t target_ulong; -#define TARGET_FMT_lx "%08x" -#define TARGET_FMT_ld "%d" -#define TARGET_FMT_lu "%u" -#elif TARGET_LONG_SIZE == 8 -typedef int64_t target_long; -typedef uint64_t target_ulong; -#define TARGET_FMT_lx "%016" PRIx64 -#define TARGET_FMT_ld "%" PRId64 -#define TARGET_FMT_lu "%" PRIu64 -#else -#error TARGET_LONG_SIZE undefined -#endif +#include "exec/target_long.h" #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) diff --git a/include/exec/target_long.h b/include/exec/target_long.h new file mode 100644 index 0000000000..93c9472971 --- /dev/null +++ b/include/exec/target_long.h @@ -0,0 +1,42 @@ +/* + * Target Long Definitions + * + * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2023 Linaro Ltd + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _TARGET_LONG_H_ +#define _TARGET_LONG_H_ + +/* + * Usually this should only be included via cpu-defs.h however for + * certain cases where we want to build only two versions of a binary + * object we can include directly. However the build-system must + * ensure TARGET_LONG_BITS is defined directly. + */ +#ifndef TARGET_LONG_BITS +#error TARGET_LONG_BITS not defined +#endif + +#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) + +/* target_ulong is the type of a virtual address */ +#if TARGET_LONG_SIZE == 4 +typedef int32_t target_long; +typedef uint32_t target_ulong; +#define TARGET_FMT_lx "%08x" +#define TARGET_FMT_ld "%d" +#define TARGET_FMT_lu "%u" +#elif TARGET_LONG_SIZE == 8 +typedef int64_t target_long; +typedef uint64_t target_ulong; +#define TARGET_FMT_lx "%016" PRIx64 +#define TARGET_FMT_ld "%" PRId64 +#define TARGET_FMT_lu "%" PRIu64 +#else +#error TARGET_LONG_SIZE undefined +#endif + +#endif /* _TARGET_LONG_H_ */ From patchwork Fri Mar 3 02:58:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658456 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225863wrb; Thu, 2 Mar 2023 19:00:37 -0800 (PST) X-Google-Smtp-Source: AK7set+ZfKcR/9/qD3XbrGb1IxK4AolKxxL5bguLcd3vuEK4m7G2dA9YuuqQko/Zen9Bk3tJw1RF X-Received: by 2002:a05:622a:14e:b0:3bf:c407:10ca with SMTP id v14-20020a05622a014e00b003bfc40710camr942109qtw.10.1677812437466; Thu, 02 Mar 2023 19:00:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812437; cv=none; d=google.com; s=arc-20160816; b=Rpoi0vzJ8BJhPVWfMgkd0XxNlFQMRmYoN+KXg8TFcHPU0+0eHSHX6/Y+oMJF6P6zuy eM4loJyVBczZOh5aDsCXmmDYWNFNvJM7+Ql7hnk+WwM6NW1LLtmxvXdHp8CTYtvKPZgB DxSbLzmDk12zG3Xfni+1p4NoYK2pSj9HG6zPa0Zc+xcq4V1DhhgdDMp8jiOnNNveXztH QVeqR4sMsjPXEnXY0HaMN7TIHcFY6cPgBd010wCAlxRGb7geniAwfwXkb36oqcIjdDWD 0XqiEP0j617otyAmdhwPLTCk3HmedW9tYuEBa8enpgweidZq+DT7YfLYi1NRyxBg7rZJ AaLw== 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=6d5cuY6swY8U6e//2djcuW9/WFKA+am2NtOsQtC3Xo4=; b=GUQvyWYpurYKleK6Gn2mdqafDznx6qdt0S2tk9gjYRsEWc+TiVJ333Vj8SCrlrZntV 21aIDlV4gllbuVW3ASa3qBcng/ASxLLn9OWRtJ8Io+WyIc8MeLYIX2rPMk/Ci1r348Dm i/4+KF/tnW7CB/c8Trhu1oAr/biUnfY2pL+eEB2k5lHCp56HHuQuoPtmN3WMQ3MnenMj gLSmRyvdew3k2V3A8/C0SV/9WNxo5Ib6jYtvHl4biLcC/2oVQIk1Fv1kjnbwebY4YE5A Ooq+6Uf/NzMhd95BquADKu8DhFouqospCGvxRficl5FSUgxm+HdWPCQpSoYtFrjrVr4f vi5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hHYpkzks; 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 d2-20020a05622a100200b003ba2a171913si914549qte.578.2023.03.02.19.00.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:37 -0800 (PST) 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=hHYpkzks; 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 1pXvcv-0007co-Lk; Thu, 02 Mar 2023 21:58:33 -0500 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 1pXvct-0007bf-Ld for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:31 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcr-0001ti-Gs for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:31 -0500 Received: by mail-pl1-x631.google.com with SMTP id i5so1367106pla.2 for ; Thu, 02 Mar 2023 18:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812308; 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=6d5cuY6swY8U6e//2djcuW9/WFKA+am2NtOsQtC3Xo4=; b=hHYpkzksNrat8BA3PYARXUxXH1R2SflMSwePo8EImrDoYFC7kji1Qrr1s5RiiWlLdP 0PiomXrDunwVCrl1ueWvL+gIDpG6WeA0NHhPyihQZGXfCw/rYojzwc+NlVq7M7nU3wUM R4gOAPS3cYatrV5f87UDnVDmKmM/r6EOb+TMDd5s2GkN/bcR+k1q1knLcieuhJX0JXFS fbearFxrPbv7clLpMxxFocpflLxxQaBdNQhLvHv7jDCwgdjTJtTrRMR+5jjGb1AuIbQv GxqpdyadPNuGmK9L3RVyPdkMNGbFFuT8WgF6Ckb8KwwzfpUUsCUou6A4Z3B32mSDwGxq ALPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812308; 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=6d5cuY6swY8U6e//2djcuW9/WFKA+am2NtOsQtC3Xo4=; b=c2NZ66fNXHZvjx7duhqEKY1qLRKQ2qtqpJItDO+15t+jbhrLYrodBhTQl33EZOvnG4 Is+pW89l+dsIRTwvzypaivUEuvYcgLmUqo3qRXjKSIOB+qsOLMWrofS3MhtYk5q2lRs/ aaESDAnZCpw9C0fUzOFwcRDN35OQvmuTZwR8v//WO/cp20BHowflaBP3z/RogjO6yiWC LEUhLo8Xh7lZi0rFnFx8UX6h1nKRLtQhGo8LrE/onXqRgoK8XZrkD7IcnWjX3lACj5kR DeLEl1pgz4zyA2JmyU3pI17boKA64cTvsI09RA/7qayNXaLsuEu87paEvVTtTAD9hDvf JyZA== X-Gm-Message-State: AO0yUKV7tbF9oqWq4kUNpzpVwsJR1uHJ1HJ2YzRw/RZMbPgm7O8lEUoL 3qWIKRHJf4TCY+AueZ1EVdX9cln+xTalILSg+Jo= X-Received: by 2002:a17:902:8bcb:b0:19e:664e:fcaf with SMTP id r11-20020a1709028bcb00b0019e664efcafmr546260plo.0.1677812308062; Thu, 02 Mar 2023 18:58:28 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 25/29] gdbstub: split out softmmu/user specifics for syscall handling Date: Thu, 2 Mar 2023 18:58:01 -0800 Message-Id: <20230303025805.625589-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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 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: Alex Bennée Most of the syscall code is config agnostic aside from the size of target_ulong. In preparation for the next patch move the final bits of specialisation into the appropriate user and softmmu helpers. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20230302190846.2593720-26-alex.bennee@linaro.org> --- gdbstub/internals.h | 3 +++ gdbstub/softmmu.c | 14 ++++++++++++++ gdbstub/syscalls.c | 27 +++------------------------ gdbstub/user.c | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 8db61f7fb4..94ddff4495 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -195,6 +195,9 @@ bool gdb_handled_syscall(void); void gdb_disable_syscalls(void); void gdb_syscall_reset(void); +/* user/softmmu specific syscall handling */ +void gdb_syscall_handling(const char *syscall_packet); + /* * Break/Watch point support - there is an implementation for softmmu * and user mode. diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index d3152fb6e7..22ecd09d04 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -103,6 +103,20 @@ static void gdb_chr_event(void *opaque, QEMUChrEvent event) } } +/* + * In softmmu mode we stop the VM and wait to send the syscall packet + * until notification that the CPU has stopped. This must be done + * because if the packet is sent now the reply from the syscall + * request could be received while the CPU is still in the running + * state, which can cause packets to be dropped and state transition + * 'T' packets to be sent while the syscall is still being processed. + */ +void gdb_syscall_handling(const char *syscall_packet) +{ + vm_stop(RUN_STATE_DEBUG); + qemu_cpu_kick(gdbserver_state.c_cpu); +} + static void gdb_vm_state_change(void *opaque, bool running, RunState state) { CPUState *cpu = gdbserver_state.c_cpu; diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index f15b210958..0a48f58d70 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -104,9 +104,7 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) } gdbserver_syscall_state.current_syscall_cb = cb; -#ifndef CONFIG_USER_ONLY - vm_stop(RUN_STATE_DEBUG); -#endif + p = &gdbserver_syscall_state.syscall_buf[0]; p_end = &gdbserver_syscall_state.syscall_buf[sizeof(gdbserver_syscall_state.syscall_buf)]; *(p++) = 'F'; @@ -141,27 +139,8 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) } } *p = 0; -#ifdef CONFIG_USER_ONLY - gdb_put_packet(gdbserver_syscall_state.syscall_buf); - /* - * Return control to gdb for it to process the syscall request. - * Since the protocol requires that gdb hands control back to us - * using a "here are the results" F packet, we don't need to check - * gdb_handlesig's return value (which is the signal to deliver if - * execution was resumed via a continue packet). - */ - gdb_handlesig(gdbserver_state.c_cpu, 0); -#else - /* - * In this case wait to send the syscall packet until notification that - * the CPU has stopped. This must be done because if the packet is sent - * now the reply from the syscall request could be received while the CPU - * is still in the running state, which can cause packets to be dropped - * and state transition 'T' packets to be sent while the syscall is still - * being processed. - */ - qemu_cpu_kick(gdbserver_state.c_cpu); -#endif + + gdb_syscall_handling(gdbserver_syscall_state.syscall_buf); } void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) diff --git a/gdbstub/user.c b/gdbstub/user.c index 3da410e221..80488b6bb9 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -472,3 +472,17 @@ void gdb_breakpoint_remove_all(CPUState *cs) { cpu_breakpoint_remove_all(cs, BP_GDB); } + +/* + * For user-mode syscall support we send the system call immediately + * and then return control to gdb for it to process the syscall request. + * Since the protocol requires that gdb hands control back to us + * using a "here are the results" F packet, we don't need to check + * gdb_handlesig's return value (which is the signal to deliver if + * execution was resumed via a continue packet). + */ +void gdb_syscall_handling(const char *syscall_packet) +{ + gdb_put_packet(syscall_packet); + gdb_handlesig(gdbserver_state.c_cpu, 0); +} From patchwork Fri Mar 3 02:58:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658462 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp226068wrb; Thu, 2 Mar 2023 19:01:01 -0800 (PST) X-Google-Smtp-Source: AK7set81Sxnwv4RSHIjmPqrGajq2qZZTM+CWxQG46MXnxrK5BIZb7PrtG3wd+PxwH8Cd4GJSIHub X-Received: by 2002:a05:6214:c4f:b0:574:8ef8:89d1 with SMTP id r15-20020a0562140c4f00b005748ef889d1mr659729qvj.5.1677812460899; Thu, 02 Mar 2023 19:01:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812460; cv=none; d=google.com; s=arc-20160816; b=o5vgVzHE5460Nu30/cCCPD4pwbTQDcCHIBPFZGVmtW0cknS/irB2CUf4+SOYgKDJ6O if9+wgUPV12W6nzZBdQkxKjNzh+ZsQnSMhV2EFPrw5UubNyyY27J+vpTwKNG4Mz5h8hH k56PqF1UyVd3/ROdSfiQDPzsefxwG4wiiZEuIAjbhjADwbEl7xWj5xdmzg2ofdNLhvON lgZ764QSgyZRTmxJaV0mT3aGNGVIsVcgQ70TqlowCafM5nkhGLghShx41EqsJg3Nuk/R JAtUGNNDlOvahPxPaDCQyejfLtlRB/S8FRF5+mXZiVcVFBkmabdydfTe0JGl3A2MPOZV 3WQA== 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=CWVGvsm0VObLmtXd6+IOdcWIt2VbqCAgLdqZOqtIWuY=; b=G+nUxMpy4NQgLP/JqN9njtarhawalt5TTgNyt0Pq0vVWTaVyMmmuoHswd/5RR4ZTiE rQ3uKs3c7PCDhvVuQC5FLX33FDVJEhx1e09o+W1i9P9/vEJeFF/PFfZ+FENbu24gTVFn HsuQV4s6gH0NETcY46n/F/h7qKVClvSLmURNQDmEF+D6DQvYkFXOnP1OTia1l0f8sLdE 3ITbhFPb/KpqPBW0HBZlfwG+4wT+JjewNi81MDOjupXlZhPhL+DzKWReEBkIGSVewtPN 9js42OZxb/KUCvCekkmtzMzouY3WnaiOgUDugNTkRDx+pbv5c/iCOPD5ELnvG96l6Lbq Mw+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IYGO5mGI; 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 n10-20020a0c9d4a000000b00570b7ce3d78si653726qvf.465.2023.03.02.19.01.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:01:00 -0800 (PST) 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=IYGO5mGI; 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 1pXvcv-0007cJ-0m; Thu, 02 Mar 2023 21:58:33 -0500 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 1pXvct-0007bI-4r for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:31 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcr-0001q5-H0 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:30 -0500 Received: by mail-pl1-x62c.google.com with SMTP id z2so1304391plf.12 for ; Thu, 02 Mar 2023 18:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812309; 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=CWVGvsm0VObLmtXd6+IOdcWIt2VbqCAgLdqZOqtIWuY=; b=IYGO5mGIcZ7UaHZbX7HYumvxijAinMeQIwqDcOkL3c0sUA+tSZdLz2l+gC0QSVBgrE MWgoihozps1NJ6dgAvPq0LpMl7yuVdiPBWPHOkii4CCiH7kwERVgeS9U3seQ2FJjhNfm 4eunSQprzqSB+jaaduU0G+7w7i0vkGHgozHiQMMwjQv0AvwUEjHtZW0h8dago+U0bF6S RZ3/lD9qTY/kXQ1cCVTyggZCIozem47t1ixLTajqwMVrUhvUHtSNQR8S4QN6YeRTtzHe D4yPs2/raZYDzBIF19TyXZlZh+YBN+8TLMPkcKkQs+bNvNjhgC5uhcnHjQ4o8jR7fkg0 zwcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812309; 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=CWVGvsm0VObLmtXd6+IOdcWIt2VbqCAgLdqZOqtIWuY=; b=5eMT7QT8WnlSFjHCqnYG8qjA5ujt/HK0aaKp+lEJ1CbGIA2Yc+JN2NY2Haau3ZQJjN xXks+vlNIHl3mnh4zp5yUxu6yQ4keA/2BX1fD7nOf42aB12nR2j2AFIIxlG0qn3waQ31 dLODZWS0EWOSjAqvtZLVsm6vY21sgifXQEPrEExaVW2xg3oE9g6nH6HwZ0L5WStD2y/T h7Az98aiHoOi9QyZ8nRBNGUMqbqgX2pQ1ETyBhnwmHwK5fQfH3WYcNmooZEAjfwn/O4S XpGf/rSOoRqc32iWdZK4qUkzKYwLZTmOsEYB5Dfhg5cPXPS0mk6c+RSAzdkfayDZLZId 7iTw== X-Gm-Message-State: AO0yUKVxHJMNF9v7xIfBHC/y0Syh1Fq1xhRcFA63Lpe/vuy8DpLbIxTv 7ICjWlSNG7gIfhapCpZ73fwDcXDRTOI3cJsBEvY= X-Received: by 2002:a17:902:d54f:b0:19e:73a9:c21b with SMTP id z15-20020a170902d54f00b0019e73a9c21bmr516795plf.45.1677812308751; Thu, 02 Mar 2023 18:58:28 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 26/29] gdbstub: Remove gdb_do_syscallv Date: Thu, 2 Mar 2023 18:58:02 -0800 Message-Id: <20230303025805.625589-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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 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 This function is unused, except to implement gdb_do_syscall. Fold the implementations together. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/gdbstub/syscalls.h | 11 ----------- gdbstub/syscalls.c | 26 ++++++++++---------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/include/gdbstub/syscalls.h b/include/gdbstub/syscalls.h index 5851a2c706..243eaf8ce4 100644 --- a/include/gdbstub/syscalls.h +++ b/include/gdbstub/syscalls.h @@ -91,17 +91,6 @@ typedef void (*gdb_syscall_complete_cb)(CPUState *cpu, uint64_t ret, int err); */ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); -/** - * gdb_do_syscallv: - * @cb: function to call when the system call has completed - * @fmt: gdb syscall format string - * @va: arguments to interpolate into @fmt - * - * As gdb_do_syscall, but taking a va_list rather than a variable - * argument list. - */ -void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va); - /** * use_gdb_syscalls() - report if GDB should be used for syscalls * diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index 0a48f58d70..af42e244f9 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -92,24 +92,26 @@ bool gdb_handled_syscall(void) * %lx - 64-bit argument printed in hex. * %s - string pointer (target_ulong) and length (int) pair. */ -void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) +void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) { - char *p; - char *p_end; - target_ulong addr; - uint64_t i64; + char *p, *p_end; + va_list va; if (!gdb_attached()) { return; } gdbserver_syscall_state.current_syscall_cb = cb; + va_start(va, fmt); - p = &gdbserver_syscall_state.syscall_buf[0]; - p_end = &gdbserver_syscall_state.syscall_buf[sizeof(gdbserver_syscall_state.syscall_buf)]; + p = gdbserver_syscall_state.syscall_buf; + p_end = p + sizeof(gdbserver_syscall_state.syscall_buf); *(p++) = 'F'; while (*fmt) { if (*fmt == '%') { + target_ulong addr; + uint64_t i64; + fmt++; switch (*fmt++) { case 'x': @@ -140,16 +142,8 @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va) } *p = 0; - gdb_syscall_handling(gdbserver_syscall_state.syscall_buf); -} - -void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) -{ - va_list va; - - va_start(va, fmt); - gdb_do_syscallv(cb, fmt, va); va_end(va); + gdb_syscall_handling(gdbserver_syscall_state.syscall_buf); } /* From patchwork Fri Mar 3 02:58:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658458 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225961wrb; Thu, 2 Mar 2023 19:00:48 -0800 (PST) X-Google-Smtp-Source: AK7set+nO2HwlRP8Njf0WtHSZrIsTcQmQ1N6djiMSEpxo6lFrcU0QkyZSKr+B82+rtNxJhpkEhpo X-Received: by 2002:a05:6214:c46:b0:56e:aa11:daa3 with SMTP id r6-20020a0562140c4600b0056eaa11daa3mr684175qvj.14.1677812448130; Thu, 02 Mar 2023 19:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812448; cv=none; d=google.com; s=arc-20160816; b=Eot6phvGDTLtI3+fnzPnSKxaAIVf6MEXmJrarH7m+v7sAXQayuAoRkFSPxXqXc20kt 2f5zYqXTIWzG1FXbxgfCjrv4UyqlM6aE+V1w21EeKyzmz0sjtrJfYCzCPDgwugK0kPGV n0e7XSmFRcwC+EApDqxA5a5ETSAiCNCM9XXkQfiCqTYqbLqfJrZ98tCi/sZzXCV9GMaG C0Oj8aUeLkdY3bqKFc8umUV1xwZiFwvVH6dpxByhIXX0sThYAPGMQh/sVdrbHR9w+T3L pWLgT1vkf4xPtW13uX3m+xrHfSBhLdv6zEzZseeL8Xo4Ln+pzQtJ4pSjHLzjAy/oe1rd sSkQ== 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=kpo/p9yzI64Tx7SaKYcCkvRfvTqYOcBW+5MSbV4gbos=; b=u9a0cg8q4OEKiH0B27O3Cg9UkAPeAmX5rB/qSD+J/YCedoa9A4agTzhoazFcRaoNPd SC6EcitdMZWWQgjgBRN2BfPo0NagsxMGtXSv8T1i8QYJV8SRl4uALxz9KS89oS0kLNjL DbP+STLydJ+j9c5q9Wpo1WeMIIiSCqfgY3b530mICTVvI4VZzvMK7Kyuy4zqvBjabMyw qUR4zkATewEB+li14z6tl+YintzVjfJkdvCFfDDwRRqH729G2xioPJJWtWR6kAqKSRgO ss1d33FjH9WinOHHDae3hbG/boUXYP4y2cHSl+fcks0ifdIoOm/xmktMfVb45loq97dc Af/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I6fkVpJU; 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 x14-20020a0ce24e000000b0056ea4991a4csi749682qvl.0.2023.03.02.19.00.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 19:00:48 -0800 (PST) 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=I6fkVpJU; 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 1pXvcv-0007cL-4T; Thu, 02 Mar 2023 21:58:33 -0500 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 1pXvcu-0007c7-7g for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:32 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvcs-0001qG-8P for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:31 -0500 Received: by mail-pj1-x102d.google.com with SMTP id y15-20020a17090aa40f00b00237ad8ee3a0so967885pjp.2 for ; Thu, 02 Mar 2023 18:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812309; 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=kpo/p9yzI64Tx7SaKYcCkvRfvTqYOcBW+5MSbV4gbos=; b=I6fkVpJUcgLB0yPqniPC8TiaQMFcnbl/WJ/GKCyxW/t+JwQOLwnlJXg1rGYcKsYiQT NK1E1KxHEOCUkKEK2son5OOPX4XdMtatq+Ot1wPsihtOtYDZiuuLeLcs4ckvR7S7IBja B8LWpnh6gAmNkv69ff2icYijrGhCm+xMe7PEvQ5626CnzAWufGydPe2nqa2+VlgkB1jg 9bTDjyUq0K+oDtHdL5649a2w44cBEUdrf6y4m3viTc8pk4Rdfh0X8mjpOCKq+3IM6BYM 4ahS9ZMYUAjx95SCLrft8gpKapTHF7Z8JR/iQjk/YQf5u66J6GFk7Rx5mVIUV0l7AFKP a8mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812309; 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=kpo/p9yzI64Tx7SaKYcCkvRfvTqYOcBW+5MSbV4gbos=; b=HEzygRGDh/dhtw8p5yl4kqewsCiY0+Z9n7LgdgzWOlT6kps0u0fQ7N+MIDlKEtOdwp Cxep17CEZ9L97Dz0tEV5c2xRaUMQBBNuCEASMWsTgLXNl79RwDHVcPJ1iqAk9Q7uTskD WoxvQxJsfwjDYoIGZTGKRA6mdiRPYAet3gD1pUmMM8bFsBsKSNkfiKLSqy8nOwnNkane S63FnFjy70ibHZYfMmcSt1Ftm6EDo2v4cVloEIQx02A6z5mONCqnFvcZw0T9WnC7rUR5 dK8tvb8Tl5pMh128sM4NIQ+wCewkr8XqDvRVrFUw91n7sI4p9npBmdmlFNpqbXOF29K9 z+Tw== X-Gm-Message-State: AO0yUKUxbn+e/M8UthftnNpc4ndFtpWTnLH7FFLIzbeIKTVWFqWOtx78 kMrljcpIiCHMWFS9PtLA2akDiyNMaelUZMW8GV4= X-Received: by 2002:a17:902:c10a:b0:19e:7b09:bd4d with SMTP id 10-20020a170902c10a00b0019e7b09bd4dmr447039pli.47.1677812309490; Thu, 02 Mar 2023 18:58:29 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 27/29] gdbstub: Adjust gdb_do_syscall to only use uint32_t and uint64_t Date: Thu, 2 Mar 2023 18:58:03 -0800 Message-Id: <20230303025805.625589-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.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 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 Pass %x as uint32_t and %lx as uint64_t; pass the address of %s as uint64_t and the length as uint32_t. Add casts in semihosting/syscalls.c from target_ulong to uint64_t; add casts from int to uint32_t for clarity. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- gdbstub/syscalls.c | 12 ++++++------ semihosting/syscalls.c | 34 ++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index af42e244f9..b7d85c41c7 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -109,14 +109,14 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) *(p++) = 'F'; while (*fmt) { if (*fmt == '%') { - target_ulong addr; uint64_t i64; + uint32_t i32; fmt++; switch (*fmt++) { case 'x': - addr = va_arg(va, target_ulong); - p += snprintf(p, p_end - p, TARGET_FMT_lx, addr); + i32 = va_arg(va, uint32_t); + p += snprintf(p, p_end - p, "%" PRIx32, i32); break; case 'l': if (*(fmt++) != 'x') { @@ -126,9 +126,9 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...) p += snprintf(p, p_end - p, "%" PRIx64, i64); break; case 's': - addr = va_arg(va, target_ulong); - p += snprintf(p, p_end - p, TARGET_FMT_lx "/%x", - addr, va_arg(va, int)); + i64 = va_arg(va, uint64_t); + i32 = va_arg(va, uint32_t); + p += snprintf(p, p_end - p, "%" PRIx64 "/%x" PRIx32, i64, i32); break; default: bad_format: diff --git a/semihosting/syscalls.c b/semihosting/syscalls.c index 42080ffdda..68899ebb1c 100644 --- a/semihosting/syscalls.c +++ b/semihosting/syscalls.c @@ -139,46 +139,48 @@ static void gdb_open(CPUState *cs, gdb_syscall_complete_cb complete, gdb_open_complete = complete; gdb_do_syscall(gdb_open_cb, "open,%s,%x,%x", - fname, len, (target_ulong)gdb_flags, (target_ulong)mode); + (uint64_t)fname, (uint32_t)len, + (uint32_t)gdb_flags, (uint32_t)mode); } static void gdb_close(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf) { - gdb_do_syscall(complete, "close,%x", (target_ulong)gf->hostfd); + gdb_do_syscall(complete, "close,%x", (uint32_t)gf->hostfd); } static void gdb_read(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong buf, target_ulong len) { - gdb_do_syscall(complete, "read,%x,%x,%x", - (target_ulong)gf->hostfd, buf, len); + gdb_do_syscall(complete, "read,%x,%lx,%lx", + (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); } static void gdb_write(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong buf, target_ulong len) { - gdb_do_syscall(complete, "write,%x,%x,%x", - (target_ulong)gf->hostfd, buf, len); + gdb_do_syscall(complete, "write,%x,%lx,%lx", + (uint32_t)gf->hostfd, (uint64_t)buf, (uint64_t)len); } static void gdb_lseek(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, int64_t off, int gdb_whence) { gdb_do_syscall(complete, "lseek,%x,%lx,%x", - (target_ulong)gf->hostfd, off, (target_ulong)gdb_whence); + (uint32_t)gf->hostfd, off, (uint32_t)gdb_whence); } static void gdb_isatty(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf) { - gdb_do_syscall(complete, "isatty,%x", (target_ulong)gf->hostfd); + gdb_do_syscall(complete, "isatty,%x", (uint32_t)gf->hostfd); } static void gdb_fstat(CPUState *cs, gdb_syscall_complete_cb complete, GuestFD *gf, target_ulong addr) { - gdb_do_syscall(complete, "fstat,%x,%x", (target_ulong)gf->hostfd, addr); + gdb_do_syscall(complete, "fstat,%x,%lx", + (uint32_t)gf->hostfd, (uint64_t)addr); } static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete, @@ -191,7 +193,8 @@ static void gdb_stat(CPUState *cs, gdb_syscall_complete_cb complete, return; } - gdb_do_syscall(complete, "stat,%s,%x", fname, len, addr); + gdb_do_syscall(complete, "stat,%s,%lx", + (uint64_t)fname, (uint32_t)len, (uint64_t)addr); } static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete, @@ -203,7 +206,7 @@ static void gdb_remove(CPUState *cs, gdb_syscall_complete_cb complete, return; } - gdb_do_syscall(complete, "unlink,%s", fname, len); + gdb_do_syscall(complete, "unlink,%s", (uint64_t)fname, (uint32_t)len); } static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete, @@ -223,7 +226,9 @@ static void gdb_rename(CPUState *cs, gdb_syscall_complete_cb complete, return; } - gdb_do_syscall(complete, "rename,%s,%s", oname, olen, nname, nlen); + gdb_do_syscall(complete, "rename,%s,%s", + (uint64_t)oname, (uint32_t)olen, + (uint64_t)nname, (uint32_t)nlen); } static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete, @@ -235,13 +240,14 @@ static void gdb_system(CPUState *cs, gdb_syscall_complete_cb complete, return; } - gdb_do_syscall(complete, "system,%s", cmd, len); + gdb_do_syscall(complete, "system,%s", (uint64_t)cmd, (uint32_t)len); } static void gdb_gettimeofday(CPUState *cs, gdb_syscall_complete_cb complete, target_ulong tv_addr, target_ulong tz_addr) { - gdb_do_syscall(complete, "gettimeofday,%x,%x", tv_addr, tz_addr); + gdb_do_syscall(complete, "gettimeofday,%lx,%lx", + (uint64_t)tv_addr, (uint64_t)tz_addr); } /* From patchwork Fri Mar 3 02:58:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658451 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225501wrb; Thu, 2 Mar 2023 18:59:52 -0800 (PST) X-Google-Smtp-Source: AK7set89dg6s/xj5zBB/JmWMMDP52rz/uZjfxUN/NpSt0MgXZ5J4S8Syl13rgyWGWWhspgGQlYed X-Received: by 2002:ac8:7e83:0:b0:3bf:c994:c9b3 with SMTP id w3-20020ac87e83000000b003bfc994c9b3mr680754qtj.61.1677812392104; Thu, 02 Mar 2023 18:59:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812392; cv=none; d=google.com; s=arc-20160816; b=0DndLdFYAeu8VMH3K/1dDQtHCWryIq5f/wdeLFdwZZowndNIiOQON8a2wrOJBCIHmS Y07i2P+3I1xFW2HVnFjFQxtN1waB1ELsudlEGbDFxkGeyRcnCZbgVm0ICQAi6ve/RLdp QBpAHs0xpLioN3hkj2K/W1a6/d0h4pVCszNrvXPk8+24UUNlSfWQQYyrHiZLshXzr2Oz UgDsA4m9NnKLGK36M0bsAdr4OAoSaj7ib9xErjw/wYD4W8Ot5rgf+BVhB8fMjtxDkKto 0CbZvjTGj4s11rsMdNZNG4oniYsWkHEQoAUMGf+QYja+hBkdFZ9bYihyAbrmLSOT2aB1 7g2A== 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=uL8gPV4GfBPCsX5yefLxqBJp76wGELs04Du3rKf0/lI=; b=btaIFCeoDYOTwre2GFoLZwKcaMGi8y51QIG0I5GYI0SN0tDBP3qP+GTFG3R8/fciUB eIA0XuzOl2zvOrQdOLIBM02wRFNJt5g3d5PHI/QLYxDqgyeUONTsiahCERL2iXhrqfa7 VzYRq4jO17IyKgdELsNpyZvItD7olVOipR8KW6TJEniXZBtQ6V0cY821ivKgMOknild9 n0QHaHg+EgnRbyMvTVjofYLKoO6TR4W3xD+UYBd87xStMOqzoE7IjkOppBl7iJiWBJMb VQTIVrXmb0inJAQsyZHuHCuuu28FMhRzEIalrCqeIlB/brEcvP1+6Bs8m6lekd+vxAnF BdiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O7ntNckl; 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 a11-20020ac85b8b000000b003ba10333b13si1046384qta.523.2023.03.02.18.59.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:59:52 -0800 (PST) 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=O7ntNckl; 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 1pXvcy-0007eB-Ji; Thu, 02 Mar 2023 21:58:36 -0500 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 1pXvcv-0007cK-1C for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:33 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvct-0001uN-HG for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:32 -0500 Received: by mail-pj1-x102b.google.com with SMTP id y2so1154902pjg.3 for ; Thu, 02 Mar 2023 18:58:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812310; 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=uL8gPV4GfBPCsX5yefLxqBJp76wGELs04Du3rKf0/lI=; b=O7ntNcklmYopitZn731XJ7vJ6QAWmgejTKbRD5kN6cYSifij1anxrJUNzD2xx3Hmfa 3UmPRwhnaK0opiyWUwb5aUUftFrMCiAL3Yx2atzRE4sSLE2w6LFxnXHqBQHtd9FrXEtM D9ksXF1HOv3KOjSUNCj4UKECw5+mLX8nJbbB8jt5d/tmQWGm6h65MxsBpvbotYVR2ZVK yJqdxJk4whDGO1spbqk76pM7WPrBx+K5SP0ZY6QVCFo+b1YlSsg2LSEIRL8DQeSKe4Gn WOCERggmGMibmzx4zRHMcGlFqaKsSy7m3eF7dOUBvkE8jPGg/RbLzRSiOLkuS0H2eHOa H8mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812310; 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=uL8gPV4GfBPCsX5yefLxqBJp76wGELs04Du3rKf0/lI=; b=xqEjvCAfPNXPhDWRD8zipx4YlsHk6F4iI9J4eL/HfPPpjk+Fe+SLZZ1kNd17ceG4mi PiasPCXPB4kJRFQSIxy6i4gKUQQFsFGdJi2X7jcolzybkElUXdIsgRoXK2+uOiP6ci2f kjFrOoVdri/QS/ajVeX8mt2NitEax6QgaHn6kSasJqaSpxsoa01HNvUD33l5fx9jyRIx /RWBfv5cP5kMLhaVqDOl80fkW61ZhFWJGkZrc2JC5QfjYgftk5h7xL6RSDnKiNRggOkL J62dxL0iCp7DC0vB77N+8+YGI16qhADjEOmaBqyRNqI3r2rvE7gfGSsNGYQ77TmBKix8 YGNw== X-Gm-Message-State: AO0yUKWEmBhIwUpzNi94FDmgHUMZqQ1xlYAnzO22ewXRAAHeLXMbZGDe JccUa4zIPB596yoRHLDHUXyDPdFh9fnyc/eYlno= X-Received: by 2002:a17:903:24f:b0:19e:7a2c:78a7 with SMTP id j15-20020a170903024f00b0019e7a2c78a7mr550293plh.57.1677812310276; Thu, 02 Mar 2023 18:58:30 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH v4.5 28/29] gdbstub: Build syscall.c once Date: Thu, 2 Mar 2023 18:58:04 -0800 Message-Id: <20230303025805.625589-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 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 There is no longer anything target specific. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- gdbstub/syscalls.c | 5 +---- gdbstub/meson.build | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/gdbstub/syscalls.c b/gdbstub/syscalls.c index b7d85c41c7..4391d124e2 100644 --- a/gdbstub/syscalls.c +++ b/gdbstub/syscalls.c @@ -2,9 +2,7 @@ * GDB Syscall Handling * * GDB can execute syscalls on the guests behalf, currently used by - * the various semihosting extensions. As this interfaces with a guest - * ABI we need to build it per-guest (although in reality its a 32 or - * 64 bit target_ulong that is the only difference). + * the various semihosting extensions. * * Copyright (c) 2003-2005 Fabrice Bellard * Copyright (c) 2023 Linaro Ltd @@ -13,7 +11,6 @@ */ #include "qemu/osdep.h" -#include "cpu.h" #include "semihosting/semihost.h" #include "sysemu/runstate.h" #include "gdbstub/user.h" diff --git a/gdbstub/meson.build b/gdbstub/meson.build index d679c7ab86..bd5c5cd67d 100644 --- a/gdbstub/meson.build +++ b/gdbstub/meson.build @@ -31,8 +31,7 @@ user_ss.add(gdb_user) gdb_softmmu = declare_dependency(link_whole: libgdb_softmmu) softmmu_ss.add(gdb_softmmu) -# These have to built to the target ABI -specific_ss.add(files('syscalls.c')) +common_ss.add(files('syscalls.c')) # The user-target is specialised by the guest specific_ss.add(when: 'CONFIG_USER_ONLY', if_true: files('user-target.c')) From patchwork Fri Mar 3 02:58:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 658446 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp225205wrb; Thu, 2 Mar 2023 18:58:54 -0800 (PST) X-Google-Smtp-Source: AK7set+9bRP2QXT9MF12QocVZVPF7NM52e4x1avm3REprGhz/KhCEvbWOSOAUnxvkiT+qZqdCuCO X-Received: by 2002:a05:622a:1183:b0:3bf:cfa6:8842 with SMTP id m3-20020a05622a118300b003bfcfa68842mr964978qtk.0.1677812333861; Thu, 02 Mar 2023 18:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677812333; cv=none; d=google.com; s=arc-20160816; b=s5S1Ie8LQ1s2rMbBdoETC7IWr3apUG/Wcc/wz6gZb8xAzChIes0SckprICImy+Ml8O FMFQog2e+CXegQbQ3Fm1Zejakj8pgF6eB+xd92HNE6QeqA98yR9MiKX7jWXePqzfmOby y+sDjIpXwItxwjPPpyXGm4gXEySxdn1kHldpCTEa51b26r190olTJACmLrvzWFEHAr1F QT9GJHJe8/PHQX3qSoMs74gakl2bESE223zSYnGYSSnUpUTpKwxMntdY2Y9ozj/20IKT RUjkUZyKlqWiG//6sRVVyj6MHwAaNOz6BB/e3hrb3g4n6vFmnYtYUNyMR0gh8NpFeW1c MTBQ== 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=4OngDMFsl9T6YL6fMvNNNnl0dkTUWspPmNYtn7l2lDM=; b=zsCJCdWeQBqG2cdxxqOJaOo+9m/P6gVAdkGTVEZm/wmIluunBk8zUNVKhUH3uJMzmT VMb4jJIjgC0recTzJxGtMuY4p9mLMdNRTIUTYXXc0QEjJYzN9nUbuuWSE+JVMPGsDo4+ a6RbmBgZtavBSKzqUwW6yNI4rxP0jScIdkyLshCODhadlCbqTm/6k4m58Q2/O+/mKvQZ iRcvxjQTBgs2RR+LsXHsQtYS30daONgKOVeCuJ9HjzmZT1HzWzoasRjXFwIydI2xeqks f1WJWghlUiMqO4JFKSFp8TOXFpQc6MnlPmdWg/xW7/VmAoizCYP1+MP+FIcsZminvtEi s8vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M4pHKN3N; 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 12-20020a37030c000000b00718e35db8f5si882783qkd.88.2023.03.02.18.58.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 18:58:53 -0800 (PST) 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=M4pHKN3N; 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 1pXvcw-0007dh-TI; Thu, 02 Mar 2023 21:58:34 -0500 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 1pXvcv-0007cY-F8 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:33 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXvct-0001pV-RB for qemu-devel@nongnu.org; Thu, 02 Mar 2023 21:58:33 -0500 Received: by mail-pj1-x102b.google.com with SMTP id x34so1210303pjj.0 for ; Thu, 02 Mar 2023 18:58:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1677812311; 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=4OngDMFsl9T6YL6fMvNNNnl0dkTUWspPmNYtn7l2lDM=; b=M4pHKN3Nlc4yFZavIpROm06Ha2GbYlXhoFLrUNMjY/E1ThP1YzbMs6oiLmuQhT7/J+ o1NwiwIq1IG9IISWMNMVsS0xESmFI25OoOiZwkFWQqhxOa89wQaRQZWzZtQKHGC1bX3R CQ+CcgK4pHg2BGJ7BZ/QzRq9JSgwJag7FZ1IhQXhShEWsPVya5obiNNNjG22BOnBNJ1O XVDaIGeKkFeeWw8PK9fORMrL/3/f6KVPtHmlpMb3GyTOeh/qWHESreeJZ5WN5/dNUMqE 0VsoKNNt2K2jkY2boj8RoJTqNfNvrFKwWlHGh8SZGSS1DJtikm3leYNCXKSBE/aXw5YI 3Ygw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677812311; 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=4OngDMFsl9T6YL6fMvNNNnl0dkTUWspPmNYtn7l2lDM=; b=7Gerj8lPPDDEAZQgdzTpp+7zFhR3ZnQ/Ra2s5XOC/ypBY9tHzAkWkNfbIqiWnQ52GX l2FtV4u9N9DQZ5E00FOcJf1sNYdEJlp1jQLt7xlkqqO1eNVlMWV3WaGI4/IUL8BhXub7 8b9j6UzmWRuD5i1AJUAHiMREmedi7LiuSTQMlqNKmGXiCrqRI5VNte/ULPFgfoXu6Qie GYKTJMleWMmjnD9epuW5ka7SIFSpSw8ud4BzCHtO586ShtdGl1Mev8sh3x4yAymVXnhh UFA9XYmzWRB9vNnvhXPodqwDahBDJAMdzyv5umsLvMv5g53NYpmkrYYvAZZQIDuajVK3 S3CQ== X-Gm-Message-State: AO0yUKW/90SUaD1PfNcFzNpRAxe7lqF0K3RzfFFrWAVyuJRuKqVVwdwB p8Rg47Stfqp+ygJrBnf0sbqacCaj1/HRYwandtc= X-Received: by 2002:a17:902:8688:b0:194:7a99:d5ce with SMTP id g8-20020a170902868800b001947a99d5cemr425332plo.12.1677812311056; Thu, 02 Mar 2023 18:58:31 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:f3e6:4626:fbc8:b2ce]) by smtp.gmail.com with ESMTPSA id e4-20020a17090301c400b001992e74d055sm372244plh.12.2023.03.02.18.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 18:58:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Mads Ynddal , =?utf-8?q?Ph?= =?utf-8?q?ilippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4.5 29/29] gdbstub: move update guest debug to accel ops Date: Thu, 2 Mar 2023 18:58:05 -0800 Message-Id: <20230303025805.625589-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230303025805.625589-1-richard.henderson@linaro.org> References: <20230303025805.625589-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.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 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: Mads Ynddal Continuing the refactor of a48e7d9e52 (gdbstub: move guest debug support check to ops) by removing hardcoded kvm_enabled() from generic cpu.c code, and replace it with a property of AccelOpsClass. Signed-off-by: Mads Ynddal Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230207131721.49233-1-mads@ynddal.dk> [AJB: add ifdef around update_guest_debug_ops, fix brace] Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-27-alex.bennee@linaro.org> --- include/sysemu/accel-ops.h | 1 + accel/kvm/kvm-accel-ops.c | 8 ++++++++ cpu.c | 11 ++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index 30690c71bd..3c1fab4b1e 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -48,6 +48,7 @@ struct AccelOpsClass { /* gdbstub hooks */ bool (*supports_guest_debug)(void); + int (*update_guest_debug)(CPUState *cpu); int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len); int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len); void (*remove_all_breakpoints)(CPUState *cpu); diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index fbf4fe3497..457eafa380 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -86,6 +86,13 @@ static bool kvm_cpus_are_resettable(void) return !kvm_enabled() || kvm_cpu_check_are_resettable(); } +#ifdef KVM_CAP_SET_GUEST_DEBUG +static int kvm_update_guest_debug_ops(CPUState *cpu) +{ + return kvm_update_guest_debug(cpu, 0); +} +#endif + static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); @@ -99,6 +106,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm; #ifdef KVM_CAP_SET_GUEST_DEBUG + ops->update_guest_debug = kvm_update_guest_debug_ops; ops->supports_guest_debug = kvm_supports_guest_debug; ops->insert_breakpoint = kvm_insert_breakpoint; ops->remove_breakpoint = kvm_remove_breakpoint; diff --git a/cpu.c b/cpu.c index e6abc6c76c..567b23af46 100644 --- a/cpu.c +++ b/cpu.c @@ -31,8 +31,8 @@ #include "hw/core/sysemu-cpu-ops.h" #include "exec/address-spaces.h" #endif +#include "sysemu/cpus.h" #include "sysemu/tcg.h" -#include "sysemu/kvm.h" #include "exec/replay-core.h" #include "exec/cpu-common.h" #include "exec/exec-all.h" @@ -326,9 +326,14 @@ void cpu_single_step(CPUState *cpu, int enabled) { if (cpu->singlestep_enabled != enabled) { cpu->singlestep_enabled = enabled; - if (kvm_enabled()) { - kvm_update_guest_debug(cpu, 0); + +#if !defined(CONFIG_USER_ONLY) + const AccelOpsClass *ops = cpus_get_accel(); + if (ops->update_guest_debug) { + ops->update_guest_debug(cpu); } +#endif + trace_breakpoint_singlestep(cpu->cpu_index, enabled); } }