[2/3] Convert DAP disassemble code to use Block hashing

Message ID 20240516-dap-global-scope-v1-2-07c493009505@adacore.com
State New
Headers
Series Return a global scope from DAP scopes request |

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 success Testing passed

Commit Message

Tom Tromey May 16, 2024, 6:01 p.m. UTC
  This changes the DAP disassemble code to use the new Block hashing,
storing the already-visited blocks in a set rather than a list.
---
 gdb/python/lib/gdb/dap/disassemble.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gdb/python/lib/gdb/dap/disassemble.py b/gdb/python/lib/gdb/dap/disassemble.py
index d65790a40b0..a2e27e54a64 100644
--- a/gdb/python/lib/gdb/dap/disassemble.py
+++ b/gdb/python/lib/gdb/dap/disassemble.py
@@ -27,9 +27,8 @@  class _BlockTracker:
         # just one label -- DAP wouldn't let us return multiple labels
         # anyway.
         self.labels = {}
-        # List of blocks that have already been handled.  Note that
-        # blocks aren't hashable so a set is not used.
-        self.blocks = []
+        # Blocks that have already been handled.
+        self.blocks = set()
 
     # Add a gdb.Block and its superblocks, ignoring the static and
     # global block.  BLOCK can also be None, which is ignored.
@@ -37,7 +36,7 @@  class _BlockTracker:
         while block is not None:
             if block.is_static or block.is_global or block in self.blocks:
                 return
-            self.blocks.append(block)
+            self.blocks.add(block)
             if block.function is not None:
                 self.labels[block.start] = block.function.name
             for sym in block: