-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of launch
and attach
requests is confusing
#7
Comments
Valid point. I was aware of the 'attach' shortcoming when I built it, but at the time was more focussed on implementing the ability to resolve variable values during debug stepping. Now is probably a good time to discuss this, especially since the multicore PR is going to impact how sessions start and end in the debugger. So, before I open a PR, I'd like to clarify the understanding of current behaviour first.
So here is what I propose for addressing your concern. Let me know what you think ...
Thoughts? |
I agree that the ability to attach to an already running debugger process is very useful, and I don't think it should be removed. However, I think this should not depend on the request type. My suggestion would be to use an additional configuration flag for this, so the user can decide if they want this ability or not. From my experience with other debuggers, it's quite common to have this kind of config option. I don't have a strong opinion in regards to multicore, I would prefer whatever is easier to implement ;) |
I'm aligned with this. I will PR this as soon as @Yatekii and I release the first iteration of RTT integration. |
12: Refactor how `launch` and `attach` requests work. r=noppej a=noppej This PR was motivated by discussions in #7, and will require rework of the equivalent functionality in [probe-rs-debugger](https://github.com/probe-rs/probe-rs/tree/master/debugger). It will involve a big code change in both repo's. In the first iterations of this extension, the `launch` and `attach` terminology was interpreted to apply to the debug adapter process. In other words, "launch a new instance of the debug adapter", or "attach to a to an existing debug adapter process". - Both operations allowed flashing and resetting of the target process running on the probe. - Neither operations allowed the debug adapter session to last for more than one session of the target process on the probe. The proposed change will reinterpret the `launch` and `attach` terminology to apply to the target process running on the probe. To help clarify the different behaviours, I will use the following terminology: - _debug session_: This refers to host side process, and ... - Starts when a user initiates either a `launch` or `attach` request, and ... - Ends when the user either initiates `disconnect` request, or chooses to `Stop` a host side debug session. - _target session_: This refers to the target side process, and ... - Starts when the target device boots and executes the firmware program, and ... - Ends when the target device processing halts as a result of a unrecoverable exception, or as part of a `Reset` request, or when the device looses power. ### `launch` request type ### 1. Start a _debug session_ : i. Connect to the target device and executes a `Reset` request so that a new _target session_ is started ii. Optionally flashes the target device firmware with the binary to be executed ### `attach` request type ### 2. Start a _debug session_ : i. Connect to the target device, but do NOT issue `Reset, so that the existing _target session_ is uninterrupted ### Common behaviour to both `launch` and `attach` request types ### 3. Support all standard debug behaviours, such as "Pause", "Breakpoints", RTT, etc. 4. The `Reset` request will cause `probe-rs`, to restart the target device, and associated _target session_. i. This will honour the value of the `halt_after_reset` flag. ii. The _debug session_ is not affected. 5. The `Disconnect` request in the _debug session_ will ... i. Instruct `probe-rs` to disconnect from the target device. ii. This implicitly ends the _debug session_. iii. The state of the _target session_ is not affected. iv. There are some subtleties depending on `launch` vs `attach` as described in the [MS DAP Specification for the Disconnect Request](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Disconnect) 6. The `Stop` function (`Terminate` request) in the _debug session_ will behave the same as the `disconnect`, except ... i. The _debug session_ will send a `stop` request to `halt` the _target session_ before disconnecting. ii. There are some subtleties depending on `launch` vs `attach` as described in the [MS DAP Specification for the Terminate Request](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Terminate) ### Running `probe-rs-debugger` as a standalone for a VSCode _debug session_ ### In most cases, the VSCode debug extension will take care of automatically launching (and ending) the `probe-rs-debugger` executable to act as the debug adapter for `probe-rs`. It is possible for the user to take control of this, by running `probe-rs-debugger` from the command line, with the following command - `probe-rs-debugger debug --dap --port <any availably TCP/IP port number>` Any VSCode _debug session_ can then attach to the specified <port number> on the server where `probe-rs-debugger` runs, and use the functionality above. 7. Such a _server debug session_ implies the following: i. In order for VSCode to know where to find the debug adapter, the user needs to add the appropriate TCP host IP address and port number to the `launch.json` configuration, by adding the option `"server":"<host address>:<port number>"` _(e.g. `"server":"127.0.0.1:50000"`)_ ii. Such a _server debug session_ will put the management (start and stop) of the `probe-rs-debugger` process completely under control of the user. ### Further reading: ### The above proposal aims to be consistent with the process described in the [VSCode debug docs](https://code.visualstudio.com/docs/editor/debugging) Co-authored-by: JackN <noppej@hotmail.com>
I think the current usage of
launch
andattach
in the debugger is confusing, because it's different from the normal usage of these request types.From what I understand, the probe-rs debugger currently uses
launch
andattach
in relation to the debugger itself, i.e.launch
starts a new debugger process andattach
attaches to an existing debugger process.However, usually
launch
andattach
are used in relation to the program being debugged.Launch
is used when the debugger starts a new instance of the program being debugged,attach
is used to attach to an already running program. See also the VS Code Documentation.Could we change the usage in the probe-rs debugger to be the same? So
attach
would not reset or flash anything, but just attach. Andlaunch
would be used to reset the target, optionally flash the binary, and then debug it out of reset.What do you think?
The text was updated successfully, but these errors were encountered: