[binutils-gdb] Fix a latent bug in DAP request decorator

Tom Tromey tromey@sourceware.org
Mon Jun 12 18:13:49 GMT 2023


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5c7cdc95aaace0f2eb7a13199a3cbf479617a009

commit 5c7cdc95aaace0f2eb7a13199a3cbf479617a009
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu May 11 14:25:07 2023 -0600

    Fix a latent bug in DAP request decorator
    
    The 'request' decorator is intended to also ensure that the request
    function runs in the DAP thread.  However, the unwrapped function is
    installed in the global request map, so the wrapped version is never
    called.  This patch fixes the bug.

Diff:
---
 gdb/python/lib/gdb/dap/server.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index f27fa9caa4f..8abe475b031 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -164,9 +164,10 @@ def request(name):
 
     def wrap(func):
         global _commands
-        _commands[name] = func
         # All requests must run in the DAP thread.
-        return in_dap_thread(func)
+        func = in_dap_thread(func)
+        _commands[name] = func
+        return func
 
     return wrap


More information about the Gdb-cvs mailing list