public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Implement DAP module-removed event
@ 2023-08-04 15:51 Tom Tromey
  2023-08-08 20:02 ` Alexandra Petlanova Hajkova
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-08-04 15:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

DAP specifies an event that should be sent when a module is removed.
This patch implements this.
---
 gdb/python/lib/gdb/dap/events.py  | 13 +++++++++++++
 gdb/testsuite/gdb.dap/modules.c   |  3 +++
 gdb/testsuite/gdb.dap/modules.exp | 15 +++++++++++++--
 3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index aca25120ca0..e9ddcab135f 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -68,6 +68,18 @@ def _new_objfile(event):
         )
 
 
+@in_gdb_thread
+def _objfile_removed(event):
+    if is_module(event.objfile):
+        send_event(
+            "module",
+            {
+                "reason": "removed",
+                "module": make_module(event.objfile),
+            },
+        )
+
+
 _suppress_cont = False
 
 
@@ -150,3 +162,4 @@ gdb.events.new_thread.connect(_new_thread)
 gdb.events.thread_exited.connect(_thread_exited)
 gdb.events.cont.connect(_cont)
 gdb.events.new_objfile.connect(_new_objfile)
+gdb.events.free_objfile.connect(_objfile_removed)
diff --git a/gdb/testsuite/gdb.dap/modules.c b/gdb/testsuite/gdb.dap/modules.c
index 6ef8a600c5d..7a4b9f0d898 100644
--- a/gdb/testsuite/gdb.dap/modules.c
+++ b/gdb/testsuite/gdb.dap/modules.c
@@ -36,5 +36,8 @@ main (void)
   func = (int (*)(void (*) (void))) dlsym (handle, "call_me");
   func (stop);
 
+  dlclose (handle);
+  stop ();
+
   return 0;
 }
diff --git a/gdb/testsuite/gdb.dap/modules.exp b/gdb/testsuite/gdb.dap/modules.exp
index e75ae578c78..949a3cfccf0 100644
--- a/gdb/testsuite/gdb.dap/modules.exp
+++ b/gdb/testsuite/gdb.dap/modules.exp
@@ -42,7 +42,7 @@ if {[dap_launch $testfile] == ""} {
     return
 }
 
-set obj [dap_check_request_and_response "set breakpoint on two functions" \
+set obj [dap_check_request_and_response "set breakpoint on stop function" \
 	     setFunctionBreakpoints \
 	     {o breakpoints [a [o name [s stop]]]}]
 set fn_bpno [dap_get_breakpoint_number $obj]
@@ -53,7 +53,7 @@ dap_wait_for_event_and_check "stopped at function breakpoint" stopped \
     "body reason" breakpoint \
     "body hitBreakpointIds" $fn_bpno
 
-dap_check_request_and_response "continue to next stop" continue \
+dap_check_request_and_response "continue to second stop" continue \
     {o threadId [i 1]}
 
 
@@ -78,4 +78,15 @@ set frame_id [dict get [lindex [dict get $bt body stackFrames] 1] moduleId]
 
 gdb_assert {[string match *$libname* $frame_id]} "module.id in stack trace"
 
+
+dap_check_request_and_response "continue to third stop" continue \
+    {o threadId [i 1]}
+
+dap_wait_for_event_and_check "module removed event" module \
+    "body reason" removed
+
+dap_wait_for_event_and_check "third stop at function breakpoint" stopped \
+    "body reason" breakpoint \
+    "body hitBreakpointIds" $fn_bpno
+
 dap_shutdown
-- 
2.40.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Implement DAP module-removed event
  2023-08-04 15:51 [PATCH] Implement DAP module-removed event Tom Tromey
@ 2023-08-08 20:02 ` Alexandra Petlanova Hajkova
  2023-08-16 15:54   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandra Petlanova Hajkova @ 2023-08-08 20:02 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 534 bytes --]

On Fri, Aug 4, 2023 at 5:51 PM Tom Tromey via Gdb-patches <
gdb-patches@sourceware.org> wrote:

> DAP specifies an event that should be sent when a module is removed.
> This patch implements this.
> ---
>  gdb/python/lib/gdb/dap/events.py  | 13 +++++++++++++
>  gdb/testsuite/gdb.dap/modules.c   |  3 +++
>  gdb/testsuite/gdb.dap/modules.exp | 15 +++++++++++++--
>  3 files changed, 29 insertions(+), 2 deletions(-)
>
> I can confirm this change does not introduce any regressions, tested on
> Fedora 38, x86_64.
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Implement DAP module-removed event
  2023-08-08 20:02 ` Alexandra Petlanova Hajkova
@ 2023-08-16 15:54   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2023-08-16 15:54 UTC (permalink / raw)
  To: Alexandra Petlanova Hajkova; +Cc: Tom Tromey, gdb-patches

Alexandra>  I can confirm this change does not introduce any
Alexandra>  regressions, tested on Fedora 38, x86_64.

Thanks, I'm going to add a tested-by tag & push this now.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-16 15:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-04 15:51 [PATCH] Implement DAP module-removed event Tom Tromey
2023-08-08 20:02 ` Alexandra Petlanova Hajkova
2023-08-16 15:54   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).