You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: package.json
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1510,7 +1510,7 @@
1510
1510
},
1511
1511
"launchCommands": {
1512
1512
"type": "array",
1513
-
"description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail. Launch the process with \"process launch -s\" to make the process to at the entry point since lldb-vscode will auto resume if necessary.",
1513
+
"description": "Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail. Launch the process with \"process launch -s\" to make the process to at the entry point since lldb-dap will auto resume if necessary.",
1514
1514
"default": []
1515
1515
},
1516
1516
"stopCommands": {
@@ -1520,7 +1520,12 @@
1520
1520
},
1521
1521
"exitCommands": {
1522
1522
"type": "array",
1523
-
"description": "Commands executed at the end of debugging session.",
1523
+
"description": "Commands executed when the program exits.",
1524
+
"default": []
1525
+
},
1526
+
"terminateCommands": {
1527
+
"type": "array",
1528
+
"description": "Commands executed when the debugging session ends.",
Copy file name to clipboardExpand all lines: userdocs/userdocs.docc/Articles/Features/debugging.md
+60Lines changed: 60 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -9,3 +9,63 @@ When you open a Swift package (a directory containing a `Package.swift` file), t
9
9
> Debugging works best when using a version of the Swift toolchain 6.0 or higher.
10
10
11
11
Use the **Run > Start Debugging** menu item to run an executable and start debugging. If you have multiple launch configurations you can choose which launch configuration to use in the debugger view.
12
+
13
+
## Launch Configurations
14
+
15
+
The Swift extension will automatically generate launch configurations for all of your executable products. You can customize these configurations via the `.vscode/launch.json` file in your workspace to add environment variables, arguments, etc.
16
+
17
+
Each generated launch configuration will have the `"type"` set to `"swift"`. The properties for the swift launch configuration match the ones [provided by `lldb-dap`](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.lldb-dap). You can use code completion in VS Code to help with adding properties to your launch configuration.
18
+
19
+
### Launching an Executable
20
+
21
+
The most basic launch configuration uses the `"launch"` request and provides a program that will be debugged. For example:
22
+
23
+
```javascript
24
+
{
25
+
"label":"Debug my-executable", // Human readable name for the configuration
26
+
"type":"swift", // All Swift launch configurations use the same type
| program | string | Path to the executable to launch.
37
+
| args | [string] | An array of command line argument strings to be passed to the program being launched.
38
+
| cwd | string | The program working directory.
39
+
| env | dictionary | Environment variables to set when launching the program. The format of each environment variable string is "VAR=VALUE" for environment variables with values or just "VAR" for environment variables with no values.
40
+
| stopOnEntry | boolean | Whether to stop program immediately after launching.
41
+
| runInTerminal | boolean | Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs.
| preRunCommands | [string] | Commands executed just before the program is launched.
44
+
| postRunCommands | [string] | Commands executed just as soon as the program is successfully launched when it's in a stopped state prior to any automatic continuation.
45
+
| launchCommands | [string] | Custom commands that are executed instead of launching a process. A target will be created with the launch arguments prior to executing these commands. The commands may optionally create a new target and must perform a launch. A valid process must exist after these commands complete or the \"launch\" will fail. Launch the process with \"process launch -s\" to make the process to at the entry point since lldb-dap will auto resume if necessary.
46
+
| stopCommands | [string] | Commands executed each time the program stops.
47
+
| exitCommands | [string] | Commands executed when the program exits.
48
+
| terminateCommands | [string] | Commands executed when the debugging session ends.
49
+
50
+
### Attaching to a Process
51
+
52
+
You can attach to an existing process by using the `"attach"` request and providing one or both of a `"program"` or `"pid"` to attach to:
53
+
54
+
```javascript
55
+
{
56
+
"label":"Debug my-executable", // Human readable name for the configuration
57
+
"type":"swift", // All Swift launch configurations use the same type
| program | string | Path to the executable to attach to. This value is optional but can help to resolve breakpoints prior the attaching to the program.
69
+
| pid | number | The process id of the process you wish to attach to. If `pid` is omitted, the debugger will attempt to attach to the program by finding a process whose file name matches the file name from `program`. Setting this value to `${command:pickMyProcess}` will allow interactive process selection in the IDE.
70
+
| waitFor | boolean | Wait for the process to launch.
71
+
| attachCommands | [string] | LLDB commands that will be executed after `preRunCommands` which take place of the code that normally does the attach. The commands can create a new target and attach or launch it however desired. This allows custom launch and attach configurations. Core files can use `target create --core /path/to/core` to attach to core files.
0 commit comments