Skip to content

Commit

Permalink
add OTP 20 support; debugger
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdu committed Jun 21, 2017
1 parent 5b2d809 commit f2a4559
Show file tree
Hide file tree
Showing 21 changed files with 4,807 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build_utils.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/bash -e

declare -A OTP_VSNS=( ["17"]="17.5" ["18"]="18.3" ["19"]="19.3")
declare -A OTP_VSNS=( ["17"]="17.5" ["18"]="18.3" ["19"]="19.3" ["20"]="20.0")

build_project() {
REBAR=$1
Expand Down
3 changes: 2 additions & 1 deletion debugger/build
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ cd ../erlide_debugger_18
./build "$@"
cd ../erlide_debugger_19
./build "$@"

cd ../erlide_debugger_20
./build "$@"
cd ../erlide_debugger
./build "$@"

Expand Down
18 changes: 18 additions & 0 deletions debugger/erlide_debugger_20/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>erlide_debugger_19</name>
<comment></comment>
<projects>
<project>erlide_common</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.erlide.core.erlbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.erlide.core.erlnature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=ISO-8859-1
17 changes: 17 additions & 0 deletions debugger/erlide_debugger_20/.settings/org.erlide.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
backend_version=19.0
compiler/warn_deprecated_function=true
compiler/warn_export_all=true
compiler/warn_export_vars=true
compiler/warn_obsolete_guard=true
compiler/warn_shadow_vars=true
compiler/warn_unused_function=true
compiler/warn_unused_import=true
compiler/warn_unused_record=true
compiler/warn_unused_vars=true
eclipse.preferences.version=1
external_includes=
external_modules=
include_dirs=include;
output_dir=ebin
source_dirs=src;
use_pathz=false
3 changes: 3 additions & 0 deletions debugger/erlide_debugger_20/.settings/org.erlide.model.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
builderData=INTERNAL|compile|clean|test|
configType=INTERNAL
eclipse.preferences.version=1
8 changes: 8 additions & 0 deletions debugger/erlide_debugger_20/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#! /bin/bash

source ../../build_utils.sh

dir=`pwd`
prj=`basename $dir`

build_project ../../rebar3 $prj 20 "$@"
Empty file.
Empty file.
24 changes: 24 additions & 0 deletions debugger/erlide_debugger_20/rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{require_otp_vsn, "20.*"}.

{plugins, []}.

{erl_opts, []}.
{edoc_opts,[{todo,true}]}.

{eunit_opts, [verbose, {report,{eunit_surefire,[{dir,"."}]}}]}.

{cover_export_enabled, true}.
{cover_enabled, false}.
{cover_print_enable, true}.

{covertool_eunit, {".eunit/cover.coverdata", "eunit.coverage.xml"}}.
{covertool_prefix_len, 0}.

{xref_checks,[
undefined_function_calls,
undefined_functions,
locals_not_used,
%exports_not_used,
deprecated_function_calls,
deprecated_functions
]}.
1 change: 1 addition & 0 deletions debugger/erlide_debugger_20/rebar.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[].
115 changes: 115 additions & 0 deletions debugger/erlide_debugger_20/src/dbg_debugged.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1998-2016. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
-module(dbg_debugged).

%% External exports
-export([eval/3]).

%%====================================================================
%% External exports
%%====================================================================

%%--------------------------------------------------------------------
%% eval(Mod, Func, Args) -> Value
%% Main entry point from external (non-interpreted) code.
%% Called via the error handler.
%%--------------------------------------------------------------------
eval(Mod, Func, Args) ->
SaveStacktrace = erlang:get_stacktrace(),
Meta = dbg_ieval:eval(Mod, Func, Args),
Mref = erlang:monitor(process, Meta),
msg_loop(Meta, Mref, SaveStacktrace).

%%====================================================================
%% Internal functions
%%====================================================================

msg_loop(Meta, Mref, SaveStacktrace) ->
receive

%% Evaluated function has returned a value
{sys, Meta, {ready, Val}} ->
erlang:demonitor(Mref, [flush]),

%% Restore original stacktrace and return the value
try erlang:raise(throw, stack, SaveStacktrace)
catch
throw:stack ->
case Val of
{dbg_apply,M,F,A} ->
apply(M, F, A);
_ ->
Val
end
end;

%% Evaluated function raised an (uncaught) exception
{sys, Meta, {exception,{Class,Reason,Stacktrace}}} ->
erlang:demonitor(Mref, [flush]),

%% ...raise the same exception
erlang:error(erlang:raise(Class, Reason, Stacktrace),
[Class,Reason,Stacktrace]);

%% Meta is evaluating a receive, must be done within context
%% of real (=this) process
{sys, Meta, {'receive',Msg}} ->
receive Msg ->
Meta ! {self(), rec_acked},
ok
end,
msg_loop(Meta, Mref, SaveStacktrace);

%% Meta needs something evaluated within context of real process
{sys, Meta, {command,Command}} ->
Reply = handle_command(Command),
Meta ! {sys, self(), Reply},
msg_loop(Meta, Mref, SaveStacktrace);

%% Meta has terminated
%% Must be due to int:stop() (or -heaven forbid- a debugger bug)
{'DOWN', Mref, _, _, Reason} ->

%% Restore original stacktrace and return a dummy value
try erlang:raise(throw, stack, SaveStacktrace)
catch
throw:stack ->
{interpreter_terminated, Reason}
end
end.

handle_command(Command) ->
try
reply(Command)
catch Class:Reason ->
Stacktrace = stacktrace_f(erlang:get_stacktrace()),
{exception,{Class,Reason,Stacktrace}}
end.

reply({apply,M,F,As}) ->
{value, erlang:apply(M,F,As)};
reply({eval,Expr,Bs}) ->
%% Bindings is an orddict (sort them)
erl_eval:expr(Expr, lists:sort(Bs)). % {value, Value, Bs2}

%% Fix stacktrace - keep all above call to this module.
%%
stacktrace_f([]) -> [];
stacktrace_f([{?MODULE,_,_,_}|_]) -> [];
stacktrace_f([F|S]) -> [F|stacktrace_f(S)].
Loading

0 comments on commit f2a4559

Please sign in to comment.