Skip to content

Commit e1e2c85

Browse files
committed
Merge branch 'gs_303' into 'master'
Corrections for the DAP variables view See merge request eng/ide/gnatstudio!854
2 parents 4cab018 + e2734d5 commit e1e2c85

File tree

6 files changed

+138
-3
lines changed

6 files changed

+138
-3
lines changed

dap/src/dap-clients-variables-variables.adb

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,23 @@ package body DAP.Clients.Variables.Variables is
9292

9393
-- Add childs to Id
9494
if Result.a_body.variables.Length = 0 then
95-
Var.Scopes.Append_Child (C, Empty_Variable_Data);
95+
-- GDB did not return nested elements, for example:
96+
-- {"request_seq": 17, "type": "response", "command": "variables",
97+
-- "success": true, "body": {"variables": []}, "seq": 146}
98+
-- so display "[]" as a value
99+
Var.Scopes.Append_Child
100+
(C,
101+
(Non_Specified,
102+
(name => "<>",
103+
value => "[]",
104+
a_type => "<>",
105+
presentationHint => (Is_Set => False),
106+
evaluateName => <>,
107+
variablesReference => 0,
108+
namedVariables => (Is_Set => False),
109+
indexedVariables => (Is_Set => False),
110+
memoryReference => <>)));
111+
96112
else
97113
for Index in 1 .. Result.a_body.variables.Length loop
98114
Var.Scopes.Append_Child
@@ -130,11 +146,46 @@ package body DAP.Clients.Variables.Variables is
130146
overriding procedure On_Error_Message
131147
(Self : in out Variables_Request;
132148
Client : not null access DAP.Clients.DAP_Client'Class;
133-
Message : VSS.Strings.Virtual_String) is
149+
Message : VSS.Strings.Virtual_String)
150+
is
151+
Var : constant Variables_Holder_Access := Client.Get_Variables;
152+
Id : constant Integer :=
153+
Self.Parameters.arguments.variablesReference;
154+
C : Variables_References_Trees.Cursor;
134155
begin
135156
DAP.Requests.Variables.Variables_DAP_Request
136157
(Self).On_Error_Message (Client, Message);
137-
Client.Variables.On_Variable_Not_Found (Self.Params);
158+
159+
C := Var.Find_By_Id (Id);
160+
if C = Variables_References_Trees.No_Element then
161+
-- We did not find any entrance
162+
return;
163+
end if;
164+
165+
if Id = Var.Arguments_Scope_Id
166+
or else Id = Var.Locals_Scope_Id
167+
or else Id = Var.Globals_Scope_Id
168+
or else Message.Is_Empty
169+
then
170+
Client.Variables.On_Variable_Not_Found (Self.Params);
171+
172+
else
173+
-- Can't get nested elements for some reason, display
174+
-- error message as a value to let user know about the problem.
175+
Var.Scopes.Append_Child
176+
(C,
177+
(Non_Specified,
178+
(name => "<>",
179+
value => Message,
180+
a_type => "<>",
181+
presentationHint => (Is_Set => False),
182+
evaluateName => <>,
183+
variablesReference => 0,
184+
namedVariables => (Is_Set => False),
185+
indexedVariables => (Is_Set => False),
186+
memoryReference => <>)));
187+
Var.On_Variables_Response (Self.Params);
188+
end if;
138189
end On_Error_Message;
139190

140191
-----------------
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
with Ada.Text_IO;
2+
with Ada.Unchecked_Conversion;
3+
with System;
4+
with System.Address_To_Access_Conversions;
5+
6+
procedure Main is
7+
8+
type Integer_Access is access all Integer;
9+
package To_Access is
10+
new System.Address_To_Access_Conversions (Integer);
11+
function To_Address is
12+
new Ada.Unchecked_Conversion (Integer, System.Address);
13+
14+
I : Integer_Access;
15+
16+
begin
17+
I := Integer_Access (To_Access.To_Pointer (To_Address (16#8#)));
18+
Ada.Text_IO.Put_Line (I.all'Img);
19+
end Main;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
project Prj is
2+
3+
for Object_Dir use "obj";
4+
for Main use ("main.adb");
5+
6+
package Builder is
7+
for Switches ("ada") use ("-g");
8+
end Builder;
9+
10+
end Prj;
11+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
v="$(gdb -v | head -n 1 | cut -c 14-16)"
2+
if [ $v -ge 15 ]
3+
then
4+
mkdir obj
5+
$GPS -Pprj --load=test.py --traceon=GPS.DEBUGGING.DAP_MODULE --traceon=MODULE.Debugger_DAP --traceoff=GPS.DAP.VARIABLES --traceoff=DAP.CLIENTS.VARIABLES --traceoff=DAP.VARIABLES_REQUEST
6+
rm -r obj
7+
fi
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
Verify that the Variables view shows error message as a value
3+
when GDB can't get the value.
4+
"""
5+
6+
from gs_utils.internal.utils import *
7+
from workflows import promises
8+
9+
10+
@run_test_driver
11+
def driver():
12+
yield wait_tasks()
13+
GPS.execute_action("Build & Debug Number 1")
14+
yield wait_for_mdi_child("Debugger Console")
15+
16+
b = GPS.EditorBuffer.get(GPS.File("main.adb"))
17+
18+
p = promises.DebuggerWrapper(GPS.File("main"))
19+
debug = p.get()
20+
yield wait_until_not_busy(debug)
21+
22+
yield p.send_promise("break main.adb:18")
23+
yield wait_until_not_busy(debug)
24+
25+
yield p.send_promise("run")
26+
yield wait_DAP_server('stackTrace')
27+
yield wait_idle()
28+
29+
GPS.MDI.get_by_child(b.current_view()).raise_window()
30+
b.current_view().goto(b.at(14, 4))
31+
32+
select_editor_contextual("Debug/Display I in Variables view")
33+
yield wait_until_not_busy(debug)
34+
35+
view = Variables_View()
36+
yield view.open_and_yield()
37+
38+
view.expand([0])
39+
yield wait_until_not_busy(debug)
40+
41+
gps_assert(
42+
"Cannot access memory" in view.dump()[1][0],
43+
True,
44+
"Invalid contents of the Variables view")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
title: 'dap.incorrect_variable'
2+
skip:
3+
- [SKIP, 'env.valgrind_cmd != []']

0 commit comments

Comments
 (0)