From patchwork Wed May 31 14:12:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Farre X-Patchwork-Id: 70387 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 536E33858296 for ; Wed, 31 May 2023 14:13:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 536E33858296 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685542418; bh=KOD4rjZNKbr+OyTGx2shxsS95oHhWgztMerokpzHTsk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=wlOkzOY3v/aZ2FhYMKk4W/KK7C57Bvb0+pdYMkz9nF2Jzhz4Ey998apbvI7irki6w VIoXFRE69kVV5QVI5LleZNSFLWLfKK/2v9qHFe3TPJTjL18gtcFwoxeUkRj2fQsiha obRJMC6YZMztOIKccygXwaHzp1k49e6bcTSLg1gE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 4C3C13858D20 for ; Wed, 31 May 2023 14:13:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C3C13858D20 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2af1ae3a21fso64443571fa.0 for ; Wed, 31 May 2023 07:13:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685542393; x=1688134393; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KOD4rjZNKbr+OyTGx2shxsS95oHhWgztMerokpzHTsk=; b=I8L7n0EzcGzy2ArWR9tqFWJKqyGTl01fdrUv2JvOkLYFOkaKLyVrzeMeC9KjHXhGZi DJJhOhACJG3L6t2ImBevL1UH7vC1zG0Brcn9tNLTeC7M/ap9wNVJI96fnqxUDXr5/SgK zm28hc2c3Tq2axLpBs9eDEdt4p2Dw/9B1D/6DLe28E2hdQ8EAtTXI8VlgF1ikZWUscVV /93J7gAmV0fpSZZ6wb3XX7lAPRTyuZwcHJMLlvhW30pTaDNDNS5Gh5Z7JNQ3MPCI3q2W aE1NhUthAfgpxpHSomf377losRmdjvE43xLkc2HW6BF9CBfPmIQMRwfHv25iYP5IBNzj Uteg== X-Gm-Message-State: AC+VfDzSaCSVnqURBbSpiDSwzizY36uYkj243F3nx5GFXbt/4jP3DwAr 6iZdwxg31ZvmhkgTgCVel0qd9hnBy4g8vA== X-Google-Smtp-Source: ACHHUZ5ABP/RL9+TK0dc1XiwPETIDg7nK/OaJjX7yaV4iZVAfVRINCkt7O4oA8cav0AUa8mlS1ZVkg== X-Received: by 2002:a2e:9650:0:b0:2ad:9c26:3638 with SMTP id z16-20020a2e9650000000b002ad9c263638mr2965687ljh.52.1685542392431; Wed, 31 May 2023 07:13:12 -0700 (PDT) Received: from fedora.. (78-73-77-63-no2450.tbcn.telia.com. [78.73.77.63]) by smtp.gmail.com with ESMTPSA id z24-20020a2e9b98000000b002af2a411655sm3327628lji.41.2023.05.31.07.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 07:13:11 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Simon Farre Subject: [PATCH v2] Fix DAP Stop & Continue event bugs Date: Wed, 31 May 2023 16:12:58 +0200 Message-Id: <20230531141258.222599-1-simon.farre.cx@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Simon Farre via Gdb-patches From: Simon Farre Reply-To: Simon Farre Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Removed type annotation as it broke gdbpy. Fixes a bug in the stop and continue event handlers in the DAP code. Event handlers used the `gdb.selected_thread` which may or may not be null at the time the event handler is called. It may also return the wrong thread. The event parameter holds the necessary data. --- gdb/python/lib/gdb/dap/events.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py index d9ae603dfa4..9dc2b58ca5a 100644 --- a/gdb/python/lib/gdb/dap/events.py +++ b/gdb/python/lib/gdb/dap/events.py @@ -91,7 +91,7 @@ def _cont(event): send_event( "continued", { - "threadId": gdb.selected_thread().global_num, + "threadId": event.inferior_thread.global_num, "allThreadsContinued": True, }, ) @@ -139,7 +139,7 @@ def _on_stop(event): log("entering _on_stop: " + repr(event)) global _expected_stop obj = { - "threadId": gdb.selected_thread().global_num, + "threadId": event.inferior_thread.global_num, "allThreadsStopped": True, } if isinstance(event, gdb.BreakpointEvent):