github.com/cnboonhan/delve@v0.0.0-20230908061759-363f2388c2fb/pkg/terminal/starbind/starlark_mapping.go (about)

     1  // DO NOT EDIT: auto-generated using _scripts/gen-starlark-bindings.go
     2  
     3  package starbind
     4  
     5  import (
     6  	"fmt"
     7  	"github.com/go-delve/delve/service/api"
     8  	"github.com/go-delve/delve/service/rpc2"
     9  	"go.starlark.net/starlark"
    10  )
    11  
    12  func (env *Env) starlarkPredeclare() (starlark.StringDict, map[string]string) {
    13  	r := starlark.StringDict{}
    14  	doc := make(map[string]string)
    15  
    16  	r["amend_breakpoint"] = starlark.NewBuiltin("amend_breakpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
    17  		if err := isCancelled(thread); err != nil {
    18  			return starlark.None, decorateError(thread, err)
    19  		}
    20  		var rpcArgs rpc2.AmendBreakpointIn
    21  		var rpcRet rpc2.AmendBreakpointOut
    22  		if len(args) > 0 && args[0] != starlark.None {
    23  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Breakpoint, "Breakpoint")
    24  			if err != nil {
    25  				return starlark.None, decorateError(thread, err)
    26  			}
    27  		}
    28  		for _, kv := range kwargs {
    29  			var err error
    30  			switch kv[0].(starlark.String) {
    31  			case "Breakpoint":
    32  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Breakpoint, "Breakpoint")
    33  			default:
    34  				err = fmt.Errorf("unknown argument %q", kv[0])
    35  			}
    36  			if err != nil {
    37  				return starlark.None, decorateError(thread, err)
    38  			}
    39  		}
    40  		err := env.ctx.Client().CallAPI("AmendBreakpoint", &rpcArgs, &rpcRet)
    41  		if err != nil {
    42  			return starlark.None, err
    43  		}
    44  		return env.interfaceToStarlarkValue(rpcRet), nil
    45  	})
    46  	doc["amend_breakpoint"] = "builtin amend_breakpoint(Breakpoint)\n\namend_breakpoint allows user to update an existing breakpoint\nfor example to change the information retrieved when the\nbreakpoint is hit or to change, add or remove the break condition.\n\narg.Breakpoint.ID must be a valid breakpoint ID"
    47  	r["ancestors"] = starlark.NewBuiltin("ancestors", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
    48  		if err := isCancelled(thread); err != nil {
    49  			return starlark.None, decorateError(thread, err)
    50  		}
    51  		var rpcArgs rpc2.AncestorsIn
    52  		var rpcRet rpc2.AncestorsOut
    53  		if len(args) > 0 && args[0] != starlark.None {
    54  			err := unmarshalStarlarkValue(args[0], &rpcArgs.GoroutineID, "GoroutineID")
    55  			if err != nil {
    56  				return starlark.None, decorateError(thread, err)
    57  			}
    58  		}
    59  		if len(args) > 1 && args[1] != starlark.None {
    60  			err := unmarshalStarlarkValue(args[1], &rpcArgs.NumAncestors, "NumAncestors")
    61  			if err != nil {
    62  				return starlark.None, decorateError(thread, err)
    63  			}
    64  		}
    65  		if len(args) > 2 && args[2] != starlark.None {
    66  			err := unmarshalStarlarkValue(args[2], &rpcArgs.Depth, "Depth")
    67  			if err != nil {
    68  				return starlark.None, decorateError(thread, err)
    69  			}
    70  		}
    71  		for _, kv := range kwargs {
    72  			var err error
    73  			switch kv[0].(starlark.String) {
    74  			case "GoroutineID":
    75  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.GoroutineID, "GoroutineID")
    76  			case "NumAncestors":
    77  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.NumAncestors, "NumAncestors")
    78  			case "Depth":
    79  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Depth, "Depth")
    80  			default:
    81  				err = fmt.Errorf("unknown argument %q", kv[0])
    82  			}
    83  			if err != nil {
    84  				return starlark.None, decorateError(thread, err)
    85  			}
    86  		}
    87  		err := env.ctx.Client().CallAPI("Ancestors", &rpcArgs, &rpcRet)
    88  		if err != nil {
    89  			return starlark.None, err
    90  		}
    91  		return env.interfaceToStarlarkValue(rpcRet), nil
    92  	})
    93  	doc["ancestors"] = "builtin ancestors(GoroutineID, NumAncestors, Depth)\n\nancestors returns the stacktraces for the ancestors of a goroutine."
    94  	r["attached_to_existing_process"] = starlark.NewBuiltin("attached_to_existing_process", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
    95  		if err := isCancelled(thread); err != nil {
    96  			return starlark.None, decorateError(thread, err)
    97  		}
    98  		var rpcArgs rpc2.AttachedToExistingProcessIn
    99  		var rpcRet rpc2.AttachedToExistingProcessOut
   100  		err := env.ctx.Client().CallAPI("AttachedToExistingProcess", &rpcArgs, &rpcRet)
   101  		if err != nil {
   102  			return starlark.None, err
   103  		}
   104  		return env.interfaceToStarlarkValue(rpcRet), nil
   105  	})
   106  	doc["attached_to_existing_process"] = "builtin attached_to_existing_process()\n\nattached_to_existing_process returns whether we attached to a running process or not"
   107  	r["build_id"] = starlark.NewBuiltin("build_id", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   108  		if err := isCancelled(thread); err != nil {
   109  			return starlark.None, decorateError(thread, err)
   110  		}
   111  		var rpcArgs rpc2.BuildIDIn
   112  		var rpcRet rpc2.BuildIDOut
   113  		err := env.ctx.Client().CallAPI("BuildID", &rpcArgs, &rpcRet)
   114  		if err != nil {
   115  			return starlark.None, err
   116  		}
   117  		return env.interfaceToStarlarkValue(rpcRet), nil
   118  	})
   119  	doc["build_id"] = "builtin build_id()"
   120  	r["cancel_next"] = starlark.NewBuiltin("cancel_next", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   121  		if err := isCancelled(thread); err != nil {
   122  			return starlark.None, decorateError(thread, err)
   123  		}
   124  		var rpcArgs rpc2.CancelNextIn
   125  		var rpcRet rpc2.CancelNextOut
   126  		err := env.ctx.Client().CallAPI("CancelNext", &rpcArgs, &rpcRet)
   127  		if err != nil {
   128  			return starlark.None, err
   129  		}
   130  		return env.interfaceToStarlarkValue(rpcRet), nil
   131  	})
   132  	doc["cancel_next"] = "builtin cancel_next()"
   133  	r["checkpoint"] = starlark.NewBuiltin("checkpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   134  		if err := isCancelled(thread); err != nil {
   135  			return starlark.None, decorateError(thread, err)
   136  		}
   137  		var rpcArgs rpc2.CheckpointIn
   138  		var rpcRet rpc2.CheckpointOut
   139  		if len(args) > 0 && args[0] != starlark.None {
   140  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Where, "Where")
   141  			if err != nil {
   142  				return starlark.None, decorateError(thread, err)
   143  			}
   144  		}
   145  		for _, kv := range kwargs {
   146  			var err error
   147  			switch kv[0].(starlark.String) {
   148  			case "Where":
   149  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Where, "Where")
   150  			default:
   151  				err = fmt.Errorf("unknown argument %q", kv[0])
   152  			}
   153  			if err != nil {
   154  				return starlark.None, decorateError(thread, err)
   155  			}
   156  		}
   157  		err := env.ctx.Client().CallAPI("Checkpoint", &rpcArgs, &rpcRet)
   158  		if err != nil {
   159  			return starlark.None, err
   160  		}
   161  		return env.interfaceToStarlarkValue(rpcRet), nil
   162  	})
   163  	doc["checkpoint"] = "builtin checkpoint(Where)"
   164  	r["clear_breakpoint"] = starlark.NewBuiltin("clear_breakpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   165  		if err := isCancelled(thread); err != nil {
   166  			return starlark.None, decorateError(thread, err)
   167  		}
   168  		var rpcArgs rpc2.ClearBreakpointIn
   169  		var rpcRet rpc2.ClearBreakpointOut
   170  		if len(args) > 0 && args[0] != starlark.None {
   171  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Id, "Id")
   172  			if err != nil {
   173  				return starlark.None, decorateError(thread, err)
   174  			}
   175  		}
   176  		if len(args) > 1 && args[1] != starlark.None {
   177  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Name, "Name")
   178  			if err != nil {
   179  				return starlark.None, decorateError(thread, err)
   180  			}
   181  		}
   182  		for _, kv := range kwargs {
   183  			var err error
   184  			switch kv[0].(starlark.String) {
   185  			case "Id":
   186  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Id, "Id")
   187  			case "Name":
   188  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Name, "Name")
   189  			default:
   190  				err = fmt.Errorf("unknown argument %q", kv[0])
   191  			}
   192  			if err != nil {
   193  				return starlark.None, decorateError(thread, err)
   194  			}
   195  		}
   196  		err := env.ctx.Client().CallAPI("ClearBreakpoint", &rpcArgs, &rpcRet)
   197  		if err != nil {
   198  			return starlark.None, err
   199  		}
   200  		return env.interfaceToStarlarkValue(rpcRet), nil
   201  	})
   202  	doc["clear_breakpoint"] = "builtin clear_breakpoint(Id, Name)\n\nclear_breakpoint deletes a breakpoint by Name (if Name is not an\nempty string) or by ID."
   203  	r["clear_checkpoint"] = starlark.NewBuiltin("clear_checkpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   204  		if err := isCancelled(thread); err != nil {
   205  			return starlark.None, decorateError(thread, err)
   206  		}
   207  		var rpcArgs rpc2.ClearCheckpointIn
   208  		var rpcRet rpc2.ClearCheckpointOut
   209  		if len(args) > 0 && args[0] != starlark.None {
   210  			err := unmarshalStarlarkValue(args[0], &rpcArgs.ID, "ID")
   211  			if err != nil {
   212  				return starlark.None, decorateError(thread, err)
   213  			}
   214  		}
   215  		for _, kv := range kwargs {
   216  			var err error
   217  			switch kv[0].(starlark.String) {
   218  			case "ID":
   219  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.ID, "ID")
   220  			default:
   221  				err = fmt.Errorf("unknown argument %q", kv[0])
   222  			}
   223  			if err != nil {
   224  				return starlark.None, decorateError(thread, err)
   225  			}
   226  		}
   227  		err := env.ctx.Client().CallAPI("ClearCheckpoint", &rpcArgs, &rpcRet)
   228  		if err != nil {
   229  			return starlark.None, err
   230  		}
   231  		return env.interfaceToStarlarkValue(rpcRet), nil
   232  	})
   233  	doc["clear_checkpoint"] = "builtin clear_checkpoint(ID)"
   234  	r["raw_command"] = starlark.NewBuiltin("raw_command", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   235  		if err := isCancelled(thread); err != nil {
   236  			return starlark.None, decorateError(thread, err)
   237  		}
   238  		var rpcArgs api.DebuggerCommand
   239  		var rpcRet rpc2.CommandOut
   240  		if len(args) > 0 && args[0] != starlark.None {
   241  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Name, "Name")
   242  			if err != nil {
   243  				return starlark.None, decorateError(thread, err)
   244  			}
   245  		}
   246  		if len(args) > 1 && args[1] != starlark.None {
   247  			err := unmarshalStarlarkValue(args[1], &rpcArgs.ThreadID, "ThreadID")
   248  			if err != nil {
   249  				return starlark.None, decorateError(thread, err)
   250  			}
   251  		}
   252  		if len(args) > 2 && args[2] != starlark.None {
   253  			err := unmarshalStarlarkValue(args[2], &rpcArgs.GoroutineID, "GoroutineID")
   254  			if err != nil {
   255  				return starlark.None, decorateError(thread, err)
   256  			}
   257  		}
   258  		if len(args) > 3 && args[3] != starlark.None {
   259  			err := unmarshalStarlarkValue(args[3], &rpcArgs.ReturnInfoLoadConfig, "ReturnInfoLoadConfig")
   260  			if err != nil {
   261  				return starlark.None, decorateError(thread, err)
   262  			}
   263  		} else {
   264  			cfg := env.ctx.LoadConfig()
   265  			rpcArgs.ReturnInfoLoadConfig = &cfg
   266  		}
   267  		if len(args) > 4 && args[4] != starlark.None {
   268  			err := unmarshalStarlarkValue(args[4], &rpcArgs.Expr, "Expr")
   269  			if err != nil {
   270  				return starlark.None, decorateError(thread, err)
   271  			}
   272  		}
   273  		if len(args) > 5 && args[5] != starlark.None {
   274  			err := unmarshalStarlarkValue(args[5], &rpcArgs.UnsafeCall, "UnsafeCall")
   275  			if err != nil {
   276  				return starlark.None, decorateError(thread, err)
   277  			}
   278  		}
   279  		for _, kv := range kwargs {
   280  			var err error
   281  			switch kv[0].(starlark.String) {
   282  			case "Name":
   283  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Name, "Name")
   284  			case "ThreadID":
   285  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.ThreadID, "ThreadID")
   286  			case "GoroutineID":
   287  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.GoroutineID, "GoroutineID")
   288  			case "ReturnInfoLoadConfig":
   289  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.ReturnInfoLoadConfig, "ReturnInfoLoadConfig")
   290  			case "Expr":
   291  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Expr, "Expr")
   292  			case "UnsafeCall":
   293  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.UnsafeCall, "UnsafeCall")
   294  			default:
   295  				err = fmt.Errorf("unknown argument %q", kv[0])
   296  			}
   297  			if err != nil {
   298  				return starlark.None, decorateError(thread, err)
   299  			}
   300  		}
   301  		err := env.ctx.Client().CallAPI("Command", &rpcArgs, &rpcRet)
   302  		if err != nil {
   303  			return starlark.None, err
   304  		}
   305  		return env.interfaceToStarlarkValue(rpcRet), nil
   306  	})
   307  	doc["raw_command"] = "builtin raw_command(Name, ThreadID, GoroutineID, ReturnInfoLoadConfig, Expr, UnsafeCall)\n\nraw_command interrupts, continues and steps through the program."
   308  	r["create_breakpoint"] = starlark.NewBuiltin("create_breakpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   309  		if err := isCancelled(thread); err != nil {
   310  			return starlark.None, decorateError(thread, err)
   311  		}
   312  		var rpcArgs rpc2.CreateBreakpointIn
   313  		var rpcRet rpc2.CreateBreakpointOut
   314  		if len(args) > 0 && args[0] != starlark.None {
   315  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Breakpoint, "Breakpoint")
   316  			if err != nil {
   317  				return starlark.None, decorateError(thread, err)
   318  			}
   319  		}
   320  		if len(args) > 1 && args[1] != starlark.None {
   321  			err := unmarshalStarlarkValue(args[1], &rpcArgs.LocExpr, "LocExpr")
   322  			if err != nil {
   323  				return starlark.None, decorateError(thread, err)
   324  			}
   325  		}
   326  		if len(args) > 2 && args[2] != starlark.None {
   327  			err := unmarshalStarlarkValue(args[2], &rpcArgs.SubstitutePathRules, "SubstitutePathRules")
   328  			if err != nil {
   329  				return starlark.None, decorateError(thread, err)
   330  			}
   331  		}
   332  		if len(args) > 3 && args[3] != starlark.None {
   333  			err := unmarshalStarlarkValue(args[3], &rpcArgs.Suspended, "Suspended")
   334  			if err != nil {
   335  				return starlark.None, decorateError(thread, err)
   336  			}
   337  		}
   338  		for _, kv := range kwargs {
   339  			var err error
   340  			switch kv[0].(starlark.String) {
   341  			case "Breakpoint":
   342  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Breakpoint, "Breakpoint")
   343  			case "LocExpr":
   344  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.LocExpr, "LocExpr")
   345  			case "SubstitutePathRules":
   346  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.SubstitutePathRules, "SubstitutePathRules")
   347  			case "Suspended":
   348  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Suspended, "Suspended")
   349  			default:
   350  				err = fmt.Errorf("unknown argument %q", kv[0])
   351  			}
   352  			if err != nil {
   353  				return starlark.None, decorateError(thread, err)
   354  			}
   355  		}
   356  		err := env.ctx.Client().CallAPI("CreateBreakpoint", &rpcArgs, &rpcRet)
   357  		if err != nil {
   358  			return starlark.None, err
   359  		}
   360  		return env.interfaceToStarlarkValue(rpcRet), nil
   361  	})
   362  	doc["create_breakpoint"] = "builtin create_breakpoint(Breakpoint, LocExpr, SubstitutePathRules, Suspended)\n\ncreate_breakpoint creates a new breakpoint. The client is expected to populate `CreateBreakpointIn`\nwith an `api.Breakpoint` struct describing where to set the breakpoint. For more information on\nhow to properly request a breakpoint via the `api.Breakpoint` struct see the documentation for\n`debugger.CreateBreakpoint` here: https://pkg.go.dev/github.com/go-delve/delve/service/debugger#Debugger.CreateBreakpoint."
   363  	r["create_ebpf_tracepoint"] = starlark.NewBuiltin("create_ebpf_tracepoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   364  		if err := isCancelled(thread); err != nil {
   365  			return starlark.None, decorateError(thread, err)
   366  		}
   367  		var rpcArgs rpc2.CreateEBPFTracepointIn
   368  		var rpcRet rpc2.CreateEBPFTracepointOut
   369  		if len(args) > 0 && args[0] != starlark.None {
   370  			err := unmarshalStarlarkValue(args[0], &rpcArgs.FunctionName, "FunctionName")
   371  			if err != nil {
   372  				return starlark.None, decorateError(thread, err)
   373  			}
   374  		}
   375  		for _, kv := range kwargs {
   376  			var err error
   377  			switch kv[0].(starlark.String) {
   378  			case "FunctionName":
   379  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.FunctionName, "FunctionName")
   380  			default:
   381  				err = fmt.Errorf("unknown argument %q", kv[0])
   382  			}
   383  			if err != nil {
   384  				return starlark.None, decorateError(thread, err)
   385  			}
   386  		}
   387  		err := env.ctx.Client().CallAPI("CreateEBPFTracepoint", &rpcArgs, &rpcRet)
   388  		if err != nil {
   389  			return starlark.None, err
   390  		}
   391  		return env.interfaceToStarlarkValue(rpcRet), nil
   392  	})
   393  	doc["create_ebpf_tracepoint"] = "builtin create_ebpf_tracepoint(FunctionName)"
   394  	r["create_watchpoint"] = starlark.NewBuiltin("create_watchpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   395  		if err := isCancelled(thread); err != nil {
   396  			return starlark.None, decorateError(thread, err)
   397  		}
   398  		var rpcArgs rpc2.CreateWatchpointIn
   399  		var rpcRet rpc2.CreateWatchpointOut
   400  		if len(args) > 0 && args[0] != starlark.None {
   401  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Scope, "Scope")
   402  			if err != nil {
   403  				return starlark.None, decorateError(thread, err)
   404  			}
   405  		} else {
   406  			rpcArgs.Scope = env.ctx.Scope()
   407  		}
   408  		if len(args) > 1 && args[1] != starlark.None {
   409  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Expr, "Expr")
   410  			if err != nil {
   411  				return starlark.None, decorateError(thread, err)
   412  			}
   413  		}
   414  		if len(args) > 2 && args[2] != starlark.None {
   415  			err := unmarshalStarlarkValue(args[2], &rpcArgs.Type, "Type")
   416  			if err != nil {
   417  				return starlark.None, decorateError(thread, err)
   418  			}
   419  		}
   420  		for _, kv := range kwargs {
   421  			var err error
   422  			switch kv[0].(starlark.String) {
   423  			case "Scope":
   424  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope")
   425  			case "Expr":
   426  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Expr, "Expr")
   427  			case "Type":
   428  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Type, "Type")
   429  			default:
   430  				err = fmt.Errorf("unknown argument %q", kv[0])
   431  			}
   432  			if err != nil {
   433  				return starlark.None, decorateError(thread, err)
   434  			}
   435  		}
   436  		err := env.ctx.Client().CallAPI("CreateWatchpoint", &rpcArgs, &rpcRet)
   437  		if err != nil {
   438  			return starlark.None, err
   439  		}
   440  		return env.interfaceToStarlarkValue(rpcRet), nil
   441  	})
   442  	doc["create_watchpoint"] = "builtin create_watchpoint(Scope, Expr, Type)"
   443  	r["debug_info_directories"] = starlark.NewBuiltin("debug_info_directories", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   444  		if err := isCancelled(thread); err != nil {
   445  			return starlark.None, decorateError(thread, err)
   446  		}
   447  		var rpcArgs rpc2.DebugInfoDirectoriesIn
   448  		var rpcRet rpc2.DebugInfoDirectoriesOut
   449  		if len(args) > 0 && args[0] != starlark.None {
   450  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Set, "Set")
   451  			if err != nil {
   452  				return starlark.None, decorateError(thread, err)
   453  			}
   454  		}
   455  		if len(args) > 1 && args[1] != starlark.None {
   456  			err := unmarshalStarlarkValue(args[1], &rpcArgs.List, "List")
   457  			if err != nil {
   458  				return starlark.None, decorateError(thread, err)
   459  			}
   460  		}
   461  		for _, kv := range kwargs {
   462  			var err error
   463  			switch kv[0].(starlark.String) {
   464  			case "Set":
   465  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Set, "Set")
   466  			case "List":
   467  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.List, "List")
   468  			default:
   469  				err = fmt.Errorf("unknown argument %q", kv[0])
   470  			}
   471  			if err != nil {
   472  				return starlark.None, decorateError(thread, err)
   473  			}
   474  		}
   475  		err := env.ctx.Client().CallAPI("DebugInfoDirectories", &rpcArgs, &rpcRet)
   476  		if err != nil {
   477  			return starlark.None, err
   478  		}
   479  		return env.interfaceToStarlarkValue(rpcRet), nil
   480  	})
   481  	doc["debug_info_directories"] = "builtin debug_info_directories(Set, List)"
   482  	r["detach"] = starlark.NewBuiltin("detach", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   483  		if err := isCancelled(thread); err != nil {
   484  			return starlark.None, decorateError(thread, err)
   485  		}
   486  		var rpcArgs rpc2.DetachIn
   487  		var rpcRet rpc2.DetachOut
   488  		if len(args) > 0 && args[0] != starlark.None {
   489  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Kill, "Kill")
   490  			if err != nil {
   491  				return starlark.None, decorateError(thread, err)
   492  			}
   493  		}
   494  		for _, kv := range kwargs {
   495  			var err error
   496  			switch kv[0].(starlark.String) {
   497  			case "Kill":
   498  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Kill, "Kill")
   499  			default:
   500  				err = fmt.Errorf("unknown argument %q", kv[0])
   501  			}
   502  			if err != nil {
   503  				return starlark.None, decorateError(thread, err)
   504  			}
   505  		}
   506  		err := env.ctx.Client().CallAPI("Detach", &rpcArgs, &rpcRet)
   507  		if err != nil {
   508  			return starlark.None, err
   509  		}
   510  		return env.interfaceToStarlarkValue(rpcRet), nil
   511  	})
   512  	doc["detach"] = "builtin detach(Kill)\n\ndetach detaches the debugger, optionally killing the process."
   513  	r["disassemble"] = starlark.NewBuiltin("disassemble", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   514  		if err := isCancelled(thread); err != nil {
   515  			return starlark.None, decorateError(thread, err)
   516  		}
   517  		var rpcArgs rpc2.DisassembleIn
   518  		var rpcRet rpc2.DisassembleOut
   519  		if len(args) > 0 && args[0] != starlark.None {
   520  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Scope, "Scope")
   521  			if err != nil {
   522  				return starlark.None, decorateError(thread, err)
   523  			}
   524  		} else {
   525  			rpcArgs.Scope = env.ctx.Scope()
   526  		}
   527  		if len(args) > 1 && args[1] != starlark.None {
   528  			err := unmarshalStarlarkValue(args[1], &rpcArgs.StartPC, "StartPC")
   529  			if err != nil {
   530  				return starlark.None, decorateError(thread, err)
   531  			}
   532  		}
   533  		if len(args) > 2 && args[2] != starlark.None {
   534  			err := unmarshalStarlarkValue(args[2], &rpcArgs.EndPC, "EndPC")
   535  			if err != nil {
   536  				return starlark.None, decorateError(thread, err)
   537  			}
   538  		}
   539  		if len(args) > 3 && args[3] != starlark.None {
   540  			err := unmarshalStarlarkValue(args[3], &rpcArgs.Flavour, "Flavour")
   541  			if err != nil {
   542  				return starlark.None, decorateError(thread, err)
   543  			}
   544  		}
   545  		for _, kv := range kwargs {
   546  			var err error
   547  			switch kv[0].(starlark.String) {
   548  			case "Scope":
   549  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope")
   550  			case "StartPC":
   551  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.StartPC, "StartPC")
   552  			case "EndPC":
   553  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.EndPC, "EndPC")
   554  			case "Flavour":
   555  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Flavour, "Flavour")
   556  			default:
   557  				err = fmt.Errorf("unknown argument %q", kv[0])
   558  			}
   559  			if err != nil {
   560  				return starlark.None, decorateError(thread, err)
   561  			}
   562  		}
   563  		err := env.ctx.Client().CallAPI("Disassemble", &rpcArgs, &rpcRet)
   564  		if err != nil {
   565  			return starlark.None, err
   566  		}
   567  		return env.interfaceToStarlarkValue(rpcRet), nil
   568  	})
   569  	doc["disassemble"] = "builtin disassemble(Scope, StartPC, EndPC, Flavour)\n\ndisassemble code.\n\nIf both StartPC and EndPC are non-zero the specified range will be disassembled, otherwise the function containing StartPC will be disassembled.\n\nScope is used to mark the instruction the specified goroutine is stopped at.\n\nDisassemble will also try to calculate the destination address of an absolute indirect CALL if it happens to be the instruction the selected goroutine is stopped at."
   570  	r["dump_cancel"] = starlark.NewBuiltin("dump_cancel", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   571  		if err := isCancelled(thread); err != nil {
   572  			return starlark.None, decorateError(thread, err)
   573  		}
   574  		var rpcArgs rpc2.DumpCancelIn
   575  		var rpcRet rpc2.DumpCancelOut
   576  		err := env.ctx.Client().CallAPI("DumpCancel", &rpcArgs, &rpcRet)
   577  		if err != nil {
   578  			return starlark.None, err
   579  		}
   580  		return env.interfaceToStarlarkValue(rpcRet), nil
   581  	})
   582  	doc["dump_cancel"] = "builtin dump_cancel()\n\ndump_cancel cancels the core dump."
   583  	r["dump_start"] = starlark.NewBuiltin("dump_start", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   584  		if err := isCancelled(thread); err != nil {
   585  			return starlark.None, decorateError(thread, err)
   586  		}
   587  		var rpcArgs rpc2.DumpStartIn
   588  		var rpcRet rpc2.DumpStartOut
   589  		if len(args) > 0 && args[0] != starlark.None {
   590  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Destination, "Destination")
   591  			if err != nil {
   592  				return starlark.None, decorateError(thread, err)
   593  			}
   594  		}
   595  		for _, kv := range kwargs {
   596  			var err error
   597  			switch kv[0].(starlark.String) {
   598  			case "Destination":
   599  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Destination, "Destination")
   600  			default:
   601  				err = fmt.Errorf("unknown argument %q", kv[0])
   602  			}
   603  			if err != nil {
   604  				return starlark.None, decorateError(thread, err)
   605  			}
   606  		}
   607  		err := env.ctx.Client().CallAPI("DumpStart", &rpcArgs, &rpcRet)
   608  		if err != nil {
   609  			return starlark.None, err
   610  		}
   611  		return env.interfaceToStarlarkValue(rpcRet), nil
   612  	})
   613  	doc["dump_start"] = "builtin dump_start(Destination)\n\ndump_start starts a core dump to arg.Destination."
   614  	r["dump_wait"] = starlark.NewBuiltin("dump_wait", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   615  		if err := isCancelled(thread); err != nil {
   616  			return starlark.None, decorateError(thread, err)
   617  		}
   618  		var rpcArgs rpc2.DumpWaitIn
   619  		var rpcRet rpc2.DumpWaitOut
   620  		if len(args) > 0 && args[0] != starlark.None {
   621  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Wait, "Wait")
   622  			if err != nil {
   623  				return starlark.None, decorateError(thread, err)
   624  			}
   625  		}
   626  		for _, kv := range kwargs {
   627  			var err error
   628  			switch kv[0].(starlark.String) {
   629  			case "Wait":
   630  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Wait, "Wait")
   631  			default:
   632  				err = fmt.Errorf("unknown argument %q", kv[0])
   633  			}
   634  			if err != nil {
   635  				return starlark.None, decorateError(thread, err)
   636  			}
   637  		}
   638  		err := env.ctx.Client().CallAPI("DumpWait", &rpcArgs, &rpcRet)
   639  		if err != nil {
   640  			return starlark.None, err
   641  		}
   642  		return env.interfaceToStarlarkValue(rpcRet), nil
   643  	})
   644  	doc["dump_wait"] = "builtin dump_wait(Wait)\n\ndump_wait waits for the core dump to finish or for arg.Wait milliseconds.\nWait == 0 means return immediately.\nReturns the core dump status"
   645  	r["eval"] = starlark.NewBuiltin("eval", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   646  		if err := isCancelled(thread); err != nil {
   647  			return starlark.None, decorateError(thread, err)
   648  		}
   649  		var rpcArgs rpc2.EvalIn
   650  		var rpcRet rpc2.EvalOut
   651  		if len(args) > 0 && args[0] != starlark.None {
   652  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Scope, "Scope")
   653  			if err != nil {
   654  				return starlark.None, decorateError(thread, err)
   655  			}
   656  		} else {
   657  			rpcArgs.Scope = env.ctx.Scope()
   658  		}
   659  		if len(args) > 1 && args[1] != starlark.None {
   660  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Expr, "Expr")
   661  			if err != nil {
   662  				return starlark.None, decorateError(thread, err)
   663  			}
   664  		}
   665  		if len(args) > 2 && args[2] != starlark.None {
   666  			err := unmarshalStarlarkValue(args[2], &rpcArgs.Cfg, "Cfg")
   667  			if err != nil {
   668  				return starlark.None, decorateError(thread, err)
   669  			}
   670  		} else {
   671  			cfg := env.ctx.LoadConfig()
   672  			rpcArgs.Cfg = &cfg
   673  		}
   674  		for _, kv := range kwargs {
   675  			var err error
   676  			switch kv[0].(starlark.String) {
   677  			case "Scope":
   678  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope")
   679  			case "Expr":
   680  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Expr, "Expr")
   681  			case "Cfg":
   682  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Cfg, "Cfg")
   683  			default:
   684  				err = fmt.Errorf("unknown argument %q", kv[0])
   685  			}
   686  			if err != nil {
   687  				return starlark.None, decorateError(thread, err)
   688  			}
   689  		}
   690  		err := env.ctx.Client().CallAPI("Eval", &rpcArgs, &rpcRet)
   691  		if err != nil {
   692  			return starlark.None, err
   693  		}
   694  		return env.interfaceToStarlarkValue(rpcRet), nil
   695  	})
   696  	doc["eval"] = "builtin eval(Scope, Expr, Cfg)\n\neval returns a variable in the specified context.\n\nSee https://github.com/go-delve/delve/blob/master/Documentation/cli/expr.md\nfor a description of acceptable values of arg.Expr."
   697  	r["examine_memory"] = starlark.NewBuiltin("examine_memory", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   698  		if err := isCancelled(thread); err != nil {
   699  			return starlark.None, decorateError(thread, err)
   700  		}
   701  		var rpcArgs rpc2.ExamineMemoryIn
   702  		var rpcRet rpc2.ExaminedMemoryOut
   703  		if len(args) > 0 && args[0] != starlark.None {
   704  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Address, "Address")
   705  			if err != nil {
   706  				return starlark.None, decorateError(thread, err)
   707  			}
   708  		}
   709  		if len(args) > 1 && args[1] != starlark.None {
   710  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Length, "Length")
   711  			if err != nil {
   712  				return starlark.None, decorateError(thread, err)
   713  			}
   714  		}
   715  		for _, kv := range kwargs {
   716  			var err error
   717  			switch kv[0].(starlark.String) {
   718  			case "Address":
   719  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Address, "Address")
   720  			case "Length":
   721  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Length, "Length")
   722  			default:
   723  				err = fmt.Errorf("unknown argument %q", kv[0])
   724  			}
   725  			if err != nil {
   726  				return starlark.None, decorateError(thread, err)
   727  			}
   728  		}
   729  		err := env.ctx.Client().CallAPI("ExamineMemory", &rpcArgs, &rpcRet)
   730  		if err != nil {
   731  			return starlark.None, err
   732  		}
   733  		return env.interfaceToStarlarkValue(rpcRet), nil
   734  	})
   735  	doc["examine_memory"] = "builtin examine_memory(Address, Length)"
   736  	r["find_location"] = starlark.NewBuiltin("find_location", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   737  		if err := isCancelled(thread); err != nil {
   738  			return starlark.None, decorateError(thread, err)
   739  		}
   740  		var rpcArgs rpc2.FindLocationIn
   741  		var rpcRet rpc2.FindLocationOut
   742  		if len(args) > 0 && args[0] != starlark.None {
   743  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Scope, "Scope")
   744  			if err != nil {
   745  				return starlark.None, decorateError(thread, err)
   746  			}
   747  		} else {
   748  			rpcArgs.Scope = env.ctx.Scope()
   749  		}
   750  		if len(args) > 1 && args[1] != starlark.None {
   751  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Loc, "Loc")
   752  			if err != nil {
   753  				return starlark.None, decorateError(thread, err)
   754  			}
   755  		}
   756  		if len(args) > 2 && args[2] != starlark.None {
   757  			err := unmarshalStarlarkValue(args[2], &rpcArgs.IncludeNonExecutableLines, "IncludeNonExecutableLines")
   758  			if err != nil {
   759  				return starlark.None, decorateError(thread, err)
   760  			}
   761  		}
   762  		if len(args) > 3 && args[3] != starlark.None {
   763  			err := unmarshalStarlarkValue(args[3], &rpcArgs.SubstitutePathRules, "SubstitutePathRules")
   764  			if err != nil {
   765  				return starlark.None, decorateError(thread, err)
   766  			}
   767  		}
   768  		for _, kv := range kwargs {
   769  			var err error
   770  			switch kv[0].(starlark.String) {
   771  			case "Scope":
   772  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope")
   773  			case "Loc":
   774  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Loc, "Loc")
   775  			case "IncludeNonExecutableLines":
   776  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.IncludeNonExecutableLines, "IncludeNonExecutableLines")
   777  			case "SubstitutePathRules":
   778  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.SubstitutePathRules, "SubstitutePathRules")
   779  			default:
   780  				err = fmt.Errorf("unknown argument %q", kv[0])
   781  			}
   782  			if err != nil {
   783  				return starlark.None, decorateError(thread, err)
   784  			}
   785  		}
   786  		err := env.ctx.Client().CallAPI("FindLocation", &rpcArgs, &rpcRet)
   787  		if err != nil {
   788  			return starlark.None, err
   789  		}
   790  		return env.interfaceToStarlarkValue(rpcRet), nil
   791  	})
   792  	doc["find_location"] = "builtin find_location(Scope, Loc, IncludeNonExecutableLines, SubstitutePathRules)\n\nfind_location returns concrete location information described by a location expression.\n\n\tloc ::= <filename>:<line> | <function>[:<line>] | /<regex>/ | (+|-)<offset> | <line> | *<address>\n\t* <filename> can be the full path of a file or just a suffix\n\t* <function> ::= <package>.<receiver type>.<name> | <package>.(*<receiver type>).<name> | <receiver type>.<name> | <package>.<name> | (*<receiver type>).<name> | <name>\n\t  <function> must be unambiguous\n\t* /<regex>/ will return a location for each function matched by regex\n\t* +<offset> returns a location for the line that is <offset> lines after the current line\n\t* -<offset> returns a location for the line that is <offset> lines before the current line\n\t* <line> returns a location for a line in the current file\n\t* *<address> returns the location corresponding to the specified address\n\nNOTE: this function does not actually set breakpoints."
   793  	r["follow_exec"] = starlark.NewBuiltin("follow_exec", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   794  		if err := isCancelled(thread); err != nil {
   795  			return starlark.None, decorateError(thread, err)
   796  		}
   797  		var rpcArgs rpc2.FollowExecIn
   798  		var rpcRet rpc2.FollowExecOut
   799  		if len(args) > 0 && args[0] != starlark.None {
   800  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Enable, "Enable")
   801  			if err != nil {
   802  				return starlark.None, decorateError(thread, err)
   803  			}
   804  		}
   805  		if len(args) > 1 && args[1] != starlark.None {
   806  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Regex, "Regex")
   807  			if err != nil {
   808  				return starlark.None, decorateError(thread, err)
   809  			}
   810  		}
   811  		for _, kv := range kwargs {
   812  			var err error
   813  			switch kv[0].(starlark.String) {
   814  			case "Enable":
   815  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Enable, "Enable")
   816  			case "Regex":
   817  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Regex, "Regex")
   818  			default:
   819  				err = fmt.Errorf("unknown argument %q", kv[0])
   820  			}
   821  			if err != nil {
   822  				return starlark.None, decorateError(thread, err)
   823  			}
   824  		}
   825  		err := env.ctx.Client().CallAPI("FollowExec", &rpcArgs, &rpcRet)
   826  		if err != nil {
   827  			return starlark.None, err
   828  		}
   829  		return env.interfaceToStarlarkValue(rpcRet), nil
   830  	})
   831  	doc["follow_exec"] = "builtin follow_exec(Enable, Regex)\n\nfollow_exec enables or disables follow exec mode."
   832  	r["follow_exec_enabled"] = starlark.NewBuiltin("follow_exec_enabled", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   833  		if err := isCancelled(thread); err != nil {
   834  			return starlark.None, decorateError(thread, err)
   835  		}
   836  		var rpcArgs rpc2.FollowExecEnabledIn
   837  		var rpcRet rpc2.FollowExecEnabledOut
   838  		err := env.ctx.Client().CallAPI("FollowExecEnabled", &rpcArgs, &rpcRet)
   839  		if err != nil {
   840  			return starlark.None, err
   841  		}
   842  		return env.interfaceToStarlarkValue(rpcRet), nil
   843  	})
   844  	doc["follow_exec_enabled"] = "builtin follow_exec_enabled()\n\nfollow_exec_enabled returns true if follow exec mode is enabled."
   845  	r["function_return_locations"] = starlark.NewBuiltin("function_return_locations", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   846  		if err := isCancelled(thread); err != nil {
   847  			return starlark.None, decorateError(thread, err)
   848  		}
   849  		var rpcArgs rpc2.FunctionReturnLocationsIn
   850  		var rpcRet rpc2.FunctionReturnLocationsOut
   851  		if len(args) > 0 && args[0] != starlark.None {
   852  			err := unmarshalStarlarkValue(args[0], &rpcArgs.FnName, "FnName")
   853  			if err != nil {
   854  				return starlark.None, decorateError(thread, err)
   855  			}
   856  		}
   857  		for _, kv := range kwargs {
   858  			var err error
   859  			switch kv[0].(starlark.String) {
   860  			case "FnName":
   861  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.FnName, "FnName")
   862  			default:
   863  				err = fmt.Errorf("unknown argument %q", kv[0])
   864  			}
   865  			if err != nil {
   866  				return starlark.None, decorateError(thread, err)
   867  			}
   868  		}
   869  		err := env.ctx.Client().CallAPI("FunctionReturnLocations", &rpcArgs, &rpcRet)
   870  		if err != nil {
   871  			return starlark.None, err
   872  		}
   873  		return env.interfaceToStarlarkValue(rpcRet), nil
   874  	})
   875  	doc["function_return_locations"] = "builtin function_return_locations(FnName)\n\nfunction_return_locations is the implements the client call of the same name. Look at client documentation for more information."
   876  	r["get_breakpoint"] = starlark.NewBuiltin("get_breakpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   877  		if err := isCancelled(thread); err != nil {
   878  			return starlark.None, decorateError(thread, err)
   879  		}
   880  		var rpcArgs rpc2.GetBreakpointIn
   881  		var rpcRet rpc2.GetBreakpointOut
   882  		if len(args) > 0 && args[0] != starlark.None {
   883  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Id, "Id")
   884  			if err != nil {
   885  				return starlark.None, decorateError(thread, err)
   886  			}
   887  		}
   888  		if len(args) > 1 && args[1] != starlark.None {
   889  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Name, "Name")
   890  			if err != nil {
   891  				return starlark.None, decorateError(thread, err)
   892  			}
   893  		}
   894  		for _, kv := range kwargs {
   895  			var err error
   896  			switch kv[0].(starlark.String) {
   897  			case "Id":
   898  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Id, "Id")
   899  			case "Name":
   900  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Name, "Name")
   901  			default:
   902  				err = fmt.Errorf("unknown argument %q", kv[0])
   903  			}
   904  			if err != nil {
   905  				return starlark.None, decorateError(thread, err)
   906  			}
   907  		}
   908  		err := env.ctx.Client().CallAPI("GetBreakpoint", &rpcArgs, &rpcRet)
   909  		if err != nil {
   910  			return starlark.None, err
   911  		}
   912  		return env.interfaceToStarlarkValue(rpcRet), nil
   913  	})
   914  	doc["get_breakpoint"] = "builtin get_breakpoint(Id, Name)\n\nget_breakpoint gets a breakpoint by Name (if Name is not an empty string) or by ID."
   915  	r["get_buffered_tracepoints"] = starlark.NewBuiltin("get_buffered_tracepoints", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   916  		if err := isCancelled(thread); err != nil {
   917  			return starlark.None, decorateError(thread, err)
   918  		}
   919  		var rpcArgs rpc2.GetBufferedTracepointsIn
   920  		var rpcRet rpc2.GetBufferedTracepointsOut
   921  		err := env.ctx.Client().CallAPI("GetBufferedTracepoints", &rpcArgs, &rpcRet)
   922  		if err != nil {
   923  			return starlark.None, err
   924  		}
   925  		return env.interfaceToStarlarkValue(rpcRet), nil
   926  	})
   927  	doc["get_buffered_tracepoints"] = "builtin get_buffered_tracepoints()"
   928  	r["get_thread"] = starlark.NewBuiltin("get_thread", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   929  		if err := isCancelled(thread); err != nil {
   930  			return starlark.None, decorateError(thread, err)
   931  		}
   932  		var rpcArgs rpc2.GetThreadIn
   933  		var rpcRet rpc2.GetThreadOut
   934  		if len(args) > 0 && args[0] != starlark.None {
   935  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Id, "Id")
   936  			if err != nil {
   937  				return starlark.None, decorateError(thread, err)
   938  			}
   939  		}
   940  		for _, kv := range kwargs {
   941  			var err error
   942  			switch kv[0].(starlark.String) {
   943  			case "Id":
   944  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Id, "Id")
   945  			default:
   946  				err = fmt.Errorf("unknown argument %q", kv[0])
   947  			}
   948  			if err != nil {
   949  				return starlark.None, decorateError(thread, err)
   950  			}
   951  		}
   952  		err := env.ctx.Client().CallAPI("GetThread", &rpcArgs, &rpcRet)
   953  		if err != nil {
   954  			return starlark.None, err
   955  		}
   956  		return env.interfaceToStarlarkValue(rpcRet), nil
   957  	})
   958  	doc["get_thread"] = "builtin get_thread(Id)\n\nget_thread gets a thread by its ID."
   959  	r["is_multiclient"] = starlark.NewBuiltin("is_multiclient", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   960  		if err := isCancelled(thread); err != nil {
   961  			return starlark.None, decorateError(thread, err)
   962  		}
   963  		var rpcArgs rpc2.IsMulticlientIn
   964  		var rpcRet rpc2.IsMulticlientOut
   965  		err := env.ctx.Client().CallAPI("IsMulticlient", &rpcArgs, &rpcRet)
   966  		if err != nil {
   967  			return starlark.None, err
   968  		}
   969  		return env.interfaceToStarlarkValue(rpcRet), nil
   970  	})
   971  	doc["is_multiclient"] = "builtin is_multiclient()"
   972  	r["last_modified"] = starlark.NewBuiltin("last_modified", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   973  		if err := isCancelled(thread); err != nil {
   974  			return starlark.None, decorateError(thread, err)
   975  		}
   976  		var rpcArgs rpc2.LastModifiedIn
   977  		var rpcRet rpc2.LastModifiedOut
   978  		err := env.ctx.Client().CallAPI("LastModified", &rpcArgs, &rpcRet)
   979  		if err != nil {
   980  			return starlark.None, err
   981  		}
   982  		return env.interfaceToStarlarkValue(rpcRet), nil
   983  	})
   984  	doc["last_modified"] = "builtin last_modified()"
   985  	r["breakpoints"] = starlark.NewBuiltin("breakpoints", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
   986  		if err := isCancelled(thread); err != nil {
   987  			return starlark.None, decorateError(thread, err)
   988  		}
   989  		var rpcArgs rpc2.ListBreakpointsIn
   990  		var rpcRet rpc2.ListBreakpointsOut
   991  		if len(args) > 0 && args[0] != starlark.None {
   992  			err := unmarshalStarlarkValue(args[0], &rpcArgs.All, "All")
   993  			if err != nil {
   994  				return starlark.None, decorateError(thread, err)
   995  			}
   996  		}
   997  		for _, kv := range kwargs {
   998  			var err error
   999  			switch kv[0].(starlark.String) {
  1000  			case "All":
  1001  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.All, "All")
  1002  			default:
  1003  				err = fmt.Errorf("unknown argument %q", kv[0])
  1004  			}
  1005  			if err != nil {
  1006  				return starlark.None, decorateError(thread, err)
  1007  			}
  1008  		}
  1009  		err := env.ctx.Client().CallAPI("ListBreakpoints", &rpcArgs, &rpcRet)
  1010  		if err != nil {
  1011  			return starlark.None, err
  1012  		}
  1013  		return env.interfaceToStarlarkValue(rpcRet), nil
  1014  	})
  1015  	doc["breakpoints"] = "builtin breakpoints(All)\n\nbreakpoints gets all breakpoints."
  1016  	r["checkpoints"] = starlark.NewBuiltin("checkpoints", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1017  		if err := isCancelled(thread); err != nil {
  1018  			return starlark.None, decorateError(thread, err)
  1019  		}
  1020  		var rpcArgs rpc2.ListCheckpointsIn
  1021  		var rpcRet rpc2.ListCheckpointsOut
  1022  		err := env.ctx.Client().CallAPI("ListCheckpoints", &rpcArgs, &rpcRet)
  1023  		if err != nil {
  1024  			return starlark.None, err
  1025  		}
  1026  		return env.interfaceToStarlarkValue(rpcRet), nil
  1027  	})
  1028  	doc["checkpoints"] = "builtin checkpoints()"
  1029  	r["dynamic_libraries"] = starlark.NewBuiltin("dynamic_libraries", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1030  		if err := isCancelled(thread); err != nil {
  1031  			return starlark.None, decorateError(thread, err)
  1032  		}
  1033  		var rpcArgs rpc2.ListDynamicLibrariesIn
  1034  		var rpcRet rpc2.ListDynamicLibrariesOut
  1035  		err := env.ctx.Client().CallAPI("ListDynamicLibraries", &rpcArgs, &rpcRet)
  1036  		if err != nil {
  1037  			return starlark.None, err
  1038  		}
  1039  		return env.interfaceToStarlarkValue(rpcRet), nil
  1040  	})
  1041  	doc["dynamic_libraries"] = "builtin dynamic_libraries()"
  1042  	r["function_args"] = starlark.NewBuiltin("function_args", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1043  		if err := isCancelled(thread); err != nil {
  1044  			return starlark.None, decorateError(thread, err)
  1045  		}
  1046  		var rpcArgs rpc2.ListFunctionArgsIn
  1047  		var rpcRet rpc2.ListFunctionArgsOut
  1048  		if len(args) > 0 && args[0] != starlark.None {
  1049  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Scope, "Scope")
  1050  			if err != nil {
  1051  				return starlark.None, decorateError(thread, err)
  1052  			}
  1053  		} else {
  1054  			rpcArgs.Scope = env.ctx.Scope()
  1055  		}
  1056  		if len(args) > 1 && args[1] != starlark.None {
  1057  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Cfg, "Cfg")
  1058  			if err != nil {
  1059  				return starlark.None, decorateError(thread, err)
  1060  			}
  1061  		} else {
  1062  			rpcArgs.Cfg = env.ctx.LoadConfig()
  1063  		}
  1064  		for _, kv := range kwargs {
  1065  			var err error
  1066  			switch kv[0].(starlark.String) {
  1067  			case "Scope":
  1068  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope")
  1069  			case "Cfg":
  1070  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Cfg, "Cfg")
  1071  			default:
  1072  				err = fmt.Errorf("unknown argument %q", kv[0])
  1073  			}
  1074  			if err != nil {
  1075  				return starlark.None, decorateError(thread, err)
  1076  			}
  1077  		}
  1078  		err := env.ctx.Client().CallAPI("ListFunctionArgs", &rpcArgs, &rpcRet)
  1079  		if err != nil {
  1080  			return starlark.None, err
  1081  		}
  1082  		return env.interfaceToStarlarkValue(rpcRet), nil
  1083  	})
  1084  	doc["function_args"] = "builtin function_args(Scope, Cfg)\n\nfunction_args lists all arguments to the current function"
  1085  	r["functions"] = starlark.NewBuiltin("functions", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1086  		if err := isCancelled(thread); err != nil {
  1087  			return starlark.None, decorateError(thread, err)
  1088  		}
  1089  		var rpcArgs rpc2.ListFunctionsIn
  1090  		var rpcRet rpc2.ListFunctionsOut
  1091  		if len(args) > 0 && args[0] != starlark.None {
  1092  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Filter, "Filter")
  1093  			if err != nil {
  1094  				return starlark.None, decorateError(thread, err)
  1095  			}
  1096  		}
  1097  		for _, kv := range kwargs {
  1098  			var err error
  1099  			switch kv[0].(starlark.String) {
  1100  			case "Filter":
  1101  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Filter, "Filter")
  1102  			default:
  1103  				err = fmt.Errorf("unknown argument %q", kv[0])
  1104  			}
  1105  			if err != nil {
  1106  				return starlark.None, decorateError(thread, err)
  1107  			}
  1108  		}
  1109  		err := env.ctx.Client().CallAPI("ListFunctions", &rpcArgs, &rpcRet)
  1110  		if err != nil {
  1111  			return starlark.None, err
  1112  		}
  1113  		return env.interfaceToStarlarkValue(rpcRet), nil
  1114  	})
  1115  	doc["functions"] = "builtin functions(Filter)\n\nfunctions lists all functions in the process matching filter."
  1116  	r["goroutines"] = starlark.NewBuiltin("goroutines", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1117  		if err := isCancelled(thread); err != nil {
  1118  			return starlark.None, decorateError(thread, err)
  1119  		}
  1120  		var rpcArgs rpc2.ListGoroutinesIn
  1121  		var rpcRet rpc2.ListGoroutinesOut
  1122  		if len(args) > 0 && args[0] != starlark.None {
  1123  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Start, "Start")
  1124  			if err != nil {
  1125  				return starlark.None, decorateError(thread, err)
  1126  			}
  1127  		}
  1128  		if len(args) > 1 && args[1] != starlark.None {
  1129  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Count, "Count")
  1130  			if err != nil {
  1131  				return starlark.None, decorateError(thread, err)
  1132  			}
  1133  		}
  1134  		if len(args) > 2 && args[2] != starlark.None {
  1135  			err := unmarshalStarlarkValue(args[2], &rpcArgs.Filters, "Filters")
  1136  			if err != nil {
  1137  				return starlark.None, decorateError(thread, err)
  1138  			}
  1139  		}
  1140  		if len(args) > 3 && args[3] != starlark.None {
  1141  			err := unmarshalStarlarkValue(args[3], &rpcArgs.GoroutineGroupingOptions, "GoroutineGroupingOptions")
  1142  			if err != nil {
  1143  				return starlark.None, decorateError(thread, err)
  1144  			}
  1145  		}
  1146  		if len(args) > 4 && args[4] != starlark.None {
  1147  			err := unmarshalStarlarkValue(args[4], &rpcArgs.EvalScope, "EvalScope")
  1148  			if err != nil {
  1149  				return starlark.None, decorateError(thread, err)
  1150  			}
  1151  		} else {
  1152  			scope := env.ctx.Scope()
  1153  			rpcArgs.EvalScope = &scope
  1154  		}
  1155  		for _, kv := range kwargs {
  1156  			var err error
  1157  			switch kv[0].(starlark.String) {
  1158  			case "Start":
  1159  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Start, "Start")
  1160  			case "Count":
  1161  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Count, "Count")
  1162  			case "Filters":
  1163  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Filters, "Filters")
  1164  			case "GoroutineGroupingOptions":
  1165  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.GoroutineGroupingOptions, "GoroutineGroupingOptions")
  1166  			case "EvalScope":
  1167  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.EvalScope, "EvalScope")
  1168  			default:
  1169  				err = fmt.Errorf("unknown argument %q", kv[0])
  1170  			}
  1171  			if err != nil {
  1172  				return starlark.None, decorateError(thread, err)
  1173  			}
  1174  		}
  1175  		err := env.ctx.Client().CallAPI("ListGoroutines", &rpcArgs, &rpcRet)
  1176  		if err != nil {
  1177  			return starlark.None, err
  1178  		}
  1179  		return env.interfaceToStarlarkValue(rpcRet), nil
  1180  	})
  1181  	doc["goroutines"] = "builtin goroutines(Start, Count, Filters, GoroutineGroupingOptions, EvalScope)\n\ngoroutines lists all goroutines.\nIf Count is specified ListGoroutines will return at the first Count\ngoroutines and an index in Nextg, that can be passed as the Start\nparameter, to get more goroutines from ListGoroutines.\nPassing a value of Start that wasn't returned by ListGoroutines will skip\nan undefined number of goroutines.\n\nIf arg.Filters are specified the list of returned goroutines is filtered\napplying the specified filters.\nFor example:\n\n\tListGoroutinesFilter{ Kind: ListGoroutinesFilterUserLoc, Negated: false, Arg: \"afile.go\" }\n\nwill only return goroutines whose UserLoc contains \"afile.go\" as a substring.\nMore specifically a goroutine matches a location filter if the specified\nlocation, formatted like this:\n\n\tfilename:lineno in function\n\ncontains Arg[0] as a substring.\n\nFilters can also be applied to goroutine labels:\n\n\tListGoroutineFilter{ Kind: ListGoroutinesFilterLabel, Negated: false, Arg: \"key=value\" }\n\nthis filter will only return goroutines that have a key=value label.\n\nIf arg.GroupBy is not GoroutineFieldNone then the goroutines will\nbe grouped with the specified criterion.\nIf the value of arg.GroupBy is GoroutineLabel goroutines will\nbe grouped by the value of the label with key GroupByKey.\nFor each group a maximum of MaxGroupMembers example goroutines are\nreturned, as well as the total number of goroutines in the group."
  1182  	r["local_vars"] = starlark.NewBuiltin("local_vars", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1183  		if err := isCancelled(thread); err != nil {
  1184  			return starlark.None, decorateError(thread, err)
  1185  		}
  1186  		var rpcArgs rpc2.ListLocalVarsIn
  1187  		var rpcRet rpc2.ListLocalVarsOut
  1188  		if len(args) > 0 && args[0] != starlark.None {
  1189  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Scope, "Scope")
  1190  			if err != nil {
  1191  				return starlark.None, decorateError(thread, err)
  1192  			}
  1193  		} else {
  1194  			rpcArgs.Scope = env.ctx.Scope()
  1195  		}
  1196  		if len(args) > 1 && args[1] != starlark.None {
  1197  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Cfg, "Cfg")
  1198  			if err != nil {
  1199  				return starlark.None, decorateError(thread, err)
  1200  			}
  1201  		} else {
  1202  			rpcArgs.Cfg = env.ctx.LoadConfig()
  1203  		}
  1204  		for _, kv := range kwargs {
  1205  			var err error
  1206  			switch kv[0].(starlark.String) {
  1207  			case "Scope":
  1208  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope")
  1209  			case "Cfg":
  1210  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Cfg, "Cfg")
  1211  			default:
  1212  				err = fmt.Errorf("unknown argument %q", kv[0])
  1213  			}
  1214  			if err != nil {
  1215  				return starlark.None, decorateError(thread, err)
  1216  			}
  1217  		}
  1218  		err := env.ctx.Client().CallAPI("ListLocalVars", &rpcArgs, &rpcRet)
  1219  		if err != nil {
  1220  			return starlark.None, err
  1221  		}
  1222  		return env.interfaceToStarlarkValue(rpcRet), nil
  1223  	})
  1224  	doc["local_vars"] = "builtin local_vars(Scope, Cfg)\n\nlocal_vars lists all local variables in scope."
  1225  	r["package_vars"] = starlark.NewBuiltin("package_vars", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1226  		if err := isCancelled(thread); err != nil {
  1227  			return starlark.None, decorateError(thread, err)
  1228  		}
  1229  		var rpcArgs rpc2.ListPackageVarsIn
  1230  		var rpcRet rpc2.ListPackageVarsOut
  1231  		if len(args) > 0 && args[0] != starlark.None {
  1232  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Filter, "Filter")
  1233  			if err != nil {
  1234  				return starlark.None, decorateError(thread, err)
  1235  			}
  1236  		}
  1237  		if len(args) > 1 && args[1] != starlark.None {
  1238  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Cfg, "Cfg")
  1239  			if err != nil {
  1240  				return starlark.None, decorateError(thread, err)
  1241  			}
  1242  		} else {
  1243  			rpcArgs.Cfg = env.ctx.LoadConfig()
  1244  		}
  1245  		for _, kv := range kwargs {
  1246  			var err error
  1247  			switch kv[0].(starlark.String) {
  1248  			case "Filter":
  1249  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Filter, "Filter")
  1250  			case "Cfg":
  1251  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Cfg, "Cfg")
  1252  			default:
  1253  				err = fmt.Errorf("unknown argument %q", kv[0])
  1254  			}
  1255  			if err != nil {
  1256  				return starlark.None, decorateError(thread, err)
  1257  			}
  1258  		}
  1259  		err := env.ctx.Client().CallAPI("ListPackageVars", &rpcArgs, &rpcRet)
  1260  		if err != nil {
  1261  			return starlark.None, err
  1262  		}
  1263  		return env.interfaceToStarlarkValue(rpcRet), nil
  1264  	})
  1265  	doc["package_vars"] = "builtin package_vars(Filter, Cfg)\n\npackage_vars lists all package variables in the context of the current thread."
  1266  	r["packages_build_info"] = starlark.NewBuiltin("packages_build_info", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1267  		if err := isCancelled(thread); err != nil {
  1268  			return starlark.None, decorateError(thread, err)
  1269  		}
  1270  		var rpcArgs rpc2.ListPackagesBuildInfoIn
  1271  		var rpcRet rpc2.ListPackagesBuildInfoOut
  1272  		if len(args) > 0 && args[0] != starlark.None {
  1273  			err := unmarshalStarlarkValue(args[0], &rpcArgs.IncludeFiles, "IncludeFiles")
  1274  			if err != nil {
  1275  				return starlark.None, decorateError(thread, err)
  1276  			}
  1277  		}
  1278  		for _, kv := range kwargs {
  1279  			var err error
  1280  			switch kv[0].(starlark.String) {
  1281  			case "IncludeFiles":
  1282  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.IncludeFiles, "IncludeFiles")
  1283  			default:
  1284  				err = fmt.Errorf("unknown argument %q", kv[0])
  1285  			}
  1286  			if err != nil {
  1287  				return starlark.None, decorateError(thread, err)
  1288  			}
  1289  		}
  1290  		err := env.ctx.Client().CallAPI("ListPackagesBuildInfo", &rpcArgs, &rpcRet)
  1291  		if err != nil {
  1292  			return starlark.None, err
  1293  		}
  1294  		return env.interfaceToStarlarkValue(rpcRet), nil
  1295  	})
  1296  	doc["packages_build_info"] = "builtin packages_build_info(IncludeFiles)\n\npackages_build_info returns the list of packages used by the program along with\nthe directory where each package was compiled and optionally the list of\nfiles constituting the package.\nNote that the directory path is a best guess and may be wrong is a tool\nother than cmd/go is used to perform the build."
  1297  	r["registers"] = starlark.NewBuiltin("registers", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1298  		if err := isCancelled(thread); err != nil {
  1299  			return starlark.None, decorateError(thread, err)
  1300  		}
  1301  		var rpcArgs rpc2.ListRegistersIn
  1302  		var rpcRet rpc2.ListRegistersOut
  1303  		if len(args) > 0 && args[0] != starlark.None {
  1304  			err := unmarshalStarlarkValue(args[0], &rpcArgs.ThreadID, "ThreadID")
  1305  			if err != nil {
  1306  				return starlark.None, decorateError(thread, err)
  1307  			}
  1308  		}
  1309  		if len(args) > 1 && args[1] != starlark.None {
  1310  			err := unmarshalStarlarkValue(args[1], &rpcArgs.IncludeFp, "IncludeFp")
  1311  			if err != nil {
  1312  				return starlark.None, decorateError(thread, err)
  1313  			}
  1314  		}
  1315  		if len(args) > 2 && args[2] != starlark.None {
  1316  			err := unmarshalStarlarkValue(args[2], &rpcArgs.Scope, "Scope")
  1317  			if err != nil {
  1318  				return starlark.None, decorateError(thread, err)
  1319  			}
  1320  		} else {
  1321  			scope := env.ctx.Scope()
  1322  			rpcArgs.Scope = &scope
  1323  		}
  1324  		for _, kv := range kwargs {
  1325  			var err error
  1326  			switch kv[0].(starlark.String) {
  1327  			case "ThreadID":
  1328  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.ThreadID, "ThreadID")
  1329  			case "IncludeFp":
  1330  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.IncludeFp, "IncludeFp")
  1331  			case "Scope":
  1332  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope")
  1333  			default:
  1334  				err = fmt.Errorf("unknown argument %q", kv[0])
  1335  			}
  1336  			if err != nil {
  1337  				return starlark.None, decorateError(thread, err)
  1338  			}
  1339  		}
  1340  		err := env.ctx.Client().CallAPI("ListRegisters", &rpcArgs, &rpcRet)
  1341  		if err != nil {
  1342  			return starlark.None, err
  1343  		}
  1344  		return env.interfaceToStarlarkValue(rpcRet), nil
  1345  	})
  1346  	doc["registers"] = "builtin registers(ThreadID, IncludeFp, Scope)\n\nregisters lists registers and their values.\nIf ListRegistersIn.Scope is not nil the registers of that eval scope will\nbe returned, otherwise ListRegistersIn.ThreadID will be used."
  1347  	r["sources"] = starlark.NewBuiltin("sources", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1348  		if err := isCancelled(thread); err != nil {
  1349  			return starlark.None, decorateError(thread, err)
  1350  		}
  1351  		var rpcArgs rpc2.ListSourcesIn
  1352  		var rpcRet rpc2.ListSourcesOut
  1353  		if len(args) > 0 && args[0] != starlark.None {
  1354  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Filter, "Filter")
  1355  			if err != nil {
  1356  				return starlark.None, decorateError(thread, err)
  1357  			}
  1358  		}
  1359  		for _, kv := range kwargs {
  1360  			var err error
  1361  			switch kv[0].(starlark.String) {
  1362  			case "Filter":
  1363  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Filter, "Filter")
  1364  			default:
  1365  				err = fmt.Errorf("unknown argument %q", kv[0])
  1366  			}
  1367  			if err != nil {
  1368  				return starlark.None, decorateError(thread, err)
  1369  			}
  1370  		}
  1371  		err := env.ctx.Client().CallAPI("ListSources", &rpcArgs, &rpcRet)
  1372  		if err != nil {
  1373  			return starlark.None, err
  1374  		}
  1375  		return env.interfaceToStarlarkValue(rpcRet), nil
  1376  	})
  1377  	doc["sources"] = "builtin sources(Filter)\n\nsources lists all source files in the process matching filter."
  1378  	r["targets"] = starlark.NewBuiltin("targets", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1379  		if err := isCancelled(thread); err != nil {
  1380  			return starlark.None, decorateError(thread, err)
  1381  		}
  1382  		var rpcArgs rpc2.ListTargetsIn
  1383  		var rpcRet rpc2.ListTargetsOut
  1384  		err := env.ctx.Client().CallAPI("ListTargets", &rpcArgs, &rpcRet)
  1385  		if err != nil {
  1386  			return starlark.None, err
  1387  		}
  1388  		return env.interfaceToStarlarkValue(rpcRet), nil
  1389  	})
  1390  	doc["targets"] = "builtin targets()\n\ntargets returns the list of targets we are currently attached to."
  1391  	r["threads"] = starlark.NewBuiltin("threads", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1392  		if err := isCancelled(thread); err != nil {
  1393  			return starlark.None, decorateError(thread, err)
  1394  		}
  1395  		var rpcArgs rpc2.ListThreadsIn
  1396  		var rpcRet rpc2.ListThreadsOut
  1397  		err := env.ctx.Client().CallAPI("ListThreads", &rpcArgs, &rpcRet)
  1398  		if err != nil {
  1399  			return starlark.None, err
  1400  		}
  1401  		return env.interfaceToStarlarkValue(rpcRet), nil
  1402  	})
  1403  	doc["threads"] = "builtin threads()\n\nthreads lists all threads."
  1404  	r["types"] = starlark.NewBuiltin("types", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1405  		if err := isCancelled(thread); err != nil {
  1406  			return starlark.None, decorateError(thread, err)
  1407  		}
  1408  		var rpcArgs rpc2.ListTypesIn
  1409  		var rpcRet rpc2.ListTypesOut
  1410  		if len(args) > 0 && args[0] != starlark.None {
  1411  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Filter, "Filter")
  1412  			if err != nil {
  1413  				return starlark.None, decorateError(thread, err)
  1414  			}
  1415  		}
  1416  		for _, kv := range kwargs {
  1417  			var err error
  1418  			switch kv[0].(starlark.String) {
  1419  			case "Filter":
  1420  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Filter, "Filter")
  1421  			default:
  1422  				err = fmt.Errorf("unknown argument %q", kv[0])
  1423  			}
  1424  			if err != nil {
  1425  				return starlark.None, decorateError(thread, err)
  1426  			}
  1427  		}
  1428  		err := env.ctx.Client().CallAPI("ListTypes", &rpcArgs, &rpcRet)
  1429  		if err != nil {
  1430  			return starlark.None, err
  1431  		}
  1432  		return env.interfaceToStarlarkValue(rpcRet), nil
  1433  	})
  1434  	doc["types"] = "builtin types(Filter)\n\ntypes lists all types in the process matching filter."
  1435  	r["process_pid"] = starlark.NewBuiltin("process_pid", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1436  		if err := isCancelled(thread); err != nil {
  1437  			return starlark.None, decorateError(thread, err)
  1438  		}
  1439  		var rpcArgs rpc2.ProcessPidIn
  1440  		var rpcRet rpc2.ProcessPidOut
  1441  		err := env.ctx.Client().CallAPI("ProcessPid", &rpcArgs, &rpcRet)
  1442  		if err != nil {
  1443  			return starlark.None, err
  1444  		}
  1445  		return env.interfaceToStarlarkValue(rpcRet), nil
  1446  	})
  1447  	doc["process_pid"] = "builtin process_pid()\n\nprocess_pid returns the pid of the process we are debugging."
  1448  	r["recorded"] = starlark.NewBuiltin("recorded", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1449  		if err := isCancelled(thread); err != nil {
  1450  			return starlark.None, decorateError(thread, err)
  1451  		}
  1452  		var rpcArgs rpc2.RecordedIn
  1453  		var rpcRet rpc2.RecordedOut
  1454  		err := env.ctx.Client().CallAPI("Recorded", &rpcArgs, &rpcRet)
  1455  		if err != nil {
  1456  			return starlark.None, err
  1457  		}
  1458  		return env.interfaceToStarlarkValue(rpcRet), nil
  1459  	})
  1460  	doc["recorded"] = "builtin recorded()"
  1461  	r["restart"] = starlark.NewBuiltin("restart", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1462  		if err := isCancelled(thread); err != nil {
  1463  			return starlark.None, decorateError(thread, err)
  1464  		}
  1465  		var rpcArgs rpc2.RestartIn
  1466  		var rpcRet rpc2.RestartOut
  1467  		if len(args) > 0 && args[0] != starlark.None {
  1468  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Position, "Position")
  1469  			if err != nil {
  1470  				return starlark.None, decorateError(thread, err)
  1471  			}
  1472  		}
  1473  		if len(args) > 1 && args[1] != starlark.None {
  1474  			err := unmarshalStarlarkValue(args[1], &rpcArgs.ResetArgs, "ResetArgs")
  1475  			if err != nil {
  1476  				return starlark.None, decorateError(thread, err)
  1477  			}
  1478  		}
  1479  		if len(args) > 2 && args[2] != starlark.None {
  1480  			err := unmarshalStarlarkValue(args[2], &rpcArgs.NewArgs, "NewArgs")
  1481  			if err != nil {
  1482  				return starlark.None, decorateError(thread, err)
  1483  			}
  1484  		}
  1485  		if len(args) > 3 && args[3] != starlark.None {
  1486  			err := unmarshalStarlarkValue(args[3], &rpcArgs.Rerecord, "Rerecord")
  1487  			if err != nil {
  1488  				return starlark.None, decorateError(thread, err)
  1489  			}
  1490  		}
  1491  		if len(args) > 4 && args[4] != starlark.None {
  1492  			err := unmarshalStarlarkValue(args[4], &rpcArgs.Rebuild, "Rebuild")
  1493  			if err != nil {
  1494  				return starlark.None, decorateError(thread, err)
  1495  			}
  1496  		}
  1497  		if len(args) > 5 && args[5] != starlark.None {
  1498  			err := unmarshalStarlarkValue(args[5], &rpcArgs.NewRedirects, "NewRedirects")
  1499  			if err != nil {
  1500  				return starlark.None, decorateError(thread, err)
  1501  			}
  1502  		}
  1503  		for _, kv := range kwargs {
  1504  			var err error
  1505  			switch kv[0].(starlark.String) {
  1506  			case "Position":
  1507  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Position, "Position")
  1508  			case "ResetArgs":
  1509  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.ResetArgs, "ResetArgs")
  1510  			case "NewArgs":
  1511  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.NewArgs, "NewArgs")
  1512  			case "Rerecord":
  1513  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Rerecord, "Rerecord")
  1514  			case "Rebuild":
  1515  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Rebuild, "Rebuild")
  1516  			case "NewRedirects":
  1517  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.NewRedirects, "NewRedirects")
  1518  			default:
  1519  				err = fmt.Errorf("unknown argument %q", kv[0])
  1520  			}
  1521  			if err != nil {
  1522  				return starlark.None, decorateError(thread, err)
  1523  			}
  1524  		}
  1525  		err := env.ctx.Client().CallAPI("Restart", &rpcArgs, &rpcRet)
  1526  		if err != nil {
  1527  			return starlark.None, err
  1528  		}
  1529  		return env.interfaceToStarlarkValue(rpcRet), nil
  1530  	})
  1531  	doc["restart"] = "builtin restart(Position, ResetArgs, NewArgs, Rerecord, Rebuild, NewRedirects)\n\nrestart restarts program."
  1532  	r["set_expr"] = starlark.NewBuiltin("set_expr", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1533  		if err := isCancelled(thread); err != nil {
  1534  			return starlark.None, decorateError(thread, err)
  1535  		}
  1536  		var rpcArgs rpc2.SetIn
  1537  		var rpcRet rpc2.SetOut
  1538  		if len(args) > 0 && args[0] != starlark.None {
  1539  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Scope, "Scope")
  1540  			if err != nil {
  1541  				return starlark.None, decorateError(thread, err)
  1542  			}
  1543  		} else {
  1544  			rpcArgs.Scope = env.ctx.Scope()
  1545  		}
  1546  		if len(args) > 1 && args[1] != starlark.None {
  1547  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Symbol, "Symbol")
  1548  			if err != nil {
  1549  				return starlark.None, decorateError(thread, err)
  1550  			}
  1551  		}
  1552  		if len(args) > 2 && args[2] != starlark.None {
  1553  			err := unmarshalStarlarkValue(args[2], &rpcArgs.Value, "Value")
  1554  			if err != nil {
  1555  				return starlark.None, decorateError(thread, err)
  1556  			}
  1557  		}
  1558  		for _, kv := range kwargs {
  1559  			var err error
  1560  			switch kv[0].(starlark.String) {
  1561  			case "Scope":
  1562  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope")
  1563  			case "Symbol":
  1564  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Symbol, "Symbol")
  1565  			case "Value":
  1566  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Value, "Value")
  1567  			default:
  1568  				err = fmt.Errorf("unknown argument %q", kv[0])
  1569  			}
  1570  			if err != nil {
  1571  				return starlark.None, decorateError(thread, err)
  1572  			}
  1573  		}
  1574  		err := env.ctx.Client().CallAPI("Set", &rpcArgs, &rpcRet)
  1575  		if err != nil {
  1576  			return starlark.None, err
  1577  		}
  1578  		return env.interfaceToStarlarkValue(rpcRet), nil
  1579  	})
  1580  	doc["set_expr"] = "builtin set_expr(Scope, Symbol, Value)\n\nset_expr sets the value of a variable. Only numerical types and\npointers are currently supported."
  1581  	r["stacktrace"] = starlark.NewBuiltin("stacktrace", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1582  		if err := isCancelled(thread); err != nil {
  1583  			return starlark.None, decorateError(thread, err)
  1584  		}
  1585  		var rpcArgs rpc2.StacktraceIn
  1586  		var rpcRet rpc2.StacktraceOut
  1587  		if len(args) > 0 && args[0] != starlark.None {
  1588  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Id, "Id")
  1589  			if err != nil {
  1590  				return starlark.None, decorateError(thread, err)
  1591  			}
  1592  		}
  1593  		if len(args) > 1 && args[1] != starlark.None {
  1594  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Depth, "Depth")
  1595  			if err != nil {
  1596  				return starlark.None, decorateError(thread, err)
  1597  			}
  1598  		}
  1599  		if len(args) > 2 && args[2] != starlark.None {
  1600  			err := unmarshalStarlarkValue(args[2], &rpcArgs.Full, "Full")
  1601  			if err != nil {
  1602  				return starlark.None, decorateError(thread, err)
  1603  			}
  1604  		}
  1605  		if len(args) > 3 && args[3] != starlark.None {
  1606  			err := unmarshalStarlarkValue(args[3], &rpcArgs.Defers, "Defers")
  1607  			if err != nil {
  1608  				return starlark.None, decorateError(thread, err)
  1609  			}
  1610  		}
  1611  		if len(args) > 4 && args[4] != starlark.None {
  1612  			err := unmarshalStarlarkValue(args[4], &rpcArgs.Opts, "Opts")
  1613  			if err != nil {
  1614  				return starlark.None, decorateError(thread, err)
  1615  			}
  1616  		}
  1617  		if len(args) > 5 && args[5] != starlark.None {
  1618  			err := unmarshalStarlarkValue(args[5], &rpcArgs.Cfg, "Cfg")
  1619  			if err != nil {
  1620  				return starlark.None, decorateError(thread, err)
  1621  			}
  1622  		}
  1623  		for _, kv := range kwargs {
  1624  			var err error
  1625  			switch kv[0].(starlark.String) {
  1626  			case "Id":
  1627  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Id, "Id")
  1628  			case "Depth":
  1629  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Depth, "Depth")
  1630  			case "Full":
  1631  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Full, "Full")
  1632  			case "Defers":
  1633  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Defers, "Defers")
  1634  			case "Opts":
  1635  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Opts, "Opts")
  1636  			case "Cfg":
  1637  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Cfg, "Cfg")
  1638  			default:
  1639  				err = fmt.Errorf("unknown argument %q", kv[0])
  1640  			}
  1641  			if err != nil {
  1642  				return starlark.None, decorateError(thread, err)
  1643  			}
  1644  		}
  1645  		err := env.ctx.Client().CallAPI("Stacktrace", &rpcArgs, &rpcRet)
  1646  		if err != nil {
  1647  			return starlark.None, err
  1648  		}
  1649  		return env.interfaceToStarlarkValue(rpcRet), nil
  1650  	})
  1651  	doc["stacktrace"] = "builtin stacktrace(Id, Depth, Full, Defers, Opts, Cfg)\n\nstacktrace returns stacktrace of goroutine Id up to the specified Depth.\n\nIf Full is set it will also the variable of all local variables\nand function arguments of all stack frames."
  1652  	r["state"] = starlark.NewBuiltin("state", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1653  		if err := isCancelled(thread); err != nil {
  1654  			return starlark.None, decorateError(thread, err)
  1655  		}
  1656  		var rpcArgs rpc2.StateIn
  1657  		var rpcRet rpc2.StateOut
  1658  		if len(args) > 0 && args[0] != starlark.None {
  1659  			err := unmarshalStarlarkValue(args[0], &rpcArgs.NonBlocking, "NonBlocking")
  1660  			if err != nil {
  1661  				return starlark.None, decorateError(thread, err)
  1662  			}
  1663  		}
  1664  		for _, kv := range kwargs {
  1665  			var err error
  1666  			switch kv[0].(starlark.String) {
  1667  			case "NonBlocking":
  1668  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.NonBlocking, "NonBlocking")
  1669  			default:
  1670  				err = fmt.Errorf("unknown argument %q", kv[0])
  1671  			}
  1672  			if err != nil {
  1673  				return starlark.None, decorateError(thread, err)
  1674  			}
  1675  		}
  1676  		err := env.ctx.Client().CallAPI("State", &rpcArgs, &rpcRet)
  1677  		if err != nil {
  1678  			return starlark.None, err
  1679  		}
  1680  		return env.interfaceToStarlarkValue(rpcRet), nil
  1681  	})
  1682  	doc["state"] = "builtin state(NonBlocking)\n\nstate returns the current debugger state."
  1683  	r["toggle_breakpoint"] = starlark.NewBuiltin("toggle_breakpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
  1684  		if err := isCancelled(thread); err != nil {
  1685  			return starlark.None, decorateError(thread, err)
  1686  		}
  1687  		var rpcArgs rpc2.ToggleBreakpointIn
  1688  		var rpcRet rpc2.ToggleBreakpointOut
  1689  		if len(args) > 0 && args[0] != starlark.None {
  1690  			err := unmarshalStarlarkValue(args[0], &rpcArgs.Id, "Id")
  1691  			if err != nil {
  1692  				return starlark.None, decorateError(thread, err)
  1693  			}
  1694  		}
  1695  		if len(args) > 1 && args[1] != starlark.None {
  1696  			err := unmarshalStarlarkValue(args[1], &rpcArgs.Name, "Name")
  1697  			if err != nil {
  1698  				return starlark.None, decorateError(thread, err)
  1699  			}
  1700  		}
  1701  		for _, kv := range kwargs {
  1702  			var err error
  1703  			switch kv[0].(starlark.String) {
  1704  			case "Id":
  1705  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Id, "Id")
  1706  			case "Name":
  1707  				err = unmarshalStarlarkValue(kv[1], &rpcArgs.Name, "Name")
  1708  			default:
  1709  				err = fmt.Errorf("unknown argument %q", kv[0])
  1710  			}
  1711  			if err != nil {
  1712  				return starlark.None, decorateError(thread, err)
  1713  			}
  1714  		}
  1715  		err := env.ctx.Client().CallAPI("ToggleBreakpoint", &rpcArgs, &rpcRet)
  1716  		if err != nil {
  1717  			return starlark.None, err
  1718  		}
  1719  		return env.interfaceToStarlarkValue(rpcRet), nil
  1720  	})
  1721  	doc["toggle_breakpoint"] = "builtin toggle_breakpoint(Id, Name)\n\ntoggle_breakpoint toggles on or off a breakpoint by Name (if Name is not an\nempty string) or by ID."
  1722  	return r, doc
  1723  }