@@ -48,7 +48,7 @@ defmodule ElixirLS.Debugger.Server do
48
48
next_id: 1 ,
49
49
output: Output ,
50
50
breakpoints: % { } ,
51
- function_breakpoints: [ ]
51
+ function_breakpoints: % { }
52
52
53
53
defmodule PausedProcess do
54
54
defstruct stack: nil ,
@@ -137,18 +137,7 @@ defmodule ElixirLS.Debugger.Server do
137
137
paused_process = % PausedProcess { stack: Stacktrace . get ( pid ) , ref: ref }
138
138
state = put_in ( state . paused_processes [ pid ] , paused_process )
139
139
140
- reason =
141
- case event do
142
- :breakpoint_reached ->
143
- # Debugger Adapter Protocol requires us to return 'step' | 'breakpoint' | 'exception' | 'pause' | 'entry' | 'goto'
144
- # | 'function breakpoint' | 'data breakpoint' | 'instruction breakpoint'
145
- # but we can't tell what kind of a breakpoint was hit
146
- "breakpoint"
147
-
148
- :paused ->
149
- "pause"
150
- end
151
-
140
+ reason = get_stop_reason ( state , event , paused_process . stack )
152
141
body = % { "reason" => reason , "threadId" => thread_id , "allThreadsStopped" => false }
153
142
Output . send_event ( "stopped" , body )
154
143
state
@@ -272,6 +261,7 @@ defmodule ElixirLS.Debugger.Server do
272
261
set_breakpoints_req ( _ , % { "path" => path } , breakpoints ) ,
273
262
state = % __MODULE__ { }
274
263
) do
264
+ path = Path . absname ( path )
275
265
new_lines = for % { "line" => line } <- breakpoints , do: line
276
266
277
267
new_conditions =
@@ -332,7 +322,7 @@ defmodule ElixirLS.Debugger.Server do
332
322
end
333
323
end
334
324
335
- current = state . function_breakpoints |> Map . new ( )
325
+ current = state . function_breakpoints
336
326
337
327
results =
338
328
for { { m , f , a } , { condition , hit_count } } <- parsed_mfas_conditions ,
@@ -368,7 +358,7 @@ defmodule ElixirLS.Debugger.Server do
368
358
{ { m , f , a } , result }
369
359
)
370
360
371
- successful = for { mfa , { :ok , lines } } <- results , do: { mfa , lines }
361
+ successful = for { mfa , { :ok , lines } } <- results , into: % { } , do: { mfa , lines }
372
362
373
363
state = % {
374
364
state
@@ -1345,4 +1335,27 @@ defmodule ElixirLS.Debugger.Server do
1345
1335
ref = Process . send_after ( self ( ) , :update_threads , 3000 )
1346
1336
% __MODULE__ { state | update_threads_ref: ref }
1347
1337
end
1338
+
1339
+ # Debugger Adapter Protocol stop reasons 'step' | 'breakpoint' | 'exception' | 'pause' | 'entry' | 'goto'
1340
+ # | 'function breakpoint' | 'data breakpoint' | 'instruction breakpoint'
1341
+ defp get_stop_reason ( _state , :paused , _frames ) , do: "pause"
1342
+ defp get_stop_reason ( _state , :breakpoint_reached , [ ] ) , do: "breakpoint"
1343
+
1344
+ defp get_stop_reason ( state = % __MODULE__ { } , :breakpoint_reached , [ first_frame = % Frame { } | _ ] ) do
1345
+ file_breakpoints = Map . get ( state . breakpoints , first_frame . file , [ ] )
1346
+
1347
+ frame_mfa = { first_frame . module , first_frame . function , length ( first_frame . args ) }
1348
+ function_breakpoints = Map . get ( state . function_breakpoints , frame_mfa , [ ] )
1349
+
1350
+ cond do
1351
+ { first_frame . module , first_frame . line } in file_breakpoints ->
1352
+ "breakpoint"
1353
+
1354
+ first_frame . line in function_breakpoints ->
1355
+ "function breakpoint"
1356
+
1357
+ true ->
1358
+ "step"
1359
+ end
1360
+ end
1348
1361
end
0 commit comments