5
5
6
6
HOST = "127.0.0.1"
7
7
PORT = 5678
8
- DEPTH_LIMIT = 2 # How many levels deep to fetch variables
9
8
10
9
11
10
def read_line (sock ):
@@ -93,7 +92,7 @@ def fetch_variables(sock, seq, var_ref):
93
92
return seq , variables_list
94
93
95
94
96
- def fetch_variable_tree (sock , seq , var_ref , depth = DEPTH_LIMIT , visited = None ):
95
+ def fetch_variable_tree (sock , seq , var_ref , depth , visited = None ):
97
96
"""
98
97
Recursively fetches a tree of variables up to 'depth' levels.
99
98
@@ -152,7 +151,7 @@ def fetch_variable_tree(sock, seq, var_ref, depth=DEPTH_LIMIT, visited=None):
152
151
return seq , result
153
152
154
153
155
- def dap_client ():
154
+ def dap_client (depth_limit : int ):
156
155
"""
157
156
Example DAP client that:
158
157
1. Connects to debugpy,
@@ -166,6 +165,7 @@ def dap_client():
166
165
"""
167
166
168
167
print (f"Connecting to { HOST } :{ PORT } ..." )
168
+ print (f"Depth limit: { depth_limit } " )
169
169
sock = socket .create_connection ((HOST , PORT ))
170
170
sock .settimeout (10.0 )
171
171
@@ -303,7 +303,7 @@ def dap_client():
303
303
print (f" Scope: { scope_name_original } (ref={ scope_ref } )" )
304
304
305
305
# Recursively expand variables in this scope
306
- seq , var_tree = fetch_variable_tree (sock , seq , scope_ref , depth = DEPTH_LIMIT )
306
+ seq , var_tree = fetch_variable_tree (sock , seq , scope_ref , depth = depth_limit )
307
307
# Store them under the scope name (lowercased or original, your choice)
308
308
scope_dict [scope_name_lower ] = var_tree
309
309
@@ -331,6 +331,6 @@ def dap_client():
331
331
332
332
333
333
if __name__ == "__main__" :
334
- result = dap_client ()
334
+ result = dap_client (depth_limit = 2 )
335
335
print ("\n === Final Expanded Frames ===\n " )
336
336
print (json .dumps (result , indent = 2 ))
0 commit comments