Don't allow multiple request registrations in DAP

Message ID 20240207194735.3478872-1-tromey@adacore.com
State New
Headers
Series Don't allow multiple request registrations in DAP |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Testing failed

Commit Message

Tom Tromey Feb. 7, 2024, 7:47 p.m. UTC
  This changes the DAP code to check that a given request or capability
is only registered a single time.  This is just a precaution against
accidentally introducing a second definition of a request somewhere.
---
 gdb/python/lib/gdb/dap/server.py | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Alexandra Petlanova Hajkova Feb. 9, 2024, 12:04 p.m. UTC | #1
On Wed, Feb 7, 2024 at 8:47 PM Tom Tromey <tromey@adacore.com> wrote:

> This changes the DAP code to check that a given request or capability
> is only registered a single time.  This is just a precaution against
> accidentally introducing a second definition of a request somewhere.
>
>
I can confirm this change does not cause any regressions on ppc64le, Fedora
Rawhide.
  
Tom Tromey Feb. 21, 2024, 9:11 p.m. UTC | #2
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:

Tom> This changes the DAP code to check that a given request or capability
Tom> is only registered a single time.  This is just a precaution against
Tom> accidentally introducing a second definition of a request somewhere.

I'm checking this in.

Tom
  

Patch

diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index 7cc5a4681ee..ba139412b90 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -354,6 +354,7 @@  def request(
             cmd = _check_not_running(cmd)
 
         global _commands
+        assert name not in _commands
         _commands[name] = cmd
         return cmd
 
@@ -366,6 +367,7 @@  def capability(name, value=True):
 
     def wrap(func):
         global _capabilities
+        assert name not in _capabilities
         _capabilities[name] = value
         return func