@@ -45,73 +45,82 @@ adds `FOO=1` and `bar` to the environment:
4545
4646### Attaching to a process
4747
48- When attaching to a process using LLDB, you can attach in multiple ways:
48+ You can attach to a running process on the system in one of two ways:
4949
50- 1 . Attach to an existing process using the process ID
51- 2 . Attach to an existing process by name
52- 3 . Attach by name by waiting for the next instance of a process to launch
50+ 1 . Using the ` LLDB DAP: Attach to Process... ` command
51+ 2 . Creating a launch configuration with ` "request" ` set to ` "attach" `
5352
54- #### Attach using PID
53+ #### Using the Attach to Process Command
5554
56- This will attach to a process ` a.out ` whose process ID is 123:
55+ The ` LLDB DAP: Attach to Process... ` command can be accessed from the command
56+ palette. It will show a list of available processes running on the system.
57+ Choosing one of these processes will start a debugging session where ` lldb-dap `
58+ will attach to the chosen process.
5759
58- ``` javascript
60+ #### Creating a Launch Configuration
61+
62+ Sometimes you will want to rename an attach debug session or configure lldb-dap
63+ on a per-session basis. For this you can create a new launch configuration
64+ with the ` "request" ` property set to ` "attach" ` :
65+
66+ ``` jsonc
5967{
6068 " type" : " lldb-dap" ,
6169 " request" : " attach" ,
62- " name" : " Attach to PID" ,
63- " program" : " /tmp/a.out" ,
64- " pid" : 123
70+ " name" : " My Custom Attach" ,
71+ " pid" : " ${command:pickProcess}" // optional: the process picker is used by default
6572}
6673```
6774
68- You can also use the variable substitution ` ${command:pickProcess} ` to select a
69- process at the start of the debug session instead of setting the pid manually:
75+ These launch configurations can be accessed from the Run and Debug view in the
76+ VS Code side panel. You will once again be shown a process picker upon launching
77+ this debug session. Selecting a process will start a debugging session where
78+ ` lldb-dap ` will attach to the specified process.
7079
71- ``` javascript
80+ Specifying the pid as a number will attach to that specific process ID and avoid
81+ the process picker entirely:
82+
83+ ``` jsonc
7284{
7385 " type" : " lldb-dap" ,
7486 " request" : " attach" ,
75- " name" : " Attach to PID" ,
76- " pid" : " ${command:pickProcess}" ,
77- " program" : " /path/to/program"
87+ " name" : " My Custom Attach" ,
88+ " pid" : 123 // Will attach to the process with ID 123
7889}
7990```
8091
81- Note: The ` program ` path above is optional. If specified, ` pickProcess ` will
82- filter the list of available process based on the full program path. If absent,
83- ` pickProcess ` will offer a list of all processes running on the system.
92+ #### Filtering by Program Name
8493
85- #### Attach by Name
94+ The process picker allows for fuzzy matching of program name, arguments, and
95+ process ID. However, you can also provide an optional ` "program" ` property to
96+ your launch configuration in order to filter the process picker by the basename
97+ of the program by default:
8698
87- This will attach to an existing process whose base
88- name matches ` a.out ` . All we have to do is leave the ` pid ` value out of the
89- above configuration:
90-
91- ``` javascript
99+ ``` jsonc
92100{
93- " name" : " Attach to Name" ,
94101 " type" : " lldb-dap" ,
95102 " request" : " attach" ,
96- " program" : " /tmp/a.out" ,
103+ " name" : " My Custom Attach" ,
104+ " program" : " ${workspaceFolder}/build/a.out" // Will show only processes that match "a.out"
97105}
98106```
99107
100- If you want to ignore any existing a.out processes and wait for the next instance
101- to be launched you can add the "waitFor" key value pair :
108+ If you want to ignore any existing ` a.out ` processes and wait for the next instance
109+ to be launched you can set the ` "waitFor" ` property :
102110
103- ``` javascript
111+ ``` jsonc
104112{
105113 " name" : " Attach to Name (wait)" ,
106114 " type" : " lldb-dap" ,
107115 " request" : " attach" ,
108- " program" : " /tmp /a.out" ,
109- " waitFor" : true
116+ " program" : " ${workspaceFolder}/build /a.out" ,
117+ " waitFor" : true // Forces lldb-dap to wait for a new process to launch
110118}
111119```
112120
113121This will work as long as the architecture, vendor and OS supports waiting
114122for processes. Currently MacOS is the only platform that supports this.
123+ Additionally, the process picker will not be used in this case.
115124
116125### Loading a Core File
117126
0 commit comments