Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions lib/debug/server_cdp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ def cdp_event args
@obj_map[oid] = [s[:type], frame_id]
}
end
result[:reason] = 'other'

if oid = result.dig(:data, :objectId)
@obj_map[oid] = ['properties']
end
@ui.fire_event 'Debugger.paused', **result
when :evaluate
rs = result.dig(:response, :result)
Expand Down Expand Up @@ -429,14 +432,18 @@ def process_cdp args

case type
when :backtrace
event! :cdp_result, :backtrace, req, {
exception = nil
result = {
reason: 'other',
callFrames: @target_frames.map.with_index{|frame, i|
exception = frame.raised_exception if frame == current_frame && frame.has_raised_exception

path = frame.realpath || frame.path
if path.match /<internal:(.*)>/
path = $1
end

call_frame = {
{
callFrameId: SecureRandom.hex(16),
functionName: frame.name,
functionLocation: {
Expand Down Expand Up @@ -475,9 +482,14 @@ def process_cdp args
type: 'object'
}
}
call_frame
}
}

if exception
result[:data] = evaluate_result exception
result[:reason] = 'exception'
end
event! :cdp_result, :backtrace, req, result
when :evaluate
res = {}
fid, expr = args
Expand Down Expand Up @@ -685,7 +697,9 @@ def variable name, obj
variable_ name, obj, 'number'
when Exception
bt = nil
bt = log.map{|e| " #{e}\n"}.join if log = obj.backtrace
if log = obj.backtrace
bt = log.map{|e| " #{e}\n"}.join
end
variable_ name, obj, 'object', description: "#{obj.inspect}\n#{bt}", subtype: 'error'
else
variable_ name, obj, 'undefined'
Expand Down
2 changes: 1 addition & 1 deletion lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ def enter_postmortem_session exc

frames = exc.instance_variable_get(:@__debugger_postmortem_frames)
@postmortem = true
ThreadClient.current.suspend :postmortem, postmortem_frames: frames
ThreadClient.current.suspend :postmortem, postmortem_frames: frames, postmortem_exc: exc
ensure
@postmortem = false
end
Expand Down
7 changes: 6 additions & 1 deletion lib/debug/thread_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def on_pause
suspend :pause
end

def suspend event, tp = nil, bp: nil, sig: nil, postmortem_frames: nil, replay_frames: nil
def suspend event, tp = nil, bp: nil, sig: nil, postmortem_frames: nil, replay_frames: nil, postmortem_exc: nil
return if management?

@current_frame_index = 0
Expand Down Expand Up @@ -257,6 +257,11 @@ def suspend event, tp = nil, bp: nil, sig: nil, postmortem_frames: nil, replay_f
cf.has_raised_exception = true
cf.raised_exception = bp.last_exc
end

if postmortem_exc
cf.has_raised_exception = true
cf.raised_exception = postmortem_exc
end
end

if event != :pause
Expand Down