Skip to content

Commit 877f707

Browse files
BoulangerBoulanger
authored andcommitted
Prevent the Debug views from being opened in Default perspective
When: - Changing an advance pref - Computing its action filter - Launching its action - Recieving a response after closing it Add a test. Close eng/ide/gnatstudio#285
1 parent e90a569 commit 877f707

File tree

9 files changed

+86
-16
lines changed

9 files changed

+86
-16
lines changed

dap/src/modules/dap-views-assembly.adb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ package body DAP.Views.Assembly is
957957
pragma Unreferenced (New_Request);
958958

959959
View : constant Assembly_MDI := Assembly_MDI_Views.Retrieve_View
960-
(Self.Kernel);
960+
(Self.Kernel, True);
961961
S : Disassemble_Elements;
962962

963963
-- Format_Opcodes --
@@ -1360,7 +1360,7 @@ package body DAP.Views.Assembly is
13601360
is
13611361
pragma Unreferenced (Self);
13621362
View : constant Assembly_View :=
1363-
Assembly_View (Assembly_MDI_Views.Retrieve_View (Kernel));
1363+
Assembly_View (Assembly_MDI_Views.Retrieve_View (Kernel, True));
13641364
begin
13651365
if View /= null then
13661366
View.Highlight (False);
@@ -1378,7 +1378,7 @@ package body DAP.Views.Assembly is
13781378
is
13791379
pragma Unreferenced (Self);
13801380
View : constant Assembly_View := Assembly_View
1381-
(Assembly_MDI_Views.Retrieve_View (Kernel));
1381+
(Assembly_MDI_Views.Retrieve_View (Kernel, True));
13821382
begin
13831383
if View /= null then
13841384
View.Highlight (False);

dap/src/modules/dap-views-call_stack.adb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ package body DAP.Views.Call_Stack is
238238
use type DAP.Clients.DAP_Client_Access;
239239

240240
View : constant Call_Stack :=
241-
CS_MDI_Views.Retrieve_View (Get_Kernel (Context));
241+
CS_MDI_Views.Retrieve_View
242+
(Get_Kernel (Context), Visible_Only => True);
242243
begin
243244
if View = null then
244245
return False;
@@ -294,9 +295,11 @@ package body DAP.Views.Call_Stack is
294295
or else Pref = Preference (Show_Location)
295296
or else Pref = Preference (Show_Address)
296297
then
297-
View := CS_MDI_Views.Retrieve_View (Kernel);
298-
Update_Columns_Visibility (View);
299-
Update (View);
298+
View := CS_MDI_Views.Retrieve_View (Kernel, Visible_Only => True);
299+
if View /= null then
300+
Update_Columns_Visibility (View);
301+
Update (View);
302+
end if;
300303
end if;
301304
end Execute;
302305

@@ -314,7 +317,7 @@ package body DAP.Views.Call_Stack is
314317

315318
Kernel : constant Kernel_Handle := Get_Kernel (Context.Context);
316319
View : constant Call_Stack :=
317-
Call_Stack (CS_MDI_Views.Retrieve_View (Kernel));
320+
Call_Stack (CS_MDI_Views.Retrieve_View (Kernel, Visible_Only => True));
318321
Client : DAP.Clients.DAP_Client_Access;
319322
begin
320323
if View /= null then
@@ -502,7 +505,7 @@ package body DAP.Views.Call_Stack is
502505
Client : not null access DAP.Clients.DAP_Client'Class)
503506
is
504507
View : constant Call_Stack :=
505-
Call_Stack (CS_MDI_Views.Retrieve_View (Kernel));
508+
Call_Stack (CS_MDI_Views.Retrieve_View (Kernel, Visible_Only => True));
506509
begin
507510
if View /= null
508511
and then Get_Client (View) = Client

dap/src/modules/dap-views-consoles.adb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ package body DAP.Views.Consoles is
554554
is
555555
pragma Unreferenced (Command);
556556
View : constant Console_MDI :=
557-
Console_MDI_Views.Retrieve_View (Get_Kernel (Context.Context));
557+
Console_MDI_Views.Retrieve_View (Get_Kernel (Context.Context), True);
558558
begin
559559
if View /= null then
560560
View.Console.Clear;

dap/src/modules/dap-views.adb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ package body DAP.Views is
189189
is
190190
pragma Unreferenced (Self);
191191

192-
V : constant access Formal_View_Record'Class :=
193-
Formal_Views.Retrieve_View (Kernel);
192+
V : constant access Formal_View_Record'Class :=
193+
Formal_Views.Retrieve_View (Kernel, True);
194194
begin
195195

196196
if V /= null then
@@ -210,7 +210,7 @@ package body DAP.Views is
210210
pragma Unreferenced (Self);
211211

212212
V : constant access Formal_View_Record'Class :=
213-
Formal_Views.Retrieve_View (Kernel);
213+
Formal_Views.Retrieve_View (Kernel, True);
214214
begin
215215
if V /= null then
216216
V.On_Process_Terminated;
@@ -227,7 +227,7 @@ package body DAP.Views is
227227
Debugger : access GPS.Debuggers.Base_Visual_Debugger'Class)
228228
is
229229
V : constant access Formal_View_Record'Class :=
230-
Formal_Views.Retrieve_View (Kernel);
230+
Formal_Views.Retrieve_View (Kernel, True);
231231
begin
232232

233233
if V /= null and then V.Get_Client /= null then
@@ -247,8 +247,8 @@ package body DAP.Views is
247247
is
248248
pragma Unreferenced (Self);
249249

250-
V : constant access Formal_View_Record'Class :=
251-
Formal_Views.Retrieve_View (Kernel);
250+
V : constant access Formal_View_Record'Class :=
251+
Formal_Views.Retrieve_View (Kernel, True);
252252
begin
253253
if V /= null then
254254
V.On_Location_Changed;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
project Default is
2+
3+
package Compiler is
4+
for Switches ("Ada") use ("-g");
5+
end Compiler;
6+
7+
for Main use ("main.adb");
8+
9+
end Default;
10+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
procedure Main is
2+
begin
3+
null;
4+
end Main;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
v="$(gdb -v | head -n 1 | cut -c 14-16)"
2+
if [ $v -ge 15 ]
3+
then
4+
$GPS -Pdefault --load=test.py --traceon=GPS.DEBUGGING.DAP_MODULE --traceon=MODULE.Debugger_DAP --traceoff=GPS.DAP.VARIABLES
5+
fi
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
Test that Debug views are closed when exiting the debugger session.
3+
"""
4+
import GPS
5+
from gs_utils.internal.utils import *
6+
7+
8+
DEBUG_VIEWS = ["Call Stack", "Assembly", "Threads", "Variables"]
9+
10+
11+
def check_debug_view_visibility(visible, msg):
12+
cpt = 0
13+
for child in GPS.MDI.children():
14+
if child.name() in DEBUG_VIEWS:
15+
gps_assert(
16+
child.pywidget().get_parent().props.visible
17+
and child.pywidget().get_parent().get_parent().props.visible,
18+
visible,
19+
child.name() + " " + msg)
20+
cpt += 1
21+
if visible:
22+
gps_assert(cpt, len(DEBUG_VIEWS), "Missing views %s" % msg)
23+
24+
25+
@run_test_driver
26+
def test_driver():
27+
GPS.execute_action("Build & Debug Number 1")
28+
yield hook("debugger_started")
29+
30+
# Open the views
31+
for view in DEBUG_VIEWS:
32+
GPS.execute_action("/Debug/Data/%s" % view)
33+
34+
# Start the debugger with the dialog without setting any text
35+
debug = GPS.Debugger.get()
36+
debug.send("run")
37+
yield wait_until_not_busy(debug)
38+
check_debug_view_visibility(
39+
True,
40+
"should be opened")
41+
42+
debug.send("quit")
43+
# Wait for context and filter to be recomputed
44+
yield timeout(3000)
45+
check_debug_view_visibility(
46+
False,
47+
"should be hidden after quitting the debugger")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'dap.gs.285.debug_views_in_default_perspective'

0 commit comments

Comments
 (0)