From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id F2B9B3830B69 for ; Wed, 8 Nov 2023 08:23:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2B9B3830B69 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F2B9B3830B69 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699431836; cv=none; b=hjsfnrCCnQp4S03xqdB5fLT9cqWve4C3SpV+NUzSz09bhRPWvL6djqnXAahA5FFgGfBjfYUFxpXYeWoPqZ9+sHfSDW9wwxgOItgxLY1+pbUudtmDUItNtZvkQwGogDulMFia2O9XgTobGOqb6Gz/Y34+gRErEEp3vPQYZx7fl80= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699431836; c=relaxed/simple; bh=jHeMtocfEqoNtyvZMZnucc1bi6Cq8qPgZq7vn3gnoVI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=lE7pW/c+3zjMEoDqdB3TxUeQd97g/Tzeo9GfV0l39BhShEJoFIHcn+S70eAXqbntqJgtv6IhaLLnuBRs8D8xEs6rXLu3ipctzV9SBC+WzLFJ5NkonVilZu+H+sQfkdDoRc4cZUsYGDDopAlYB6p1+p4R12x77PXWxgKOjriRoUA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c503da4fd6so87558711fa.1 for ; Wed, 08 Nov 2023 00:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699431833; x=1700036633; darn=sourceware.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Yc8Uii0XdnhWKskRZbBF6hoCrjqRnCR0IAp80shtma4=; b=klEgQv/KpkIm7G7frltj+6wJK/Cj0Q5zCLqZhvqxm5e6HThDr8O5yC9K1VpT+mhifl kYC3oHpqRox0RgOz4Sq/BX8l5q6voWWYVgW8Dyim0iyw2O/jWpCTXAKC01dEtmKYBSB2 ZWh70W/ZLFgZ6QFkEc1FvXslUTs1sxKpWFLMyKGOxJCYNbzeTwdydX61WLYLkjnjQ1EM qk4TEjZpDcAFmbcTyNhhJ9fK6xBI3KtdfOUKQYLSg2pN4MIBgLOQK1Cmz75rejk1KbD8 04C2xzk1wSJ9FDgiStO5iKjnIcxd3Zt/YHGmgCmF1dDgCu6Zl/Xhuue/G42gxkJnHx2U GxhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699431833; x=1700036633; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Yc8Uii0XdnhWKskRZbBF6hoCrjqRnCR0IAp80shtma4=; b=rifW5EGFdzorMewckqRk0jw9rjrtrh8sKe95p/Fi/ltk3SeYANpIA8uGpSBj51Vyik eD0mx+aT6KDx0J1AwoG0TC1TJUT1UNx38mSs5AGAn7Lx76Vkz14/xnkip3NuNnSlZAq6 2RS9lhVDNnbdwp/GsHZsIaeI3Uid//YkxzC9TSqr/SswYMNtPYTkOQwbjJZmvqJG3Uc2 Ba4c/a2EfSF0ubauTwTuAmTQyOfpArgZnVLlrkQHqtdwMjlGIRZxkSE5MHcjqgRGxr1F zS3+iJHzv4JD7cQKlhw+k5ByBrTpD59XhG+rndtF062aGogc7maUM3fHrWxgT6VOO/S+ +0NQ== X-Gm-Message-State: AOJu0YxYitsI1k/vbo/qMtGP6FDfxA3VwD+hu2zw5827xmIeh60UPNq8 Q1eBKh1FfcNMv5ID4HykrpO2tBN92gE/vQR3dSqgAg== X-Google-Smtp-Source: AGHT+IGORzeWAqyIwymDaCyaP5ziklZWyNPMcf0dl8dulG/9kn7G+JLx0CeVW7AJzaxo+VkOCK7A7w== X-Received: by 2002:a05:6512:308d:b0:4f8:7513:8cac with SMTP id z13-20020a056512308d00b004f875138cacmr845979lfd.48.1699431832861; Wed, 08 Nov 2023 00:23:52 -0800 (PST) Received: from legouguec-Precision-7550 ([2.57.72.67]) by smtp.gmail.com with ESMTPSA id a15-20020a5d456f000000b0032fab28e9c9sm4304448wrc.73.2023.11.08.00.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 00:23:52 -0800 (PST) From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/3] Implement the notStopped DAP response In-Reply-To: <20231107-dap-not-stopped-v1-3-3d91c935255d@adacore.com> (Tom Tromey's message of "Tue, 07 Nov 2023 11:29:31 -0700") References: <20231107-dap-not-stopped-v1-0-3d91c935255d@adacore.com> <20231107-dap-not-stopped-v1-3-3d91c935255d@adacore.com> Date: Wed, 08 Nov 2023 09:23:51 +0100 Message-ID: <878r78bqlk.fsf@adacore.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tom Tromey writes: > @@ -21,8 +21,17 @@ from .startup import exec_and_log, in_gdb_thread, log > from .modules import is_module, make_module > > > +# True when the inferior is thought to be running, False otherwise. > +# This may be accessed from any thread, which can be racy. However, > +# this unimportant because this global is only used for the > +# 'notStopped' response, which itself is inherently racy. > +inferior_running = False > + > + Out of curiosity, could `inferior_thread ()->state` have helped here? (Exposing it as a gdb.Inferior method perhaps?) Not necessarily with the "racy" part; thinking more of the "keep a single source of truth" part (i.e. dispense with relying on event notifications). > +# A helper decorator that checks whether the inferior is running. > +def _check_not_running(func): > + @functools.wraps(func) > + def check(*args, **kwargs): > + # Import this as late as possible. FIXME. > + from .events import inferior_running > + > + if inferior_running: > + raise Exception("notStopped") > + return func(*args, **kwargs) > + > + return check Assuming this is what the FIXME is about (apologies if not): an alternative could be doing a bare `import .events`, then lookup `.events.inferior_running` in check(). Or defining an accessor function in .events and importing that instead of this global. > @@ -178,6 +199,11 @@ def request(name: str, *, response: bool = True, server: bool = False): > > If SERVER is True, the function will be invoked in the DAP thread. > When SERVER is True, RESPONSE may not be False. > + > + If MUST_BE_STOPPED is True (the default), then the request will > + fail with the 'notStopped' reason if it is processed while the > + inferior is running. When MUST_BE_STOPPED is False, the request > + will proceed regardless of the inferior's state. > """ > > # Validate the parameters. (Feeling like EXPECT_STOPPED might better convey that parameter's role as a precondition, rather than as a "call to action" for request(); tiny nit though, the doc clarifies the intent anyway)