From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 86m9KmlQLWWEcS8AWB0awg (envelope-from ) for ; Mon, 16 Oct 2023 11:02:01 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eUJJ9hRN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A10F61E0C1; Mon, 16 Oct 2023 11:02:01 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 872B11E00F for ; Mon, 16 Oct 2023 11:01:59 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C683385E038 for ; Mon, 16 Oct 2023 15:01:58 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C52D73858C35 for ; Mon, 16 Oct 2023 15:01:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C52D73858C35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C52D73858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697468508; cv=none; b=G0G7LRRJYHHL2Np2NVNWqnaMCOIQoEnUt4k75//iW/ZcSM9OCViO65QFe38yu3VBNzGLLtrpedqXo1A2+/nWB3vVIU3wWRdaB0tbO720wcF1mhjc3k1e/Ndyba6QEBb4QL1d567p/tSZBuzDhmIec70VVI5jP4IdJbD2pbrdcEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697468508; c=relaxed/simple; bh=Lg+QtUBAmW/qjTN1EE2Gk7baLGyqS8Itxnh5Gvc1ly8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kMwvTTrXtV/Upyuvgqc8m+KgKwFvIdeDbAkny6ADsA4odui1hiZummwkNIXybuRvRHzM/n5hQJK2VC8hfYm9JhvFGAc6zNUkUnPncAFCrTuJePdNZnmKGs+jJOHR9N13sB4yDKC/Hr6qu0MMHL9FxJCnYUTWEUXqkSvd9A1gOtU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697468506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GDEydxO3b36/tP9MRTiRsTt+tTrRwGXaL9UPtE83o4s=; b=eUJJ9hRNHmO9wbTwyV3xCWPKlhZCkbK65a/nROAETH78aCRF1tb2sOtagQdSWyhpufI/V+ u/VznlnEL/M+WNGwFafIChkc4Qv6sQ7eeTBskz9OX/AqM5s1lcd4NPQpwtKbAoUbAdokxa M3W+WMavMVjLKvi3V9wDDmOefL1C8+Y= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-jzwSWTPEOfynhsLV_sK5Mw-1; Mon, 16 Oct 2023 11:01:45 -0400 X-MC-Unique: jzwSWTPEOfynhsLV_sK5Mw-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-77410b85b63so569569485a.1 for ; Mon, 16 Oct 2023 08:01:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697468505; x=1698073305; h=mime-version: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=GDEydxO3b36/tP9MRTiRsTt+tTrRwGXaL9UPtE83o4s=; b=lVwj/cHlwQyAVyhJgixsi/8rH+DGNTYv9jiBCd45L8MQOguYoAAU7Ad1hXMNsDOhkP rpJAo49hVCkhQpbPYS7wcPm3uwXnNMVj6VxOn+t+57aEGsPrUXpYYC56v2goUdo7pmEo OLFMDGVkyZLArxYLBB0WKZyRWFoc9OazcF7Kff/bHnZdHtu5ejPgU57iuWSnDfbLWeCI KNez1dRuV2EFprq2OoaGdEqvj9SseRa6HASnTYPtOaAXRcPeFU1iYtIzoWJBv5u3Zu47 0uzFwoW5wd3MKnz8k2IUZ/ZuvSLyUDOt3xU/IISy4qMzgJHyOdl36MaDmlrl4Dek8ps3 tjMQ== X-Gm-Message-State: AOJu0Ywud1mk1o91z8Uk3H2w4T9fzNASESbYzQajBTQaT6iYGMR71K1t aNPCgnDAUC+RS/3mX8hWI8dFRi5W5/pxFvAa0wAH1tzBoU87gxKl3GUd7FpunHbGEwbVSrOAVsr Mk6gMcb388SF9MB9JG5/1Gw== X-Received: by 2002:a05:620a:854:b0:76c:fc7c:ac5e with SMTP id u20-20020a05620a085400b0076cfc7cac5emr34323799qku.74.1697468504755; Mon, 16 Oct 2023 08:01:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqZjE9JiFc1TSTk1KOz6zYS5005F51R8NHEGuisZIx1x5x5H1nkGEf5J7DJ8KL2mXmLtyG+Q== X-Received: by 2002:a05:620a:854:b0:76c:fc7c:ac5e with SMTP id u20-20020a05620a085400b0076cfc7cac5emr34323766qku.74.1697468504302; Mon, 16 Oct 2023 08:01:44 -0700 (PDT) Received: from localhost ([31.111.84.209]) by smtp.gmail.com with ESMTPSA id o23-20020a05620a111700b007671cfe8a18sm3054268qkk.13.2023.10.16.08.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 08:01:44 -0700 (PDT) From: Andrew Burgess To: Simon Farre , gdb-patches@sourceware.org Cc: tromey@adacore.com, Simon Farre Subject: Re: [PATCH v1] [gdb/python]: Add StepEndedEvent (simplifies DAP) In-Reply-To: <20231016115026.133574-1-simon.farre.cx@gmail.com> References: <20231016115026.133574-1-simon.farre.cx@gmail.com> Date: Mon, 16 Oct 2023 16:01:42 +0100 Message-ID: <8734yahaqx.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Simon Farre writes: > Adds the StepEndedEvent which signals that one of the thread finite state machines > finished. Matches the behavior of what is generated by MI; the "end stepping range". > > This should simplify some of the DAP code, where "expected stop reason" is being tracked. > This logic should be handled by the Python interpreter to begin with, instead. > --- > gdb/NEWS | 3 +++ > gdb/doc/python.texi | 3 +++ > gdb/python/py-event-types.def | 5 +++++ > gdb/python/py-stopevent.c | 17 +++++++++++++++++ This will definitely need some tests writing for it. It might be possible to just add some additional cases to gdb.python/py-events.exp to cover this new functionality. > 4 files changed, 28 insertions(+) > > diff --git a/gdb/NEWS b/gdb/NEWS > index 81264c0cfb3..b2abaa6a2ce 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -11,6 +11,9 @@ > ** New function gdb.notify_mi(NAME, DATA), that emits custom > GDB/MI async notification. > > + ** Added StepEndedEvent which is emitted during stops where it could be determined > + that what triggered the stop was that the stepping state machine finished. > + > *** Changes in GDB 14 > > * GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which > diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi > index 546b4d4b962..c6968791eb1 100644 > --- a/gdb/doc/python.texi > +++ b/gdb/doc/python.texi > @@ -3733,6 +3733,9 @@ registry extend @code{gdb.StopEvent}. As a child of > thread when @value{GDBN} is running in non-stop mode. Refer to > @code{gdb.ThreadEvent} above for more details. > > +Emits @code{gdb.StepEndedEvent} that signals that this stop event was generated > +because one of the step-like commands finished. > + > Emits @code{gdb.SignalEvent}, which extends @code{gdb.StopEvent}. > > This event indicates that the inferior or one of its threads has > diff --git a/gdb/python/py-event-types.def b/gdb/python/py-event-types.def > index c6225115027..36146b181c5 100644 > --- a/gdb/python/py-event-types.def > +++ b/gdb/python/py-event-types.def > @@ -106,6 +106,11 @@ GDB_PY_DEFINE_EVENT_TYPE (signal, > "GDB signal event object", > stop_event_object_type); > > +GDB_PY_DEFINE_EVENT_TYPE (step_ended, > + "StepEndedEvent", > + "GDB step ended event object", > + stop_event_object_type); > + > GDB_PY_DEFINE_EVENT_TYPE (stop, > "StopEvent", > "GDB stop event object", > diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c > index 0aa9d5381f8..13e1b12d33a 100644 > --- a/gdb/python/py-stopevent.c > +++ b/gdb/python/py-stopevent.c > @@ -18,6 +18,7 @@ > along with this program. If not, see . */ > > #include "defs.h" > +#include "mi/mi-common.h" > #include "py-stopevent.h" > > gdbpy_ref<> > @@ -27,6 +28,21 @@ create_stop_event_object (PyTypeObject *py_type) > return create_thread_event_object (py_type, thread.get ()); > } > > +/** If thread finite state machine reports that it has finished, inform > + the Python-interpreter of this. */ Start comments with '/*' and end with two spaces after the '.' before '*/'. > + > +static gdbpy_ref<> maybe_create_step_ended () Newline before the function name. Plus should have a comment above the function explaining what it does. > +{ > + const auto tp = inferior_thread(); > + const auto fsm = tp != nullptr ? tp->thread_fsm() : nullptr; 2x missing space before (). > + if (fsm != nullptr && fsm->finished_p () && > + fsm->async_reply_reason () == EXEC_ASYNC_END_STEPPING_RANGE) The '&&' should be at the start of the new line. > + { > + return create_stop_event_object (&step_ended_event_object_type); > + } Single statement blocks don't require { ... } around them. Thanks, Andrew > + return nullptr; > +} > + > /* Callback observers when a stop event occurs. This function will create a > new Python stop event object. If only a specific thread is stopped the > thread object of the event will be set to that thread. Otherwise, if all > @@ -86,6 +102,7 @@ emit_stop_event (struct bpstat *bs, enum gdb_signal stop_signal) > return -1; > } > > + stop_event_obj = maybe_create_step_ended(); > /* If all fails emit an unknown stop event. All event types should > be known and this should eventually be unused. */ > if (stop_event_obj == NULL) > -- > 2.41.0