19from typing
import Mapping, Optional, Sequence
21from .events
import exec_and_expect_stop
22from .server
import request, capability
23from .startup
import in_gdb_thread, exec_and_log
32def _launch_setup(program, cwd, args, env, stopAtBeginningOfMainSubprogram):
34 exec_and_log(
"cd " + cwd)
35 if program
is not None:
36 exec_and_log(
"file " + program)
37 inf = gdb.selected_inferior()
38 if stopAtBeginningOfMainSubprogram:
41 exec_and_log(
"tbreak " + main)
45 for name, value
in env.items():
46 inf.set_env(name, value)
52@request("launch", response=False)
55 program: Optional[str] =
None,
56 cwd: Optional[str] =
None,
57 args: Sequence[str] = (),
58 env: Optional[Mapping[str, str]] =
None,
59 stopAtBeginningOfMainSubprogram: bool =
False,
64 _launch_setup(program, cwd, args, env, stopAtBeginningOfMainSubprogram)
68def attach(*, pid: Optional[int] =
None, target: Optional[str] =
None, **args):
73 cmd =
"attach " + str(pid)
74 elif target
is not None:
75 cmd =
"target remote " + target
77 raise Exception(
"attach requires either 'pid' or 'target'")
81@capability("supportsConfigurationDoneRequest")
82@request("configurationDone", response=False)
85 if _program
is not None:
88 exec_and_expect_stop(
"run",
None)
attach(*Optional[int] pid=None, Optional[str] target=None, **args)
_launch_setup(program, cwd, args, env, stopAtBeginningOfMainSubprogram)