From d0bb666c8811615981db8721c119ee6450857272 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Fri, 22 Feb 2013 15:09:25 +0100 Subject: [debugger] Add an option 'Strings' A new checkbox has been added. When it is checked, the range set by the 'erl' flag '+pc' is used for determining when to print lists of integers as strings. When it is unchecked, integer lists are never printed as strings. A minor incompatibility: settings saved by Erlang R16B01 or later cannot be read by Erlang R16B or earlier. --- lib/debugger/src/dbg_ieval.erl | 105 +++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 51 deletions(-) (limited to 'lib/debugger/src/dbg_ieval.erl') diff --git a/lib/debugger/src/dbg_ieval.erl b/lib/debugger/src/dbg_ieval.erl index f5744a6e14..f4b6d488a5 100644 --- a/lib/debugger/src/dbg_ieval.erl +++ b/lib/debugger/src/dbg_ieval.erl @@ -324,61 +324,64 @@ trace(What, Args) -> trace(return, {_Le,{dbg_apply,_,_,_}}, _Bool) -> ignore; trace(What, Args, true) -> - Str = case What of - send -> - {To,Msg} = Args, - io_lib:format("==> ~w : ~p~n", [To, Msg]); - receivex -> - {Le, TimeoutP} = Args, - Tail = case TimeoutP of - true -> "with timeout~n"; - false -> "~n" - end, - io_lib:format(" (~w) receive " ++ Tail, [Le]); - - received when Args =:= null -> - io_lib:format("~n", []); - received -> % Args=Msg - io_lib:format("~n<== ~p~n", [Args]); - - call -> - {Called, {Le,Li,M,F,As}} = Args, - case Called of - extern -> - io_lib:format("++ (~w) <~w> ~w:~w~ts~n", - [Le,Li,M,F,format_args(As)]); - local -> - io_lib:format("++ (~w) <~w> ~w~ts~n", - [Le,Li,F,format_args(As)]) - end; - call_fun -> - {Le,Li,F,As} = Args, - io_lib:format("++ (~w) <~w> ~w~ts~n", - [Le, Li, F, format_args(As)]); - return -> - {Le,Val} = Args, - io_lib:format("-- (~w) ~p~n", [Le, Val]); - - - bif -> - {Le,Li,M,F,As} = Args, - io_lib:format("++ (~w) <~w> ~w:~w~ts~n", - [Le, Li, M, F, format_args(As)]) - end, - dbg_icmd:tell_attached({trace_output, Str}); + Fun = fun(P) -> format_trace(What, Args, P) end, + dbg_icmd:tell_attached({trace_output, Fun}); trace(_What, _Args, false) -> ignore. -format_args(As) when is_list(As) -> - [$(,format_args1(As),$)]; -format_args(A) -> - [$/,io_lib:format("~p", [A])]. +format_trace(What, Args, P) -> + case What of + send -> + {To,Msg} = Args, + io_lib:format("==> ~w : "++P++"~n", [To, Msg]); + receivex -> + {Le, TimeoutP} = Args, + Tail = case TimeoutP of + true -> "with timeout~n"; + false -> "~n" + end, + io_lib:format(" (~w) receive " ++ Tail, [Le]); + + received when Args =:= null -> + io_lib:format("~n", []); + received -> % Args=Msg + io_lib:format("~n<== "++P++"~n", [Args]); + + call -> + {Called, {Le,Li,M,F,As}} = Args, + case Called of + extern -> + io_lib:format("++ (~w) <~w> ~w:~w~ts~n", + [Le,Li,M,F,format_args(As, P)]); + local -> + io_lib:format("++ (~w) <~w> ~w~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", + [Le, Li, F, format_args(As, P)]); + return -> + {Le,Val} = Args, + io_lib:format("-- (~w) "++P++"~n", [Le, Val]); + + + bif -> + {Le,Li,M,F,As} = Args, + io_lib:format("++ (~w) <~w> ~w:~w~ts~n", + [Le, Li, M, F, format_args(As, P)]) + end. + +format_args(As, P) when is_list(As) -> + [$(,format_args1(As, P),$)]; +format_args(A, P) -> + [$/,io_lib:format(P, [A])]. -format_args1([A]) -> - [io_lib:format("~p", [A])]; -format_args1([A|As]) -> - [io_lib:format("~p", [A]),$,|format_args1(As)]; -format_args1([]) -> +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([], _) -> []. %%--Other useful functions-------------------------------------------- -- cgit v1.2.3