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)