From patchwork Fri Feb 16 16:30:08 2024 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: 773346 Delivered-To: patch@linaro.org Received: by 2002:a5d:4943:0:b0:33b:4db1:f5b3 with SMTP id r3csp24917wrs; Fri, 16 Feb 2024 08:31:59 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUXYv3BZ++n1DykqeqaYojWPs7o+g0FG+8oqLGvQXefNPG/XmfCSXLpYPzevT65QU1I0KScJ5WCfOMEvF8Octr0 X-Google-Smtp-Source: AGHT+IHOegiBiqgxAZpvS4XKIn3+aj8Oli4RuQmCKlNNylXjjxDX89pEYwRuTKIp2HQdO3/g5dma X-Received: by 2002:a05:6358:7405:b0:178:ff94:f9a2 with SMTP id s5-20020a056358740500b00178ff94f9a2mr5884086rwg.27.1708101119377; Fri, 16 Feb 2024 08:31:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708101119; cv=none; d=google.com; s=arc-20160816; b=JpQz82IzT8Yp75mVAANDXIDGKcqwGpShNfXZMI3YOm+vFAF9MY2RnxNFnQ3gVEnp2V gmAEEGR3Srp6QpibrtiJdgETb8icRG2CLv3XgcSd5c65x6CVhzZ/GjS5vgzMWqO5vhcN xP40RmlefgJSpOazz0FEKml7D+hCytARwLLHfHq1f8XOYW5cKVoZ+j5+QKlMUdI7WCwB uPXKOiVdOm0bWHoOvrLHv+xYpgKaM4s4pHD+81FebfYTkWyr/gcaRCoqZxtca5Xex9T7 h0Jv5FpiJao7lwy6bOhMsLR7ATDpgyDNMNASSDO6d4Az7aC9zMBEJcSttW2XPChLNGaz MrCA== 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=sYddgSiv4TdBqJm1PnHuh0lKMNJczxN97MFaER3IoIY=; fh=edBBzxC9D4aeJQkoOTUe3r9rrX1lOuBdxVr2qjfDcVQ=; b=paG1Qsc2yCj2a0sPFErosVDOyaumhUnIi8/olXQku92vWHmnsxY5ZXcnWmH7owDcaw WDWbMrzgwDN/VFone/l/EyX8R2BvNmqw+1tLsPsdd6Qmnhkc8i06Ja8CZeBLLfhZfaOS 6biU7MM49BPiBSdLkRa8oxB1b1E7CjUiBBXNgtgY4WqXiWQl/Wz1i8KCLcVp3dW7RgdO Vf7kjk2Ff53qCKbqBv0n94ZDzixflB5SXhoO60UcE9oSTzDk61clHRGt9FLR+k0aW+EP yxnHWoqhofazoffGvLxVUoHmMc4F7qtGrDlpilZq/Jwj9IlKqLCXv8MXLfrUiyidyc59 Ysgw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NPjz0KIk; 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 y19-20020a05622a121300b0042da6c0be7esi207329qtx.196.2024.02.16.08.31.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Feb 2024 08:31:59 -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=NPjz0KIk; 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 1rb16n-0004Y5-Ou; Fri, 16 Feb 2024 11:30:41 -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 1rb16m-0004WY-I4 for qemu-devel@nongnu.org; Fri, 16 Feb 2024 11:30:40 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rb16d-0002AZ-Up for qemu-devel@nongnu.org; Fri, 16 Feb 2024 11:30:40 -0500 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3394bec856fso2007320f8f.0 for ; Fri, 16 Feb 2024 08:30:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708101030; x=1708705830; darn=nongnu.org; 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=sYddgSiv4TdBqJm1PnHuh0lKMNJczxN97MFaER3IoIY=; b=NPjz0KIkUTDHtLThIgxxbAOkeM6anrOCASER3dpVo7EQJmlLYh+ySCio9S82G7ZBc1 K1tv965z3WKkscsxTFcOgrVFYFuJWLQhCM9nxyjuNWpEepuWBOS4T8IvCYbq124Z49sH p5w4zLCMi3h7Ml/I2NsrGkyNcUgrsQ1L8ZbNLrHAPvggGldY7bCKvg1t+NrxNWWRdGkC Mn6uWomy0wvrYH3wnq0YsdQUp1fIayqUhhrqk9zSxErU36D1PqCzXP/Uc0FZEG7uVn+q tgt5fkEBqUN0zXMFPfNVdiPgJGp+ETZufnZsWOWBn5qBcKTfwfKaOUWKEdczeORaqAfb LPnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708101030; x=1708705830; 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=sYddgSiv4TdBqJm1PnHuh0lKMNJczxN97MFaER3IoIY=; b=d8TH/RbWtXrR+/RxrBt/1WXI/lqhJMc+e59UXAfLlmeHh5ySr9JPl0h9bJQOr7H1ZS d6+oaNaELzi08be3IUqnienJU60/AiJ4qebGp+lC7BrSkk6OspiXQ0aILpw3RbLVZHC1 ++/TL4pmVKL4wH74M8ny0D/SgwMyfx1Qe61+Z2ec+/c50aGv3EtvgReij35HNmUi4Lqi Im+aw7uQjnaiMoDHAUicxgi1ln99PwnlHfNNUIE3t2tZfiGX7/iMLzxwZ8lJfTSVa7na QrryW8v/RQd6BtKkki/X22+siJupdRrGic8Fw6SRYIMrtuCE/eXlKwZr+RfR3wpneflZ 6bHA== X-Gm-Message-State: AOJu0Yw/8lrp08zZr9TiiHMRh0B0YEmk8Yc4ZvQy7ccuzJhLP+ZZNm7T 6BK7dBIsK0G4dnPt2s59bpFu46dqKvjnVz81Imn7hG8Yd/+H4xInEaJx3RRSnl0= X-Received: by 2002:adf:f9c6:0:b0:33a:d28c:222c with SMTP id w6-20020adff9c6000000b0033ad28c222cmr7733487wrr.11.1708101029794; Fri, 16 Feb 2024 08:30:29 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id u7-20020a05600c00c700b0040fb783ad93sm2701787wmm.48.2024.02.16.08.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 08:30:27 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A8DA55F9D4; Fri, 16 Feb 2024 16:30:26 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Yoshinori Sato , David Hildenbrand , Weiwei Li , Richard Henderson , Michael Rolnik , Ilya Leoshkevich , Peter Maydell , qemu-ppc@nongnu.org, Paolo Bonzini , qemu-riscv@nongnu.org, Cleber Rosa , Thomas Huth , Song Gao , qemu-arm@nongnu.org, Pierrick Bouvier , John Snow , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?C=C3=A9dri?= =?utf-8?q?c_Le_Goater?= , Nicholas Piggin , qemu-s390x@nongnu.org, Laurent Vivier , "Edgar E. Iglesias" , Daniel Henrique Barboza , Yanan Wang , Palmer Dabbelt , Marcel Apfelbaum , Brian Cain , Mahmoud Mandour , Alexandre Iooss , Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Daniel Henrique Barboza , Eduardo Habkost , Alistair Francis , Liu Zhiwei , Akihiko Odaki Subject: [PATCH 06/23] gdbstub: Use GDBFeature for GDBRegisterState Date: Fri, 16 Feb 2024 16:30:08 +0000 Message-Id: <20240216163025.424857-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240216163025.424857-1-alex.bennee@linaro.org> References: <20240216163025.424857-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Akihiko Odaki Simplify GDBRegisterState by replacing num_regs and xml members with one member that points to GDBFeature. Signed-off-by: Akihiko Odaki Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20240103173349.398526-31-alex.bennee@linaro.org> Message-Id: <20231213-gdb-v17-5-777047380591@daynix.com> Signed-off-by: Alex Bennée --- gdbstub/gdbstub.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 256599c8dfb..0ea417b2c9a 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -47,10 +47,9 @@ typedef struct GDBRegisterState { int base_reg; - int num_regs; gdb_get_reg_cb get_reg; gdb_set_reg_cb set_reg; - const char *xml; + const GDBFeature *feature; } GDBRegisterState; GDBState gdbserver_state; @@ -391,7 +390,7 @@ static const char *get_feature_xml(const char *p, const char **newp, g_ptr_array_add( xml, g_markup_printf_escaped("", - r->xml)); + r->feature->xmlname)); } } g_ptr_array_add(xml, g_strdup("")); @@ -513,7 +512,7 @@ static int gdb_read_register(CPUState *cpu, GByteArray *buf, int reg) if (cpu->gdb_regs) { for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { return r->get_reg(env, buf, reg - r->base_reg); } } @@ -534,7 +533,7 @@ static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg) if (cpu->gdb_regs) { for (guint i = 0; i < cpu->gdb_regs->len; i++) { r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <= reg && reg < r->base_reg + r->num_regs) { + if (r->base_reg <= reg && reg < r->base_reg + r->feature->num_regs) { return r->set_reg(env, mem_buf, reg - r->base_reg); } } @@ -553,7 +552,7 @@ void gdb_register_coprocessor(CPUState *cpu, for (i = 0; i < cpu->gdb_regs->len; i++) { /* Check for duplicates. */ s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (strcmp(s->xml, feature->xmlname) == 0) { + if (s->feature == feature) { return; } } @@ -565,10 +564,9 @@ void gdb_register_coprocessor(CPUState *cpu, g_array_set_size(cpu->gdb_regs, i + 1); s = &g_array_index(cpu->gdb_regs, GDBRegisterState, i); s->base_reg = cpu->gdb_num_regs; - s->num_regs = feature->num_regs; s->get_reg = get_reg; s->set_reg = set_reg; - s->xml = feature->xml; + s->feature = feature; /* Add to end of list. */ cpu->gdb_num_regs += feature->num_regs;