From nobody Wed Nov 27 19:52:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1697568946; cv=none; d=zohomail.com; s=zohoarc; b=DstNHLNU/6Pflg5tkTDT7o1lud9M9zO0oi4JWEC9IygudEn0X1VaBLnWYShmkltTsMlzM0HDqNcFV5GsJxpX7qp6DpQHM4uc/BuuLZ/yCvVOdeZE2VHbQ/TF6LL00Ni3hQFLSLvfXaqkAqwVziC6w26Y53EfwEiDg7vAN5EAXmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697568946; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:Message-Id:Reply-To:To; bh=Y9a4WcM7W3w4Ibv1QcOl1jK0U40rkzZ0nUtw12AhXXI=; b=T5JA+yrAKh4mUZ1ZPplY6y3rt6loyCrzAbaMsT4+gOw6NSTKPICUdnM0YiCx8BsZcT5sylli0FR2sFuRvn9WuAubNle2MGUFPV/JTNU8RdI3Da6LdrVMlK6Wbr/h2QyS7US/5AMZgsgxABb9xwJ2ZPKUdq2MmRD4uEVKhH+xWCY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697568946489768.2514576760458; Tue, 17 Oct 2023 11:55:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qspD0-000199-DA; Tue, 17 Oct 2023 14:54:26 -0400 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 1qspCy-00018u-Mi for qemu-devel@nongnu.org; Tue, 17 Oct 2023 14:54:24 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qspCx-0006zD-26 for qemu-devel@nongnu.org; Tue, 17 Oct 2023 14:54:24 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-578d0dcd4e1so3625045a12.2 for ; Tue, 17 Oct 2023 11:54:22 -0700 (PDT) Received: from localhost ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with UTF8SMTPSA id w16-20020a170902e89000b001aaf2e8b1eesm1923674plg.248.2023.10.17.11.54.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Oct 2023 11:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1697568862; x=1698173662; 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=Y9a4WcM7W3w4Ibv1QcOl1jK0U40rkzZ0nUtw12AhXXI=; b=QwSBZibt364j6No0pwvnA+Y/OltVaivBuptZCizc6/MvX51XfTQCHKelqTYqP7TaDM 8YW9I1Bd8NWFRYpLIH2H/rU182Lp+dgIZJSwTMRL18WTsQQkWbpkaT8nGZJZdYAy5U19 rMXOCX/mfYXZhrin71VLdTIjr8LIj9OL5q0AD+fBdwJmtdv2eQ4830/sPrhUAcBujV05 y/QDIQ0/GgoVpKJ8MT/cCii1sjxPGYmfySOgIQzAiCJ2qpk3p/+kOVeXunu79zanKpA0 HXsxKskMHeenmH+a15/XRtgAIGrd0XM7UWYNY5rNCxfoEwNF35mK/soocHfq/67O71NY s/qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697568862; x=1698173662; 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=Y9a4WcM7W3w4Ibv1QcOl1jK0U40rkzZ0nUtw12AhXXI=; b=sS8E/Ec/mObYn9WciIyt+HYibKjf3TwCM1R0KeUuLuOpMm6WsSa+mfbTneJSIlIv9t Cv/IkfmYJvqSomzIjxD86L6HyPP/H2oQolAOU4tvsDcVBAjTX4xooN01dMK4F3Q76k38 AA3bdUX50ge5oyhNVunbcMLyR4zYB3eNE65g622rJ4XXFxQpi3IRzUINA5J1AS80olyh wyh2lPqrxQd57OaPqwaZvBsFHzQP+d3f9QCBfLTc2ZyDKICIvMXAa8V6WfHmi8iGQqRg IJaeSGZNH0yW+jj+zSiYd3ScTgkbbP3KzAw6upnecsWSFQyz/4T6Fp0x1YI3aWtmH22X 1sWQ== X-Gm-Message-State: AOJu0YwhXpPE0CpYX7vMRFtOO34eTh4OX5i9T+0I+bRnEZY44XE/reAm rtiM0TaAfa6QmuBSCFLSmihUcQ== X-Google-Smtp-Source: AGHT+IHVGgorh/PciSnscWxhEHR+3QuQlXySBRRiv0/IJW3NxcQKHxUSbljezhvawYrRBrdMLIyDmQ== X-Received: by 2002:a05:6a21:7185:b0:174:63a9:293 with SMTP id wq5-20020a056a21718500b0017463a90293mr3356018pzb.48.1697568861643; Tue, 17 Oct 2023 11:54:21 -0700 (PDT) From: Akihiko Odaki To: Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Mikhail Tyutin , Aleksandr Anenkov , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fabiano Rosas , Akihiko Odaki Subject: [PATCH v4 1/5] gdbstub: Check if gdb_regs is NULL Date: Wed, 18 Oct 2023 03:53:56 +0900 Message-ID: <20231017185406.13381-2-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231017185406.13381-1-akihiko.odaki@daynix.com> References: <20231017185406.13381-1-akihiko.odaki@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::52a; envelope-from=akihiko.odaki@daynix.com; helo=mail-pg1-x52a.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1697568948643100012 Content-Type: text/plain; charset="utf-8" cpu->gdb_regs may be NULL if no coprocessor is registered. Fixes: 73c392c26b ("gdbstub: Replace gdb_regs with an array") Signed-off-by: Akihiko Odaki --- gdbstub/gdbstub.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index 1e96a71c0c..29540a0284 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -385,12 +385,14 @@ static const char *get_feature_xml(const char *p, con= st char **newp, xml, g_markup_printf_escaped("", cc->gdb_core_xml_file)); - for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { - r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - g_ptr_array_add( - xml, - g_markup_printf_escaped("", - r->xml)); + if (cpu->gdb_regs) { + for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { + r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, = i); + g_ptr_array_add( + xml, + g_markup_printf_escaped("", + r->xml)); + } } g_ptr_array_add(xml, g_strdup("")); g_ptr_array_add(xml, NULL); @@ -430,10 +432,12 @@ static int gdb_read_register(CPUState *cpu, GByteArra= y *buf, int reg) return cc->gdb_read_register(cpu, buf, reg); } =20 - for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { - r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { - return r->get_reg(env, buf, reg - r->base_reg); + if (cpu->gdb_regs) { + for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { + r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + return r->get_reg(env, buf, reg - r->base_reg); + } } } return 0; @@ -449,10 +453,12 @@ static int gdb_write_register(CPUState *cpu, uint8_t = *mem_buf, int reg) return cc->gdb_write_register(cpu, mem_buf, reg); } =20 - for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { - r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); - if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { - return r->set_reg(env, mem_buf, reg - r->base_reg); + if (cpu->gdb_regs) { + for (guint i =3D 0; i < cpu->gdb_regs->len; i++) { + r =3D &g_array_index(cpu->gdb_regs, GDBRegisterState, i); + if (r->base_reg <=3D reg && reg < r->base_reg + r->num_regs) { + return r->set_reg(env, mem_buf, reg - r->base_reg); + } } } return 0; --=20 2.42.0