From patchwork Thu Jan 5 16:43:05 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: 639323 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp345976pvb; Thu, 5 Jan 2023 09:39:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXtiI6RtvLL6Thgz/I73gheejLSSIENsZPZvh8d58rbzrF8uhlEvRPPbAHbH46yuprT2CvLL X-Received: by 2002:ac8:65d6:0:b0:3a8:1d77:ee3a with SMTP id t22-20020ac865d6000000b003a81d77ee3amr73835161qto.15.1672940341664; Thu, 05 Jan 2023 09:39:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672940341; cv=none; d=google.com; s=arc-20160816; b=zPSePiqcvx9cJEgKZxjSXhdY32115YoU319LPp1l927R6sG2pbXXTeFlcTnJOkdfzB FscuxJXA/QYpG0OlAI0X2S7zSsWVd6dSAEJLmF/d5+DbeYall4eRpYaONUGjQ7h8jZN1 J7XWX0s89aXJoqjDqVdsx12dELa18I+bdZnegQ0oRmthOpH7DdLrBmRbie9WJOyOfCta tZHsli63U38z8avLRlPfbQsCNZjHWmf8PIoGvmgvCKEu1YMGkRFJzL3OqCYGR+9MkBQ+ i83gDWZ0VHxIrcrIZL1JRq0PSQiGSh3fpAU+eVsevpyuY/wKTfXGSZuyRFKgs2xk/PCq 7s3Q== 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=TLd5g4iuKDGI8GqVRVcMJw8OLSB9d+X+S79K8IqAr5U=; b=he0Bwwl7li9nzGAdB2XpmHLwKO1/OUPuhZ++1FdSlBDnaVX4b4LN+ooSIaaJj7NcCR 2CKVEeULkSVznswX0NZa0JYpbcmvgdt9rMV4sMZ+q7rPYPARbpQaS2RKILSLj9c/gRCv HMfdx//OJipDDRIqG9fznohr5KOLvINiRlQa9hL4PKpU9Bes+LVyYwVinWpAXvmi15On K+ME04MCpEUVqt0Vzyp17i78Hx+LR8LK2QGoecPKlmhYDqzwJ+qIynz15m507Yu2Yild TGU6c8alb/cLNck0inbmkKVYohcEsMgL08VwRYdF5lefzzk6gogfCkswsCccNadiSLci fJaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JZlF4xVL; 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 fa15-20020a05622a4ccf00b003ab9329d086si17042088qtb.522.2023.01.05.09.39.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Jan 2023 09:39:01 -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=JZlF4xVL; 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 1pDTL6-00071q-0r; Thu, 05 Jan 2023 11:43: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 1pDTL4-0006zv-89 for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:34 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pDTKv-0006yF-Pk for qemu-devel@nongnu.org; Thu, 05 Jan 2023 11:43:33 -0500 Received: by mail-wm1-x32f.google.com with SMTP id g25-20020a7bc4d9000000b003d97c8d4941so1728691wmk.4 for ; Thu, 05 Jan 2023 08:43:25 -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=TLd5g4iuKDGI8GqVRVcMJw8OLSB9d+X+S79K8IqAr5U=; b=JZlF4xVL0DZbE6YHARHBXTfNzEGQ9egipQL7UtCEXYMOJy3s3cypJ4/+X1vQF6VFsf uvSGF/knRwbiqqrONbLExgxItcYrF5J9exNorp2I+zPJVKqPGVPnW5YaStlaSkYTH0qZ tqpRmZClp1dFVgzaxyZoAsLJC+hI4O92GEkH/LLpIDpvj1k95lRltJlCkDS+3akluKXA Ln6Tae1r49pgl5pNYADVbdkPBqBfpREogEKiiLew7AOOVGGHB/f/M5vltJiIPZYN+O5n aWVX7bdc0VrQ0O5lcRec/6aCwalY7bPF9NKMm1AcEcuPgRxYaxNCCRnr3AUPc/uZiv6+ roBw== 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=TLd5g4iuKDGI8GqVRVcMJw8OLSB9d+X+S79K8IqAr5U=; b=sTMouvOcZovMY3Pb5L/rFT1DPLtryZj1j/2R2nEHl3p9+r31AgCS0HLb9li2kDI2k3 3LYLKOiHHGAOZt/RS7E7OV4hpWKojUYIcRXSXpmkNG8CRhBFChC4jDwraJDG0bjREu3Q cKfJnCYx2piIzDwkI5lFyJDWOpKFbXlHNK8/QWSEE3p8MWOGpOW/TuHdHPoxDOSy4orl i7JeXUWvjZjPtknd54VBR/OEpn3GIQnWK5YVcBPgM9WIQS9uQDqbjloo+7YHyyHOBL2n y/EbQaJGiGxKkhFKWCvEKRQnAlBcldgnaguTrFUhYwjJJX7gnv9oBI4w3L/FtmBcnyrC O9qg== X-Gm-Message-State: AFqh2koajHJGwFP5uOtUI8+PD/5hyS76XHUOLDH8wdH+XvaBpH5cgd6a i9x3eJg9AqUZSWiQjIXLtTmCjw== X-Received: by 2002:a05:600c:3b87:b0:3d2:813:138a with SMTP id n7-20020a05600c3b8700b003d20813138amr40251224wms.35.1672937004490; Thu, 05 Jan 2023 08:43:24 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id p12-20020a05600c358c00b003d237d60318sm3423082wmq.2.2023.01.05.08.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 08:43:22 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B93A31FFBE; Thu, 5 Jan 2023 16:43:20 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org, alex.bennee@gmail.com Cc: David Hildenbrand , Sunil Muthuswamy , Aurelien Jarno , Michael Rolnik , Aleksandar Rikalo , Greg Kurz , Ilya Leoshkevich , Thomas Huth , qemu-ppc@nongnu.org, Laurent Vivier , Max Filippov , Yanan Wang , Marek Vasut , Stafford Horne , Peter Maydell , Daniel Henrique Barboza , Palmer Dabbelt , =?utf-8?q?Alex_Benn=C3=A9e?= , Taylor Simpson , Marcel Apfelbaum , Alexandre Iooss , Chris Wulff , Richard Henderson , Eduardo Habkost , Song Gao , Mark Cave-Ayland , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= , Artyom Tarasenko , Paolo Bonzini , qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Alistair Francis , "Edgar E. Iglesias" , Bastian Koppelmann , Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Bin Meng , Mahmoud Mandour , David Gibson , Yoshinori Sato , Xiaojuan Yang , qemu-arm@nongnu.org Subject: [PATCH v2 06/21] gdbstub: move GDBState to shared internals header Date: Thu, 5 Jan 2023 16:43:05 +0000 Message-Id: <20230105164320.2164095-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230105164320.2164095-1-alex.bennee@linaro.org> References: <20230105164320.2164095-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32f.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. To keep building we have to temporarily define CONFIG_USER_ONLY just before we include internals.h for the user-mode side of things. This will get removed once the state is fully moved. Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée --- gdbstub/internals.h | 69 +++++++++++++++++++++++++++++++++++++++++++++ gdbstub/gdbstub.c | 60 --------------------------------------- gdbstub/softmmu.c | 2 ++ gdbstub/user.c | 2 ++ 4 files changed, 73 insertions(+), 60 deletions(-) diff --git a/gdbstub/internals.h b/gdbstub/internals.h index b444f24ef5..9784db2dc5 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -9,6 +9,75 @@ #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, +}; + +/* Temporary home */ +#ifdef CONFIG_USER_ONLY +typedef struct { + int fd; + char *socket_path; + int running_state; +} GDBUserState; +#else +typedef struct { + CharBackend chr; + Chardev *mon_chr; +} GDBSystemState; +#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; +#ifdef CONFIG_USER_ONLY + GDBUserState user; +#else + GDBSystemState system; +#endif + 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 42ae13b344..505beafad7 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,64 +324,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; - char *socket_path; - int running_state; -} GDBUserState; -#else -typedef struct { - CharBackend chr; - Chardev *mon_chr; -} GDBSystemState; -#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; -#ifdef CONFIG_USER_ONLY - GDBUserState user; -#else - GDBSystemState system; -#endif - 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) diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 183dfb40e4..696894243b 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -14,6 +14,8 @@ #include "exec/gdbstub.h" #include "exec/hwaddr.h" #include "sysemu/cpus.h" +#include "chardev/char.h" +#include "chardev/char-fe.h" #include "internals.h" bool gdb_supports_guest_debug(void) diff --git a/gdbstub/user.c b/gdbstub/user.c index a5f370bcf9..4c2b41eefa 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -13,6 +13,8 @@ #include "exec/hwaddr.h" #include "exec/gdbstub.h" #include "hw/core/cpu.h" +/* temp hack */ +#define CONFIG_USER_ONLY 1 #include "internals.h" bool gdb_supports_guest_debug(void)