From patchwork Tue Feb 21 22:52:08 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: 1745978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=OeB7+lh6; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PLvkH73W8z240n for ; Wed, 22 Feb 2023 09:54:47 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUbV8-0007Q1-9W; Tue, 21 Feb 2023 17:52:46 -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 1pUbV0-0007Hb-Sy for qemu-devel@nongnu.org; Tue, 21 Feb 2023 17:52:38 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUbUu-00044u-Ba for qemu-devel@nongnu.org; Tue, 21 Feb 2023 17:52:38 -0500 Received: by mail-wm1-x333.google.com with SMTP id p3-20020a05600c358300b003e206711347so4107413wmq.0 for ; Tue, 21 Feb 2023 14:52:31 -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=eUILZnrzV31FSD2JeDeA7yTRDiHYzpbow2qcab0Tfu8=; b=OeB7+lh6KCV4ce96w9ajqYCfG46Wcm3ZiVhEmmcVZyXDhM66D44B/ed1B1PZHK+4SZ sCB3EOz38PBSuS8ywayidAWEbabj/sF8kCAJKXK8GRWRpJDrcRxWj3Rg7LRMDvYYfqPN HuixIxLCAYghTMGeYr/lopG93PbWZmlPqQqWTUbf1uAm2FrYAt6Bx5Y+G1ve2FGwZAsu AlGDZ3bMQ5YuqmH4Lpi6LN6tzXljZU4pktXMNQbICQ3mDFZD5wUyEhtb3xlT4NumxCMd tKfmhdK0wExqniMDqgXOiesMylXw8qPdH4nfZF6209+cWlg4UPWrdNmLsLrCEj6Kdc9l 76tg== 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=eUILZnrzV31FSD2JeDeA7yTRDiHYzpbow2qcab0Tfu8=; b=XPoN+MU7GILMB0aUuOg+m11XDHeCfJd4iDl79GevRQoA14tVWnZZ8sHU31Kt7H9fQU G/m9pztu0fUECnWpFx0uBPnhc4iDg51fqbgQFXuiepzj6LnkLeyNAfrH6j4OY48IkkDM wXCSNAy+Zix72YdCo/YtQAb9cBGwOtCNwjyDwwC8d5EIYXjrNnVLPBJQtV6FinXdSygz 35veyMh7eYAhqXzkqOIvuF0EMMF3lPJrwRr9miTbzOnCCuOdlWq/ko0Lmm6228mhuKwf tfbSzbwjFXi7vsHsIBA2Jquz0tedSR67MlyeMnNxI+X9oeSRqGnJysiD+BBAp4gZjs4q lB1Q== X-Gm-Message-State: AO0yUKU7kvut9bQMKWcdlKL8Q6vrIdLYaB8++6aNx1TB3ZUyCYfmyLT1 OvMVIo1v2eRyqamACWBmUiM8pA== X-Google-Smtp-Source: AK7set8h4qgwzSpR2cMhLYzratOxCSw0eWeoPt3THJmbtED0jsAA7L0TBP5Em5dbKuH0wKvu/qpXhQ== X-Received: by 2002:a05:600c:810:b0:3e2:2467:d3f5 with SMTP id k16-20020a05600c081000b003e22467d3f5mr4081020wmp.25.1677019950636; Tue, 21 Feb 2023 14:52:30 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id o27-20020a05600c511b00b003e21dcccf9fsm6415315wms.16.2023.02.21.14.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 14:52:28 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id CBC971FFBD; Tue, 21 Feb 2023 22:52:27 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, Yoshinori Sato , nicolas.eder@lauterbach.com, Stafford Horne , Daniel Henrique Barboza , Mahmoud Mandour , Taylor Simpson , mads@ynddal.dk, Marek Vasut , Artyom Tarasenko , Alistair Francis , qemu-ppc@nongnu.org, Yanan Wang , Sunil Muthuswamy , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Eduardo Habkost , Bin Meng , Bastian Koppelmann , Palmer Dabbelt , Marcel Apfelbaum , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Rolnik , Aleksandar Rikalo , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Aurelien Jarno , Xiaojuan Yang , Richard Henderson , Peter Maydell , Alexandre Iooss , Chris Wulff , Jiaxun Yang , David Gibson , "Edgar E. Iglesias" , Greg Kurz , David Hildenbrand , Song Gao , Ilya Leoshkevich , Max Filippov , Mark Cave-Ayland Subject: [PATCH v3 05/24] gdbstub: move GDBState to shared internals header Date: Tue, 21 Feb 2023 22:52:08 +0000 Message-Id: <20230221225227.3735319-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221225227.3735319-1-alex.bennee@linaro.org> References: <20230221225227.3735319-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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 b444f24ef5..de56328a2c 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -9,6 +9,56 @@ #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 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, 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 86564adeba..f419425cb0 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,23 +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; @@ -358,29 +339,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)