From nobody Wed Nov 27 14:43:23 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698489429; cv=none; d=zohomail.com; s=zohoarc; b=KBSZxcNNe0bv8QzfFXbz+5ltggyQSudpqFrO3gebQlqpAiBClnaxXswNa08x4cWSvmYtJZRG9Eq1UpTvp+BfoUTLFcsY6FfelPJL+184AfV9wPRjmrE7QE7LIZEaLqLgV+JvwEhaF2APhP+XJ3z2ZNcr8xOJQy2nKAq/JMnfpmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698489429; h=Content-Type: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:To:To:Message-Id:Reply-To; bh=M9D0IAeyBl7tCHLFuwBJ3K5ngt4JViKy0HwHpFD6M2Y=; b=J9rW9hW3VlK/w6M/rLdvPlSLyhlgOg6FPCcWNSPPka5XSHsiCx6QFVSjMyT5MSa7TOtghfVSmcv1Uj+BuK6IT+R5go2IQ4rTNVDJHS6dr8ZafKHqxZUgXQLC2g+NX5TYJBnMYX3aIO9Wwa4Lb6txfLx+bi0LWvHdFYVIxXtbIo4= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698489429107412.8177220109669; Sat, 28 Oct 2023 03:37:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwgdM-0006LE-Bw; Sat, 28 Oct 2023 06:33:36 -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 1qwgdG-0006Ii-SC for qemu-devel@nongnu.org; Sat, 28 Oct 2023 06:33:32 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qwgd7-0003AO-2O for qemu-devel@nongnu.org; Sat, 28 Oct 2023 06:33:30 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-507b96095abso4117513e87.3 for ; Sat, 28 Oct 2023 03:33:20 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id y15-20020a05600c2b0f00b004083996dad8sm7108076wme.18.2023.10.28.03.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 03:33:18 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 638545F798; Sat, 28 Oct 2023 11:33:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698489199; x=1699093999; 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=M9D0IAeyBl7tCHLFuwBJ3K5ngt4JViKy0HwHpFD6M2Y=; b=ors6grAt5/KN4yOvC5orcw9Tjz4hrOcQQq05skR39BpOho8XecGCeKScN3FM22TI0O kfyiEJdtdkkjE1i/ultBBbPIJehA73sYqNOEAV6AwjpZrpCsoZtnipwb9kh8T8gZzomv WSIA8Fw5n89RoECzgukBcmhT4vukofUbJGJfvRjZ0RUqhGy8DBPEexcqN9F1OviN48MZ F479ZtpytKNQHVs/eg/FqHWv8JRFRuyjI+gbMhfCVVYZ9J/a166BBMhiMrfHwKtDr7Rm t7d6SX0uvbxpZ4IF3JOw/2JkJtDeCTb2ZErP531gDTrJn3+sodMZVFxowJrQMF3yzS3I imZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698489199; x=1699093999; 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=M9D0IAeyBl7tCHLFuwBJ3K5ngt4JViKy0HwHpFD6M2Y=; b=DL79Ze65JD8BOE5p0mZexZt088KD8a6ywVm94NGgk5Ix8cjhlKSiGGsYBXnhPfWKhg MIF+T/Tbs7/Oyb+ba1ylUMkl1FIAQG2NZStQx8YFET0LWJR+nJOURtf/Bpfq1aiiVGk9 tJoogrDKtdZu4SKHcbiDQyNJh4GFNUuyjqznj4mAj1SFWvg1tqP53kczzM1/SUIvoJWZ i0d7BQawwg/W1wXkOV3DrinTLgZuJF7sZBf0u+/KBA7NOvD5afSfqVkeSaXbHIHMREe+ tem9PkZpRLytOaahV1bFH+8VhewVXi+KmUTThWZpengbOHVFB2PoUDu680Tt4b2LxD0o mzSQ== X-Gm-Message-State: AOJu0YyXaxzHW5yN/y5oGl83toLcR0kDiTQMKaJOWE6EOWBIUwr8nrDu mPqcfjB1sDwkNKbu0JT1TYnztA== X-Google-Smtp-Source: AGHT+IHokqGcLvTFoksdLga3NGQV/4qCBfUzmAdJeFvPPgAzRaKcrKxpfj1+NRgacFOgSg84G/4BtA== X-Received: by 2002:ac2:495d:0:b0:507:9787:6779 with SMTP id o29-20020ac2495d000000b0050797876779mr3445417lfi.3.1698489199359; Sat, 28 Oct 2023 03:33:19 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Beraldo Leal , Mahmoud Mandour , Brian Cain , Paolo Bonzini , Warner Losh , Eduardo Habkost , Alexandre Iooss , "Edgar E. Iglesias" , Kyle Evans , qemu-arm@nongnu.org, Aleksandar Rikalo , Aurelien Jarno , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Wainer dos Santos Moschetta , Peter Maydell , Brad Smith , Jiaxun Yang , Thomas Huth , Akihiko Odaki , Fabiano Rosas Subject: [PATCH 14/17] gdbstub: Check if gdb_regs is NULL Date: Sat, 28 Oct 2023 11:33:08 +0100 Message-Id: <20231028103311.347104-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231028103311.347104-1-alex.bennee@linaro.org> References: <20231028103311.347104-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2a00:1450:4864:20::133; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x133.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698489429434100013 From: Akihiko Odaki 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 Message-Id: <20231019101030.128431-2-akihiko.odaki@daynix.com> Signed-off-by: Alex Benn=C3=A9e Tested-by: Fabiano Rosas Reviewed-by: Richard Henderson Tested-by: Richard Henderson --- 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.39.2