github.com/neilgarb/delve@v1.9.2-nobreaks/service/api/types.go (about)

     1  package api
     2  
     3  import (
     4  	"bytes"
     5  	"errors"
     6  	"fmt"
     7  	"reflect"
     8  	"strconv"
     9  	"unicode"
    10  
    11  	"github.com/go-delve/delve/pkg/proc"
    12  )
    13  
    14  // ErrNotExecutable is an error returned when trying
    15  // to debug a non-executable file.
    16  var ErrNotExecutable = errors.New("not an executable file")
    17  
    18  // DebuggerState represents the current context of the debugger.
    19  type DebuggerState struct {
    20  	// PID of the process we are debugging.
    21  	Pid int
    22  	// Running is true if the process is running and no other information can be collected.
    23  	Running bool
    24  	// Recording is true if the process is currently being recorded and no other
    25  	// information can be collected. While the debugger is in this state
    26  	// sending a StopRecording request will halt the recording, every other
    27  	// request will block until the process has been recorded.
    28  	Recording bool
    29  	// Core dumping currently in progress.
    30  	CoreDumping bool
    31  	// CurrentThread is the currently selected debugger thread.
    32  	CurrentThread *Thread `json:"currentThread,omitempty"`
    33  	// SelectedGoroutine is the currently selected goroutine
    34  	SelectedGoroutine *Goroutine `json:"currentGoroutine,omitempty"`
    35  	// List of all the process threads
    36  	Threads []*Thread
    37  	// NextInProgress indicates that a next or step operation was interrupted by another breakpoint
    38  	// or a manual stop and is waiting to complete.
    39  	// While NextInProgress is set further requests for next or step may be rejected.
    40  	// Either execute continue until NextInProgress is false or call CancelNext
    41  	NextInProgress bool
    42  	// WatchOutOfScope contains the list of watchpoints that went out of scope
    43  	// during the last continue.
    44  	WatchOutOfScope []*Breakpoint
    45  	// Exited indicates whether the debugged process has exited.
    46  	Exited     bool `json:"exited"`
    47  	ExitStatus int  `json:"exitStatus"`
    48  	// When contains a description of the current position in a recording
    49  	When string
    50  	// Filled by RPCClient.Continue, indicates an error
    51  	Err error `json:"-"`
    52  }
    53  
    54  type TracepointResult struct {
    55  	// Addr is the address of this tracepoint.
    56  	Addr uint64 `json:"addr"`
    57  	// File is the source file for the breakpoint.
    58  	File string `json:"file"`
    59  	// Line is a line in File for the breakpoint.
    60  	Line int `json:"line"`
    61  	// FunctionName is the name of the function at the current breakpoint, and
    62  	// may not always be available.
    63  	FunctionName string `json:"functionName,omitempty"`
    64  
    65  	GoroutineID int `json:"goroutineID"`
    66  
    67  	InputParams  []Variable `json:"inputParams,omitempty"`
    68  	ReturnParams []Variable `json:"returnParams,omitempty"`
    69  }
    70  
    71  // Breakpoint addresses a set of locations at which process execution may be
    72  // suspended.
    73  type Breakpoint struct {
    74  	// ID is a unique identifier for the breakpoint.
    75  	ID int `json:"id"`
    76  	// User defined name of the breakpoint.
    77  	Name string `json:"name"`
    78  	// Addr is deprecated, use Addrs.
    79  	Addr uint64 `json:"addr"`
    80  	// Addrs is the list of addresses for this breakpoint.
    81  	Addrs []uint64 `json:"addrs"`
    82  	// File is the source file for the breakpoint.
    83  	File string `json:"file"`
    84  	// Line is a line in File for the breakpoint.
    85  	Line int `json:"line"`
    86  	// FunctionName is the name of the function at the current breakpoint, and
    87  	// may not always be available.
    88  	FunctionName string `json:"functionName,omitempty"`
    89  
    90  	// Breakpoint condition
    91  	Cond string
    92  	// Breakpoint hit count condition.
    93  	// Supported hit count conditions are "NUMBER" and "OP NUMBER".
    94  	HitCond string
    95  
    96  	// Tracepoint flag, signifying this is a tracepoint.
    97  	Tracepoint bool `json:"continue"`
    98  	// TraceReturn flag signifying this is a breakpoint set at a return
    99  	// statement in a traced function.
   100  	TraceReturn bool `json:"traceReturn"`
   101  	// retrieve goroutine information
   102  	Goroutine bool `json:"goroutine"`
   103  	// number of stack frames to retrieve
   104  	Stacktrace int `json:"stacktrace"`
   105  	// expressions to evaluate
   106  	Variables []string `json:"variables,omitempty"`
   107  	// LoadArgs requests loading function arguments when the breakpoint is hit
   108  	LoadArgs *LoadConfig
   109  	// LoadLocals requests loading function locals when the breakpoint is hit
   110  	LoadLocals *LoadConfig
   111  
   112  	// WatchExpr is the expression used to create this watchpoint
   113  	WatchExpr string
   114  	WatchType WatchType
   115  
   116  	VerboseDescr []string `json:"VerboseDescr,omitempty"`
   117  
   118  	// number of times a breakpoint has been reached in a certain goroutine
   119  	HitCount map[string]uint64 `json:"hitCount"`
   120  	// number of times a breakpoint has been reached
   121  	TotalHitCount uint64 `json:"totalHitCount"`
   122  	// Disabled flag, signifying the state of the breakpoint
   123  	Disabled bool `json:"disabled"`
   124  
   125  	UserData interface{} `json:"-"`
   126  }
   127  
   128  // ValidBreakpointName returns an error if
   129  // the name to be chosen for a breakpoint is invalid.
   130  // The name can not be just a number, and must contain a series
   131  // of letters or numbers.
   132  func ValidBreakpointName(name string) error {
   133  	if _, err := strconv.Atoi(name); err == nil {
   134  		return errors.New("breakpoint name can not be a number")
   135  	}
   136  
   137  	for _, ch := range name {
   138  		if !(unicode.IsLetter(ch) || unicode.IsDigit(ch)) {
   139  			return fmt.Errorf("invalid character in breakpoint name '%c'", ch)
   140  		}
   141  	}
   142  
   143  	return nil
   144  }
   145  
   146  // WatchType is the watchpoint type
   147  type WatchType uint8
   148  
   149  const (
   150  	WatchRead WatchType = 1 << iota
   151  	WatchWrite
   152  )
   153  
   154  // Thread is a thread within the debugged process.
   155  type Thread struct {
   156  	// ID is a unique identifier for the thread.
   157  	ID int `json:"id"`
   158  	// PC is the current program counter for the thread.
   159  	PC uint64 `json:"pc"`
   160  	// File is the file for the program counter.
   161  	File string `json:"file"`
   162  	// Line is the line number for the program counter.
   163  	Line int `json:"line"`
   164  	// Function is function information at the program counter. May be nil.
   165  	Function *Function `json:"function,omitempty"`
   166  
   167  	// ID of the goroutine running on this thread
   168  	GoroutineID int `json:"goroutineID"`
   169  
   170  	// Breakpoint this thread is stopped at
   171  	Breakpoint *Breakpoint `json:"breakPoint,omitempty"`
   172  	// Informations requested by the current breakpoint
   173  	BreakpointInfo *BreakpointInfo `json:"breakPointInfo,omitempty"`
   174  
   175  	// ReturnValues contains the return values of the function we just stepped out of
   176  	ReturnValues []Variable
   177  	// CallReturn is true if ReturnValues are the return values of an injected call.
   178  	CallReturn bool
   179  }
   180  
   181  // Location holds program location information.
   182  // In most cases a Location object will represent a physical location, with
   183  // a single PC address held in the PC field.
   184  // FindLocations however returns logical locations that can either have
   185  // multiple PC addresses each (due to inlining) or no PC address at all.
   186  type Location struct {
   187  	PC       uint64    `json:"pc"`
   188  	File     string    `json:"file"`
   189  	Line     int       `json:"line"`
   190  	Function *Function `json:"function,omitempty"`
   191  	PCs      []uint64  `json:"pcs,omitempty"`
   192  }
   193  
   194  // Stackframe describes one frame in a stack trace.
   195  type Stackframe struct {
   196  	Location
   197  	Locals    []Variable
   198  	Arguments []Variable
   199  
   200  	FrameOffset        int64
   201  	FramePointerOffset int64
   202  
   203  	Defers []Defer
   204  
   205  	Bottom bool `json:"Bottom,omitempty"` // Bottom is true if this is the bottom frame of the stack
   206  
   207  	Err string
   208  }
   209  
   210  // Defer describes a deferred function.
   211  type Defer struct {
   212  	DeferredLoc Location // deferred function
   213  	DeferLoc    Location // location of the defer statement
   214  	SP          uint64   // value of SP when the function was deferred
   215  	Unreadable  string
   216  }
   217  
   218  // Var will return the variable described by 'name' within
   219  // this stack frame.
   220  func (frame *Stackframe) Var(name string) *Variable {
   221  	for i := range frame.Locals {
   222  		if frame.Locals[i].Name == name {
   223  			return &frame.Locals[i]
   224  		}
   225  	}
   226  	for i := range frame.Arguments {
   227  		if frame.Arguments[i].Name == name {
   228  			return &frame.Arguments[i]
   229  		}
   230  	}
   231  	return nil
   232  }
   233  
   234  // Function represents thread-scoped function information.
   235  type Function struct {
   236  	// Name is the function name.
   237  	Name_  string `json:"name"`
   238  	Value  uint64 `json:"value"`
   239  	Type   byte   `json:"type"`
   240  	GoType uint64 `json:"goType"`
   241  	// Optimized is true if the function was optimized
   242  	Optimized bool `json:"optimized"`
   243  }
   244  
   245  // Name will return the function name.
   246  func (fn *Function) Name() string {
   247  	if fn == nil {
   248  		return "???"
   249  	}
   250  	return fn.Name_
   251  }
   252  
   253  // VariableFlags is the type of the Flags field of Variable.
   254  type VariableFlags uint16
   255  
   256  const (
   257  	// VariableEscaped is set for local variables that escaped to the heap
   258  	//
   259  	// The compiler performs escape analysis on local variables, the variables
   260  	// that may outlive the stack frame are allocated on the heap instead and
   261  	// only the address is recorded on the stack. These variables will be
   262  	// marked with this flag.
   263  	VariableEscaped = 1 << iota
   264  
   265  	// VariableShadowed is set for local variables that are shadowed by a
   266  	// variable with the same name in another scope
   267  	VariableShadowed
   268  
   269  	// VariableConstant means this variable is a constant value
   270  	VariableConstant
   271  
   272  	// VariableArgument means this variable is a function argument
   273  	VariableArgument
   274  
   275  	// VariableReturnArgument means this variable is a function return value
   276  	VariableReturnArgument
   277  
   278  	// VariableFakeAddress means the address of this variable is either fake
   279  	// (i.e. the variable is partially or completely stored in a CPU register
   280  	// and doesn't have a real address) or possibly no longer available (because
   281  	// the variable is the return value of a function call and allocated on a
   282  	// frame that no longer exists)
   283  	VariableFakeAddress
   284  
   285  	// VariableCPtr means the variable is a C pointer
   286  	VariableCPtr
   287  
   288  	// VariableCPURegister means this variable is a CPU register.
   289  	VariableCPURegister
   290  )
   291  
   292  // Variable describes a variable.
   293  type Variable struct {
   294  	// Name of the variable or struct member
   295  	Name string `json:"name"`
   296  	// Address of the variable or struct member
   297  	Addr uint64 `json:"addr"`
   298  	// Only the address field is filled (result of evaluating expressions like &<expr>)
   299  	OnlyAddr bool `json:"onlyAddr"`
   300  	// Go type of the variable
   301  	Type string `json:"type"`
   302  	// Type of the variable after resolving any typedefs
   303  	RealType string `json:"realType"`
   304  
   305  	Flags VariableFlags `json:"flags"`
   306  
   307  	Kind reflect.Kind `json:"kind"`
   308  
   309  	// Strings have their length capped at proc.maxArrayValues, use Len for the real length of a string
   310  	// Function variables will store the name of the function in this field
   311  	Value string `json:"value"`
   312  
   313  	// Number of elements in an array or a slice, number of keys for a map, number of struct members for a struct, length of strings
   314  	Len int64 `json:"len"`
   315  	// Cap value for slices
   316  	Cap int64 `json:"cap"`
   317  
   318  	// Array and slice elements, member fields of structs, key/value pairs of maps, value of complex numbers
   319  	// The Name field in this slice will always be the empty string except for structs (when it will be the field name) and for complex numbers (when it will be "real" and "imaginary")
   320  	// For maps each map entry will have to items in this slice, even numbered items will represent map keys and odd numbered items will represent their values
   321  	// This field's length is capped at proc.maxArrayValues for slices and arrays and 2*proc.maxArrayValues for maps, in the circumstances where the cap takes effect len(Children) != Len
   322  	// The other length cap applied to this field is related to maximum recursion depth, when the maximum recursion depth is reached this field is left empty, contrary to the previous one this cap also applies to structs (otherwise structs will always have all their member fields returned)
   323  	Children []Variable `json:"children"`
   324  
   325  	// Base address of arrays, Base address of the backing array for slices (0 for nil slices)
   326  	// Base address of the backing byte array for strings
   327  	// address of the struct backing chan and map variables
   328  	// address of the function entry point for function variables (0 for nil function pointers)
   329  	Base uint64 `json:"base"`
   330  
   331  	// Unreadable addresses will have this field set
   332  	Unreadable string `json:"unreadable"`
   333  
   334  	// LocationExpr describes the location expression of this variable's address
   335  	LocationExpr string
   336  	// DeclLine is the line number of this variable's declaration
   337  	DeclLine int64
   338  }
   339  
   340  // LoadConfig describes how to load values from target's memory
   341  type LoadConfig struct {
   342  	// FollowPointers requests pointers to be automatically dereferenced.
   343  	FollowPointers bool
   344  	// MaxVariableRecurse is how far to recurse when evaluating nested types.
   345  	MaxVariableRecurse int
   346  	// MaxStringLen is the maximum number of bytes read from a string
   347  	MaxStringLen int
   348  	// MaxArrayValues is the maximum number of elements read from an array, a slice or a map.
   349  	MaxArrayValues int
   350  	// MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields.
   351  	MaxStructFields int
   352  }
   353  
   354  // Goroutine represents the information relevant to Delve from the runtime's
   355  // internal G structure.
   356  type Goroutine struct {
   357  	// ID is a unique identifier for the goroutine.
   358  	ID int `json:"id"`
   359  	// Current location of the goroutine
   360  	CurrentLoc Location `json:"currentLoc"`
   361  	// Current location of the goroutine, excluding calls inside runtime
   362  	UserCurrentLoc Location `json:"userCurrentLoc"`
   363  	// Location of the go instruction that started this goroutine
   364  	GoStatementLoc Location `json:"goStatementLoc"`
   365  	// Location of the starting function
   366  	StartLoc Location `json:"startLoc"`
   367  	// ID of the associated thread for running goroutines
   368  	ThreadID   int    `json:"threadID"`
   369  	Status     uint64 `json:"status"`
   370  	WaitSince  int64  `json:"waitSince"`
   371  	WaitReason int64  `json:"waitReason"`
   372  	Unreadable string `json:"unreadable"`
   373  	// Goroutine's pprof labels
   374  	Labels map[string]string `json:"labels,omitempty"`
   375  }
   376  
   377  const (
   378  	GoroutineWaiting = proc.Gwaiting
   379  	GoroutineSyscall = proc.Gsyscall
   380  )
   381  
   382  // DebuggerCommand is a command which changes the debugger's execution state.
   383  type DebuggerCommand struct {
   384  	// Name is the command to run.
   385  	Name string `json:"name"`
   386  	// ThreadID is used to specify which thread to use with the SwitchThread
   387  	// command.
   388  	ThreadID int `json:"threadID,omitempty"`
   389  	// GoroutineID is used to specify which thread to use with the SwitchGoroutine
   390  	// and Call commands.
   391  	GoroutineID int `json:"goroutineID,omitempty"`
   392  	// When ReturnInfoLoadConfig is not nil it will be used to load the value
   393  	// of any return variables.
   394  	ReturnInfoLoadConfig *LoadConfig
   395  	// Expr is the expression argument for a Call command
   396  	Expr string `json:"expr,omitempty"`
   397  
   398  	// UnsafeCall disables parameter escape checking for function calls.
   399  	// Go objects can be allocated on the stack or on the heap. Heap objects
   400  	// can be used by any goroutine; stack objects can only be used by the
   401  	// goroutine that owns the stack they are allocated on and can not surivive
   402  	// the stack frame of allocation.
   403  	// The Go compiler will use escape analysis to determine whether to
   404  	// allocate an object on the stack or the heap.
   405  	// When injecting a function call Delve will check that no address of a
   406  	// stack allocated object is passed to the called function: this ensures
   407  	// the rules for stack objects will not be violated.
   408  	// If you are absolutely sure that the function you are calling will not
   409  	// violate the rules about stack objects you can disable this safety check
   410  	// by setting UnsafeCall to true.
   411  	UnsafeCall bool `json:"unsafeCall,omitempty"`
   412  }
   413  
   414  // BreakpointInfo contains informations about the current breakpoint
   415  type BreakpointInfo struct {
   416  	Stacktrace []Stackframe `json:"stacktrace,omitempty"`
   417  	Goroutine  *Goroutine   `json:"goroutine,omitempty"`
   418  	Variables  []Variable   `json:"variables,omitempty"`
   419  	Arguments  []Variable   `json:"arguments,omitempty"`
   420  	Locals     []Variable   `json:"locals,omitempty"`
   421  }
   422  
   423  // EvalScope is the scope a command should
   424  // be evaluated in. Describes the goroutine and frame number.
   425  type EvalScope struct {
   426  	GoroutineID  int
   427  	Frame        int
   428  	DeferredCall int // when DeferredCall is n > 0 this eval scope is relative to the n-th deferred call in the current frame
   429  }
   430  
   431  const (
   432  	// Continue resumes process execution.
   433  	Continue = "continue"
   434  	// Rewind resumes process execution backwards (target must be a recording).
   435  	Rewind = "rewind"
   436  	// DirectionCongruentContinue resumes process execution, if a reverse next, step or stepout operation is in progress it will resume execution backward.
   437  	DirectionCongruentContinue = "directionCongruentContinue"
   438  	// Step continues to next source line, entering function calls.
   439  	Step = "step"
   440  	// ReverseStep continues backward to the previous line of source code, entering function calls.
   441  	ReverseStep = "reverseStep"
   442  	// StepOut continues to the return address of the current function
   443  	StepOut = "stepOut"
   444  	// ReverseStepOut continues backward to the calle rof the current function.
   445  	ReverseStepOut = "reverseStepOut"
   446  	// StepInstruction continues for exactly 1 cpu instruction.
   447  	StepInstruction = "stepInstruction"
   448  	// ReverseStepInstruction reverses execution for exactly 1 cpu instruction.
   449  	ReverseStepInstruction = "reverseStepInstruction"
   450  	// Next continues to the next source line, not entering function calls.
   451  	Next = "next"
   452  	// ReverseNext continues backward to the previous line of source code, not entering function calls.
   453  	ReverseNext = "reverseNext"
   454  	// SwitchThread switches the debugger's current thread context.
   455  	SwitchThread = "switchThread"
   456  	// SwitchGoroutine switches the debugger's current thread context to the thread running the specified goroutine
   457  	SwitchGoroutine = "switchGoroutine"
   458  	// Halt suspends the process.
   459  	// The effect of Halt while the target process is stopped, or in the
   460  	// process of stopping, is operating system and timing dependent. It will
   461  	// either have no effect or cause the following resume to stop immediately.
   462  	Halt = "halt"
   463  	// Call resumes process execution injecting a function call.
   464  	Call = "call"
   465  )
   466  
   467  // AssemblyFlavour describes the output
   468  // of disassembled code.
   469  type AssemblyFlavour int
   470  
   471  const (
   472  	// GNUFlavour will disassemble using GNU assembly syntax.
   473  	GNUFlavour = AssemblyFlavour(proc.GNUFlavour)
   474  	// IntelFlavour will disassemble using Intel assembly syntax.
   475  	IntelFlavour = AssemblyFlavour(proc.IntelFlavour)
   476  	// GoFlavour will disassemble using Go assembly syntax.
   477  	GoFlavour = AssemblyFlavour(proc.GoFlavour)
   478  )
   479  
   480  // AsmInstruction represents one assembly instruction at some address
   481  type AsmInstruction struct {
   482  	// Loc is the location of this instruction
   483  	Loc Location
   484  	// Destination of CALL instructions
   485  	DestLoc *Location
   486  	// Text is the formatted representation of the instruction
   487  	Text string
   488  	// Bytes is the instruction as read from memory
   489  	Bytes []byte
   490  	// If Breakpoint is true a breakpoint is set at this instruction
   491  	Breakpoint bool
   492  	// In AtPC is true this is the instruction the current thread is stopped at
   493  	AtPC bool
   494  }
   495  
   496  // AsmInstructions is a slice of single instructions.
   497  type AsmInstructions []AsmInstruction
   498  
   499  // GetVersionIn is the argument for GetVersion.
   500  type GetVersionIn struct {
   501  }
   502  
   503  // GetVersionOut is the result of GetVersion.
   504  type GetVersionOut struct {
   505  	DelveVersion    string
   506  	APIVersion      int
   507  	Backend         string // backend currently in use
   508  	TargetGoVersion string
   509  
   510  	MinSupportedVersionOfGo string
   511  	MaxSupportedVersionOfGo string
   512  }
   513  
   514  // SetAPIVersionIn is the input for SetAPIVersion.
   515  type SetAPIVersionIn struct {
   516  	APIVersion int
   517  }
   518  
   519  // SetAPIVersionOut is the output for SetAPIVersion.
   520  type SetAPIVersionOut struct {
   521  }
   522  
   523  // Register holds information on a CPU register.
   524  type Register struct {
   525  	Name        string
   526  	Value       string
   527  	DwarfNumber int
   528  }
   529  
   530  // Registers is a list of CPU registers.
   531  type Registers []Register
   532  
   533  func (regs Registers) String() string {
   534  	maxlen := 0
   535  	for _, reg := range regs {
   536  		if n := len(reg.Name); n > maxlen {
   537  			maxlen = n
   538  		}
   539  	}
   540  
   541  	var buf bytes.Buffer
   542  	for _, reg := range regs {
   543  		fmt.Fprintf(&buf, "%*s = %s\n", maxlen, reg.Name, reg.Value)
   544  	}
   545  	return buf.String()
   546  }
   547  
   548  // DiscardedBreakpoint is a breakpoint that is not
   549  // reinstated during a restart.
   550  type DiscardedBreakpoint struct {
   551  	Breakpoint *Breakpoint
   552  	Reason     string
   553  }
   554  
   555  // Checkpoint is a point in the program that
   556  // can be returned to in certain execution modes.
   557  type Checkpoint struct {
   558  	ID    int
   559  	When  string
   560  	Where string
   561  }
   562  
   563  // Image represents a loaded shared object (go plugin or shared library)
   564  type Image struct {
   565  	Path    string
   566  	Address uint64
   567  }
   568  
   569  // Ancestor represents a goroutine ancestor
   570  type Ancestor struct {
   571  	ID    int64
   572  	Stack []Stackframe
   573  
   574  	Unreadable string
   575  }
   576  
   577  // StacktraceOptions is the type of the Opts field of StacktraceIn that
   578  // configures the stacktrace.
   579  // Tracks proc.StacktraceOptions
   580  type StacktraceOptions uint16
   581  
   582  const (
   583  	// StacktraceReadDefers requests a stacktrace decorated with deferred calls
   584  	// for each frame.
   585  	StacktraceReadDefers StacktraceOptions = 1 << iota
   586  
   587  	// StacktraceSimple requests a stacktrace where no stack switches will be
   588  	// attempted.
   589  	StacktraceSimple
   590  
   591  	// StacktraceG requests a stacktrace starting with the register
   592  	// values saved in the runtime.g structure.
   593  	StacktraceG
   594  )
   595  
   596  // PackageBuildInfo maps an import path to a directory path.
   597  type PackageBuildInfo struct {
   598  	ImportPath    string
   599  	DirectoryPath string
   600  	Files         []string
   601  }
   602  
   603  // DumpState describes the state of a core dump in progress
   604  type DumpState struct {
   605  	Dumping bool
   606  	AllDone bool
   607  
   608  	ThreadsDone, ThreadsTotal int
   609  	MemDone, MemTotal         uint64
   610  
   611  	Err string
   612  }
   613  
   614  // ListGoroutinesFilter describes a filtering condition for the
   615  // ListGoroutines API call.
   616  type ListGoroutinesFilter struct {
   617  	Kind    GoroutineField
   618  	Negated bool
   619  	Arg     string
   620  }
   621  
   622  // GoroutineField allows referring to a field of a goroutine object.
   623  type GoroutineField uint8
   624  
   625  const (
   626  	GoroutineFieldNone  GoroutineField = iota
   627  	GoroutineCurrentLoc                // the goroutine's CurrentLoc
   628  	GoroutineUserLoc                   // the goroutine's UserLoc
   629  	GoroutineGoLoc                     // the goroutine's GoStatementLoc
   630  	GoroutineStartLoc                  // the goroutine's StartLoc
   631  	GoroutineLabel                     // the goroutine's label
   632  	GoroutineRunning                   // the goroutine is running
   633  	GoroutineUser                      // the goroutine is a user goroutine
   634  )
   635  
   636  // GoroutineGroup represents a group of goroutines in the return value of
   637  // the ListGoroutines API call.
   638  type GoroutineGroup struct {
   639  	Name   string // name of this group
   640  	Offset int    // start offset in the list of goroutines of this group
   641  	Count  int    // number of goroutines that belong to this group in the list of goroutines
   642  	Total  int    // total number of goroutines that belong to this group
   643  }
   644  
   645  type GoroutineGroupingOptions struct {
   646  	GroupBy         GoroutineField
   647  	GroupByKey      string
   648  	MaxGroupMembers int
   649  	MaxGroups       int
   650  }