diff options
author | Siri Hansen <[email protected]> | 2017-09-07 17:34:58 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2017-09-07 17:34:58 +0200 |
commit | 695ce64b3168c3fcc2d5f2de5cb74701f767e71d (patch) | |
tree | 153c3af70c221a063844e922d29c11ee9b82b64e /lib | |
parent | f4c24c5faba8cbf0817b4dd9559e2ae2223525f0 (diff) | |
parent | b569db7fd80de6f6f049797fa7676bdfbe55cc4f (diff) | |
download | otp-695ce64b3168c3fcc2d5f2de5cb74701f767e71d.tar.gz otp-695ce64b3168c3fcc2d5f2de5cb74701f767e71d.tar.bz2 otp-695ce64b3168c3fcc2d5f2de5cb74701f767e71d.zip |
Merge branch 'maint'
Diffstat (limited to 'lib')
123 files changed, 1239 insertions, 983 deletions
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index 19b0ee20fe..a12c0c9101 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -848,7 +848,8 @@ capture_get([ExclCat | ExclCategories]) -> Strs = test_server:capture_get(), CatsStr = [atom_to_list(ExclCat) | [[$| | atom_to_list(EC)] || EC <- ExclCategories]], - {ok,MP} = re:compile("<div class=\"(" ++ lists:flatten(CatsStr) ++ ")\">.*"), + {ok,MP} = re:compile("<div class=\"(" ++ lists:flatten(CatsStr) ++ ")\">.*", + [unicode]), lists:flatmap(fun(Str) -> case re:run(Str, MP) of {match,_} -> []; diff --git a/lib/common_test/src/ct_telnet.erl b/lib/common_test/src/ct_telnet.erl index 14d9d381da..b50cddd492 100644 --- a/lib/common_test/src/ct_telnet.erl +++ b/lib/common_test/src/ct_telnet.erl @@ -1455,7 +1455,7 @@ match_line(Name,Pid,Line,[{prompt,PromptType}|Patterns],FoundPrompt,Term, when PromptType=/=FoundPrompt -> match_line(Name,Pid,Line,Patterns,FoundPrompt,Term,EO,RetTag); match_line(Name,Pid,Line,[{Tag,Pattern}|Patterns],FoundPrompt,Term,EO,RetTag) -> - case re:run(Line,Pattern,[{capture,all,list}]) of + case re:run(Line,Pattern,[{capture,all,list},unicode]) of nomatch -> match_line(Name,Pid,Line,Patterns,FoundPrompt,Term,EO,RetTag); {match,Match} -> @@ -1463,7 +1463,7 @@ match_line(Name,Pid,Line,[{Tag,Pattern}|Patterns],FoundPrompt,Term,EO,RetTag) -> {RetTag,{Tag,Match}} end; match_line(Name,Pid,Line,[Pattern|Patterns],FoundPrompt,Term,EO,RetTag) -> - case re:run(Line,Pattern,[{capture,all,list}]) of + case re:run(Line,Pattern,[{capture,all,list},unicode]) of nomatch -> match_line(Name,Pid,Line,Patterns,FoundPrompt,Term,EO,RetTag); {match,Match} -> @@ -1575,7 +1575,7 @@ split_lines([],Line,Lines) -> match_prompt(Str,Prx) -> match_prompt(Str,Prx,[]). match_prompt(Str,Prx,Acc) -> - case re:run(Str,Prx) of + case re:run(Str,Prx,[unicode]) of nomatch -> noprompt; {match,[{Start,Len}]} -> diff --git a/lib/common_test/src/ct_testspec.erl b/lib/common_test/src/ct_testspec.erl index 09839bd35d..bb445bb0d2 100644 --- a/lib/common_test/src/ct_testspec.erl +++ b/lib/common_test/src/ct_testspec.erl @@ -537,7 +537,7 @@ replace_names_in_elems([],Modified,_Defs) -> replace_names_in_string(Term,Defs=[{Name,Replacement=[Ch|_]}|Ds]) when is_integer(Ch) -> try re:replace(Term,[$'|atom_to_list(Name)]++"'", - Replacement,[{return,list}]) of + Replacement,[{return,list},unicode]) of Term -> % no match, proceed replace_names_in_string(Term,Ds); Term1 -> @@ -569,7 +569,7 @@ replace_names_in_node1(NodeStr,Defs=[{Name,Replacement}|Ds]) -> replace_names_in_node1(NodeStr,Ds); true -> case re:replace(NodeStr,atom_to_list(Name), - ReplStr,[{return,list}]) of + ReplStr,[{return,list},unicode]) of NodeStr -> % no match, proceed replace_names_in_node1(NodeStr,Ds); NodeStr1 -> diff --git a/lib/common_test/src/test_server_node.erl b/lib/common_test/src/test_server_node.erl index a18ff1fd62..c0d7e12721 100644 --- a/lib/common_test/src/test_server_node.erl +++ b/lib/common_test/src/test_server_node.erl @@ -692,7 +692,7 @@ find_rel_suse_2(Rel, RootWc) -> case file:list_dir(RelDir) of {ok,Dirs} -> case lists:filter(fun(Dir) -> - case re:run(Dir, Pat) of + case re:run(Dir, Pat, [unicode]) of nomatch -> false; _ -> true end diff --git a/lib/common_test/src/test_server_sup.erl b/lib/common_test/src/test_server_sup.erl index 9a26de4774..21f4be22fe 100644 --- a/lib/common_test/src/test_server_sup.erl +++ b/lib/common_test/src/test_server_sup.erl @@ -346,7 +346,7 @@ check_appup_clauses_plausible([], _Direction, _Modules) -> ok; check_appup_clauses_plausible([{Re, Instrs} | Rest], Direction, Modules) when is_binary(Re) -> - case re:compile(Re) of + case re:compile(Re,[unicode]) of {ok, _} -> case check_appup_instructions(Instrs, Direction, Modules) of ok -> diff --git a/lib/debugger/src/dbg_ieval.erl b/lib/debugger/src/dbg_ieval.erl index 88c7caacb0..8009d62629 100644 --- a/lib/debugger/src/dbg_ieval.erl +++ b/lib/debugger/src/dbg_ieval.erl @@ -353,15 +353,15 @@ format_trace(What, Args, P) -> {Called, {Le,Li,M,F,As}} = Args, case Called of extern -> - io_lib:format("++ (~w) <~w> ~w:~w~ts~n", + io_lib:format("++ (~w) <~w> ~w:~tw~ts~n", [Le,Li,M,F,format_args(As, P)]); local -> - io_lib:format("++ (~w) <~w> ~w~ts~n", + io_lib:format("++ (~w) <~w> ~tw~ts~n", [Le,Li,F,format_args(As, P)]) end; call_fun -> {Le,Li,F,As} = Args, - io_lib:format("++ (~w) <~w> ~w~ts~n", + io_lib:format("++ (~w) <~w> ~tw~ts~n", [Le, Li, F, format_args(As, P)]); return -> {Le,Val} = Args, @@ -370,7 +370,7 @@ format_trace(What, Args, P) -> bif -> {Le,Li,M,F,As} = Args, - io_lib:format("++ (~w) <~w> ~w:~w~ts~n", + io_lib:format("++ (~w) <~w> ~w:~tw~ts~n", [Le, Li, M, F, format_args(As, P)]) end. diff --git a/lib/debugger/src/dbg_wx_break_win.erl b/lib/debugger/src/dbg_wx_break_win.erl index 770681510d..10e9272254 100644 --- a/lib/debugger/src/dbg_wx_break_win.erl +++ b/lib/debugger/src/dbg_wx_break_win.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2016. All Rights Reserved. +%% Copyright Ericsson AB 2008-2017. 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. @@ -159,7 +159,7 @@ create_win(Parent, Pos, Type, Mod, Line) -> %%-------------------------------------------------------------------- update_functions(WinInfo, Funcs) -> Items = lists:map(fun([N, A]) -> - lists:flatten(io_lib:format("~p/~p", [N,A])) + lists:flatten(io_lib:format("~tw/~w", [N,A])) end, Funcs), wxListBox:set(WinInfo#winInfo.listbox, Items), diff --git a/lib/debugger/src/dbg_wx_mon_win.erl b/lib/debugger/src/dbg_wx_mon_win.erl index 9737c9e67f..fcd954454b 100644 --- a/lib/debugger/src/dbg_wx_mon_win.erl +++ b/lib/debugger/src/dbg_wx_mon_win.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2016. All Rights Reserved. +%% Copyright Ericsson AB 2008-2017. 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. @@ -342,7 +342,7 @@ add_process(WinInfo, Pid, Name, {Mod,Func,Args}, Status, Info) -> Row = (WinInfo#winInfo.row), Name2 = case Name of undefined -> ""; _ -> to_string(Name) end, - FuncS = to_string("~w:~w/~w", [Mod, Func, length(Args)]), + FuncS = to_string("~w:~tw/~w", [Mod, Func, length(Args)]), Info2 = case Info of {} -> ""; _ -> to_string(Info) end, Pid2 = to_string("~p",[Pid]), diff --git a/lib/debugger/src/dbg_wx_trace.erl b/lib/debugger/src/dbg_wx_trace.erl index f4ee30618c..b1e0e03b4c 100644 --- a/lib/debugger/src/dbg_wx_trace.erl +++ b/lib/debugger/src/dbg_wx_trace.erl @@ -345,11 +345,12 @@ gui_cmd('Back Trace', State) -> P = p(State), lists:foreach( fun({Le, {Mod,Func,Args}}) -> - Str = io_lib:format("~p > ~p:~p"++P++"~n", - [Le, Mod, Func, Args]), + Str = io_lib:format("~p > ~w:~tw~ts\n", + [Le, Mod, Func, format_args(Args, P)]), dbg_wx_trace_win:trace_output(State#state.win,Str); ({Le, {Fun,Args}}) -> - Str = io_lib:format("~p > ~p"++P++"~n", [Le, Fun, Args]), + Str = io_lib:format("~p > ~p~ts~n", + [Le, Fun, format_args(Args, P)]), dbg_wx_trace_win:trace_output(State#state.win,Str); (_) -> ignore end, @@ -539,6 +540,18 @@ add_break(WI, Coords, Type, Mod, Line) -> Win = dbg_wx_trace_win:get_window(WI), dbg_wx_break:start(Win, Coords, Type, Mod, Line). +format_args(As, P) when is_list(As) -> + [$(,format_args1(As, P),$)]; +format_args(A, P) -> + [$/,io_lib:format(P, [A])]. + +format_args1([A], P) -> + [io_lib:format(P, [A])]; +format_args1([A|As], P) -> + [io_lib:format(P, [A]),$,|format_args1(As, P)]; +format_args1([], _) -> + []. + %%--Commands from the interpreter------------------------------------- int_cmd({interpret, Mod}, State) -> diff --git a/lib/debugger/src/dbg_wx_win.erl b/lib/debugger/src/dbg_wx_win.erl index f1298154ab..9f59915476 100644 --- a/lib/debugger/src/dbg_wx_win.erl +++ b/lib/debugger/src/dbg_wx_win.erl @@ -299,7 +299,7 @@ open_help(_Parent, HelpHtmlFile) -> %%-------------------------------------------------------------------- to_string(Atom) when is_atom(Atom) -> - atom_to_list(Atom); + io_lib:format("~tw", [Atom]); to_string(Integer) when is_integer(Integer) -> integer_to_list(Integer); to_string([]) -> ""; diff --git a/lib/debugger/src/i.erl b/lib/debugger/src/i.erl index 2da3e77618..62ce8d0e20 100644 --- a/lib/debugger/src/i.erl +++ b/lib/debugger/src/i.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2016. All Rights Reserved. +%% Copyright Ericsson AB 1998-2017. 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. @@ -307,13 +307,13 @@ ip() -> ip([{Pid,{M,F,A},Status,{}}|Stats]) -> hformat(io_lib:format("~w",[Pid]), - io_lib:format("~p:~p/~p",[M,F,length(A)]), + io_lib:format("~w:~tw/~w",[M,F,length(A)]), io_lib:format("~w",[Status]), ""), ip(Stats); ip([{Pid,{M,F,A},Status,Info}|Stats]) -> hformat(io_lib:format("~w",[Pid]), - io_lib:format("~p:~p/~p",[M,F,length(A)]), + io_lib:format("~w:~tw/~w",[M,F,length(A)]), io_lib:format("~w",[Status]), io_lib:format("~w",[Info])), ip(Stats); @@ -321,7 +321,7 @@ ip([]) -> ok. hformat(A1, A2, A3, A4) -> - format("~-12s ~-21s ~-9s ~-21s~n", [A1,A2,A3,A4]). + format("~-12s ~-21ts ~-9s ~-21s~n", [A1,A2,A3,A4]). %% ------------------------------------------- diff --git a/lib/dialyzer/src/dialyzer.erl b/lib/dialyzer/src/dialyzer.erl index c319acb2fb..1538174d4a 100644 --- a/lib/dialyzer/src/dialyzer.erl +++ b/lib/dialyzer/src/dialyzer.erl @@ -498,24 +498,24 @@ call_or_apply_to_string(ArgNs, FailReason, SigArgs, SigRet, true -> %% We do not know which argument(s) caused the failure io_lib:format("will never return since the success typing arguments" - " are ~s\n", [SigArgs]); + " are ~ts\n", [SigArgs]); false -> io_lib:format("will never return since it differs in the ~s argument" - " from the success typing arguments: ~s\n", + " from the success typing arguments: ~ts\n", [PositionString, SigArgs]) end; only_contract -> case (ArgNs =:= []) orelse IsOverloaded of true -> %% We do not know which arguments caused the failure - io_lib:format("breaks the contract ~s\n", [Contract]); + io_lib:format("breaks the contract ~ts\n", [Contract]); false -> - io_lib:format("breaks the contract ~s in the ~s argument\n", + io_lib:format("breaks the contract ~ts in the ~s argument\n", [Contract, PositionString]) end; both -> - io_lib:format("will never return since the success typing is ~s -> ~s" - " and the contract is ~s\n", [SigArgs, SigRet, Contract]) + io_lib:format("will never return since the success typing is ~ts -> ~ts" + " and the contract is ~ts\n", [SigArgs, SigRet, Contract]) end. form_positions(ArgNs) -> @@ -533,9 +533,9 @@ form_positions(ArgNs) -> form_expected_without_opaque([{N, T, TStr}]) -> case erl_types:t_is_opaque(T) of true -> - io_lib:format("an opaque term of type ~s as ", [TStr]); + io_lib:format("an opaque term of type ~ts as ", [TStr]); false -> - io_lib:format("a term of type ~s (with opaque subterms) as ", [TStr]) + io_lib:format("a term of type ~ts (with opaque subterms) as ", [TStr]) end ++ form_position_string([N]) ++ " argument"; form_expected_without_opaque(ExpectedTriples) -> %% TODO: can do much better here {ArgNs, _Ts, _TStrs} = lists:unzip3(ExpectedTriples), @@ -546,8 +546,8 @@ form_expected(ExpectedArgs) -> [T] -> TS = erl_types:t_to_string(T), case erl_types:t_is_opaque(T) of - true -> io_lib:format("an opaque term of type ~s is expected", [TS]); - false -> io_lib:format("a structured term of type ~s is expected", [TS]) + true -> io_lib:format("an opaque term of type ~ts is expected", [TS]); + false -> io_lib:format("a structured term of type ~ts is expected", [TS]) end; [_,_|_] -> "terms of different types are expected in these positions" end. diff --git a/lib/dialyzer/src/dialyzer_cl_parse.erl b/lib/dialyzer/src/dialyzer_cl_parse.erl index a456d38e64..80c10183cf 100644 --- a/lib/dialyzer/src/dialyzer_cl_parse.erl +++ b/lib/dialyzer/src/dialyzer_cl_parse.erl @@ -82,7 +82,7 @@ cl(["--get_warnings"|T]) -> cl(["-D"|_]) -> cl_error("No defines specified after -D"); cl(["-D"++Define|T]) -> - Def = re:split(Define, "=", [{return, list}]), + Def = re:split(Define, "=", [{return, list}, unicode]), append_defines(Def), cl(T); cl(["-h"|_]) -> diff --git a/lib/dialyzer/src/dialyzer_gui_wx.erl b/lib/dialyzer/src/dialyzer_gui_wx.erl index 538327d4d1..b4b1872c12 100644 --- a/lib/dialyzer/src/dialyzer_gui_wx.erl +++ b/lib/dialyzer/src/dialyzer_gui_wx.erl @@ -1093,7 +1093,7 @@ macro_loop(Options, Win, Box, MacroText, TermText, Frame) -> Fun = fun(X) -> Val = wxControlWithItems:getString(Box,X), - [MacroName|_] = re:split(Val, " ", [{return, list}]), + [MacroName|_] = re:split(Val, " ", [{return, list}, unicode]), list_to_atom(MacroName) end, Delete = [Fun(X) || X <- List], diff --git a/lib/dialyzer/src/typer.erl b/lib/dialyzer/src/typer.erl index bf5484e5f6..16b9c8a94a 100644 --- a/lib/dialyzer/src/typer.erl +++ b/lib/dialyzer/src/typer.erl @@ -74,7 +74,8 @@ -spec start() -> no_return(). start() -> -_ = io:setopts(standard_error, [{encoding,unicode}]), + _ = io:setopts(standard_error, [{encoding,unicode}]), + _ = io:setopts([{encoding,unicode}]), {Args, Analysis} = process_cl_args(), %% io:format("Args: ~p\n", [Args]), %% io:format("Analysis: ~p\n", [Analysis]), @@ -484,12 +485,12 @@ write_typed_file(File, Info) -> write_typed_file(File, Info, NewFileName) -> {ok, Binary} = file:read_file(File), - Chars = binary_to_list(Binary), + Chars = unicode:characters_to_list(Binary), write_typed_file(Chars, NewFileName, Info, 1, []), io:format(" Saved as: ~tp\n", [NewFileName]). write_typed_file(Chars, File, #info{functions = []}, _LNo, _Acc) -> - ok = file:write_file(File, list_to_binary(Chars), [append]); + ok = file:write_file(File, unicode:characters_to_binary(Chars), [append]); write_typed_file([Ch|Chs] = Chars, File, Info, LineNo, Acc) -> [{Line,F,A}|RestFuncs] = Info#info.functions, case Line of @@ -519,7 +520,7 @@ write_typed_file([Ch|Chs] = Chars, File, Info, LineNo, Acc) -> raw_write(F, A, Info, File, Content) -> TypeInfo = get_type_string(F, A, Info, file), ContentList = lists:reverse(Content) ++ TypeInfo ++ "\n", - ContentBin = list_to_binary(ContentList), + ContentBin = unicode:characters_to_binary(ContentList), file:write_file(File, ContentBin, [append]). get_type_string(F, A, Info, Mode) -> @@ -608,7 +609,7 @@ cl(["-D"++Def|Opts]) -> case Def of "" -> fatal_error("no variable name specified after -D"); _ -> - DefPair = process_def_list(re:split(Def, "=", [{return, list}])), + DefPair = process_def_list(re:split(Def, "=", [{return, list}, unicode])), {{def, DefPair}, Opts} end; cl(["-I",Dir|Opts]) -> {{inc, Dir}, Opts}; @@ -697,7 +698,7 @@ get_all_files(#args{files = Fs, files_r = Ds}) -> test_erl_file_exclude_ann(File) -> case is_erl_file(File) of true -> %% Exclude files ending with ".ann.erl" - case re:run(File, "[\.]ann[\.]erl$") of + case re:run(File, "[\.]ann[\.]erl$", [unicode]) of {match, _} -> false; nomatch -> true end; diff --git a/lib/edoc/src/edoc_doclet.erl b/lib/edoc/src/edoc_doclet.erl index 6e17ec0af0..0e084e619e 100644 --- a/lib/edoc/src/edoc_doclet.erl +++ b/lib/edoc/src/edoc_doclet.erl @@ -198,7 +198,7 @@ source({M, Name, Path}, Dir, Suffix, Env, Set, Private, Hidden, {Set, Error} end; R -> - report("skipping source file '~ts': ~P.", [File, R, 15]), + report("skipping source file '~ts': ~tP.", [File, R, 15]), {Set, true} end. diff --git a/lib/edoc/src/edoc_lib.erl b/lib/edoc/src/edoc_lib.erl index ebdb0f79f6..d00a283794 100644 --- a/lib/edoc/src/edoc_lib.erl +++ b/lib/edoc/src/edoc_lib.erl @@ -541,13 +541,13 @@ uri_get_http_1(Result, URI) -> Reason = inet:format_error(R), {error, http_errmsg(Reason, URI)}; {ok, R} -> - Reason = io_lib:format("bad return value ~P", [R, 5]), + Reason = io_lib:format("bad return value ~tP", [R, 5]), {error, http_errmsg(Reason, URI)}; {'EXIT', R} -> - Reason = io_lib:format("crashed with reason ~w", [R]), + Reason = io_lib:format("crashed with reason ~tw", [R]), {error, http_errmsg(Reason, URI)}; R -> - Reason = io_lib:format("uncaught throw: ~w", [R]), + Reason = io_lib:format("uncaught throw: ~tw", [R]), {error, http_errmsg(Reason, URI)} end. @@ -603,7 +603,7 @@ filename([]) -> filename(N) when is_atom(N) -> atom_to_list(N); filename(N) -> - report("bad filename: `~P'.", [N, 25]), + report("bad filename: `~tP'.", [N, 25]), exit(error). %% @private @@ -1000,7 +1000,7 @@ run_plugin(Name, Key, Default, Fun, Opts) when is_atom(Name) -> {ok, Value} -> Value; R -> - report("error in ~ts '~w': ~P.", [Name, Module, R, 20]), + report("error in ~ts '~w': ~tP.", [Name, Module, R, 20]), exit(error) end. @@ -1009,7 +1009,7 @@ get_plugin(Key, Default, Opts) -> M when is_atom(M) -> M; Other -> - report("bad value for option '~w': ~P.", [Key, Other, 10]), + report("bad value for option '~w': ~tP.", [Key, Other, 10]), exit(error) end. diff --git a/lib/edoc/src/edoc_run.erl b/lib/edoc/src/edoc_run.erl index c88c6cfd78..50aba0a930 100644 --- a/lib/edoc/src/edoc_run.erl +++ b/lib/edoc/src/edoc_run.erl @@ -150,7 +150,7 @@ file(Args) -> -spec invalid_args(string(), args()) -> no_return(). invalid_args(Where, Args) -> - report("invalid arguments to ~ts: ~w.", [Where, Args]), + report("invalid arguments to ~ts: ~tw.", [Where, Args]), shutdown_error(). run(F) -> @@ -159,10 +159,10 @@ run(F) -> {ok, _} -> shutdown_ok(); {'EXIT', E} -> - report("edoc terminated abnormally: ~P.", [E, 10]), + report("edoc terminated abnormally: ~tP.", [E, 10]), shutdown_error(); Thrown -> - report("internal error: throw without catch in edoc: ~P.", + report("internal error: throw without catch in edoc: ~tP.", [Thrown, 15]), shutdown_error() end. diff --git a/lib/edoc/src/edoc_types.erl b/lib/edoc/src/edoc_types.erl index ccc3169767..510f9513b2 100644 --- a/lib/edoc/src/edoc_types.erl +++ b/lib/edoc/src/edoc_types.erl @@ -107,7 +107,7 @@ to_xml(#t_paren{type = T}, Env) -> to_xml(#t_nonempty_list{type = T}, Env) -> {nonempty_list, [wrap_utype(T, Env)]}; to_xml(#t_atom{val = V}, _Env) -> - {atom, [{value, io_lib:write(V)}], []}; + {atom, [{value, atom_to_list(V)}], []}; to_xml(#t_integer{val = V}, _Env) -> {integer, [{value, integer_to_list(V)}], []}; to_xml(#t_integer_range{from = From, to = To}, _Env) -> diff --git a/lib/erl_docgen/src/docgen_otp_specs.erl b/lib/erl_docgen/src/docgen_otp_specs.erl index 6c41147e27..126229ecc9 100644 --- a/lib/erl_docgen/src/docgen_otp_specs.erl +++ b/lib/erl_docgen/src/docgen_otp_specs.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2017. 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. @@ -406,7 +406,7 @@ t_var(E) -> [get_attrval(name, E)]. t_atom(E) -> - [get_attrval(value, E)]. + [io_lib:write(list_to_atom(get_attrval(value, E)))]. t_integer(E) -> [get_attrval(value, E)]. @@ -578,7 +578,7 @@ ot_var(E) -> {var,0,list_to_atom(get_attrval(name, E))}. ot_atom(E) -> - {ok, [{atom,A,Name}], _} = erl_scan:string(get_attrval(value, E), 0), + {ok, [{atom,A,Name}], _} = erl_scan:string(lists:flatten(t_atom(E)), 0), {atom,erl_anno:line(A),Name}. ot_integer(E) -> diff --git a/lib/et/src/et_collector.erl b/lib/et/src/et_collector.erl index aba90b0be1..b0f016a8ea 100644 --- a/lib/et/src/et_collector.erl +++ b/lib/et/src/et_collector.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2017. 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. @@ -750,7 +750,7 @@ next_iterate(TH, Prev = first, Limit, Fun, Acc) -> '$end_of_table' -> Acc; {'EXIT', _} = Error -> - io:format("~p(~p): First ~p~n", [?MODULE, ?LINE, Error]), + io:format("~p(~p): First ~tp~n", [?MODULE, ?LINE, Error]), iterate(TH#table_handle.collector_pid, Prev, Limit, Fun, Acc); First -> lookup_and_apply(TH, Prev, First, Limit, -1, Fun, Acc) @@ -761,7 +761,7 @@ next_iterate(TH, Prev = last, Limit, Fun, Acc) -> '$end_of_table' -> Acc; {'EXIT', _} = Error -> - io:format("~p(~p): Last ~p~n", [?MODULE, ?LINE, Error]), + io:format("~p(~p): Last ~tp~n", [?MODULE, ?LINE, Error]), iterate(TH#table_handle.collector_pid, Prev, Limit, Fun, Acc); Last -> lookup_and_apply(TH, Prev, Last, Limit, -1, Fun, Acc) @@ -773,7 +773,7 @@ next_iterate(TH, Prev, Limit, Fun, Acc) -> '$end_of_table' -> Acc; {'EXIT', _} = Error -> - io:format("~p(~p): Next ~p -> ~p~n", [?MODULE, ?LINE, Key, Error]), + io:format("~p(~p): Next ~tp -> ~tp~n", [?MODULE, ?LINE, Key, Error]), iterate(TH#table_handle.collector_pid, Prev, Limit, Fun, Acc); Next -> lookup_and_apply(TH, Prev, Next, Limit, -1, Fun, Acc) @@ -785,7 +785,7 @@ prev_iterate(TH, Prev = first, Limit, Fun, Acc) -> '$end_of_table' -> Acc; {'EXIT', _} = Error -> - io:format("~p(~p): First ~p~n", [?MODULE, ?LINE, Error]), + io:format("~p(~p): First ~tp~n", [?MODULE, ?LINE, Error]), iterate(TH#table_handle.collector_pid, Prev, Limit, Fun, Acc); First -> lookup_and_apply(TH, Prev, First, Limit, 1, Fun, Acc) @@ -796,7 +796,7 @@ prev_iterate(TH, Prev = last, Limit, Fun, Acc) -> '$end_of_table' -> Acc; {'EXIT', _} = Error -> - io:format("~p(~p): Last ~p~n", [?MODULE, ?LINE, Error]), + io:format("~p(~p): Last ~tp~n", [?MODULE, ?LINE, Error]), iterate(TH#table_handle.collector_pid, Prev, Limit, Fun, Acc); Last -> lookup_and_apply(TH, Prev, Last, Limit, 1, Fun, Acc) @@ -808,7 +808,7 @@ prev_iterate(TH, Prev, Limit, Fun, Acc) -> '$end_of_table' -> Acc; {'EXIT', _} = Error -> - io:format("~p(~p): Prev ~p -> ~p~n", [?MODULE, ?LINE, Key, Error]), + io:format("~p(~p): Prev ~tp -> ~tp~n", [?MODULE, ?LINE, Key, Error]), iterate(TH#table_handle.collector_pid, Prev, Limit, Fun, Acc); Next -> lookup_and_apply(TH, Prev, Next, Limit, 1, Fun, Acc) @@ -1049,7 +1049,7 @@ handle_call(stop, _From, S) -> end, {stop, shutdown, ok, S}; handle_call(Request, From, S) -> - ok = error_logger:format("~p(~p): handle_call(~p, ~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_call(~tp, ~tp, ~tp)~n", [?MODULE, self(), Request, From, S]), reply({error, {bad_request, Request}}, S). @@ -1061,7 +1061,7 @@ handle_call(Request, From, S) -> %%---------------------------------------------------------------------- handle_cast(Msg, S) -> - ok = error_logger:format("~p(~p): handle_cast(~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_cast(~tp, ~tp)~n", [?MODULE, self(), Msg, S]), noreply(S). @@ -1083,18 +1083,18 @@ handle_info({nodeup, Node}, S) -> S2 = listen_on_trace_port(Node, Port, S), noreply(S2); {error, Reason} when Reason =:= already_started-> - ok = error_logger:format("~p(~p): producer ignored(~p:~p):~n ~p~n", + ok = error_logger:format("~p(~p): producer ignored(~p:~p):~n ~tp~n", [?MODULE, self(), Node, Port, Reason]), S2 = S#state{trace_port = Port + 1}, noreply(S2); {badrpc, Reason} -> - ok = error_logger:format("~p(~p): producer ignored(~p:~p):~n ~p~n", + ok = error_logger:format("~p(~p): producer ignored(~p:~p):~n ~tp~n", [?MODULE, self(), Node, Port, Reason]), S2 = S#state{trace_port = Port + 1}, noreply(S2); {error, Reason} -> self() ! {nodeup, Node}, - ok = error_logger:format("~p(~p): producer retry(~p:~p):~n ~p~n", + ok = error_logger:format("~p(~p): producer retry(~p:~p):~n ~tp~n", [?MODULE, self(), Node, Port, Reason]), S2 = S#state{trace_port = Port + 1}, noreply(S2) @@ -1125,12 +1125,12 @@ handle_info(Info = {'EXIT', Pid, Reason}, S) -> opt_unlink(S#state.parent_pid), {stop, Reason, S}; false -> - ok = error_logger:format("~p(~p): handle_info(~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_info(~tp, ~tp)~n", [?MODULE, self(), Info, S]), noreply(S) end; handle_info(Info, S) -> - ok = error_logger:format("~p(~p): handle_info(~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_info(~tp, ~tp)~n", [?MODULE, self(), Info, S]), noreply(S). @@ -1143,12 +1143,12 @@ listen_on_trace_port(Node, Port, S) -> S#state{trace_nodes = [Node | S#state.trace_nodes], trace_port = Port + 1}; {'EXIT', Reason} when Reason =:= already_started-> - ok = error_logger:format("~p(~p): consumer ignored(~p:~p): ~p~n", + ok = error_logger:format("~p(~p): consumer ignored(~p:~p): ~tp~n", [?MODULE, self(), Node, Port, Reason]), S#state{trace_port = Port + 1}; {'EXIT', Reason} -> self() ! {nodeup, Node}, - ok = error_logger:format("~p(~p): consumer retry(~p:~p):~n ~p~n", + ok = error_logger:format("~p(~p): consumer retry(~p:~p):~n ~tp~n", [?MODULE, self(), Node, Port, Reason]), S#state{trace_port = Port + 1} end. @@ -1247,7 +1247,7 @@ file_open(F) -> {ok, _} -> {ok, Fd}; {repaired, _, _, BadBytes} -> - ok = error_logger:format("~p: Skipped ~p bad bytes in file: ~p~n", + ok = error_logger:format("~p: Skipped ~p bad bytes in file: ~tp~n", [?MODULE, BadBytes, F#file.name]), {ok, Fd}; {error,Reason} -> diff --git a/lib/et/src/et_selector.erl b/lib/et/src/et_selector.erl index a0297c21d1..35db07cd99 100644 --- a/lib/et/src/et_selector.erl +++ b/lib/et/src/et_selector.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2001-2016. All Rights Reserved. +%% Copyright Ericsson AB 2001-2017. 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. @@ -208,7 +208,7 @@ parse_event(Mod, Trace) -> {to, undefined}, {drop, NumberOfDroppedItems}]}}; _ -> - error_logger:format("~p(~p): Ignoring unknown trace type -> ~p~n~n", + error_logger:format("~p(~p): Ignoring unknown trace type -> ~tp~n~n", [?MODULE, ?LINE, Trace]), false end. @@ -258,7 +258,7 @@ parse_seq_event(Trace, ParsedTS, ReportedTS, Label, Info) -> {serial, Serial}, {user_info, UserInfo}]}}; _ -> - error_logger:format("~p(~p): Ignoring unknown trace type -> ~p~n~n", + error_logger:format("~p(~p): Ignoring unknown trace type -> ~tp~n~n", [?MODULE, ?LINE, Trace]), false end. @@ -590,7 +590,7 @@ parse_event(Mod, Trace, ParsedTS, ReportedTS, From, Label, Contents) -> {to, From}, {gc_items, GcKeyValueList}]}}; _ -> - error_logger:format("~p(~p): Ignoring unknown trace type -> ~p~n~n", + error_logger:format("~p(~p): Ignoring unknown trace type -> ~tp~n~n", [?MODULE, ?LINE, Trace]), false end. diff --git a/lib/et/src/et_wx_contents_viewer.erl b/lib/et/src/et_wx_contents_viewer.erl index 247dd4c7ba..bca517317e 100644 --- a/lib/et/src/et_wx_contents_viewer.erl +++ b/lib/et/src/et_wx_contents_viewer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2017. 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. @@ -213,7 +213,7 @@ init([S]) when is_record(S, state) -> %%---------------------------------------------------------------------- handle_call(Request, From, S) -> - ok = error_logger:format("~p(~p): handle_call(~p, ~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_call(~tp, ~tp, ~tp)~n", [?MODULE, self(), Request, From, S]), Reply = {error, {bad_request, Request}}, {reply, Reply, S}. @@ -226,7 +226,7 @@ handle_call(Request, From, S) -> %%---------------------------------------------------------------------- handle_cast(Msg, S) -> - ok = error_logger:format("~p(~p): handle_cast(~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_cast(~tp, ~tp)~n", [?MODULE, self(), Msg, S]), {noreply, S}. @@ -272,10 +272,11 @@ handle_event(#wx{id = Id, end, FileName = lists:flatten(["et_contents_viewer_", now_to_string(TimeStamp), ".txt"]), Style = ?wxFD_SAVE bor ?wxFD_OVERWRITE_PROMPT, - Msg = "Select a file to the events to", + Msg = "Select a file to save events to", case select_file(S#state.frame, Msg, filename:absname(FileName), Style) of {ok, FileName2} -> - Bin = list_to_binary(event_to_string(Event, S#state.event_order)), + EventString = event_to_string(Event, S#state.event_order), + Bin = unicode:characters_to_binary(EventString), ok = file:write_file(FileName2, Bin); cancel -> ok @@ -381,7 +382,7 @@ handle_event(#wx{event = #wxSize{size = {W, H}}}, S) -> S2 = S#state{width = W, height = H}, {noreply, S2}; handle_event(Wx = #wx{}, S) -> - io:format("~p got an unexpected event: ~p\n", [self(), Wx]), + io:format("~p got an unexpected event: ~tp\n", [self(), Wx]), {noreply, S}. %%---------------------------------------------------------------------- @@ -405,7 +406,7 @@ handle_info({'EXIT', Pid, Reason}, S) -> {noreply, S} end; handle_info(Info, S) -> - ok = error_logger:format("~p(~p): handle_info(~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_info(~tp, ~tp)~n", [?MODULE, self(), Info, S]), {noreply, S}. @@ -606,8 +607,8 @@ do_config_editor(Editor, Event, _Colour, TsKey) -> %%%---------------------------------------------------------------------- term_to_string(Term) -> - case catch io_lib:format("~s", [Term]) of - {'EXIT', _} -> io_lib:format("~p", [Term]); + case catch io_lib:format("~ts", [Term]) of + {'EXIT', _} -> io_lib:format("~tp", [Term]); GoodString -> GoodString end. @@ -659,7 +660,7 @@ pad_string(Int, MinLen, Char, Dir) when is_integer(Int) -> pad_string(Atom, MinLen, Char, Dir) when is_atom(Atom) -> pad_string(atom_to_list(Atom), MinLen, Char, Dir); pad_string(String, MinLen, Char, Dir) when is_integer(MinLen), MinLen >= 0 -> - Len = length(String), + Len = string:length(String), case {Len >= MinLen, Dir} of {true, _} -> String; diff --git a/lib/et/src/et_wx_viewer.erl b/lib/et/src/et_wx_viewer.erl index 9613299e6b..4dd44e7a4c 100644 --- a/lib/et/src/et_wx_viewer.erl +++ b/lib/et/src/et_wx_viewer.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2017. 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. @@ -352,7 +352,7 @@ handle_call({open_event, N}, _From, S) when is_integer(N), N > 0-> Reply = do_open_event(S, N), reply(Reply, S); handle_call(Request, From, S) -> - ok = error_logger:format("~p(~p): handle_call(~p, ~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_call(~tp, ~tp, ~tp)~n", [?MODULE, self(), Request, From, S]), Reply = {error, {bad_request, Request}}, reply(Reply, S). @@ -365,7 +365,7 @@ handle_call(Request, From, S) -> %%---------------------------------------------------------------------- handle_cast(Msg, S) -> - ok = error_logger:format("~p(~p): handle_cast(~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_cast(~tp, ~tp)~n", [?MODULE, self(), Msg, S]), noreply(S). @@ -803,7 +803,7 @@ handle_info(timeout, S) -> handle_info({'EXIT', Pid, Reason}, S) -> if Pid =:= S#state.collector_pid -> - io:format("collector died: ~p\n\n", [Reason]), + io:format("collector died: ~tp\n\n", [Reason]), wxFrame:destroy(S#state.frame), {stop, Reason, S}; Pid =:= S#state.parent_pid -> @@ -853,10 +853,10 @@ handle_info(#wx{event = #wxPaint{}}, S) -> S2 = refresh_main_window(S), noreply(S2); handle_info(#wx{event = #wxMouse{type = T, x=X,y=Y}}, S) -> - io:format("~p ~p\n", [T, {X,Y}]), + io:format("~tp ~tp\n", [T, {X,Y}]), noreply(S); handle_info(Info, S) -> - ok = error_logger:format("~p(~p): handle_info(~p, ~p)~n", + ok = error_logger:format("~p(~p): handle_info(~tp, ~tp)~n", [?MODULE, self(), Info, S]), noreply(S). @@ -1162,7 +1162,7 @@ open_viewer(Scale, FilterName, Actors, S) -> %% unlink(ViewerPid), ok; {error, Reason} -> - ok = error_logger:format("~p: Failed to start a new window: ~p~n", + ok = error_logger:format("~p: Failed to start a new window: ~tp~n", [?MODULE, Reason]) end. @@ -1393,7 +1393,7 @@ create_filter_menu(S=#state{filter_menu = {Menu,Data}}, ActiveFilterName, Filter wxMenu:delete(Menu,I) catch _:Reason -> - io:format("Could not delete item: ~p, because ~p.\n", [I, Reason]) + io:format("Could not delete item: ~tp, because ~tp.\n", [I, Reason]) end end, Data), @@ -1872,7 +1872,7 @@ create_contents_window(Event, {S, Res}) -> {ok, Pid} -> {S, [{ok, Pid} | Res]}; {error, Reason} -> - ok = error_logger:format("~p(~p): create_contents_window(~p) ->~n ~p~n", + ok = error_logger:format("~p(~p): create_contents_window(~tp) ->~n ~tp~n", [?MODULE, self(), Options, Reason]), {S, [{error, Reason} | Res]}; Stuff -> @@ -2069,15 +2069,15 @@ create_actor(Name) -> #actor{name = Name, string = String, include = false, exclude = false}. name_to_string(Name) -> - case catch io_lib:format("~s", [Name]) of - {'EXIT', _} -> lists:flatten(io_lib:format("~w", [Name])); + case catch io_lib:format("~ts", [Name]) of + {'EXIT', _} -> lists:flatten(io_lib:format("~tw", [Name])); GoodString -> lists:flatten(GoodString) end. pad_string(Atom, MinLen) when is_atom(Atom) -> pad_string(atom_to_list(Atom), MinLen); pad_string(String, MinLen) when is_integer(MinLen), MinLen >= 0 -> - Len = length(String), + Len = string:length(String), case Len >= MinLen of true -> String; diff --git a/lib/eunit/src/eunit_lib.erl b/lib/eunit/src/eunit_lib.erl index aa2cffc66d..e340f50a3c 100644 --- a/lib/eunit/src/eunit_lib.erl +++ b/lib/eunit/src/eunit_lib.erl @@ -107,7 +107,7 @@ format_stacktrace(Trace) -> format_stacktrace(Trace, "in function", "in call from"). format_stacktrace([{M,F,A,L}|Fs], Pre, Pre1) when is_integer(A) -> - [io_lib:fwrite("~ts ~w:~w/~w~ts\n", + [io_lib:fwrite("~ts ~w:~tw/~w~ts\n", [Pre, M, F, A, format_stacktrace_location(L)]) | format_stacktrace(Fs, Pre1, Pre1)]; format_stacktrace([{M,F,As,L}|Fs], Pre, Pre1) when is_list(As) -> @@ -121,9 +121,9 @@ format_stacktrace([{M,F,As,L}|Fs], Pre, Pre1) when is_list(As) -> io_lib:fwrite("~ts ~ts ~ts", [format_arg(A1),F,format_arg(A2)]); false -> - io_lib:fwrite("~w(~ts)", [F,format_arglist(As)]) + io_lib:fwrite("~tw(~ts)", [F,format_arglist(As)]) end, - [io_lib:fwrite("~ts ~w:~w/~w~ts\n called as ~ts\n", + [io_lib:fwrite("~ts ~w:~tw/~w~ts\n called as ~ts\n", [Pre,M,F,A,format_stacktrace_location(L),C]) | format_stacktrace(Fs,Pre1,Pre1)]; format_stacktrace([{M,F,As}|Fs], Pre, Pre1) -> @@ -162,15 +162,15 @@ is_op(_M, _F, _A) -> format_error({bad_test, Term}) -> error_msg("bad test descriptor", "~tP", [Term, 15]); format_error({bad_generator, {{M,F,A}, Term}}) -> - error_msg(io_lib:format("result from generator ~w:~w/~w is not a test", + error_msg(io_lib:format("result from generator ~w:~tw/~w is not a test", [M,F,A]), "~tP", [Term, 15]); format_error({generator_failed, {{M,F,A}, Exception}}) -> - error_msg(io_lib:format("test generator ~w:~w/~w failed",[M,F,A]), + error_msg(io_lib:format("test generator ~w:~tw/~w failed",[M,F,A]), "~ts", [format_exception(Exception)]); format_error({no_such_function, {M,F,A}}) when is_atom(M), is_atom(F), is_integer(A) -> - error_msg(io_lib:format("no such function: ~w:~w/~w", [M,F,A]), + error_msg(io_lib:format("no such function: ~w:~tw/~w", [M,F,A]), "", []); format_error({module_not_found, M}) -> error_msg("test module not found", "~tp", [M]); @@ -185,7 +185,7 @@ format_error({cleanup_failed, Exception}) -> error_msg("context cleanup failed", "~ts", [format_exception(Exception)]); format_error({{bad_instantiator, {{M,F,A}, Term}}, _DummyException}) -> - error_msg(io_lib:format("result from instantiator ~w:~w/~w is not a test", + error_msg(io_lib:format("result from instantiator ~w:~tw/~w is not a test", [M,F,A]), "~tP", [Term, 15]); format_error({instantiation_failed, Exception}) -> @@ -384,11 +384,9 @@ fun_parent(F) -> {arity, A} = erlang:fun_info(F, arity), {M, N, A}; {type, local} -> - [$-|S] = atom_to_list(N), - C1 = string:chr(S, $/), - C2 = string:chr(S, $-), - {M, list_to_atom(string:sub_string(S, 1, C1 - 1)), - list_to_integer(string:sub_string(S, C1 + 1, C2 - 1))} + [$-|S] = atom_to_list(N), + [S2, T] = string:split(S, "/", trailing), + {M, list_to_atom(S2), element(1, string:to_integer(T))} end. -ifdef(TEST). diff --git a/lib/eunit/src/eunit_tty.erl b/lib/eunit/src/eunit_tty.erl index 77a7cf1fd5..2c9a598628 100644 --- a/lib/eunit/src/eunit_tty.erl +++ b/lib/eunit/src/eunit_tty.erl @@ -235,7 +235,7 @@ print_test_error({skipped, Reason}, _) -> format_skipped({module_not_found, M}) -> io_lib:fwrite("missing module: ~w", [M]); format_skipped({no_such_function, {M,F,A}}) -> - io_lib:fwrite("no such function: ~w:~w/~w", [M,F,A]). + io_lib:fwrite("no such function: ~w:~tw/~w", [M,F,A]). print_test_cancel(Reason) -> fwrite(format_cancel(Reason)). diff --git a/lib/hipe/cerl/cerl_cconv.erl b/lib/hipe/cerl/cerl_cconv.erl index 122e6ef039..2cd0e261d5 100644 --- a/lib/hipe/cerl/cerl_cconv.erl +++ b/lib/hipe/cerl/cerl_cconv.erl @@ -258,7 +258,7 @@ bind_module_defs([], Env, S) -> check_function_name(Name, S) -> case s__is_function_name(Name, S) of true -> - error_msg("multiple definitions of function `~w'.", [Name]), + error_msg("multiple definitions of function `~tw'.", [Name]), exit(error); false -> ok diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl index 9bf8547745..f07ec52cfa 100644 --- a/lib/kernel/src/error_logger.erl +++ b/lib/kernel/src/error_logger.erl @@ -499,27 +499,16 @@ display4(A = [_|_]) -> display4(A) -> erlang:display(A). -string_p([]) -> + +string_p(Term) when is_list(Term) -> + string_p1(lists:flatten(Term)); +string_p(_Term) -> + false. + +string_p1([]) -> false; -string_p(Term) -> - string_p1(Term). - -string_p1([H|T]) when is_integer(H), H >= $\s, H < 255 -> - string_p1(T); -string_p1([$\n|T]) -> string_p1(T); -string_p1([$\r|T]) -> string_p1(T); -string_p1([$\t|T]) -> string_p1(T); -string_p1([$\v|T]) -> string_p1(T); -string_p1([$\b|T]) -> string_p1(T); -string_p1([$\f|T]) -> string_p1(T); -string_p1([$\e|T]) -> string_p1(T); -string_p1([H|T]) when is_list(H) -> - case string_p1(H) of - true -> string_p1(T); - _ -> false - end; -string_p1([]) -> true; -string_p1(_) -> false. +string_p1(FlatList) -> + io_lib:printable_list(FlatList). -spec limit_term(term()) -> term(). diff --git a/lib/kernel/src/file_server.erl b/lib/kernel/src/file_server.erl index 6504174cbc..6e8f64d932 100644 --- a/lib/kernel/src/file_server.erl +++ b/lib/kernel/src/file_server.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2017. 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. @@ -207,7 +207,7 @@ handle_call(stop, _From, Handle) -> {stop, normal, stopped, Handle}; handle_call(Request, From, Handle) -> - error_logger:error_msg("handle_call(~p, ~p, _)", [Request, From]), + error_logger:error_msg("handle_call(~tp, ~tp, _)", [Request, From]), {noreply, Handle}. %%---------------------------------------------------------------------- @@ -220,7 +220,7 @@ handle_call(Request, From, Handle) -> -spec handle_cast(term(), state()) -> {'noreply', state()}. handle_cast(Msg, State) -> - error_logger:error_msg("handle_cast(~p, _)", [Msg]), + error_logger:error_msg("handle_cast(~tp, _)", [Msg]), {noreply, State}. %%---------------------------------------------------------------------- @@ -243,7 +243,7 @@ handle_info({'EXIT', Handle, _Reason}, Handle) -> {stop, normal, Handle}; handle_info(Info, State) -> - error_logger:error_msg("handle_Info(~p, _)", [Info]), + error_logger:error_msg("handle_Info(~tp, _)", [Info]), {noreply, State}. %%---------------------------------------------------------------------- diff --git a/lib/kernel/src/global.erl b/lib/kernel/src/global.erl index a9e92b28b8..a38522eb5c 100644 --- a/lib/kernel/src/global.erl +++ b/lib/kernel/src/global.erl @@ -262,7 +262,7 @@ check_dupname(Name, Pid) -> {ok, allow} -> true; _ -> - S = "global: ~w registered under several names: ~w\n", + S = "global: ~w registered under several names: ~tw\n", Names = [Name | [Name1 || {_Pid, Name1} <- PidNames]], error_logger:error_msg(S, [Pid, Names]), false @@ -659,7 +659,7 @@ handle_call(stop, _From, S) -> handle_call(Request, From, S) -> error_logger:warning_msg("The global_name_server " "received an unexpected message:\n" - "handle_call(~p, ~p, _)\n", + "handle_call(~tp, ~tp, _)\n", [Request, From]), {noreply, S}. @@ -828,7 +828,7 @@ handle_cast({async_del_lock, _ResourceId, _Pid}, S) -> handle_cast(Request, S) -> error_logger:warning_msg("The global_name_server " "received an unexpected message:\n" - "handle_cast(~p, _)\n", [Request]), + "handle_cast(~tp, _)\n", [Request]), {noreply, S}. %%======================================================================== @@ -955,7 +955,7 @@ handle_info({'DOWN', MonitorRef, process, _Pid, _Info}, S0) -> handle_info(Message, S) -> error_logger:warning_msg("The global_name_server " "received an unexpected message:\n" - "handle_info(~p, _)\n", [Message]), + "handle_info(~tp, _)\n", [Message]), {noreply, S}. @@ -1949,13 +1949,13 @@ exchange_names([{Name, Pid, Method} | Tail], Node, Ops, Res) -> exchange_names(Tail, Node, [Op | Ops], [Op | Res]); {badrpc, Badrpc} -> error_logger:info_msg("global: badrpc ~w received when " - "conflicting name ~w was found\n", + "conflicting name ~tw was found\n", [Badrpc, Name]), Op = {insert, {Name, Pid, Method}}, exchange_names(Tail, Node, [Op | Ops], Res); Else -> error_logger:info_msg("global: Resolve method ~w for " - "conflicting name ~w returned ~w\n", + "conflicting name ~tw returned ~tw\n", [Method, Name, Else]), Op = {delete, Name}, exchange_names(Tail, Node, [Op | Ops], [Op | Res]) @@ -1984,7 +1984,7 @@ minmax(P1,P2) -> Pid2 :: pid(). random_exit_name(Name, Pid, Pid2) -> {Min, Max} = minmax(Pid, Pid2), - error_logger:info_msg("global: Name conflict terminating ~w\n", + error_logger:info_msg("global: Name conflict terminating ~tw\n", [{Name, Max}]), exit(Max, kill), Min. @@ -2200,7 +2200,7 @@ unexpected_message({'EXIT', _Pid, _Reason}, _What) -> ok; unexpected_message(Message, What) -> error_logger:warning_msg("The global_name_server ~w process " - "received an unexpected message:\n~p\n", + "received an unexpected message:\n~tp\n", [What, Message]). %%% Utilities diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl index fb4faea420..f36b4f1e6a 100644 --- a/lib/kernel/src/net_kernel.erl +++ b/lib/kernel/src/net_kernel.erl @@ -778,7 +778,7 @@ handle_info(transition_period_end, {noreply,State#state{tick = #tick{ticker = Tckr, time = T}}}; handle_info(X, State) -> - error_msg("Net kernel got ~w~n",[X]), + error_msg("Net kernel got ~tw~n",[X]), {noreply,State}. %% ----------------------------------------------------------- diff --git a/lib/kernel/src/pg2.erl b/lib/kernel/src/pg2.erl index edf4aedde2..c4732f37ee 100644 --- a/lib/kernel/src/pg2.erl +++ b/lib/kernel/src/pg2.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2016. All Rights Reserved. +%% Copyright Ericsson AB 1997-2017. 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. @@ -199,7 +199,7 @@ handle_call({delete, Name}, _From, S) -> {reply, ok, S}; handle_call(Request, From, S) -> error_logger:warning_msg("The pg2 server received an unexpected message:\n" - "handle_call(~p, ~p, _)\n", + "handle_call(~tp, ~tp, _)\n", [Request, From]), {noreply, S}. diff --git a/lib/mnesia/src/mnesia.erl b/lib/mnesia/src/mnesia.erl index 3b771e8c5b..b68b2de028 100644 --- a/lib/mnesia/src/mnesia.erl +++ b/lib/mnesia/src/mnesia.erl @@ -2283,9 +2283,9 @@ list_index_plugins([{N,M,F} | T] = Ps, Legend) -> lists:foldl(fun({N1,_,_}, Wa) -> erlang:max(Wa, length(pp_ix_name(N1))) end, 0, Ps)), - io:fwrite(Legend ++ "~-" ++ W ++ "s - ~s:~s~n", + io:fwrite(Legend ++ "~-" ++ W ++ "s - ~s:~ts~n", [pp_ix_name(N), atom_to_list(M), atom_to_list(F)]), - [io:fwrite(Indent ++ "~-" ++ W ++ "s - ~s:~s~n", + [io:fwrite(Indent ++ "~-" ++ W ++ "s - ~s:~ts~n", [pp_ix_name(N1), atom_to_list(M1), atom_to_list(F1)]) || {N1,M1,F1} <- T]. diff --git a/lib/mnesia/src/mnesia_bup.erl b/lib/mnesia/src/mnesia_bup.erl index 3e55deb958..34f16f178b 100644 --- a/lib/mnesia/src/mnesia_bup.erl +++ b/lib/mnesia/src/mnesia_bup.erl @@ -920,7 +920,7 @@ create_dat_files([{schema, Tab, TabDef} | Tail], Ext, LocalTabs) -> ok -> ok; {error, Reason} -> - mnesia_lib:fatal("Cannot rename file ~p -> ~p: ~p~n", + mnesia_lib:fatal("Cannot rename file ~tp -> ~tp: ~tp~n", [TmpFile, DclFile, Reason]) end end @@ -1016,7 +1016,7 @@ disc_only_swap_fun(disc_only_copies, Expunge, Open, Close) -> ok -> ok; {error, Reason} -> - mnesia_lib:fatal("Cannot rename file ~p -> ~p: ~p~n", + mnesia_lib:fatal("Cannot rename file ~tp -> ~tp: ~tp~n", [TmpFile, DatFile, Reason]) end end; diff --git a/lib/mnesia/src/mnesia_checkpoint.erl b/lib/mnesia/src/mnesia_checkpoint.erl index 8659e4622c..2ff77326a9 100644 --- a/lib/mnesia/src/mnesia_checkpoint.erl +++ b/lib/mnesia/src/mnesia_checkpoint.erl @@ -683,14 +683,14 @@ retainer_create(_Cp, R, Tab, Name, Ext = {ext, Alias, Mod}) -> Cs = val({Tab, cstruct}), Mod:load_table(Alias, T, {retainer, create_table}, mnesia_schema:cs2list(Cs)), - dbg_out("Checkpoint retainer created ~p ~p~n", [Name, Tab]), + dbg_out("Checkpoint retainer created ~p ~tp~n", [Name, Tab]), R#retainer{store = {Ext, T}, really_retain = true}; retainer_create(_Cp, R, Tab, Name, disc_only_copies) -> Fname = tab2retainer({Tab, Name}), file:delete(Fname), Args = [{file, Fname}, {type, set}, {keypos, 2}, {repair, false}], {ok, _} = mnesia_lib:dets_sync_open({Tab, Name}, Args), - dbg_out("Checkpoint retainer created ~p ~p~n", [Name, Tab]), + dbg_out("Checkpoint retainer created ~p ~tp~n", [Name, Tab]), R#retainer{store = {dets, {Tab, Name}}, really_retain = true}; retainer_create(Cp, R, Tab, Name, Storage) -> T = ?ets_new_table(mnesia_retainer, [set, public, {keypos, 2}]), @@ -698,7 +698,7 @@ retainer_create(Cp, R, Tab, Name, Storage) -> ReallyR = R#retainer.really_retain, ReallyCp = lists:member(Tab, Overriders), ReallyR2 = prepare_ram_tab(Tab, T, Storage, ReallyR, ReallyCp), - dbg_out("Checkpoint retainer created ~p ~p~n", [Name, Tab]), + dbg_out("Checkpoint retainer created ~p ~tp~n", [Name, Tab]), R#retainer{store = {ets, T}, really_retain = ReallyR2}. %% Copy the dumped table into retainer if needed @@ -849,7 +849,7 @@ retainer_loop(Cp = #checkpoint_args{is_activated=false, name=Name}) -> retainer_loop(Cp#checkpoint_args{iterators = Iters}); {system, From, Msg} -> - dbg_out("~p got {system, ~p, ~p}~n", [?MODULE, From, Msg]), + dbg_out("~p got {system, ~p, ~tp}~n", [?MODULE, From, Msg]), sys:handle_system_msg(Msg, From, Cp#checkpoint_args.supervisor, ?MODULE, [], Cp) end; @@ -938,11 +938,11 @@ retainer_loop(Cp = #checkpoint_args{name=Name}) -> retainer_loop(Cp#checkpoint_args{iterators = Iters}); {system, From, Msg} -> - dbg_out("~p got {system, ~p, ~p}~n", [?MODULE, From, Msg]), + dbg_out("~p got {system, ~p, ~tp}~n", [?MODULE, From, Msg]), sys:handle_system_msg(Msg, From, Cp#checkpoint_args.supervisor, ?MODULE, [], Cp); Msg -> - dbg_out("~p got ~p~n", [?MODULE, Msg]) + dbg_out("~p got ~tp~n", [?MODULE, Msg]) end. maybe_activate(Cp) diff --git a/lib/mnesia/src/mnesia_controller.erl b/lib/mnesia/src/mnesia_controller.erl index 6b93935cb4..77013489b3 100644 --- a/lib/mnesia/src/mnesia_controller.erl +++ b/lib/mnesia/src/mnesia_controller.erl @@ -446,7 +446,7 @@ try_schedule_late_disc_load(Tabs, Reason, MsgTag) -> [BadNodes]), try_schedule_late_disc_load(Tabs, Reason, MsgTag); {aborted, AbortReason} -> - fatal("Cannot late_load_tables~p: ~p~n", + fatal("Cannot late_load_tables ~tp: ~tp~n", [[Tabs, Reason, MsgTag], AbortReason]) end. @@ -535,7 +535,7 @@ try_merge_schema(Nodes, Told0, UserFun) -> end, try_merge_schema(Nodes, Told, UserFun); {atomic, {"Cannot get cstructs", Node, Reason}} -> - dbg_out("Cannot get cstructs, Node ~p ~p~n", [Node, Reason]), + dbg_out("Cannot get cstructs, Node ~p ~tp~n", [Node, Reason]), timer:sleep(300), % Avoid a endless loop look alike try_merge_schema(Nodes, Told0, UserFun); {aborted, {shutdown, _}} -> %% One of the nodes is going down @@ -826,12 +826,12 @@ handle_call({del_other, Who}, _From, State = #state{others=Others0}) -> {reply, ok, State#state{others=Others}}; handle_call(Msg, _From, State) -> - error("~p got unexpected call: ~p~n", [?SERVER_NAME, Msg]), + error("~p got unexpected call: ~tp~n", [?SERVER_NAME, Msg]), noreply(State). late_disc_load(TabsR, Reason, RemoteLoaders, From, State = #state{loader_queue = LQ, late_loader_queue = LLQ}) -> - verbose("Intend to load tables: ~p~n", [TabsR]), + verbose("Intend to load tables: ~tp~n", [TabsR]), ?eval_debug_fun({?MODULE, late_disc_load}, [{tabs, TabsR}, {reason, Reason}, @@ -1118,7 +1118,7 @@ handle_cast({adopt_orphans, Node, Tabs}, State) -> noreply(State2); handle_cast(Msg, State) -> - error("~p got unexpected cast: ~p~n", [?SERVER_NAME, Msg]), + error("~p got unexpected cast: ~tp~n", [?SERVER_NAME, Msg]), noreply(State). handle_sync_tabs([Tab | Tabs], From) -> @@ -1166,7 +1166,7 @@ handle_info(#dumper_done{worker_pid=Pid, worker_res=Res}, State) -> State3 = opt_start_worker(State2), noreply(State3); true -> - fatal("Dumper failed: ~p~n state: ~p~n", [Res, State]), + fatal("Dumper failed: ~p~n state: ~tp~n", [Res, State]), {stop, fatal, State} end; @@ -1249,7 +1249,7 @@ handle_info(#sender_done{worker_pid=Pid, worker_res=Res}, State) -> true -> %% No need to send any message to the table receiver %% since it will soon get a mnesia_down anyway - fatal("Sender failed: ~p~n state: ~p~n", [Res, State]), + fatal("Sender failed: ~p~n state: ~tp~n", [Res, State]), {stop, fatal, State} end; @@ -1257,7 +1257,7 @@ handle_info({'EXIT', Pid, R}, State) when Pid == State#state.supervisor -> ?SAFE(set(mnesia_status, stopping)), case State#state.dumper_pid of undefined -> - dbg_out("~p was ~p~n", [?SERVER_NAME, R]), + dbg_out("~p was ~tp~n", [?SERVER_NAME, R]), {stop, shutdown, State}; _ -> noreply(State#state{is_stopping = true}) @@ -1266,12 +1266,12 @@ handle_info({'EXIT', Pid, R}, State) when Pid == State#state.supervisor -> handle_info({'EXIT', Pid, R}, State) when Pid == State#state.dumper_pid -> case State#state.dumper_queue of [#schema_commit_lock{}|Workers] -> %% Schema trans crashed or was killed - dbg_out("WARNING: Dumper ~p exited ~p~n", [Pid, R]), + dbg_out("WARNING: Dumper ~p exited ~tp~n", [Pid, R]), State2 = State#state{dumper_queue = Workers, dumper_pid = undefined}, State3 = opt_start_worker(State2), noreply(State3); _Other -> - fatal("Dumper or schema commit crashed: ~p~n state: ~p~n", [R, State]), + fatal("Dumper or schema commit crashed: ~p~n state: ~tp~n", [R, State]), {stop, fatal, State} end; @@ -1280,15 +1280,15 @@ handle_info(Msg = {'EXIT', Pid, R}, State) when R /= wait_for_tables_timeout -> true -> %% No need to send any message to the table receiver %% since it will soon get a mnesia_down anyway - fatal("Sender crashed: ~p~n state: ~p~n", [{Pid,R}, State]), + fatal("Sender crashed: ~p~n state: ~tp~n", [{Pid,R}, State]), {stop, fatal, State}; false -> case lists:keymember(Pid, 1, get_loaders(State)) of true -> - fatal("Loader crashed: ~p~n state: ~p~n", [R, State]), + fatal("Loader crashed: ~p~n state: ~tp~n", [R, State]), {stop, fatal, State}; false -> - error("~p got unexpected info: ~p~n", [?SERVER_NAME, Msg]), + error("~p got unexpected info: ~tp~n", [?SERVER_NAME, Msg]), noreply(State) end end; @@ -1308,7 +1308,7 @@ handle_info({'EXIT', Pid, wait_for_tables_timeout}, State) -> noreply(State); handle_info(Msg, State) -> - error("~p got unexpected info: ~p~n", [?SERVER_NAME, Msg]), + error("~p got unexpected info: ~tp~n", [?SERVER_NAME, Msg]), noreply(State). sync_tab_timeout(Pid, [{{sync_tab, Tab}, Pids} | Tail]) -> @@ -2054,7 +2054,7 @@ opt_start_sender2([Sender|R], Pids, Kept, LoaderQ) -> Pid = spawn_link(?MODULE, send_and_reply,[self(), Sender]), opt_start_sender2(R,[{Pid,Sender}|Pids],Kept,LoaderQ); true -> - verbose("Send table failed ~p not active on this node ~n", [Tab]), + verbose("Send table failed ~tp not active on this node ~n", [Tab]), Sender#send_table.receiver_pid ! {copier_done, node()}, opt_start_sender2(R,Pids, Kept, LoaderQ) end. @@ -2239,7 +2239,7 @@ disc_load_table(Tab, Reason, ReplyTo) -> Done#loader_done{is_loaded = false, reply = Res}; true -> - fatal("Cannot load table ~p from disc: ~p~n", [Tab, Res]) + fatal("Cannot load table ~tp from disc: ~tp~n", [Tab, Res]) end. filter_active(Tab) -> diff --git a/lib/mnesia/src/mnesia_dumper.erl b/lib/mnesia/src/mnesia_dumper.erl index eb02a585a6..f0ed7aef4a 100644 --- a/lib/mnesia/src/mnesia_dumper.erl +++ b/lib/mnesia/src/mnesia_dumper.erl @@ -193,7 +193,7 @@ do_perform_dump(Cont, InPlace, InitBy, Regulator, OldVersion) -> do_perform_dump(C2, InPlace, InitBy, Regulator, Version) catch _:R when R =/= fatal -> ST = erlang:get_stacktrace(), - Reason = {"Transaction log dump error: ~p~n", [{R, ST}]}, + Reason = {"Transaction log dump error: ~tp~n", [{R, ST}]}, close_files(InPlace, {error, Reason}, InitBy), exit(Reason) end; @@ -329,7 +329,7 @@ perform_update(Tid, SchemaOps, _DumperMode, _UseDir) -> ST = erlang:get_stacktrace(), Error = {error, {"Schema update error", {Reason, ST}}}, close_files(InPlace, Error, InitBy), - fatal("Schema update error ~p ~p", [{Reason,ST}, SchemaOps]) + fatal("Schema update error ~tp ~tp", [{Reason,ST}, SchemaOps]) end. insert_ops(_Tid, _Storage, [], _InPlace, _InitBy, _) -> ok; @@ -1166,7 +1166,7 @@ needs_dump_ets(Tab) -> DcdF = mnesia_lib:tab2dcd(Tab), case file:read_file_info(DcdF) of {error, Reason} -> - mnesia_lib:dbg_out("File ~p info_error ~p ~n", + mnesia_lib:dbg_out("File ~tp info_error ~tp ~n", [DcdF, Reason]), true; {ok, DcdInfo} -> @@ -1205,7 +1205,7 @@ prepare_open(Tab, UpdateInPlace) -> Tmp = mnesia_lib:tab2tmp(Tab), try ok = mnesia_lib:copy_file(Dat, Tmp) catch error:Error -> - fatal("Cannot copy dets file ~p to ~p: ~p~n", + fatal("Cannot copy dets file ~tp to ~tp: ~tp~n", [Dat, Tmp, Error]) end, Tmp @@ -1441,7 +1441,7 @@ start_regulator() -> {ok, Pid} -> Pid; {error, Reason} -> - fatal("Failed to start ~n: ~p~n", [N, Reason]) + fatal("Failed to start ~n: ~tp~n", [N, Reason]) end end. diff --git a/lib/mnesia/src/mnesia_event.erl b/lib/mnesia/src/mnesia_event.erl index b06043bc61..49b3990086 100644 --- a/lib/mnesia/src/mnesia_event.erl +++ b/lib/mnesia/src/mnesia_event.erl @@ -103,11 +103,11 @@ handle_any_event({mnesia_system_event, Event}, State) -> handle_any_event({mnesia_table_event, Event}, State) -> handle_table_event(Event, State); handle_any_event(Msg, State) -> - report_error("~p got unexpected event: ~p~n", [?MODULE, Msg]), + report_error("~p got unexpected event: ~tp~n", [?MODULE, Msg]), {ok, State}. handle_table_event({Oper, Record, TransId}, State) -> - report_info("~p performed by ~p on record:~n\t~p~n", + report_info("~p performed by ~p on record:~n\t~tp~n", [Oper, TransId, Record]), {ok, State}. @@ -155,7 +155,7 @@ handle_system_event({mnesia_down, Node}, State) -> end; handle_system_event({mnesia_overload, Details}, State) -> - report_warning("Mnesia is overloaded: ~w~n", [Details]), + report_warning("Mnesia is overloaded: ~tw~n", [Details]), {ok, State}; handle_system_event({mnesia_info, Format, Args}, State) -> @@ -175,16 +175,16 @@ handle_system_event({mnesia_fatal, Format, Args, BinaryCore}, State) -> {ok, State#state{dumped_core = true}}; handle_system_event({inconsistent_database, Reason, Node}, State) -> - report_error("mnesia_event got {inconsistent_database, ~w, ~w}~n", + report_error("mnesia_event got {inconsistent_database, ~tw, ~w}~n", [Reason, Node]), {ok, State}; handle_system_event({mnesia_user, Event}, State) -> - report_info("User event: ~p~n", [Event]), + report_info("User event: ~tp~n", [Event]), {ok, State}; handle_system_event(Msg, State) -> - report_error("mnesia_event got unexpected system event: ~p~n", [Msg]), + report_error("mnesia_event got unexpected system event: ~tp~n", [Msg]), {ok, State}. report_info(Format0, Args0) -> diff --git a/lib/mnesia/src/mnesia_index.erl b/lib/mnesia/src/mnesia_index.erl index c79f790973..d121bd01e9 100644 --- a/lib/mnesia/src/mnesia_index.erl +++ b/lib/mnesia/src/mnesia_index.erl @@ -420,7 +420,7 @@ make_ram_index(Tab, Storage, [Pos | Tail]) -> add_ram_index(Tab, Storage, {Pos, _Pref}) -> Type = ordered, - verbose("Creating index for ~w ~p ~p~n", [Tab, Pos, Type]), + verbose("Creating index for ~tw ~p ~p~n", [Tab, Pos, Type]), SetOrBag = val({Tab, setorbag}), IxValsF = index_vals_f(Storage, Tab, Pos), IxFun = fun(Val, Key) -> {{Val, Key}} end, diff --git a/lib/mnesia/src/mnesia_late_loader.erl b/lib/mnesia/src/mnesia_late_loader.erl index e273329ffc..e4f8dcf2b9 100644 --- a/lib/mnesia/src/mnesia_late_loader.erl +++ b/lib/mnesia/src/mnesia_late_loader.erl @@ -87,13 +87,13 @@ loop(State) -> loop(State); {system, From, Msg} -> - mnesia_lib:dbg_out("~p got {system, ~p, ~p}~n", + mnesia_lib:dbg_out("~p got {system, ~p, ~tp}~n", [?SERVER_NAME, From, Msg]), Parent = State#state.supervisor, sys:handle_system_msg(Msg, From, Parent, ?MODULE, [], State); Msg -> - mnesia_lib:error("~p got unexpected message: ~p~n", + mnesia_lib:error("~p got unexpected message: ~tp~n", [?SERVER_NAME, Msg]), loop(State) end. diff --git a/lib/mnesia/src/mnesia_lib.erl b/lib/mnesia/src/mnesia_lib.erl index 1fdc656600..53fdd76de8 100644 --- a/lib/mnesia/src/mnesia_lib.erl +++ b/lib/mnesia/src/mnesia_lib.erl @@ -467,7 +467,7 @@ pr_other(Var) -> no -> {node_not_running, node()}; _ -> {no_exists, Var} end, - verbose("~p (~p) val(mnesia_gvar, ~w) -> ~p ~p ~n", + verbose("~p (~tp) val(mnesia_gvar, ~tw) -> ~p ~tp ~n", [self(), process_info(self(), registered_name), Var, Why, erlang:get_stacktrace()]), mnesia:abort(Why). @@ -654,7 +654,7 @@ coredump() -> coredump(CrashInfo) -> Core = mkcore(CrashInfo), Out = core_file(), - important("Writing Mnesia core to file: ~p...~p~n", [Out, CrashInfo]), + important("Writing Mnesia core to file: ~tp...~tp~n", [Out, CrashInfo]), _ = file:write_file(Out, Core), Out. @@ -844,7 +844,7 @@ vcore() -> case file:list_dir(Cwd) of {ok, Files}-> CoreFiles = lists:sort(lists:zf(Filter, Files)), - show("Mnesia core files: ~p~n", [CoreFiles]), + show("Mnesia core files: ~tp~n", [CoreFiles]), vcore(lists:last(CoreFiles)); Error -> Error @@ -853,17 +853,17 @@ vcore() -> vcore(Bin) when is_binary(Bin) -> Core = binary_to_term(Bin), Fun = fun({Item, Info}) -> - show("***** ~p *****~n", [Item]), + show("***** ~tp *****~n", [Item]), case catch vcore_elem({Item, Info}) of {'EXIT', Reason} -> - show("{'EXIT', ~p}~n", [Reason]); + show("{'EXIT', ~tp}~n", [Reason]); _ -> ok end end, lists:foreach(Fun, Core); vcore(File) -> - show("~n***** Mnesia core: ~p *****~n", [File]), + show("~n***** Mnesia core: ~tp *****~n", [File]), case file:read_file(File) of {ok, Bin} -> vcore(Bin); @@ -879,7 +879,7 @@ vcore_elem({schema_file, {ok, B}}) -> vcore_elem({logfile, {ok, BinList}}) -> Fun = fun({F, Info}) -> - show("----- logfile: ~p -----~n", [F]), + show("----- logfile: ~tp -----~n", [F]), case Info of {ok, B} -> Fname = "/tmp/mnesia_vcore_elem.TMP", @@ -887,7 +887,7 @@ vcore_elem({logfile, {ok, BinList}}) -> mnesia_log:view(Fname), file:delete(Fname); _ -> - show("~p~n", [Info]) + show("~tp~n", [Info]) end end, lists:foreach(Fun, BinList); @@ -895,12 +895,12 @@ vcore_elem({logfile, {ok, BinList}}) -> vcore_elem({crashinfo, {Format, Args}}) -> show(Format, Args); vcore_elem({gvar, L}) -> - show("~p~n", [lists:sort(L)]); + show("~tp~n", [lists:sort(L)]); vcore_elem({transactions, Info}) -> mnesia_tm:display_info(user, Info); vcore_elem({_Item, Info}) -> - show("~p~n", [Info]). + show("~tp~n", [Info]). fix_error(X) -> set(last_error, X), %% for debugabililty @@ -1018,7 +1018,7 @@ report_system_event({'EXIT', Reason}, Event) -> end; Error -> - Msg = "Mnesia(~p): Cannot report event ~p: ~p (~p)~n", + Msg = "Mnesia(~tp): Cannot report event ~tp: ~tp (~tp)~n", error_logger:format(Msg, [node(), Event, Reason, Error]) end, ok; diff --git a/lib/mnesia/src/mnesia_loader.erl b/lib/mnesia/src/mnesia_loader.erl index c710470a2c..4c6336cb73 100644 --- a/lib/mnesia/src/mnesia_loader.erl +++ b/lib/mnesia/src/mnesia_loader.erl @@ -46,7 +46,7 @@ val(Var) -> disc_load_table(Tab, Reason) -> Storage = val({Tab, storage_type}), Type = val({Tab, setorbag}), - dbg_out("Getting table ~p (~p) from disc: ~p~n", + dbg_out("Getting table ~tp (~p) from disc: ~tp~n", [Tab, Storage, Reason]), ?eval_debug_fun({?MODULE, do_get_disc_copy}, [{tab, Tab}, @@ -56,7 +56,7 @@ disc_load_table(Tab, Reason) -> do_get_disc_copy2(Tab, Reason, Storage, Type). do_get_disc_copy2(Tab, _Reason, Storage, _Type) when Storage == unknown -> - verbose("Local table copy of ~p has recently been deleted, ignored.~n", + verbose("Local table copy of ~tp has recently been deleted, ignored.~n", [Tab]), {not_loaded, storage_unknown}; do_get_disc_copy2(Tab, Reason, Storage, Type) when Storage == disc_copies -> @@ -199,20 +199,20 @@ net_load_table(Tab, Reason, Ns, _Cs) -> try_net_load_table(Tab, Reason, Ns, val({Tab, cstruct})). try_net_load_table(Tab, _Reason, [], _Cs) -> - verbose("Copy failed. No active replicas of ~p are available.~n", [Tab]), + verbose("Copy failed. No active replicas of ~tp are available.~n", [Tab]), {not_loaded, none_active}; try_net_load_table(Tab, Reason, Ns, Cs) -> Storage = mnesia_lib:cs_to_storage_type(node(), Cs), do_get_network_copy(Tab, Reason, Ns, Storage, Cs). do_get_network_copy(Tab, _Reason, _Ns, unknown, _Cs) -> - verbose("Local table copy of ~p has recently been deleted, ignored.~n", [Tab]), + verbose("Local table copy of ~tp has recently been deleted, ignored.~n", [Tab]), {not_loaded, storage_unknown}; do_get_network_copy(Tab, Reason, Ns, Storage, Cs) -> [Node | Tail] = Ns, case lists:member(Node,val({current, db_nodes})) of true -> - dbg_out("Getting table ~p (~p) from node ~p: ~p~n", + dbg_out("Getting table ~tp (~p) from node ~p: ~tp~n", [Tab, Storage, Node, Reason]), ?eval_debug_fun({?MODULE, do_get_network_copy}, [{tab, Tab}, {reason, Reason}, @@ -222,7 +222,7 @@ do_get_network_copy(Tab, Reason, Ns, Storage, Cs) -> set({Tab, load_node}, Node), set({Tab, load_reason}, Reason), mnesia_controller:i_have_tab(Tab), - dbg_out("Table ~p copied from ~p to ~p~n", [Tab, Node, node()]), + dbg_out("Table ~tp copied from ~p to ~p~n", [Tab, Node, node()]), {loaded, ok}; Err = {error, _} when element(1, Reason) == dumper -> {not_loaded,Err}; @@ -286,12 +286,12 @@ init_receiver(Node, Tab,Storage,Cs,Reason) -> element(1,Reason) == dumper -> {error,Result}; {atomic, {error,Result}} -> - fatal("Cannot create table ~p: ~p~n", + fatal("Cannot create table ~tp: ~tp~n", [[Tab, Storage], Result]); {atomic, Result} -> Result; {aborted, nomore} -> restart; {aborted, _Reas} -> - verbose("Receiver failed on ~p from ~p:~nReason: ~p~n", + verbose("Receiver failed on ~tp from ~p:~nReason: ~tp~n", [Tab,Node,_Reas]), down %% either this node or sender is dying end, @@ -313,7 +313,7 @@ start_remote_sender(Node,Tab,Storage) -> {SenderPid, TabSize, DetsData}; %% Protocol conversion hack {copier_done, Node} -> - verbose("Sender of table ~p crashed on node ~p ~n", [Tab, Node]), + verbose("Sender of table ~tp crashed on node ~p ~n", [Tab, Node]), down(Tab, Storage) end. @@ -374,7 +374,7 @@ do_init_table(Tab,Storage,Cs,SenderPid, tab_receiver(Node,Tab,Storage,Cs,OrigTabRec); Reason -> Msg = "[d]ets:init table failed", - verbose("~s: ~p: ~p~n", [Msg, Tab, Reason]), + verbose("~ts: ~tp: ~tp~n", [Msg, Tab, Reason]), down(Tab, Storage) end; Error -> @@ -432,7 +432,7 @@ tab_receiver(Node, Tab, Storage, Cs, OrigTabRec) -> %% Protocol conversion hack {copier_done, Node} -> - verbose("Sender of table ~p crashed on node ~p ~n", [Tab, Node]), + verbose("Sender of table ~tp crashed on node ~p ~n", [Tab, Node]), down(Tab, Storage); {'EXIT', Pid, Reason} -> @@ -490,7 +490,7 @@ ext_load_table(Mod, Alias, Tab, Reason) -> ext_init_table(Action, Alias, Mod, Tab, Fun, State, Sender) -> case Fun(Action) of {copier_done, Node} -> - verbose("Receiver of table ~p crashed on ~p (more)~n", [Tab, Node]), + verbose("Receiver of table ~tp crashed on ~p (more)~n", [Tab, Node]), down(Tab, {ext,Alias,Mod}); {Data, NewFun} -> case Mod:receive_data(Data, Alias, Tab, Sender, State) of @@ -553,7 +553,7 @@ finish_copy(Storage,Tab,Cs,SenderPid,DatBin,OrigTabRec) -> ok; {error, Reason} -> Msg = "Failed to handle last", - verbose("~s: ~p: ~p~n", [Msg, Tab, Reason]), + verbose("~ts: ~tp: ~tp~n", [Msg, Tab, Reason]), down(Tab, Storage) end. @@ -859,7 +859,7 @@ send_more(Pid, N, Chunk, DataState, Tab, Storage) -> send_more(Pid, 1, NewChunk, Init(), Tab, Storage); {copier_done, Node} when Node == node(Pid)-> - verbose("Receiver of table ~p crashed on ~p (more)~n", [Tab, Node]), + verbose("Receiver of table ~tp crashed on ~p (more)~n", [Tab, Node]), throw(receiver_died) end. @@ -937,7 +937,7 @@ finish_copy(Pid, Tab, Storage, RemoteS, NeedLock) -> {Pid, no_more} -> % Dont bother about the spurious 'more' message no_more; {copier_done, Node} -> - verbose("Tab receiver ~p crashed (more): ~p~n", [Tab, Node]), + verbose("Tab receiver ~tp crashed (more): ~p~n", [Tab, Node]), receiver_died end end, diff --git a/lib/mnesia/src/mnesia_locker.erl b/lib/mnesia/src/mnesia_locker.erl index 59fd89059f..073b48abc0 100644 --- a/lib/mnesia/src/mnesia_locker.erl +++ b/lib/mnesia/src/mnesia_locker.erl @@ -245,7 +245,7 @@ loop(State) -> do_stop(); {system, From, Msg} -> - verbose("~p got {system, ~p, ~p}~n", [?MODULE, From, Msg]), + verbose("~p got {system, ~p, ~tp}~n", [?MODULE, From, Msg]), Parent = State#state.supervisor, sys:handle_system_msg(Msg, From, Parent, ?MODULE, [], State); @@ -254,7 +254,7 @@ loop(State) -> loop(State); Msg -> - error("~p got unexpected message: ~p~n", [?MODULE, Msg]), + error("~p got unexpected message: ~tp~n", [?MODULE, Msg]), loop(State) end. diff --git a/lib/mnesia/src/mnesia_log.erl b/lib/mnesia/src/mnesia_log.erl index 9536effd42..55b1d6e419 100644 --- a/lib/mnesia/src/mnesia_log.erl +++ b/lib/mnesia/src/mnesia_log.erl @@ -310,7 +310,7 @@ verify_no_exists(Fname) -> false -> ok; true -> - fatal("Log file exists: ~p~n", [Fname]) + fatal("Log file exists: ~tp~n", [Fname]) end. open_log(Name, Header, Fname) -> @@ -331,7 +331,7 @@ open_log(Name, Header, Fname, Exists, Repair) -> open_log(Name, Header, Fname, Exists, Repair, Mode) -> Args = [{file, Fname}, {name, Name}, {repair, Repair}, {mode, Mode}], -%% io:format("~p:open_log: ~p ~p~n", [?MODULE, Name, Fname]), +%% io:format("~p:open_log: ~tp ~tp~n", [?MODULE, Name, Fname]), case mnesia_monitor:open_log(Args) of {ok, Log} when Exists == true -> Log; @@ -344,19 +344,19 @@ open_log(Name, Header, Fname, Exists, Repair, Mode) -> write_header(Log, Header), Log; {repaired, Log, _Recover, BadBytes} -> - mnesia_lib:important("Data may be missing, log ~p repaired: Lost ~p bytes~n", + mnesia_lib:important("Data may be missing, log ~tp repaired: Lost ~p bytes~n", [Fname, BadBytes]), Log; {error, Reason = {file_error, _Fname, emfile}} -> - fatal("Cannot open log file ~p: ~p~n", [Fname, Reason]); + fatal("Cannot open log file ~tp: ~tp~n", [Fname, Reason]); {error, Reason} when Repair == true -> file:delete(Fname), - mnesia_lib:important("Data may be missing, Corrupt logfile deleted: ~p, ~p ~n", + mnesia_lib:important("Data may be missing, Corrupt logfile deleted: ~tp, ~tp ~n", [Fname, Reason]), %% Create a new open_log(Name, Header, Fname, false, false, read_write); {error, Reason} -> - fatal("Cannot open log file ~p: ~p~n", [Fname, Reason]) + fatal("Cannot open log file ~tp: ~tp~n", [Fname, Reason]) end. write_header(Log, Header) -> @@ -381,7 +381,7 @@ close_log(Log) -> {error, {read_only_mode, Log}} -> ok; {error, Reason} -> - mnesia_lib:important("Failed syncing ~p to_disk reason ~p ~n", + mnesia_lib:important("Failed syncing ~tp to_disk reason ~tp ~n", [Log, Reason]) end, mnesia_monitor:close_log(Log). @@ -464,13 +464,13 @@ chunk_log(_Log, eof) -> chunk_log(Log, Cont) -> case disk_log:chunk(Log, Cont) of {error, Reason} -> - fatal("Possibly truncated ~p file: ~p~n", + fatal("Possibly truncated ~tp file: ~tp~n", [Log, Reason]); {C2, Chunk, _BadBytes} -> %% Read_only case, should we warn about the bad log file? %% BUGBUG Should we crash if Repair == false ?? %% We got to check this !! - mnesia_lib:important("~p repaired, lost ~p bad bytes~n", [Log, _BadBytes]), + mnesia_lib:important("~tp repaired, lost ~p bad bytes~n", [Log, _BadBytes]), {C2, Chunk}; Other -> Other @@ -505,7 +505,7 @@ prepare_decision_log_dump(false, Prev) -> ok -> prepare_decision_log_dump(true, Prev); {error, Reason} -> - fatal("Cannot rename decision log file ~p -> ~p: ~p~n", + fatal("Cannot rename decision log file ~tp -> ~tp: ~tp~n", [decision_log_file(), Prev, Reason]) end; prepare_decision_log_dump(true, Prev) -> @@ -522,7 +522,7 @@ confirm_decision_log_dump() -> ok -> file:delete(previous_decision_log_file()); {error, Reason} -> - fatal("Cannot confirm decision log dump: ~p~n", + fatal("Cannot confirm decision log dump: ~tp~n", [Reason]) end. @@ -561,7 +561,7 @@ view() -> lists:foreach(fun(F) -> view(F) end, log_files()). view(File) -> - mnesia_lib:show("***** ~p ***** ~n", [File]), + mnesia_lib:show("***** ~tp ***** ~n", [File]), case exists(File) of false -> nolog; @@ -574,25 +574,25 @@ view(File) -> {repaired, _, _, _} -> view_file(start, N); {error, Reason} -> - error("Cannot open log ~p: ~p~n", [File, Reason]) + error("Cannot open log ~tp: ~tp~n", [File, Reason]) end end. view_file(C, Log) -> case disk_log:chunk(Log, C) of {error, Reason} -> - error("** Possibly truncated FILE ~p~n", [Reason]), + error("** Possibly truncated FILE ~tp~n", [Reason]), error; eof -> disk_log:close(Log), eof; {C2, Terms, _BadBytes} -> - dbg_out("Lost ~p bytes in ~p ~n", [_BadBytes, Log]), - lists:foreach(fun(X) -> mnesia_lib:show("~p~n", [X]) end, + dbg_out("Lost ~p bytes in ~tp ~n", [_BadBytes, Log]), + lists:foreach(fun(X) -> mnesia_lib:show("~tp~n", [X]) end, Terms), view_file(C2, Log); {C2, Terms} -> - lists:foreach(fun(X) -> mnesia_lib:show("~p~n", [X]) end, + lists:foreach(fun(X) -> mnesia_lib:show("~tp~n", [X]) end, Terms), view_file(C2, Log) end. @@ -750,12 +750,12 @@ abort_write_fun(B, What, Args) -> abort_write(B, What, Args, Reason) -> Mod = B#backup_args.module, Opaque = B#backup_args.opaque, - dbg_out("Failed to perform backup. M=~p:F=~p:A=~p -> ~p~n", + dbg_out("Failed to perform backup. M=~p:F=~tp:A=~tp -> ~tp~n", [Mod, What, Args, Reason]), try apply(Mod, abort_write, [Opaque]) of {ok, _Res} -> throw({error, Reason}) catch _:Other -> - error("Failed to abort backup. ~p:~p~p -> ~p~n", + error("Failed to abort backup. ~p:~tp~tp -> ~tp~n", [Mod, abort_write, [Opaque], Other]), throw({error, Reason}) end. @@ -802,7 +802,7 @@ select_source(Tab, Name, PrevName) -> {PrevName, retainer}; _ -> %% Do a full backup anyway - dbg_out("Incremental backup escalated to full backup: ~p~n", [Tab]), + dbg_out("Incremental backup escalated to full backup: ~tp~n", [Tab]), {Name, table} end end. diff --git a/lib/mnesia/src/mnesia_monitor.erl b/lib/mnesia/src/mnesia_monitor.erl index 22a24b6dc9..4cfe16dec0 100644 --- a/lib/mnesia/src/mnesia_monitor.erl +++ b/lib/mnesia/src/mnesia_monitor.erl @@ -178,10 +178,10 @@ check_protocol([{Node, {reject, _Mon, Version, Protocol}} | Tail], Protocols) -> [Node, Protocols, Version, Protocol]), check_protocol(Tail, Protocols); check_protocol([{error, _Reason} | Tail], Protocols) -> - dbg_out("~p connect failed error: ~p~n", [?MODULE, _Reason]), + dbg_out("~p connect failed error: ~tp~n", [?MODULE, _Reason]), check_protocol(Tail, Protocols); check_protocol([{badrpc, _Reason} | Tail], Protocols) -> - dbg_out("~p connect failed badrpc: ~p~n", [?MODULE, _Reason]), + dbg_out("~p connect failed badrpc: ~tp~n", [?MODULE, _Reason]), check_protocol(Tail, Protocols); check_protocol([], [Protocol | _Protocols]) -> set(protocol_version, Protocol), @@ -246,10 +246,10 @@ start_proc(Who, Mod, Fun, Args) -> proc_lib:start_link(mnesia_sp, init_proc, Args2, infinity). terminate_proc(Who, R, State) when R /= shutdown, R /= killed -> - fatal("~p crashed: ~p state: ~p~n", [Who, R, State]); + fatal("~p crashed: ~p state: ~tp~n", [Who, R, State]); terminate_proc(Who, Reason, _State) -> - mnesia_lib:verbose("~p terminated: ~p~n", [Who, Reason]), + mnesia_lib:verbose("~p terminated: ~tp~n", [Who, Reason]), ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -294,7 +294,7 @@ init([Parent]) -> {ok, #state{supervisor = Parent}} catch _:Reason -> - mnesia_lib:report_fatal("Bad configuration: ~p~n", [Reason]), + mnesia_lib:report_fatal("Bad configuration: ~tp~n", [Reason]), {stop, {bad_config, Reason}} end. @@ -333,7 +333,7 @@ handle_call({mktab, Tab, Args}, _From, State) -> catch error:ExitReason -> Msg = "Cannot create ets table", Reason = {system_limit, Msg, Tab, Args, ExitReason}, - fatal("~p~n", [Reason]), + fatal("~tp~n", [Reason]), {noreply, State} end; @@ -353,7 +353,7 @@ handle_call({open_dets, Tab, Args}, _From, State) -> {error, Reason} -> Msg = "Cannot open dets table", Error = {error, {Msg, Tab, Args, Reason}}, - fatal("~p~n", [Error]), + fatal("~tp~n", [Error]), {noreply, State} end; @@ -385,7 +385,7 @@ handle_call({reopen_log, Name, Fname, Head}, _From, State) -> {error, Reason} -> Msg = "Cannot rename disk_log file", Error = {error, {Msg, Name, Fname, Head, Reason}}, - fatal("~p~n", [Error]), + fatal("~tp~n", [Error]), {noreply, State} end; @@ -400,7 +400,7 @@ handle_call({close_log, Name}, _From, State) -> {error, Reason} -> Msg = "Cannot close disk_log file", Error = {error, {Msg, Name, Reason}}, - fatal("~p~n", [Error]), + fatal("~tp~n", [Error]), {noreply, State} end; @@ -461,7 +461,7 @@ handle_call(init, _From, State) -> {reply, EarlyNodes, State2}; handle_call(Msg, _From, State) -> - error("~p got unexpected call: ~p~n", [?MODULE, Msg]), + error("~p got unexpected call: ~tp~n", [?MODULE, Msg]), {noreply, State}. accept_protocol(Mon, Version, Protocol, From, State) -> @@ -535,7 +535,7 @@ handle_cast({inconsistent_database, Context, Node}, State) -> {noreply, State}; handle_cast(Msg, State) -> - error("~p got unexpected cast: ~p~n", [?MODULE, Msg]), + error("~p got unexpected cast: ~tp~n", [?MODULE, Msg]), {noreply, State}. %%---------------------------------------------------------------------- @@ -572,7 +572,7 @@ handle_info(Msg = {'EXIT',Pid,_}, State) -> %% We have probably got an exit signal from %% disk_log or dets Hint = "Hint: check that the disk still is writable", - fatal("~p got unexpected info: ~p; ~p~n", + fatal("~p got unexpected info: ~tp; ~p~n", [?MODULE, Msg, Hint]) end; @@ -599,13 +599,13 @@ handle_info({disk_log, _Node, Log, Info}, State) -> {truncated, _No} -> ok; _ -> - mnesia_lib:important("Warning Log file ~p error reason ~s~n", + mnesia_lib:important("Warning Log file ~tp error reason ~ts~n", [Log, disk_log:format_error(Info)]) end, {noreply, State}; handle_info(Msg, State) -> - error("~p got unexpected info (~p): ~p~n", [?MODULE, State, Msg]). + error("~p got unexpected info (~tp): ~tp~n", [?MODULE, State, Msg]). process_q(State = #state{mq=[]}) -> {noreply,State}; process_q(State = #state{mq=[{info,Msg}|R]}) -> diff --git a/lib/mnesia/src/mnesia_recover.erl b/lib/mnesia/src/mnesia_recover.erl index b204fb282f..d792070332 100644 --- a/lib/mnesia/src/mnesia_recover.erl +++ b/lib/mnesia/src/mnesia_recover.erl @@ -762,7 +762,7 @@ handle_call(sync, _From, State) -> {reply, ok, State}; handle_call(Msg, _From, State) -> - error("~p got unexpected call: ~p~n", [?MODULE, Msg]), + error("~p got unexpected call: ~tp~n", [?MODULE, Msg]), {noreply, State}. do_log_mnesia_up(Node) -> @@ -881,7 +881,7 @@ handle_cast({log_dump_overload, Flag}, State) when is_boolean(Flag) -> {noreply, State#state{log_dump_overload = Flag}}; handle_cast(Msg, State) -> - error("~p got unexpected cast: ~p~n", [?MODULE, Msg]), + error("~p got unexpected cast: ~tp~n", [?MODULE, Msg]), {noreply, State}. %%---------------------------------------------------------------------- @@ -927,11 +927,11 @@ handle_info({force_decision, Tid}, State) -> end; handle_info({'EXIT', Pid, R}, State) when Pid == State#state.supervisor -> - mnesia_lib:dbg_out("~p was ~p~n",[?MODULE, R]), + mnesia_lib:dbg_out("~p was ~tp~n",[?MODULE, R]), {stop, shutdown, State}; handle_info(Msg, State) -> - error("~p got unexpected info: ~p~n", [?MODULE, Msg]), + error("~p got unexpected info: ~tp~n", [?MODULE, Msg]), {noreply, State}. %%---------------------------------------------------------------------- diff --git a/lib/mnesia/src/mnesia_schema.erl b/lib/mnesia/src/mnesia_schema.erl index f71ee26d7c..83cc19c678 100644 --- a/lib/mnesia/src/mnesia_schema.erl +++ b/lib/mnesia/src/mnesia_schema.erl @@ -386,7 +386,7 @@ delete_schema(Ns) when is_list(Ns), Ns /= [] -> [] -> ok; BadReplies -> - verbose("~s: ~p~n", [Reason, BadReplies]), + verbose("~s: ~tp~n", [Reason, BadReplies]), {error, {"All nodes not running", BadReplies}} end; {_Replies, BadNs} -> @@ -467,10 +467,10 @@ opt_create_dir(UseDir, Dir) when UseDir == true-> false -> case file:make_dir(Dir) of ok -> - verbose("Create Directory ~p~n", [Dir]), + verbose("Create Directory ~tp~n", [Dir]), ok; {error, Reason} -> - verbose("Cannot create mnesia dir ~p~n", [Reason]), + verbose("Cannot create mnesia dir ~tp~n", [Reason]), {error, {"Cannot create Mnesia dir", Dir, Reason}} end end; @@ -1470,7 +1470,7 @@ verify_backend_type(Name, Module) -> [] -> ok; _Other -> - io:fwrite(user, "Missing backend_type exports: ~p~n", [_Other]), + io:fwrite(user, "Missing backend_type exports: ~tp~n", [_Other]), mnesia:abort({bad_type, {backend_type,Name,Module}}) end. @@ -1776,7 +1776,7 @@ make_del_table_copy(Tab, Node) -> mnesia:abort({combine_error, Tab, "Last replica"}); [] -> ensure_active(Cs), - dbg_out("Last replica deleted in table ~p~n", [Tab]), + dbg_out("Last replica deleted in table ~tp~n", [Tab]), make_delete_table(Tab, whole_table); _ when Tab == schema -> %% ensure_active(Cs2), @@ -2178,13 +2178,13 @@ do_write_table_property(Tab, Prop) -> case change_prop_in_existing_op(Tab, Prop, write_property, Store) of true -> dbg_out("change_prop_in_existing_op" - "(~p,~p,write_property,Store) -> true~n", + "(~tp,~p,write_property,Store) -> true~n", [Tab,Prop]), %% we have merged the table prop into the create_table op ok; false -> dbg_out("change_prop_in_existing_op" - "(~p,~p,write_property,Store) -> false~n", + "(~tp,~p,write_property,Store) -> false~n", [Tab,Prop]), %% this must be an existing table get_tid_ts_and_lock(Tab, none), @@ -2315,13 +2315,13 @@ do_delete_table_property(Tab, PropKey) -> case change_prop_in_existing_op(Tab, PropKey, delete_property, Store) of true -> dbg_out("change_prop_in_existing_op" - "(~p,~p,delete_property,Store) -> true~n", + "(~tp,~p,delete_property,Store) -> true~n", [Tab,PropKey]), %% we have merged the table prop into the create_table op ok; false -> dbg_out("change_prop_in_existing_op" - "(~p,~p,delete_property,Store) -> false~n", + "(~tp,~p,delete_property,Store) -> false~n", [Tab,PropKey]), %% this must be an existing table get_tid_ts_and_lock(Tab, none), @@ -2435,17 +2435,17 @@ prepare_op(_Tid, {op, sync_trans}, {part, CoordPid}) -> {sync_trans, CoordPid} -> {false, optional}; {mnesia_down, _Node} = Else -> - mnesia_lib:verbose("sync_op terminated due to ~p~n", [Else]), + mnesia_lib:verbose("sync_op terminated due to ~tp~n", [Else]), mnesia:abort(Else); {'EXIT', _, _} = Else -> - mnesia_lib:verbose("sync_op terminated due to ~p~n", [Else]), + mnesia_lib:verbose("sync_op terminated due to ~tp~n", [Else]), mnesia:abort(Else) end; prepare_op(_Tid, {op, sync_trans}, {coord, Nodes}) -> case receive_sync(Nodes, []) of {abort, Reason} -> - mnesia_lib:verbose("sync_op terminated due to ~p~n", [Reason]), + mnesia_lib:verbose("sync_op terminated due to ~tp~n", [Reason]), mnesia:abort(Reason); Pids -> [Pid ! {sync_trans, self()} || Pid <- Pids], @@ -2707,7 +2707,7 @@ prepare_op(_Tid, {op, transform, Fun, TabDef}, _WaitFor) -> {true, Objs, mandatory} catch _:Reason -> mnesia_lib:db_fixtable(Storage, Tab, false), - mnesia_lib:important("Transform function failed: '~p' in '~p'", + mnesia_lib:important("Transform function failed: '~tp' in '~tp'", [Reason, erlang:get_stacktrace()]), exit({"Bad transform function", Tab, Fun, node(), Reason}) end @@ -2719,7 +2719,7 @@ prepare_op(_Tid, {op, merge_schema, TabDef}, _WaitFor) -> ok -> {true, optional}; Error -> - verbose("Merge_Schema ~p failed on ~p: ~p~n", [_Tid,node(),Error]), + verbose("Merge_Schema ~p failed on ~p: ~tp~n", [_Tid,node(),Error]), mnesia:abort({bad_commit, Error}) end; prepare_op(_Tid, _Op, _WaitFor) -> @@ -3133,7 +3133,7 @@ ext_real_suffixes(Ext) -> [M || {_,M} <- Ext]) catch error:E -> - verbose("Cant find real ext suffixes (~p)~n", [E]), + verbose("Cant find real ext suffixes (~tp)~n", [E]), [] end. @@ -3142,7 +3142,7 @@ ext_tmp_suffixes(Ext) -> [M || {_,M} <- Ext]) catch error:E -> - verbose("Cant find tmp ext suffixes (~p)~n", [E]), + verbose("Cant find tmp ext suffixes (~tp)~n", [E]), [] end. @@ -3153,14 +3153,14 @@ info() -> info(Tab) -> Props = get_table_properties(Tab), - io:format("-- Properties for ~w table --- ~n",[Tab]), + io:format("-- Properties for ~tw table --- ~n",[Tab]), info2(Tab, Props). info2(Tab, [{cstruct, _V} | Tail]) -> % Ignore cstruct info2(Tab, Tail); info2(Tab, [{frag_hash, _V} | Tail]) -> % Ignore frag_hash info2(Tab, Tail); info2(Tab, [{P, V} | Tail]) -> - io:format("~-20w -> ~p~n",[P,V]), + io:format("~-20tw -> ~tp~n",[P,V]), info2(Tab, Tail); info2(_, []) -> io:format("~n", []). @@ -3726,7 +3726,7 @@ merge_versions(AnythingNew, Cs, RemoteCs, Force) -> ok; true -> Str = io_lib:format("Bad cookies. Cannot merge definitions of " - "table ~w. Local = ~w, Remote = ~w~n", + "table ~tw. Local = ~w, Remote = ~w~n", [Cs#cstruct.name, Cs, RemoteCs]), throw(Str) end, @@ -3746,7 +3746,7 @@ merge_versions(AnythingNew, Cs, RemoteCs, Force) -> do_merge_versions(AnythingNew, Cs, RemoteCs); true -> Str1 = io_lib:format("Cannot merge definitions of " - "table ~w. Local = ~w, Remote = ~w~n", + "table ~tw. Local = ~w, Remote = ~w~n", [Cs#cstruct.name, Cs, RemoteCs]), throw(Str1) end. diff --git a/lib/mnesia/src/mnesia_subscr.erl b/lib/mnesia/src/mnesia_subscr.erl index c2748f5bae..dfaa20d2d3 100644 --- a/lib/mnesia/src/mnesia_subscr.erl +++ b/lib/mnesia/src/mnesia_subscr.erl @@ -264,7 +264,7 @@ handle_call({change, How}, _From, State) -> {reply, Reply, State}; handle_call(Msg, _From, State) -> - error("~p got unexpected call: ~p~n", [?MODULE, Msg]), + error("~p got unexpected call: ~tp~n", [?MODULE, Msg]), {noreply, State}. %%---------------------------------------------------------------------- @@ -274,7 +274,7 @@ handle_call(Msg, _From, State) -> %% {stop, Reason, State} (terminate/2 is called) %%---------------------------------------------------------------------- handle_cast(Msg, State) -> - error("~p got unexpected cast: ~p~n", [?MODULE, Msg]), + error("~p got unexpected cast: ~tp~n", [?MODULE, Msg]), {noreply, State}. %%---------------------------------------------------------------------- @@ -292,7 +292,7 @@ handle_info({'EXIT', Pid, _Reason}, State) -> {noreply, State}; handle_info(Msg, State) -> - error("~p got unexpected info: ~p~n", [?MODULE, Msg]), + error("~p got unexpected info: ~tp~n", [?MODULE, Msg]), {noreply, State}. %%---------------------------------------------------------------------- diff --git a/lib/mnesia/src/mnesia_text.erl b/lib/mnesia/src/mnesia_text.erl index 21adca813a..7d24d09472 100644 --- a/lib/mnesia/src/mnesia_text.erl +++ b/lib/mnesia/src/mnesia_text.erl @@ -87,18 +87,18 @@ validate_tab(_) -> error(badtab). make_tabs([{Tab, Def} | Tail]) -> try mnesia:table_info(Tab, where_to_read) of Node -> - io:format("** Table ~w already exists on ~p, just entering data~n", + io:format("** Table ~tw already exists on ~p, just entering data~n", [Tab, Node]), make_tabs(Tail) catch exit:_ -> %% non-existing table case mnesia:create_table(Tab, Def) of {aborted, Reason} -> - io:format("** Failed to create table ~w ~n" - "** Reason = ~w, Args = ~p~n", + io:format("** Failed to create table ~tw ~n" + "** Reason = ~tw, Args = ~tp~n", [Tab, Reason, Def]), [Tab | make_tabs(Tail)]; _ -> - io:format("New table ~w~n", [Tab]), + io:format("New table ~tw~n", [Tab]), make_tabs(Tail) end end; @@ -139,12 +139,12 @@ collect_data(Tabs, [{Line, Term} | Tail]) when is_tuple(Term) -> {value, _} -> [Term | collect_data(Tabs, Tail)]; _Other -> - io:format("Object:~p at line ~w unknown\n", [Term,Line]), + io:format("Object:~tp at line ~w unknown\n", [Term,Line]), error(undefined_object) end; collect_data(_Tabs, []) -> []; collect_data(_Tabs, [H|_T]) -> - io:format("Object:~p unknown\n", [H]), + io:format("Object:~tp unknown\n", [H]), error(undefined_object). error(What) -> throw({error, What}). @@ -178,7 +178,7 @@ read_term_from_stream(Stream, File, Line) -> {ok, {Line, Term}, EndLine}; {error, {NewLine,Mod,What}} -> Str = Mod:format_error(What), - io:format("Error in line:~p of:~p ~s\n", + io:format("Error in line:~p of:~tp ~ts\n", [NewLine, File, Str]), error end; diff --git a/lib/mnesia/src/mnesia_tm.erl b/lib/mnesia/src/mnesia_tm.erl index 305bf14bcf..ebf580d09e 100644 --- a/lib/mnesia/src/mnesia_tm.erl +++ b/lib/mnesia/src/mnesia_tm.erl @@ -314,7 +314,7 @@ doit_loop(#state{coordinators=Coordinators,participants=Participants,supervisor= ?eval_debug_fun({?MODULE, do_abort, pre}, [{tid, Tid}]), case gb_trees:lookup(Tid, Participants) of none -> - verbose("Tried to abort a non participant transaction ~p: ~p~n", + verbose("Tried to abort a non participant transaction ~p: ~tp~n", [Tid, Reason]), mnesia_locker:release_tid(Tid), doit_loop(State); @@ -417,7 +417,7 @@ doit_loop(#state{coordinators=Coordinators,participants=Participants,supervisor= {From, {unblock_me, Tab}} -> case lists:member(Tab, State#state.blocked_tabs) of false -> - verbose("Wrong dirty Op blocked on ~p ~p ~p", + verbose("Wrong dirty Op blocked on ~p ~tp ~p", [node(), Tab, From]), reply(From, unblocked), doit_loop(State); @@ -466,11 +466,11 @@ doit_loop(#state{coordinators=Coordinators,participants=Participants,supervisor= end; {system, From, Msg} -> - dbg_out("~p got {system, ~p, ~p}~n", [?MODULE, From, Msg]), + dbg_out("~p got {system, ~p, ~tp}~n", [?MODULE, From, Msg]), sys:handle_system_msg(Msg, From, Sup, ?MODULE, [], State); Msg -> - verbose("** ERROR ** ~p got unexpected message: ~p~n", [?MODULE, Msg]), + verbose("** ERROR ** ~p got unexpected message: ~tp~n", [?MODULE, Msg]), doit_loop(State) end. @@ -556,7 +556,7 @@ handle_exit(Pid, Reason, State) -> %% We got exit from a local fool doit_loop(State); {P = #participant{}, _RestP} -> - fatal("Participant ~p in transaction ~p died ~p~n", + fatal("Participant ~p in transaction ~p died ~tp~n", [P#participant.pid, P#participant.tid, Reason]), NewPs = gb_trees:delete(P#participant.tid,State#state.participants), doit_loop(State#state{participants = NewPs}) @@ -598,7 +598,7 @@ recover_coordinator(Tid, Etabs) -> ok %% to the new nested trans store. end catch _:Reason -> - dbg_out("Recovery of coordinator ~p failed:~n", + dbg_out("Recovery of coordinator ~p failed: ~tp~n", [Tid, {Reason, erlang:get_stacktrace()}]), Protocol = asym_trans, tell_outcome(Tid, Protocol, node(), CheckNodes, TellNodes) @@ -941,7 +941,7 @@ decr(_X) -> 0. return_abort(Fun, Args, Reason) -> {_Mod, Tid, Ts} = get(mnesia_activity_state), - dbg_out("Transaction ~p calling ~p with ~p failed: ~n ~p~n", + dbg_out("Transaction ~p calling ~tp with ~tp failed: ~n ~tp~n", [Tid, Fun, Args, Reason]), OldStore = Ts#tidstore.store, Nodes = get_elements(nodes, OldStore), @@ -1714,7 +1714,7 @@ commit_participant(Coord, Tid, Bin, C0, DiscNs, _RamNs) -> mnesia_schema:undo_prepare_commit(Tid, C0); Msg -> - verbose("** ERROR ** commit_participant ~p, got unexpected msg: ~p~n", + verbose("** ERROR ** commit_participant ~p, got unexpected msg: ~tp~n", [Tid, Msg]) end; {Tid, {do_abort, Reason}} -> @@ -1730,7 +1730,7 @@ commit_participant(Coord, Tid, Bin, C0, DiscNs, _RamNs) -> Msg -> reply(Coord, {do_abort, Tid, self(), {bad_commit,internal}}), - verbose("** ERROR ** commit_participant ~p, got unexpected msg: ~p~n", + verbose("** ERROR ** commit_participant ~p, got unexpected msg: ~tp~n", [Tid, Msg]) end catch _:Reason -> @@ -1804,7 +1804,7 @@ do_update(Tid, Storage, [Op | Ops], OldRes) -> %% Determine actual storage type and try again. %% BUGBUG: Updates may be lost if table is transformed. ST = erlang:get_stacktrace(), - verbose("do_update in ~w failed: ~p -> {'EXIT', ~p}~n", + verbose("do_update in ~w failed: ~tp -> {'EXIT', ~tp}~n", [Tid, Op, {Reason, ST}]), do_update(Tid, Storage, Ops, OldRes) end; @@ -1919,7 +1919,7 @@ do_snmp(Tid, [Head|Tail]) -> %% deleted our local replica or recently deattached %% the snmp table ST = erlang:get_stacktrace(), - verbose("do_snmp in ~w failed: ~p -> {'EXIT', ~p}~n", + verbose("do_snmp in ~w failed: ~tp -> {'EXIT', ~tp}~n", [Tid, Head, {Reason, ST}]) end, do_snmp(Tid, Tail). @@ -2151,7 +2151,7 @@ pr_participant(Stream, P) -> true -> Commit0 end, pr_tid(Stream, P#participant.tid), - io:format(Stream, "with participant objects ~p~n", [Commit]). + io:format(Stream, "with participant objects ~tp~n", [Commit]). pr_tid(Stream, Tid) -> @@ -2193,7 +2193,7 @@ search_pr_participant(S, [ P | Tail]) -> true -> Commit0 end, - io:format("~p~n", [Commit]), + io:format("~tp~n", [Commit]), search_pr_participant(S,Tail); %% !!!!! true -> search_pr_participant(S, Tail) @@ -2214,12 +2214,12 @@ display_pid_info(Pid) -> Reds = fetch(reductions, Info), LM = length(fetch(messages, Info)), pformat(io_lib:format("~p", [Pid]), - io_lib:format("~p", [Call]), - io_lib:format("~p", [Curr]), Reds, LM) + io_lib:format("~tp", [Call]), + io_lib:format("~tp", [Curr]), Reds, LM) end. pformat(A1, A2, A3, A4, A5) -> - io:format( "~-12s ~-21s ~-21s ~9w ~4w~n", [A1,A2,A3,A4,A5]). + io:format( "~-12s ~-21ts ~-21ts ~9w ~4w~n", [A1,A2,A3,A4,A5]). fetch(Key, Info) -> case lists:keysearch(Key, 1, Info) of diff --git a/lib/observer/src/cdv_atom_cb.erl b/lib/observer/src/cdv_atom_cb.erl index a123354c8f..86cdf2fd6d 100644 --- a/lib/observer/src/cdv_atom_cb.erl +++ b/lib/observer/src/cdv_atom_cb.erl @@ -42,7 +42,7 @@ get_info(_) -> {Info,TW}. format({Bin,q}) when is_binary(Bin) -> - [$'|binary_to_list(Bin)]; + [$'|lists:flatten(io_lib:format("~ts",[Bin]))]; format({Bin,nq}) when is_binary(Bin) -> lists:flatten(io_lib:format("~ts",[Bin])); format(D) -> diff --git a/lib/observer/src/cdv_bin_cb.erl b/lib/observer/src/cdv_bin_cb.erl index 5472d36a6f..5502869973 100644 --- a/lib/observer/src/cdv_bin_cb.erl +++ b/lib/observer/src/cdv_bin_cb.erl @@ -38,6 +38,7 @@ init_bin_page(Parent,{Type,Bin}) -> [{"Format \~p",cdv_html_wx,{Type,format_bin_fun("~p",Bin)}}, {"Format \~tp",cdv_html_wx,{Type,format_bin_fun("~tp",Bin)}}, {"Format \~w",cdv_html_wx,{Type,format_bin_fun("~w",Bin)}}, + {"Format \~tw",cdv_html_wx,{Type,format_bin_fun("~tw",Bin)}}, {"Format \~s",cdv_html_wx,{Type,format_bin_fun("~s",Bin)}}, {"Format \~ts",cdv_html_wx,{Type,format_bin_fun("~ts",Bin)}}, {"Hex",cdv_html_wx,{Type,hex_binary_fun(Bin)}}, @@ -56,7 +57,7 @@ format_bin_fun(Format,Bin) -> binary_to_term_fun(Bin) -> fun() -> try binary_to_term(Bin) of - Term -> plain_html(io_lib:format("~p",[Term])) + Term -> plain_html(io_lib:format("~tp",[Term])) catch error:badarg -> Warning = "This binary can not be converted to an Erlang term", observer_html_lib:warning(Warning) diff --git a/lib/observer/src/cdv_detail_wx.erl b/lib/observer/src/cdv_detail_wx.erl index 27057fd27f..4c26e447a6 100644 --- a/lib/observer/src/cdv_detail_wx.erl +++ b/lib/observer/src/cdv_detail_wx.erl @@ -133,7 +133,7 @@ handle_event(Event, _State) -> error({unhandled_event, Event}). handle_info(_Info, State) -> - %% io:format("~p: ~p, Handle info: ~p~n", [?MODULE, ?LINE, _Info]), + %% io:format("~p: ~p, Handle info: ~tp~n", [?MODULE, ?LINE, _Info]), {noreply, State}. handle_call(Call, From, _State) -> diff --git a/lib/observer/src/cdv_html_wx.erl b/lib/observer/src/cdv_html_wx.erl index 0ab0ba4315..5158e95a65 100644 --- a/lib/observer/src/cdv_html_wx.erl +++ b/lib/observer/src/cdv_html_wx.erl @@ -62,7 +62,7 @@ handle_info(active, State) -> {noreply, State}; handle_info(Info, State) -> - io:format("~p:~p: Unhandled info: ~p~n", [?MODULE, ?LINE, Info]), + io:format("~p:~p: Unhandled info: ~tp~n", [?MODULE, ?LINE, Info]), {noreply, State}. terminate(_Reason, _State) -> @@ -72,7 +72,7 @@ code_change(_, _, State) -> {ok, State}. handle_call(Msg, _From, State) -> - io:format("~p~p: Unhandled Call ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p~p: Unhandled Call ~tp~n",[?MODULE, ?LINE, Msg]), {reply, ok, State}. handle_cast({detail_win_closed, Id},#state{expand_wins=Opened0}=State) -> @@ -80,7 +80,7 @@ handle_cast({detail_win_closed, Id},#state{expand_wins=Opened0}=State) -> {noreply, State#state{expand_wins=Opened}}; handle_cast(Msg, State) -> - io:format("~p~p: Unhandled cast ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p~p: Unhandled cast ~tp~n",[?MODULE, ?LINE, Msg]), {noreply, State}. handle_event(#wx{event=#wxHtmlLink{type=command_html_link_clicked, @@ -118,7 +118,7 @@ handle_event(#wx{event=#wxHtmlLink{type=command_html_link_clicked, {noreply, NewState}; handle_event(Event, State) -> - io:format("~p:~p: Unhandled event ~p\n", [?MODULE,?LINE,Event]), + io:format("~p:~p: Unhandled event ~tp\n", [?MODULE,?LINE,Event]), {noreply, State}. %%%----------------------------------------------------------------- diff --git a/lib/observer/src/cdv_info_wx.erl b/lib/observer/src/cdv_info_wx.erl index 01fe6b15f2..7e416dd11a 100644 --- a/lib/observer/src/cdv_info_wx.erl +++ b/lib/observer/src/cdv_info_wx.erl @@ -65,7 +65,7 @@ handle_info(active, State) -> {noreply, State}; handle_info(Info, State) -> - io:format("~p:~p: Unhandled info: ~p~n", [?MODULE, ?LINE, Info]), + io:format("~p:~p: Unhandled info: ~tp~n", [?MODULE, ?LINE, Info]), {noreply, State}. terminate(_Reason, _State) -> @@ -88,11 +88,11 @@ handle_call(new_dump, _From, #state{callback=Callback,panel=Panel, {reply, ok, State#state{fpanel=NewFPanel,trunc_warn=TW}}; handle_call(Msg, _From, State) -> - io:format("~p~p: Unhandled Call ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p~p: Unhandled Call ~tp~n",[?MODULE, ?LINE, Msg]), {reply, ok, State}. handle_cast(Msg, State) -> - io:format("~p~p: Unhandled cast ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p~p: Unhandled cast ~tp~n",[?MODULE, ?LINE, Msg]), {noreply, State}. handle_event(#wx{event=#wxMouse{type=left_down},userData=Target}, State) -> @@ -108,7 +108,7 @@ handle_event(#wx{obj=Obj,event=#wxMouse{type=leave_window}},State) -> {noreply, State}; handle_event(Event, State) -> - io:format("~p:~p: Unhandled event ~p\n", [?MODULE,?LINE,Event]), + io:format("~p:~p: Unhandled event ~tp\n", [?MODULE,?LINE,Event]), {noreply, State}. %%%----------------------------------------------------------------- diff --git a/lib/observer/src/cdv_multi_wx.erl b/lib/observer/src/cdv_multi_wx.erl index b511503752..93f045b1da 100644 --- a/lib/observer/src/cdv_multi_wx.erl +++ b/lib/observer/src/cdv_multi_wx.erl @@ -94,7 +94,7 @@ handle_info(active, State) -> {noreply, NewState}; handle_info(Info, State) -> - io:format("~p:~p: Unhandled info: ~p~n", [?MODULE, ?LINE, Info]), + io:format("~p:~p: Unhandled info: ~tp~n", [?MODULE, ?LINE, Info]), {noreply, State}. terminate(_Reason, _State) -> @@ -112,11 +112,11 @@ handle_call(new_dump, _From, State) -> {reply, ok, NewState}; handle_call(Msg, _From, State) -> - io:format("~p:~p: Unhandled Call ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p:~p: Unhandled Call ~tp~n",[?MODULE, ?LINE, Msg]), {reply, ok, State}. handle_cast(Msg, State) -> - io:format("~p:~p: Unhandled cast ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p:~p: Unhandled cast ~tp~n",[?MODULE, ?LINE, Msg]), {noreply, State}. handle_event(#wx{event=#wxCommand{type=command_listbox_selected, @@ -136,7 +136,7 @@ handle_event(#wx{event=#wxCommand{type=command_listbox_selected, {noreply,NewState}; handle_event(Event, State) -> - io:format("~p:~p: Unhandled event ~p\n", [?MODULE,?LINE,Event]), + io:format("~p:~p: Unhandled event ~tp\n", [?MODULE,?LINE,Event]), {noreply, State}. %%%%%%%%%%%%%%%%%%%%%%% Internal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/lib/observer/src/cdv_proc_cb.erl b/lib/observer/src/cdv_proc_cb.erl index 592150146b..f10650bbb7 100644 --- a/lib/observer/src/cdv_proc_cb.erl +++ b/lib/observer/src/cdv_proc_cb.erl @@ -71,7 +71,7 @@ get_details(Id, _) -> Proplist0 = crashdump_viewer:to_proplist(record_info(fields,proc),Info), Proplist = [{expand_table,Tab}|Proplist0], - Title = io_lib:format("~s (~s)",[Info#proc.name, Id]), + Title = io_lib:format("~ts (~s)",[Info#proc.name, Id]), {ok,{Title,Proplist,TW}}; {error,{other_node,NodeId}} -> Info = "The process you are searching for was residing on " diff --git a/lib/observer/src/cdv_table_wx.erl b/lib/observer/src/cdv_table_wx.erl index df16230b70..ba23758ea6 100644 --- a/lib/observer/src/cdv_table_wx.erl +++ b/lib/observer/src/cdv_table_wx.erl @@ -74,7 +74,7 @@ handle_info(active, State) -> {noreply, State}; handle_info(Info, State) -> - io:format("~p:~p: Unhandled info: ~p~n", [?MODULE, ?LINE, Info]), + io:format("~p:~p: Unhandled info: ~tp~n", [?MODULE, ?LINE, Info]), {noreply, State}. terminate(_Reason, _State) -> @@ -84,15 +84,15 @@ code_change(_, _, State) -> {ok, State}. handle_call(Msg, _From, State) -> - io:format("~p~p: Unhandled Call ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p~p: Unhandled Call ~tp~n",[?MODULE, ?LINE, Msg]), {reply, ok, State}. handle_cast(Msg, State) -> - io:format("~p~p: Unhandled cast ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p~p: Unhandled cast ~tp~n",[?MODULE, ?LINE, Msg]), {noreply, State}. handle_event(Event, State) -> - io:format("~p:~p: Unhandled event ~p\n", [?MODULE,?LINE,Event]), + io:format("~p:~p: Unhandled event ~tp\n", [?MODULE,?LINE,Event]), {noreply, State}. %%%%%%%%%%%%%%%%%%%%%%% Internal %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/lib/observer/src/cdv_term_cb.erl b/lib/observer/src/cdv_term_cb.erl index f0d90dde7c..f206d7e4c9 100644 --- a/lib/observer/src/cdv_term_cb.erl +++ b/lib/observer/src/cdv_term_cb.erl @@ -57,13 +57,7 @@ expand(['#CDVBin',Offset,Size,Pos], true) -> {ok,Bin} = crashdump_viewer:expand_binary({Offset,Size,Pos}), Bin; expand(Bin, Tab) when is_binary(Bin), not is_boolean(Tab) -> - Size = byte_size(Bin), - PrevSize = min(Size, 10) * 8, - <<Preview:PrevSize, _/binary>> = Bin, - Hash = erlang:phash2(Bin), - Key = {Preview, Size, Hash}, - ets:insert(Tab, {Key,Bin}), - ['#OBSBin',Preview,Size,Hash]; + observer_lib:make_obsbin(Bin, Tab); expand([H|T], Expand) -> case expand(T, Expand) of ET when is_list(ET) -> diff --git a/lib/observer/src/cdv_virtual_list_wx.erl b/lib/observer/src/cdv_virtual_list_wx.erl index ebf58865e9..f3daae8e4d 100644 --- a/lib/observer/src/cdv_virtual_list_wx.erl +++ b/lib/observer/src/cdv_virtual_list_wx.erl @@ -73,7 +73,7 @@ start_detail_win(Id) -> "#Port"++_ -> start_detail_win(Id, port); _ -> - io:format("cdv: unknown identifier: ~p~n",[Id]), + io:format("cdv: unknown identifier: ~tp~n",[Id]), ignore end. @@ -195,7 +195,7 @@ call(Holder, What) when is_pid(Holder) -> erlang:demonitor(Ref), Res after 5000 -> - io:format("Hanging call ~p~n",[What]), + io:format("Hanging call ~tp~n",[What]), "" end; call(_,_) -> @@ -214,7 +214,7 @@ handle_info(active, State) -> {noreply, State}; handle_info(Info, State) -> - io:format("~p:~p, Unexpected info: ~p~n", [?MODULE, ?LINE, Info]), + io:format("~p:~p, Unexpected info: ~tp~n", [?MODULE, ?LINE, Info]), {noreply, State}. terminate(_Reason, #state{holder=Holder}) -> @@ -236,7 +236,7 @@ handle_call(new_dump, _From, {reply, ok, State#state{detail_wins=[],holder=NewHolder,trunc_warn=TW}}; handle_call(Msg, _From, State) -> - io:format("~p:~p: Unhandled call ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p:~p: Unhandled call ~tp~n",[?MODULE, ?LINE, Msg]), {reply, ok, State}. handle_cast({start_detail_win,Id}, State) -> @@ -248,7 +248,7 @@ handle_cast({detail_win_closed, Id},#state{detail_wins=Opened}=State) -> {noreply, State#state{detail_wins=Opened2}}; handle_cast(Msg, State) -> - io:format("~p:~p: Unhandled cast ~p~n", [?MODULE, ?LINE, Msg]), + io:format("~p:~p: Unhandled cast ~tp~n", [?MODULE, ?LINE, Msg]), {noreply, State}. %%%%%%%%%%%%%%%%%%%%LOOP%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -322,7 +322,7 @@ handle_event(#wx{event=#wxList{type=command_list_item_activated, {noreply, State}; handle_event(Event, State) -> - io:format("~p:~p: handle event ~p\n", [?MODULE, ?LINE, Event]), + io:format("~p:~p: handle event ~tp\n", [?MODULE, ?LINE, Event]), {noreply, State}. @@ -382,7 +382,7 @@ table_holder(#holder{callback=Callback, attrs=Attrs, info=Info}=S0) -> stop -> ok; What -> - io:format("Table holder got ~p~n",[What]), + io:format("Table holder got ~tp~n",[What]), table_holder(S0) end. diff --git a/lib/observer/src/cdv_wx.erl b/lib/observer/src/cdv_wx.erl index 1e3fb6289e..898f39ded2 100644 --- a/lib/observer/src/cdv_wx.erl +++ b/lib/observer/src/cdv_wx.erl @@ -306,7 +306,7 @@ handle_info({'EXIT', Pid, normal}, #state{server=Pid}=State) -> {stop, normal, State}; handle_info({'EXIT', Pid, _Reason}, State) -> - io:format("Child (~s) crashed exiting: ~p ~p~n", + io:format("Child (~s) crashed exiting: ~p ~tp~n", [pid2panel(Pid, State), Pid,_Reason]), {stop, normal, State}; diff --git a/lib/observer/src/crashdump_viewer.erl b/lib/observer/src/crashdump_viewer.erl index 8d70f5e2c8..fd8b3b9e67 100644 --- a/lib/observer/src/crashdump_viewer.erl +++ b/lib/observer/src/crashdump_viewer.erl @@ -200,13 +200,13 @@ do_script_start(StartFun) -> {'EXIT', Pid, normal} -> ok; {'EXIT', Pid, Reason} -> - io:format("\ncdv crash: ~p\n",[Reason]) + io:format("\ncdv crash: ~tp\n",[Reason]) end; _ -> io:format("\ncdv crash: ~p\n",[unknown_reason]) end; Error -> - io:format("\ncdv start failed: ~p\n",[Error]) + io:format("\ncdv start failed: ~tp\n",[Error]) end. usage() -> @@ -340,7 +340,7 @@ handle_call(general_info,_From,State=#state{file=File}) -> handle_call({expand_binary,{Offset,Size,Pos}},_From,State=#state{file=File}) -> Fd = open(File), pos_bof(Fd,Pos), - {Bin,_Line} = get_binary(Offset,Size,val(Fd)), + {Bin,_Line} = get_binary(Offset,Size,bytes(Fd)), close(Fd), {reply,{ok,Bin},State}; handle_call(procs_summary,_From,State=#state{file=File,wordsize=WS}) -> @@ -512,9 +512,9 @@ unexpected(_Fd,{eof,_LastLine},_Where) -> ok; % truncated file unexpected(Fd,{part,What},Where) -> skip_rest_of_line(Fd), - io:format("WARNING: Found unexpected line in ~s:~n~s ...~n",[Where,What]); + io:format("WARNING: Found unexpected line in ~ts:~n~ts ...~n",[Where,What]); unexpected(_Fd,What,Where) -> - io:format("WARNING: Found unexpected line in ~s:~n~s~n",[Where,What]). + io:format("WARNING: Found unexpected line in ~ts:~n~ts~n",[Where,What]). truncated_warning([]) -> []; @@ -701,9 +701,24 @@ skip(Fd,<<>>) -> end. -val(Fd) -> - val(Fd, "-1"). -val(Fd, NoExist) -> +string(Fd) -> + string(Fd, "-1"). +string(Fd,NoExist) -> + case bytes(Fd,noexist) of + noexist -> NoExist; + Val -> byte_list_to_string(Val) + end. + +byte_list_to_string(ByteList) -> + Bin = list_to_binary(ByteList), + case unicode:characters_to_list(Bin) of + Str when is_list(Str) -> Str; + _ -> ByteList + end. + +bytes(Fd) -> + bytes(Fd, "-1"). +bytes(Fd, NoExist) -> case get_rest_of_line(Fd) of {eof,[]} -> NoExist; [] -> NoExist; @@ -742,7 +757,7 @@ get_lines_to_empty(Fd,<<$\n:8,Bin/binary>>,[],Lines) -> put_chunk(Fd,Bin), lists:reverse(Lines); get_lines_to_empty(Fd,<<$\n:8,Bin/binary>>,Acc,Lines) -> - get_lines_to_empty(Fd,Bin,[],[lists:reverse(Acc)|Lines]); + get_lines_to_empty(Fd,Bin,[],[byte_list_to_string(lists:reverse(Acc))|Lines]); get_lines_to_empty(Fd,<<$\r:8,Bin/binary>>,Acc,Lines) -> get_lines_to_empty(Fd,Bin,Acc,Lines); get_lines_to_empty(Fd,<<$\s:8,Bin/binary>>,[],Lines) -> @@ -754,7 +769,7 @@ get_lines_to_empty(Fd,<<>>,Acc,Lines) -> {ok,Bin} -> get_lines_to_empty(Fd,Bin,Acc,Lines); eof -> - lists:reverse(Lines,[lists:reverse(Acc)]) + lists:reverse(Lines,[byte_list_to_string(lists:reverse(Acc))]) end. split(Str) -> @@ -816,7 +831,7 @@ do_read_file(File) -> {ok,Binaries,DumpVsn}; _Other -> R = io_lib:format( - "~s is not an Erlang crash dump~n", + "~ts is not an Erlang crash dump~n", [File]), close(Fd), {error,R} @@ -824,20 +839,20 @@ do_read_file(File) -> {ok,<<"<Erlang crash dump>",_Rest/binary>>} -> %% old version - no longer supported R = io_lib:format( - "The crashdump ~s is in the pre-R10B format, " + "The crashdump ~ts is in the pre-R10B format, " "which is no longer supported.~n", [File]), close(Fd), {error,R}; _Other -> R = io_lib:format( - "~s is not an Erlang crash dump~n", + "~ts is not an Erlang crash dump~n", [File]), close(Fd), {error,R} end; _other -> - R = io_lib:format("~s is not an Erlang crash dump~n",[File]), + R = io_lib:format("~ts is not an Erlang crash dump~n",[File]), {error,R} end. @@ -986,7 +1001,7 @@ general_info(File) -> instr_info=InstrInfo}. get_slogan_and_sysvsn(Fd,Acc) -> - case val(Fd,eof) of + case string(Fd,eof) of "Slogan: " ++ SloganPart when Acc==[] -> get_slogan_and_sysvsn(Fd,[SloganPart]); "System version: " ++ SystemVsn -> @@ -1000,14 +1015,14 @@ get_slogan_and_sysvsn(Fd,Acc) -> get_general_info(Fd,GenInfo) -> case line_head(Fd) of "Compiled" -> - get_general_info(Fd,GenInfo#general_info{compile_time=val(Fd)}); + get_general_info(Fd,GenInfo#general_info{compile_time=bytes(Fd)}); "Taints" -> - Val = case val(Fd) of "-1" -> "(none)"; Line -> Line end, + Val = case string(Fd) of "-1" -> "(none)"; Line -> Line end, get_general_info(Fd,GenInfo#general_info{taints=Val}); "Atoms" -> - get_general_info(Fd,GenInfo#general_info{num_atoms=val(Fd)}); + get_general_info(Fd,GenInfo#general_info{num_atoms=bytes(Fd)}); "Calling Thread" -> - get_general_info(Fd,GenInfo#general_info{thread=val(Fd)}); + get_general_info(Fd,GenInfo#general_info{thread=bytes(Fd)}); "=" ++ _next_tag -> GenInfo; Other -> @@ -1068,15 +1083,15 @@ get_proc_details(File,Pid,WS,DumpVsn,Binaries) -> get_procinfo(Fd,Fun,Proc,WS) -> case line_head(Fd) of "State" -> - State = case val(Fd) of + State = case bytes(Fd) of "Garbing" -> "Garbing\n(limited info)"; State0 -> State0 end, get_procinfo(Fd,Fun,Proc#proc{state=State},WS); "Name" -> - get_procinfo(Fd,Fun,Proc#proc{name=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{name=string(Fd)},WS); "Spawned as" -> - IF = val(Fd), + IF = string(Fd), case Proc#proc.name of undefined -> get_procinfo(Fd,Fun,Proc#proc{name=IF,init_func=IF},WS); @@ -1085,17 +1100,17 @@ get_procinfo(Fd,Fun,Proc,WS) -> end; "Message queue length" -> %% stored as integer so we can sort on it - get_procinfo(Fd,Fun,Proc#proc{msg_q_len=list_to_integer(val(Fd))},WS); + get_procinfo(Fd,Fun,Proc#proc{msg_q_len=list_to_integer(bytes(Fd))},WS); "Reductions" -> %% stored as integer so we can sort on it - get_procinfo(Fd,Fun,Proc#proc{reds=list_to_integer(val(Fd))},WS); + get_procinfo(Fd,Fun,Proc#proc{reds=list_to_integer(bytes(Fd))},WS); "Stack+heap" -> %% stored as integer so we can sort on it get_procinfo(Fd,Fun,Proc#proc{stack_heap= - list_to_integer(val(Fd))*WS},WS); + list_to_integer(bytes(Fd))*WS},WS); "Memory" -> %% stored as integer so we can sort on it - get_procinfo(Fd,Fun,Proc#proc{memory=list_to_integer(val(Fd))},WS); + get_procinfo(Fd,Fun,Proc#proc{memory=list_to_integer(bytes(Fd))},WS); {eof,_} -> Proc; % truncated file Other -> @@ -1117,67 +1132,67 @@ all_procinfo(Fd,Fun,Proc,WS,LineHead) -> case LineHead of %% - START - moved from get_procinfo - "Spawned by" -> - case val(Fd) of + case bytes(Fd) of "[]" -> get_procinfo(Fd,Fun,Proc,WS); Parent -> get_procinfo(Fd,Fun,Proc#proc{parent=Parent},WS) end; "Started" -> - get_procinfo(Fd,Fun,Proc#proc{start_time=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{start_time=bytes(Fd)},WS); "Last scheduled in for" -> get_procinfo(Fd,Fun,Proc#proc{current_func= {"Last scheduled in for", - val(Fd)}},WS); + string(Fd)}},WS); "Current call" -> get_procinfo(Fd,Fun,Proc#proc{current_func={"Current call", - val(Fd)}},WS); + string(Fd)}},WS); "Number of heap fragments" -> - get_procinfo(Fd,Fun,Proc#proc{num_heap_frag=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{num_heap_frag=bytes(Fd)},WS); "Heap fragment data" -> - get_procinfo(Fd,Fun,Proc#proc{heap_frag_data=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{heap_frag_data=bytes(Fd)},WS); "OldHeap" -> - Bytes = list_to_integer(val(Fd))*WS, + Bytes = list_to_integer(bytes(Fd))*WS, get_procinfo(Fd,Fun,Proc#proc{old_heap=Bytes},WS); "Heap unused" -> - Bytes = list_to_integer(val(Fd))*WS, + Bytes = list_to_integer(bytes(Fd))*WS, get_procinfo(Fd,Fun,Proc#proc{heap_unused=Bytes},WS); "OldHeap unused" -> - Bytes = list_to_integer(val(Fd))*WS, + Bytes = list_to_integer(bytes(Fd))*WS, get_procinfo(Fd,Fun,Proc#proc{old_heap_unused=Bytes},WS); "New heap start" -> - get_procinfo(Fd,Fun,Proc#proc{new_heap_start=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{new_heap_start=bytes(Fd)},WS); "New heap top" -> - get_procinfo(Fd,Fun,Proc#proc{new_heap_top=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{new_heap_top=bytes(Fd)},WS); "Stack top" -> - get_procinfo(Fd,Fun,Proc#proc{stack_top=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{stack_top=bytes(Fd)},WS); "Stack end" -> - get_procinfo(Fd,Fun,Proc#proc{stack_end=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{stack_end=bytes(Fd)},WS); "Old heap start" -> - get_procinfo(Fd,Fun,Proc#proc{old_heap_start=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{old_heap_start=bytes(Fd)},WS); "Old heap top" -> - get_procinfo(Fd,Fun,Proc#proc{old_heap_top=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{old_heap_top=bytes(Fd)},WS); "Old heap end" -> - get_procinfo(Fd,Fun,Proc#proc{old_heap_end=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{old_heap_end=bytes(Fd)},WS); %% - END - moved from get_procinfo - "Last calls" -> get_procinfo(Fd,Fun,Proc#proc{last_calls=get_lines_to_empty(Fd)},WS); "Link list" -> - {Links,Monitors,MonitoredBy} = parse_link_list(val(Fd),[],[],[]), + {Links,Monitors,MonitoredBy} = parse_link_list(bytes(Fd),[],[],[]), get_procinfo(Fd,Fun,Proc#proc{links=Links, monitors=Monitors, mon_by=MonitoredBy},WS); "Program counter" -> - get_procinfo(Fd,Fun,Proc#proc{prog_count=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{prog_count=string(Fd)},WS); "CP" -> - get_procinfo(Fd,Fun,Proc#proc{cp=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{cp=string(Fd)},WS); "arity = " ++ Arity -> %%! Temporary workaround get_procinfo(Fd,Fun,Proc#proc{arity=Arity--"\r\n"},WS); "Run queue" -> - get_procinfo(Fd,Fun,Proc#proc{run_queue=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{run_queue=string(Fd)},WS); "Internal State" -> - get_procinfo(Fd,Fun,Proc#proc{int_state=val(Fd)},WS); + get_procinfo(Fd,Fun,Proc#proc{int_state=string(Fd)},WS); "=" ++ _next_tag -> Proc; Other -> @@ -1204,7 +1219,7 @@ parse_link_list(", "++Rest,Links,Monitors,MonitoredBy) -> parse_link_list([],Links,Monitors,MonitoredBy) -> {lists:reverse(Links),lists:reverse(Monitors),lists:reverse(MonitoredBy)}; parse_link_list(Unexpected,Links,Monitors,MonitoredBy) -> - io:format("WARNING: found unexpected data in link list:~n~s~n",[Unexpected]), + io:format("WARNING: found unexpected data in link list:~n~ts~n",[Unexpected]), parse_link_list([],Links,Monitors,MonitoredBy). @@ -1363,7 +1378,7 @@ read_stack_dump(Fd,Pid,BinAddrAdj,Dict) -> end. read_stack_dump1(Fd,BinAddrAdj,Dict,Acc) -> %% This function is never called if the dump is truncated in {?proc_heap,Pid} - case val(Fd) of + case bytes(Fd) of "=" ++ _next_tag -> lists:reverse(Acc); Line -> @@ -1391,7 +1406,7 @@ read_messages(Fd,Pid,BinAddrAdj,Dict) -> end. read_messages1(Fd,BinAddrAdj,Dict,Acc) -> %% This function is never called if the dump is truncated in {?proc_heap,Pid} - case val(Fd) of + case bytes(Fd) of "=" ++ _next_tag -> lists:reverse(Acc); Line -> @@ -1419,7 +1434,7 @@ read_dictionary(Fd,Pid,BinAddrAdj,Dict) -> end. read_dictionary1(Fd,BinAddrAdj,Dict,Acc) -> %% This function is never called if the dump is truncated in {?proc_heap,Pid} - case val(Fd) of + case bytes(Fd) of "=" ++ _next_tag -> lists:reverse(Acc); Line -> @@ -1451,7 +1466,7 @@ read_heap(BinAddrAdj,Dict0) -> end_of_heap -> Dict0; Fd -> - case val(Fd) of + case bytes(Fd) of "=" ++ _next_tag -> put(fd, end_of_heap), Dict0; @@ -1498,42 +1513,42 @@ get_portinfo(Fd,Port) -> case line_head(Fd) of "Slot" -> %% stored as integer so we can sort on it - get_portinfo(Fd,Port#port{slot=list_to_integer(val(Fd))}); + get_portinfo(Fd,Port#port{slot=list_to_integer(bytes(Fd))}); "Connected" -> %% stored as pid so we can sort on it - Connected0 = val(Fd), + Connected0 = bytes(Fd), Connected = try list_to_pid(Connected0) catch error:badarg -> Connected0 end, get_portinfo(Fd,Port#port{connected=Connected}); "Links" -> - Pids = split_pid_list_no_space(val(Fd)), + Pids = split_pid_list_no_space(bytes(Fd)), Links = [{Pid,Pid} || Pid <- Pids], get_portinfo(Fd,Port#port{links=Links}); "Registered as" -> - get_portinfo(Fd,Port#port{name=val(Fd)}); + get_portinfo(Fd,Port#port{name=string(Fd)}); "Monitors" -> - Monitors0 = string:tokens(val(Fd),"()"), + Monitors0 = string:tokens(bytes(Fd),"()"), Monitors = [begin [Pid,Ref] = string:tokens(Mon,","), {Pid,Pid++" ("++Ref++")"} end || Mon <- Monitors0], get_portinfo(Fd,Port#port{monitors=Monitors}); "Port controls linked-in driver" -> - Str = lists:flatten(["Linked in driver: " | val(Fd)]), + Str = lists:flatten(["Linked in driver: " | string(Fd)]), get_portinfo(Fd,Port#port{controls=Str}); "Port controls forker process" -> - Str = lists:flatten(["Forker process: " | val(Fd)]), + Str = lists:flatten(["Forker process: " | string(Fd)]), get_portinfo(Fd,Port#port{controls=Str}); "Port controls external process" -> - Str = lists:flatten(["External proc: " | val(Fd)]), + Str = lists:flatten(["External proc: " | string(Fd)]), get_portinfo(Fd,Port#port{controls=Str}); "Port is a file" -> - Str = lists:flatten(["File: "| val(Fd)]), + Str = lists:flatten(["File: "| string(Fd)]), get_portinfo(Fd,Port#port{controls=Str}); "Port is UNIX fd not opened by emulator" -> - Str = lists:flatten(["UNIX fd not opened by emulator: "| val(Fd)]), + Str = lists:flatten(["UNIX fd not opened by emulator: "| string(Fd)]), get_portinfo(Fd,Port#port{controls=Str}); "=" ++ _next_tag -> Port; @@ -1566,23 +1581,23 @@ tab_is_named(#ets_table{}) -> "no". get_etsinfo(Fd,EtsTable = #ets_table{details=Ds},WS) -> case line_head(Fd) of "Slot" -> - get_etsinfo(Fd,EtsTable#ets_table{slot=list_to_integer(val(Fd))},WS); + get_etsinfo(Fd,EtsTable#ets_table{slot=list_to_integer(bytes(Fd))},WS); "Table" -> - get_etsinfo(Fd,EtsTable#ets_table{id=val(Fd)},WS); + get_etsinfo(Fd,EtsTable#ets_table{id=string(Fd)},WS); "Name" -> - get_etsinfo(Fd,EtsTable#ets_table{name=val(Fd)},WS); + get_etsinfo(Fd,EtsTable#ets_table{name=string(Fd)},WS); "Ordered set (AVL tree), Elements" -> skip_rest_of_line(Fd), get_etsinfo(Fd,EtsTable#ets_table{data_type="tree"},WS); "Buckets" -> %% A bug in erl_db_hash.c prints a space after the buckets %% - need to strip the string to make list_to_integer/1 happy. - Buckets = list_to_integer(string:strip(val(Fd))), + Buckets = list_to_integer(string:strip(bytes(Fd))), get_etsinfo(Fd,EtsTable#ets_table{buckets=Buckets},WS); "Objects" -> - get_etsinfo(Fd,EtsTable#ets_table{size=list_to_integer(val(Fd))},WS); + get_etsinfo(Fd,EtsTable#ets_table{size=list_to_integer(bytes(Fd))},WS); "Words" -> - Words = list_to_integer(val(Fd)), + Words = list_to_integer(bytes(Fd)), Bytes = case Words of -1 -> -1; % probably truncated @@ -1592,37 +1607,37 @@ get_etsinfo(Fd,EtsTable = #ets_table{details=Ds},WS) -> "=" ++ _next_tag -> EtsTable; "Chain Length Min" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{chain_min=>Val}},WS); "Chain Length Avg" -> - Val = try list_to_float(string:strip(val(Fd))) catch _:_ -> "-" end, + Val = try list_to_float(string:strip(bytes(Fd))) catch _:_ -> "-" end, get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{chain_avg=>Val}},WS); "Chain Length Max" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{chain_max=>Val}},WS); "Chain Length Std Dev" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{chain_stddev=>Val}},WS); "Chain Length Expected Std Dev" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{chain_exp_stddev=>Val}},WS); "Fixed" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{fixed=>Val}},WS); "Type" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{data_type=Val},WS); "Protection" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{protection=>Val}},WS); "Compressed" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{compressed=>Val}},WS); "Write Concurrency" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{write_c=>Val}},WS); "Read Concurrency" -> - Val = val(Fd), + Val = bytes(Fd), get_etsinfo(Fd,EtsTable#ets_table{details=Ds#{read_c=>Val}},WS); Other -> unexpected(Fd,Other,"ETS info"), @@ -1672,9 +1687,9 @@ get_timerinfo(Fd,Id) -> get_timerinfo_1(Fd,Timer) -> case line_head(Fd) of "Message" -> - get_timerinfo_1(Fd,Timer#timer{msg=val(Fd)}); + get_timerinfo_1(Fd,Timer#timer{msg=string(Fd)}); "Time left" -> - TimeLeft = list_to_integer(val(Fd) -- " ms"), + TimeLeft = list_to_integer(bytes(Fd) -- " ms"), get_timerinfo_1(Fd,Timer#timer{time=TimeLeft}); "=" ++ _next_tag -> Timer; @@ -1743,37 +1758,37 @@ get_nodeinfo(Fd,Channel,Type,Start) -> get_nodeinfo(Fd,Nod) -> case line_head(Fd) of "Name" -> - get_nodeinfo(Fd,Nod#nod{name=val(Fd)}); + get_nodeinfo(Fd,Nod#nod{name=bytes(Fd)}); "Controller" -> - get_nodeinfo(Fd,Nod#nod{controller=val(Fd)}); + get_nodeinfo(Fd,Nod#nod{controller=bytes(Fd)}); "Creation" -> %% Throwing away elements like "(refc=1)", which might be %% printed from a debug compiled emulator. Creations = lists:flatmap(fun(C) -> try [list_to_integer(C)] catch error:badarg -> [] end - end, string:tokens(val(Fd)," ")), + end, string:tokens(bytes(Fd)," ")), get_nodeinfo(Fd,Nod#nod{creation={creations,Creations}}); "Remote link" -> - Procs = val(Fd), % e.g. "<0.31.0> <4322.54.0>" + Procs = bytes(Fd), % e.g. "<0.31.0> <4322.54.0>" {Local,Remote} = split(Procs), Str = Local++" <-> "++Remote, NewRemLinks = [{Local,Str} | Nod#nod.remote_links], get_nodeinfo(Fd,Nod#nod{remote_links=NewRemLinks}); "Remote monitoring" -> - Procs = val(Fd), % e.g. "<0.31.0> <4322.54.0>" + Procs = bytes(Fd), % e.g. "<0.31.0> <4322.54.0>" {Local,Remote} = split(Procs), Str = Local++" -> "++Remote, NewRemMon = [{Local,Str} | Nod#nod.remote_mon], get_nodeinfo(Fd,Nod#nod{remote_mon=NewRemMon}); "Remotely monitored by" -> - Procs = val(Fd), % e.g. "<0.31.0> <4322.54.0>" + Procs = bytes(Fd), % e.g. "<0.31.0> <4322.54.0>" {Local,Remote} = split(Procs), Str = Local++" <- "++Remote, NewRemMonBy = [{Local,Str} | Nod#nod.remote_mon_by], get_nodeinfo(Fd,Nod#nod{remote_mon_by=NewRemMonBy}); "Error" -> - get_nodeinfo(Fd,Nod#nod{error="ERROR: "++val(Fd)}); + get_nodeinfo(Fd,Nod#nod{error="ERROR: "++string(Fd)}); "=" ++ _next_tag -> Nod; Other -> @@ -1817,9 +1832,9 @@ loaded_mods(File) -> get_loaded_mod_totals(Fd,{CC,OC}) -> case line_head(Fd) of "Current code" -> - get_loaded_mod_totals(Fd,{val(Fd),OC}); + get_loaded_mod_totals(Fd,{bytes(Fd),OC}); "Old code" -> - get_loaded_mod_totals(Fd,{CC,val(Fd)}); + get_loaded_mod_totals(Fd,{CC,bytes(Fd)}); "=" ++ _next_tag -> {CC,OC}; Other -> @@ -1830,10 +1845,10 @@ get_loaded_mod_totals(Fd,{CC,OC}) -> get_loaded_mod_info(Fd,LM,Fun) -> case line_head(Fd) of "Current size" -> - CS = list_to_integer(val(Fd)), + CS = list_to_integer(bytes(Fd)), get_loaded_mod_info(Fd,LM#loaded_mod{current_size=CS},Fun); "Old size" -> - OS = list_to_integer(val(Fd)), + OS = list_to_integer(bytes(Fd)), get_loaded_mod_info(Fd,LM#loaded_mod{old_size=OS},Fun); "=" ++ _next_tag -> LM; @@ -1849,16 +1864,16 @@ main_modinfo(_Fd,LM,_LineHead) -> all_modinfo(Fd,LM,LineHead) -> case LineHead of "Current attributes" -> - Str = hex_to_str(val(Fd,"")), + Str = hex_to_str(bytes(Fd,"")), LM#loaded_mod{current_attrib=Str}; "Current compilation info" -> - Str = hex_to_str(val(Fd,"")), + Str = hex_to_str(bytes(Fd,"")), LM#loaded_mod{current_comp_info=Str}; "Old attributes" -> - Str = hex_to_str(val(Fd,"")), + Str = hex_to_str(bytes(Fd,"")), LM#loaded_mod{old_attrib=Str}; "Old compilation info" -> - Str = hex_to_str(val(Fd,"")), + Str = hex_to_str(bytes(Fd,"")), LM#loaded_mod{old_comp_info=Str}; Other -> unexpected(Fd,Other,"loaded modules info"), @@ -1868,7 +1883,7 @@ all_modinfo(Fd,LM,LineHead) -> hex_to_str(Hex) -> Term = hex_to_term(Hex,[]), - io_lib:format("~p~n",[Term]). + io_lib:format("~tp~n",[Term]). hex_to_term([X,Y|Hex],Acc) -> MS = hex_to_dec([X]), @@ -1909,17 +1924,17 @@ funs(File) -> get_funinfo(Fd,Fu) -> case line_head(Fd) of "Module" -> - get_funinfo(Fd,Fu#fu{module=val(Fd)}); + get_funinfo(Fd,Fu#fu{module=bytes(Fd)}); "Uniq" -> - get_funinfo(Fd,Fu#fu{uniq=list_to_integer(val(Fd))}); + get_funinfo(Fd,Fu#fu{uniq=list_to_integer(bytes(Fd))}); "Index" -> - get_funinfo(Fd,Fu#fu{index=list_to_integer(val(Fd))}); + get_funinfo(Fd,Fu#fu{index=list_to_integer(bytes(Fd))}); "Address" -> - get_funinfo(Fd,Fu#fu{address=val(Fd)}); + get_funinfo(Fd,Fu#fu{address=bytes(Fd)}); "Native_address" -> - get_funinfo(Fd,Fu#fu{native_address=val(Fd)}); + get_funinfo(Fd,Fu#fu{native_address=bytes(Fd)}); "Refc" -> - get_funinfo(Fd,Fu#fu{refc=list_to_integer(val(Fd))}); + get_funinfo(Fd,Fu#fu{refc=list_to_integer(bytes(Fd))}); "=" ++ _next_tag -> Fu; Other -> @@ -1999,7 +2014,7 @@ get_meminfo(Fd,Acc) -> {eof,_last_line} -> lists:reverse(Acc); Key -> - get_meminfo(Fd,[{list_to_atom(Key),val(Fd)}|Acc]) + get_meminfo(Fd,[{list_to_atom(Key),bytes(Fd)}|Acc]) end. %%----------------------------------------------------------------- @@ -2023,7 +2038,7 @@ get_allocareainfo(Fd,Acc) -> {eof,_last_line} -> lists:reverse(Acc); Key -> - Val = val(Fd), + Val = bytes(Fd), AllocInfo = case split(Val) of {Alloc,[]} -> @@ -2061,7 +2076,7 @@ get_allocatorinfo1(Fd,Acc,Max) -> {eof,_last_line} -> pad_and_reverse(Acc,Max,[]); Key -> - Values = get_all_vals(val(Fd),[]), + Values = get_all_vals(bytes(Fd),[]), L = length(Values), Max1 = if L > Max -> L; true -> Max end, get_allocatorinfo1(Fd,[{Key,Values}|Acc],Max1) @@ -2316,13 +2331,13 @@ get_hashtableinfo(Fd,Name,Start) -> get_hashtableinfo1(Fd,HashTable) -> case line_head(Fd) of "size" -> - get_hashtableinfo1(Fd,HashTable#hash_table{size=val(Fd)}); + get_hashtableinfo1(Fd,HashTable#hash_table{size=bytes(Fd)}); "used" -> - get_hashtableinfo1(Fd,HashTable#hash_table{used=val(Fd)}); + get_hashtableinfo1(Fd,HashTable#hash_table{used=bytes(Fd)}); "objs" -> - get_hashtableinfo1(Fd,HashTable#hash_table{objs=val(Fd)}); + get_hashtableinfo1(Fd,HashTable#hash_table{objs=bytes(Fd)}); "depth" -> - get_hashtableinfo1(Fd,HashTable#hash_table{depth=val(Fd)}); + get_hashtableinfo1(Fd,HashTable#hash_table{depth=bytes(Fd)}); "=" ++ _next_tag -> HashTable; Other -> @@ -2353,15 +2368,15 @@ get_indextableinfo(Fd,Name,Start) -> get_indextableinfo1(Fd,IndexTable) -> case line_head(Fd) of "size" -> - get_indextableinfo1(Fd,IndexTable#index_table{size=val(Fd)}); + get_indextableinfo1(Fd,IndexTable#index_table{size=bytes(Fd)}); "used" -> - get_indextableinfo1(Fd,IndexTable#index_table{used=val(Fd)}); + get_indextableinfo1(Fd,IndexTable#index_table{used=bytes(Fd)}); "limit" -> - get_indextableinfo1(Fd,IndexTable#index_table{limit=val(Fd)}); + get_indextableinfo1(Fd,IndexTable#index_table{limit=bytes(Fd)}); "rate" -> - get_indextableinfo1(Fd,IndexTable#index_table{rate=val(Fd)}); + get_indextableinfo1(Fd,IndexTable#index_table{rate=bytes(Fd)}); "entries" -> - get_indextableinfo1(Fd,IndexTable#index_table{entries=val(Fd)}); + get_indextableinfo1(Fd,IndexTable#index_table{entries=bytes(Fd)}); "=" ++ _next_tag -> IndexTable; Other -> @@ -2393,45 +2408,45 @@ get_schedulerinfo(Fd,Name,Start) -> get_schedulerinfo1(Fd,Sched=#sched{details=Ds}) -> case line_head(Fd) of "Current Process" -> - get_schedulerinfo1(Fd,Sched#sched{process=val(Fd, "None")}); + get_schedulerinfo1(Fd,Sched#sched{process=bytes(Fd, "None")}); "Current Port" -> - get_schedulerinfo1(Fd,Sched#sched{port=val(Fd, "None")}); + get_schedulerinfo1(Fd,Sched#sched{port=bytes(Fd, "None")}); "Run Queue Max Length" -> - RQMax = list_to_integer(val(Fd)), + RQMax = list_to_integer(bytes(Fd)), RQ = RQMax + Sched#sched.run_q, get_schedulerinfo1(Fd,Sched#sched{run_q=RQ, details=Ds#{runq_max=>RQMax}}); "Run Queue High Length" -> - RQHigh = list_to_integer(val(Fd)), + RQHigh = list_to_integer(bytes(Fd)), RQ = RQHigh + Sched#sched.run_q, get_schedulerinfo1(Fd,Sched#sched{run_q=RQ, details=Ds#{runq_high=>RQHigh}}); "Run Queue Normal Length" -> - RQNorm = list_to_integer(val(Fd)), + RQNorm = list_to_integer(bytes(Fd)), RQ = RQNorm + Sched#sched.run_q, get_schedulerinfo1(Fd,Sched#sched{run_q=RQ, details=Ds#{runq_norm=>RQNorm}}); "Run Queue Low Length" -> - RQLow = list_to_integer(val(Fd)), + RQLow = list_to_integer(bytes(Fd)), RQ = RQLow + Sched#sched.run_q, get_schedulerinfo1(Fd,Sched#sched{run_q=RQ, details=Ds#{runq_low=>RQLow}}); "Run Queue Port Length" -> - RQ = list_to_integer(val(Fd)), + RQ = list_to_integer(bytes(Fd)), get_schedulerinfo1(Fd,Sched#sched{port_q=RQ}); "Scheduler Sleep Info Flags" -> - get_schedulerinfo1(Fd,Sched#sched{details=Ds#{sleep_info=>val(Fd, "None")}}); + get_schedulerinfo1(Fd,Sched#sched{details=Ds#{sleep_info=>bytes(Fd, "None")}}); "Scheduler Sleep Info Aux Work" -> - get_schedulerinfo1(Fd,Sched#sched{details=Ds#{sleep_aux=>val(Fd, "None")}}); + get_schedulerinfo1(Fd,Sched#sched{details=Ds#{sleep_aux=>bytes(Fd, "None")}}); "Run Queue Flags" -> - get_schedulerinfo1(Fd,Sched#sched{details=Ds#{runq_flags=>val(Fd, "None")}}); + get_schedulerinfo1(Fd,Sched#sched{details=Ds#{runq_flags=>bytes(Fd, "None")}}); "Current Process State" -> - get_schedulerinfo1(Fd,Sched#sched{details=Ds#{currp_state=>val(Fd)}}); + get_schedulerinfo1(Fd,Sched#sched{details=Ds#{currp_state=>bytes(Fd)}}); "Current Process Internal State" -> - get_schedulerinfo1(Fd,Sched#sched{details=Ds#{currp_int_state=>val(Fd)}}); + get_schedulerinfo1(Fd,Sched#sched{details=Ds#{currp_int_state=>bytes(Fd)}}); "Current Process Program counter" -> - get_schedulerinfo1(Fd,Sched#sched{details=Ds#{currp_prg_cnt=>val(Fd)}}); + get_schedulerinfo1(Fd,Sched#sched{details=Ds#{currp_prg_cnt=>string(Fd)}}); "Current Process CP" -> - get_schedulerinfo1(Fd,Sched#sched{details=Ds#{currp_cp=>val(Fd)}}); + get_schedulerinfo1(Fd,Sched#sched{details=Ds#{currp_cp=>string(Fd)}}); "Current Process Limited Stack Trace" -> %% If there shall be last in scheduler information block Sched#sched{details=get_limited_stack(Fd, 0, Ds)}; @@ -2443,7 +2458,7 @@ get_schedulerinfo1(Fd,Sched=#sched{details=Ds}) -> end. get_limited_stack(Fd, N, Ds) -> - case val(Fd) of + case string(Fd) of Addr = "0x" ++ _ -> get_limited_stack(Fd, N+1, Ds#{{currp_stack, N} => Addr}); "=" ++ _next_tag -> @@ -2595,7 +2610,7 @@ skip_dist_ext([C|Cs], KeptCs) -> parse_atom([$A|Line0], D) -> {N,":"++Line1} = get_hex(Line0), {Chars, Line} = get_chars(N, Line1), - {list_to_atom(Chars), Line, D}. + {binary_to_atom(list_to_binary(Chars),utf8), Line, D}. parse_atom_translation_table(0, Line0, As) -> {list_to_tuple(lists:reverse(As)), Line0}; @@ -2614,7 +2629,7 @@ deref_ptr(Ptr, Line, BinAddrAdj, D0) -> end_of_heap -> {['#CDVIncompleteHeap'],Line,D0}; Fd -> - case val(Fd) of + case bytes(Fd) of "="++_ -> put(fd, end_of_heap), deref_ptr(Ptr, Line, BinAddrAdj, D0); @@ -2759,7 +2774,7 @@ tag_to_atom("scheduler") -> ?scheduler; tag_to_atom("timer") -> ?timer; tag_to_atom("visible_node") -> ?visible_node; tag_to_atom(UnknownTag) -> - io:format("WARNING: Found unexpected tag:~s~n",[UnknownTag]), + io:format("WARNING: Found unexpected tag:~ts~n",[UnknownTag]), list_to_atom(UnknownTag). %%%----------------------------------------------------------------- diff --git a/lib/observer/src/etop_tr.erl b/lib/observer/src/etop_tr.erl index 8e43f8bb35..1e48fefca4 100644 --- a/lib/observer/src/etop_tr.erl +++ b/lib/observer/src/etop_tr.erl @@ -89,14 +89,14 @@ handle_data(Last, {_, Pid, out, _, Time2} = G, Store) -> end, New; false -> - io:format("Erlang top got garbage ~p~n", [G]), + io:format("Erlang top got garbage ~tp~n", [G]), Last end; handle_data(_W, {drop, D}, _) -> %% Error case we are missing data here! io:format("Erlang top dropped data ~p~n", [D]), []; handle_data(Last, G, _) -> - io:format("Erlang top got garbage ~p~n", [G]), + io:format("Erlang top got garbage ~tp~n", [G]), Last. elapsed({Me1, S1, Mi1}, {Me2, S2, Mi2}) -> diff --git a/lib/observer/src/etop_txt.erl b/lib/observer/src/etop_txt.erl index 183641119a..cd3ec62c13 100644 --- a/lib/observer/src/etop_txt.erl +++ b/lib/observer/src/etop_txt.erl @@ -48,7 +48,6 @@ do_update(Prev,Config) -> do_update(standard_io,Info,Prev,Config). do_update(Fd,Info,Prev,Config) -> - Encoding = encoding(Fd), {Cpu,NProcs,RQ,Clock} = loadinfo(Info,Prev), io:nl(Fd), writedoubleline(Fd), @@ -72,7 +71,7 @@ do_update(Fd,Info,Prev,Config) -> io:nl(Fd), writepinfo_header(Fd), writesingleline(Fd), - writepinfo(Fd,Info#etop_info.procinfo,Encoding), + writepinfo(Fd,Info#etop_info.procinfo,modifier(Fd)), writedoubleline(Fd), io:nl(Fd), Info. @@ -93,26 +92,27 @@ writepinfo(Fd,[#etop_proc_info{pid=Pid, cf=MFA, mq=MQ} |T], - Encoding) -> - io:fwrite(Fd,proc_format(Encoding), - [Pid,to_list(Name,Encoding),Time,Reds,Mem,MQ, - formatmfa(MFA,Encoding)]), - writepinfo(Fd,T,Encoding); + Modifier) -> + io:fwrite(Fd,proc_format(Modifier), + [Pid,to_string(Name,Modifier),Time,Reds,Mem,MQ, + to_string(MFA,Modifier)]), + writepinfo(Fd,T,Modifier); writepinfo(_Fd,[],_) -> ok. +proc_format(Modifier) -> + "~-15w~-20"++Modifier++"s~8w~8w~8w~8w ~-20"++Modifier++"s~n". -formatmfa({M, F, A},latin1) -> - io_lib:format("~w:~w/~w",[M, F, A]); -formatmfa({M, F, A},_) -> - io_lib:format("~w:~tw/~w",[M, F, A]); -formatmfa(Other,_) -> - %% E.g. when running hipe - the current_function for some - %% processes will be 'undefined' - io_lib:format("~w",[Other]). +to_string({M,F,A},Modifier) -> + io_lib:format("~w:~"++Modifier++"w/~w",[M,F,A]); +to_string(Other,Modifier) -> + io_lib:format("~"++Modifier++"w",[Other]). -to_list(Name,_) when is_atom(Name) -> atom_to_list(Name); -to_list({_M,_F,_A}=MFA,Encoding) -> formatmfa(MFA,Encoding). +modifier(Device) -> + case encoding(Device) of + latin1 -> ""; + _ -> "t" + end. encoding(Device) -> case io:getopts(Device) of @@ -122,7 +122,3 @@ encoding(Device) -> latin1 end. -proc_format(latin1) -> - "~-15w~-20s~8w~8w~8w~8w ~-20s~n"; -proc_format(_) -> - "~-15w~-20ts~8w~8w~8w~8w ~-20ts~n". diff --git a/lib/observer/src/multitrace.erl b/lib/observer/src/multitrace.erl index a01eeec6ae..82aec05e0d 100644 --- a/lib/observer/src/multitrace.erl +++ b/lib/observer/src/multitrace.erl @@ -103,16 +103,16 @@ print_func(Out,{trace_ts,P,call,{M,F,A},C,Ts},N) -> io:format(Out, "~w: ~s~n" "Process : ~w~n" - "Call : ~w:~w/~w~n" - "Arguments : ~p~n" - "Caller : ~w~n~n", + "Call : ~w:~tw/~w~n" + "Arguments : ~tp~n" + "Caller : ~tw~n~n", [N,ts(Ts),P,M,F,length(A),A,C]); print_func(Out,{trace_ts,P,return_from,{M,F,A},R,Ts},N) -> io:format(Out, "~w: ~s~n" "Process : ~w~n" - "Return from : ~w:~w/~w~n" - "Return value : ~p~n~n", + "Return from : ~w:~tw/~w~n" + "Return value : ~tp~n~n", [N,ts(Ts),P,M,F,A,R]). @@ -181,7 +181,7 @@ handle_schedule(Out,{trace_ts,P,out,Info,Ts},_TI,S) -> "out:~n" "Process : ~w~n" "Time : ~s~n" - "Function : ~w~n~n",[P,ts(Ts),Info]), + "Function : ~tw~n~n",[P,ts(Ts),Info]), case lists:keysearch(P,1,S) of {value,{P,List}} -> lists:keyreplace(P,1,S,{P,[{out,Ts}|List]}); @@ -193,7 +193,7 @@ handle_schedule(Out,{trace_ts,P,in,Info,Ts},_TI,S) -> "in:~n" "Process : ~w~n" "Time : ~s~n" - "Function : ~w~n~n",[P,ts(Ts),Info]), + "Function : ~tw~n~n",[P,ts(Ts),Info]), case lists:keysearch(P,1,S) of {value,{P,List}} -> lists:keyreplace(P,1,S,{P,[{in,Ts}|List]}); diff --git a/lib/observer/src/observer_alloc_wx.erl b/lib/observer/src/observer_alloc_wx.erl index ef425f0874..7f4b3dd484 100644 --- a/lib/observer/src/observer_alloc_wx.erl +++ b/lib/observer/src/observer_alloc_wx.erl @@ -80,7 +80,7 @@ init([Notebook, Parent, Config]) -> } } catch _:Err -> - io:format("~p crashed ~p: ~p~n",[?MODULE, Err, erlang:get_stacktrace()]), + io:format("~p crashed ~tp: ~tp~n",[?MODULE, Err, erlang:get_stacktrace()]), {stop, Err} end. @@ -183,7 +183,7 @@ handle_info({'EXIT', Old, _}, State = #state{appmon=Old}) -> {noreply, State#state{active=false, appmon=undefined}}; handle_info(_Event, State) -> - %% io:format("~p:~p: ~p~n",[?MODULE,?LINE,_Event]), + %% io:format("~p:~p: ~tp~n",[?MODULE,?LINE,_Event]), {noreply, State}. terminate(_Event, #state{}) -> diff --git a/lib/observer/src/observer_app_wx.erl b/lib/observer/src/observer_app_wx.erl index bc4f1fe117..2a481966da 100644 --- a/lib/observer/src/observer_app_wx.erl +++ b/lib/observer/src/observer_app_wx.erl @@ -320,7 +320,7 @@ handle_info({'EXIT', _, noconnection}, State) -> handle_info({'EXIT', _, normal}, State) -> {noreply, State}; handle_info(_Event, State) -> - %% io:format("~p:~p: ~p~n",[?MODULE,?LINE,_Event]), + %% io:format("~p:~p: ~tp~n",[?MODULE,?LINE,_Event]), {noreply, State}. %%%%%%%%%% diff --git a/lib/observer/src/observer_html_lib.erl b/lib/observer/src/observer_html_lib.erl index 1f1306c370..3dfcc42ada 100644 --- a/lib/observer/src/observer_html_lib.erl +++ b/lib/observer/src/observer_html_lib.erl @@ -142,13 +142,13 @@ dict_table(Tab,{Key0,Value0}, Even) -> tr(color(Even), [td("VALIGN=center",pre(Key)), td(pre(Value))]). proc_state(Tab,{Key0,Value0}, Even) -> - Key = lists:flatten(io_lib:format("~s",[Key0])), + Key = lists:flatten(io_lib:format("~ts",[Key0])), Value = all_or_expand(Tab,Value0), tr(color(Even), [td("VALIGN=center",Key), td(pre(Value))]). all_or_expand(Tab,Term) -> - Preview = io_lib:format("~P",[Term,8]), - Check = io_lib:format("~P",[Term,100]), + Preview = io_lib:format("~tP",[Term,8]), + Check = io_lib:format("~tP",[Term,100]), Exp = Preview=/=Check, all_or_expand(Tab,Term,Preview,Exp). all_or_expand(_Tab,Term,Str,false) @@ -166,13 +166,8 @@ all_or_expand(Tab,Term,Preview,true) "Click to expand above term")]; all_or_expand(Tab,Bin,_PreviewStr,_Expand) when is_binary(Bin) -> - Size = byte_size(Bin), - PrevSize = min(Size, 10) * 8, - <<Preview:PrevSize, _/binary>> = Bin, - Hash = erlang:phash2(Bin), - Key = {Preview, Size, Hash}, - ets:insert(Tab,{Key,Bin}), - Term = io_lib:format("~p", [['#OBSBin',Preview,Size,Hash]]), + OBSBin = observer_lib:make_obsbin(Bin,Tab), + Term = io_lib:format("~tp", [OBSBin]), href_proc_port(lists:flatten(Term), true). color(true) -> io_lib:format("BGCOLOR=\"#~2.16.0B~2.16.0B~2.16.0B\"", tuple_to_list(?BG_EVEN)); @@ -339,9 +334,11 @@ href_proc_bin(From, T, Acc, LTB) -> BinStr = case string:tokens(OffsetSizePos,",.| \n") of [Offset,SizeStr,Pos] when From =:= cdv -> - Id = {list_to_integer(Offset),10,list_to_integer(Pos)}, + Size = list_to_integer(SizeStr), + PreviewSize = min(Size,10), + Id = {list_to_integer(Offset),PreviewSize,list_to_integer(Pos)}, {ok,PreviewBin} = crashdump_viewer:expand_binary(Id), - PreviewStr = preview_string(list_to_integer(SizeStr), PreviewBin), + PreviewStr = preview_string(Size, PreviewBin), if LTB -> href("TARGET=\"expanded\"", ["#Binary?offset="++Offset++ @@ -351,14 +348,14 @@ href_proc_bin(From, T, Acc, LTB) -> true -> PreviewStr end; - [Preview,SizeStr,Md5] when From =:= obs -> + [PreviewIntStr,SizeStr,Md5] when From =:= obs -> Size = list_to_integer(SizeStr), - PrevSize = min(Size, 10) * 8, - PreviewStr = preview_string(Size, - <<(list_to_integer(Preview)):PrevSize>>), + PreviewInt = list_to_integer(PreviewIntStr), + PrevSize = (trunc(math:log2(PreviewInt)/8)+1)*8, + PreviewStr = preview_string(Size,<<PreviewInt:PrevSize>>), if LTB -> href("TARGET=\"expanded\"", - ["#OBSBinary?key1="++Preview++ + ["#OBSBinary?key1="++PreviewIntStr++ "&key2="++SizeStr++ "&key3="++Md5], PreviewStr); @@ -372,14 +369,14 @@ href_proc_bin(From, T, Acc, LTB) -> preview_string(Size, PreviewBin) when Size > 10 -> ["<<", - remove_lgt(io_lib:format("~p",[PreviewBin])), + remove_lgt(io_lib:format("~tp",[PreviewBin])), "...(", observer_lib:to_str({bytes,Size}), ")", ">>"]; preview_string(_, PreviewBin) -> ["<<", - remove_lgt(io_lib:format("~p",[PreviewBin])), + remove_lgt(io_lib:format("~tp",[PreviewBin])), ">>"]. remove_lgt(Deep) -> diff --git a/lib/observer/src/observer_lib.erl b/lib/observer/src/observer_lib.erl index 8b6036f52a..463fb5b8ef 100644 --- a/lib/observer/src/observer_lib.erl +++ b/lib/observer/src/observer_lib.erl @@ -30,7 +30,8 @@ create_attrs/0, set_listctrl_col_size/2, create_status_bar/1, - html_window/1, html_window/2 + html_window/1, html_window/2, + make_obsbin/2 ]). -include_lib("wx/include/wx.hrl"). @@ -300,7 +301,7 @@ to_str(Float) when is_float(Float) -> to_str({trunc, Float}) when is_float(Float) -> float_to_list(Float, [{decimals,0}]); to_str(Term) -> - io_lib:format("~w", [Term]). + io_lib:format("~tw", [Term]). create_menus([], _MenuBar, _Type) -> ok; create_menus(Menus, MenuBar, Type) -> @@ -520,7 +521,7 @@ link_entry2(Panel,{Target,Str},Cursor) -> TC. to_link(RegName={Name, Node}) when is_atom(Name), is_atom(Node) -> - Str = io_lib:format("{~p,~p}", [Name, Node]), + Str = io_lib:format("{~tp,~p}", [Name, Node]), {RegName, Str}; to_link(TI = {_Target, _Identifier}) -> TI; @@ -641,11 +642,11 @@ parse_string(Str) -> Tokens = case erl_scan:string(Str, 1, [text]) of {ok, Ts, _} -> Ts; {error, {_SLine, SMod, SError}, _} -> - throw(io_lib:format("~s", [SMod:format_error(SError)])) + throw(io_lib:format("~ts", [SMod:format_error(SError)])) end, case lib:extended_parse_term(Tokens) of {error, {_PLine, PMod, PError}} -> - throw(io_lib:format("~s", [PMod:format_error(PError)])); + throw(io_lib:format("~ts", [PMod:format_error(PError)])); Res -> Res end catch @@ -769,3 +770,26 @@ update_progress_text(PD,Text) -> end. finish_progress(PD) -> wxProgressDialog:destroy(PD). + +make_obsbin(Bin,Tab) -> + Size = byte_size(Bin), + Preview = + try + %% The binary might be a unicode string, in which case we + %% don't want to split it in the middle of a grapheme + %% cluster - thus trying string:length and slice. + PL1 = min(string:length(Bin), 10), + PB1 = string:slice(Bin,0,PL1), + PS1 = byte_size(PB1) * 8, + <<P1:PS1>> = PB1, + P1 + catch _:_ -> + %% Probably not a string, so just split anywhere + PS2 = min(Size, 10) * 8, + <<P2:PS2, _/binary>> = Bin, + P2 + end, + Hash = erlang:phash2(Bin), + Key = {Preview, Size, Hash}, + ets:insert(Tab, {Key,Bin}), + ['#OBSBin',Preview,Size,Hash]. diff --git a/lib/observer/src/observer_perf_wx.erl b/lib/observer/src/observer_perf_wx.erl index fcc51310c8..5adfadb16e 100644 --- a/lib/observer/src/observer_perf_wx.erl +++ b/lib/observer/src/observer_perf_wx.erl @@ -87,7 +87,7 @@ init([Notebook, Parent, Config]) -> }, {Panel, State0} catch _:Err -> - io:format("~p crashed ~p: ~p~n",[?MODULE, Err, erlang:get_stacktrace()]), + io:format("~p crashed ~tp: ~tp~n",[?MODULE, Err, erlang:get_stacktrace()]), {stop, Err} end. @@ -235,7 +235,7 @@ handle_info({'EXIT', Old, _}, State = #state{appmon=Old}) -> {noreply, State#state{active=false, appmon=undefined}}; handle_info(_Event, State) -> - %% io:format("~p:~p: ~p~n",[?MODULE,?LINE,_Event]), + %% io:format("~p:~p: ~tp~n",[?MODULE,?LINE,_Event]), {noreply, State}. %%%%%%%%%% diff --git a/lib/observer/src/observer_port_wx.erl b/lib/observer/src/observer_port_wx.erl index 8339267659..5908e99e36 100644 --- a/lib/observer/src/observer_port_wx.erl +++ b/lib/observer/src/observer_port_wx.erl @@ -338,7 +338,7 @@ handle_info({info, {port_info_not_available,NodeName}}, {noreply, State}; handle_info({error, Error}, #state{panel=Panel} = State) -> - Str = io_lib:format("ERROR: ~s~n",[Error]), + Str = io_lib:format("ERROR: ~ts~n",[Error]), observer_lib:display_info_dialog(Panel, Str), {noreply, State}; diff --git a/lib/observer/src/observer_pro_wx.erl b/lib/observer/src/observer_pro_wx.erl index 3083297f31..2e5fe0bc1a 100644 --- a/lib/observer/src/observer_pro_wx.erl +++ b/lib/observer/src/observer_pro_wx.erl @@ -217,7 +217,7 @@ call(Holder, What) -> erlang:demonitor(Ref), Res after 2000 -> - io:format("Hanging call ~p~n",[What]), + io:format("Hanging call ~tp~n",[What]), "" end. @@ -256,7 +256,7 @@ handle_info(not_active, #state{timer=Timer0}=State) -> {noreply, State#state{timer=Timer}}; handle_info(Info, State) -> - io:format("~p:~p, Unexpected info: ~p~n", [?MODULE, ?LINE, Info]), + io:format("~p:~p, Unexpected info: ~tp~n", [?MODULE, ?LINE, Info]), {noreply, State}. terminate(_Reason, #state{holder=Holder}) -> @@ -273,11 +273,11 @@ handle_call(get_config, _, #state{holder=Holder, timer=Timer}=State) -> {reply, Conf#{acc=>Accum}, State}; handle_call(Msg, _From, State) -> - io:format("~p:~p: Unhandled call ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p:~p: Unhandled call ~tp~n",[?MODULE, ?LINE, Msg]), {reply, ok, State}. handle_cast(Msg, State) -> - io:format("~p:~p: Unhandled cast ~p~n", [?MODULE, ?LINE, Msg]), + io:format("~p:~p: Unhandled cast ~tp~n", [?MODULE, ?LINE, Msg]), {noreply, State}. %%%%%%%%%%%%%%%%%%%%LOOP%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -401,7 +401,7 @@ handle_event(#wx{event=#wxList{type=command_list_item_activated}}, {noreply, State#state{procinfo_menu_pids=Opened2}}; handle_event(Event, State) -> - io:format("~p:~p: handle event ~p\n", [?MODULE, ?LINE, Event]), + io:format("~p:~p: handle event ~tp\n", [?MODULE, ?LINE, Event]), {noreply, State}. @@ -559,7 +559,7 @@ table_holder(#holder{info=Info, attrs=Attrs, %% Node crashed will be noticed soon.. table_holder(S0#holder{backend_pid=undefined}); _What -> - %% io:format("~p: Table holder got ~p~n",[?MODULE, _What]), + %% io:format("~p: Table holder got ~tp~n",[?MODULE, _What]), table_holder(S0) end. diff --git a/lib/observer/src/observer_procinfo.erl b/lib/observer/src/observer_procinfo.erl index 10decd8b62..963def958b 100644 --- a/lib/observer/src/observer_procinfo.erl +++ b/lib/observer/src/observer_procinfo.erl @@ -56,7 +56,7 @@ init([Pid, ParentFrame, Parent]) -> Table = ets:new(observer_expand,[set,public]), Title=case observer_wx:try_rpc(node(Pid), erlang, process_info, [Pid, registered_name]) of [] -> io_lib:format("~p",[Pid]); - {registered_name, Registered} -> io_lib:format("~p (~p)",[Registered, Pid]); + {registered_name, Registered} -> io_lib:format("~tp (~p)",[Registered, Pid]); undefined -> throw(process_undefined) end, Frame=wxFrame:new(ParentFrame, ?wxID_ANY, [atom_to_list(node(Pid)), $:, Title], @@ -171,7 +171,7 @@ handle_info({get_debug_info, From}, State = #state{notebook=Notebook}) -> From ! {procinfo_debug, Notebook}, {noreply, State}; handle_info(_Info, State) -> - %% io:format("~p: ~p, Handle info: ~p~n", [?MODULE, ?LINE, Info]), + %% io:format("~p: ~p, Handle info: ~tp~n", [?MODULE, ?LINE, Info]), {noreply, State}. handle_call(Call, From, _State) -> @@ -263,7 +263,7 @@ init_stack_page(Parent, Pid) -> wxListCtrl:setItem(LCtrl, Row, 0, observer_lib:to_str({M,F,A})), FileLine = case Info of [{file,File},{line,Line}] -> - io_lib:format("~s:~w", [File,Line]); + io_lib:format("~ts:~w", [File,Line]); _ -> [] end, @@ -487,5 +487,5 @@ io_request({put_chars, Encoding, Module, Function, Args}, State) -> {error, {error, Function}, State} end; io_request(_Req, State) -> - %% io:format("~p: Unknown req: ~p ~n",[?LINE, _Req]), + %% io:format("~p: Unknown req: ~tp ~n",[?LINE, _Req]), {ok, {error, request}, State}. diff --git a/lib/observer/src/observer_sys_wx.erl b/lib/observer/src/observer_sys_wx.erl index 2e1af3ada9..8c2ffd77b4 100644 --- a/lib/observer/src/observer_sys_wx.erl +++ b/lib/observer/src/observer_sys_wx.erl @@ -199,7 +199,7 @@ handle_info(not_active, #sys_wx_state{timer = Timer} = State) -> {noreply, State#sys_wx_state{timer = observer_lib:stop_timer(Timer)}}; handle_info(Info, State) -> - io:format("~p:~p: Unhandled info: ~p~n", [?MODULE, ?LINE, Info]), + io:format("~p:~p: Unhandled info: ~tp~n", [?MODULE, ?LINE, Info]), {noreply, State}. terminate(_Reason, _State) -> @@ -212,11 +212,11 @@ handle_call(get_config, _, #sys_wx_state{timer=Timer}=State) -> {reply, observer_lib:timer_config(Timer), State}; handle_call(Msg, _From, State) -> - io:format("~p~p: Unhandled Call ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p~p: Unhandled Call ~tp~n",[?MODULE, ?LINE, Msg]), {reply, ok, State}. handle_cast(Msg, State) -> - io:format("~p~p: Unhandled cast ~p~n",[?MODULE, ?LINE, Msg]), + io:format("~p~p: Unhandled cast ~tp~n",[?MODULE, ?LINE, Msg]), {noreply, State}. handle_event(#wx{id = ?ID_REFRESH, event = #wxCommand{type = command_menu_selected}}, @@ -235,5 +235,5 @@ handle_event(#wx{id = ?ID_REFRESH_INTERVAL, {noreply, State#sys_wx_state{timer=Timer}}; handle_event(Event, State) -> - io:format("~p:~p: Unhandled event ~p\n", [?MODULE,?LINE,Event]), + io:format("~p:~p: Unhandled event ~tp\n", [?MODULE,?LINE,Event]), {noreply, State}. diff --git a/lib/observer/src/observer_trace_wx.erl b/lib/observer/src/observer_trace_wx.erl index b960c61ff0..8127248262 100644 --- a/lib/observer/src/observer_trace_wx.erl +++ b/lib/observer/src/observer_trace_wx.erl @@ -683,7 +683,7 @@ handle_event(#wx{id=?REMOVE_NODES}, #state{n_view=Nview, nodes=Ns0} = State) -> {noreply, State#state{nodes = Ns}}; handle_event(#wx{id=ID, event = What}, State) -> - io:format("~p:~p: Unhandled event: ~p, ~p ~n", [?MODULE, ?LINE, ID, What]), + io:format("~p:~p: Unhandled event: ~p, ~tp ~n", [?MODULE, ?LINE, ID, What]), {noreply, State}. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -729,7 +729,7 @@ handle_info({update_ms, NewMs}, State) -> {noreply, State#state{match_specs=NewMs}}; handle_info(Any, State) -> - io:format("~p~p: received unexpected message: ~p\n", [?MODULE, self(), Any]), + io:format("~p~p: received unexpected message: ~tp\n", [?MODULE, self(), Any]), {noreply, State}. terminate(_Reason, #state{nodes=_Nodes}) -> @@ -1046,33 +1046,33 @@ format_trace(Trace, Size, TS0={_,_,MS}) -> case element(4, Trace) of {dbg,ok} -> ""; Message -> - io_lib:format("~s (~100p) << ~100p~n", [TS,From,Message]) + io_lib:format("~s (~100p) << ~100tp~n", [TS,From,Message]) end; 'send' -> Message = element(4, Trace), To = element(5, Trace), - io_lib:format("~s (~100p) ~100p ! ~100p~n", [TS,From,To,Message]); + io_lib:format("~s (~100p) ~100p ! ~100tp~n", [TS,From,To,Message]); call -> case element(4, Trace) of MFA when Size == 5 -> Message = element(5, Trace), - io_lib:format("~s (~100p) call ~s (~100p) ~n", [TS,From,ffunc(MFA),Message]); + io_lib:format("~s (~100p) call ~ts (~100tp) ~n", [TS,From,ffunc(MFA),Message]); MFA -> - io_lib:format("~s (~100p) call ~s~n", [TS,From,ffunc(MFA)]) + io_lib:format("~s (~100p) call ~ts~n", [TS,From,ffunc(MFA)]) end; return_from -> MFA = element(4, Trace), Ret = element(5, Trace), - io_lib:format("~s (~100p) returned from ~s -> ~100p~n", [TS,From,ffunc(MFA),Ret]); + io_lib:format("~s (~100p) returned from ~ts -> ~100tp~n", [TS,From,ffunc(MFA),Ret]); return_to -> MFA = element(4, Trace), - io_lib:format("~s (~100p) returning to ~s~n", [TS,From,ffunc(MFA)]); + io_lib:format("~s (~100p) returning to ~ts~n", [TS,From,ffunc(MFA)]); spawn when Size == 5 -> Pid = element(4, Trace), MFA = element(5, Trace), - io_lib:format("~s (~100p) spawn ~100p as ~s~n", [TS,From,Pid,ffunc(MFA)]); + io_lib:format("~s (~100p) spawn ~100p as ~ts~n", [TS,From,Pid,ffunc(MFA)]); Op -> - io_lib:format("~s (~100p) ~100p ~s~n", [TS,From,Op,ftup(Trace,4,Size)]) + io_lib:format("~s (~100p) ~100p ~ts~n", [TS,From,Op,ftup(Trace,4,Size)]) end. %%% These f* functions returns non-flat strings @@ -1080,24 +1080,24 @@ format_trace(Trace, Size, TS0={_,_,MS}) -> %% {M,F,[A1, A2, ..., AN]} -> "M:F(A1, A2, ..., AN)" %% {M,F,A} -> "M:F/A" ffunc({M,F,Argl}) when is_list(Argl) -> - io_lib:format("~100p:~100p(~s)", [M, F, fargs(Argl)]); + io_lib:format("~100p:~100tp(~ts)", [M, F, fargs(Argl)]); ffunc({M,F,Arity}) -> - io_lib:format("~100p:~100p/~100p", [M,F,Arity]); -ffunc(X) -> io_lib:format("~100p", [X]). + io_lib:format("~100p:~100tp/~100p", [M,F,Arity]); +ffunc(X) -> io_lib:format("~100tp", [X]). %% Integer -> "Integer" %% [A1, A2, ..., AN] -> "A1, A2, ..., AN" fargs(Arity) when is_integer(Arity) -> integer_to_list(Arity); fargs([]) -> []; -fargs([A]) -> io_lib:format("~100p", [A]); %% last arg -fargs([A|Args]) -> [io_lib:format("~100p,", [A]) | fargs(Args)]; -fargs(A) -> io_lib:format("~100p", [A]). % last or only arg +fargs([A]) -> io_lib:format("~100tp", [A]); %% last arg +fargs([A|Args]) -> [io_lib:format("~100tp,", [A]) | fargs(Args)]; +fargs(A) -> io_lib:format("~100tp", [A]). % last or only arg %% {A_1, A_2, ..., A_N} -> "A_Index A_Index+1 ... A_Size" ftup(Trace, Index, Index) -> - io_lib:format("~100p", [element(Index, Trace)]); + io_lib:format("~100tp", [element(Index, Trace)]); ftup(Trace, Index, Size) -> - [io_lib:format("~100p ", [element(Index, Trace)]) + [io_lib:format("~100tp ", [element(Index, Trace)]) | ftup(Trace, Index+1, Size)]. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1125,18 +1125,19 @@ get_config(#state{def_proc_flags = ProcFlags, write_file(Frame, Filename, Config) -> Str = - ["%%%\n%%% This file is generated by Observer\n", + ["%%% ",epp:encoding_to_string(utf8), "\n" + "%%%\n%%% This file is generated by Observer\n", "%%%\n%%% DO NOT EDIT!\n%%%\n", - [io_lib:format("~p.~n",[MSTerm]) || + [io_lib:format("~tp.~n",[MSTerm]) || MSTerm <- proplists:get_value(match_specs, Config)], io_lib:format("~p.~n",[lists:keyfind(procflags, 1, Config)]), io_lib:format("~p.~n",[lists:keyfind(portflags, 1, Config)]), - io_lib:format("~p.~n",[lists:keyfind(output, 1, Config)]), - [io_lib:format("~p.~n",[ModuleTerm]) || + io_lib:format("~tp.~n",[lists:keyfind(output, 1, Config)]), + [io_lib:format("~tp.~n",[ModuleTerm]) || ModuleTerm <- proplists:get_value(trace_p, Config)] ], - case file:write_file(Filename, list_to_binary(Str)) of + case file:write_file(Filename, unicode:characters_to_binary(Str)) of ok -> success; {error, Reason} -> @@ -1200,7 +1201,7 @@ make_ms(MS) -> make_ms(Name,Term,FunStr). make_ms(Name, Term, FunStr) -> - #match_spec{name=Name, term=Term, str=io_lib:format("~w", Term), func = FunStr}. + #match_spec{name=Name, term=Term, str=io_lib:format("~tw", Term), func = FunStr}. parse_tp({tp, Mod, FAs}, State) -> Patterns = [#tpattern{m=Mod,fa={F,A}, ms=make_ms(List)} || diff --git a/lib/observer/src/observer_traceoptions_wx.erl b/lib/observer/src/observer_traceoptions_wx.erl index fca1510527..fbcf6d7fe9 100644 --- a/lib/observer/src/observer_traceoptions_wx.erl +++ b/lib/observer/src/observer_traceoptions_wx.erl @@ -487,7 +487,7 @@ edit_ms(TextCtrl, Label0, Parent) -> _ -> Label0 end, #match_spec{name=Label, term=MatchSpec, - str=io_lib:format("~w",[MatchSpec]), + str=io_lib:format("~tw",[MatchSpec]), func=Str} catch throw:cancel -> @@ -511,18 +511,18 @@ ms_from_string(Str) -> Tokens = case erl_scan:string(Str) of {ok, Ts, _} -> Ts; {error, {SLine, SMod, SError}, _} -> - throw(io_lib:format("~w: ~s", [SLine,SMod:format_error(SError)])) + throw(io_lib:format("~w: ~ts", [SLine,SMod:format_error(SError)])) end, Exprs = case erl_parse:parse_exprs(Tokens) of {ok, T} -> T; {error, {PLine, PMod, PError}} -> - throw(io_lib:format("~w: ~s", [PLine,PMod:format_error(PError)])) + throw(io_lib:format("~w: ~ts", [PLine,PMod:format_error(PError)])) end, Term = case Exprs of [{'fun', _, {clauses, Clauses}}|_] -> case ms_transform:transform_from_shell(dbg,Clauses,orddict:new()) of {error, [{_,[{MSLine,Mod,MSInfo}]}],_} -> - throw(io_lib:format("~w: ~p", [MSLine,Mod:format_error(MSInfo)])); + throw(io_lib:format("~w: ~tp", [MSLine,Mod:format_error(MSInfo)])); {error, _} -> throw("Could not convert fun() to match spec"); Ms -> @@ -536,7 +536,7 @@ ms_from_string(Str) -> {error, List} -> throw([[Error, $\n] || {_, Error} <- List]) end catch error:_Reason -> - %% io:format("Bad term: ~s~n ~p in ~p~n", [Str, _Reason, erlang:get_stacktrace()]), + %% io:format("Bad term: ~ts~n ~tp in ~tp~n", [Str, _Reason, erlang:get_stacktrace()]), throw("Invalid term") end. @@ -556,7 +556,8 @@ filter_listbox_data(Input, Data, ListBox) -> filter_listbox_data(Input, Data, ListBox, true). filter_listbox_data(Input, Data, ListBox, AddClientData) -> - FilteredData = [X || X = {Str, _} <- Data, re:run(Str, Input) =/= nomatch], + FilteredData = [X || X = {Str, _} <- Data, + re:run(Str, Input, [unicode]) =/= nomatch], wxListBox:clear(ListBox), wxListBox:appendStrings(ListBox, [Str || {Str,_} <- FilteredData]), AddClientData andalso @@ -648,9 +649,9 @@ parse_function_names(Choices) -> parse_function_names([], Acc) -> lists:reverse(Acc); parse_function_names([{H, Term}|T], Acc) -> - IsFun = re:run(H, ".*-fun-\\d*?-"), - IsLc = re:run(H, ".*-lc\\$\\^\\d*?/\\d*?-\\d*?-"), - IsLbc = re:run(H, ".*-lbc\\$\\^\\d*?/\\d*?-\\d*?-"), + IsFun = re:run(H, ".*-fun-\\d*?-", [unicode,ucp]), + IsLc = re:run(H, ".*-lc\\$\\^\\d*?/\\d*?-\\d*?-", [unicode,ucp]), + IsLbc = re:run(H, ".*-lbc\\$\\^\\d*?/\\d*?-\\d*?-", [unicode,ucp]), Parsed = if IsFun =/= nomatch -> "Fun: " ++ H; IsLc =/= nomatch -> "List comprehension: " ++ H; diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl index 789e060cfb..d6dcee2cda 100644 --- a/lib/observer/src/observer_tv_table.erl +++ b/lib/observer/src/observer_tv_table.erl @@ -258,7 +258,7 @@ handle_event(#wx{event=#wxList{type=command_list_item_selected, itemIndex=Index} State = #state{pid=Pid, grid=Grid, status=StatusBar}) -> N = wxListCtrl:getItemCount(Grid), Str = get_row(Pid, Index, all), - wxStatusBar:setStatusText(StatusBar, io_lib:format("Objects: ~w: ~s",[N, Str])), + wxStatusBar:setStatusText(StatusBar, io_lib:format("Objects: ~w: ~ts",[N, Str])), {noreply, State#state{selected=Index}}; handle_event(#wx{event=#wxList{type=command_list_item_activated, itemIndex=Index}}, @@ -278,7 +278,7 @@ handle_event(#wx{id=?ID_DELETE}, State = #state{grid=Grid, pid=Pid, status=StatusBar, selected=Index}) -> Str = get_row(Pid, Index, all), Pid ! {delete, Index}, - wxStatusBar:setStatusText(StatusBar, io_lib:format("Deleted object: ~s",[Str])), + wxStatusBar:setStatusText(StatusBar, io_lib:format("Deleted object: ~ts",[Str])), wxListCtrl:setItemState(Grid, Index, 0, ?wxLIST_STATE_FOCUSED), {noreply, State#state{selected=undefined}}; @@ -338,7 +338,7 @@ handle_event(#wx{id=?SEARCH_ENTRY, event=#wxCommand{type=command_text_enter,cmdS Pid ! {mark_search_hit, false}, case search(Pid, Str, Pos, Dir, Case) of false -> - wxStatusBar:setStatusText(SB, io_lib:format("Not found (regexp): ~s",[Str])), + wxStatusBar:setStatusText(SB, io_lib:format("Not found (regexp): ~ts",[Str])), Pid ! {mark_search_hit, Find#find.start}, wxListCtrl:refreshItem(Grid, Find#find.start), {noreply, State#state{search=Search#search{find=Find#find{found=false}}}}; @@ -372,7 +372,7 @@ handle_event(#wx{id=?SEARCH_ENTRY, event=#wxCommand{cmdString=Str}}, Pid ! {mark_search_hit, false}, case search(Pid, Str, Cont#find.start, Dir, Case) of false -> - wxStatusBar:setStatusText(SB, io_lib:format("Not found (regexp): ~s",[Str])), + wxStatusBar:setStatusText(SB, io_lib:format("Not found (regexp): ~ts",[Str])), {noreply, State}; Row -> wxListCtrl:ensureVisible(Grid, Row), @@ -395,19 +395,19 @@ handle_event(#wx{id=?ID_REFRESH_INTERVAL}, {noreply, State#state{timer=Timer}}; handle_event(_Event, State) -> - %io:format("~p:~p, handle event ~p\n", [?MODULE, ?LINE, Event]), + %io:format("~p:~p, handle event ~tp\n", [?MODULE, ?LINE, Event]), {noreply, State}. handle_sync_event(_Event, _Obj, _State) -> - %io:format("~p:~p, handle sync_event ~p\n", [?MODULE, ?LINE, Event]), + %io:format("~p:~p, handle sync_event ~tp\n", [?MODULE, ?LINE, Event]), ok. handle_call(_Event, _From, State) -> - %io:format("~p:~p, handle call (~p) ~p\n", [?MODULE, ?LINE, From, Event]), + %io:format("~p:~p, handle call (~p) ~tp\n", [?MODULE, ?LINE, From, Event]), {noreply, State}. handle_cast(_Event, State) -> - %io:format("~p:~p, handle cast ~p\n", [?MODULE, ?LINE, Event]), + %io:format("~p:~p, handle cast ~tp\n", [?MODULE, ?LINE, Event]), {noreply, State}. handle_info({no_rows, N}, State = #state{grid=Grid, status=StatusBar}) -> @@ -433,7 +433,7 @@ handle_info(refresh_interval, State = #state{pid=Pid}) -> handle_info({error, Error}, State = #state{frame=Frame}) -> ErrorStr = try io_lib:format("~ts", [Error]), Error - catch _:_ -> io_lib:format("~p", [Error]) + catch _:_ -> io_lib:format("~tp", [Error]) end, Dlg = wxMessageDialog:new(Frame, ErrorStr), wxMessageDialog:showModal(Dlg), @@ -441,7 +441,7 @@ handle_info({error, Error}, State = #state{frame=Frame}) -> {noreply, State}; handle_info(_Event, State) -> - %% io:format("~p:~p, handle info ~p\n", [?MODULE, ?LINE, _Event]), + %% io:format("~p:~p, handle info ~tp\n", [?MODULE, ?LINE, _Event]), {noreply, State}. terminate(_Event, #state{pid=Pid, attrs=Attrs}) -> @@ -554,7 +554,7 @@ table_holder(S0 = #holder{parent=Parent, pid=Pid, table=Table}) -> edit_row(Row, Term, S0), table_holder(S0); What -> - io:format("Table holder got ~p~n",[What]), + io:format("Table holder got ~tp~n",[What]), Parent ! {refresh, 0, S0#holder.n-1}, table_holder(S0) end. @@ -641,7 +641,7 @@ search([Str, Row, Dir0, CaseSens], true -> 1; false -> -1 end, - Res = case re:compile(Str, Opt) of + Res = case re:compile(Str, [unicode|Opt]) of {ok, Re} -> re_search(Row, Dir, N, Re, Table); {error, _} -> false end, @@ -665,7 +665,7 @@ get_row(From, Row, Col, Table) -> [Object|_] when Col =:= all -> From ! {self(), format(Object)}; [Object|_] when Col =:= all_multiline -> - From ! {self(), io_lib:format("~p", [Object])}; + From ! {self(), io_lib:format("~tp", [Object])}; [Object|_] when Col =:= term -> From ! {self(), Object}; [Object|_] when tuple_size(Object) >= Col -> @@ -801,7 +801,7 @@ format(Bin) when is_binary(Bin), byte_size(Bin) > 100 -> io_lib:format("<<#Bin:~w>>", [byte_size(Bin)]); format(Bin) when is_binary(Bin) -> try - true = printable_list(unicode:characters_to_list(Bin)), + true = io_lib:printable_list(unicode:characters_to_list(Bin)), io_lib:format("<<\"~ts\">>", [Bin]) catch _:_ -> io_lib:format("~w", [Bin]) @@ -809,7 +809,7 @@ format(Bin) when is_binary(Bin) -> format(Float) when is_float(Float) -> io_lib:format("~.3g", [Float]); format(Term) -> - io_lib:format("~w", [Term]). + io_lib:format("~tw", [Term]). format_tuple(Tuple, I, Max) when I < Max -> [format(element(I, Tuple)), $,|format_tuple(Tuple, I+1, Max)]; @@ -820,7 +820,7 @@ format_tuple(_Tuple, 1, 0) -> format_list([]) -> "[]"; format_list(List) -> - case printable_list(List) of + case io_lib:printable_list(List) of true -> io_lib:format("\"~ts\"", [map_printable_list(List)]); false -> [$[ | make_list(List)] end. @@ -849,26 +849,3 @@ map_printable_list([$\e|Cs]) -> map_printable_list([]) -> []; map_printable_list([C|Cs]) -> [C|map_printable_list(Cs)]. - -%% printable_list([Char]) -> bool() -%% Return true if CharList is a list of printable characters, else -%% false. - -printable_list([C|Cs]) when is_integer(C), C >= $ , C =< 255 -> - printable_list(Cs); -printable_list([$\n|Cs]) -> - printable_list(Cs); -printable_list([$\r|Cs]) -> - printable_list(Cs); -printable_list([$\t|Cs]) -> - printable_list(Cs); -printable_list([$\v|Cs]) -> - printable_list(Cs); -printable_list([$\b|Cs]) -> - printable_list(Cs); -printable_list([$\f|Cs]) -> - printable_list(Cs); -printable_list([$\e|Cs]) -> - printable_list(Cs); -printable_list([]) -> true; -printable_list(_Other) -> false. %Everything else is false diff --git a/lib/observer/src/observer_tv_wx.erl b/lib/observer/src/observer_tv_wx.erl index 9564bdfa1c..e16f3cab6b 100644 --- a/lib/observer/src/observer_tv_wx.erl +++ b/lib/observer/src/observer_tv_wx.erl @@ -252,7 +252,7 @@ handle_info(not_active, State = #state{timer = Timer0}) -> {noreply, State#state{timer=Timer}}; handle_info({error, Error}, #state{panel=Panel,opt=Opt}=State) -> - Str = io_lib:format("ERROR: ~s~n",[Error]), + Str = io_lib:format("ERROR: ~ts~n",[Error]), observer_lib:display_info_dialog(Panel,Str), case Opt#opt.type of mnesia -> wxMenuBar:check(observer_wx:get_menubar(), ?ID_ETS, true); diff --git a/lib/observer/src/observer_wx.erl b/lib/observer/src/observer_wx.erl index 9b9e80f479..be93b1d5f1 100644 --- a/lib/observer/src/observer_wx.erl +++ b/lib/observer/src/observer_wx.erl @@ -459,7 +459,7 @@ handle_info({'EXIT', Pid, Reason}, State) -> normal -> {noreply, State}; _ -> - io:format("Observer: Child (~s) crashed exiting: ~p ~p~n", + io:format("Observer: Child (~s) crashed exiting: ~p ~tp~n", [pid2panel(Pid, State), Pid, Reason]), {stop, normal, State} end; @@ -504,7 +504,7 @@ save_config(Panels) -> File = config_file(), case filelib:ensure_dir(File) of ok -> - Format = [io_lib:format("~p.~n",[Conf]) || Conf <- Configs], + Format = [io_lib:format("~tp.~n",[Conf]) || Conf <- Configs], _ = file:write_file(File, Format); _ -> ignore diff --git a/lib/observer/src/ttb.erl b/lib/observer/src/ttb.erl index 09b0bc6710..940fdc9818 100644 --- a/lib/observer/src/ttb.erl +++ b/lib/observer/src/ttb.erl @@ -635,7 +635,7 @@ stop(Opts) when is_list(Opts) -> ok; {_, {stopped, _}} -> %% Printout moved out of the ttb loop to avoid occasional deadlock - io:format("Stored logs in ~s~n", [element(2, Result)]); + io:format("Stored logs in ~ts~n", [element(2, Result)]); {_, _} -> ok end, @@ -792,7 +792,7 @@ do_stop({FetchOrFormat, UserDir}, Sender, NodeInfo, SessionInfo) -> write_config(?last_config, all), Localhost = host(node()), Dir = get_fetch_dir(UserDir, proplists:get_value(logfile, SessionInfo)), - file:make_dir(Dir), + ok = filelib:ensure_dir(filename:join(Dir,"*")), %% The nodes are traversed twice here because %% the meta tracing in observer_backend must be %% stopped before dbg is stopped, and dbg must @@ -900,21 +900,29 @@ fetch_report(Localhost, Dir, Node, MetaFile) -> fetch(Localhost,Dir,Node,MetaFile) -> case (host(Node) == Localhost) orelse is_local(MetaFile) of - true -> % same host, just move the files + true -> % same host, just move the files Files = get_filenames(Node,MetaFile), lists:foreach( - fun(File0) -> - Dest = filename:join(Dir,filename:basename(File0)), - file:rename(File0, Dest) - end, - Files); + fun(File0) -> + Dest = filename:join(Dir,filename:basename(File0)), + file:rename(File0, Dest) + end, + Files); false -> {ok, LSock} = gen_tcp:listen(0, [binary,{packet,2},{active,false}]), {ok,Port} = inet:port(LSock), - rpc:cast(Node,observer_backend,ttb_fetch, - [MetaFile,{Port,Localhost}]), + Enc = file:native_name_encoding(), + Args = + case rpc:call(Node,erlang,function_exported, + [observer_backend,ttb_fetch,3]) of + true -> + [MetaFile,{Port,Localhost},Enc]; + false -> + [MetaFile,{Port,Localhost}] + end, + rpc:cast(Node,observer_backend,ttb_fetch,Args), {ok, Sock} = gen_tcp:accept(LSock), - receive_files(Dir,Sock,undefined), + receive_files(Dir,Sock,undefined,Enc), ok = gen_tcp:close(LSock), ok = gen_tcp:close(Sock) end. @@ -929,25 +937,48 @@ get_filenames(_N, {local,F,_}) -> get_filenames(N, F) -> rpc:call(N, observer_backend,ttb_get_filenames,[F]). -receive_files(Dir,Sock,Fd) -> +receive_files(Dir,Sock,Fd,Enc) -> case gen_tcp:recv(Sock, 0) of {ok, <<0,Bin/binary>>} -> file:write(Fd,Bin), - receive_files(Dir,Sock,Fd); - {ok, <<1,Bin/binary>>} -> - File0 = binary_to_list(Bin), + receive_files(Dir,Sock,Fd,Enc); + {ok, <<Code,Bin/binary>>} when Code==1; Code==2; Code==3 -> + File0 = decode_filename(Code,Bin,Enc), File = filename:join(Dir,File0), {ok,Fd1} = file:open(File,[raw,write]), - receive_files(Dir,Sock,Fd1); + receive_files(Dir,Sock,Fd1,Enc); {error, closed} -> ok = file:close(Fd) end. +decode_filename(1,Bin,_Enc) -> + %% Old version of observer_backend - filename encoded with + %% list_to_binary + binary_to_list(Bin); +decode_filename(2,Bin,Enc) -> + %% Successfully encoded filename with correct encoding + unicode:characters_to_list(Bin,Enc); +decode_filename(3,Bin,latin1) -> + %% Filename encoded with faulty encoding. This has to be utf8 + %% remote and latin1 here, and the filename actually containing + %% characters outside the latin1 range. So making an escaped + %% variant of the filename and warning about it. + File0 = unicode:characters_to_list(Bin,utf8), + File = [ case X of + High when High > 255 -> + ["\\\\x{",erlang:integer_to_list(X, 16),$}]; + Low -> + Low + end || X <- File0 ], + io:format("Warning: fetching file with faulty filename encoding ~ts~n" + "Will be written as ~ts~n", + [File0,File]), + File. + host(Node) -> [_name,Host] = string:tokens(atom_to_list(Node),"@"), Host. - wait_for_fetch([]) -> ok; wait_for_fetch(Nodes) -> @@ -1087,7 +1118,7 @@ read_traci(File) -> {ok,B} -> interpret_binary(B,dict:new(),[]); _ -> - io:format("Warning: no meta data file: ~s~n",[MetaFile]), + io:format("Warning: no meta data file: ~ts~n",[MetaFile]), {dict:new(),[]} end. @@ -1303,7 +1334,7 @@ get_term(B) -> end. display_warning(Item,Warning) -> - io:format("Warning: {~w,~w}~n",[Warning,Item]). + io:format("Warning: {~tw,~tw}~n",[Warning,Item]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/lib/observer/src/ttb_et.erl b/lib/observer/src/ttb_et.erl index 95e8e9aa07..1b828eebc0 100644 --- a/lib/observer/src/ttb_et.erl +++ b/lib/observer/src/ttb_et.erl @@ -137,13 +137,13 @@ processes(E0) -> E = label(E0), {{FromProc,FromNode},{ToProc,ToNode}} = get_actors(E#event.from,E#event.to), - {true,E#event{from = io_lib:format("~w~n~w",[FromProc,FromNode]), - to = io_lib:format("~w~n~w",[ToProc,ToNode])}}. + {true,E#event{from = io_lib:format("~tw~n~w",[FromProc,FromNode]), + to = io_lib:format("~tw~n~w",[ToProc,ToNode])}}. mods_and_procs(E) -> ActorFun = fun({M,_F,_A},{Proc,Node}) -> - io_lib:format("~w~n~w~n~w",[M,Proc,Node]) + io_lib:format("~w~n~tw~n~w",[M,Proc,Node]) end, calltrace_filter(E,ActorFun). @@ -155,13 +155,13 @@ modules(E) -> funcs_and_procs(E) -> ActorFun = fun({M,F,A},{Proc,Node}) -> - io_lib:format("~s~n~w~n~w",[mfa(M,F,A),Proc,Node]) + io_lib:format("~ts~n~tw~n~w",[mfa(M,F,A),Proc,Node]) end, calltrace_filter(E,ActorFun). functions(E) -> ActorFun = fun({M,F,A},{_Proc,Node}) -> - io_lib:format("~s~n~w",[mfa(M,F,A),Node]) + io_lib:format("~ts~n~w",[mfa(M,F,A),Node]) end, calltrace_filter(E,ActorFun). @@ -221,7 +221,7 @@ label(Event=#event{label=L,contents=C}) -> false -> Event end. label(L,{M,F,A}) -> label(L,M,F,A); -label(L,Other) -> io_lib:format("~w ~w",[L,Other]). +label(L,Other) -> io_lib:format("~w ~tw",[L,Other]). label(call,M,F,A) -> "call " ++ mfa(M,F,A); label(return_from,M,F,A) -> "return_from " ++ mfa(M,F,A); label(return_to,M,F,A) -> "return_to " ++ mfa(M,F,A); diff --git a/lib/observer/test/Makefile b/lib/observer/test/Makefile index 6100af5e17..fcb1b73911 100644 --- a/lib/observer/test/Makefile +++ b/lib/observer/test/Makefile @@ -27,7 +27,8 @@ MODULES = \ ttb_SUITE \ client \ server \ - crashdump_helper + crashdump_helper \ + crashdump_helper_unicode ERL_FILES= $(MODULES:%=%.erl) @@ -46,7 +47,7 @@ RELSYSDIR = $(RELEASE_PATH)/observer_test # FLAGS # ---------------------------------------------------- ERL_MAKE_FLAGS += -ERL_COMPILE_FLAGS += +ERL_COMPILE_FLAGS += +nowarn_export_all EBIN = . diff --git a/lib/observer/test/crashdump_helper_unicode.erl b/lib/observer/test/crashdump_helper_unicode.erl new file mode 100644 index 0000000000..60c3d20315 --- /dev/null +++ b/lib/observer/test/crashdump_helper_unicode.erl @@ -0,0 +1,22 @@ +-module(crashdump_helper_unicode). +-behaviour(gen_server). +-export([start/0, init/1, handle_call/3, handle_cast/2]). +-record(state, {s,a,b,lb}). + +start() -> + gen_server:start({local, 'unicode_reg_name_αβ'}, ?MODULE, [], []). + +init([]) -> + process_flag(trap_exit, true), + ets:new('tab_αβ',[set,named_table]), + Bin = <<"bin αβ"/utf8>>, + LongBin = <<"long bin αβ - a utf8 binary which can be expanded αβ"/utf8>>, + {ok, #state{s = "unicode_string_αβ", + a = 'unicode_atom_αβ', + b = Bin, + lb = LongBin}}. + +handle_call(_Info, _From, State) -> + {reply, ok, State}. +handle_cast(_Info, State) -> + {noreply, State}. diff --git a/lib/observer/test/crashdump_viewer_SUITE.erl b/lib/observer/test/crashdump_viewer_SUITE.erl index 1fd94ffb3c..77cf086d4b 100644 --- a/lib/observer/test/crashdump_viewer_SUITE.erl +++ b/lib/observer/test/crashdump_viewer_SUITE.erl @@ -427,6 +427,18 @@ special(File,Procs) -> {ok,_,[TW]} = crashdump_viewer:general_info(), {match,_} = re:run(TW,"CRASH DUMP SIZE LIMIT REACHED"), ok; + ".unicode" -> + #proc{pid=Pid0} = + lists:keyfind("'unicode_reg_name_αβ'",#proc.name,Procs), + Pid = pid_to_list(Pid0), + {ok,#proc{},[]} = crashdump_viewer:proc_details(Pid), + io:format(" unicode registered name ok",[]), + + {ok,[#ets_table{id="'tab_αβ'",name="'tab_αβ'"}],[]} = + crashdump_viewer:ets_tables(Pid), + io:format(" unicode table name ok",[]), + + ok; _ -> ok end, @@ -492,7 +504,8 @@ do_create_dumps(DataDir,Rel) -> CD5 = dump_with_args(DataDir,Rel,"trunc.bytes", "-env ERL_CRASH_DUMP_BYTES " ++ integer_to_list(Bytes)), - {[CD1,CD2,CD3,CD4,CD5], DosDump}; + CD6 = dump_with_unicode_atoms(DataDir,Rel,"unicode"), + {[CD1,CD2,CD3,CD4,CD5,CD6], DosDump}; _ -> {[CD1,CD2], DosDump} end. @@ -573,6 +586,16 @@ dump_with_strange_module_name(DataDir,Rel,DumpName) -> ?t:stop_node(n1), CD. +dump_with_unicode_atoms(DataDir,Rel,DumpName) -> + Opt = rel_opt(Rel), + Pz = "-pz \"" ++ filename:dirname(code:which(?MODULE)) ++ "\"", + PzOpt = [{args,Pz}], + {ok,N1} = ?t:start_node(n1,peer,Opt ++ PzOpt), + {ok,_Pid} = rpc:call(N1,crashdump_helper_unicode,start,[]), + CD = dump(N1,DataDir,Rel,DumpName), + ?t:stop_node(n1), + CD. + dump(Node,DataDir,Rel,DumpName) -> Crashdump = filename:join(DataDir, dump_prefix(Rel)++DumpName), rpc:call(Node,os,putenv,["ERL_CRASH_DUMP",Crashdump]), diff --git a/lib/runtime_tools/src/observer_backend.erl b/lib/runtime_tools/src/observer_backend.erl index 7f0c1ac6e4..1b075a507d 100644 --- a/lib/runtime_tools/src/observer_backend.erl +++ b/lib/runtime_tools/src/observer_backend.erl @@ -36,6 +36,7 @@ ttb_write_binary/2, ttb_stop/1, ttb_fetch/2, + ttb_fetch/3, ttb_resume_trace/0, ttb_get_filenames/1]). -define(CHUNKSIZE,8191). % 8 kbytes - 1 byte @@ -658,22 +659,42 @@ stop_seq_trace() -> %% Fetch ttb logs from remote node ttb_fetch(MetaFile,{Port,Host}) -> + ttb_fetch(MetaFile,{Port,Host},undefined). +ttb_fetch(MetaFile,{Port,Host},MasterEnc) -> erlang:process_flag(priority,low), Files = ttb_get_filenames(MetaFile), {ok, Sock} = gen_tcp:connect(Host, Port, [binary, {packet, 2}]), - send_files({Sock,Host},Files), + send_files({Sock,Host},Files,MasterEnc,file:native_name_encoding()), ok = gen_tcp:close(Sock). -send_files({Sock,Host},[File|Files]) -> +send_files({Sock,Host},[File|Files],MasterEnc,MyEnc) -> {ok,Fd} = file:open(File,[raw,read,binary]), - ok = gen_tcp:send(Sock,<<1,(list_to_binary(filename:basename(File)))/binary>>), + Basename = filename:basename(File), + {Code,FilenameBin} = encode_filename(Basename,MasterEnc,MyEnc), + ok = gen_tcp:send(Sock,<<Code,FilenameBin/binary>>), send_chunks(Sock,Fd), ok = file:delete(File), - send_files({Sock,Host},Files); -send_files({_Sock,_Host},[]) -> + send_files({Sock,Host},Files,MasterEnc,MyEnc); +send_files({_Sock,_Host},[],_MasterEnc,_MyEnc) -> done. +encode_filename(Basename,undefined,MyEnc) -> + %% Compatible with old version of ttb.erl, but no longer crashing + %% for code points > 255. + {1,unicode:characters_to_binary(Basename,MyEnc,MyEnc)}; +encode_filename(Basename,MasterEnc,MyEnc) -> + case unicode:characters_to_binary(Basename,MyEnc,MasterEnc) of + Bin when is_binary(Bin) -> + %% Encoding succeeded + {2,Bin}; + _ -> + %% Can't convert Basename from my encoding to the master + %% node's encoding. Doing my best and hoping that master + %% node can fix it... + {3,unicode:characters_to_binary(Basename,MyEnc,MyEnc)} + end. + send_chunks(Sock,Fd) -> case file:read(Fd,?CHUNKSIZE) of {ok,Bin} -> diff --git a/lib/sasl/doc/src/sasl_app.xml b/lib/sasl/doc/src/sasl_app.xml index 0576397f9b..e0693fcb60 100644 --- a/lib/sasl/doc/src/sasl_app.xml +++ b/lib/sasl/doc/src/sasl_app.xml @@ -103,13 +103,16 @@ <tag><c>{file,FileName}</c></tag> <item><p>Installs <c>sasl_report_file_h</c> in the error logger. All reports go to file <c>FileName</c>, which is a - string.</p></item> + string. The file is opened in <c>write</c> mode with encoding + <c>utf8</c>.</p></item> <tag><c>{file,FileName,Modes}</c></tag> <item><p>Same as <c>{file,FileName}</c>, except that <c>Modes</c> allows you to specify the modes used for opening the <c>FileName</c> given to the <seealso marker="kernel:file#open/2">file:open/2</seealso> - call. When not specified, <c>Modes</c> defaults to <c>[write]</c>. - Use <c>[append]</c> to have the <c>FileName</c> open in append mode. + call. By default, the file is opened in <c>write</c> mode + with encoding <c>utf8</c>. Use <c>[append]</c> to have + the <c>FileName</c> open in append mode. A different + encoding can also be specified. <c>FileName</c> is a string.</p></item> <tag><c>false</c></tag> <item><p>No SASL error logger handler is installed.</p></item> diff --git a/lib/sasl/src/sasl_report.erl b/lib/sasl/src/sasl_report.erl index eb454155d5..e6556ec6ce 100644 --- a/lib/sasl/src/sasl_report.erl +++ b/lib/sasl/src/sasl_report.erl @@ -47,6 +47,7 @@ io_report(_IO, _Fd, _, _) -> is_my_error_report(all, Type) -> is_my_error_report(Type); is_my_error_report(error, Type) -> is_my_error_report(Type); is_my_error_report(_, _Type) -> false. + is_my_error_report(supervisor_report) -> true; is_my_error_report(crash_report) -> true; is_my_error_report(_) -> false. @@ -54,6 +55,7 @@ is_my_error_report(_) -> false. is_my_info_report(all, Type) -> is_my_info_report(Type); is_my_info_report(progress, Type) -> is_my_info_report(Type); is_my_info_report(_, _Type) -> false. + is_my_info_report(progress) -> true; is_my_info_report(_) -> false. @@ -62,46 +64,65 @@ write_report2(IO, Fd, Head, supervisor_report, Report) -> Context = sup_get(errorContext, Report), Reason = sup_get(reason, Report), Offender = sup_get(offender, Report), - {FmtString,Args} = supervisor_format([Name,Context,Reason,Offender]), - write_report_action(IO, Fd, Head, FmtString, Args); + Enc = encoding(Fd), + {FmtString,Args} = supervisor_format([Name,Context,Reason,Offender], Enc), + String = io_lib:format(FmtString, Args), + write_report_action(IO, Fd, Head, String); write_report2(IO, Fd, Head, progress, Report) -> - Format = format_key_val(Report), - write_report_action(IO, Fd, Head, "~s", [Format]); + Encoding = encoding(Fd), + Depth = error_logger:get_format_depth(), + String = format_key_val(Report, Encoding, Depth), + write_report_action(IO, Fd, Head, String); write_report2(IO, Fd, Head, crash_report, Report) -> + Encoding = encoding(Fd), Depth = error_logger:get_format_depth(), - Format = proc_lib:format(Report, latin1, Depth), - write_report_action(IO, Fd, Head, "~s", [Format]). - -supervisor_format(Args0) -> - case error_logger:get_format_depth() of - unlimited -> - {" Supervisor: ~p~n" - " Context: ~p~n" - " Reason: ~80.18p~n" - " Offender: ~80.18p~n~n", - Args0}; - Depth -> - [A,B,C,D] = Args0, - Args = [A,Depth,B,Depth,C,Depth,D,Depth], - {" Supervisor: ~P~n" - " Context: ~P~n" - " Reason: ~80.18P~n" - " Offender: ~80.18P~n~n", - Args} - end. - -write_report_action(IO, Fd, Head, Format, Args) -> - S = [Head|io_lib:format(Format, Args)], + String = proc_lib:format(Report, Encoding, Depth), + write_report_action(IO, Fd, Head, String). + +supervisor_format(Args0, Encoding) -> + {P, Tl} = p(Encoding, error_logger:get_format_depth()), + [A,B,C,D] = Args0, + Args = [A|Tl] ++ [B|Tl] ++ [C|Tl] ++ [D|Tl], + {" Supervisor: ~" ++ P ++ "\n" + " Context: ~" ++ P ++ "\n" + " Reason: ~80.18" ++ P ++ "\n" + " Offender: ~80.18" ++ P ++ "\n~n", + Args}. + +write_report_action(IO, Fd, Head, String) -> + S = [Head|String], case IO of io -> io:put_chars(Fd, S); io_lib -> S end. -format_key_val([{Tag,Data}|Rep]) -> - io_lib:format(" ~16w: ~p~n",[Tag,Data]) ++ format_key_val(Rep); -format_key_val(_) -> +format_key_val(Rep, Encoding, Depth) -> + {P, Tl} = p(Encoding, Depth), + format_key_val1(Rep, P, Tl). + +format_key_val1([{Tag,Data}|Rep], P, Tl) -> + (io_lib:format(" ~16w: ~" ++ P ++ "\n", [Tag, Data|Tl]) ++ + format_key_val1(Rep, P, Tl)); +format_key_val1(_, _, _) -> []. +p(Encoding, Depth) -> + {Letter, Tl} = case Depth of + unlimited -> {"p", []}; + _ -> {"P", [Depth]} + end, + P = modifier(Encoding) ++ Letter, + {P, Tl}. + +encoding(IO) -> + case lists:keyfind(encoding, 1, io:getopts(IO)) of + false -> latin1; + {encoding, Enc} -> Enc + end. + +modifier(latin1) -> ""; +modifier(_) -> "t". + sup_get(Tag, Report) -> case lists:keysearch(Tag, 1, Report) of {value, {_, Value}} -> diff --git a/lib/sasl/src/sasl_report_file_h.erl b/lib/sasl/src/sasl_report_file_h.erl index 21746839fa..d3b5c7dc0d 100644 --- a/lib/sasl/src/sasl_report_file_h.erl +++ b/lib/sasl/src/sasl_report_file_h.erl @@ -29,15 +29,27 @@ handle_event/2, handle_call/2, handle_info/2, terminate/2]). -init({File, Modes, Type}) when is_list(Modes) -> +init({File, Modes0, Type}) when is_list(Modes0) -> process_flag(trap_exit, true), + Modes1 = + case lists:keymember(encoding,1,Modes0) of + true -> Modes0; + false -> [{encoding,utf8}|Modes0] + end, + Modes = + case [M || M <- Modes1, lists:member(M,[write,append,exclusive])] of + [] -> + [write|Modes1]; + _ -> + Modes1 + end, case file:open(File, Modes) of {ok,Fd} -> {ok, {Fd, File, Type}}; What -> What end. - + handle_event({_Type, GL, _Msg}, State) when node(GL) /= node() -> {ok, State}; handle_event(Event, {Fd, File, Type}) -> diff --git a/lib/sasl/test/sasl_report_SUITE.erl b/lib/sasl/test/sasl_report_SUITE.erl index 53fb614921..92df5e6e40 100644 --- a/lib/sasl/test/sasl_report_SUITE.erl +++ b/lib/sasl/test/sasl_report_SUITE.erl @@ -20,7 +20,7 @@ -module(sasl_report_SUITE). -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2]). --export([gen_server_crash/1]). +-export([gen_server_crash/1, gen_server_crash_unicode/1]). -export([crash_me/0,start_link/0,init/1,handle_cast/2,terminate/2]). @@ -29,7 +29,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [gen_server_crash]. + [gen_server_crash, gen_server_crash_unicode]. groups() -> []. @@ -47,8 +47,14 @@ end_per_group(_GroupName, Config) -> Config. gen_server_crash(Config) -> + gen_server_crash(Config, latin1). + +gen_server_crash_unicode(Config) -> + gen_server_crash(Config, unicode). + +gen_server_crash(Config, Encoding) -> try - do_gen_server_crash(Config) + do_gen_server_crash(Config, Encoding) after error_logger:tty(true), ok = application:unset_env(sasl, sasl_error_logger), @@ -57,7 +63,7 @@ gen_server_crash(Config) -> end, ok. -do_gen_server_crash(Config) -> +do_gen_server_crash(Config, Encoding) -> PrivDir = ?config(priv_dir, Config), LogDir = filename:join(PrivDir, ?MODULE), KernelLog = filename:join(LogDir, "kernel.log"), @@ -67,7 +73,8 @@ do_gen_server_crash(Config) -> error_logger:delete_report_handler(cth_log_redirect), error_logger:tty(false), application:stop(sasl), - ok = application:set_env(sasl, sasl_error_logger, {file,SaslLog}, + Modes = [write, {encoding, Encoding}], + ok = application:set_env(sasl, sasl_error_logger, {file,SaslLog,Modes}, [{persistent,true}]), application:set_env(kernel, error_logger_format_depth, 30), error_logger:logfile({open,KernelLog}), @@ -78,16 +85,21 @@ do_gen_server_crash(Config) -> error_logger:logfile(close), - check_file(KernelLog, 70000, 150000), - check_file(SaslLog, 100000, 150000), + check_file(KernelLog, utf8, 70000, 150000), + check_file(SaslLog, Encoding, 70000, 150000), + %% ok = file:delete(KernelLog), + %% ok = file:delete(SaslLog), ok. -check_file(File, Min, Max) -> +check_file(File, Encoding, Min, Max) -> {ok,Bin} = file:read_file(File), Base = filename:basename(File), io:format("*** Contents of ~s ***\n", [Base]), - io:put_chars([Bin,"\n"]), + case Encoding of + latin1 -> io:format("~s\n", [Bin]); + _ -> io:format("~ts\n", [Bin]) + end, Sz = byte_size(Bin), io:format("Size: ~p (allowed range is ~p..~p)\n", [Sz,Min,Max]), @@ -110,7 +122,9 @@ crash_me() -> {ok,SuperPid} = supervisor:start_link(sasl_report_suite_supervisor, []), [{Id,Pid,_,_}] = supervisor:which_children(SuperPid), HugeData = gb_sets:from_list(lists:seq(1, 100000)), - gen_server:cast(Pid, HugeData), + SomeData1 = list_to_atom([246]), + SomeData2 = list_to_atom([1024]), + gen_server:cast(Pid, {HugeData,SomeData1,SomeData2}), Ref = monitor(process, Pid), receive {'DOWN',Ref,process,Pid,_} -> @@ -129,6 +143,12 @@ init(_) -> handle_cast(Big, St) -> Seq = lists:seq(1, 10000), + Latin1Atom = list_to_atom([246]), + UnicodeAtom = list_to_atom([1024]), + put(Latin1Atom, Latin1Atom), + put(UnicodeAtom, UnicodeAtom), + self() ! Latin1Atom, + self() ! UnicodeAtom, self() ! Seq, self() ! Seq, self() ! Seq, diff --git a/lib/stdlib/src/dets.erl b/lib/stdlib/src/dets.erl index 10e8c9c800..4e3fe0e5c1 100644 --- a/lib/stdlib/src/dets.erl +++ b/lib/stdlib/src/dets.erl @@ -1354,7 +1354,7 @@ open_file_loop2(Head, N) -> ?MODULE, [], Head); Message -> error_logger:format("** dets: unexpected message" - "(ignored): ~w~n", [Message]), + "(ignored): ~tw~n", [Message]), open_file_loop(Head, N) end. @@ -1403,7 +1403,7 @@ apply_op(Op, From, Head, N) -> Head; _Dirty when N =:= 0 -> % dirty or new_dirty %% The updates seems to have declined - dets_utils:vformat("** dets: Auto save of ~p\n", + dets_utils:vformat("** dets: Auto save of ~tp\n", [Head#head.name]), {NewHead, _Res} = perform_save(Head, true), erlang:garbage_collect(), @@ -1587,13 +1587,13 @@ bug_found(Name, Op, Bad, From) -> %% If stream_op/5 found more requests, this is not %% the last operation. error_logger:format - ("** dets: Bug was found when accessing table ~w,~n" - "** dets: operation was ~p and reply was ~w.~n" - "** dets: Stacktrace: ~w~n", + ("** dets: Bug was found when accessing table ~tw,~n" + "** dets: operation was ~tp and reply was ~tw.~n" + "** dets: Stacktrace: ~tw~n", [Name, Op, Bad, erlang:get_stacktrace()]); false -> error_logger:format - ("** dets: Bug was found when accessing table ~w~n", + ("** dets: Bug was found when accessing table ~tw~n", [Name]) end, if @@ -2117,7 +2117,7 @@ do_open_file([Fname, Verbose], Parent, Server, Ref) -> Error; Bad -> error_logger:format - ("** dets: Bug was found in open_file/1, reply was ~w.~n", + ("** dets: Bug was found in open_file/1, reply was ~tw.~n", [Bad]), {error, {dets_bug, Fname, Bad}} end; @@ -2135,7 +2135,7 @@ do_open_file([Tab, OpenArgs, Verb], Parent, Server, _Ref) -> Bad -> error_logger:format ("** dets: Bug was found in open_file/2, arguments were~n" - "** dets: ~w and reply was ~w.~n", + "** dets: ~tw and reply was ~tw.~n", [OpenArgs, Bad]), {error, {dets_bug, Tab, {open_file, OpenArgs}, Bad}} end. @@ -3123,7 +3123,7 @@ check_safe_fixtable(Head) -> ((get(verbose) =:= yes) orelse dets_utils:debug_mode()) of true -> error_logger:format - ("** dets: traversal of ~p needs safe_fixtable~n", + ("** dets: traversal of ~tp needs safe_fixtable~n", [Head#head.name]); false -> ok @@ -3189,7 +3189,7 @@ scan_read(H, From, _To, Min, _L, Ts, R, C) -> err(Error) -> case get(verbose) of yes -> - error_logger:format("** dets: failed with ~w~n", [Error]), + error_logger:format("** dets: failed with ~tw~n", [Error]), Error; undefined -> Error diff --git a/lib/stdlib/src/dets_utils.erl b/lib/stdlib/src/dets_utils.erl index da6ebd18f2..17f55ebdc2 100644 --- a/lib/stdlib/src/dets_utils.erl +++ b/lib/stdlib/src/dets_utils.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2001-2016. All Rights Reserved. +%% Copyright Ericsson AB 2001-2017. 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. @@ -387,7 +387,7 @@ corrupt_reason(Head, Reason0) -> corrupt(Head, Error) -> case get(verbose) of yes -> - error_logger:format("** dets: Corrupt table ~p: ~tp\n", + error_logger:format("** dets: Corrupt table ~tp: ~tp\n", [Head#head.name, Error]); _ -> ok end, diff --git a/lib/stdlib/src/edlin_expand.erl b/lib/stdlib/src/edlin_expand.erl index a1a97af4c5..bdcefda6e5 100644 --- a/lib/stdlib/src/edlin_expand.erl +++ b/lib/stdlib/src/edlin_expand.erl @@ -23,7 +23,7 @@ -export([expand/1, format_matches/1]). --import(lists, [reverse/1, nthtail/2, prefix/2]). +-import(lists, [reverse/1, prefix/2]). %% expand(CurrentBefore) -> %% {yes, Expansion, Matches} | {no, Matches} @@ -75,15 +75,15 @@ to_atom(Str) -> end. match(Prefix, Alts, Extra0) -> - Len = length(Prefix), + Len = string:length(Prefix), Matches = lists:sort( [{S, A} || {H, A} <- Alts, - prefix(Prefix, S=hd(io_lib:fwrite("~w",[H])))]), + prefix(Prefix, S=flat_write(H))]), case longest_common_head([N || {N, _} <- Matches]) of {partial, []} -> {no, [], Matches}; % format_matches(Matches)}; {partial, Str} -> - case nthtail(Len, Str) of + case string:slice(Str, Len) of [] -> {yes, [], Matches}; % format_matches(Matches)}; Remain -> @@ -94,18 +94,21 @@ match(Prefix, Alts, Extra0) -> {"(",[{Str,0}]} -> "()"; {_,_} -> Extra0 end, - {yes, nthtail(Len, Str) ++ Extra, []}; + {yes, string:slice(Str, Len) ++ Extra, []}; no -> {no, [], []} end. +flat_write(T) -> + lists:flatten(io_lib:fwrite("~tw",[T])). + %% Return the list of names L in multiple columns. format_matches(L) -> {S1, Dots} = format_col(lists:sort(L), []), S = case Dots of true -> {_, Prefix} = longest_common_head(vals(L)), - PrefixLen = length(Prefix), + PrefixLen = string:length(Prefix), case PrefixLen =< 3 of true -> S1; % Do not replace the prefix with "...". false -> @@ -128,7 +131,7 @@ format_col([A|T], Width, Len, Acc0, LL, Dots) -> {H0, R} = format_val(A), Hmax = LL - length(R), {H, NewDots} = - case length(H0) > Hmax of + case string:length(H0) > Hmax of true -> {io_lib:format("~-*ts", [Hmax - 3, H0]) ++ "...", true}; false -> {H0, Dots} end, @@ -149,12 +152,12 @@ format_val(H) -> field_width(L, LL) -> field_width(L, 0, LL). field_width([{H,_}|T], W, LL) -> - case length(H) of + case string:length(H) of L when L > W -> field_width(T, L, LL); _ -> field_width(T, W, LL) end; field_width([H|T], W, LL) -> - case length(H) of + case string:length(H) of L when L > W -> field_width(T, L, LL); _ -> field_width(T, W, LL) end; @@ -169,10 +172,11 @@ vals([S|L]) -> [S|vals(L)]. leading_dots([], _Len) -> []; leading_dots([{H, I}|L], Len) -> - [{"..." ++ nthtail(Len, H), I}|leading_dots(L, Len)]; + [{"..." ++ string:slice(H, Len), I}|leading_dots(L, Len)]; leading_dots([H|L], Len) -> - ["..." ++ nthtail(Len, H)|leading_dots(L, Len)]. + ["..." ++ string:slice(H, Len)|leading_dots(L, Len)]. +%% Strings are handled naively, but it should be OK here. longest_common_head([]) -> no; longest_common_head(LL) -> diff --git a/lib/stdlib/src/error_logger_file_h.erl b/lib/stdlib/src/error_logger_file_h.erl index b7c193f965..58da0cbdd6 100644 --- a/lib/stdlib/src/error_logger_file_h.erl +++ b/lib/stdlib/src/error_logger_file_h.erl @@ -126,7 +126,7 @@ format_body(State, [{Format,Args}|T]) -> S0 catch _:_ -> - format(State, "ERROR: ~p - ~p\n", [Format,Args]) + format(State, "ERROR: ~tp - ~tp\n", [Format,Args]) end, [S|format_body(State, T)]; format_body(_State, []) -> @@ -165,44 +165,26 @@ parse_event({warning_report, _GL, {Pid, std_warning, Args}}) -> parse_event(_) -> ignore. format_term(Term) when is_list(Term) -> - case string_p(Term) of + case string_p(lists:flatten(Term)) of true -> - [{"~s\n",[Term]}]; + [{"~ts\n",[Term]}]; false -> format_term_list(Term) end; format_term(Term) -> - [{"~p\n",[Term]}]. + [{"~tp\n",[Term]}]. format_term_list([{Tag,Data}|T]) -> - [{" ~p: ~p\n",[Tag,Data]}|format_term_list(T)]; + [{" ~tp: ~tp\n",[Tag,Data]}|format_term_list(T)]; format_term_list([Data|T]) -> - [{" ~p\n",[Data]}|format_term_list(T)]; + [{" ~tp\n",[Data]}|format_term_list(T)]; format_term_list([]) -> - []; -format_term_list(_) -> - %% Continue to allow non-proper lists for now. - %% FIXME: Remove this clause in OTP 19. []. string_p([]) -> false; -string_p(Term) -> - string_p1(Term). - -string_p1([H|T]) when is_integer(H), H >= $\s, H < 255 -> - string_p1(T); -string_p1([$\n|T]) -> string_p1(T); -string_p1([$\r|T]) -> string_p1(T); -string_p1([$\t|T]) -> string_p1(T); -string_p1([$\v|T]) -> string_p1(T); -string_p1([$\b|T]) -> string_p1(T); -string_p1([$\f|T]) -> string_p1(T); -string_p1([$\e|T]) -> string_p1(T); -string_p1([H|T]) when is_list(H) -> - string_p1(H) andalso string_p1(T); -string_p1([]) -> true; -string_p1(_) -> false. +string_p(FlatList) -> + io_lib:printable_list(FlatList). get_utc_config() -> %% SASL utc_log configuration overrides stdlib config @@ -225,7 +207,7 @@ header(Time, Title) -> end. header({{Y,Mo,D},{H,Mi,S}}, Title, UTC) -> - io_lib:format("~n=~s==== ~p-~s-~p::~s:~s:~s ~s===~n", + io_lib:format("~n=~ts==== ~p-~s-~p::~s:~s:~s ~s===~n", [Title,D,month(Mo),Y,t(H),t(Mi),t(S),UTC]). t(X) when is_integer(X) -> diff --git a/lib/stdlib/src/error_logger_tty_h.erl b/lib/stdlib/src/error_logger_tty_h.erl index 8f0d7b0362..fa940b7264 100644 --- a/lib/stdlib/src/error_logger_tty_h.erl +++ b/lib/stdlib/src/error_logger_tty_h.erl @@ -39,13 +39,16 @@ {user, prev_handler, io_mod=io, - depth=unlimited}). + depth=unlimited, + modifier=""}). %% This one is used when we takeover from the simple error_logger. init({[], {error_logger, Buf}}) -> User = set_group_leader(), Depth = error_logger:get_format_depth(), - State = #st{user=User,prev_handler=error_logger,depth=Depth}, + Modifier = modifier(), + State = #st{user=User,prev_handler=error_logger, + depth=Depth,modifier=Modifier}, write_events(State, Buf), {ok, State}; %% This one is used if someone took over from us, and now wants to @@ -57,7 +60,8 @@ init({[], {error_logger_tty_h, PrevHandler}}) -> init([]) -> User = set_group_leader(), Depth = error_logger:get_format_depth(), - {ok, #st{user=User,prev_handler=[],depth=Depth}}. + Modifier = modifier(), + {ok, #st{user=User,prev_handler=[],depth=Depth,modifier=Modifier}}. handle_event({_Type, GL, _Msg}, State) when node(GL) =/= node() -> {ok, State}; @@ -91,8 +95,9 @@ code_change(_OldVsn, State, _Extra) -> write_event(Event, IoMod) -> do_write_event(#st{io_mod=IoMod}, Event). -write_event(Event, IoMod, Depth) -> - do_write_event(#st{io_mod=IoMod,depth=Depth}, Event). +write_event(Event, IoMod, {Depth, Enc}) -> + Modifier = modifier(Enc), + do_write_event(#st{io_mod=IoMod,depth=Depth,modifier=Modifier}, Event). %%% ------------------------------------------------------ @@ -120,12 +125,12 @@ write_events(State, [Ev|Es]) -> write_events(_State, []) -> ok. -do_write_event(State, {Time, Event}) -> - case parse_event(Event) of +do_write_event(#st{modifier=M}=State, {Time, Event}) -> + case parse_event(Event,M) of ignore -> ok; {Title,Pid,FormatList} -> - Header = header(Time, Title), + Header = header(Time, Title, M), Body = format_body(State, FormatList), AtNode = if node(Pid) =/= node() -> @@ -144,13 +149,13 @@ do_write_event(State, {Time, Event}) -> do_write_event(_, _) -> ok. -format_body(State, [{Format,Args}|T]) -> +format_body(#st{modifier=M}=State, [{Format,Args}|T]) -> S = try format(State, Format, Args) of S0 -> S0 catch _:_ -> - format(State, "ERROR: ~p - ~p\n", [Format,Args]) + format(State, "ERROR: ~"++M++"p - ~"++M++"p\n", [Format,Args]) end, [S|format_body(State, T)]; format_body(_State, []) -> @@ -174,62 +179,41 @@ limit_format([H|T], Depth) -> limit_format([], _) -> []. -parse_event({error, _GL, {Pid, Format, Args}}) -> +parse_event({error, _GL, {Pid, Format, Args}},_) -> {"ERROR REPORT",Pid,[{Format,Args}]}; -parse_event({info_msg, _GL, {Pid, Format, Args}}) -> +parse_event({info_msg, _GL, {Pid, Format, Args}},_) -> {"INFO REPORT",Pid,[{Format, Args}]}; -parse_event({warning_msg, _GL, {Pid, Format, Args}}) -> +parse_event({warning_msg, _GL, {Pid, Format, Args}},_) -> {"WARNING REPORT",Pid,[{Format,Args}]}; -parse_event({error_report, _GL, {Pid, std_error, Args}}) -> - {"ERROR REPORT",Pid,format_term(Args)}; -parse_event({info_report, _GL, {Pid, std_info, Args}}) -> - {"INFO REPORT",Pid,format_term(Args)}; -parse_event({warning_report, _GL, {Pid, std_warning, Args}}) -> - {"WARNING REPORT",Pid,format_term(Args)}; -parse_event(_) -> ignore. - -format_term(Term) when is_list(Term) -> - case string_p(Term) of +parse_event({error_report, _GL, {Pid, std_error, Args}},M) -> + {"ERROR REPORT",Pid,format_term(Args,M)}; +parse_event({info_report, _GL, {Pid, std_info, Args}},M) -> + {"INFO REPORT",Pid,format_term(Args,M)}; +parse_event({warning_report, _GL, {Pid, std_warning, Args}},M) -> + {"WARNING REPORT",Pid,format_term(Args,M)}; +parse_event(_,_) -> ignore. + +format_term(Term,M) when is_list(Term) -> + case string_p(lists:flatten(Term)) of true -> - [{"~s\n",[Term]}]; + [{"~"++M++"s\n",[Term]}]; false -> - format_term_list(Term) + format_term_list(Term,M) end; -format_term(Term) -> - [{"~p\n",[Term]}]. - -format_term_list([{Tag,Data}|T]) -> - [{" ~p: ~p\n",[Tag,Data]}|format_term_list(T)]; -format_term_list([Data|T]) -> - [{" ~p\n",[Data]}|format_term_list(T)]; -format_term_list([]) -> - []; -format_term_list(_) -> - %% Continue to allow non-proper lists for now. - %% FIXME: Remove this clause in OTP 19. +format_term(Term,M) -> + [{"~"++M++"p\n",[Term]}]. + +format_term_list([{Tag,Data}|T],M) -> + [{" ~"++M++"p: ~"++M++"p\n",[Tag,Data]}|format_term_list(T,M)]; +format_term_list([Data|T],M) -> + [{" ~"++M++"p\n",[Data]}|format_term_list(T,M)]; +format_term_list([],_) -> []. string_p([]) -> false; -string_p(Term) -> - string_p1(Term). - -string_p1([H|T]) when is_integer(H), H >= $\s, H < 255 -> - string_p1(T); -string_p1([$\n|T]) -> string_p1(T); -string_p1([$\r|T]) -> string_p1(T); -string_p1([$\t|T]) -> string_p1(T); -string_p1([$\v|T]) -> string_p1(T); -string_p1([$\b|T]) -> string_p1(T); -string_p1([$\f|T]) -> string_p1(T); -string_p1([$\e|T]) -> string_p1(T); -string_p1([H|T]) when is_list(H) -> - case string_p1(H) of - true -> string_p1(T); - _ -> false - end; -string_p1([]) -> true; -string_p1(_) -> false. +string_p(FlatList) -> + io_lib:printable_list(FlatList). get_utc_config() -> %% SASL utc_log configuration overrides stdlib config @@ -243,16 +227,16 @@ get_utc_config() -> end end. -header(Time, Title) -> +header(Time, Title, M) -> case get_utc_config() of true -> - header(Time, Title, "UTC "); + header(Time, Title, "UTC ", M); _ -> - header(calendar:universal_time_to_local_time(Time), Title, "") + header(calendar:universal_time_to_local_time(Time), Title, "", M) end. -header({{Y,Mo,D},{H,Mi,S}}, Title, UTC) -> - io_lib:format("~n=~s==== ~p-~s-~p::~s:~s:~s ~s===~n", +header({{Y,Mo,D},{H,Mi,S}}, Title, UTC, M) -> + io_lib:format("~n=~"++M++"s==== ~p-~s-~p::~s:~s:~s ~s===~n", [Title,D,month(Mo),Y,t(H),t(Mi),t(S),UTC]). t(X) when is_integer(X) -> @@ -274,3 +258,13 @@ month(9) -> "Sep"; month(10) -> "Oct"; month(11) -> "Nov"; month(12) -> "Dec". + +modifier() -> + modifier(encoding()). +modifier(latin1) -> + ""; +modifier(_) -> + "t". + +encoding() -> + proplists:get_value(encoding,io:getopts(),latin1). diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl index 2093916a7c..2b9d8ff65b 100644 --- a/lib/stdlib/src/escript.erl +++ b/lib/stdlib/src/escript.erl @@ -860,7 +860,7 @@ code_handler(Name, Args, Dict, File) -> %% io:format("Calling:~p~n",[{Mod,Name,Args}]), apply(Mod, Name, Args); error -> - io:format("Script does not export ~w/~w\n", [Name,Arity]), + io:format("Script does not export ~tw/~w\n", [Name,Arity]), my_halt(127) end end. diff --git a/lib/stdlib/src/ets.erl b/lib/stdlib/src/ets.erl index 898b2f5bba..b5d3cd3c8d 100644 --- a/lib/stdlib/src/ets.erl +++ b/lib/stdlib/src/ets.erl @@ -1693,7 +1693,7 @@ choice(Height, Width, P, Mode, Tab, Key, Turn, Opos) -> end, choice(Height, Width, P, Mode, Tab, Key, Turn, Opos); [$/|Regexp] -> %% from regexp - case re:compile(nonl(Regexp)) of + case re:compile(nonl(Regexp),[unicode]) of {ok,Re} -> re_search(Height, Width, Tab, ets:first(Tab), Re, 1, 1); {error,{ErrorString,_Pos}} -> diff --git a/lib/stdlib/src/gen.erl b/lib/stdlib/src/gen.erl index 32f43fc706..33af0aed8f 100644 --- a/lib/stdlib/src/gen.erl +++ b/lib/stdlib/src/gen.erl @@ -422,7 +422,7 @@ debug_options(Name, Opts) -> try sys:debug_options(Options) catch _:_ -> error_logger:format( - "~p: ignoring erroneous debug options - ~p~n", + "~tp: ignoring erroneous debug options - ~tp~n", [Name,Options]), [] end; diff --git a/lib/stdlib/src/gen_event.erl b/lib/stdlib/src/gen_event.erl index da2b0da3ca..a9b98911e2 100644 --- a/lib/stdlib/src/gen_event.erl +++ b/lib/stdlib/src/gen_event.erl @@ -441,15 +441,15 @@ system_replace_state(StateFun, [ServerName, MSL, HibernateAfterTimeout, Hib]) -> print_event(Dev, {in, Msg}, Name) -> case Msg of {notify, Event} -> - io:format(Dev, "*DBG* ~p got event ~p~n", [Name, Event]); + io:format(Dev, "*DBG* ~tp got event ~tp~n", [Name, Event]); {_,_,{call, Handler, Query}} -> - io:format(Dev, "*DBG* ~p(~p) got call ~p~n", + io:format(Dev, "*DBG* ~tp(~tp) got call ~tp~n", [Name, Handler, Query]); _ -> - io:format(Dev, "*DBG* ~p got ~p~n", [Name, Msg]) + io:format(Dev, "*DBG* ~tp got ~tp~n", [Name, Msg]) end; print_event(Dev, Dbg, Name) -> - io:format(Dev, "*DBG* ~p : ~p~n", [Name, Dbg]). + io:format(Dev, "*DBG* ~tp : ~tp~n", [Name, Dbg]). %% server_add_handler(Handler, Args, MSL) -> {Ret, MSL'}. @@ -582,8 +582,8 @@ server_update(Handler1, Func, Event, SName) -> remove, SName, normal), no; {'EXIT', {undef, [{Mod1, handle_info, [_,_], _}|_]}} -> - error_logger:warning_msg("** Undefined handle_info in ~p~n" - "** Unhandled message: ~p~n", [Mod1, Event]), + error_logger:warning_msg("** Undefined handle_info in ~tp~n" + "** Unhandled message: ~tp~n", [Mod1, Event]), {ok, Handler1}; Other -> do_terminate(Mod1, Handler1, {error, Other}, State, @@ -767,10 +767,10 @@ report_error(Handler, Reason, State, LastIn, SName) -> State end, error_msg("** gen_event handler ~p crashed.~n" - "** Was installed in ~p~n" - "** Last event was: ~p~n" - "** When handler state == ~p~n" - "** Reason == ~p~n", + "** Was installed in ~tp~n" + "** Last event was: ~tp~n" + "** When handler state == ~tp~n" + "** Reason == ~tp~n", [handler(Handler),SName,LastIn,FmtState,Reason1]). handler(Handler) when not Handler#handler.id -> diff --git a/lib/stdlib/src/gen_fsm.erl b/lib/stdlib/src/gen_fsm.erl index 9ef0ca818c..96a53426e2 100644 --- a/lib/stdlib/src/gen_fsm.erl +++ b/lib/stdlib/src/gen_fsm.erl @@ -452,30 +452,30 @@ system_replace_state(StateFun, [Name, StateName, StateData, Mod, Time, Hibernate print_event(Dev, {in, Msg}, {Name, StateName}) -> case Msg of {'$gen_event', Event} -> - io:format(Dev, "*DBG* ~p got event ~p in state ~w~n", + io:format(Dev, "*DBG* ~tp got event ~tp in state ~tw~n", [Name, Event, StateName]); {'$gen_all_state_event', Event} -> io:format(Dev, - "*DBG* ~p got all_state_event ~p in state ~w~n", + "*DBG* ~tp got all_state_event ~tp in state ~tw~n", [Name, Event, StateName]); {timeout, Ref, {'$gen_timer', Message}} -> io:format(Dev, - "*DBG* ~p got timer ~p in state ~w~n", + "*DBG* ~tp got timer ~tp in state ~tw~n", [Name, {timeout, Ref, Message}, StateName]); {timeout, _Ref, {'$gen_event', Event}} -> io:format(Dev, - "*DBG* ~p got timer ~p in state ~w~n", + "*DBG* ~tp got timer ~tp in state ~tw~n", [Name, Event, StateName]); _ -> - io:format(Dev, "*DBG* ~p got ~p in state ~w~n", + io:format(Dev, "*DBG* ~tp got ~tp in state ~tw~n", [Name, Msg, StateName]) end; print_event(Dev, {out, Msg, To, StateName}, Name) -> - io:format(Dev, "*DBG* ~p sent ~p to ~w~n" - " and switched to state ~w~n", + io:format(Dev, "*DBG* ~tp sent ~tp to ~tw~n" + " and switched to state ~tw~n", [Name, Msg, To, StateName]); print_event(Dev, return, {Name, StateName}) -> - io:format(Dev, "*DBG* ~p switched to state ~w~n", + io:format(Dev, "*DBG* ~tp switched to state ~tw~n", [Name, StateName]). handle_msg(Msg, Parent, Name, StateName, StateData, Mod, _Time, HibernateAfterTimeout) -> %No debug here @@ -500,7 +500,7 @@ handle_msg(Msg, Parent, Name, StateName, StateData, Mod, _Time, HibernateAfterTi exit(R); {'EXIT', {undef, [{Mod, handle_info, [_,_,_], _}|_]}} -> error_logger:warning_msg("** Undefined handle_info in ~p~n" - "** Unhandled message: ~p~n", [Mod, Msg]), + "** Unhandled message: ~tp~n", [Mod, Msg]), loop(Parent, Name, StateName, StateData, Mod, infinity, HibernateAfterTimeout, []); {'EXIT', What} -> terminate(What, Name, Msg, Mod, StateName, StateData, []); @@ -620,29 +620,29 @@ error_info(Reason, Name, Msg, StateName, StateData, Debug) -> _ -> Reason end, - Str = "** State machine ~p terminating \n" ++ + Str = "** State machine ~tp terminating \n" ++ get_msg_str(Msg) ++ - "** When State == ~p~n" - "** Data == ~p~n" - "** Reason for termination = ~n** ~p~n", + "** When State == ~tp~n" + "** Data == ~tp~n" + "** Reason for termination = ~n** ~tp~n", format(Str, [Name, get_msg(Msg), StateName, StateData, Reason1]), sys:print_log(Debug), ok. get_msg_str({'$gen_event', _Event}) -> - "** Last event in was ~p~n"; + "** Last event in was ~tp~n"; get_msg_str({'$gen_sync_event', _Event}) -> - "** Last sync event in was ~p~n"; + "** Last sync event in was ~tp~n"; get_msg_str({'$gen_all_state_event', _Event}) -> - "** Last event in was ~p (for all states)~n"; + "** Last event in was ~tp (for all states)~n"; get_msg_str({'$gen_sync_all_state_event', _Event}) -> - "** Last sync event in was ~p (for all states)~n"; + "** Last sync event in was ~tp (for all states)~n"; get_msg_str({timeout, _Ref, {'$gen_timer', _Msg}}) -> - "** Last timer event in was ~p~n"; + "** Last timer event in was ~tp~n"; get_msg_str({timeout, _Ref, {'$gen_event', _Msg}}) -> - "** Last timer event in was ~p~n"; + "** Last timer event in was ~tp~n"; get_msg_str(_Msg) -> - "** Last message in was ~p~n". + "** Last message in was ~tp~n". get_msg({'$gen_event', Event}) -> Event; get_msg({'$gen_sync_event', Event}) -> Event; diff --git a/lib/stdlib/src/gen_server.erl b/lib/stdlib/src/gen_server.erl index 48ef1c987a..ac172325b5 100644 --- a/lib/stdlib/src/gen_server.erl +++ b/lib/stdlib/src/gen_server.erl @@ -638,7 +638,7 @@ try_dispatch(Mod, Func, Msg, State) -> case erlang:function_exported(Mod, handle_info, 2) of false -> error_logger:warning_msg("** Undefined handle_info in ~p~n" - "** Unhandled message: ~p~n", + "** Unhandled message: ~tp~n", [Mod, Msg]), {ok, {noreply, State}}; true -> @@ -802,21 +802,21 @@ system_replace_state(StateFun, [Name, State, Mod, Time, HibernateAfterTimeout]) print_event(Dev, {in, Msg}, Name) -> case Msg of {'$gen_call', {From, _Tag}, Call} -> - io:format(Dev, "*DBG* ~p got call ~p from ~w~n", + io:format(Dev, "*DBG* ~tp got call ~tp from ~w~n", [Name, Call, From]); {'$gen_cast', Cast} -> - io:format(Dev, "*DBG* ~p got cast ~p~n", + io:format(Dev, "*DBG* ~tp got cast ~tp~n", [Name, Cast]); _ -> - io:format(Dev, "*DBG* ~p got ~p~n", [Name, Msg]) + io:format(Dev, "*DBG* ~tp got ~tp~n", [Name, Msg]) end; print_event(Dev, {out, Msg, To, State}, Name) -> - io:format(Dev, "*DBG* ~p sent ~p to ~w, new state ~w~n", + io:format(Dev, "*DBG* ~tp sent ~tp to ~w, new state ~tp~n", [Name, Msg, To, State]); print_event(Dev, {noreply, State}, Name) -> - io:format(Dev, "*DBG* ~p new state ~w~n", [Name, State]); + io:format(Dev, "*DBG* ~tp new state ~tp~n", [Name, State]); print_event(Dev, Event, Name) -> - io:format(Dev, "*DBG* ~p dbg ~p~n", [Name, Event]). + io:format(Dev, "*DBG* ~tp dbg ~tp~n", [Name, Event]). %%% --------------------------------------------------- @@ -898,10 +898,10 @@ error_info(Reason, Name, From, Msg, State, Debug) -> end, {ClientFmt, ClientArgs} = client_stacktrace(From), LimitedState = error_logger:limit_term(State), - error_logger:format("** Generic server ~p terminating \n" - "** Last message in was ~p~n" - "** When Server state == ~p~n" - "** Reason for termination == ~n** ~p~n" ++ ClientFmt, + error_logger:format("** Generic server ~tp terminating \n" + "** Last message in was ~tp~n" + "** When Server state == ~tp~n" + "** Reason for termination == ~n** ~tp~n" ++ ClientFmt, [Name, Msg, LimitedState, Reason1] ++ ClientArgs), sys:print_log(Debug), ok. @@ -915,11 +915,11 @@ client_stacktrace(From) when is_pid(From), node(From) =:= node() -> {"** Client ~p is dead~n", [From]}; [{current_stacktrace, Stacktrace}, {registered_name, []}] -> {"** Client ~p stacktrace~n" - "** ~p~n", + "** ~tp~n", [From, Stacktrace]}; [{current_stacktrace, Stacktrace}, {registered_name, Name}] -> - {"** Client ~p stacktrace~n" - "** ~p~n", + {"** Client ~tp stacktrace~n" + "** ~tp~n", [Name, Stacktrace]} end; client_stacktrace(From) when is_pid(From) -> diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl index b5e9da1e66..1110d18af6 100644 --- a/lib/stdlib/src/gen_statem.erl +++ b/lib/stdlib/src/gen_statem.erl @@ -791,34 +791,34 @@ format_status( print_event(Dev, {in,Event}, {Name,State}) -> io:format( - Dev, "*DBG* ~p receive ~s in state ~p~n", + Dev, "*DBG* ~tp receive ~ts in state ~tp~n", [Name,event_string(Event),State]); print_event(Dev, {out,Reply,{To,_Tag}}, {Name,State}) -> io:format( - Dev, "*DBG* ~p send ~p to ~p from state ~p~n", + Dev, "*DBG* ~tp send ~tp to ~p from state ~tp~n", [Name,Reply,To,State]); print_event(Dev, {terminate,Reason}, {Name,State}) -> io:format( - Dev, "*DBG* ~p terminate ~p in state ~p~n", + Dev, "*DBG* ~tp terminate ~tp in state ~tp~n", [Name,Reason,State]); print_event(Dev, {Tag,Event,NextState}, {Name,State}) -> StateString = case NextState of State -> - io_lib:format("~p", [State]); + io_lib:format("~tp", [State]); _ -> - io_lib:format("~p => ~p", [State,NextState]) + io_lib:format("~tp => ~tp", [State,NextState]) end, io:format( - Dev, "*DBG* ~p ~w ~s in state ~s~n", + Dev, "*DBG* ~tp ~tw ~ts in state ~ts~n", [Name,Tag,event_string(Event),StateString]). event_string(Event) -> case Event of {{call,{Pid,_Tag}},Request} -> - io_lib:format("call ~p from ~w", [Request,Pid]); + io_lib:format("call ~tp from ~w", [Request,Pid]); {EventType,EventContent} -> - io_lib:format("~w ~p", [EventType,EventContent]) + io_lib:format("~tw ~tp", [EventType,EventContent]) end. sys_debug(Debug, #{name := Name}, State, Entry) -> @@ -1732,25 +1732,25 @@ error_info( CallbackMode end, error_logger:format( - "** State machine ~p terminating~n" ++ + "** State machine ~tp terminating~n" ++ case Q of [] -> ""; - _ -> "** Last event = ~p~n" + _ -> "** Last event = ~tp~n" end ++ - "** When server state = ~p~n" ++ - "** Reason for termination = ~w:~p~n" ++ + "** When server state = ~tp~n" ++ + "** Reason for termination = ~w:~tp~n" ++ "** Callback mode = ~p~n" ++ case Q of - [_,_|_] -> "** Queued = ~p~n"; + [_,_|_] -> "** Queued = ~tp~n"; _ -> "" end ++ case P of [] -> ""; - _ -> "** Postponed = ~p~n" + _ -> "** Postponed = ~tp~n" end ++ case FixedStacktrace of [] -> ""; - _ -> "** Stacktrace =~n** ~p~n" + _ -> "** Stacktrace =~n** ~tp~n" end, [Name | case Q of diff --git a/lib/stdlib/src/proc_lib.erl b/lib/stdlib/src/proc_lib.erl index d4d1bdccec..8e10cbe93b 100644 --- a/lib/stdlib/src/proc_lib.erl +++ b/lib/stdlib/src/proc_lib.erl @@ -823,22 +823,22 @@ to_string(A, _) -> io_lib:write_atom(A). pp_fun({Enc,Depth}) -> - {Letter,Tl} = case Depth of - unlimited -> {"p",[]}; - _ -> {"P",[Depth]} - end, - P = modifier(Enc) ++ Letter, + {P,Tl} = p(Enc, Depth), fun(Term, I) -> io_lib:format("~." ++ integer_to_list(I) ++ P, [Term|Tl]) end. -format_tag(Indent, Tag, Data, {_Enc,Depth}) -> - case Depth of - unlimited -> - io_lib:format("~s~p: ~80.18p~n", [Indent, Tag, Data]); - _ -> - io_lib:format("~s~p: ~80.18P~n", [Indent, Tag, Data, Depth]) - end. +format_tag(Indent, Tag, Data, {Enc,Depth}) -> + {P,Tl} = p(Enc, Depth), + io_lib:format("~s~p: ~80.18" ++ P ++ "\n", [Indent, Tag, Data|Tl]). + +p(Encoding, Depth) -> + {Letter, Tl} = case Depth of + unlimited -> {"p", []}; + _ -> {"P", [Depth]} + end, + P = modifier(Encoding) ++ Letter, + {P, Tl}. modifier(latin1) -> ""; modifier(_) -> "t". diff --git a/lib/stdlib/src/qlc.erl b/lib/stdlib/src/qlc.erl index 535ca57a6b..f11f9d0a0b 100644 --- a/lib/stdlib/src/qlc.erl +++ b/lib/stdlib/src/qlc.erl @@ -1132,7 +1132,7 @@ wait_for_request(Parent, MonRef, Post) -> wait_for_request(Parent, MonRef, Post); Other -> error_logger:error_msg( - "The qlc cursor ~w received an unexpected message:\n~p\n", + "The qlc cursor ~w received an unexpected message:\n~tp\n", [self(), Other]), wait_for_request(Parent, MonRef, Post) end. diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl index 26b3960f4f..212b143b1d 100644 --- a/lib/stdlib/src/shell.erl +++ b/lib/stdlib/src/shell.erl @@ -1459,7 +1459,7 @@ check_env(V) -> {ok, Val} -> Txt = io_lib:fwrite ("Invalid value of STDLIB configuration parameter" - "~w: ~tp\n", [V, Val]), + "~tw: ~tp\n", [V, Val]), error_logger:info_report(lists:flatten(Txt)) end. diff --git a/lib/stdlib/src/slave.erl b/lib/stdlib/src/slave.erl index 5b5c328c0c..d7cf6386f5 100644 --- a/lib/stdlib/src/slave.erl +++ b/lib/stdlib/src/slave.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2017. 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. @@ -77,7 +77,7 @@ start_pseudo(_,_,_) -> ok. %% It's already there Pid :: pid(). relay({badrpc,Reason}) -> - error_msg(" ** exiting relay server ~w :~w **~n", [self(),Reason]), + error_msg(" ** exiting relay server ~w :~tw **~n", [self(),Reason]), exit(Reason); relay(undefined) -> error_msg(" ** exiting relay server ~w **~n", [self()]), diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl index 1cd65fbf18..7920e55930 100644 --- a/lib/stdlib/src/supervisor.erl +++ b/lib/stdlib/src/supervisor.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2017. 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. @@ -628,7 +628,7 @@ handle_info({'EXIT', Pid, Reason}, State) -> end; handle_info(Msg, State) -> - error_logger:error_msg("Supervisor received unexpected message: ~p~n", + error_logger:error_msg("Supervisor received unexpected message: ~tp~n", [Msg]), {noreply, State}. diff --git a/lib/stdlib/test/Makefile b/lib/stdlib/test/Makefile index 72211332e9..7b79dcf04d 100644 --- a/lib/stdlib/test/Makefile +++ b/lib/stdlib/test/Makefile @@ -36,6 +36,7 @@ MODULES= \ ets_tough_SUITE \ expand_test \ expand_test1 \ + unicode_expand \ ExpandTestCaps \ ExpandTestCaps1 \ filelib_SUITE \ diff --git a/lib/stdlib/test/edlin_expand_SUITE.erl b/lib/stdlib/test/edlin_expand_SUITE.erl index 1f694ea549..5c2b1965ba 100644 --- a/lib/stdlib/test/edlin_expand_SUITE.erl +++ b/lib/stdlib/test/edlin_expand_SUITE.erl @@ -22,7 +22,7 @@ init_per_testcase/2, end_per_testcase/2, init_per_group/2,end_per_group/2]). -export([normal/1, quoted_fun/1, quoted_module/1, quoted_both/1, erl_1152/1, - erl_352/1]). + erl_352/1, unicode/1]). -include_lib("common_test/include/ct.hrl"). @@ -37,7 +37,8 @@ suite() -> {timetrap,{minutes,1}}]. all() -> - [normal, quoted_fun, quoted_module, quoted_both, erl_1152, erl_352]. + [normal, quoted_fun, quoted_module, quoted_both, erl_1152, erl_352, + unicode]. groups() -> []. @@ -150,6 +151,7 @@ quoted_both(Config) when is_list(Config) -> {yes,"weird-fun-name'()",[]} = do_expand("'ExpandTestCaps1':'#"), ok. +%% Note: pull request #1152. erl_1152(Config) when is_list(Config) -> "\n"++"foo"++" "++[1089]++_ = do_format(["foo",[1089]]), ok. @@ -226,6 +228,26 @@ check_trailing([I|Str], ArityStr, Suffix, Dots) -> Rest =:= Suffix end. +unicode(Config) when is_list(Config) -> + {module,unicode_expand} = c:l('unicode_expand'), + {no,[],[{"'кlирилли́ческий атом'",0}, + {"'кlирилли́ческий атом'",1}, + {"'кlирилли́ческий атомB'",1}, + {"module_info",0}, + {"module_info",1}]} = do_expand("unicode_expand:"), + {yes,"рилли́ческий атом", []} = do_expand("unicode_expand:'кlи"), + {yes,"еский атом", []} = do_expand("unicode_expand:'кlирилли́ч"), + {yes,"(",[]} = do_expand("unicode_expand:'кlирилли́ческий атомB'"), + "\n'кlирилли́ческий атом'/0 'кlирилли́ческий атом'/1 " + "'кlирилли́ческий атомB'/1 \nmodule_info/0 " + "module_info/1 \n" = + do_format([{"'кlирилли́ческий атом'",0}, + {"'кlирилли́ческий атом'",1}, + {"'кlирилли́ческий атомB'",1}, + {"module_info",0}, + {"module_info",1}]), + ok. + do_expand(String) -> edlin_expand:expand(lists:reverse(String)). diff --git a/lib/stdlib/test/error_logger_h_SUITE.erl b/lib/stdlib/test/error_logger_h_SUITE.erl index 30f96e0522..1f2a9fda0b 100644 --- a/lib/stdlib/test/error_logger_h_SUITE.erl +++ b/lib/stdlib/test/error_logger_h_SUITE.erl @@ -162,7 +162,7 @@ tty_log_open(Log) -> {ok,D} -> D; _ -> unlimited end, - error_logger:add_report_handler(?MODULE, {Fd,Depth}), + error_logger:add_report_handler(?MODULE, {Fd,Depth,latin1}), Fd. tty_log_close() -> @@ -393,11 +393,11 @@ dl_format_1([], [], _, Facc, Aacc) -> %%% calling error_logger_tty_h:write_event/2. %%% -init({_,_}=St) -> +init({_,_,_}=St) -> {ok,St}. -handle_event(Event, {Fd,Depth}=St) -> - case error_logger_tty_h:write_event(tag_event(Event), io_lib, Depth) of +handle_event(Event, {Fd,Depth,Enc}=St) -> + case error_logger_tty_h:write_event(tag_event(Event), io_lib, {Depth,Enc}) of ok -> ok; Str when is_list(Str) -> @@ -405,7 +405,7 @@ handle_event(Event, {Fd,Depth}=St) -> end, {ok,St}. -terminate(_Reason, {Fd,_}) -> +terminate(_Reason, {Fd,_,_}) -> ok = file:close(Fd), []. diff --git a/lib/stdlib/test/proc_lib_SUITE.erl b/lib/stdlib/test/proc_lib_SUITE.erl index c4fafe82a4..7686889360 100644 --- a/lib/stdlib/test/proc_lib_SUITE.erl +++ b/lib/stdlib/test/proc_lib_SUITE.erl @@ -552,14 +552,17 @@ t_format(_Config) -> t_format() -> error_logger:add_report_handler(?MODULE, self()), - Pid = proc_lib:spawn(fun t_format_looper/0), + Pid = proc_lib:spawn(fun '\x{aaa}t_format_looper'/0), HugeData = gb_sets:from_list(lists:seq(1, 100)), - Pid ! {die,HugeData}, + SomeData1 = list_to_atom([246]), + SomeData2 = list_to_atom([1024]), + Pid ! {SomeData1,SomeData2}, + Pid ! {die,{HugeData,SomeData1,SomeData2}}, Report = receive {crash_report, Pid, Report0} -> Report0 end, - Usz = do_test_format(Report, unlimited), - Tsz = do_test_format(Report, 20), + Usz = do_test_format(Report, latin1, unlimited), + Tsz = do_test_format(Report, latin1, 20), if Tsz >= Usz -> @@ -568,6 +571,16 @@ t_format() -> ok end, + UszU = do_test_format(Report, unicode, unlimited), + TszU = do_test_format(Report, unicode, 20), + + if + TszU >= UszU -> + ct:fail(failed); + true -> + ok + end, + ok. t_format_arbitrary(_Config) -> @@ -597,15 +610,19 @@ do_test_format(Report, Encoding, Depth) -> io:format("*** Depth = ~p, Encoding = ~p", [Depth, Encoding]), S0 = proc_lib:format(Report, Encoding, Depth), S = lists:flatten(S0), - io:put_chars(S), + case Encoding of + latin1 -> io:format("~s\n", [S]); + _ -> io:format("~ts\n", [S]) + end, length(S). -t_format_looper() -> +'\x{aaa}t_format_looper'() -> receive {die,Data} -> exit(Data); - _ -> - t_format_looper() + M -> + put(M, M), + '\x{aaa}t_format_looper'() end. %%----------------------------------------------------------------- diff --git a/lib/stdlib/test/unicode_expand.erl b/lib/stdlib/test/unicode_expand.erl new file mode 100644 index 0000000000..41f741fa84 --- /dev/null +++ b/lib/stdlib/test/unicode_expand.erl @@ -0,0 +1,36 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2017. 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(unicode_expand). + +-export(['кlирилли́ческий атом'/0, 'кlирилли́ческий атом'/1, + 'кlирилли́ческий атомB'/1]). + +-export_type(['кlирилли́ческий атом'/0]). + +-type 'кlирилли́ческий атом'() :: integer(). + +'кlирилли́ческий атом'() -> + 'кlирилли́ческий атом'('кlирилли́ческий атом'). + +'кlирилли́ческий атом'(_Atom) -> + ok. + +'кlирилли́ческий атомB'(_B) -> + true. diff --git a/lib/syntax_tools/src/epp_dodger.erl b/lib/syntax_tools/src/epp_dodger.erl index cf1ba0abfa..0a12e8fd8b 100644 --- a/lib/syntax_tools/src/epp_dodger.erl +++ b/lib/syntax_tools/src/epp_dodger.erl @@ -866,10 +866,10 @@ tokens_to_string([]) -> format_error(macro_args) -> errormsg("macro call missing end parenthesis"); format_error({unknown, Reason}) -> - errormsg(io_lib:format("unknown error: ~P", [Reason, 15])). + errormsg(io_lib:format("unknown error: ~tP", [Reason, 15])). errormsg(String) -> - io_lib:format("~s: ~s", [?MODULE, String]). + io_lib:format("~s: ~ts", [?MODULE, String]). %% ===================================================================== diff --git a/lib/syntax_tools/src/erl_comment_scan.erl b/lib/syntax_tools/src/erl_comment_scan.erl index a7a2c10b79..07e501e553 100644 --- a/lib/syntax_tools/src/erl_comment_scan.erl +++ b/lib/syntax_tools/src/erl_comment_scan.erl @@ -309,7 +309,7 @@ filename([C|T]) when is_integer(C), C > 0 -> filename([]) -> []; filename(N) -> - report_error("bad filename: `~P'.", [N, 25]), + report_error("bad filename: `~tP'.", [N, 25]), exit(error). error_read_file(Name) -> diff --git a/lib/syntax_tools/src/erl_tidy.erl b/lib/syntax_tools/src/erl_tidy.erl index 888cb71f51..5623aa6af3 100644 --- a/lib/syntax_tools/src/erl_tidy.erl +++ b/lib/syntax_tools/src/erl_tidy.erl @@ -193,7 +193,7 @@ dir_3(Name, Dir, Regexp, Env) -> dir_1(Dir1, Regexp, Env). dir_4(File, Regexp, Env) -> - case re:run(File, Regexp) of + case re:run(File, Regexp, [unicode]) of {match, _} -> Opts = [{outfile, File}, {dir, ""} | Env#dir.options], case catch file(File, Opts) of @@ -805,7 +805,7 @@ keep_form(Form, Used, Opts) -> {F, A} = N, File = proplists:get_value(file, Opts, ""), report({File, erl_syntax:get_pos(Form), - "removing unused function `~w/~w'."}, + "removing unused function `~tw/~w'."}, [F, A], Opts), false; true -> @@ -870,8 +870,8 @@ update_attribute(F, Imports, Opts) -> Names -> File = proplists:get_value(file, Opts, ""), report({File, erl_syntax:get_pos(F), - "removing unused imports:~s"}, - [[io_lib:fwrite("\n\t`~w:~w/~w'", [M, N, A]) + "removing unused imports:~ts"}, + [[io_lib:fwrite("\n\t`~w:~tw/~w'", [M, N, A]) || {N, A} <- Names]], Opts) end, Is = [make_fname(N) || N <- Ns1], @@ -1166,7 +1166,7 @@ visit_import_application({N, A} = Name, F, As, Tree, Env, St0) -> case Expand of true -> report({Env#env.file, erl_syntax:get_pos(F), - "expanding call to imported function `~w:~w/~w'."}, + "expanding call to imported function `~w:~tw/~w'."}, [M, N, A], Env#env.verbosity), F1 = erl_syntax:module_qualifier(erl_syntax:atom(M), erl_syntax:atom(N)), @@ -1220,7 +1220,7 @@ visit_spawn_call({N, A}, F, Ps, [A1, A2, A3] = As, Tree, case erl_syntax:is_proper_list(A3) of true -> report({Env#env.file, erl_syntax:get_pos(F), - "changing use of `~w/~w' to `~w/~w' with a fun."}, + "changing use of `~tw/~w' to `~tw/~w' with a fun."}, [N, A, N, 1 + length(Ps)], Env#env.verbosity), F1 = case erl_syntax:is_atom(A1, Env#env.module) of true -> @@ -1404,8 +1404,8 @@ visit_remote_application({M, N, A} = Name, F, As, Tree, Env, St) -> case rename_remote_call(Name, St) of {M1, N1} -> report({Env#env.file, erl_syntax:get_pos(F), - "updating obsolete call to `~w:~w/~w' " - "to use `~w:~w/~w' instead."}, + "updating obsolete call to `~w:~tw/~w' " + "to use `~w:~tw/~w' instead."}, [M, N, A, M1, N1, A], Env#env.verbosity), M2 = erl_syntax:atom(M1), N2 = erl_syntax:atom(N1), @@ -1820,7 +1820,7 @@ filename([]) -> filename(N) when is_atom(N) -> atom_to_list(N); filename(N) -> - report_error("bad filename: `~P'.", [N, 25]), + report_error("bad filename: `~tP'.", [N, 25]), exit(error). get_env(Tree) -> @@ -1911,11 +1911,11 @@ format({warning, D}, Vs) -> format({recommend, D}, Vs) -> ["recommendation: ", format(D, Vs)]; format({"", L, D}, Vs) when is_integer(L), L > 0 -> - [io_lib:fwrite("~w: ", [L]), format(D, Vs)]; + [io_lib:fwrite("~tw: ", [L]), format(D, Vs)]; format({"", _L, D}, Vs) -> format(D, Vs); format({F, L, D}, Vs) when is_integer(L), L > 0 -> - [io_lib:fwrite("~ts:~w: ", [filename(F), L]), format(D, Vs)]; + [io_lib:fwrite("~ts:~tw: ", [filename(F), L]), format(D, Vs)]; format({F, _L, D}, Vs) -> [io_lib:fwrite("~ts: ", [filename(F)]), format(D, Vs)]; format(S, Vs) when is_list(S) -> diff --git a/lib/syntax_tools/src/igor.erl b/lib/syntax_tools/src/igor.erl index b92cd8d607..16e3511734 100644 --- a/lib/syntax_tools/src/igor.erl +++ b/lib/syntax_tools/src/igor.erl @@ -834,7 +834,7 @@ merge_sources_1(Name, Modules, Trees, Opts) -> dict:from_list(Rs); false -> report_error("bad value for `redirect' option: " - "~P.", + "~tP.", [Rs, 10]), exit(error) end, @@ -1069,7 +1069,7 @@ filter_forms_2(Forms, Env) -> comment -> kill; _ -> report_error("invalid value for option " - "`file_attributes': ~w.", + "`file_attributes': ~tw.", [FileAttrsOpt]), exit(error) end, @@ -1180,7 +1180,7 @@ merge_namespaces(Modules, Env) -> [] -> ok; Fs -> - report_warning("interface functions renamed:\n\t~p.", [Fs]) + report_warning("interface functions renamed:\n\t~tp.", [Fs]) end, {M4, Acc2} = merge_namespaces_1(M2, Acc1), Ms = M3 ++ M4, @@ -1778,7 +1778,7 @@ transform_function(T, Env, St) -> {maybe_modified(V, T1, 2, Text, Env), St1}. renaming_note(Name) -> - [lists:flatten(io_lib:fwrite("renamed function to `~w'", + [lists:flatten(io_lib:fwrite("renamed function to `~tw'", [Name]))]. rename_atom(Node, Atom) -> @@ -2488,7 +2488,7 @@ rename(Files, Renamings, Opts) -> true -> dict:from_list(Renamings); false -> - report_error("bad module renaming: ~P.", + report_error("bad module renaming: ~tP.", [Renamings, 10]), exit(error) end, @@ -2672,7 +2672,7 @@ error_text(D, Name) -> end. error_text_1(D, Name) -> - io_lib:fwrite("error: `~w', ~P.", [Name, D, 15]). + io_lib:fwrite("error: `~w', ~tP.", [Name, D, 15]). check_records(Rs, Name) -> case duplicates([N || {N, _} <- Rs]) of @@ -2680,7 +2680,7 @@ check_records(Rs, Name) -> ok; Ns -> report_error("in module `~w': " - "multiply defined records: ~p.", + "multiply defined records: ~tp.", [Name, Ns]), exit(error) end. @@ -2694,7 +2694,7 @@ expand_imports(Is, Name) -> ordsets:from_list(As); Ns -> report_error("in module `~w': " - "multiply imported functions: ~p.", + "multiply imported functions: ~tp.", [Name, Ns]), exit(error) end. @@ -2968,7 +2968,7 @@ filename([]) -> filename(N) when is_atom(N) -> atom_to_list(N); filename(N) -> - report_error("bad filename: `~P'.", [N, 25]), + report_error("bad filename: `~tP'.", [N, 25]), exit(error). duplicates(Xs) -> @@ -3031,7 +3031,7 @@ split_lines_1(Cs, Cs1, Ls) -> %% Reporting warning_unsafe_call(Name, Module, Target) -> - report_warning("call to `~w' in module `~w' " + report_warning("call to `~tw' in module `~w' " "possibly unsafe in `~s'.", [Name, Module, Target]). warning_apply_2(Module, Target) -> diff --git a/lib/syntax_tools/src/merl.erl b/lib/syntax_tools/src/merl.erl index d6cf208998..b503944442 100644 --- a/lib/syntax_tools/src/merl.erl +++ b/lib/syntax_tools/src/merl.erl @@ -565,13 +565,13 @@ parse_5(Ts, Es) -> -dialyzer({nowarn_function, parse_error/1}). % no local return parse_error({L, M, R}) when is_atom(M), is_integer(L) -> - fail("~w: ~s", [L, M:format_error(R)]); + fail("~w: ~ts", [L, M:format_error(R)]); parse_error({{L,C}, M, R}) when is_atom(M), is_integer(L), is_integer(C) -> - fail("~w:~w: ~s", [L,C,M:format_error(R)]); + fail("~w:~w: ~ts", [L,C,M:format_error(R)]); parse_error({_, M, R}) when is_atom(M) -> fail(M:format_error(R)); parse_error(R) -> - fail("unknown parse error: ~p", [R]). + fail("unknown parse error: ~tp", [R]). %% ------------------------------------------------------------------------ %% Templates, substitution and matching diff --git a/lib/tools/src/eprof.erl b/lib/tools/src/eprof.erl index 3ae899a078..535ddbcd04 100644 --- a/lib/tools/src/eprof.erl +++ b/lib/tools/src/eprof.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2016. All Rights Reserved. +%% Copyright Ericsson AB 1996-2017. 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. @@ -246,7 +246,7 @@ handle_call(profile_stop, _From, #state{ profiling = true } = S) -> %% logfile handle_call({logfile, File}, _From, #state{ fd = OldFd } = S) -> - case file:open(File, [write]) of + case file:open(File, [write, {encoding, utf8}]) of {ok, Fd} -> case OldFd of undefined -> ok; @@ -478,11 +478,11 @@ string_bp_mfa([{Mfa, {Count, Time}}|Mfas], Tus, {MfaW, CountW, PercW, TimeW, TpC Stpc = s("~.2f", [divide(Time,Count)]), string_bp_mfa(Mfas, Tus, { - erlang:max(MfaW, length(Smfa)), - erlang:max(CountW,length(Scount)), - erlang:max(PercW, length(Sperc)), - erlang:max(TimeW, length(Stime)), - erlang:max(TpCW, length(Stpc)) + erlang:max(MfaW, string:length(Smfa)), + erlang:max(CountW,string:length(Scount)), + erlang:max(PercW, string:length(Sperc)), + erlang:max(TimeW, string:length(Stime)), + erlang:max(TpCW, string:length(Stpc)) }, [[Smfa, Scount, Sperc, Stime, Stpc] | Strings]). print_bp_mfa(Mfas, {Tn, Tus}, Fd, Opts) -> @@ -491,11 +491,11 @@ print_bp_mfa(Mfas, {Tn, Tus}, Fd, Opts) -> TnStr = s(Tn), TusStr = s(Tus), TuspcStr = s("~.2f", [divide(Tus,Tn)]), - Ws = {erlang:max(length("FUNCTION"), MfaW), - lists:max([length("CALLS"), CountW, length(TnStr)]), - erlang:max(length(" %"), PercW), - lists:max([length("TIME"), TimeW, length(TusStr)]), - lists:max([length("uS / CALLS"), TpCW, length(TuspcStr)])}, + Ws = {erlang:max(string:length("FUNCTION"), MfaW), + lists:max([string:length("CALLS"), CountW, string:length(TnStr)]), + erlang:max(string:length(" %"), PercW), + lists:max([string:length("TIME"), TimeW, string:length(TusStr)]), + lists:max([string:length("uS / CALLS"), TpCW, string:length(TuspcStr)])}, format(Fd, Ws, ["FUNCTION", "CALLS", " %", "TIME", "uS / CALLS"]), format(Fd, Ws, ["--------", "-----", "-------", "----", "----------"]), lists:foreach(fun (String) -> format(Fd, Ws, String) end, Strs), @@ -503,13 +503,13 @@ print_bp_mfa(Mfas, {Tn, Tus}, Fd, Opts) -> format(Fd, Ws, ["Total:", TnStr, "100.00%", TusStr, TuspcStr]), ok. -s({M,F,A}) -> s("~w:~w/~w",[M,F,A]); -s(Term) -> s("~p", [Term]). +s({M,F,A}) -> s("~w:~tw/~w",[M,F,A]); +s(Term) -> s("~tp", [Term]). s(Format, Terms) -> lists:flatten(io_lib:format(Format, Terms)). format(Fd, {MfaW, CountW, PercW, TimeW, TpCW}, Strings) -> - format(Fd, s("~~.~ps ~~~ps ~~~ps ~~~ps [~~~ps]~~n", [MfaW, CountW, PercW, TimeW, TpCW]), Strings); + format(Fd, s("~~.~wts ~~~ws ~~~ws ~~~ws [~~~ws]~~n", [MfaW, CountW, PercW, TimeW, TpCW]), Strings); format(undefined, Format, Strings) -> io:format(Format, Strings), ok; diff --git a/lib/tools/src/fprof.erl b/lib/tools/src/fprof.erl index 436f68d12b..2fe42beb03 100644 --- a/lib/tools/src/fprof.erl +++ b/lib/tools/src/fprof.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2001-2016. All Rights Reserved. +%% Copyright Ericsson AB 2001-2017. 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. @@ -1475,7 +1475,7 @@ info_suspect_call(GroupLeader, GroupLeader, _, _) -> ok; info_suspect_call(GroupLeader, _, Func, Pid) -> io:format(GroupLeader, - "~nWarning: ~p called in ~p - trace may become corrupt!~n", + "~nWarning: ~tp called in ~p - trace may become corrupt!~n", parsify([Func, Pid])). info(GroupLeader, GroupLeader, _, _) -> @@ -1498,13 +1498,13 @@ dump_stack(Dump, Stack, Term) -> {N, length(hd(Stack))} end end, - io:format(Dump, "~s~p.~n", [lists:duplicate(Depth, " "), parsify(Term)]), + io:format(Dump, "~s~tp.~n", [lists:duplicate(Depth, " "), parsify(Term)]), true. dump(undefined, _) -> false; dump(Dump, Term) -> - io:format(Dump, "~p.~n", [parsify(Term)]), + io:format(Dump, "~tp.~n", [parsify(Term)]), true. @@ -2603,17 +2603,17 @@ println({Io, [W1, W2, W3, W4]}, Head, println({Io, _}, Head, [], Tail, Comment) -> - io:format(Io, "~s~s~s~n", + io:format(Io, "~s~ts~ts~n", [pad(Head, $ , 3), Tail, Comment]); println({Io, _}, Head, {Tag, Term}, Tail, Comment) -> - io:format(Io, "~s~p, ~p~s~s~n", + io:format(Io, "~s~tp, ~tp~ts~ts~n", [pad(Head, $ , 3), parsify(Tag), parsify(Term), Tail, Comment]); println({Io, _}, Head, Term, Tail, Comment) -> - io:format(Io, "~s~p~s~s~n", + io:format(Io, "~s~tp~ts~ts~n", [pad(Head, $ , 3), parsify(Term), Tail, Comment]). @@ -2720,7 +2720,7 @@ postsort_r([[_|C] | L], R) -> flat_format(F, Trailer) when is_float(F) -> lists:flatten([io_lib:format("~.3f", [F]), Trailer]); flat_format(W, Trailer) -> - lists:flatten([io_lib:format("~p", [W]), Trailer]). + lists:flatten([io_lib:format("~tp", [W]), Trailer]). %% Format, flatten, and pad. flat_format(Term, Trailer, Width) -> diff --git a/lib/tools/src/xref_base.erl b/lib/tools/src/xref_base.erl index 8d2cc07e40..3199b28acb 100644 --- a/lib/tools/src/xref_base.erl +++ b/lib/tools/src/xref_base.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2017. 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. @@ -405,21 +405,21 @@ analysis(exports_not_used, _) -> %% Local calls are not considered here. "X * UU" would do otherwise. "X - XU"; analysis({call, F}, functions) -> - make_query("range (E | ~w : Fun)", [F]); + make_query("range (E | ~tw : Fun)", [F]); analysis({use, F}, functions) -> - make_query("domain (E || ~w : Fun)", [F]); + make_query("domain (E || ~tw : Fun)", [F]); analysis({module_call, M}, _) -> - make_query("range (ME | ~w : Mod)", [M]); + make_query("range (ME | ~tw : Mod)", [M]); analysis({module_use, M}, _) -> - make_query("domain (ME || ~w : Mod)", [M]); + make_query("domain (ME || ~tw : Mod)", [M]); analysis({application_call, A}, _) -> - make_query("range (AE | ~w : App)", [A]); + make_query("range (AE | ~tw : App)", [A]); analysis({application_use, A}, _) -> - make_query("domain (AE || ~w : App)", [A]); + make_query("domain (AE || ~tw : App)", [A]); analysis({release_call, R}, _) -> - make_query("range (RE | ~w : Rel)", [R]); + make_query("range (RE | ~tw : Rel)", [R]); analysis({release_use, R}, _) -> - make_query("domain (RE || ~w : Rel)", [R]); + make_query("domain (RE || ~tw : Rel)", [R]); analysis(deprecated_function_calls, functions) -> "XC || DF"; analysis({deprecated_function_calls,Flag}, functions) -> @@ -1833,9 +1833,9 @@ message(true, What, Arg) -> unreadable -> io:format("Skipping ~ts (unreadable)~n", [Arg]); xref_attr -> - io:format("~ts: Skipping 'xref' attribute ~w~n", Arg); + io:format("~ts: Skipping 'xref' attribute ~tw~n", Arg); depr_attr -> - io:format("~ts: Skipping 'deprecated' attribute ~w~n", Arg); + io:format("~ts: Skipping 'deprecated' attribute ~tw~n", Arg); lib_search -> io:format("Scanning library path for BEAM files... ", []); lib_check -> diff --git a/lib/tools/src/xref_parser.yrl b/lib/tools/src/xref_parser.yrl index 0711da79e2..5ee6419ff5 100644 --- a/lib/tools/src/xref_parser.yrl +++ b/lib/tools/src/xref_parser.yrl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2017. 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. @@ -170,7 +170,7 @@ is_prefix_op('#') -> numeric; is_prefix_op(_) -> false. check_regexp(String) -> - case re:compile(String) of + case re:compile(String, [unicode]) of {ok, _Expr} -> {regexpr, String}; {error, {ErrString, Position}} -> @@ -274,7 +274,7 @@ mfa2s({M,F,A}) -> [c2s(M),':',c2s(F),'/',A]. c2s(C) -> - [S] = io_lib:format("~p", [C]), + [S] = io_lib:format("~tp", [C]), list_to_atom(S). re(variable) -> ['_']; diff --git a/lib/tools/src/xref_utils.erl b/lib/tools/src/xref_utils.erl index b0c168e018..02e207d40c 100644 --- a/lib/tools/src/xref_utils.erl +++ b/lib/tools/src/xref_utils.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2016. All Rights Reserved. +%% Copyright Ericsson AB 2000-2017. 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. @@ -638,14 +638,14 @@ neighbours([], G, Fun, VT, L, _V, Vs) -> neighbours(Vs, G, Fun, VT, L). match_list(L, RExpr) -> - {ok, Expr} = re:compile(RExpr), + {ok, Expr} = re:compile(RExpr, [unicode]), filter(fun(E) -> match(E, Expr) end, L). match_one(VarL, Con, Col) -> select_each(VarL, fun(E) -> Con =:= element(Col, E) end). match_many(VarL, RExpr, Col) -> - {ok, Expr} = re:compile(RExpr), + {ok, Expr} = re:compile(RExpr, [unicode]), select_each(VarL, fun(E) -> match(element(Col, E), Expr) end). match(I, Expr) when is_integer(I) -> @@ -653,7 +653,12 @@ match(I, Expr) when is_integer(I) -> {match, [{0,length(S)}]} =:= re:run(S, Expr, [{capture, first}]); match(A, Expr) when is_atom(A) -> S = atom_to_list(A), - {match, [{0,length(S)}]} =:= re:run(S, Expr, [{capture, first}]). + case re:run(S, Expr, [{capture, first}]) of + {match, [{0,Size}]} -> + Size =:= byte_size(unicode:characters_to_binary(S)); + _ -> + false + end. select_each([{Mod,Funs} | L], Pred) -> case filter(Pred, Funs) of diff --git a/lib/tools/test/xref_SUITE.erl b/lib/tools/test/xref_SUITE.erl index 057449d4a2..379a5c09ab 100644 --- a/lib/tools/test/xref_SUITE.erl +++ b/lib/tools/test/xref_SUITE.erl @@ -50,7 +50,8 @@ -export([analyze/1, basic/1, md/1, q/1, variables/1, unused_locals/1]). --export([format_error/1, otp_7423/1, otp_7831/1, otp_10192/1, otp_13708/1]). +-export([format_error/1, otp_7423/1, otp_7831/1, otp_10192/1, otp_13708/1, + otp_14464/1]). -import(lists, [append/2, flatten/1, keysearch/3, member/2, sort/1, usort/1]). @@ -81,8 +82,10 @@ groups() -> update, deprecated, trycatch, fun_mfa, fun_mfa_r14, fun_mfa_vars, qlc]}, {analyses, [], + [analyze, basic, md, q, variables, unused_locals]}, - {misc, [], [format_error, otp_7423, otp_7831, otp_10192, otp_13708]}]. + {misc, [], [format_error, otp_7423, otp_7831, otp_10192, otp_13708, + otp_14464]}]. init_per_suite(Conf) when is_list(Conf) -> @@ -2396,7 +2399,6 @@ otp_10192(Conf) when is_list(Conf) -> xref:stop(s), ok. -%% OTP-10192. Allow filenames with character codes greater than 126. otp_13708(Conf) when is_list(Conf) -> {ok, _} = start(s), ok = xref:set_default(s, [{verbose, true}]), @@ -2409,6 +2411,36 @@ otp_13708(Conf) when is_list(Conf) -> ok = xref:set_library_path(s, [Dir], [{verbose, true}]), xref:stop(s). +%% OTP-14464. Unicode atoms. +otp_14464(Conf) when is_list(Conf) -> + Dir = ?copydir, + + File1 = fname(Dir, "a.erl"), + MFile1 = fname(Dir, "a"), + Beam1 = fname(Dir, "a.beam"), + Test1 = "-module(a). + -export([ärlig/0, 'кlирилли́ческий атомB'/0]). + + ärlig() -> + 'кlирилли́ческий атомB'. + + 'кlирилли́ческий атомB'() -> + foo. + ", + ok = file:write_file(File1, unicode:characters_to_binary(Test1)), + {ok, a} = compile:file(File1, [debug_info,{outdir,Dir}]), + + {ok, _} = xref:start(s), + {ok, a} = xref:add_module(s, MFile1), + + {ok, [{a,ärlig,0}]} = xref:q(s, 'a:"ärlig"/0'), + {ok, [{a,'кlирилли́ческий атомB',0}]} = + xref:q(s, 'a:"кlирилли́ческий атомB"/0'), + + xref:stop(s), + ok = file:delete(File1), + ok = file:delete(Beam1). + %%% %%% Utilities %%% diff --git a/lib/wx/src/wx_object.erl b/lib/wx/src/wx_object.erl index 42973335b4..cc19ff9770 100644 --- a/lib/wx/src/wx_object.erl +++ b/lib/wx/src/wx_object.erl @@ -561,21 +561,21 @@ system_code_change([Name, State, Mod, Time], _Module, OldVsn, Extra) -> print_event(Dev, {in, Msg}, Name) -> case Msg of {'$gen_call', {From, _Tag}, Call} -> - io:format(Dev, "*DBG* ~p got call ~p from ~w~n", + io:format(Dev, "*DBG* ~tp got call ~tp from ~w~n", [Name, Call, From]); {'$gen_cast', Cast} -> - io:format(Dev, "*DBG* ~p got cast ~p~n", + io:format(Dev, "*DBG* ~tp got cast ~tp~n", [Name, Cast]); _ -> - io:format(Dev, "*DBG* ~p got ~p~n", [Name, Msg]) + io:format(Dev, "*DBG* ~tp got ~tp~n", [Name, Msg]) end; print_event(Dev, {out, Msg, To, State}, Name) -> - io:format(Dev, "*DBG* ~p sent ~p to ~w, new state ~w~n", + io:format(Dev, "*DBG* ~tp sent ~tp to ~w, new state ~tp~n", [Name, Msg, To, State]); print_event(Dev, {noreply, State}, Name) -> - io:format(Dev, "*DBG* ~p new state ~w~n", [Name, State]); + io:format(Dev, "*DBG* ~tp new state ~tp~n", [Name, State]); print_event(Dev, Event, Name) -> - io:format(Dev, "*DBG* ~p dbg ~p~n", [Name, Event]). + io:format(Dev, "*DBG* ~tp dbg ~tp~n", [Name, Event]). %%% --------------------------------------------------- %%% Terminate the server. @@ -629,10 +629,10 @@ error_info(Reason, Name, Msg, State, Debug) -> _ -> Reason end, - format("** wx object server ~p terminating \n" - "** Last message in was ~p~n" - "** When Server state == ~p~n" - "** Reason for termination == ~n** ~p~n", + format("** wx object server ~tp terminating \n" + "** Last message in was ~tp~n" + "** When Server state == ~tp~n" + "** Reason for termination == ~n** ~tp~n", [Name, Msg, State, Reason1]), sys:print_log(Debug), ok. @@ -657,7 +657,7 @@ debug_options(Name, Opts) -> dbg_opts(Name, Opts) -> case catch sys:debug_options(Opts) of {'EXIT',_} -> - format("~p: ignoring erroneous debug options - ~p~n", + format("~tp: ignoring erroneous debug options - ~tp~n", [Name, Opts]), []; Dbg -> |