Skip to content

Don't stop at DAP's connection - #640

Closed
st0012 wants to merge 2 commits into
ruby:masterfrom
st0012:fix-#629
Closed

Don't stop at DAP's connection#640
st0012 wants to merge 2 commits into
ruby:masterfrom
st0012:fix-#629

Conversation

@st0012

@st0012st0012 commented May 19, 2022

Copy link
Copy Markdown
Member

Based on the discussion in #629, DAP's connection stoppage can be removed.

Closes#629

jonatan-branting added a commit to jonatan-branting/nvim-dap that referenced this pull request Jun 27, 2022
Without this, attaching to a ruby/debug remote session causes the
debugger to pause at locations which were not intended by the user.
(e.g. rspec internals when debugging a spec, when attaching to a spec
which just started to run)
This is due to a bug (or weird intended behaviour) in ruby/debug, which
is fixed in ruby/debug#640
@ko1

ko1 commented Jul 6, 2022

Copy link
Copy Markdown
Collaborator

I found two lines comment outs are needed to "non-stop" with VSCode attach mode.
Is it intentional or the following patch is your favorite in the scenario on #629 (I guess so)?

diff --git a/lib/debug/server.rb b/lib/debug/server.rb
index 9abb187..abd3752 100644
--- a/lib/debug/server.rb+++ b/lib/debug/server.rb@@ -68,7 +68,7 @@ module DEBUGGER__
} unless already_connected
setup_interrupt do
- pause unless already_connected+ # pause unless already_connected
process
end
diff --git a/lib/debug/server_dap.rb b/lib/debug/server_dap.rb
index 84f954d..0842784 100644
--- a/lib/debug/server_dap.rb+++ b/lib/debug/server_dap.rb@@ -256,7 +256,7 @@ module DEBUGGER__
UI_DAP.local_fs_map_set req.dig('arguments', 'localfs') || req.dig('arguments', 'localfsMap')
when 'attach'
send_response req
- Process.kill(UI_ServerBase::TRAP_SIGNAL, Process.pid)+ # Process.kill(UI_ServerBase::TRAP_SIGNAL, Process.pid)
@is_attach = true
UI_DAP.local_fs_map_set req.dig('arguments', 'localfs') || req.dig('arguments', 'localfsMap')
when 'setBreakpoints'

@st0012

Copy link
Copy Markdown
MemberAuthor

@ko1 Yes, thanks for catching it. I've updated the server_dap part as well.

@st0012

st0012 commented Jul 7, 2022

Copy link
Copy Markdown
MemberAuthor

I think the current code works: DAP connection will not stop at connection, but CUI connection will still stop.
However, after skipping the initial stop, the terminating disconnect request doesn't work anymore:

To reproduce:

  1. Start a Rails server with rdbg -O -n -c -- bundle exec rails
  2. Attach to it from VSCode
  3. Click the disconnect dropdown and click Stop

With Stop (master)

#53409:[>] {"command":"disconnect","arguments":{"restart":false,"terminateDebuggee":true},"type":"request","seq":15}
#53409:[<] {"type":"response","command":"disconnect","request_seq":15,"success":true,"message":"Success","seq":18}
# Debuggee exits

Without Stop (this branch)

#52510:[>] {"command":"disconnect","arguments":{"restart":false,"terminateDebuggee":true},"type":"request","seq":10}
#52510:[<] {"type":"response","command":"disconnect","request_seq":10,"success":true,"message":"Success","seq":11}
#52510:[<] {"type":"event","event":"terminated","seq":12}
DEBUGGER: Disconnected.
# Debuggee doesn't exit

It looks like without the initial stop, this kill! command won't be processed:

@q_msg << 'kill!'

@st0012

Copy link
Copy Markdown
MemberAuthor

Ah it's because commands will only be processed when suspended.

1. Detach raw test does exactly the same thing as the request test.
So it's obsolete and doesn't need to be updated.
2. The current DAP assert_reattach helper assumes the debuggee will be
suspended due to the attaching stop. But it's actually not the case
anymore so we need to manually pause it to make sure it can take
later commands.
@st0012st0012 changed the title Don't stop on remote connection if nonstop is specifiedDon't stop at DAP's connectionJul 7, 2022
@ko1

ko1 commented Jul 8, 2022

Copy link
Copy Markdown
Collaborator

fixed by #688

@ko1ko1 closed this Jul 8, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected stoppage on remote debugging connection

2 participants

@st0012@ko1