Skip to content

Commit 0a20dfd

Browse files
Merge branch 'topic/dap_remove_delete' into 'master'
Do not intercept 'delete' commands in DAP See merge request eng/ide/gnatstudio!478
2 parents c3b9a0e + 8ce5b61 commit 0a20dfd

File tree

5 files changed

+37
-88
lines changed

5 files changed

+37
-88
lines changed

dap/src/dap-clients-breakpoint_managers.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ package body DAP.Clients.Breakpoint_Managers is
4545
("DAP.CLIENTS.BREAKPOINT_MANAGER");
4646

4747
type On_DAP_Request_Processed
48-
is new GPS.Kernel.Hooks.Dap_Message_Hooks_Function with record
48+
is new GPS.Kernel.Hooks.Dap_Method_Hooks_Function with record
4949
Manager : Breakpoint_Manager_Access;
5050
end record;
5151
overriding procedure Execute

dap/src/dap-clients.adb

Lines changed: 4 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ with VSS.Regular_Expressions;
4141
with VSS.Stream_Element_Vectors.Conversions;
4242
with VSS.Strings; use VSS.Strings;
4343
with VSS.Strings.Conversions;
44-
with VSS.Strings.Cursors.Iterators.Characters;
4544
with VSS.Text_Streams.Memory_UTF8_Input;
4645
with VSS.Text_Streams.Memory_UTF8_Output;
4746

@@ -136,18 +135,6 @@ package body DAP.Clients is
136135
& "(?:\s+(.+)?)?$");
137136
-- to catch breakpoint command
138137

139-
Is_Delete_Pattern : constant VSS.Regular_Expressions.
140-
Regular_Expression := VSS.Regular_Expressions.To_Regular_Expression
141-
("^\s*(delete|del|d)(?:\s+(.+)?)?$");
142-
-- to catch delete breakpoint(s) command
143-
144-
Bp_Delete_Details_Idx : constant := 2;
145-
146-
Ids_Pattern : constant VSS.Regular_Expressions.
147-
Regular_Expression := VSS.Regular_Expressions.To_Regular_Expression
148-
("((\d+)\s*-\s*(\d+)|\d+)");
149-
-- to get all (breakpoints) ids or range
150-
151138
Is_Ignore_Pattern : constant VSS.Regular_Expressions.
152139
Regular_Expression := VSS.Regular_Expressions.To_Regular_Expression
153140
("^\s*(?:ignore)\s+(\d+)\s+(\d+)");
@@ -1390,6 +1377,10 @@ package body DAP.Clients is
13901377
if Self.Status /= Terminating then
13911378
Self.Process_Event (Reader, Event);
13921379
end if;
1380+
1381+
GPS.Kernel.Hooks.Dap_Event_Processed_Hook.Run
1382+
(Kernel => Self.Kernel,
1383+
Event => VSS.Strings.Conversions.To_UTF_8_String (Event));
13931384
end if;
13941385

13951386
exception
@@ -1655,10 +1646,8 @@ package body DAP.Clients is
16551646
VSS_Cmd : Virtual_String;
16561647
Details : Virtual_String;
16571648
Level : Integer;
1658-
Ids : Breakpoint_Identifier_Lists.List;
16591649

16601650
procedure Add_BP_For_Offset;
1661-
procedure Check_Delete_Command;
16621651
procedure Check_Ignore_Command;
16631652
function Value
16641653
(S : VSS.Strings.Virtual_String) return Integer;
@@ -1690,72 +1679,6 @@ package body DAP.Clients is
16901679
Condition => Details_Match.Captured (Bp_Condition_Idx));
16911680
end Add_BP_For_Offset;
16921681

1693-
--------------------------
1694-
-- Check_Delete_Command --
1695-
--------------------------
1696-
1697-
procedure Check_Delete_Command is
1698-
begin
1699-
-- Is the `delete` command
1700-
Matched := Is_Delete_Pattern.Match (VSS_Cmd);
1701-
1702-
if Matched.Has_Match then
1703-
if Self.Breakpoints = null then
1704-
null;
1705-
1706-
elsif Matched.Has_Capture (Bp_Delete_Details_Idx) then
1707-
-- Get breakpoint ids or ranges
1708-
Details := Matched.Captured (Bp_Delete_Details_Idx);
1709-
1710-
declare
1711-
From : VSS.Strings.Cursors.Iterators.Characters.
1712-
Character_Iterator := Details.Before_First_Character;
1713-
begin
1714-
while From.Forward loop
1715-
Details_Match := Ids_Pattern.Match (Details, From);
1716-
exit when not Details_Match.Has_Match;
1717-
1718-
if Details_Match.Has_Capture (2) then
1719-
-- Range match found:
1720-
-- 1: 1 .. 3 => '2-3'
1721-
-- 2: 1 .. 1 => '2'
1722-
-- 3: 3 .. 3 => '3'
1723-
1724-
for Index in
1725-
Value (Details_Match.Captured (1)) ..
1726-
Value (Details_Match.Captured (2))
1727-
loop
1728-
Ids.Append (Breakpoint_Identifier (Index));
1729-
end loop;
1730-
1731-
else
1732-
-- Id match found:
1733-
-- 1: 1 .. 1 => '4'
1734-
1735-
Ids.Append
1736-
(Breakpoint_Identifier
1737-
(Value (Details_Match.Captured (1))));
1738-
end if;
1739-
1740-
From.Set_At (Details_Match.Last_Marker (1));
1741-
end loop;
1742-
1743-
if not Ids.Is_Empty then
1744-
Self.Breakpoints.Remove_Breakpoints (Ids);
1745-
end if;
1746-
end;
1747-
1748-
else
1749-
-- `delete` command does not have ids,
1750-
-- remove all breakpoints.
1751-
Self.Breakpoints.Remove_All_Breakpoints;
1752-
end if;
1753-
1754-
-- Clear the command to signal that the command is processed
1755-
VSS_Cmd.Clear;
1756-
end if;
1757-
end Check_Delete_Command;
1758-
17591682
--------------------------
17601683
-- Check_Ignore_Command --
17611684
--------------------------
@@ -1941,10 +1864,6 @@ package body DAP.Clients is
19411864
VSS_Cmd.Clear;
19421865
end if;
19431866

1944-
if not VSS_Cmd.Is_Empty then -- Command is not processed yet
1945-
Check_Delete_Command;
1946-
end if;
1947-
19481867
if not VSS_Cmd.Is_Empty then -- Command is not processed yet
19491868
Check_Ignore_Command;
19501869
end if;

docs/users_guide/GPS/generated_hooks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ def DAP_debugger_unloaded(name,id):
2222
2323
"""
2424

25+
# DAP_event_processed = 'DAP_event_processed'
26+
def DAP_event_processed(name,event):
27+
"""
28+
Emitted when an event received from the DAP server has been processed.
29+
30+
:param str name:
31+
:param str event:
32+
33+
"""
34+
2535
# DAP_response_processed = 'DAP_response_processed'
2636
def DAP_response_processed(name,method):
2737
"""

kernel/src/hooks.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,14 @@ def __init__(self, name, type, descr=''):
545545
Param('contents', 'String'),
546546
Param('method', 'String')]),
547547

548-
'DAP_message_hooks': Hook_Type(
548+
'DAP_method_hooks': Hook_Type(
549549
[Param('name', '__hookname__'),
550550
Param('method', 'String')]),
551551

552+
'DAP_event_hooks': Hook_Type(
553+
[Param('name', '__hookname__'),
554+
Param('event', 'String')]),
555+
552556
'DAP_id_hooks': Hook_Type(
553557
[Param('name', '__hookname__'),
554558
Param('id', 'Integer')])
@@ -1119,10 +1123,15 @@ def on_file_changed(hook, file):
11191123
Emitted when the filter of a view has changed.'''),
11201124

11211125
Hook('DAP_response_processed',
1122-
'DAP_message_hooks',
1126+
'DAP_method_hooks',
11231127
descr='''
11241128
Emitted when a response from the DAP server has been processed.'''),
11251129

1130+
Hook('DAP_event_processed',
1131+
'DAP_event_hooks',
1132+
descr='''
1133+
Emitted when an event received from the DAP server has been processed.'''),
1134+
11261135
Hook('DAP_debugger_unloaded',
11271136
'DAP_id_hooks',
11281137
descr='''

share/support/core/gs_utils/internal/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ def wait_DAP_server(method=""):
251251
if m == method:
252252
break
253253

254+
@workflows.run_as_workflow
255+
def wait_DAP_event(event=""):
256+
"""
257+
Wait until the given DAP event has been processed by GNAT Studio.
258+
"""
259+
while True:
260+
(e) = yield hook("DAP_event_processed")
261+
262+
if e == event:
263+
break
264+
254265

255266
@workflows.run_as_workflow
256267
def wait_until_not_busy(debugger, t=100):

0 commit comments

Comments
 (0)