Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The Three Main Pieces
_capture_frame_locals: "Take a snapshot of variables"When the code pauses at a breakpoint, you want to see what your variables look like. This function grabs all the local variables from the current point in execution and makes a safe copy. Simple things (strings, numbers, lists) are kept as-is. Anything complex gets converted to a string with
repr()so it won't cause problems when sent over the network.BreakpointController: "The traffic light"The code runs on a background thread.
A trace function (
_trace_callback) is hooked into Python viasys.settrace. This is a special Python mechanism that lets you get notified every single time a new line of code is about to run.When that line matches one of your breakpoints, the thread pauses (using
threading.Event.wait()), takes a snapshot of variables, and puts a message in a queue saying "hey, I hit a breakpoint!"The outside world reads that message, shows it to the user, and eventually calls
resume()to let the thread continue.UiPathDebugFunctionsRuntime: "The wrapper"It wraps another runtime (the "real" one that actually runs user code) and adds debugging on top. The key idea:
BreakpointController, run the inner runtime inside a traced thread, and yield breakpoint events back to the caller.How Breakpoints Are Specified
Users pass breakpoints as strings:
Notes
sys.settraceis a low-level Python feature: it literally lets you install a callback that Python calls before executing each line. It's how debuggers likepdbwork under the hood. The "call" event means "a function is being entered" (and the callback decides whether to trace inside it), while "line" means "a new line is about to execute" (where we check for breakpoints).callevent: Decides whether to trace into a function. In step mode, it enters all project files but skips third-party code.lineevent: Pauses execution on every line of every project file, captures local variables, and waits for a resume signal._is_project_file()ensures only user code is traced, preventing stepping into standard library or dependency internals.Development Package
uipath pack --nolockto get the latest dev build from this PR (requires version range).