Skip to content

Commit 2988e38

Browse files
st0012ono-maxk0kubunandyw8jeremyevans
authored
Merge v1.7.2 (#9)
* DAP: use Object#__send__ to avoid name conflicts * DAP: allow custom request extension in Session class * Fix bug that "trace line" does not work after stopping trace once * Increase timeout in debug_code * Fix warning about unused variable * Avoid memberless Struct Related to Ruby bug 19416. * Remove redundant raw detach test The test's subject is the `disconnect` request with `restart: false, terminateDebuggee: <true|false>` arguments, which has been covered by the tests in `disconnect_dap_test.rb`. So this test case has become obsolete. Co-authored-by: Andy Waite <[email protected]> * Always propagate keyword arguments in WebSocketServer * Fix `::Process::daemon` patch As discussed here: ruby@699a31e#r94469355 * Add test * Use local variables * Add test for info consts with an expression Co-authored-by: Andy Waite <[email protected]> * Fix typo in README * ⬆️ Update ci ruby versions * ⏪ Revert Ruby 2.6 * ✏️ Fix typo * CDP: Support evaluating expression on non-current frame * CDP: support reattaching in Chrome DevTools Close ruby#800 * Improved stability for chrome debugging - Display the greeting message regardless of the status of invocation of chrome. This allows coming back to the debugger on a new tab when the window process by `UI_CDP.run_new_chrome` is killed. - Handle `Errno::ESRCH` in `UI_CDP.cleanup_reader`. When the process by `UI_CDP.run_new_chrome` is killed, re-killing it breaks your debugging session and in turn the "debugee". * Make `UI_ServerBase#puts` to behave like `STDERR#puts` `UI_ServerBase#greeting` calls `#puts` with no arguments, this breaks reconnections to the debugger. * Handle not existing $FILENAME in `Session#process_protocol_request` `Session#process_protocol_request` gracefully handles `Errno::ENOENT` when `eval`-ing `$FILENAME`, and it doens't exist. * free terminated ThreadClients fix ruby#899 * DAP: use Mutex when sending response When debug.gem tries to send response from multiple threads, the socket connection is closed. I confirmed this bug when using custom request from vscode-rdbg * Make sure to fail when remote debuggee does not exit after scenarios Because Errno::EPIPE is rescued while sending message to socket, protocol_test_case_test.rb does not pass. protocol_test_case_test.rb had been passed because ReaderThreadError was occurred and the debuggee process was still alive. Here is a scenario. After closing socket, terminated event was sent. However socket was closed, so debuggee process raised Errno::EPIPE and debugggee process was still alive. The test framework detected the status and failed. Thus I fixed so that the test framework does not kill the debuggee process unexpectedly. * Alias Session send methods in WebSocketServer Methods ``respond``, ``respond_fail`` and ``fire_event`` can be aliased to ``send_response``, ``send_fail_response`` and ``send_event``, respectively. * Fix timing bug on session_server creation `@session_server` should be assigned at first. `@session_server = Thread.current` in the session thread does not work because the creator thread can access to `@session_server` before it. * Fix useless assignments Found by running `rubocop --only=Lint/UselessAssignment` * Remove Tracer#puts as it's not used * Avoid raising debuggee not finished error if assertions failed When assertions failed, we should let the AssertionFailedError surface and not calling flunk so we can get correct failure messages. * Fix test builder * DAP: allow custom request extension in ThreadClient class * DAP: introduce Rdbg Record Inspector * Revert "DAP: introduce Rdbg Record Inspector" This reverts commit e29faba. * relax authority check to pass on the Windows. fix ruby/vscode-rdbg#169 * Add test for global variable support in DAP and CDP * Add test for instance variable ordering in DAP PR ruby#806 sorts instance variables by name before returning them. This commit adds a test that verifies this functionality under the DAP protocol. * Fix incorrect method name * dap/cdp_result -> protocol_result From ThreadClient it retunrs :dap_result or :cdp_result to the SESSION. This patch renames it to `:protocol_result` and it will be handled by `process_protocol_result`. * separate 'test_console' and 'test_test' * `test_all` should also run `test_test` * Omit slow tests for healty CI * add workflow * DAP: rename the method name of custom request Follow up for ruby#939 Change the name from "request_..." to "custom_dap_request_" in UI_DAP and ThreadClient for consistency * DAP: support custom request in session class UI_DAP -> Session: custom_dap_request_... Session -> ThreadClient: custom_dap_request_event_... Add "request_event" prefix to clarify it is a response (not Events in DAP) * Add test for DAP's command execution through evaluate request * Enqueue DAP's evaluate command right away * DAP: echo back the given command on `, debug_command` form. * remain breakpoints on reloaded files Breakpoints should be remained on reloaded files. To make sure maintaining loaded file names. fix ruby#870 * Use better approach to signal remote process' exit status 1. `remote_info.failed_process` stores symbol but we only use the value's presence to check if the process is force-killed. 2. The force-killed status is directly controlled by `kill_safely` through `kill_remote_debuggee`, which is directly called right before we check the status with `remote_info.failed_process`. Combining the two, we can just let `kill_safely` and `kill_remote_debuggee` to return the force-killed status and not storing it in `remote_info`, which already contains a bunch of information. This also eliminates the need to pass `test_info` to `kill_safely`, which makes related code easier to understand and maintain. * Remove unused failed_process attribute * Add "result" as an argument to custom_dap_request_event method The generated result in ThreadClient is passed as "result". We usually use it when returning responses to VS Code in Session class * restart all threads on eval When a thread keeps a lock, and REPL runs a code which needs the lock, other threads should make a progress to release the lock. fix ruby#877 * CDP: support remote debugging in different environment From investigation by @ko1-san, the path to set breakpoints seems to be sent in "url" field when debugging in different environment such as WSL(running debuggee) and Windows(running Chrome DevTools). I supported "url" field in this PR. * `-v` prints version and do something Without this patch, `rdbg -v target.rb` prints version and terminates the process. With this pach, `-v` prints version and starts debugging for `target.rb`. If no filename is given, terminates the process. * v1.7.2 * Revert "Workaround VS Code's breakpoint skipping issue" This reverts commit 4313d91. * Revert "Avoid locking all threads on debugger suspension" This reverts commit 1e0f45c. * Revert "Always insert preset commands when executing commands from DAP (#4)" This reverts commit 8eea4c9. --------- Co-authored-by: Naoto Ono <[email protected]> Co-authored-by: Takashi Kokubun <[email protected]> Co-authored-by: Andy Waite <[email protected]> Co-authored-by: Jeremy Evans <[email protected]> Co-authored-by: Andy Waite <[email protected]> Co-authored-by: Mau Magnaguagno <[email protected]> Co-authored-by: Vinicius Stock <[email protected]> Co-authored-by: yamashush <[email protected]> Co-authored-by: Jose D. Gomez R <[email protected]> Co-authored-by: Koichi Sasada <[email protected]> Co-authored-by: Emily Samp <[email protected]>
1 parent 8eea4c9 commit 2988e38

31 files changed

+621
-251
lines changed

.github/workflows/test_test.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7+
8+
name: TestTestFramework
9+
10+
on:
11+
push:
12+
branches: [ master ]
13+
pull_request:
14+
branches: [ master ]
15+
16+
jobs:
17+
test:
18+
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
ruby-version: ['3.0', '3.1', '3.2', 'head', 'debug']
25+
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: Set up Ruby
29+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
30+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
31+
uses: ruby/setup-ruby@v1
32+
with:
33+
ruby-version: ${{ matrix.ruby-version }}
34+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
35+
- name: Run tests
36+
run: |
37+
bundle exec rake clobber
38+
bundle exec rake compile
39+
bundle exec rake test_test

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ If the file already exists, **only method** will be added to it.
149149
```ruby
150150
# frozen_string_literal: true
151151

152-
require_relative '../support/test_case'
152+
require_relative '../support/console_test_case'
153153

154154
module DEBUGGER__
155-
class FooTest < TestCase
155+
class FooTest < ConsoleTestCase
156156
def program
157157
<<~RUBY
158158
1| module Foo

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ New debug.rb has several advantages:
2626
* Support threads (almost done) and ractors (TODO).
2727
* Support suspending and entering to the console debugging with `Ctrl-C` at most of timing.
2828
* Show parameters on backtrace command.
29-
* Support recording & reply debugging.
29+
* Support recording & replay debugging.
3030

3131
# Installation
3232

Rakefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ task :check_readme do
3535
end
3636
end
3737

38+
desc "Run debug.gem test-framework tests"
39+
Rake::TestTask.new(:test_test) do |t|
40+
t.test_files = FileList["test/support/*_test.rb"]
41+
end
42+
3843
desc "Run all debugger console related tests"
3944
Rake::TestTask.new(:test_console) do |t|
40-
t.test_files = FileList["test/console/*_test.rb", "test/support/*_test.rb"]
45+
t.test_files = FileList["test/console/*_test.rb"]
4146
end
4247

4348
desc "Run all debugger protocols (CAP & DAP) related tests"
@@ -49,4 +54,4 @@ task test: 'test_console' do
4954
warn '`rake test` doesn\'t run protocol tests. Use `rake test_all` to test all.'
5055
end
5156

52-
task test_all: [:test_console, :test_protocol]
57+
task test_all: [:test_test, :test_console, :test_protocol]

lib/debug/breakpoint.rb

+6-8
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ def skip_path?(path)
101101
def generate_label(name)
102102
colorize(" BP - #{name} ", [:YELLOW, :BOLD, :REVERSE])
103103
end
104-
105-
def pending_until_load?
106-
false
107-
end
108104
end
109105

110106
if RUBY_VERSION.to_f <= 2.7
@@ -163,10 +159,6 @@ def initialize path, line, cond: nil, oneshot: false, hook_call: true, command:
163159
@pending = !@iseq
164160
end
165161

166-
def pending_until_load?
167-
@pending
168-
end
169-
170162
def setup
171163
return unless @type
172164

@@ -207,6 +199,8 @@ def activate iseq, event, line
207199
if @pending && !@oneshot
208200
DEBUGGER__.info "#{self} is activated."
209201
end
202+
203+
@pending = false
210204
end
211205

212206
def activate_exact iseq, events, line
@@ -299,6 +293,10 @@ def to_s
299293
def inspect
300294
"<#{self.class.name} #{self.to_s}>"
301295
end
296+
297+
def path_is? path
298+
DEBUGGER__.compare_path(@path, path)
299+
end
302300
end
303301

304302
class CatchBreakpoint < Breakpoint

lib/debug/config.rb

+23-2
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ def self.parse_argv argv
265265
require 'optparse'
266266
require_relative 'version'
267267

268+
have_shown_version = false
269+
268270
opt = OptionParser.new do |o|
269271
o.banner = "#{$0} [options] -- [debuggee options]"
270272
o.separator ''
@@ -372,6 +374,16 @@ def self.parse_argv argv
372374
o.separator ''
373375
o.separator 'Other options:'
374376

377+
o.on('-v', 'Show version number') do
378+
puts o.ver
379+
have_shown_version = true
380+
end
381+
382+
o.on('--version', 'Show version number and exit') do
383+
puts o.ver
384+
exit
385+
end
386+
375387
o.on("-h", "--help", "Print help") do
376388
puts o
377389
exit
@@ -395,6 +407,14 @@ def self.parse_argv argv
395407

396408
opt.parse!(argv)
397409

410+
if argv.empty?
411+
case
412+
when have_shown_version && config[:mode] == :start
413+
pp config
414+
exit
415+
end
416+
end
417+
398418
config
399419
end
400420

@@ -425,8 +445,9 @@ def self.check_dir_authority path
425445
unless (dir_uid = fs.uid) == (uid = Process.uid)
426446
raise "#{path} uid is #{dir_uid}, but Process.uid is #{uid}"
427447
end
428-
unless (dir_mode = fs.mode) == 040700 # 4: dir, 7:rwx
429-
raise "#{path}'s mode is #{dir_mode.to_s(8)} (should be 040700)"
448+
449+
if fs.world_writable? && !fs.sticky?
450+
raise "#{path} is world writable but not sticky"
430451
end
431452

432453
path

lib/debug/server.rb

+5-6
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,13 @@ def chrome_setup
406406
require_relative 'server_cdp'
407407

408408
@uuid = SecureRandom.uuid
409-
unless @chrome_pid = UI_CDP.setup_chrome(@local_addr.inspect_sockaddr, @uuid)
410-
DEBUGGER__.warn <<~EOS
411-
With Chrome browser, type the following URL in the address-bar:
409+
@chrome_pid = UI_CDP.setup_chrome(@local_addr.inspect_sockaddr, @uuid)
410+
DEBUGGER__.warn <<~EOS
411+
With Chrome browser, type the following URL in the address-bar:
412412
413-
devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=#{@local_addr.inspect_sockaddr}/#{@uuid}
413+
devtools://devtools/bundled/inspector.html?v8only=true&panel=sources&ws=#{@local_addr.inspect_sockaddr}/#{@uuid}
414414
415-
EOS
416-
end
415+
EOS
417416
end
418417

419418
def accept

0 commit comments

Comments
 (0)