|
| 1 | +# Defines prompts the SerenaInfoTool |
| 2 | +prompts: |
| 3 | + info_jet_brains_debug_repl: | |
| 4 | + Note: The debugger uses 0-based line numbers like other Serena tools (while humans typically communicate 1-based ones). |
| 5 | + You rely on the user to provide suitable run configurations for you to work with. |
| 6 | + |
| 7 | + State (objects, variables assigned) persists across calls within the same repl_key. |
| 8 | + |
| 9 | + Pre-bound variables: ``debug`` (debugger interface) |
| 10 | + |
| 11 | + Run configurations: |
| 12 | + debug.listRunConfigs() |
| 13 | + session = debug.startDebug("MyTestRun") # returns a DebugSession |
| 14 | + debug.startRun("MyApp") # non-debug run, fire-and-forget |
| 15 | + |
| 16 | + Session discovery: |
| 17 | + debug.sessions() |
| 18 | + session = debug.currentSession() |
| 19 | + session = debug.session(id) |
| 20 | + |
| 21 | + Breakpoints (project-global, set before or during debugging): |
| 22 | + debug.addBreakpoint(file, line) |
| 23 | + debug.addBreakpoint(file, line, condition) |
| 24 | + debug.addLogpoint(file, line, logExpression) |
| 25 | + debug.listBreakpoints() |
| 26 | + debug.removeBreakpointAt(file, line) |
| 27 | + |
| 28 | + Execution control (on a DebugSession, e.g. ``session``):: |
| 29 | + session.stepOver() | .stepInto() | .stepOut() |
| 30 | + session.resume() | .pause() | .stop() |
| 31 | + session.runToLine(file, line) |
| 32 | + |
| 33 | + Wait for pause (blocks until the session pauses or times out): |
| 34 | + session.waitForPause(timeoutSeconds) |
| 35 | + session.stepOverAndWait(timeoutSeconds) # step + wait in one call |
| 36 | + session.resumeAndWait(timeoutSeconds) |
| 37 | + |
| 38 | + Inspection (when paused): |
| 39 | + session.status() # location + source + variable values in one call |
| 40 | + session.variables() # overview of locals/args (values may be truncated) |
| 41 | + session.variable(name) # single variable (VariableInfo instance) |
| 42 | + session.frames() | .frame() # stack trace | current frame |
| 43 | + session.sourceContext(lines) # source around current line |
| 44 | + session.threads() |
| 45 | + |
| 46 | + VariableInfo members: name, value (String as presented by the debugger), type |
| 47 | + |
| 48 | + Evaluation & modification: |
| 49 | + session.eval("expr") # evaluate in current frame |
| 50 | + session.setVar("x", "42") # set variable via assignment |
| 51 | + |
| 52 | + Example sequence of expressions one might execute in a REPL: |
| 53 | + debug.addBreakpoint("src/main/java/Foo.java", 42) |
| 54 | + session = debug.startDebug("MyTest") |
| 55 | + session.waitForPause(30) |
| 56 | + session.status() |
| 57 | + |
| 58 | + You can pass multiple statements at once; the result of the final expression is returned: |
| 59 | + session = debug.startDebug("MyTest"); session.waitForPause(30); session.status() |
| 60 | + |
| 61 | + Control flow statements are also possible: |
| 62 | + while (session.variable("count").value.equals("0")) { session.stepOverAndWait(5) } |
| 63 | + |
| 64 | + When done, close the REPL by passing an empty expression. |
0 commit comments