2015-03-20 21:11:11 +00:00
package service
import (
2016-12-22 16:53:34 +00:00
"time"
2019-01-04 18:39:25 +00:00
"github.com/go-delve/delve/service/api"
2015-03-20 21:11:11 +00:00
)
// Client represents a debugger service client. All client methods are
// synchronous.
type Client interface {
2022-03-09 17:12:42 +00:00
// ProcessPid returns the pid of the process we are debugging.
2015-07-03 20:35:22 +00:00
ProcessPid ( ) int
2022-03-09 17:12:42 +00:00
// BuildID returns the BuildID of the process' executable we are debugging.
2022-01-30 21:39:30 +00:00
BuildID ( ) string
2016-12-22 16:53:34 +00:00
// LastModified returns the time that the process' executable was modified.
LastModified ( ) time . Time
2015-03-20 21:11:11 +00:00
// Detach detaches the debugger, optionally killing the process.
Detach ( killProcess bool ) error
2022-03-09 17:12:42 +00:00
// Restart restarts program. Set true if you want to rebuild the process we are debugging.
2020-06-05 18:03:09 +00:00
Restart ( rebuild bool ) ( [ ] api . DiscardedBreakpoint , error )
2022-03-09 17:12:42 +00:00
// RestartFrom restarts program from the specified position.
2020-08-21 14:14:02 +00:00
RestartFrom ( rerecord bool , pos string , resetArgs bool , newArgs [ ] string , newRedirects [ 3 ] string , rebuild bool ) ( [ ] api . DiscardedBreakpoint , error )
2015-07-03 20:35:22 +00:00
2015-03-20 21:11:11 +00:00
// GetState returns the current debugger state.
GetState ( ) ( * api . DebuggerState , error )
2018-06-21 11:07:37 +00:00
// GetStateNonBlocking returns the current debugger state, returning immediately if the target is already running.
GetStateNonBlocking ( ) ( * api . DebuggerState , error )
2015-03-20 21:11:11 +00:00
// Continue resumes process execution.
2015-06-28 15:00:56 +00:00
Continue ( ) <- chan * api . DebuggerState
2017-05-05 22:17:52 +00:00
// Rewind resumes process execution backwards.
Rewind ( ) <- chan * api . DebuggerState
2022-03-09 17:12:42 +00:00
// DirectionCongruentContinue resumes process execution, if a reverse next, step or stepout operation is in progress it will resume execution backward.
proc,terminal: Implement reverse step, next and stepout (#1785)
* proc: move defer breakpoint code into a function
Moves the code that sets a breakpoint on the first deferred function,
used by both next and StepOut, to its function.
* proc: implement reverse step/next/stepout
When the direction of execution is reversed (on a recording) Step, Next and
StepOut will behave similarly to their forward version. However there are
some subtle interactions between their behavior, prologue skipping, deferred
calls and normal calls. Specifically:
- when stepping backwards we need to set a breakpoint on the first
instruction after each CALL instruction, once this breakpoint is reached we
need to execute a single StepInstruction operation to reverse step into the
CALL.
- to insure that the prologue is skipped reverse next needs to check if it
is on the first instruction after the prologue, and if it is behave like
reverse stepout.
- there is no reason to set breakpoints on deferred calls when reverse
nexting or reverse stepping out, they will never be hit.
- reverse step out should generally place its breakpoint on the CALL
instruction that created the current stack frame (which will be the CALL
instruction immediately preceding the instruction at the return address).
- reverse step out needs to treat panic calls and deferreturn calls
specially.
* service,terminal: implement reverse step, next, stepout
2020-03-11 22:40:41 +00:00
DirectionCongruentContinue ( ) <- chan * api . DebuggerState
2015-03-20 21:11:11 +00:00
// Next continues to the next source line, not entering function calls.
Next ( ) ( * api . DebuggerState , error )
proc,terminal: Implement reverse step, next and stepout (#1785)
* proc: move defer breakpoint code into a function
Moves the code that sets a breakpoint on the first deferred function,
used by both next and StepOut, to its function.
* proc: implement reverse step/next/stepout
When the direction of execution is reversed (on a recording) Step, Next and
StepOut will behave similarly to their forward version. However there are
some subtle interactions between their behavior, prologue skipping, deferred
calls and normal calls. Specifically:
- when stepping backwards we need to set a breakpoint on the first
instruction after each CALL instruction, once this breakpoint is reached we
need to execute a single StepInstruction operation to reverse step into the
CALL.
- to insure that the prologue is skipped reverse next needs to check if it
is on the first instruction after the prologue, and if it is behave like
reverse stepout.
- there is no reason to set breakpoints on deferred calls when reverse
nexting or reverse stepping out, they will never be hit.
- reverse step out should generally place its breakpoint on the CALL
instruction that created the current stack frame (which will be the CALL
instruction immediately preceding the instruction at the return address).
- reverse step out needs to treat panic calls and deferreturn calls
specially.
* service,terminal: implement reverse step, next, stepout
2020-03-11 22:40:41 +00:00
// ReverseNext continues backward to the previous line of source code, not entering function calls.
ReverseNext ( ) ( * api . DebuggerState , error )
2015-03-20 21:11:11 +00:00
// Step continues to the next source line, entering function calls.
Step ( ) ( * api . DebuggerState , error )
proc,terminal: Implement reverse step, next and stepout (#1785)
* proc: move defer breakpoint code into a function
Moves the code that sets a breakpoint on the first deferred function,
used by both next and StepOut, to its function.
* proc: implement reverse step/next/stepout
When the direction of execution is reversed (on a recording) Step, Next and
StepOut will behave similarly to their forward version. However there are
some subtle interactions between their behavior, prologue skipping, deferred
calls and normal calls. Specifically:
- when stepping backwards we need to set a breakpoint on the first
instruction after each CALL instruction, once this breakpoint is reached we
need to execute a single StepInstruction operation to reverse step into the
CALL.
- to insure that the prologue is skipped reverse next needs to check if it
is on the first instruction after the prologue, and if it is behave like
reverse stepout.
- there is no reason to set breakpoints on deferred calls when reverse
nexting or reverse stepping out, they will never be hit.
- reverse step out should generally place its breakpoint on the CALL
instruction that created the current stack frame (which will be the CALL
instruction immediately preceding the instruction at the return address).
- reverse step out needs to treat panic calls and deferreturn calls
specially.
* service,terminal: implement reverse step, next, stepout
2020-03-11 22:40:41 +00:00
// ReverseStep continues backward to the previous line of source code, entering function calls.
ReverseStep ( ) ( * api . DebuggerState , error )
// StepOut continues to the return address of the current function.
2016-04-14 09:58:59 +00:00
StepOut ( ) ( * api . DebuggerState , error )
2023-04-27 20:39:33 +00:00
// ReverseStepOut continues backward to the caller of the current function.
proc,terminal: Implement reverse step, next and stepout (#1785)
* proc: move defer breakpoint code into a function
Moves the code that sets a breakpoint on the first deferred function,
used by both next and StepOut, to its function.
* proc: implement reverse step/next/stepout
When the direction of execution is reversed (on a recording) Step, Next and
StepOut will behave similarly to their forward version. However there are
some subtle interactions between their behavior, prologue skipping, deferred
calls and normal calls. Specifically:
- when stepping backwards we need to set a breakpoint on the first
instruction after each CALL instruction, once this breakpoint is reached we
need to execute a single StepInstruction operation to reverse step into the
CALL.
- to insure that the prologue is skipped reverse next needs to check if it
is on the first instruction after the prologue, and if it is behave like
reverse stepout.
- there is no reason to set breakpoints on deferred calls when reverse
nexting or reverse stepping out, they will never be hit.
- reverse step out should generally place its breakpoint on the CALL
instruction that created the current stack frame (which will be the CALL
instruction immediately preceding the instruction at the return address).
- reverse step out needs to treat panic calls and deferreturn calls
specially.
* service,terminal: implement reverse step, next, stepout
2020-03-11 22:40:41 +00:00
ReverseStepOut ( ) ( * api . DebuggerState , error )
2018-05-04 17:31:45 +00:00
// Call resumes process execution while making a function call.
2022-08-16 16:31:11 +00:00
Call ( goroutineID int64 , expr string , unsafe bool ) ( * api . DebuggerState , error )
2016-04-14 09:58:59 +00:00
2022-03-09 17:12:42 +00:00
// StepInstruction will step a single cpu instruction.
2024-02-28 08:28:33 +00:00
StepInstruction ( skipCalls bool ) ( * api . DebuggerState , error )
2022-03-09 17:12:42 +00:00
// ReverseStepInstruction will reverse step a single cpu instruction.
2024-02-28 08:28:33 +00:00
ReverseStepInstruction ( skipCalls bool ) ( * api . DebuggerState , error )
2015-03-20 21:11:11 +00:00
// SwitchThread switches the current thread context.
SwitchThread ( threadID int ) ( * api . DebuggerState , error )
2015-08-28 20:06:29 +00:00
// SwitchGoroutine switches the current goroutine (and the current thread as well)
2022-08-16 16:31:11 +00:00
SwitchGoroutine ( goroutineID int64 ) ( * api . DebuggerState , error )
2015-03-20 21:11:11 +00:00
// Halt suspends the process.
Halt ( ) ( * api . DebuggerState , error )
2015-06-12 19:32:32 +00:00
// GetBreakpoint gets a breakpoint by ID.
GetBreakpoint ( id int ) ( * api . Breakpoint , error )
2016-01-24 08:16:45 +00:00
// GetBreakpointByName gets a breakpoint by name.
GetBreakpointByName ( name string ) ( * api . Breakpoint , error )
2015-06-12 19:32:32 +00:00
// CreateBreakpoint creates a new breakpoint.
CreateBreakpoint ( * api . Breakpoint ) ( * api . Breakpoint , error )
2022-09-28 18:35:07 +00:00
// CreateBreakpointWithExpr creates a new breakpoint and sets an expression to restore it after it is disabled.
2022-10-04 15:07:05 +00:00
CreateBreakpointWithExpr ( * api . Breakpoint , string , [ ] [ 2 ] string , bool ) ( * api . Breakpoint , error )
2021-05-20 17:04:02 +00:00
// CreateWatchpoint creates a new watchpoint.
CreateWatchpoint ( api . EvalScope , string , api . WatchType ) ( * api . Breakpoint , error )
2015-06-12 19:32:32 +00:00
// ListBreakpoints gets all breakpoints.
2021-08-09 17:41:25 +00:00
ListBreakpoints ( bool ) ( [ ] * api . Breakpoint , error )
2015-06-12 19:32:32 +00:00
// ClearBreakpoint deletes a breakpoint by ID.
ClearBreakpoint ( id int ) ( * api . Breakpoint , error )
2016-01-24 08:16:45 +00:00
// ClearBreakpointByName deletes a breakpoint by name
ClearBreakpointByName ( name string ) ( * api . Breakpoint , error )
2021-03-19 18:02:23 +00:00
// ToggleBreakpoint toggles on or off a breakpoint by ID.
ToggleBreakpoint ( id int ) ( * api . Breakpoint , error )
// ToggleBreakpointByName toggles on or off a breakpoint by name.
ToggleBreakpointByName ( name string ) ( * api . Breakpoint , error )
2022-03-09 17:12:42 +00:00
// AmendBreakpoint allows user to update an existing breakpoint for example to change the information
2016-01-24 08:16:45 +00:00
// retrieved when the breakpoint is hit or to change, add or remove the break condition
AmendBreakpoint ( * api . Breakpoint ) error
2022-03-09 17:12:42 +00:00
// CancelNext cancels a Next or Step call that was interrupted by a manual stop or by another breakpoint
2016-04-24 23:20:02 +00:00
CancelNext ( ) error
2015-03-20 21:11:11 +00:00
// ListThreads lists all threads.
ListThreads ( ) ( [ ] * api . Thread , error )
// GetThread gets a thread by its ID.
GetThread ( id int ) ( * api . Thread , error )
// ListPackageVariables lists all package variables in the context of the current thread.
2016-04-24 17:15:39 +00:00
ListPackageVariables ( filter string , cfg api . LoadConfig ) ( [ ] api . Variable , error )
2015-06-12 19:04:14 +00:00
// EvalVariable returns a variable in the context of the current thread.
2016-04-24 17:15:39 +00:00
EvalVariable ( scope api . EvalScope , symbol string , cfg api . LoadConfig ) ( * api . Variable , error )
2015-03-20 21:11:11 +00:00
2015-09-28 10:01:18 +00:00
// SetVariable sets the value of a variable
SetVariable ( scope api . EvalScope , symbol , value string ) error
2015-03-20 21:11:11 +00:00
// ListSources lists all source files in the process matching filter.
ListSources ( filter string ) ( [ ] string , error )
// ListFunctions lists all functions in the process matching filter.
2024-06-12 19:35:48 +00:00
ListFunctions ( filter string , tracefollow int ) ( [ ] string , error )
2016-02-22 15:08:45 +00:00
// ListTypes lists all types in the process matching filter.
ListTypes ( filter string ) ( [ ] string , error )
2023-09-18 15:59:58 +00:00
// ListPackagesBuildInfo lists all packages in the process matching filter.
ListPackagesBuildInfo ( filter string , includeFiles bool ) ( [ ] api . PackageBuildInfo , error )
2022-03-09 17:12:42 +00:00
// ListLocalVariables lists all local variables in scope.
2016-04-24 17:15:39 +00:00
ListLocalVariables ( scope api . EvalScope , cfg api . LoadConfig ) ( [ ] api . Variable , error )
2015-05-08 20:16:22 +00:00
// ListFunctionArgs lists all arguments to the current function.
2016-04-24 17:15:39 +00:00
ListFunctionArgs ( scope api . EvalScope , cfg api . LoadConfig ) ( [ ] api . Variable , error )
2020-02-24 18:47:02 +00:00
// ListThreadRegisters lists registers and their values, for the given thread.
ListThreadRegisters ( threadID int , includeFp bool ) ( api . Registers , error )
// ListScopeRegisters lists registers and their values, for the given scope.
ListScopeRegisters ( scope api . EvalScope , includeFp bool ) ( api . Registers , error )
2015-03-20 21:11:11 +00:00
// ListGoroutines lists all goroutines.
2018-11-19 14:18:10 +00:00
ListGoroutines ( start , count int ) ( [ ] * api . Goroutine , int , error )
2021-07-01 18:25:33 +00:00
// ListGoroutinesWithFilter lists goroutines matching the filters
2023-08-23 20:02:34 +00:00
ListGoroutinesWithFilter ( start , count int , filters [ ] api . ListGoroutinesFilter , group * api . GoroutineGroupingOptions , scope * api . EvalScope ) ( [ ] * api . Goroutine , [ ] api . GoroutineGroup , int , bool , error )
2015-06-17 17:11:57 +00:00
2022-03-09 17:12:42 +00:00
// Stacktrace returns stacktrace
2022-08-16 16:31:11 +00:00
Stacktrace ( goroutineID int64 , depth int , opts api . StacktraceOptions , cfg * api . LoadConfig ) ( [ ] api . Stackframe , error )
2015-07-07 14:04:03 +00:00
2022-03-09 17:12:42 +00:00
// Ancestors returns ancestor stacktraces
2022-08-16 16:31:11 +00:00
Ancestors ( goroutineID int64 , numAncestors int , depth int ) ( [ ] api . Ancestor , error )
2019-03-16 13:50:18 +00:00
2022-03-09 17:12:42 +00:00
// AttachedToExistingProcess returns whether we attached to a running process or not
2015-07-07 14:04:03 +00:00
AttachedToExistingProcess ( ) bool
2015-08-07 16:50:14 +00:00
2022-03-09 17:12:42 +00:00
// FindLocation returns concrete location information described by a location expression
2015-08-07 16:50:14 +00:00
// loc ::= <filename>:<line> | <function>[:<line>] | /<regex>/ | (+|-)<offset> | <line> | *<address>
// * <filename> can be the full path of a file or just a suffix
// * <function> ::= <package>.<receiver type>.<name> | <package>.(*<receiver type>).<name> | <receiver type>.<name> | <package>.<name> | (*<receiver type>).<name> | <name>
// * <function> must be unambiguous
// * /<regex>/ will return a location for each function matched by regex
// * +<offset> returns a location for the line that is <offset> lines after the current line
// * -<offset> returns a location for the line that is <offset> lines before the current line
// * <line> returns a location for a line in the current file
// * *<address> returns the location corresponding to the specified address
// NOTE: this function does not actually set breakpoints.
2019-10-25 16:59:18 +00:00
// If findInstruction is true FindLocation will only return locations that correspond to instructions.
2023-07-20 10:29:59 +00:00
FindLocation ( scope api . EvalScope , loc string , findInstruction bool , substitutePathRules [ ] [ 2 ] string ) ( [ ] api . Location , string , error )
2016-02-06 06:00:48 +00:00
2022-03-09 17:12:42 +00:00
// DisassembleRange disassemble code between startPC and endPC
2016-02-06 06:00:48 +00:00
DisassembleRange ( scope api . EvalScope , startPC , endPC uint64 , flavour api . AssemblyFlavour ) ( api . AsmInstructions , error )
2022-03-09 17:12:42 +00:00
// DisassemblePC disassemble code of the function containing PC
2016-02-06 06:00:48 +00:00
DisassemblePC ( scope api . EvalScope , pc uint64 , flavour api . AssemblyFlavour ) ( api . AsmInstructions , error )
2017-05-05 22:17:52 +00:00
// Recorded returns true if the target is a recording.
Recorded ( ) bool
// TraceDirectory returns the path to the trace directory for a recording.
TraceDirectory ( ) ( string , error )
// Checkpoint sets a checkpoint at the current position.
Checkpoint ( where string ) ( checkpointID int , err error )
// ListCheckpoints gets all checkpoints.
ListCheckpoints ( ) ( [ ] api . Checkpoint , error )
// ClearCheckpoint removes a checkpoint
ClearCheckpoint ( id int ) error
2018-05-11 12:51:15 +00:00
// SetReturnValuesLoadConfig sets the load configuration for return values.
SetReturnValuesLoadConfig ( * api . LoadConfig )
2018-06-21 11:07:37 +00:00
2022-03-09 17:12:42 +00:00
// IsMulticlient returns true if the headless instance is multiclient.
2018-06-21 11:07:37 +00:00
IsMulticlient ( ) bool
2019-03-20 17:32:51 +00:00
// ListDynamicLibraries returns a list of loaded dynamic libraries.
ListDynamicLibraries ( ) ( [ ] api . Image , error )
2020-02-13 17:29:21 +00:00
// ExamineMemory returns the raw memory stored at the given address.
// The amount of data to be read is specified by length which must be less than or equal to 1000.
// This function will return an error if it reads less than `length` bytes.
2020-09-11 06:21:11 +00:00
ExamineMemory ( address uint64 , length int ) ( [ ] byte , bool , error )
2020-02-13 17:29:21 +00:00
2020-03-24 16:09:28 +00:00
// StopRecording stops a recording if one is in progress.
StopRecording ( ) error
2021-01-29 21:39:33 +00:00
// CoreDumpStart starts creating a core dump to the specified file
CoreDumpStart ( dest string ) ( api . DumpState , error )
// CoreDumpWait waits for the core dump to finish, or for the specified amount of milliseconds
CoreDumpWait ( msec int ) api . DumpState
// CoreDumpCancel cancels a core dump in progress
CoreDumpCancel ( ) error
2023-04-24 21:37:31 +00:00
// ListTargets returns the list of connected targets
ListTargets ( ) ( [ ] api . Target , error )
// FollowExec enables or disables the follow exec mode. In follow exec mode
// Delve will automatically debug child processes launched by the target
// process
FollowExec ( bool , string ) error
FollowExecEnabled ( ) bool
2018-06-21 11:07:37 +00:00
// Disconnect closes the connection to the server without sending a Detach request first.
// If cont is true a continue command will be sent instead.
Disconnect ( cont bool ) error
2019-07-02 17:55:27 +00:00
*: misc improvements to config command and substitute-path rules (#3335)
A series of interconnected changes to both the terminal command
'config', DAP command 'dlv config', quality of life improvements to how
substitute-path works, and better documentation.
- Let 'config substitute-path' show the current substitute path rules
- Add a -clear command to 'config substitute-path'
- Support 'config-debug-info-directories'
- rewrite SubstitutePath to be platform independent (see below)
- document path substitution more
Regarding the rewrite of SubstitutePath: the previous version used
runtime.GOOS and filepath.IsAbs to determine which filepath separator to use
and if matching should be case insensitive. This is wrong in all situations
where the client and server run on different OSes, when examining core files
and when cross-compilation is involved.
The new version of SubstitutePath checks the rules and the input path to
determine if Windows is involved in the process, if it looks like it is it
switches to case-insensitive matching. It uses a lax version of
filepath.IsAbs to determine if a path is absolute and tries to avoid having
to select a path separator as much as possible
Fixes #2891, #2890, #2889, #3179, #3332, #3343
2023-05-02 19:23:59 +00:00
// SetDebugInfoDirectories sets directories used to search for debug symbols
SetDebugInfoDirectories ( [ ] string ) error
// GetDebugInfoDirectories returns the list of directories used to search for debug symbols
GetDebugInfoDirectories ( ) ( [ ] string , error )
2024-10-31 17:19:08 +00:00
// GuessSubstitutePath tries to guess a substitute-path configuration for the client
GuessSubstitutePath ( ) ( [ ] [ 2 ] string , error )
2019-07-02 17:55:27 +00:00
// CallAPI allows calling an arbitrary rpc method (used by starlark bindings)
CallAPI ( method string , args , reply interface { } ) error
2015-03-20 21:11:11 +00:00
}