Skip to content
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

gdb attach: make auto-continue configurable: introduce "haltOnAttach" #244

Closed
jgrmpf opened this issue Sep 25, 2020 · 4 comments · Fixed by #299
Closed

gdb attach: make auto-continue configurable: introduce "haltOnAttach" #244

jgrmpf opened this issue Sep 25, 2020 · 4 comments · Fixed by #299

Comments

@jgrmpf
Copy link

jgrmpf commented Sep 25, 2020

This is an enhancement request.
In my use-case I am working in Windows, run aarch64 bare-metal software in QEMU started with options "-s -S" -> gdb server, halted at start. I want to source-level debug the remote code using VS code.

When attaching with VS code using Native Debug (and an external aarch64-gdb, remote=true) the code continues immediately after attaching. This is not what I wanted in this case. I wanted that VS code shows me the code location at attach time and does not continue execution automatically.

I found the presumed reason in out/src/gdb.js, GDBDebugSession::attachRequest()
this.needContinue = true;

When changing this line to
this.needContinue = false;
I get exactly the behaviour I want in this special use-case.

Enhancement request: It would be awesome if there would be a launch.js configuration option "haltOnAttach" or something similar I could use for changing the default behaviour (auto-continue) to "halt".

Great piece of software - thanks!
Jörg

@tpilar
Copy link

tpilar commented Dec 10, 2020

This would be really useful to me!

@brandonbraun653
Copy link

I really need this feature as well. Currently I can't debug some very low level startup code running on an embedded target because of this. The auto-continue feature refuses to let me halt at breakpoints or break on attach.

@GitMensch
Copy link
Collaborator

Yes, please add the stopOnEntry launch attribute.
If it is set to true and launch is used: just issue exec-start instead of exec-run. In the case of attach issue exec-interrupt directly after connected. @jgrmpf Do you mind, as the issue starter, to edit the issue title to something like implement stopOnEntry for attach? That's possibly easier to spot.

The auto-continue feature refuses to let me halt at breakpoints or break on attach.

That's strange, it should halt at breakpoints, but obviously this can only work if you attach before this code was executed. It sounds like you want either gdbserver to start the executable (launch gdbserver separately on the target, then attach via this extension and in the autorun commands run yourbinary your options) or use launch via ssh.

Unrelated side note: I suggest Windows users to use gdb-multiarch.exe found in MSYS2, which should theoretically be able to attach and debug any remote (I'm using that to debug GNU/Linux from a Windows Client, others use that for debugging on ARM)... and additionally enjoy a recent GDB (10.x currently), too.

@jgrmpf jgrmpf changed the title gdb attach: make auto-continue configurable gdb attach: make auto-continue configurable: introduce "haltOnAttach" Mar 17, 2021
@jgrmpf
Copy link
Author

jgrmpf commented Mar 17, 2021

@GitMensch: Thanks for looking into it and your proposal. But IMHO "stopOnEntry" would be misleading for the attach use case. I am not very familiar with gdbserver, but you could think of the gdbserver running in an OpenOCD HW debugger which attaches a running HW board as well. It would stop execution at the point where the HW board is running at, not at the "Entry". In my use case I do not want to start it (I think that's anyway not intended when "attaching") but attach to a running debug session. I had QEMU, i.e. the gdbserver configured not to continue on startup ("-S") and I wanted to attach right in that stage.

I added "haltOnAttach" to the title in order to hopefully clarify the enhancement request a little.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants