From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-77a62a84855so235653239f.1 for ; Tue, 25 Jul 2023 06:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1690292982; x=1690897782; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1daIOuKxH+zMHg4+ctPJ5fVGmHm29E6mixuqB/RmoaM=; b=dH22n5ikVoSiDxV4CMtFUwRP8cfhcqCpdnB5vNnmYrp8PyyhDI/HnY37m94+tjO/Y3 xyHLo1VgBtuC0WLPF3uwTPTg13prv+Vxv+zGvJo8beYmibWbz5+z1PvjJs0I+hvAFWrO pTM/+MHrxkz+O5F4LuGgX7mmtHZXXFOc79sn8Pr3eo9wNuQLMZiSNQXH5nttRZKYRMUE Pm/OQWg7Kx80hNPHH582PP8ZMaUhs0LUeKZOf+FX1b41FZmgc1Zg7adtUsxHai2yVPDJ VMgWy0T9ALp1D4z+dY0Y5abXHO2nRkp8c0ypqiiRvjnACigwn7k071aEt5AiqBpJyv8U hZGA== 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) From: Tom Tromey 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 List-Id: 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) -- 2.40.1