kopia lustrzana https://github.com/micropython/micropython-lib
test_vscode: Add global variables to show vaiable tracking and hover.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>pull/1022/head
rodzic
c98b355ef4
commit
9adb886260
|
@ -2,10 +2,14 @@
|
||||||
"""Test script for VS Code debugging with MicroPython debugpy."""
|
"""Test script for VS Code debugging with MicroPython debugpy."""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.insert(0, '.')
|
sys.path.insert(0, '.')
|
||||||
|
|
||||||
import debugpy
|
import debugpy
|
||||||
|
|
||||||
|
foo = 42
|
||||||
|
bar = "Hello, MicroPython!"
|
||||||
|
|
||||||
def fibonacci(n):
|
def fibonacci(n):
|
||||||
"""Calculate fibonacci number (iterative for efficiency)."""
|
"""Calculate fibonacci number (iterative for efficiency)."""
|
||||||
if n <= 1:
|
if n <= 1:
|
||||||
|
@ -17,6 +21,7 @@ def fibonacci(n):
|
||||||
|
|
||||||
def debuggable_code():
|
def debuggable_code():
|
||||||
"""The actual code we want to debug - wrapped in a function so sys.settrace will trace it."""
|
"""The actual code we want to debug - wrapped in a function so sys.settrace will trace it."""
|
||||||
|
global foo
|
||||||
print("Starting debuggable code...")
|
print("Starting debuggable code...")
|
||||||
|
|
||||||
# Test data - set breakpoint here (using smaller numbers to avoid slow fibonacci)
|
# 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):
|
for i, num in enumerate(numbers):
|
||||||
print(f"Calculating fibonacci({num})...")
|
print(f"Calculating fibonacci({num})...")
|
||||||
result = fibonacci(num) # <-- SET BREAKPOINT HERE (line 26)
|
result = fibonacci(num) # <-- SET BREAKPOINT HERE (line 26)
|
||||||
|
foo += result # Modify foo to see if it gets traced
|
||||||
print(f"fibonacci({num}) = {result}")
|
print(f"fibonacci({num}) = {result}")
|
||||||
print(sys.implementation)
|
print(sys.implementation)
|
||||||
import machine
|
import machine
|
||||||
|
|
Ładowanie…
Reference in New Issue