github.com/cnboonhan/delve@v0.0.0-20230908061759-363f2388c2fb/service/client.go (about) 1 package service 2 3 import ( 4 "time" 5 6 "github.com/go-delve/delve/service/api" 7 ) 8 9 // Client represents a debugger service client. All client methods are 10 // synchronous. 11 type Client interface { 12 // ProcessPid returns the pid of the process we are debugging. 13 ProcessPid() int 14 15 // BuildID returns the BuildID of the process' executable we are debugging. 16 BuildID() string 17 18 // LastModified returns the time that the process' executable was modified. 19 LastModified() time.Time 20 21 // Detach detaches the debugger, optionally killing the process. 22 Detach(killProcess bool) error 23 24 // Restart restarts program. Set true if you want to rebuild the process we are debugging. 25 Restart(rebuild bool) ([]api.DiscardedBreakpoint, error) 26 // RestartFrom restarts program from the specified position. 27 RestartFrom(rerecord bool, pos string, resetArgs bool, newArgs []string, newRedirects [3]string, rebuild bool) ([]api.DiscardedBreakpoint, error) 28 29 // GetState returns the current debugger state. 30 GetState() (*api.DebuggerState, error) 31 // GetStateNonBlocking returns the current debugger state, returning immediately if the target is already running. 32 GetStateNonBlocking() (*api.DebuggerState, error) 33 34 // Continue resumes process execution. 35 Continue() <-chan *api.DebuggerState 36 // Rewind resumes process execution backwards. 37 Rewind() <-chan *api.DebuggerState 38 // DirectionCongruentContinue resumes process execution, if a reverse next, step or stepout operation is in progress it will resume execution backward. 39 DirectionCongruentContinue() <-chan *api.DebuggerState 40 // Next continues to the next source line, not entering function calls. 41 Next() (*api.DebuggerState, error) 42 // ReverseNext continues backward to the previous line of source code, not entering function calls. 43 ReverseNext() (*api.DebuggerState, error) 44 // Step continues to the next source line, entering function calls. 45 Step() (*api.DebuggerState, error) 46 // ReverseStep continues backward to the previous line of source code, entering function calls. 47 ReverseStep() (*api.DebuggerState, error) 48 // StepOut continues to the return address of the current function. 49 StepOut() (*api.DebuggerState, error) 50 // ReverseStepOut continues backward to the caller of the current function. 51 ReverseStepOut() (*api.DebuggerState, error) 52 // Call resumes process execution while making a function call. 53 Call(goroutineID int64, expr string, unsafe bool) (*api.DebuggerState, error) 54 55 // StepInstruction will step a single cpu instruction. 56 StepInstruction() (*api.DebuggerState, error) 57 // ReverseStepInstruction will reverse step a single cpu instruction. 58 ReverseStepInstruction() (*api.DebuggerState, error) 59 // SwitchThread switches the current thread context. 60 SwitchThread(threadID int) (*api.DebuggerState, error) 61 // SwitchGoroutine switches the current goroutine (and the current thread as well) 62 SwitchGoroutine(goroutineID int64) (*api.DebuggerState, error) 63 // Halt suspends the process. 64 Halt() (*api.DebuggerState, error) 65 66 // GetBreakpoint gets a breakpoint by ID. 67 GetBreakpoint(id int) (*api.Breakpoint, error) 68 // GetBreakpointByName gets a breakpoint by name. 69 GetBreakpointByName(name string) (*api.Breakpoint, error) 70 // CreateBreakpoint creates a new breakpoint. 71 CreateBreakpoint(*api.Breakpoint) (*api.Breakpoint, error) 72 // CreateBreakpointWithExpr creates a new breakpoint and sets an expression to restore it after it is disabled. 73 CreateBreakpointWithExpr(*api.Breakpoint, string, [][2]string, bool) (*api.Breakpoint, error) 74 // CreateWatchpoint creates a new watchpoint. 75 CreateWatchpoint(api.EvalScope, string, api.WatchType) (*api.Breakpoint, error) 76 // ListBreakpoints gets all breakpoints. 77 ListBreakpoints(bool) ([]*api.Breakpoint, error) 78 // ClearBreakpoint deletes a breakpoint by ID. 79 ClearBreakpoint(id int) (*api.Breakpoint, error) 80 // ClearBreakpointByName deletes a breakpoint by name 81 ClearBreakpointByName(name string) (*api.Breakpoint, error) 82 // ToggleBreakpoint toggles on or off a breakpoint by ID. 83 ToggleBreakpoint(id int) (*api.Breakpoint, error) 84 // ToggleBreakpointByName toggles on or off a breakpoint by name. 85 ToggleBreakpointByName(name string) (*api.Breakpoint, error) 86 // AmendBreakpoint allows user to update an existing breakpoint for example to change the information 87 // retrieved when the breakpoint is hit or to change, add or remove the break condition 88 AmendBreakpoint(*api.Breakpoint) error 89 // CancelNext cancels a Next or Step call that was interrupted by a manual stop or by another breakpoint 90 CancelNext() error 91 92 // ListThreads lists all threads. 93 ListThreads() ([]*api.Thread, error) 94 // GetThread gets a thread by its ID. 95 GetThread(id int) (*api.Thread, error) 96 97 // ListPackageVariables lists all package variables in the context of the current thread. 98 ListPackageVariables(filter string, cfg api.LoadConfig) ([]api.Variable, error) 99 // EvalVariable returns a variable in the context of the current thread. 100 EvalVariable(scope api.EvalScope, symbol string, cfg api.LoadConfig) (*api.Variable, error) 101 102 // SetVariable sets the value of a variable 103 SetVariable(scope api.EvalScope, symbol, value string) error 104 105 // ListSources lists all source files in the process matching filter. 106 ListSources(filter string) ([]string, error) 107 // ListFunctions lists all functions in the process matching filter. 108 ListFunctions(filter string) ([]string, error) 109 // ListTypes lists all types in the process matching filter. 110 ListTypes(filter string) ([]string, error) 111 // ListLocalVariables lists all local variables in scope. 112 ListLocalVariables(scope api.EvalScope, cfg api.LoadConfig) ([]api.Variable, error) 113 // ListFunctionArgs lists all arguments to the current function. 114 ListFunctionArgs(scope api.EvalScope, cfg api.LoadConfig) ([]api.Variable, error) 115 // ListThreadRegisters lists registers and their values, for the given thread. 116 ListThreadRegisters(threadID int, includeFp bool) (api.Registers, error) 117 // ListScopeRegisters lists registers and their values, for the given scope. 118 ListScopeRegisters(scope api.EvalScope, includeFp bool) (api.Registers, error) 119 120 // ListGoroutines lists all goroutines. 121 ListGoroutines(start, count int) ([]*api.Goroutine, int, error) 122 // ListGoroutinesWithFilter lists goroutines matching the filters 123 ListGoroutinesWithFilter(start, count int, filters []api.ListGoroutinesFilter, group *api.GoroutineGroupingOptions, scope *api.EvalScope) ([]*api.Goroutine, []api.GoroutineGroup, int, bool, error) 124 125 // Stacktrace returns stacktrace 126 Stacktrace(goroutineID int64, depth int, opts api.StacktraceOptions, cfg *api.LoadConfig) ([]api.Stackframe, error) 127 128 // Ancestors returns ancestor stacktraces 129 Ancestors(goroutineID int64, numAncestors int, depth int) ([]api.Ancestor, error) 130 131 // AttachedToExistingProcess returns whether we attached to a running process or not 132 AttachedToExistingProcess() bool 133 134 // FindLocation returns concrete location information described by a location expression 135 // loc ::= <filename>:<line> | <function>[:<line>] | /<regex>/ | (+|-)<offset> | <line> | *<address> 136 // * <filename> can be the full path of a file or just a suffix 137 // * <function> ::= <package>.<receiver type>.<name> | <package>.(*<receiver type>).<name> | <receiver type>.<name> | <package>.<name> | (*<receiver type>).<name> | <name> 138 // * <function> must be unambiguous 139 // * /<regex>/ will return a location for each function matched by regex 140 // * +<offset> returns a location for the line that is <offset> lines after the current line 141 // * -<offset> returns a location for the line that is <offset> lines before the current line 142 // * <line> returns a location for a line in the current file 143 // * *<address> returns the location corresponding to the specified address 144 // NOTE: this function does not actually set breakpoints. 145 // If findInstruction is true FindLocation will only return locations that correspond to instructions. 146 FindLocation(scope api.EvalScope, loc string, findInstruction bool, substitutePathRules [][2]string) ([]api.Location, string, error) 147 148 // DisassembleRange disassemble code between startPC and endPC 149 DisassembleRange(scope api.EvalScope, startPC, endPC uint64, flavour api.AssemblyFlavour) (api.AsmInstructions, error) 150 // DisassemblePC disassemble code of the function containing PC 151 DisassemblePC(scope api.EvalScope, pc uint64, flavour api.AssemblyFlavour) (api.AsmInstructions, error) 152 153 // Recorded returns true if the target is a recording. 154 Recorded() bool 155 // TraceDirectory returns the path to the trace directory for a recording. 156 TraceDirectory() (string, error) 157 // Checkpoint sets a checkpoint at the current position. 158 Checkpoint(where string) (checkpointID int, err error) 159 // ListCheckpoints gets all checkpoints. 160 ListCheckpoints() ([]api.Checkpoint, error) 161 // ClearCheckpoint removes a checkpoint 162 ClearCheckpoint(id int) error 163 164 // SetReturnValuesLoadConfig sets the load configuration for return values. 165 SetReturnValuesLoadConfig(*api.LoadConfig) 166 167 // IsMulticlient returns true if the headless instance is multiclient. 168 IsMulticlient() bool 169 170 // ListDynamicLibraries returns a list of loaded dynamic libraries. 171 ListDynamicLibraries() ([]api.Image, error) 172 173 // ExamineMemory returns the raw memory stored at the given address. 174 // The amount of data to be read is specified by length which must be less than or equal to 1000. 175 // This function will return an error if it reads less than `length` bytes. 176 ExamineMemory(address uint64, length int) ([]byte, bool, error) 177 178 // StopRecording stops a recording if one is in progress. 179 StopRecording() error 180 181 // CoreDumpStart starts creating a core dump to the specified file 182 CoreDumpStart(dest string) (api.DumpState, error) 183 // CoreDumpWait waits for the core dump to finish, or for the specified amount of milliseconds 184 CoreDumpWait(msec int) api.DumpState 185 // CoreDumpCancel cancels a core dump in progress 186 CoreDumpCancel() error 187 188 // ListTargets returns the list of connected targets 189 ListTargets() ([]api.Target, error) 190 // FollowExec enables or disables the follow exec mode. In follow exec mode 191 // Delve will automatically debug child processes launched by the target 192 // process 193 FollowExec(bool, string) error 194 FollowExecEnabled() bool 195 196 // Disconnect closes the connection to the server without sending a Detach request first. 197 // If cont is true a continue command will be sent instead. 198 Disconnect(cont bool) error 199 200 // SetDebugInfoDirectories sets directories used to search for debug symbols 201 SetDebugInfoDirectories([]string) error 202 203 // GetDebugInfoDirectories returns the list of directories used to search for debug symbols 204 GetDebugInfoDirectories() ([]string, error) 205 206 // CallAPI allows calling an arbitrary rpc method (used by starlark bindings) 207 CallAPI(method string, args, reply interface{}) error 208 }