From nobody Tue Feb 10 10:59:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1573839284; cv=none; d=zoho.com; s=zohoarc; b=OH304qxUFd+CdopNkwQthST84cCXN5uP7UTTAfNf5bcolhxIW+G2g0ItS/dWz6E3EGKf4jrXhJl57WNpHxaufSma2n68PFYNOb1hXHDUBEhu8QEJLfpGI0D/eet/Y+T4ktzCKjpDiioVTOD43HDAHpyvr2ot6D0zi4C7jQRkaQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573839284; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b3lRu2lU9dlRQQ6ScHgKfSG/1eYQg9vd77Swnr8j6IA=; b=DVMNzhzPRlwsanTL+nVhH95iM2qrXhorWQ94k85WvpfcKURgk7yfnUD5x62sWY4nSZ0kFrv0e9hj5o8/18dW3bbeMRgXFvn7IlXotp+T2Nlf7ryOz/QgiuswcxCrCU4yoD2octaiXD7FGq6coFPLYnPzES1+Q+iTf9ApUWTmRT0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573839284788900.115175166973; Fri, 15 Nov 2019 09:34:44 -0800 (PST) Received: from localhost ([::1]:42762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVfUT-0001tg-S4 for importer@patchew.org; Fri, 15 Nov 2019 12:34:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34425) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVfQ6-0007BH-Ja for qemu-devel@nongnu.org; Fri, 15 Nov 2019 12:30:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVfQ4-0002i5-Dy for qemu-devel@nongnu.org; Fri, 15 Nov 2019 12:30:06 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iVfQ4-0002dp-3f for qemu-devel@nongnu.org; Fri, 15 Nov 2019 12:30:04 -0500 Received: by mail-wr1-x444.google.com with SMTP id r10so11851227wrx.3 for ; Fri, 15 Nov 2019 09:30:03 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id x11sm12248423wro.84.2019.11.15.09.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 09:30:01 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DC5201FF8C; Fri, 15 Nov 2019 17:30:00 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b3lRu2lU9dlRQQ6ScHgKfSG/1eYQg9vd77Swnr8j6IA=; b=VX4rYQkbDLJQAzgEhNQU4zCu21NMgPbg7GNdfh8AFd2iMQ7uL2Dm4WX8I2pe1QjjJh tPAmG92LF77wtSOpKpoGYSsGDoxLMjgzuYYRldGRcqkFEXgaS4Ib14FegxGT7Kqs2GvZ W9pzhAUQIhdeNggKOJwB89oZWa2EhxvNnXvzcth41eUdyzGRCM55dnf9arTuvIjRV5dr 8HM7WXNFPNt3EG8mvQAgx+xx4BsEwN3MpiBDFRcNO9Xw1RmZpNWxHznZysUUGHP/lH5u +tWVKyCCXN8UYL2hTXp49ZI3ns6D/7wfNXb9EQgOg3LYglI9CfD+BCoeo1VSBSdiQgGp 9Eiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b3lRu2lU9dlRQQ6ScHgKfSG/1eYQg9vd77Swnr8j6IA=; b=gezzMJAUvAeV2aUQfynr7GeDo59wU3eRpQkaJESZ2o+NJkRObMhwV+fheNQ/pAkq5v zH/b3tm7PR8QtIweX81PWDHaIrvsYTKRNgfFLgM6WgzUXlOTx5bieifJnDmwR5OBrCbD 2UKBoCqRVjcfH8VmbRqVDQsRxUZQlN4Nc3OkRmdGeu6Prco7k9LZUEO2G47hDmkGN9ra 6GpO9qKtKASRwaHuQnHAtbMzBlv3iGUy5gfhfbvqyLmjmtNVVNAdvoY7scFWUvB9sjI1 2bfgw8I66e8Re+gh8SfwKtkN4/gY0Oe3NLszTP1PBT1etnOeXPuydcBQI6NpfM86VeAz ovBw== X-Gm-Message-State: APjAAAVrSWhan58BnsL83IlDz/wjK8PHkRSQropfy4NOnv5hx9BIRNyU HmY1MXBDMON307a6EqY2Eo7uNA== X-Google-Smtp-Source: APXvYqwUsBlWQVxnzTlbrH0mbq88zgEd3ethII/j4ofEb0yRBPFkKrFFgjt9vQwQCq1pX4PYANul8Q== X-Received: by 2002:a5d:4684:: with SMTP id u4mr15846457wrq.352.1573839002363; Fri, 15 Nov 2019 09:30:02 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [RFC PATCH 01/11] gdbstub: move allocation of GDBState to one place Date: Fri, 15 Nov 2019 17:29:50 +0000 Message-Id: <20191115173000.21891-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191115173000.21891-1-alex.bennee@linaro.org> References: <20191115173000.21891-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, luis.machado@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , richard.henderson@linaro.org, alan.hayward@arm.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We use g_new0() as it is the preferred form for such allocations. We can also ensure that gdbserver_state is reset in one place. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Damien Hedde Reviewed-by: Richard Henderson --- gdbstub.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 4cf8af365e2..c5b6701825f 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -374,6 +374,13 @@ static int sstep_flags =3D SSTEP_ENABLE|SSTEP_NOIRQ|SS= TEP_NOTIMER; =20 static GDBState *gdbserver_state; =20 +static GDBState *gdb_allocate_state(void) +{ + g_assert(!gdbserver_state); + gdbserver_state =3D g_new0(GDBState, 1); + return gdbserver_state; +} + bool gdb_has_xml; =20 #ifdef CONFIG_USER_ONLY @@ -3083,15 +3090,13 @@ static bool gdb_accept(void) return false; } =20 - s =3D g_malloc0(sizeof(GDBState)); + s =3D gdb_allocate_state(); create_default_process(s); s->processes[0].attached =3D true; s->c_cpu =3D gdb_first_attached_cpu(s); s->g_cpu =3D s->c_cpu; s->fd =3D fd; gdb_has_xml =3D false; - - gdbserver_state =3D s; return true; } =20 @@ -3359,8 +3364,7 @@ int gdbserver_start(const char *device) =20 s =3D gdbserver_state; if (!s) { - s =3D g_malloc0(sizeof(GDBState)); - gdbserver_state =3D s; + s =3D gdb_allocate_state(); =20 qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); =20 --=20 2.20.1