gitlab.com/Raven-IO/raven-delve@v1.22.4/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 "gitlab.com/Raven-IO/raven-delve/service/api" 8 "gitlab.com/Raven-IO/raven-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/gitlab.com/Raven-IO/raven-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://gitlab.com/Raven-IO/raven-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 if len(args) > 1 && args[1] != starlark.None { 1279 err := unmarshalStarlarkValue(args[1], &rpcArgs.Filter, "Filter") 1280 if err != nil { 1281 return starlark.None, decorateError(thread, err) 1282 } 1283 } 1284 for _, kv := range kwargs { 1285 var err error 1286 switch kv[0].(starlark.String) { 1287 case "IncludeFiles": 1288 err = unmarshalStarlarkValue(kv[1], &rpcArgs.IncludeFiles, "IncludeFiles") 1289 case "Filter": 1290 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Filter, "Filter") 1291 default: 1292 err = fmt.Errorf("unknown argument %q", kv[0]) 1293 } 1294 if err != nil { 1295 return starlark.None, decorateError(thread, err) 1296 } 1297 } 1298 err := env.ctx.Client().CallAPI("ListPackagesBuildInfo", &rpcArgs, &rpcRet) 1299 if err != nil { 1300 return starlark.None, err 1301 } 1302 return env.interfaceToStarlarkValue(rpcRet), nil 1303 }) 1304 doc["packages_build_info"] = "builtin packages_build_info(IncludeFiles, Filter)\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." 1305 r["registers"] = starlark.NewBuiltin("registers", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1306 if err := isCancelled(thread); err != nil { 1307 return starlark.None, decorateError(thread, err) 1308 } 1309 var rpcArgs rpc2.ListRegistersIn 1310 var rpcRet rpc2.ListRegistersOut 1311 if len(args) > 0 && args[0] != starlark.None { 1312 err := unmarshalStarlarkValue(args[0], &rpcArgs.ThreadID, "ThreadID") 1313 if err != nil { 1314 return starlark.None, decorateError(thread, err) 1315 } 1316 } 1317 if len(args) > 1 && args[1] != starlark.None { 1318 err := unmarshalStarlarkValue(args[1], &rpcArgs.IncludeFp, "IncludeFp") 1319 if err != nil { 1320 return starlark.None, decorateError(thread, err) 1321 } 1322 } 1323 if len(args) > 2 && args[2] != starlark.None { 1324 err := unmarshalStarlarkValue(args[2], &rpcArgs.Scope, "Scope") 1325 if err != nil { 1326 return starlark.None, decorateError(thread, err) 1327 } 1328 } else { 1329 scope := env.ctx.Scope() 1330 rpcArgs.Scope = &scope 1331 } 1332 for _, kv := range kwargs { 1333 var err error 1334 switch kv[0].(starlark.String) { 1335 case "ThreadID": 1336 err = unmarshalStarlarkValue(kv[1], &rpcArgs.ThreadID, "ThreadID") 1337 case "IncludeFp": 1338 err = unmarshalStarlarkValue(kv[1], &rpcArgs.IncludeFp, "IncludeFp") 1339 case "Scope": 1340 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope") 1341 default: 1342 err = fmt.Errorf("unknown argument %q", kv[0]) 1343 } 1344 if err != nil { 1345 return starlark.None, decorateError(thread, err) 1346 } 1347 } 1348 err := env.ctx.Client().CallAPI("ListRegisters", &rpcArgs, &rpcRet) 1349 if err != nil { 1350 return starlark.None, err 1351 } 1352 return env.interfaceToStarlarkValue(rpcRet), nil 1353 }) 1354 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." 1355 r["sources"] = starlark.NewBuiltin("sources", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1356 if err := isCancelled(thread); err != nil { 1357 return starlark.None, decorateError(thread, err) 1358 } 1359 var rpcArgs rpc2.ListSourcesIn 1360 var rpcRet rpc2.ListSourcesOut 1361 if len(args) > 0 && args[0] != starlark.None { 1362 err := unmarshalStarlarkValue(args[0], &rpcArgs.Filter, "Filter") 1363 if err != nil { 1364 return starlark.None, decorateError(thread, err) 1365 } 1366 } 1367 for _, kv := range kwargs { 1368 var err error 1369 switch kv[0].(starlark.String) { 1370 case "Filter": 1371 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Filter, "Filter") 1372 default: 1373 err = fmt.Errorf("unknown argument %q", kv[0]) 1374 } 1375 if err != nil { 1376 return starlark.None, decorateError(thread, err) 1377 } 1378 } 1379 err := env.ctx.Client().CallAPI("ListSources", &rpcArgs, &rpcRet) 1380 if err != nil { 1381 return starlark.None, err 1382 } 1383 return env.interfaceToStarlarkValue(rpcRet), nil 1384 }) 1385 doc["sources"] = "builtin sources(Filter)\n\nsources lists all source files in the process matching filter." 1386 r["targets"] = starlark.NewBuiltin("targets", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1387 if err := isCancelled(thread); err != nil { 1388 return starlark.None, decorateError(thread, err) 1389 } 1390 var rpcArgs rpc2.ListTargetsIn 1391 var rpcRet rpc2.ListTargetsOut 1392 err := env.ctx.Client().CallAPI("ListTargets", &rpcArgs, &rpcRet) 1393 if err != nil { 1394 return starlark.None, err 1395 } 1396 return env.interfaceToStarlarkValue(rpcRet), nil 1397 }) 1398 doc["targets"] = "builtin targets()\n\ntargets returns the list of targets we are currently attached to." 1399 r["threads"] = starlark.NewBuiltin("threads", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1400 if err := isCancelled(thread); err != nil { 1401 return starlark.None, decorateError(thread, err) 1402 } 1403 var rpcArgs rpc2.ListThreadsIn 1404 var rpcRet rpc2.ListThreadsOut 1405 err := env.ctx.Client().CallAPI("ListThreads", &rpcArgs, &rpcRet) 1406 if err != nil { 1407 return starlark.None, err 1408 } 1409 return env.interfaceToStarlarkValue(rpcRet), nil 1410 }) 1411 doc["threads"] = "builtin threads()\n\nthreads lists all threads." 1412 r["types"] = starlark.NewBuiltin("types", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1413 if err := isCancelled(thread); err != nil { 1414 return starlark.None, decorateError(thread, err) 1415 } 1416 var rpcArgs rpc2.ListTypesIn 1417 var rpcRet rpc2.ListTypesOut 1418 if len(args) > 0 && args[0] != starlark.None { 1419 err := unmarshalStarlarkValue(args[0], &rpcArgs.Filter, "Filter") 1420 if err != nil { 1421 return starlark.None, decorateError(thread, err) 1422 } 1423 } 1424 for _, kv := range kwargs { 1425 var err error 1426 switch kv[0].(starlark.String) { 1427 case "Filter": 1428 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Filter, "Filter") 1429 default: 1430 err = fmt.Errorf("unknown argument %q", kv[0]) 1431 } 1432 if err != nil { 1433 return starlark.None, decorateError(thread, err) 1434 } 1435 } 1436 err := env.ctx.Client().CallAPI("ListTypes", &rpcArgs, &rpcRet) 1437 if err != nil { 1438 return starlark.None, err 1439 } 1440 return env.interfaceToStarlarkValue(rpcRet), nil 1441 }) 1442 doc["types"] = "builtin types(Filter)\n\ntypes lists all types in the process matching filter." 1443 r["process_pid"] = starlark.NewBuiltin("process_pid", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1444 if err := isCancelled(thread); err != nil { 1445 return starlark.None, decorateError(thread, err) 1446 } 1447 var rpcArgs rpc2.ProcessPidIn 1448 var rpcRet rpc2.ProcessPidOut 1449 err := env.ctx.Client().CallAPI("ProcessPid", &rpcArgs, &rpcRet) 1450 if err != nil { 1451 return starlark.None, err 1452 } 1453 return env.interfaceToStarlarkValue(rpcRet), nil 1454 }) 1455 doc["process_pid"] = "builtin process_pid()\n\nprocess_pid returns the pid of the process we are debugging." 1456 r["recorded"] = starlark.NewBuiltin("recorded", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1457 if err := isCancelled(thread); err != nil { 1458 return starlark.None, decorateError(thread, err) 1459 } 1460 var rpcArgs rpc2.RecordedIn 1461 var rpcRet rpc2.RecordedOut 1462 err := env.ctx.Client().CallAPI("Recorded", &rpcArgs, &rpcRet) 1463 if err != nil { 1464 return starlark.None, err 1465 } 1466 return env.interfaceToStarlarkValue(rpcRet), nil 1467 }) 1468 doc["recorded"] = "builtin recorded()" 1469 r["restart"] = starlark.NewBuiltin("restart", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1470 if err := isCancelled(thread); err != nil { 1471 return starlark.None, decorateError(thread, err) 1472 } 1473 var rpcArgs rpc2.RestartIn 1474 var rpcRet rpc2.RestartOut 1475 if len(args) > 0 && args[0] != starlark.None { 1476 err := unmarshalStarlarkValue(args[0], &rpcArgs.Position, "Position") 1477 if err != nil { 1478 return starlark.None, decorateError(thread, err) 1479 } 1480 } 1481 if len(args) > 1 && args[1] != starlark.None { 1482 err := unmarshalStarlarkValue(args[1], &rpcArgs.ResetArgs, "ResetArgs") 1483 if err != nil { 1484 return starlark.None, decorateError(thread, err) 1485 } 1486 } 1487 if len(args) > 2 && args[2] != starlark.None { 1488 err := unmarshalStarlarkValue(args[2], &rpcArgs.NewArgs, "NewArgs") 1489 if err != nil { 1490 return starlark.None, decorateError(thread, err) 1491 } 1492 } 1493 if len(args) > 3 && args[3] != starlark.None { 1494 err := unmarshalStarlarkValue(args[3], &rpcArgs.Rerecord, "Rerecord") 1495 if err != nil { 1496 return starlark.None, decorateError(thread, err) 1497 } 1498 } 1499 if len(args) > 4 && args[4] != starlark.None { 1500 err := unmarshalStarlarkValue(args[4], &rpcArgs.Rebuild, "Rebuild") 1501 if err != nil { 1502 return starlark.None, decorateError(thread, err) 1503 } 1504 } 1505 if len(args) > 5 && args[5] != starlark.None { 1506 err := unmarshalStarlarkValue(args[5], &rpcArgs.NewRedirects, "NewRedirects") 1507 if err != nil { 1508 return starlark.None, decorateError(thread, err) 1509 } 1510 } 1511 for _, kv := range kwargs { 1512 var err error 1513 switch kv[0].(starlark.String) { 1514 case "Position": 1515 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Position, "Position") 1516 case "ResetArgs": 1517 err = unmarshalStarlarkValue(kv[1], &rpcArgs.ResetArgs, "ResetArgs") 1518 case "NewArgs": 1519 err = unmarshalStarlarkValue(kv[1], &rpcArgs.NewArgs, "NewArgs") 1520 case "Rerecord": 1521 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Rerecord, "Rerecord") 1522 case "Rebuild": 1523 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Rebuild, "Rebuild") 1524 case "NewRedirects": 1525 err = unmarshalStarlarkValue(kv[1], &rpcArgs.NewRedirects, "NewRedirects") 1526 default: 1527 err = fmt.Errorf("unknown argument %q", kv[0]) 1528 } 1529 if err != nil { 1530 return starlark.None, decorateError(thread, err) 1531 } 1532 } 1533 err := env.ctx.Client().CallAPI("Restart", &rpcArgs, &rpcRet) 1534 if err != nil { 1535 return starlark.None, err 1536 } 1537 return env.interfaceToStarlarkValue(rpcRet), nil 1538 }) 1539 doc["restart"] = "builtin restart(Position, ResetArgs, NewArgs, Rerecord, Rebuild, NewRedirects)\n\nrestart restarts program." 1540 r["set_expr"] = starlark.NewBuiltin("set_expr", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1541 if err := isCancelled(thread); err != nil { 1542 return starlark.None, decorateError(thread, err) 1543 } 1544 var rpcArgs rpc2.SetIn 1545 var rpcRet rpc2.SetOut 1546 if len(args) > 0 && args[0] != starlark.None { 1547 err := unmarshalStarlarkValue(args[0], &rpcArgs.Scope, "Scope") 1548 if err != nil { 1549 return starlark.None, decorateError(thread, err) 1550 } 1551 } else { 1552 rpcArgs.Scope = env.ctx.Scope() 1553 } 1554 if len(args) > 1 && args[1] != starlark.None { 1555 err := unmarshalStarlarkValue(args[1], &rpcArgs.Symbol, "Symbol") 1556 if err != nil { 1557 return starlark.None, decorateError(thread, err) 1558 } 1559 } 1560 if len(args) > 2 && args[2] != starlark.None { 1561 err := unmarshalStarlarkValue(args[2], &rpcArgs.Value, "Value") 1562 if err != nil { 1563 return starlark.None, decorateError(thread, err) 1564 } 1565 } 1566 for _, kv := range kwargs { 1567 var err error 1568 switch kv[0].(starlark.String) { 1569 case "Scope": 1570 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Scope, "Scope") 1571 case "Symbol": 1572 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Symbol, "Symbol") 1573 case "Value": 1574 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Value, "Value") 1575 default: 1576 err = fmt.Errorf("unknown argument %q", kv[0]) 1577 } 1578 if err != nil { 1579 return starlark.None, decorateError(thread, err) 1580 } 1581 } 1582 err := env.ctx.Client().CallAPI("Set", &rpcArgs, &rpcRet) 1583 if err != nil { 1584 return starlark.None, err 1585 } 1586 return env.interfaceToStarlarkValue(rpcRet), nil 1587 }) 1588 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." 1589 r["stacktrace"] = starlark.NewBuiltin("stacktrace", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1590 if err := isCancelled(thread); err != nil { 1591 return starlark.None, decorateError(thread, err) 1592 } 1593 var rpcArgs rpc2.StacktraceIn 1594 var rpcRet rpc2.StacktraceOut 1595 if len(args) > 0 && args[0] != starlark.None { 1596 err := unmarshalStarlarkValue(args[0], &rpcArgs.Id, "Id") 1597 if err != nil { 1598 return starlark.None, decorateError(thread, err) 1599 } 1600 } 1601 if len(args) > 1 && args[1] != starlark.None { 1602 err := unmarshalStarlarkValue(args[1], &rpcArgs.Depth, "Depth") 1603 if err != nil { 1604 return starlark.None, decorateError(thread, err) 1605 } 1606 } 1607 if len(args) > 2 && args[2] != starlark.None { 1608 err := unmarshalStarlarkValue(args[2], &rpcArgs.Full, "Full") 1609 if err != nil { 1610 return starlark.None, decorateError(thread, err) 1611 } 1612 } 1613 if len(args) > 3 && args[3] != starlark.None { 1614 err := unmarshalStarlarkValue(args[3], &rpcArgs.Defers, "Defers") 1615 if err != nil { 1616 return starlark.None, decorateError(thread, err) 1617 } 1618 } 1619 if len(args) > 4 && args[4] != starlark.None { 1620 err := unmarshalStarlarkValue(args[4], &rpcArgs.Opts, "Opts") 1621 if err != nil { 1622 return starlark.None, decorateError(thread, err) 1623 } 1624 } 1625 if len(args) > 5 && args[5] != starlark.None { 1626 err := unmarshalStarlarkValue(args[5], &rpcArgs.Cfg, "Cfg") 1627 if err != nil { 1628 return starlark.None, decorateError(thread, err) 1629 } 1630 } 1631 for _, kv := range kwargs { 1632 var err error 1633 switch kv[0].(starlark.String) { 1634 case "Id": 1635 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Id, "Id") 1636 case "Depth": 1637 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Depth, "Depth") 1638 case "Full": 1639 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Full, "Full") 1640 case "Defers": 1641 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Defers, "Defers") 1642 case "Opts": 1643 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Opts, "Opts") 1644 case "Cfg": 1645 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Cfg, "Cfg") 1646 default: 1647 err = fmt.Errorf("unknown argument %q", kv[0]) 1648 } 1649 if err != nil { 1650 return starlark.None, decorateError(thread, err) 1651 } 1652 } 1653 err := env.ctx.Client().CallAPI("Stacktrace", &rpcArgs, &rpcRet) 1654 if err != nil { 1655 return starlark.None, err 1656 } 1657 return env.interfaceToStarlarkValue(rpcRet), nil 1658 }) 1659 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." 1660 r["state"] = starlark.NewBuiltin("state", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1661 if err := isCancelled(thread); err != nil { 1662 return starlark.None, decorateError(thread, err) 1663 } 1664 var rpcArgs rpc2.StateIn 1665 var rpcRet rpc2.StateOut 1666 if len(args) > 0 && args[0] != starlark.None { 1667 err := unmarshalStarlarkValue(args[0], &rpcArgs.NonBlocking, "NonBlocking") 1668 if err != nil { 1669 return starlark.None, decorateError(thread, err) 1670 } 1671 } 1672 for _, kv := range kwargs { 1673 var err error 1674 switch kv[0].(starlark.String) { 1675 case "NonBlocking": 1676 err = unmarshalStarlarkValue(kv[1], &rpcArgs.NonBlocking, "NonBlocking") 1677 default: 1678 err = fmt.Errorf("unknown argument %q", kv[0]) 1679 } 1680 if err != nil { 1681 return starlark.None, decorateError(thread, err) 1682 } 1683 } 1684 err := env.ctx.Client().CallAPI("State", &rpcArgs, &rpcRet) 1685 if err != nil { 1686 return starlark.None, err 1687 } 1688 return env.interfaceToStarlarkValue(rpcRet), nil 1689 }) 1690 doc["state"] = "builtin state(NonBlocking)\n\nstate returns the current debugger state." 1691 r["toggle_breakpoint"] = starlark.NewBuiltin("toggle_breakpoint", func(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { 1692 if err := isCancelled(thread); err != nil { 1693 return starlark.None, decorateError(thread, err) 1694 } 1695 var rpcArgs rpc2.ToggleBreakpointIn 1696 var rpcRet rpc2.ToggleBreakpointOut 1697 if len(args) > 0 && args[0] != starlark.None { 1698 err := unmarshalStarlarkValue(args[0], &rpcArgs.Id, "Id") 1699 if err != nil { 1700 return starlark.None, decorateError(thread, err) 1701 } 1702 } 1703 if len(args) > 1 && args[1] != starlark.None { 1704 err := unmarshalStarlarkValue(args[1], &rpcArgs.Name, "Name") 1705 if err != nil { 1706 return starlark.None, decorateError(thread, err) 1707 } 1708 } 1709 for _, kv := range kwargs { 1710 var err error 1711 switch kv[0].(starlark.String) { 1712 case "Id": 1713 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Id, "Id") 1714 case "Name": 1715 err = unmarshalStarlarkValue(kv[1], &rpcArgs.Name, "Name") 1716 default: 1717 err = fmt.Errorf("unknown argument %q", kv[0]) 1718 } 1719 if err != nil { 1720 return starlark.None, decorateError(thread, err) 1721 } 1722 } 1723 err := env.ctx.Client().CallAPI("ToggleBreakpoint", &rpcArgs, &rpcRet) 1724 if err != nil { 1725 return starlark.None, err 1726 } 1727 return env.interfaceToStarlarkValue(rpcRet), nil 1728 }) 1729 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." 1730 return r, doc 1731 }