From 9adb8862608210bb79a632c70d4d68c56c56981e Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Thu, 12 Jun 2025 17:37:23 +0200 Subject: [PATCH] test_vscode: Add global variables to show vaiable tracking and hover. Signed-off-by: Jos Verlinde --- python-ecosys/debugpy/test_vscode.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python-ecosys/debugpy/test_vscode.py b/python-ecosys/debugpy/test_vscode.py index aca063ba..2dca82d3 100644 --- a/python-ecosys/debugpy/test_vscode.py +++ b/python-ecosys/debugpy/test_vscode.py @@ -2,10 +2,14 @@ """Test script for VS Code debugging with MicroPython debugpy.""" import sys + sys.path.insert(0, '.') import debugpy +foo = 42 +bar = "Hello, MicroPython!" + def fibonacci(n): """Calculate fibonacci number (iterative for efficiency).""" if n <= 1: @@ -17,6 +21,7 @@ def fibonacci(n): def debuggable_code(): """The actual code we want to debug - wrapped in a function so sys.settrace will trace it.""" + global foo print("Starting debuggable code...") # Test data - set breakpoint here (using smaller numbers to avoid slow fibonacci) @@ -24,6 +29,7 @@ def debuggable_code(): for i, num in enumerate(numbers): print(f"Calculating fibonacci({num})...") result = fibonacci(num) # <-- SET BREAKPOINT HERE (line 26) + foo += result # Modify foo to see if it gets traced print(f"fibonacci({num}) = {result}") print(sys.implementation) import machine