frontend / features/Debugger/useDebugger / useDebugger
Function: useDebugger()
useDebugger(
clientRef):object
Defined in: features/Debugger/useDebugger.ts:31
Hook which manages debug session state: breakpoints, current line and variables snapshot.
Uses same worker client as useCodeRunner, so both hooks should be created in same component (or one should receive clientRef from another). This is important because only one debug session can be active at same time.
The hook sets debug pause handler on the client. When worker hits breakpoint, handler reads snapshot from worker filesystem and updates hook state. UI can then show current line, variables and switch to debug tab.
Parameters
clientRef
RefObject<PyodideWorkerClient | null>
Ref to worker client, usually taken from useCodeRunner.
Returns
object
isDebugging—truewhile debug session is active (including pause).isPaused—truewhen execution is stopped at breakpoint.currentLine— 1-based line number where execution is paused, ornull.variables— map of variable names to theirrepr()values at pause.breakpoints— sorted list of 1-based line numbers.toggleBreakpoint(line)— adds or removes breakpoint.startDebug(code, inputFilenames?, stdinText?)— starts debug session.debugContinue()— resumes until next breakpoint.debugStep()— moves to next line.stopDebug()— stops debug session from inside.
breakpoints
breakpoints:
number[]
currentLine
currentLine:
number|null
debugContinue
debugContinue: () =>
void
Returns
void
debugStep
debugStep: () =>
void
Returns
void
isDebugging
isDebugging:
boolean
isPaused
isPaused:
boolean
startDebug
startDebug: (
code,inputFilenames,stdinText) =>Promise<void>
Parameters
code
string
inputFilenames?
string[] = []
stdinText?
string = ''
Returns
Promise<void>
stopDebug
stopDebug: () =>
void
Returns
void
toggleBreakpoint
toggleBreakpoint: (
line) =>void
Parameters
line
number
Returns
void
variables
variables:
Record<string,string>