debug 1.3.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7316cec0879fc91787183e28cad0bbc4a1f819eb7d3ee4530a28b2ee173877e9
4
- data.tar.gz: e37f36b72d3aec5fed4559c78474358c487e3c1748a732984a42331c2a96191a
3
+ metadata.gz: d2f3adfa33baa3d7ef0a8ff1924d4d148be909f8cbdfc1992efda7e4ef564a17
4
+ data.tar.gz: 43085e7bec187d698d42bf7a4fc7c3ee2f4cde387cf411b2648411dc6cbb1721
5
5
  SHA512:
6
- metadata.gz: 51ba70e0a9b9c73170080a0e428edf178aa98aceb409e8d4b69ea16eb36796467852c07ba38c103cbac8f7e0861119d40d1e6272d5d002ac472ec2b92801a5b5
7
- data.tar.gz: 8e02dc629e83151c4a1b744ed3dcd9262e57d1c6dad012bfa1f42410636f9f467a189aa3579abad419e443c943c39930729305311456b06c4fc0a562ef49827c
6
+ metadata.gz: 5bafcaeeb661378a3696968655cfc9b24aadb6c0ada385d143406472db4cc1a51d55bb460431ef9679d8e6ffe846c269f731335380999256565b2d259139f2d9
7
+ data.tar.gz: 961d6a453a4f117af9e056658d31afc39e173668f32eb1745f0bdad842c4891a2b6bff0bfec45d6e17fc94108da3ac4a5274118a4f0213ae0a2a5a181de89f99
data/lib/debug/color.rb CHANGED
@@ -79,7 +79,7 @@ module DEBUGGER__
79
79
  end
80
80
 
81
81
  if defined? IRB::Color.colorize_code
82
- if SUPPORT_COLORABLE_OPTION
82
+ if defined? SUPPORT_COLORABLE_OPTION
83
83
  def colorize_code code
84
84
  IRB::Color.colorize_code(code, colorable: true)
85
85
  end
@@ -96,6 +96,7 @@ module DEBUGGER__
96
96
 
97
97
  def process
98
98
  bps = []
99
+ @src_map = {}
99
100
  loop do
100
101
  req = @web_sock.extract_data
101
102
  $stderr.puts '[>]' + req.inspect if SHOW_PROTOCOL
@@ -106,6 +107,7 @@ module DEBUGGER__
106
107
  when 'Page.getResourceTree'
107
108
  abs = File.absolute_path($0)
108
109
  src = File.read(abs)
110
+ @src_map[abs] = src
109
111
  send_response req,
110
112
  frameTree: {
111
113
  frame: {
@@ -134,7 +136,7 @@ module DEBUGGER__
134
136
  }
135
137
  when 'Debugger.getScriptSource'
136
138
  s_id = req.dig('params', 'scriptId')
137
- src = File.read(s_id)
139
+ src = get_source_code s_id
138
140
  send_response req, scriptSource: src
139
141
  @q_msg << req
140
142
  when 'Page.startScreencast', 'Emulation.setTouchEmulationEnabled', 'Emulation.setEmitTouchEventsForMouse',
@@ -168,6 +170,9 @@ module DEBUGGER__
168
170
  when 'Debugger.getPossibleBreakpoints'
169
171
  s_id = req.dig('params', 'start', 'scriptId')
170
172
  line = req.dig('params', 'start', 'lineNumber')
173
+ src = get_source_code s_id
174
+ end_line = src.count("\n")
175
+ line = end_line if line > end_line
171
176
  send_response req,
172
177
  locations: [
173
178
  { scriptId: s_id,
@@ -178,6 +183,9 @@ module DEBUGGER__
178
183
  line = req.dig('params', 'lineNumber')
179
184
  path = req.dig('params', 'url').match('http://debuggee(.*)')[1]
180
185
  cond = req.dig('params', 'condition')
186
+ src = get_source_code path
187
+ end_line = src.count("\n")
188
+ line = end_line if line > end_line
181
189
  if cond != ''
182
190
  bps << SESSION.add_line_breakpoint(path, line + 1, cond: cond)
183
191
  else
@@ -200,6 +208,14 @@ module DEBUGGER__
200
208
  end
201
209
  end
202
210
 
211
+ def get_source_code path
212
+ return @src_map[path] if @src_map[path]
213
+
214
+ src = File.read(path)
215
+ @src_map[path] = src
216
+ src
217
+ end
218
+
203
219
  ## Called by the SESSION thread
204
220
 
205
221
  def readline prompt
@@ -491,7 +491,7 @@ module DEBUGGER__
491
491
  case type
492
492
  when :backtrace
493
493
  event! :dap_result, :backtrace, req, {
494
- stackFrames: @target_frames.map.with_index{|frame, i|
494
+ stackFrames: @target_frames.map.{|frame|
495
495
  path = frame.realpath || frame.path
496
496
  ref = frame.file_lines unless path && File.exist?(path)
497
497
 
data/lib/debug/session.rb CHANGED
@@ -1555,6 +1555,36 @@ module DEBUGGER__
1555
1555
  @postmortem = false
1556
1556
  end
1557
1557
 
1558
+ def capture_exception_frames *exclude_path
1559
+ postmortem_hook = TracePoint.new(:raise){|tp|
1560
+ exc = tp.raised_exception
1561
+ frames = DEBUGGER__.capture_frames(__dir__)
1562
+
1563
+ exclude_path.each{|ex|
1564
+ if Regexp === ex
1565
+ frames.delete_if{|e| ex =~ e.path}
1566
+ else
1567
+ frames.delete_if{|e| e.path.start_with? ex.to_s}
1568
+ end
1569
+ }
1570
+ exc.instance_variable_set(:@__debugger_postmortem_frames, frames)
1571
+ }
1572
+ postmortem_hook.enable
1573
+
1574
+ begin
1575
+ yield
1576
+ nil
1577
+ rescue Exception => e
1578
+ if e.instance_variable_defined? :@__debugger_postmortem_frames
1579
+ e
1580
+ else
1581
+ raise
1582
+ end
1583
+ ensure
1584
+ postmortem_hook.disable
1585
+ end
1586
+ end
1587
+
1558
1588
  def postmortem=(is_enable)
1559
1589
  if is_enable
1560
1590
  unless @postmortem_hook
data/lib/debug/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DEBUGGER__
4
- VERSION = "1.3.2"
4
+ VERSION = "1.3.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: irb