[5/7] Fix a bug in DAP scopes code

Message ID 20231101-dap-nested-function-v1-5-0b0c3b228ac7@adacore.com
State New
Headers
Series Handle nested functions in DAP |

Checks

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

Commit Message

Tom Tromey Nov. 1, 2023, 5:09 p.m. UTC
  While working on static links, I noticed that the DAP scopes code does
not handle the scenario where a frame decorator returns None.  This
situation should be handled identically to a frame decorator returning
an empty iterator.
---
 gdb/python/lib/gdb/dap/scopes.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
  

Patch

diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py
index 87f2ed7547f..13c35817fb6 100644
--- a/gdb/python/lib/gdb/dap/scopes.py
+++ b/gdb/python/lib/gdb/dap/scopes.py
@@ -107,10 +107,14 @@  def _get_scope(id):
     else:
         frame = frame_for_id(id)
         scopes = []
-        args = frame.frame_args()
+        # Make sure to handle the None case as well as the empty
+        # iterator case.
+        args = tuple(frame.frame_args() or ())
         if args:
             scopes.append(_ScopeReference("Arguments", "arguments", frame, args))
-        locs = frame.frame_locals()
+        # Make sure to handle the None case as well as the empty
+        # iterator case.
+        locs = tuple(frame.frame_locals() or ())
         if locs:
             scopes.append(_ScopeReference("Locals", "locals", frame, locs))
         scopes.append(_RegisterReference("Registers", frame))