From patchwork Thu Mar 2 19:08:26 2023 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: 658134 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp65718wrb; Thu, 2 Mar 2023 11:12:24 -0800 (PST) X-Google-Smtp-Source: AK7set+0Xj9OKNlq3Gi++0z/oZoQQsRTx052AIBhooNy4X/n1W+wbeyks+O6N2kReDk8Hl9GVtS1 X-Received: by 2002:a05:6214:250d:b0:53a:f6ac:2a93 with SMTP id gf13-20020a056214250d00b0053af6ac2a93mr21134128qvb.43.1677784344263; Thu, 02 Mar 2023 11:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677784344; cv=none; d=google.com; s=arc-20160816; b=f9shy0YG9Kf6Uh7hSJPAz63TiBdnwnXjRRfL6aIwrPKSMPBfl2GHXIZz/bS0KJdzDu bALhcNkrnkQdBCSbEl15i5cwqGrLADIbhlxcrt0zwGvB/Iwk4vbDA0JjJqMAUOXDOEOw ltvqpOvC8ghGm5W7xF3QJOEOVXJbyWQULKGTnnzI5yJayk1W7Bjvi34xVM2BtCnfDo5b hyqWid5qYCbbTMaZZGnpNQkzaA1S40XScgq8ncSpUA4cFIfXbB6zXHy+R/a6Zd0svslF zZqrdu+sOiyLBqQsyH7/DGGRV9WWkra/rMS5lgMjA0OiPi/hnWV6I0fU7Ip+kVZ07Y1i CeLg== 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=ffhXR90TVSQnNHTvhKRNefIM4mYQZlD8n+lh28Il+5U=; b=CY9OXiGUmJiuzu/vBYuj6zCEEThq2m3ey8SYoYp3/4C0pn+ZBnDfIBWcYOM41mZP3m DMc5tQFgpFDZUo14DiFU2gx6CWEJB+NUr7vb1QFUAs9jjoLALd2k7yIKbGbbTvt2iFma jF6E+hmuvQh2IJxZOmzeAKOS11dkj/l+GhzXO+mbA603s0Ghe4U4HF6ir/CLKDsAjr8w p44YcvzvjMT2aC9vvMudq6Mp8SKrQQ9lVHWaTtOIHPQPGduZO1F3fXttb0SeGj1hGKEO Z0kAvidNc/uGdSgUr58kQKNEl9/N74cRdnZDNVsS9Cv3QPIuBJk7uBxzt0oDQIgmhLub SdIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JfTTt2YC; 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 z17-20020a0cf251000000b0056ee5ebb3c1si13577267qvl.326.2023.03.02.11.12.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Mar 2023 11:12:24 -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=JfTTt2YC; 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 1pXoIZ-0007Rt-VX; Thu, 02 Mar 2023 14:09:03 -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 1pXoIY-0007Qq-ID for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:02 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXoIN-0004WA-Qf for qemu-devel@nongnu.org; Thu, 02 Mar 2023 14:09:02 -0500 Received: by mail-wr1-x42e.google.com with SMTP id g3so132682wri.6 for ; Thu, 02 Mar 2023 11:08:51 -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=ffhXR90TVSQnNHTvhKRNefIM4mYQZlD8n+lh28Il+5U=; b=JfTTt2YCfJVrPhi7siSMIrk9/oCHPtVzmIfNVnF2IKJ8ahWHpRsGUoaBwl7kBHskWy ZBhVBc49Zrfxr4MxIFZ/OjBJk52s7AkdqTyyyzmyVYh75Y8DyxcsiXmyw87UlsRxHXBn ppuVfhF+k+oR2X9HsQjWeLR/EF9ROr9KmOpYZ3OAWOynwlakrimJT4Kj9EqpqbUtLzAq YqywemGGb1zVogr2CjiVSxiPOfE7Pgi6fEXKGGq6tzy09zWYrTNH11f9pVDWscdu8WTo tuJKh+x+AcB2LZOmV3hBDTY/CDqtlSxyaX8LhcLwvqL1wC9zssntvu+95Vf9EdFte8Yw b7jQ== 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=ffhXR90TVSQnNHTvhKRNefIM4mYQZlD8n+lh28Il+5U=; b=QeLI1zYO7mNxj0xltUt2ammK8jBjl6qMfTsZ4KFZIxrcj6lLbT+AEG3ZPpbsLO+XLG X/TP0PhWIJhz0uvUu+5s1FiNuK3a0ICAIMhgdMLAO78yBmAf0EOV+zwocJoNMNwGButQ cD8WbmIriYHhXVkDuRPxzex5k55kFWMkSWv+YNaT2Q9uH/zn8alghkgMtyl8mHf3P8NV iIsxlZMOwmf8L9oui7tFhceL1PJHRoEJpEkYMgjRoFCX+YwvbS4DYpwgRDhuRwkBv7Eo 6ZivZ2Hb8PRJ61JIU8Km931idR+PHS+iTugAFPeOh6vD4eEJHxcFKeSmF2v2loypeQLv /6Gw== X-Gm-Message-State: AO0yUKVATA8bUIf+SDnMHf1Gqdd9lLrl4Z9CmM/jmBHDVAqWDsRdidle H4p8XtBMRHW9YXaVIwask+hDTA== X-Received: by 2002:adf:e98e:0:b0:2c5:9c7a:866 with SMTP id h14-20020adfe98e000000b002c59c7a0866mr7862710wrm.51.1677784129988; Thu, 02 Mar 2023 11:08:49 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id f9-20020adfdb49000000b002c59c6abc10sm115801wrj.115.2023.03.02.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 11:08:48 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3E7901FFBE; Thu, 2 Mar 2023 19:08:47 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Weiwei Li , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Palmer Dabbelt , Laurent Vivier , nicolas.eder@lauterbach.com, Ilya Leoshkevich , kvm@vger.kernel.org, "Edgar E. Iglesias" , David Gibson , Max Filippov , Sunil Muthuswamy , qemu-s390x@nongnu.org, Stafford Horne , Bin Meng , Marek Vasut , Greg Kurz , Song Gao , Aleksandar Rikalo , Liu Zhiwei , Alistair Francis , Chris Wulff , qemu-riscv@nongnu.org, Michael Rolnik , qemu-arm@nongnu.org, Cleber Rosa , Artyom Tarasenko , Marcel Apfelbaum , Eduardo Habkost , Yoshinori Sato , Alexandre Iooss , Daniel Henrique Barboza , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , mads@ynddal.dk, Mark Cave-Ayland , qemu-ppc@nongnu.org, Richard Henderson , John Snow , Xiaojuan Yang , Thomas Huth , Paolo Bonzini , Mahmoud Mandour , Aurelien Jarno , Bastian Koppelmann , Yanan Wang , David Hildenbrand , Taylor Simpson , Peter Maydell , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v4 06/26] gdbstub: move GDBState to shared internals header Date: Thu, 2 Mar 2023 19:08:26 +0000 Message-Id: <20230302190846.2593720-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230302190846.2593720-1-alex.bennee@linaro.org> References: <20230302190846.2593720-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.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=unavailable 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. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- v3 - as we split user/system state earlier we can remove the #define hack --- 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)