From patchwork Tue Jul 25 13:49:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 73160 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 1248E38708BF for ; Tue, 25 Jul 2023 13:50:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1248E38708BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690293050; bh=1daIOuKxH+zMHg4+ctPJ5fVGmHm29E6mixuqB/RmoaM=; h=Date:Subject:References:In-Reply-To:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=eJeNW9lc2VFVbeD//wkHxt7Z8gfVHy25s3E2Mod7RXzgz52dm1qGERtdPhKO5u4GB W8O8Bl4Ft4yEbPfxiEqADTAfUcQ+JHqSnZ95v77lYg9U0rRkxIvwS0S5BTwHZFLELG MRSrsFFiFv7E75ZJeUvGcN2Vko2fOXsLJPNDPMZA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by sourceware.org (Postfix) with ESMTPS id 73B90385773F for ; Tue, 25 Jul 2023 13:49:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73B90385773F Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-77a62a84855so235653239f.1 for ; Tue, 25 Jul 2023 06:49:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690292982; x=1690897782; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1daIOuKxH+zMHg4+ctPJ5fVGmHm29E6mixuqB/RmoaM=; b=NmuCxeK07vs4hG17se1qtU1sICrUd72+93jypP/esO5uRhwg6i890VvrPhKemk9UqC 4+AC/vzk9rMWr3nvbXW0N8Kk/b80jlO9eJ3jv6okgVMKFVNczlLgW3sY40Oh4Z7dh90C uCvdEzfInhgQ1VsiKZlNSkRgHXX3oa//3zo2zPzU4JfJM2aSqAKqsbiWeHzO1KthSn7A JuMxppeElGL3mibhYkBNc+/w47uEXfwNeIF5yWYsbDLwZvE4bibJfffjjwDLmbSAGFch C/L12kv+oDjVrP5lD9d6OW2VXD2EtnQmJpFyyHOkORn8z/MTDBvtjecdIgIXJTA48c7/ Zu8g== X-Gm-Message-State: ABy/qLZUTN2ei5TLuMo2G28shKHcCJGJp1GqeAxWQjm2IgGkqwHMEwAJ ejdeavLWTh7lPUtYfZCzZd2uAkPFWymbJIwH0uWXZQ== X-Google-Smtp-Source: APBJJlFD4fkzCOqqJI3xKQ0u+M7xFG1tdQ1m2HhPMQQXXMPP5hO3W49NuY5UHTLLLlofZGyfVTslgA== X-Received: by 2002:a05:6602:190:b0:786:e612:72f8 with SMTP id m16-20020a056602019000b00786e61272f8mr2451809ioo.21.1690292982749; Tue, 25 Jul 2023 06:49:42 -0700 (PDT) Received: from localhost.localdomain (75-166-135-140.hlrn.qwest.net. [75.166.135.140]) by smtp.gmail.com with ESMTPSA id c3-20020a02a403000000b00418a5e0e93esm3595018jal.162.2023.07.25.06.49.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 06:49:42 -0700 (PDT) Date: Tue, 25 Jul 2023 07:49:42 -0600 Subject: [PATCH 5/6] Move DAP breakpoint event code to breakpoint.py MIME-Version: 1.0 Message-Id: <20230725-dap-bt-path-v1-5-bb015b0d8e54@adacore.com> References: <20230725-dap-bt-path-v1-0-bb015b0d8e54@adacore.com> In-Reply-To: <20230725-dap-bt-path-v1-0-bb015b0d8e54@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Tom Tromey via Gdb-patches From: Tom Tromey Reply-To: Tom Tromey Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" A subsequent patch will add the ability to suppress breakpoint events to DAP. My first attempt at this ended up with recurse imports, cause Python failures. So, this patch moves all the DAP breakpoint event code to breakpoint.py in preparation for the change. I've renamed breakpoint_descriptor here as well, because it can now be private to breakpoint.py. --- gdb/python/lib/gdb/dap/breakpoint.py | 42 ++++++++++++++++++++++++++++++++++-- gdb/python/lib/gdb/dap/events.py | 37 ------------------------------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 27745ebfd2c..4a1c98efd87 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -25,6 +25,44 @@ from .startup import send_gdb_with_response, in_gdb_thread, log_stack from .typecheck import type_check +@in_gdb_thread +def _bp_modified(event): + send_event( + "breakpoint", + { + "reason": "changed", + "breakpoint": _breakpoint_descriptor(event), + }, + ) + + +@in_gdb_thread +def _bp_created(event): + send_event( + "breakpoint", + { + "reason": "new", + "breakpoint": _breakpoint_descriptor(event), + }, + ) + + +@in_gdb_thread +def _bp_deleted(event): + send_event( + "breakpoint", + { + "reason": "removed", + "breakpoint": _breakpoint_descriptor(event), + }, + ) + + +gdb.events.breakpoint_created.connect(_bp_created) +gdb.events.breakpoint_modified.connect(_bp_modified) +gdb.events.breakpoint_deleted.connect(_bp_deleted) + + # Map from the breakpoint "kind" (like "function") to a second map, of # breakpoints of that type. The second map uses the breakpoint spec # as a key, and the gdb.Breakpoint itself as a value. This is used to @@ -34,7 +72,7 @@ breakpoint_map = {} @in_gdb_thread -def breakpoint_descriptor(bp): +def _breakpoint_descriptor(bp): "Return the Breakpoint object descriptor given a gdb Breakpoint." result = { "id": bp.number, @@ -115,7 +153,7 @@ def _set_breakpoints_callback(kind, specs, creator): # Reaching this spot means success. breakpoint_map[kind][keyspec] = bp - result.append(breakpoint_descriptor(bp)) + result.append(_breakpoint_descriptor(bp)) # Exceptions other than gdb.error are possible here. except Exception as e: log_stack() diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py index c1631442746..50ab038e91d 100644 --- a/gdb/python/lib/gdb/dap/events.py +++ b/gdb/python/lib/gdb/dap/events.py @@ -18,7 +18,6 @@ import gdb from .server import send_event from .startup import in_gdb_thread, Invoker, log -from .breakpoint import breakpoint_descriptor from .modules import is_module, make_module @@ -35,39 +34,6 @@ def _on_exit(event): ) -@in_gdb_thread -def _bp_modified(event): - send_event( - "breakpoint", - { - "reason": "changed", - "breakpoint": breakpoint_descriptor(event), - }, - ) - - -@in_gdb_thread -def _bp_created(event): - send_event( - "breakpoint", - { - "reason": "new", - "breakpoint": breakpoint_descriptor(event), - }, - ) - - -@in_gdb_thread -def _bp_deleted(event): - send_event( - "breakpoint", - { - "reason": "removed", - "breakpoint": breakpoint_descriptor(event), - }, - ) - - @in_gdb_thread def _new_thread(event): send_event( @@ -169,9 +135,6 @@ def _on_stop(event): gdb.events.stop.connect(_on_stop) gdb.events.exited.connect(_on_exit) -gdb.events.breakpoint_created.connect(_bp_created) -gdb.events.breakpoint_modified.connect(_bp_modified) -gdb.events.breakpoint_deleted.connect(_bp_deleted) gdb.events.new_thread.connect(_new_thread) gdb.events.cont.connect(_cont) gdb.events.new_objfile.connect(_new_objfile)