From patchwork Fri Dec 16 11:22:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 634413 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp739697pvb; Fri, 16 Dec 2022 03:23:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf6o6enGbdZvWbHkdITwmztzl9BFzR5NvJr5C41Eo8oM2s+beL8aR6N69GL4lppS2sM61gbE X-Received: by 2002:a05:622a:2443:b0:3a5:1cc9:4913 with SMTP id bl3-20020a05622a244300b003a51cc94913mr51328268qtb.40.1671189837944; Fri, 16 Dec 2022 03:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671189837; cv=none; d=google.com; s=arc-20160816; b=H8qYr54IFqQZVW3haS/BtuLabqHGPljrtkZMIT2U57gSfEaKlMCzL07XHxNkYP6ueT lmjvAxYO0ZQAauKCWkKC96rBI5yNtxP8Gdb8ssHHO1fPlnyhVdztsHvIFdVSz0dz+HH5 T15qtB7J7OB53tuPkYcWg2EkvTgD5k2DviHEt7EFQBxsKz5EaUA3EImBj+ck4gewMqQN i+1YF5QVP3NnDps8GBvGfzJa+bqSDT6i2S+4tDBAmdcN0DaeqT4Ha72cUPNAo1vPtyui X8bIldP2QmsGlOqoKnhe+aILHgAbCdvjMvxU3AI+zeyzhWzyPTSxKiG/z4s59on/wZ/D pzLQ== 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=82WvPkb7AS72H/SR2TFZc7iBeZJJjIKUngbd6FjrBjM=; b=mkKmGGjFudxD0/B0yKD5YarTSg8BwMDzSsDroo5XfamoUVxksyjDYD+muz/zpI6yxC mfvHtc+3APyp1jRLYWinfkDInuVva7jvULZ4ZNLNU1v6kNWQxMwVdIylHFNjVsTPuF2B ygwKaqnl52ZuFDcpKGZqdq98QLtGkaSjA9JlU372JSsq6bYPbEtYV3TRcmnqjoWMU266 izEQwzvJ3GJkhgCRwizayrqUyCjSzWwwQD2SF4khfad+wckNPxqvlUoi83o5cldV8yTQ m14V+d8gb8aV5CgHath73E2Cr4yRVGWAfPbGfkDsKTOeLwyBDVWNR1EWeQr+Em1GpKzd Lcwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MQPzy9zo; 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 m9-20020a05620a24c900b006fb97249357si948584qkn.412.2022.12.16.03.23.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Dec 2022 03:23:57 -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=MQPzy9zo; 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 1p68n9-00023Z-Q2; Fri, 16 Dec 2022 06:22:15 -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 1p68n7-00022H-Jr for qemu-devel@nongnu.org; Fri, 16 Dec 2022 06:22:13 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p68n5-00067p-Ox for qemu-devel@nongnu.org; Fri, 16 Dec 2022 06:22:13 -0500 Received: by mail-wr1-x435.google.com with SMTP id h12so2139262wrv.10 for ; Fri, 16 Dec 2022 03:22:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=82WvPkb7AS72H/SR2TFZc7iBeZJJjIKUngbd6FjrBjM=; b=MQPzy9zoCX2J08DHzsUEzEXjEzA1n1GqPtNwWhnNN/Bcq8YqlAimwap0vs5ToKnP91 IrWZUukpkLzoxLs2rIVraKbBMCyJz3AmmLNtwWrePx9t8Rse3pZSmNOX7cwTN8H7S7hm 0eTzLkyR5feWSjIj6Ctns/CusEECY+WR7JqTjzwFLa6jLCv5N0j9jzaAipRh0RXk9abU aGSH1S6zi0CKpE3t/+TaSvnR3Y49seTaLDyEZkmjHLPZd8hQNQwQPyoYRCw3rcG7u9Tf 8ntGq6SEURQpCvvviK76ilpKIYDCVfBChP94upBr4aMFe04OLPVIkLh4Fpy3OxThB3Qp FD5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=82WvPkb7AS72H/SR2TFZc7iBeZJJjIKUngbd6FjrBjM=; b=SHraNYatK6Xqz31wUxM4hk5C18ghGtsFHHkVIqB/6RLW1IUwWlaM6WInqqO/BdeukM x1Y62wJ54obaYwDCJYD5P7jawQvLhOHjmy41LSvhpkH1avcEg/rWzLqfFzfV76S6jCsY Ki7hs03WvMe9vGkd0mjcNcPV4Wl37WRNp+JBCXxyLQf8G9RcBJ8Y/Bloprtj+0+S6082 FT8qrQqLy1jM5RIPCIt8cMqddlPuE2jPPrNmsVx2aibsuU1Z7F4bF4pGehlmK+TxuFKo ooJ3NPfHR7/B5mBqb+bacyI7Igu5j6LwdVQtkB1QFxNCpxIstn+dC3YAf08PDzV8zLOO x0Aw== X-Gm-Message-State: ANoB5plhFOPdiJl5iMXSxpGtTcShhvF6v9HlumuVam6KMCX3FakgbBWi 0ilvWetlPvlbddVnYViRTGxTng== X-Received: by 2002:adf:e708:0:b0:242:728a:fa7 with SMTP id c8-20020adfe708000000b00242728a0fa7mr21641873wrm.61.1671189730292; Fri, 16 Dec 2022 03:22:10 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id l9-20020adfa389000000b00241c4bd6c09sm2088552wrb.33.2022.12.16.03.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Dec 2022 03:22:09 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 606811FFBD; Fri, 16 Dec 2022 11:22:07 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: f4bug@amsat.org, mads@ynddal.dk, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PATCH v1 05/10] gdbstub: move GDBState to shared internals header Date: Fri, 16 Dec 2022 11:22:01 +0000 Message-Id: <20221216112206.3171578-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221216112206.3171578-1-alex.bennee@linaro.org> References: <20221216112206.3171578-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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 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. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- gdbstub/internals.h | 53 +++++++++++++++++++++++++++++++++++++++++++++ gdbstub/gdbstub.c | 47 ++-------------------------------------- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b444f24ef5..462a93e41c 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -9,6 +9,59 @@ #ifndef GDBSTUB_INTERNALS_H #define GDBSTUB_INTERNALS_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 GDBConnection GDBConnection; + +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; + GDBConnection *connection; + 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, hwaddr addr, hwaddr len); int gdb_breakpoint_remove(CPUState *cs, int type, hwaddr addr, hwaddr len); diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 14ce911bf2..bc43aaf825 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" @@ -326,60 +324,19 @@ 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 { +typedef struct GDBConnection { int fd; char *socket_path; int running_state; } GDBConnection; #else -typedef struct { +typedef struct GDBConnection { CharBackend chr; Chardev *mon_chr; } GDBConnection; #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; - GDBConnection *connection; - 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)