aboutsummaryrefslogtreecommitdiffstats
path: root/lib/debugger/src/int.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/debugger/src/int.erl')
-rw-r--r--lib/debugger/src/int.erl93
1 files changed, 47 insertions, 46 deletions
diff --git a/lib/debugger/src/int.erl b/lib/debugger/src/int.erl
index b3a8a07f03..bdd671cff1 100644
--- a/lib/debugger/src/int.erl
+++ b/lib/debugger/src/int.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -517,7 +517,7 @@ int_mod(AbsMod, Dist) when is_atom(AbsMod); is_list(AbsMod) ->
[App, AbsMod]),
error;
_Error ->
- io:format("** Invalid beam file or no abstract code: ~p\n",
+ io:format("** Invalid beam file or no abstract code: ~tp\n",
[AbsMod]),
error
end.
@@ -626,18 +626,18 @@ find_src(Beam) ->
find_beam(Mod, Src) ->
SrcDir = filename:dirname(Src),
- BeamFile = packages:last(Mod) ++ code:objfile_extension(),
+ BeamFile = atom_to_list(Mod) ++ code:objfile_extension(),
File = filename:join(SrcDir, BeamFile),
case is_file(File) of
true -> File;
- false -> find_beam_1(Mod, SrcDir)
+ false -> find_beam_1(Mod, BeamFile, SrcDir)
end.
-find_beam_1(Mod, SrcDir) ->
- RootDir = find_root_dir(SrcDir, packages:first(Mod)),
+find_beam_1(Mod, BeamFile, SrcDir) ->
+ RootDir = filename:dirname(SrcDir),
EbinDir = filename:join(RootDir, "ebin"),
CodePath = [EbinDir | code:get_path()],
- BeamFile = to_path(Mod) ++ code:objfile_extension(),
+ BeamFile = atom_to_list(Mod) ++ code:objfile_extension(),
lists:foldl(fun(_, Beam) when is_list(Beam) -> Beam;
(Dir, error) ->
File = filename:join(Dir, BeamFile),
@@ -649,14 +649,6 @@ find_beam_1(Mod, SrcDir) ->
error,
CodePath).
-to_path(X) ->
- filename:join(packages:split(X)).
-
-find_root_dir(Dir, [_|Ss]) ->
- find_root_dir(filename:dirname(Dir), Ss);
-find_root_dir(Dir, []) ->
- filename:dirname(Dir).
-
check_beam(BeamBin) when is_binary(BeamBin) ->
case beam_lib:chunks(BeamBin, [abstract_code,exports]) of
{ok,{_Mod,[{abstract_code,no_abstract_code}|_]}} ->
@@ -682,43 +674,52 @@ everywhere(local, Fun) ->
Fun().
scan_module_name(File) ->
- case erl_prim_loader:get_file(filename:absname(File)) of
- {ok, Bin, _FullPath} ->
- Chars = binary_to_list(Bin),
- R = (catch {ok, scan_module_name_1(Chars)}),
- case R of
- {ok, A} when is_atom(A) -> A;
- _ -> error
- end;
- _ ->
- error
+ try
+ {ok, Bin, _FullPath} =
+ erl_prim_loader:get_file(filename:absname(File)),
+ scan_module_name_1([], <<>>, Bin, enc(Bin))
+ catch
+ _:_ ->
+ throw({error, no_beam})
end.
-scan_module_name_1(Chars) ->
- case erl_scan:tokens("", Chars, 1) of
- {done, {ok, Ts, _}, Rest} ->
- scan_module_name_2(Ts, Rest);
- _ ->
- error
+scan_module_name_1(Cont0, B0, Bin0, Enc) ->
+ N = min(100, byte_size(Bin0)),
+ {Bin1, Bin} = erlang:split_binary(Bin0, N),
+ {Chars, B1} =
+ case unicode:characters_to_list(list_to_binary([B0, Bin1]), Enc) of
+ {incomplete, List, Binary} ->
+ {List, Binary};
+ List when is_list(List), List =/= [] ->
+ {List, <<>>}
+ end,
+ scan_module_name_2(Cont0, Chars, B1, Bin, Enc).
+
+scan_module_name_2(Cont0, Chars, B1, Bin, Enc) ->
+ case erl_scan:tokens(Cont0, Chars, _AnyLine = 1) of
+ {done, {ok, Ts, _}, Rest} ->
+ scan_module_name_3(Ts, Rest, B1, Bin, Enc);
+ {more, Cont} ->
+ scan_module_name_1(Cont, B1, Bin, Enc)
end.
-scan_module_name_2([{'-',_},{atom,_,module},{'(',_} | _]=Ts, _Chars) ->
- scan_module_name_3(Ts);
-scan_module_name_2([{'-',_},{atom,_,_} | _], Chars) ->
- scan_module_name_1(Chars);
-scan_module_name_2(_, _) ->
- error.
-
-scan_module_name_3(Ts) ->
- case erl_parse:parse_form(Ts) of
- {ok, {attribute,_,module,{M,_}}} -> module_atom(M);
- {ok, {attribute,_,module,M}} -> module_atom(M);
- _ -> error
+scan_module_name_3([{'-',_},{atom,_,module},{'(',_} | _]=Ts,
+ _Chars, _B1, _Bin, _Enc) ->
+ scan_module_name_4(Ts);
+scan_module_name_3([{'-',_},{atom,_,_} | _], Chars, B1, Bin, Enc) ->
+ scan_module_name_2("", Chars, B1, Bin, Enc).
+
+scan_module_name_4(Ts) ->
+ {ok, {attribute,_,module,M}} = erl_parse:parse_form(Ts),
+ true = is_atom(M),
+ M.
+
+enc(Bin) ->
+ case epp:read_encoding_from_binary(Bin) of
+ none -> epp:default_encoding();
+ Encoding -> Encoding
end.
-module_atom(A) when is_atom(A) -> A;
-module_atom(L) when is_list(L) -> list_to_atom(packages:concat(L)).
-
%%--Stop interpreting modules-----------------------------------------
del_mod(AbsMod, Dist) ->