]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert DAP disassemble code to use Block hashing
authorTom Tromey <tromey@adacore.com>
Thu, 16 May 2024 13:57:59 +0000 (07:57 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 4 Jun 2024 16:54:18 +0000 (10:54 -0600)
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

index d65790a40b0eebb30d9cb919e79d7a9d9fc3d341..a2e27e54a6408487f8c32b358389fd21b3eac179 100644 (file)
@@ -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: