Skip to content

Commit 890cb99

Browse files
committed
[debugger] #11 - update debugger from OTP
1 parent 41ac5ea commit 890cb99

File tree

28 files changed

+816
-796
lines changed

28 files changed

+816
-796
lines changed

debugger/erlide_debugger_18/src/dbg_debugged.erl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
%%
44
%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
55
%%
6-
%% The contents of this file are subject to the Erlang Public License,
7-
%% Version 1.1, (the "License"); you may not use this file except in
8-
%% compliance with the License. You should have received a copy of the
9-
%% Erlang Public License along with this software. If not, it can be
10-
%% retrieved online at http://www.erlang.org/.
11-
%%
12-
%% Software distributed under the License is distributed on an "AS IS"
13-
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14-
%% the License for the specific language governing rights and limitations
15-
%% under the License.
6+
%% Licensed under the Apache License, Version 2.0 (the "License");
7+
%% you may not use this file except in compliance with the License.
8+
%% You may obtain a copy of the License at
9+
%%
10+
%% http://www.apache.org/licenses/LICENSE-2.0
11+
%%
12+
%% Unless required by applicable law or agreed to in writing, software
13+
%% distributed under the License is distributed on an "AS IS" BASIS,
14+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
%% See the License for the specific language governing permissions and
16+
%% limitations under the License.
1617
%%
1718
%% %CopyrightEnd%
18-
%%
1919
-module(dbg_debugged).
2020

2121
%% External exports

debugger/erlide_debugger_18/src/dbg_icmd.erl

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
%%
22
%% %CopyrightBegin%
33
%%
4-
%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
4+
%% Copyright Ericsson AB 1998-2016. All Rights Reserved.
55
%%
6-
%% The contents of this file are subject to the Erlang Public License,
7-
%% Version 1.1, (the "License"); you may not use this file except in
8-
%% compliance with the License. You should have received a copy of the
9-
%% Erlang Public License along with this software. If not, it can be
10-
%% retrieved online at http://www.erlang.org/.
11-
%%
12-
%% Software distributed under the License is distributed on an "AS IS"
13-
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14-
%% the License for the specific language governing rights and limitations
15-
%% under the License.
6+
%% Licensed under the Apache License, Version 2.0 (the "License");
7+
%% you may not use this file except in compliance with the License.
8+
%% You may obtain a copy of the License at
9+
%%
10+
%% http://www.apache.org/licenses/LICENSE-2.0
11+
%%
12+
%% Unless required by applicable law or agreed to in writing, software
13+
%% distributed under the License is distributed on an "AS IS" BASIS,
14+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
%% See the License for the specific language governing permissions and
16+
%% limitations under the License.
1617
%%
1718
%% %CopyrightEnd%
1819
%%
@@ -281,7 +282,7 @@ handle_int_msg({old_code,Mod}, Status, Bs,
281282
#ieval{level=Le,module=M}=Ieval) ->
282283
if
283284
Status =:= idle, Le =:= 1 ->
284-
erase([Mod|db]),
285+
erase(?DB_REF_KEY(Mod)),
285286
put(cache, []);
286287
true ->
287288
case dbg_istk:in_use_p(Mod, M) of
@@ -291,7 +292,7 @@ handle_int_msg({old_code,Mod}, Status, Bs,
291292
exit(get(self), kill),
292293
dbg_ieval:exception(exit, old_code, Bs, Ieval);
293294
false ->
294-
erase([Mod|db]),
295+
erase(?DB_REF_KEY(Mod)),
295296
put(cache, [])
296297
end
297298
end;

debugger/erlide_debugger_18/src/dbg_idb.erl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
%%
44
%% Copyright Ericsson AB 1998-2009. All Rights Reserved.
55
%%
6-
%% The contents of this file are subject to the Erlang Public License,
7-
%% Version 1.1, (the "License"); you may not use this file except in
8-
%% compliance with the License. You should have received a copy of the
9-
%% Erlang Public License along with this software. If not, it can be
10-
%% retrieved online at http://www.erlang.org/.
11-
%%
12-
%% Software distributed under the License is distributed on an "AS IS"
13-
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14-
%% the License for the specific language governing rights and limitations
15-
%% under the License.
6+
%% Licensed under the Apache License, Version 2.0 (the "License");
7+
%% you may not use this file except in compliance with the License.
8+
%% You may obtain a copy of the License at
9+
%%
10+
%% http://www.apache.org/licenses/LICENSE-2.0
11+
%%
12+
%% Unless required by applicable law or agreed to in writing, software
13+
%% distributed under the License is distributed on an "AS IS" BASIS,
14+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
%% See the License for the specific language governing permissions and
16+
%% limitations under the License.
1617
%%
1718
%% %CopyrightEnd%
1819
%%

debugger/erlide_debugger_18/src/dbg_ieval.erl

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
%%
22
%% %CopyrightBegin%
3+
%%
4+
%% Copyright Ericsson AB 1998-2016. All Rights Reserved.
5+
%%
6+
%% Licensed under the Apache License, Version 2.0 (the "License");
7+
%% you may not use this file except in compliance with the License.
8+
%% You may obtain a copy of the License at
39
%%
4-
%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
5-
%%
6-
%% The contents of this file are subject to the Erlang Public License,
7-
%% Version 1.1, (the "License"); you may not use this file except in
8-
%% compliance with the License. You should have received a copy of the
9-
%% Erlang Public License along with this software. If not, it can be
10-
%% retrieved online at http://www.erlang.org/.
11-
%%
12-
%% Software distributed under the License is distributed on an "AS IS"
13-
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14-
%% the License for the specific language governing rights and limitations
15-
%% under the License.
10+
%% http://www.apache.org/licenses/LICENSE-2.0
1611
%%
12+
%% Unless required by applicable law or agreed to in writing, software
13+
%% distributed under the License is distributed on an "AS IS" BASIS,
14+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
%% See the License for the specific language governing permissions and
16+
%% limitations under the License.
17+
%%
1718
%% %CopyrightEnd%
1819
%%
1920
-module(dbg_ieval).
@@ -568,7 +569,7 @@ get_function(Mod, Name, Args, extern) ->
568569
end.
569570

570571
db_ref(Mod) ->
571-
case get([Mod|db]) of
572+
case get(?DB_REF_KEY(Mod)) of
572573
undefined ->
573574
case dbg_iserver:call(get(int),
574575
{get_module_db, Mod, get(self)}) of
@@ -580,7 +581,7 @@ db_ref(Mod) ->
580581
Node =/= node() -> {Node,ModDb};
581582
true -> ModDb
582583
end,
583-
put([Mod|db], DbRef),
584+
put(?DB_REF_KEY(Mod), DbRef),
584585
DbRef
585586
end;
586587
DbRef ->
@@ -659,20 +660,19 @@ expr({tuple,Line,Es0}, Bs0, Ieval) ->
659660
{value,list_to_tuple(Vs),Bs};
660661

661662
%% Map
662-
expr({map,Line,Fs0}, Bs0, Ieval) ->
663-
{Fs,Bs} = eval_map_fields(Fs0, Bs0, Ieval#ieval{line=Line,top=false}),
664-
Value = lists:foldl(fun ({map_assoc,K,V}, Mi) -> maps:put(K,V,Mi) end,
665-
#{}, Fs),
666-
{value,Value,Bs};
663+
expr({map,Line,Fs}, Bs0, Ieval) ->
664+
{Map,Bs} = eval_new_map_fields(Fs, Bs0, Ieval#ieval{line=Line,top=false},
665+
fun expr/3),
666+
{value,Map,Bs};
667667
expr({map,Line,E0,Fs0}, Bs0, Ieval0) ->
668668
Ieval = Ieval0#ieval{line=Line,top=false},
669669
{value,E,Bs1} = expr(E0, Bs0, Ieval),
670-
{Fs,Bs2} = eval_map_fields(Fs0, Bs1, Ieval),
670+
{Fs,Bs2} = eval_map_fields(Fs0, Bs0, Ieval),
671+
_ = maps:put(k, v, E), %Validate map.
671672
Value = lists:foldl(fun ({map_assoc,K,V}, Mi) -> maps:put(K,V,Mi);
672-
({map_exact,K,V}, Mi) -> maps:update(K,V,Mi) end,
673-
E, Fs),
674-
{value,Value,Bs2};
675-
673+
({map_exact,K,V}, Mi) -> maps:update(K,V,Mi)
674+
end, E, Fs),
675+
{value,Value,merge_bindings(Bs2, Bs1, Ieval)};
676676
%% A block of statements
677677
expr({block,Line,Es},Bs,Ieval) ->
678678
seq(Es, Bs, Ieval#ieval{line=Line});
@@ -1487,11 +1487,13 @@ guard_expr({cons,_,H0,T0}, Bs) ->
14871487
guard_expr({tuple,_,Es0}, Bs) ->
14881488
{values,Es} = guard_exprs(Es0, Bs),
14891489
{value,list_to_tuple(Es)};
1490-
guard_expr({map,_,Fs0}, Bs) ->
1491-
Fs = eval_map_fields_guard(Fs0, Bs),
1492-
Value = lists:foldl(fun ({map_assoc,K,V}, Mi) -> maps:put(K,V,Mi) end,
1493-
#{}, Fs),
1494-
{value,Value};
1490+
guard_expr({map,_,Fs}, Bs0) ->
1491+
F = fun (G0, B0, _) ->
1492+
{value,G} = guard_expr(G0, B0),
1493+
{value,G,B0}
1494+
end,
1495+
{Map,_} = eval_new_map_fields(Fs, Bs0, #ieval{top=false}, F),
1496+
{value,Map};
14951497
guard_expr({map,_,E0,Fs0}, Bs) ->
14961498
{value,E} = guard_expr(E0, Bs),
14971499
Fs = eval_map_fields_guard(Fs0, Bs),
@@ -1540,6 +1542,17 @@ eval_map_fields([{map_field_exact,Line,K0,V0}|Fs], Bs0, Ieval0, F, Acc) ->
15401542
eval_map_fields([], Bs, _Ieval, _F, Acc) ->
15411543
{lists:reverse(Acc),Bs}.
15421544

1545+
eval_new_map_fields(Fs, Bs0, Ieval, F) ->
1546+
eval_new_map_fields(Fs, Bs0, Ieval, F, []).
1547+
1548+
eval_new_map_fields([{Line,K0,V0}|Fs], Bs0, Ieval0, F, Acc) ->
1549+
Ieval = Ieval0#ieval{line=Line},
1550+
{value,K,Bs1} = F(K0, Bs0, Ieval),
1551+
{value,V,Bs2} = F(V0, Bs1, Ieval),
1552+
eval_new_map_fields(Fs, Bs2, Ieval0, F, [{K,V}|Acc]);
1553+
eval_new_map_fields([], Bs, _, _, Acc) ->
1554+
{maps:from_list(lists:reverse(Acc)),Bs}.
1555+
15431556
%% match(Pattern,Term,Bs) -> {match,Bs} | nomatch
15441557
match(Pat, Term, Bs) ->
15451558
try match1(Pat, Term, Bs, Bs)
Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
%%
22
%% %CopyrightBegin%
33
%%
4-
%% Copyright Ericsson AB 2005-2011. All Rights Reserved.
4+
%% Copyright Ericsson AB 2005-2016. All Rights Reserved.
55
%%
6-
%% The contents of this file are subject to the Erlang Public License,
7-
%% Version 1.1, (the "License"); you may not use this file except in
8-
%% compliance with the License. You should have received a copy of the
9-
%% Erlang Public License along with this software. If not, it can be
10-
%% retrieved online at http://www.erlang.org/.
11-
%%
12-
%% Software distributed under the License is distributed on an "AS IS"
13-
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14-
%% the License for the specific language governing rights and limitations
15-
%% under the License.
6+
%% Licensed under the Apache License, Version 2.0 (the "License");
7+
%% you may not use this file except in compliance with the License.
8+
%% You may obtain a copy of the License at
9+
%%
10+
%% http://www.apache.org/licenses/LICENSE-2.0
11+
%%
12+
%% Unless required by applicable law or agreed to in writing, software
13+
%% distributed under the License is distributed on an "AS IS" BASIS,
14+
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
%% See the License for the specific language governing permissions and
16+
%% limitations under the License.
1617
%%
1718
%% %CopyrightEnd%
1819
%%
@@ -26,3 +27,5 @@
2627
%% (i.e. the next call will leave interpreted code).
2728
top = false
2829
}).
30+
31+
-define(DB_REF_KEY(Mod), {Mod,db}).

0 commit comments

Comments
 (0)