Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed tabs and trailing spaces

  • Loading branch information...
commit 4053d9c2debbd6f50a7c50f9ab676e746fd94936 1 parent 8766db8
mats cronqvist authored
Showing with 590 additions and 592 deletions.
  1. +6 −6 src/bread.erl
  2. +3 −3 src/bread_server.erl
  3. +25 −25 src/dtopConsumer.erl
  4. +1 −1  src/dtop_replay.erl
  5. +14 −14 src/gen_serv.erl
  6. +6 −6 src/getopt.erl
  7. +6 −6 src/gperfConsumer.erl
  8. +27 −27 src/gperfGtk.erl
  9. +2 −2 src/logReader.erl
  10. +2 −2 src/loggerConsumer.erl
  11. +2 −2 src/ntopConsumer.erl
  12. +2 −2 src/prf.erl
  13. +4 −4 src/prfConsumer.erl
  14. +4 −4 src/prfDog.erl
  15. +30 −30 src/prfHost.erl
  16. +10 −11 src/prfNet.erl
  17. +17 −17 src/prfPrc.erl
  18. +39 −39 src/prfSys.erl
  19. +33 −33 src/prfTarg.erl
  20. +35 −35 src/prfTrc.erl
  21. +35 −35 src/redbug.erl
  22. +1 −1  src/redbugConsumer.erl
  23. +10 −10 src/redbug_msc.erl
  24. +3 −4 src/replay_trc.erl
  25. +37 −37 src/sherk.erl
  26. +71 −71 src/sherk_aquire.erl
  27. +10 −10 src/sherk_ets.erl
  28. +3 −3 src/sherk_list.erl
  29. +26 −26 src/sherk_prof.erl
  30. +41 −41 src/sherk_scan.erl
  31. +8 −8 src/sherk_tab.erl
  32. +16 −16 src/sherk_target.erl
  33. +16 −16 src/sherk_tree.erl
  34. +43 −43 src/watchdog.erl
  35. +2 −2 src/watchdogLogger.erl
View
12 src/bread.erl
@@ -46,7 +46,7 @@ trc(Filename,Fun,Acc) ->
fold(Filename,Fun,Acc,Opts) ->
Type = take_first(Opts,[line,sax,xml,term,trc]),
case file:open(Filename, [read, raw, binary]) of
- {ok, FD} ->
+ {ok, FD} ->
try fold(read(FD),FD,wrap(Fun,Type),chunker(Type),?state(Acc,?tail_0()))
after file:close(FD)
end;
@@ -68,7 +68,7 @@ term_f(Fun) ->
catch {parsing_failed,R} -> ?log([{parse_error,R},{string,TermBin}]),O
end
end.
-
+
to_term(Bin) ->
try
{ok,Ts,_} = erl_scan:string(binary_to_list(Bin)),
@@ -81,7 +81,7 @@ to_term(Bin) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% SAX funs
sax_f(Fun) ->
- fun(RawXML,O) ->
+ fun(RawXML,O) ->
try [erlsom:sax(encoding(RawXML),[],sax_if(Fun))|O]
catch error:R -> ?log([{bt,erlang:get_stacktrace()},{doc,RawXML}]),
exit(R)
@@ -116,7 +116,7 @@ fold(eof,_,Fun,Chunker,State) ->
?state(Acc,Tail) = folder(Chunker,Fun,state_eof(State)),
[?log([{trailing,Tail}]) || not is_empty(Tail)],
Acc;
-fold({ok,Chunk},FD,Fun,Chunker,State) ->
+fold({ok,Chunk},FD,Fun,Chunker,State) ->
fold(read(FD),FD,Fun,Chunker,folder(Chunker,Fun,add_chunk(Chunk,State))).
folder(Chunker,Fun,?state(Acc,Tail)) ->
@@ -152,7 +152,7 @@ chunker(trc) ->
?log([{garbarge_at_eof,byte_size(R)}]),
{cont,?tail_0()}
end;
- (?tail(Bin,Off)) ->
+ (?tail(Bin,Off)) ->
case Bin of
<<_:Off/binary,0,S:32/integer,B:S/binary,_/binary>> ->
{ok,binary_to_term(B),?tail(Bin,Off+5+S)};
@@ -167,7 +167,7 @@ chunker(Type) ->
{_,T} when ?is_empty(T) -> {cont,?tail_0()};
{_,Trail} -> {ok,Trail,?tail_0()}
end;
- (Tail=?tail(Bin,Off)) ->
+ (Tail=?tail(Bin,Off)) ->
case re:run(Bin,Patt,[{offset,Off},{capture,[1]}]) of
nomatch -> {cont,Tail};
{match,[{O,L}]} -> {ok,snip(Bin,O,L),?tail(Bin,O+L)}
View
6 src/bread_server.erl
@@ -68,11 +68,11 @@ start_breader(File,Files,LD) ->
LD#ld{file=File,files=Files,bread_pid=BP,bread_ref=BR}.
%% runs in its own process
-breader(File,guess) ->
+breader(File,guess) ->
breader(File,guess_type(filename:extension(File)));
-breader(File,Type) ->
+breader(File,Type) ->
bread:fold(File,fun breaded/2,0,[Type]).
-
+
breaded(Blob,N) ->
receive
quit -> exit(N);
View
50 src/dtopConsumer.erl
@@ -54,34 +54,34 @@ memi(Sys) ->
sys_str(Sys) ->
{_, Time} = calendar:now_to_local_time(lks(now, Sys)),
- H = pad(element(1,Time),2,$0,left),
- M = pad(element(2,Time),2,$0,left),
- S = pad(element(3,Time),2,$0,left),
- Node = to_list(lks(node, Sys)),
+ H = pad(element(1,Time),2,$0,left),
+ M = pad(element(2,Time),2,$0,left),
+ S = pad(element(3,Time),2,$0,left),
+ Node = to_list(lks(node, Sys)),
MEMbeam = prf:human(lks(beam_vss,Sys,0)),
- MEM = prf:human(lks(total,Sys)),
+ MEM = prf:human(lks(total,Sys)),
CPUbeam = to_list(100*(lks(beam_user,Sys,0)+lks(beam_kernel,Sys,0))),
CPU = to_list(100*(lks(user,Sys,0)+lks(kernel,Sys,0))),
- Procs = prf:human(lks(procs,Sys)),
- RunQ = prf:human(lks(run_queue, Sys)),
+ Procs = prf:human(lks(procs,Sys)),
+ RunQ = prf:human(lks(run_queue, Sys)),
SYS = lists:sublist(lists:append(["size: " ,MEM,
- "(" ,MEMbeam,
- "), cpu%: " ,CPUbeam,
- "(" ,CPU,
- "), procs: ",Procs,
- ", runq: " ,RunQ,
- ", ",H,":",M,":",S]),79),
+ "(" ,MEMbeam,
+ "), cpu%: " ,CPUbeam,
+ "(" ,CPU,
+ "), procs: ",Procs,
+ ", runq: " ,RunQ,
+ ", ",H,":",M,":",S]),79),
pad(Node,79-length(SYS),$ , right)++SYS.
pad(Item,Len,Pad,LeftRight) ->
I = to_list(Item),
case length(I) of
L when L=:=Len -> I;
- L when L<Len -> case LeftRight of
- left -> lists:duplicate(Len-L,Pad)++I;
- right-> I++lists:duplicate(Len-L,Pad)
- end;
+ L when L<Len -> case LeftRight of
+ left -> lists:duplicate(Len-L,Pad)++I;
+ right-> I++lists:duplicate(Len-L,Pad)
+ end;
_ -> lists:sublist(I,Len)
end.
@@ -100,10 +100,10 @@ which_sort(msgq,PrfPrc) -> expand(lks(msgq,PrfPrc),lks(info,PrfPrc));
which_sort(dmem,PrfPrc) -> expand(lks(dmem,PrfPrc),lks(info,PrfPrc));
which_sort( mem,PrfPrc) -> expand(lks(mem,PrfPrc),lks(info,PrfPrc)).
-expand(Pids,Infos) ->
+expand(Pids,Infos) ->
lists:reverse([[{pid,Pid}|lks(Pid,Infos)] || Pid <- Pids]).
-print_procs(FD,Items,PrfSys,Prcs) ->
+print_procs(FD,Items,PrfSys,Prcs) ->
CpuPerRed = cpu_per_red(PrfSys),
[procsI(FD,P,CpuPerRed) || P <- resize(Items,Prcs)].
@@ -126,22 +126,22 @@ procsI(FD,PP,CpuPerRed) ->
io:fwrite(FD,
format(),
[pidf(to_list(lks(pid,PP))),
- funf(reg(PP)),
- funf(lks(current_function, PP)),
+ funf(reg(PP)),
+ funf(lks(current_function, PP)),
prf:human(lks(message_queue_len, PP)),
- prf:human(lks(memory,PP)),
+ prf:human(lks(memory,PP)),
to_list(lks(dreductions,PP)*CpuPerRed)])
catch _:_ ->
io:fwrite(FD,"~n",[])
end.
-reg(PP) ->
+reg(PP) ->
case lks(registered_name, PP) of
[] -> lks(initial_call, PP);
Val -> Val
end.
-pidf(Pid) ->
+pidf(Pid) ->
[_,A,B] = string:tokens(Pid,"."),
lists:append(["<0.",A,".",B]).
@@ -156,7 +156,7 @@ to_list(A) when is_tuple(A) -> tuple_to_list(A);
to_list(A) when is_integer(A) -> integer_to_list(A).
lks(Tag,TVs,Def) ->
- try lks(Tag,TVs)
+ try lks(Tag,TVs)
catch {not_found, _} -> Def
end.
View
2  src/dtop_replay.erl
@@ -13,7 +13,7 @@
replay(TrcFile,Node) -> replay(TrcFile,Node,[]).
-replay(TrcFile,OldNode,Opts) ->
+replay(TrcFile,OldNode,Opts) ->
Node = ck_node(OldNode),
replay_trc:go(TrcFile,mk_dtop_fun(Node),mk_dtop_init(Node,Opts),Opts).
View
28 src/gen_serv.erl
@@ -39,10 +39,10 @@ start(Mod) ->
start(Mod,Args) ->
gen_server:start_link({local, Mod}, ?MODULE, {Mod,Args}, []).
-stop(Mod) ->
+stop(Mod) ->
cast(Mod,stop).
-shutdown(Mod) ->
+shutdown(Mod) ->
cast(Mod,shutdown).
get_state(Mod,Field) ->
@@ -71,19 +71,19 @@ unlink() ->
init({Mod,Args}) ->
safer(#ld{mod=Mod,args=Args},init,[Args]).
-terminate(Reason,LD) ->
+terminate(Reason,LD) ->
safer(LD,terminate,[Reason,LD#ld.cld]).
-code_change(OldVsn,LD,Info) ->
+code_change(OldVsn,LD,Info) ->
safer(LD,code_change,[OldVsn,LD#ld.cld,Info]).
-handle_cast(Msg,LD) ->
+handle_cast(Msg,LD) ->
safer(LD,handle_cast,[Msg,LD#ld.cld]).
-handle_call(Msg,From,LD) ->
+handle_call(Msg,From,LD) ->
safer(LD,handle_call,[Msg,From,LD#ld.cld]).
-handle_info(Msg,LD) ->
+handle_info(Msg,LD) ->
safer(LD,handle_info,[Msg,LD#ld.cld]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -100,8 +100,8 @@ safer(LD,F,As) ->
case erlang:function_exported(LD#ld.mod,F,length(As)) of
false-> safe_default(F,LD);
true ->
- try safe_reply(F,LD,apply(LD#ld.mod,F,As))
- catch
+ try safe_reply(F,LD,apply(LD#ld.mod,F,As))
+ catch
error:R ->
?log([R,{mfa,{LD#ld.mod,F,As}},erlang:get_stacktrace()]),
safe_default(F,LD);
@@ -128,10 +128,10 @@ last(L) -> hd(lists:reverse(L)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% utilities
-print_term(Term) ->
+print_term(Term) ->
print_term(group_leader(),Term).
-print_term(FD,Term) ->
+print_term(FD,Term) ->
case node(FD) == node() of
true -> error_logger:info_report(Term);
false-> io:fwrite(FD," ~p~n",[Term])
@@ -139,14 +139,14 @@ print_term(FD,Term) ->
expand_recs(M,List) when is_list(List) ->
[expand_recs(M,L)||L<-List];
-expand_recs(M,Tup) when is_tuple(Tup) ->
+expand_recs(M,Tup) when is_tuple(Tup) ->
case tuple_size(Tup) of
L when L < 1 -> Tup;
L ->
try Fields = M:rec_info(element(1,Tup)),
L = length(Fields)+1,
lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
- catch _:_ ->
+ catch _:_ ->
list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
end
end;
@@ -154,6 +154,6 @@ expand_recs(_,Term) ->
Term.
cast(Mod,What) ->
- try gen_server:cast(Mod,What)
+ try gen_server:cast(Mod,What)
catch exit:{noproc,_} -> ok
end.
View
12 src/getopt.erl
@@ -114,7 +114,7 @@ parse_option_long(OptSpecList, OptAcc, ArgAcc, ArgPos, Args, OptStr, OptArg) ->
case lists:keysearch(Long, ?OPT_LONG, OptSpecList) of
{value, {Name, _Short, Long, undefined, _Help}} ->
parse(OptSpecList, [Name | OptAcc], ArgAcc, ArgPos, Args);
-
+
{value, {_Name, _Short, Long, _ArgSpec, _Help} = OptSpec} ->
% The option argument string is empty, but the option requires
% an argument, so we look into the next string in the list.
@@ -217,7 +217,7 @@ parse_option_next_arg(OptSpecList, OptAcc, ArgAcc, ArgPos, [] = Args, {Name, _Sh
_ ->
throw({error, {missing_option_arg, Name}})
end.
-
+
%% @doc Find the option for the discrete argument in position specified in the
%% Pos argument.
@@ -318,7 +318,7 @@ is_arg_true(Arg) ->
(Arg =:= "on") orelse (Arg =:= "enabled") orelse
(Arg =:= "1").
-
+
-spec is_arg_false(string()) -> boolean().
is_arg_false(Arg) ->
(Arg =:= "false") orelse (Arg =:= "f") orelse
@@ -362,7 +362,7 @@ is_float_arg([_Head | _Tail]) ->
false;
is_float_arg([]) ->
true.
-
+
%% @doc Show a message on stdout indicating the command line options and
%% arguments that are supported by the program.
@@ -441,8 +441,8 @@ usage_options(OptSpecList) ->
lists:flatten(lists:reverse(usage_options_reverse(OptSpecList, []))).
usage_options_reverse([{Name, Short, Long, _ArgSpec, Help} | Tail], Acc) ->
- Prefix =
- case Long of
+ Prefix =
+ case Long of
undefined ->
case Short of
% Neither short nor long form (non-option argument).
View
12 src/gperfConsumer.erl
@@ -2,7 +2,7 @@
%%%-------------------------------------------------------------------
%%% File : gperfConsumer.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 17 May 2005 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
@@ -21,7 +21,7 @@ init(Node) -> #ld{node = Node}.
terminate(_LD) -> ok.
-tick(LD, Data) ->
+tick(LD, Data) ->
NLD = update_ld(LD, Data),
gperf ! {tick, {ltime(NLD#ld.data),info(NLD)}},
NLD.
@@ -47,11 +47,11 @@ info(LD) ->
dump_ld(LD) ->
?log(lists:zip(record_info(fields,ld),tl(tuple_to_list(LD)))).
-update_ld(LD,[]) ->
+update_ld(LD,[]) ->
LD#ld{data=[]};
-update_ld(LD,[{prfSys,Sys}]) ->
+update_ld(LD,[{prfSys,Sys}]) ->
LD#ld{data=Sys};
-update_ld(LD,[X]) ->
+update_ld(LD,[X]) ->
?log({unrecognized_data,X}), LD.
ltime(Sys) ->
@@ -76,7 +76,7 @@ mem(Max,Sys) ->
mn(1,dv(lks(ets,Sys)+lks(processes,Sys),Max)),
mn(1,dv(lks(processes,Sys),Max))].
-net(Max,Sys) ->
+net(Max,Sys) ->
[mn(1,dv(lks(io_in,Sys),Max)),
mn(1,dv(lks(io_out,Sys),Max))].
View
54 src/gperfGtk.erl
@@ -1,14 +1,14 @@
%%%-------------------------------------------------------------------
%%% File : gperfGtk.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 12 Sep 2005 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
-module(gperfGtk).
-export([start/0,stop/0,init/0]).
--export([loop/1]). %internal export
+-export([loop/1]). %internal export
-import(lists,[foreach/2,flatten/1,keysearch/3,nth/2,reverse/1,seq/2,sort/1]).
-import(orddict,[new/0,store/3,is_key/2,fold/3,update/3,fetch/2,from_list/1]).
@@ -23,8 +23,8 @@
-define(WYSIZE,?YSIZE).
-define(XHALF,(?XSIZE div 2)).
-define(DAREAS, [{drawingarea1,[blue,red,green,magenta]},
- {drawingarea2,[black,blue,red,yellow]},
- {drawingarea3,[red,green]}]).
+ {drawingarea2,[black,blue,red,yellow]},
+ {drawingarea3,[red,green]}]).
-record(dArea, {win,px_fg,px_bg,gc_fg,gc_bg,gcs,layout}).
-record(conf, {widget, val, type}).
@@ -48,7 +48,7 @@ init() ->
_:R -> ?log([{error,R},{stack,erlang:get_stacktrace()}])
end.
-glade_file(Glade) ->
+glade_file(Glade) ->
try take_first(
fun(F) -> true = filelib:is_regular(F) end,
[filename:join([code:lib_dir(eper),"src",Glade])
@@ -56,8 +56,8 @@ glade_file(Glade) ->
catch _:_ -> exit({not_found,Glade})
end.
-take_first(F,[H|T]) ->
- try F(H),H
+take_first(F,[H|T]) ->
+ try F(H),H
catch _:_ -> take_first(F,T)
end.
@@ -86,7 +86,7 @@ loop(LD) ->
{args,['']} -> ?LP(LD);
{args,[Node]} -> ?LP(conf(LD,from_list([{anode,Node}])));
{args,[Node,Proxy]} -> ?LP(conf(LD,from_list([{aproxy,Proxy},
- {anode,Node}])));
+ {anode,Node}])));
%% ticker
{tick, Stuff} -> ?LP(do_tick(LD,Stuff));
@@ -106,12 +106,12 @@ dump_ld(LD) ->
%% initialize the conf dialog
-spec conf() -> confs().
conf() ->
- from_list([{anode, #conf{widget=conf_node, val='', type=atom}},
- {cookie,#conf{widget=conf_cookie,val='', type=atom}},
- {aproxy,#conf{widget=conf_proxy, val='', type=atom}},
- {cpu, #conf{widget=conf_cpu, val=300, type=integer}},
- {mem, #conf{widget=conf_mem, val=8*1024,type=integer}},
- {net, #conf{widget=conf_net, val=32*1024,type=integer}}]).
+ from_list([{anode, #conf{widget=conf_node, val='', type=atom}},
+ {cookie,#conf{widget=conf_cookie,val='', type=atom}},
+ {aproxy,#conf{widget=conf_proxy, val='', type=atom}},
+ {cpu, #conf{widget=conf_cpu, val=300, type=integer}},
+ {mem, #conf{widget=conf_mem, val=8*1024,type=integer}},
+ {net, #conf{widget=conf_net, val=32*1024,type=integer}}]).
%% sets and allpies conf values
%% TagVals and Confs are dicts
@@ -129,7 +129,7 @@ conf_upd(Key,Val,Confs) ->
%% struct differ. if so, take the value from the GUI
%% TagVals and Confs are dicts
-spec conf(#ld{}) -> #ld{}.
-conf(LD) ->
+conf(LD) ->
{TagVals,Confs} = fold(fun conf_chk/3, {new(),LD#ld.conf}, LD#ld.conf),
conf_apply(TagVals,Confs),
LD#ld{conf=Confs}.
@@ -165,14 +165,14 @@ conf_fill(Confs) -> fold(fun conf_fill/3, [], Confs).
conf_fill(_Key,#conf{widget=Widget, val=Val},_) ->
g('Gtk_entry_set_text',[Widget,to_str(Val)]).
-conf_val(Key,LD) when is_record(LD,ld) ->
+conf_val(Key,LD) when is_record(LD,ld) ->
conf_val(Key,LD#ld.conf);
conf_val(Key,Confs) ->
(fetch(Key,Confs))#conf.val.
-get_gui_val(Widget,Type,Val) ->
+get_gui_val(Widget,Type,Val) ->
X = g('Gtk_entry_get_text',[Widget]),
- case Type of
+ case Type of
atom -> try list_to_atom(X) catch _:_ -> Val end;
integer-> try list_to_integer(X) catch _:_ -> Val end
end.
@@ -197,7 +197,7 @@ setcookie(Node,Cookie) ->
restart(Confs) ->
try restart(conf_val(anode,Confs),conf_val(aproxy,Confs)),
[do_conf(Tag,Confs) || Tag <- [cpu,net,mem]]
- catch _:R ->
+ catch _:R ->
?log([{reason,R},Confs])
end.
@@ -213,7 +213,7 @@ die(_LD) ->
io:fwrite("~w - terminating~n", [?MODULE]),
exit(dying).
-do_unknown(LD,X) ->
+do_unknown(LD,X) ->
io:fwrite("~w - unknown signal - ~p~n",[?MODULE,X]),
LD.
@@ -239,7 +239,7 @@ hide(Darea) -> g('Gtk_widget_hide',[Darea]).
hide_cf() -> hide(conf_window).
-show_cf(LD) ->
+show_cf(LD) ->
conf_fill(LD#ld.conf),
show(conf_window).
@@ -280,7 +280,7 @@ timeline(LD = #ld{dAreas=Dareas},{_,M,_}=HMS) ->
foreach(fun(Darea)->draw_timeline(Darea,LD,HMS) end,Dareas),
LD#ld{minute=M}.
-stat_change(up,LD) ->
+stat_change(up,LD) ->
Nod = to_str(conf_val(anode,LD)),
g('Gtk_window_set_title',[window,"gperf - "++Nod]),
statbar(Nod++" - connected",LD),
@@ -305,7 +305,7 @@ draw_time(#dArea{px_fg=Pxfg,px_bg=Pxbg,layout=Layout,gc_fg=GC},LD,{H,M}) ->
g('Gdk_draw_layout',[Pxbg,GC,LD#ld.x-?XHALF,90,Layout]).
draw_line(DA,GCtag,X,Y) ->
- %% draws a line from {X,0} to {X,Y} where 0<Y<1.
+ %% draws a line from {X,0} to {X,Y} where 0<Y<1.
%% Y=0: upper margin, Y=1: lower margin
Y0 = ?YSIZE-?MARG,
Y1 = Y0-round(Y*(?YSIZE-2*?MARG)),
@@ -349,9 +349,9 @@ init_da({DA,Colors})->
g( 'Gtk_widget_set_size_request',[DA,?WXSIZE,?WYSIZE]),
g('Gtk_widget_modify_bg', [DA,'GTK_STATE_NORMAL',white]),
{DA,#dArea{win=Win,layout=Layout,
- gc_fg=GCblack,gc_bg=GCwhite,
- px_fg=P1,px_bg=P2,
- gcs=gcs(Win,Colors)}}.
+ gc_fg=GCblack,gc_bg=GCwhite,
+ px_fg=P1,px_bg=P2,
+ gcs=gcs(Win,Colors)}}.
pixmaps(0, _Win) -> [];
pixmaps(N,Win) ->
@@ -368,7 +368,7 @@ clear_one({_,#dArea{px_fg=Px1,px_bg=Px2,gc_fg=GCfg,gc_bg=GCbg}}) ->
clear_px(GCfg,GCbg,Pixmap) ->
g('Gdk_draw_rectangle', [Pixmap,GCbg, true, 0, 0, -1, -1]),
- g('Gdk_draw_rectangle',
+ g('Gdk_draw_rectangle',
[Pixmap,GCfg,false,?MARG,?MARG,?XSIZE-2*?MARG,?YSIZE-2*?MARG]).
gcs(_Win,[]) -> [];
View
4 src/logReader.erl
@@ -15,10 +15,10 @@ read(FN) ->
after file:close(FD)
end.
-read(FD,Cont) ->
+read(FD,Cont) ->
case file:read(FD,1048576) of
{ok,Bin} -> read(FD,chop(<<Cont/binary,Bin/binary>>));
- eof -> throw(done);
+ eof -> throw(done);
{error,R} -> exit({error_reading,R})
end.
View
4 src/loggerConsumer.erl
@@ -17,7 +17,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
collectors() -> [prfPrc,prfSys].
-init(Node) ->
+init(Node) ->
FN = os:getenv("HOME")++"/log-"++atom_to_list(Node)++".gz",
case file:open(FN,[write,compressed,raw]) of
{ok,FD} -> ?log({opened,FN}),#cld{node=Node, fd=FD};
@@ -27,7 +27,7 @@ init(Node) ->
terminate(_LD) -> ok.
config(LD,_Data) -> ?log({loopdata,LD}), LD.
-tick(LD, In) ->
+tick(LD, In) ->
Bin = term_to_binary(In),
Size = byte_size(Bin),
case file:write(LD#cld.fd,<<Size:32,Bin/binary>>) of
View
4 src/ntopConsumer.erl
@@ -46,7 +46,7 @@ print_port(Name,Data) ->
[str("~8w", [V]) || {I,V}<-Data, ok(I)],
str("~n",[])])]).
-net(NetN,NetO) ->
+net(NetN,NetO) ->
{_,O} = fold(fun foldf/3,{NetO,new()},NetN),
O.
@@ -56,7 +56,7 @@ foldf(Key,Val,{KVs,O}) ->
end.
zipsub([],[]) -> [];
-zipsub([{K,V1}|R1],[{K,V2}|R2]) when is_integer(V1),is_integer(V2)->
+zipsub([{K,V1}|R1],[{K,V2}|R2]) when is_integer(V1),is_integer(V2)->
[{K,V1-V2}|zipsub(R1,R2)];
zipsub([{K,V}|R1],[{K,V}|R2]) -> [{K,V}|zipsub(R1,R2)].
View
4 src/prf.erl
@@ -1,7 +1,7 @@
%%%-------------------------------------------------------------------
%%% File : prf.erl
%%% Author : Mats Cronqvist <etxmacr@axdt212>
-%%% Description :
+%%% Description :
%%%
%%% Created : 11 Dec 2006 by Mats Cronqvist <etxmacr@axdt212>
%%%-------------------------------------------------------------------
@@ -38,7 +38,7 @@ stop(Name) -> prfHost:stop(Name).
config(Name,Type,Data) -> prfHost:config(Name,Type,Data).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%% prf internal
+%%% prf internal
ticker_even()-> erlang:start_timer(incr(?TICK,0), self(),{tick}).
ticker_odd() -> erlang:start_timer(incr(?TICK,?TICK div 2), self(),{tick}).
View
8 src/prfConsumer.erl
@@ -2,7 +2,7 @@
%%% File : prfConsumer.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
%%% Description : an example consumer
-%%% : try e.g.
+%%% : try e.g.
%% : prf:start(foo,node(),prfConsumer).
%% : prf:stop(foo).
%%% Created : 17 May 2005 by Mats Cronqvist <locmacr@mwlx084>
@@ -22,12 +22,12 @@ init(Node) -> #cld{node = Node}.
terminate(_LD) -> ok.
config(LD,_Data) -> ?log({loopdata,LD}), LD.
-tick(LD, []) ->
+tick(LD, []) ->
?log(empty),
LD;
-tick(LD, [[]]) ->
+tick(LD, [[]]) ->
?log(empty_d),
LD;
-tick(LD, [Data|_]) ->
+tick(LD, [Data|_]) ->
?log({data,Data}),
LD.
View
8 src/prfDog.erl
@@ -21,7 +21,7 @@ collect(LD) ->
assert(),
{LD,{?MODULE,gen_server:call(?MODULE,get_data)}}.
-config(LD,Data) ->
+config(LD,Data) ->
?log([unknown,{data,Data}]),
LD.
@@ -39,7 +39,7 @@ sock_opts() -> [binary, {reuseaddr,true}, {active,false}, {packet,4}].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% user code
-do_init(Args) ->
+do_init(Args) ->
#ld{args=Args, acceptor=accept(producer,56669,sock_opts())}.
do_terminate(_LD,_Reason) -> ok.
@@ -55,7 +55,7 @@ do_info(LD,{new_socket,producer,Sock}) ->
%% we accepted a socket towards a producer.
inet:setopts(Sock,[{active,once}]),
LD#ld{socket=[Sock|LD#ld.socket]};
-do_info(LD,{tcp,Sock,Bin}) ->
+do_info(LD,{tcp,Sock,Bin}) ->
case lists:member(Sock,LD#ld.socket) of
true ->
%% got data from a known socket. this is good
@@ -72,7 +72,7 @@ do_info(LD,{tcp_closed, Sock}) ->
do_info(LD,{tcp_error, Sock, Reason}) ->
?log([{tcp_error,Reason},{socket,Sock}]),
LD;
-do_info(LD,Msg) ->
+do_info(LD,Msg) ->
?log([{unrec,Msg}|expand_recs(LD)]),
LD.
View
60 src/prfHost.erl
@@ -1,16 +1,16 @@
%%%-------------------------------------------------------------------
%%% File : prfHost.erl
%%% Author : Mats Cronqvist <qthmacr@duna283>
-%%% Description :
+%%% Description :
%%%
%%% Created : 2 Dec 2003 by Mats Cronqvist <qthmacr@duna283>
%%%-------------------------------------------------------------------
-module(prfHost).
-export([start/3,start/4,stop/1,config/3]).
--export([loop/1]). %internal
+-export([loop/1]). %internal
--record(ld, {node, server=[], collectors, config=[],
+-record(ld, {node, server=[], collectors, config=[],
proxy, consumer, consumer_data, data=[]}).
-define(LOOP, ?MODULE:loop).
@@ -22,7 +22,7 @@
start(Name,Node,Consumer) -> start(Name,Node,Consumer,no_proxy).
start(Name,Node,Consumer,Proxy)
- when is_atom(Name),is_atom(Node),is_atom(Consumer),is_atom(Proxy) ->
+ when is_atom(Name),is_atom(Node),is_atom(Consumer),is_atom(Proxy) ->
assert_proxy(Proxy),
SpawnFun = fun()->init(Consumer,Node,Proxy) end,
case whereis(Name) of
@@ -36,7 +36,7 @@ spawner(F) ->
false-> spawn_link(F)
end.
-stop(Name) ->
+stop(Name) ->
case whereis(Name) of
Pid when is_pid(Pid) -> Name ! {self(),stop}, receive stopped -> ok end;
_ -> ok
@@ -71,31 +71,31 @@ init(Consumer, Node, Proxy) ->
no_proxy when Collectors=:=watchdog ->
exit(specify_proxy);
no_proxy ->
- loop(#ld{node = Node,
- proxy = [],
- consumer = Consumer,
- collectors = subscribe(Node,Collectors),
- consumer_data = Consumer:init(Node)});
+ loop(#ld{node = Node,
+ proxy = [],
+ consumer = Consumer,
+ collectors = subscribe(Node,Collectors),
+ consumer_data = Consumer:init(Node)});
_ ->
loop(#ld{node = Proxy,
- proxy = {Node,Collectors},
- consumer = Consumer,
- collectors = subscribe(Proxy,[prfDog]),
- consumer_data = Consumer:init(Node)})
+ proxy = {Node,Collectors},
+ consumer = Consumer,
+ collectors = subscribe(Proxy,[prfDog]),
+ consumer_data = Consumer:init(Node)})
end.
loop(LD) ->
receive
- {Stopper,stop} ->
+ {Stopper,stop} ->
?log(stopping),
do_stop(LD),
Stopper ! stopped;
- {timeout, _, {tick}} when LD#ld.server == [] ->
+ {timeout, _, {tick}} when LD#ld.server == [] ->
prf:ticker_even(),
subscribe(LD#ld.node,LD#ld.collectors),
Cdata = (LD#ld.consumer):tick(LD#ld.consumer_data, []),
?LOOP(LD#ld{consumer_data = Cdata});
- {timeout, _, {tick}} ->
+ {timeout, _, {tick}} ->
prf:ticker_even(),
{Data,NLD} = get_data(LD),
Cdata = (NLD#ld.consumer):tick(NLD#ld.consumer_data, de_proxy(LD,Data)),
@@ -126,12 +126,12 @@ loop(LD) ->
de_proxy(_,[]) -> [];
de_proxy(LD,Data) ->
case LD#ld.proxy of
- [] -> Data;
+ [] -> Data;
{Node,watchdog} -> dog_data(Data,Node);
{Node,Colls} -> de_colls(Colls,dog_data(Data,Node))
end.
-de_colls(Colls,DogData) ->
+de_colls(Colls,DogData) ->
F0 = fun({_,Ev},_) -> Ev=:=ticker end,
CD = orddict:filter(F0,DogData),
F1 = fun(C,_) -> lists:member(C,Colls) end,
@@ -157,31 +157,31 @@ do_stop(LD) ->
prfTarg:unsubscribe(LD#ld.node, self()),
(LD#ld.consumer):terminate(LD#ld.consumer_data).
-get_data(LD) ->
+get_data(LD) ->
case {get_datas(LD#ld.node), LD#ld.data} of
- {[],[]} -> {[],LD};
- {[],[Data]} -> {Data,LD#ld{data=[]}};
- {[Data],_} -> {Data,LD#ld{data=[]}};
- {[Data,D2|_],_} -> {Data,LD#ld{data=[D2]}}
+ {[],[]} -> {[],LD};
+ {[],[Data]} -> {Data,LD#ld{data=[]}};
+ {[Data],_} -> {Data,LD#ld{data=[]}};
+ {[Data,D2|_],_} -> {Data,LD#ld{data=[D2]}}
end.
-get_datas(Node) ->
+get_datas(Node) ->
receive {{data, Node}, Data} -> [Data|get_datas(Node)]
after 0 -> []
end.
subscribe(Node, Collectors) ->
Self = self(),
- spawn(fun() ->
- %% this runs in its own process since it can block
+ spawn(fun() ->
+ %% this runs in its own process since it can block
%% nettick_time seconds (if the target is hung)
try prfTarg:subscribe(Node, Self, Collectors) of
- {Pid,Tick} ->
- maybe_change_ticktime(Tick),
+ {Pid,Tick} ->
+ maybe_change_ticktime(Tick),
Self ! {subscribe, {ok, Pid}}
catch
_:R -> Self ! {subscribe, {failed,R}}
- end
+ end
end),
Collectors.
View
21 src/prfNet.erl
@@ -21,14 +21,14 @@ config(State,_ConfigData) -> State.
data() -> lists:sort([port_info(P) || P <- erlang:ports()]).
%%returns {Name::atom(),Stats::list()}
-port_info(P) when is_port(P) ->
+port_info(P) when is_port(P) ->
try stats(P,name(P))
catch _:_ -> {P,[]}
end.
-stats(P,{driver,Name}) ->
+stats(P,{driver,Name}) ->
{{driver,Name},erlang:port_info(P)};
-stats(P,Name) ->
+stats(P,Name) ->
case erlang:port_info(P) of
undefined -> throw(port_gone);
Info ->
@@ -42,23 +42,23 @@ name(P) -> name(erlang:port_info(P,name),P).
name({name,"udp_inet"},P) ->
{ok,Port} = inet:port(P),
{udp,Port};
-name({name,"tcp_inet"},P) ->
+name({name,"tcp_inet"},P) ->
{ok,{IP,Port}} = inet:peername(P),
memoize({prfNet,tcp_name,IP,Port}, fun tcp_name/1);
name({name,Name},_P) ->
{driver,Name}.
tcp_name({prfNet,tcp_name,IP,Port}) ->
- case inet:gethostbyaddr(IP) of
+ case inet:gethostbyaddr(IP) of
{ok,#hostent{h_name=HostName}} ->
- try
+ try
{ok,Names} = net_adm:names(HostName),
{value,{NodeName,Port}} = lists:keysearch(Port,2,Names),
- {node,NodeName++"@"++HostName}
- catch
- _:_ -> {tcp,{HostName,Port}}
+ {node,NodeName++"@"++HostName}
+ catch
+ _:_ -> {tcp,{HostName,Port}}
end;
- _ ->
+ _ ->
X = tuple_to_list(IP),
{tcp,{tl(lists:flatten([[$.,integer_to_list(I)]||I<-X])),Port}}
end.
@@ -68,4 +68,3 @@ memoize(Key,F) ->
undefined -> put(Key,F(Key)), get(Key);
Name -> Name
end.
-
View
34 src/prfPrc.erl
@@ -43,9 +43,9 @@ config(State,{max_procs,MP}) when is_number(MP) -> State#cst{max_procs=MP};
config(State,_ConfigData) -> State.
%%% returns {State, Data}
-collect(init) ->
+collect(init) ->
collect({cst,get_info(#cst{})});
-collect(Cst = #cst{items=Items})->
+collect(Cst = #cst{items=Items})->
Info = get_info(Cst),
{Cst#cst{old_info=Info}, {?MODULE,select(Cst#cst.old_info,Info,Items)}};
collect({cst,OldInfo}) ->
@@ -54,7 +54,7 @@ collect({cst,OldInfo}) ->
get_info(Cst) ->
case Cst#cst.max_procs < erlang:system_info(process_count) of
true -> {now(),[]};
- false-> {now(),[{P,pid_info(P,?SORT_ITEMS)}||P<-lists:sort(processes())]}
+ false-> {now(),[{P,pid_info(P,?SORT_ITEMS)}||P<-lists:sort(processes())]}
end.
%%% Dreds, Dmems, Mems and Msgqs are sorted lists of pids
@@ -85,28 +85,28 @@ topl([{P,Io}|Os],[{P,Ic}|Cs],Outf,Out) -> topl(Os,Cs,Outf,Outf(P,Io,Ic,Out)).
empties() -> {[],[],[],[]}.
-outf(Then,Now,Items) ->
+outf(Then,Now,Items) ->
NowDiff = timer:now_diff(Now,Then)/1000000,
fun(P,Io,Ic,Out) -> out(P,NowDiff,Io,Ic,Out,Items) end.
-out(P,NowDiff,Io,Ic,O={Odred,Omem,Odmem,Omsgq},Items) ->
+out(P,NowDiff,Io,Ic,O={Odred,Omem,Odmem,Omsgq},Items) ->
try
Dred = dred(NowDiff,Io,Ic),
Dmem = dmem(NowDiff,Io,Ic),
- Info = {P,[{dreductions,Dred},{dmemory,Dmem}|Ic]},
+ Info = {P,[{dreductions,Dred},{dmemory,Dmem}|Ic]},
{new_topl(Odred,{Dred,Info},Items),
new_topl(Odmem,{Dmem,Info},Items),
new_topl(Omem,{mem(Ic),Info},Items),
new_topl(Omsgq,{msgq(Ic),Info},Items)}
- catch
+ catch
_:_ -> O
end.
-new_topl(Top,{Item,_},_Items) when 0 =:= Item; 0.0 =:= Item ->
+new_topl(Top,{Item,_},_Items) when 0 =:= Item; 0.0 =:= Item ->
Top;
-new_topl(Top,El,Items) when length(Top) < Items ->
+new_topl(Top,El,Items) when length(Top) < Items ->
lists:sort([El|Top]);
-new_topl(Top,El,_Items) ->
+new_topl(Top,El,_Items) ->
case El < hd(Top) of
true -> Top;
false-> tl(lists:sort([El|Top]))
@@ -119,7 +119,7 @@ red([]) -> 0;
red([{reductions,Reds}|_]) -> Reds.
mem([]) -> 0;
-mem([_,{memory,Mem}|_]) -> Mem.
+mem([_,{memory,Mem}|_]) -> Mem.
msgq([]) -> 0;
msgq([_,_,{message_queue_len,Msgq}]) -> Msgq.
@@ -130,7 +130,7 @@ msgq([_,_,{message_queue_len,Msgq}]) -> Msgq.
pid_info(Pid) when is_pid(Pid) ->
pid_info(Pid,?TAGS).
-pid_info(Pid,Tags) when is_list(Tags) ->
+pid_info(Pid,Tags) when is_list(Tags) ->
try [pidinfo(Pid,T) || T <- Tags]
catch _:_ -> []
end.
@@ -142,7 +142,7 @@ pidinfo(Pid, Type = heap_size) ->
pidinfo(Pid, Type = total_heap_size) ->
{Type,8*element(2,process_info(Pid, Type))};
pidinfo(Pid, Type = last_calls) ->
- try
+ try
case process_info(Pid,last_calls) of
{_,false} -> process_flag(Pid,save_calls,16),{Type,[]};
{_,Calls} -> {Type,lists:usort(Calls)}
@@ -157,15 +157,15 @@ pidinfo(Pid, Type = registered_name) ->
end;
pidinfo(Pid, Type = initial_call) ->
case process_info(Pid, Type) of
- {Type,{proc_lib,init_p,5}} ->
+ {Type,{proc_lib,init_p,5}} ->
case proc_lib:translate_initial_call(Pid) of
- {dets,init,2} -> {Type,{dets, element(2, dets:pid2name(Pid))}};
- IC -> {Type,IC}
+ {dets,init,2} -> {Type,{dets, element(2, dets:pid2name(Pid))}};
+ IC -> {Type,IC}
end;
{Type,{dets, do_open_file, 11}}->{Type,pinf_dets(Pid)};%gone in R12
XX -> XX
end;
-pidinfo(Pid, Type) ->
+pidinfo(Pid, Type) ->
process_info(Pid, Type).
pinf_dets(Pid) ->
View
78 src/prfSys.erl
@@ -20,37 +20,37 @@
%% else
%% - return an empty list
%%
-%% returns a list of tagged tuples
+%% returns a list of tagged tuples
%%
%% tag [unit] source
%% node [atom()] erlang:node()
-%% now [now()] erlang:now()
-%% procs [count] erlang:system_info(process_count)
-%% context_switches [count/s] erlang:statistics(context_switches)
-%% gcs [count/s] erlang:statistics(garbage_collection)
-%% gc_reclaimed [byte/s] erlang:statistics(garbage_collection)
-%% io_in [byte/s] erlang:statistics(io)
-%% io_out [byte/s] erlang:statistics(io)
-%% reductions [count/s] erlang:statistics(reductions)
-%% run_queue [count] erlang:statistics(run_queue)
-%% total [byte] erlang:memory()
-%% processes [byte] erlang:memory()
-%% processes_used [byte] erlang:memory()
-%% system [byte] erlang:memory()
-%% atom [byte] erlang:memory()
-%% atom_used [byte] erlang:memory()
-%% binary [byte] erlang:memory()
-%% code [byte] erlang:memory()
-%% ets [byte] erlang:memory()
-%% user [frac] /proc/stat
-%% nice [frac] /proc/stat
-%% kernel [frac] /proc/stat
-%% idle [frac] /proc/stat
-%% iowait [frac] /proc/stat
+%% now [now()] erlang:now()
+%% procs [count] erlang:system_info(process_count)
+%% context_switches [count/s] erlang:statistics(context_switches)
+%% gcs [count/s] erlang:statistics(garbage_collection)
+%% gc_reclaimed [byte/s] erlang:statistics(garbage_collection)
+%% io_in [byte/s] erlang:statistics(io)
+%% io_out [byte/s] erlang:statistics(io)
+%% reductions [count/s] erlang:statistics(reductions)
+%% run_queue [count] erlang:statistics(run_queue)
+%% total [byte] erlang:memory()
+%% processes [byte] erlang:memory()
+%% processes_used [byte] erlang:memory()
+%% system [byte] erlang:memory()
+%% atom [byte] erlang:memory()
+%% atom_used [byte] erlang:memory()
+%% binary [byte] erlang:memory()
+%% code [byte] erlang:memory()
+%% ets [byte] erlang:memory()
+%% user [frac] /proc/stat
+%% nice [frac] /proc/stat
+%% kernel [frac] /proc/stat
+%% idle [frac] /proc/stat
+%% iowait [frac] /proc/stat
%% ctxt [frac] /proc/stat
-%% beam_user, [frac] /proc/self/stat
-%% beam_kernel, [frac] /proc/self/stat
-%% beam_vss [byte] /proc/self/stat
+%% beam_user, [frac] /proc/self/stat
+%% beam_kernel, [frac] /proc/self/stat
+%% beam_vss [byte] /proc/self/stat
%% beam_rss [pages] /proc/self/stat
%% beam_minflt [count/s] /proc/self/stat
%% beam_majflt [count/s] /proc/self/stat
@@ -62,11 +62,11 @@
-export([collect/1,config/2]).
-record(cst,{strategy=strategy(), node=node(), total_ram=0, cores=1,
- cache=[], now=now()}).
+ cache=[], now=now()}).
-define(RATES,[context_switches,gcs,gc_reclaimed,io_in,io_out,reductions,
- user,nice,kernel,idle,iowait,
- beam_user,beam_kernel,beam_minflt,beam_majflt]).
+ user,nice,kernel,idle,iowait,
+ beam_user,beam_kernel,beam_minflt,beam_majflt]).
%%% returns {State, Data}
collect(init) ->
@@ -96,21 +96,21 @@ stats() ->
{gcs,GCs},
{gc_reclaimed,GCwords*4},
{io_in,IoIn},
- {io_out,IoOut},
+ {io_out,IoOut},
{reductions,Reds},
{run_queue,RunQ} |
erlang:memory()].
new_cst(Cst,Data) ->
Cst#cst{cache=[D || {Tag,_}=D <- Data, lists:member(Tag,?RATES)],
- now=lks(now,Data)}.
+ now=lks(now,Data)}.
rates(#cst{cache=Cache,now=Now},Data) ->
[diff(Cache,D,delta_t(Now,Data)) || D <- Data].
diff(Cache,{Tag,Val},DeltaT)->
try {Tag,(Val-lks(Tag,Cache))/DeltaT}
- catch
+ catch
no_tag -> {Tag,Val};
_:_ -> {Tag,0}
end.
@@ -155,7 +155,7 @@ proc_stat(FDs) ->
_ -> User=Nice=Kernel=Idle=Iowait=0
end,
lists:zip([user,nice,kernel,idle,iowait],
- [to_sec(J) || J <- [User,Nice,Kernel,Idle,Iowait]]).
+ [to_sec(J) || J <- [User,Nice,Kernel,Idle,Iowait]]).
proc_self_stat(FDss) ->
%%% pid,comm,state,ppid,pgrp,session,tty_nr,tpgid,flags,
@@ -169,9 +169,9 @@ proc_self_stat(FDss) ->
_ -> Minflt=Majflt=Utime=Stime=Vsize=Rss=0
end,
lists:zip([beam_user,beam_kernel,beam_vss,beam_rss,beam_minflt,beam_majflt],
- [to_sec(Utime),to_sec(Stime),to_int(Vsize),
- to_int(Rss), %% in pages...
- to_int(Minflt),to_int(Majflt)]).
+ [to_sec(Utime),to_sec(Stime),to_int(Vsize),
+ to_int(Rss), %% in pages...
+ to_int(Minflt),to_int(Majflt)]).
to_sec(J) ->
to_int(J)/100. %should use a better transform jiffies->secs
@@ -197,8 +197,8 @@ total_ram() ->
case file:open("/proc/meminfo",[read]) of
{ok,FD} ->
try {ok,Str} = file:pread(FD,0,30),
- ["MemTotal:",T,"kB"|_] = string:tokens(Str," \n"),
- list_to_integer(T)*1024
+ ["MemTotal:",T,"kB"|_] = string:tokens(Str," \n"),
+ list_to_integer(T)*1024
catch _:_ -> 0
after file:close(FD)
end;
View
66 src/prfTarg.erl
@@ -5,7 +5,7 @@
-module(prfTarg).
-export([config/1,subscribe/3,unsubscribe/2]).
--export([init/0,loop/1]). %internal; otp r5 compatible!
+-export([init/0,loop/1]). %internal; otp r5 compatible!
-import(net_kernel,[get_net_ticktime/0]).
-import(orddict,[new/0,store/3,fold/3,map/2,find/2,is_key/2,append/3]).
@@ -16,46 +16,46 @@
-include("log.hrl").
%%% interface %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-config(ConfData) ->
+config(ConfData) ->
case whereis(prfTarg) of
underfined -> not_started;
Pid -> Pid ! {config,ConfData}
end.
-subscribe(Node, Pid, Collectors) ->
+subscribe(Node, Pid, Collectors) ->
{PID,Tick} = assert(Node,Collectors),
- PID ! {subscribe, {Pid,Collectors}},
+ PID ! {subscribe, {Pid,Collectors}},
{PID,Tick}.
-unsubscribe(Node, Pid) ->
+unsubscribe(Node, Pid) ->
{Node,?MODULE} ! {unsubscribe, {Pid}}.
%%% runs on host %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
assert(Node,Collectors) ->
- assert_loaded(Node,Collectors),
+ assert_loaded(Node,Collectors),
assert_started(Node).
assert_loaded(Node, Collectors) ->
- lists:foreach(fun(M) -> ass_loaded(Node,M) end,
- [prf,prf_crypto,?MODULE|Collectors]).
+ lists:foreach(fun(M) -> ass_loaded(Node,M) end,
+ [prf,prf_crypto,?MODULE|Collectors]).
ass_loaded(nonode@nohost, Mod) -> {module,Mod}=c:l(Mod);
ass_loaded(Node, Mod) ->
case rpc:call(Node,Mod,module_info,[compile]) of
- {badrpc,{'EXIT',{undef,_}}} -> %no code
+ {badrpc,{'EXIT',{undef,_}}} -> %no code
netload(Node, Mod),
ass_loaded(Node, Mod);
{badrpc,_} ->
ok;
CompInfo when is_list(CompInfo) ->
case {ftime(CompInfo), ftime(Mod:module_info(compile))} of
- {interpreted,_} ->
- ok;
- {TargT, HostT} when TargT < HostT -> %old code on target
- netload(Node, Mod),
- ass_loaded(Node, Mod);
- _ ->
- ok
+ {interpreted,_} ->
+ ok;
+ {TargT, HostT} when TargT < HostT -> %old code on target
+ netload(Node, Mod),
+ ass_loaded(Node, Mod);
+ _ ->
+ ok
end
end.
@@ -67,7 +67,7 @@ ftime([]) -> interpreted;
ftime([{time,T}|_]) -> T;
ftime([_|T]) -> ftime(T).
-assert_started(nonode@nohost) ->
+assert_started(nonode@nohost) ->
starter(spawn(?MODULE, init, []));
assert_started(Node) ->
case net_adm:ping(Node) of
@@ -80,7 +80,7 @@ assert_started(Node) ->
starter(Pid) ->
Ref = erlang:monitor(process,Pid),
Pid ! {start,self()},
- receive
+ receive
{ack, Pid, Tick} -> erlang:demonitor(Ref), {Pid,Tick};
{'DOWN', Ref, process, Pid, {use_me, PID,Tick}} -> {PID,Tick}
end.
@@ -91,14 +91,14 @@ init() ->
erlang:group_leader(whereis(user),self()),
receive {start,Pid} -> ok end,
case whereis(?MODULE) of %to avoid register error msg...
- undefined ->
+ undefined ->
case catch register(?MODULE, self()) of
- {'EXIT', {badarg, _}} -> %somebody beat us to it
- exit({use_me, whereis(?MODULE),get_net_ticktime()});
- true ->
- Pid ! {ack, self(),get_net_ticktime()},
- prf:ticker_odd(),
- loop(#st{})
+ {'EXIT', {badarg, _}} -> %somebody beat us to it
+ exit({use_me, whereis(?MODULE),get_net_ticktime()});
+ true ->
+ Pid ! {ack, self(),get_net_ticktime()},
+ prf:ticker_odd(),
+ loop(#st{})
end;
PID ->
exit({use_me, PID,get_net_ticktime()})
@@ -106,13 +106,13 @@ init() ->
loop(St) ->
receive
- {timeout, _, {tick}} ->
+ {timeout, _, {tick}} ->
prf:ticker_odd(),
erlang:garbage_collect(self()),
?MODULE:loop(collect_and_send(St));
- {subscribe, {Pid,Collectors}} ->
+ {subscribe, {Pid,Collectors}} ->
?MODULE:loop(subscr(St, Pid, Collectors));
- {unsubscribe, {Pid}} ->
+ {unsubscribe, {Pid}} ->
?MODULE:loop(unsubscr(St, Pid));
{'EXIT', Pid, _} ->
?MODULE:loop(unsubscr(St, Pid));
@@ -122,7 +122,7 @@ loop(St) ->
F = fun(M,#collector{subscribers=S},A) -> [{mod,M},{subsc,S}|A] end,
?log([{pid,self()} | fold(F,[],St#st.collectors)]),
?MODULE:loop(St);
- stop ->
+ stop ->
ok
end.
@@ -140,21 +140,21 @@ subscr(St, Pid, Cs) ->
{Pid,Collectors} = lists:foldl(fun subs/2, {Pid,St#st.collectors}, Cs),
St#st{collectors=Collectors}.
-subs(C, {Pid, Collectors}) ->
+subs(C, {Pid, Collectors}) ->
{Pid,store(C,collector(Collectors,Pid,C),Collectors)}.
collector(Colls,Pid,C) ->
case find(C, Colls) of
{ok, Coll = #collector{subscribers=Subs}} ->
Coll#collector{subscribers=lists:umerge(Subs,[Pid])};
- error ->
+ error ->
#collector{subscribers=[Pid]}
end.
unsubscr(St = #st{collectors = Colls}, Pid) ->
St#st{collectors=map(fun(_K,V)->unsubs(Pid,V) end, Colls)}.
-unsubs(Pid,C) ->
+unsubs(Pid,C) ->
C#collector{subscribers=C#collector.subscribers--[Pid]}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -168,7 +168,7 @@ cns(Colls) ->
cns(Module,Coll,{Colls,Datas}) ->
case Coll#collector.subscribers of
- [] ->
+ [] ->
{Colls,Datas};
Subs ->
{NState, Data} = (Module):collect(Coll#collector.state),
View
70 src/prfTrc.erl
@@ -2,7 +2,7 @@
%%%-------------------------------------------------------------------
%%% File : prfTrc.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 18 Jan 2007 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
@@ -52,9 +52,9 @@ assert(Reg) ->
%% trace control process
%%% LD = idle | {host_pid,timer,consumer,conf}
%%% Conf = {time,flags,rtps,procs,where}
-%%% Where = {term_buffer,{Pid,Count,MaxQueue,MaxSize}} |
+%%% Where = {term_buffer,{Pid,Count,MaxQueue,MaxSize}} |
%%% {term_stream,{Pid,Count,MaxQueue,MaxSize}} |
-%%% {file,File,Size,Count} |
+%%% {file,File,Size,Count} |
%%% {ip,Port,Queue}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init() ->
@@ -64,7 +64,7 @@ init() ->
idle() ->
receive
{start,{HostPid,Conf}} -> ?ACTIVE(start_trace(HostPid,Conf));
- {stop,{HostPid,_}} -> HostPid ! {prfTrc,{not_started,idle,self()}},
+ {stop,{HostPid,_}} -> HostPid ! {prfTrc,{not_started,idle,self()}},
?IDLE();
{'EXIT',_,exiting} -> ?IDLE();
X -> ?log({weird_in,X}), ?IDLE()
@@ -82,14 +82,14 @@ active(LD) ->
{'EXIT',HostPid,_} -> remote_stop(Cons,LD),?WAIT_FOR_LOCAL(Cons);
{local_stop,R} -> local_stop(HostPid,LD,R),?WAIT_FOR_LOCAL(Cons);
{'EXIT',Cons,R} -> local_stop(HostPid,LD,R),?IDLE();
- X -> ?log({weird_in,X}), ?ACTIVE(LD)
+ X -> ?log({weird_in,X}), ?ACTIVE(LD)
end.
wait_for_local(Consumer) when is_pid(Consumer) ->
- receive
+ receive
{'EXIT',Consumer,_} -> ?IDLE();
X -> ?log({weird_in,X}), ?WAIT_FOR_LOCAL(Consumer)
- end.
+ end.
local_stop(HostPid, LD, R) ->
stop_trace(LD),
@@ -116,21 +116,21 @@ maybe_load_rtps(Rtps) ->
lists:foldl(fun maybe_load_rtp/2, [], Rtps).
maybe_load_rtp({{M,F,A},_MatchSpec,_Flags} = Rtp,O) ->
- try
+ try
case code:which(M) of
preloaded -> ok;
non_existing -> throw(non_existing_module);
L when is_list(L) -> [c:l(M) || false == code:is_loaded(M)]
end,
[Rtp|O]
- catch
+ catch
_:R -> ?log({no_such_function,{R,{M,F,A}}}), O
end.
is_message_trace(Flags) ->
(lists:member(send,Flags) orelse lists:member('receive',Flags)).
-start_trace(LD) ->
+start_trace(LD) ->
Conf = fetch(conf,LD),
HostPid = fetch(host_pid,LD),
link(HostPid),
@@ -145,9 +145,9 @@ start_trace(LD) ->
store(consumer,Consumer,LD).
family(Daddy) ->
- try D = whereis(Daddy),
- [D|element(2,process_info(D,links))]
- catch _:_->[]
+ try D = whereis(Daddy),
+ [D|element(2,process_info(D,links))]
+ catch _:_->[]
end.
untrace(Pids,Flags) ->
@@ -165,14 +165,14 @@ unset_tps() ->
set_tps(TPs) ->
foreach(fun set_tps_f/1,TPs).
-set_tps_f({MFA,MatchSpec,Flags}) ->
+set_tps_f({MFA,MatchSpec,Flags}) ->
erlang:trace_pattern(MFA,MatchSpec,Flags).
mk_prc(all) -> all;
mk_prc(Pid) when is_pid(Pid) -> Pid;
mk_prc({pid,P1,P2}) when is_integer(P1), is_integer(P2) -> c:pid(0,P1,P2);
-mk_prc(Reg) when is_atom(Reg) ->
- case whereis(Reg) of
+mk_prc(Reg) when is_atom(Reg) ->
+ case whereis(Reg) of
undefined -> exit({no_such_process, Reg});
Pid when is_pid(Pid) -> Pid
end.
@@ -225,20 +225,20 @@ consumer_ip(Port,QueueSize,Time) ->
spawn_link(fun() -> init_local_port(Conf) end).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%% local consumer process for port-style tracing.
+%%% local consumer process for port-style tracing.
%%% writes trace messages directly to an erlang port.
%%% flushes and quits when;
%%% it gets a stop from the controller
%%% timeout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-init_local_port(Conf) ->
+init_local_port(Conf) ->
erlang:start_timer(fetch(time,Conf),self(),fetch(daddy,Conf)),
Port = mk_port(Conf),
loop_local_port(store(port,Port,Conf)).
loop_local_port(Conf) ->
Daddy = fetch(daddy, Conf),
- receive
+ receive
{show_port,Pid} -> Pid ! fetch(port,Conf),
loop_local_port(Conf);
stop -> dbg:flush_trace_port(),
@@ -250,7 +250,7 @@ loop_local_port(Conf) ->
mk_port(Conf) ->
case fetch(style,Conf) of
- ip ->
+ ip ->
Port = fetch(port_no,Conf),
QueueSize = fetch(queue_size,Conf),
(dbg:trace_port(ip,{Port, QueueSize}))();
@@ -263,7 +263,7 @@ mk_port(Conf) ->
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%% local consumer process for pid-style tracing.
+%%% local consumer process for pid-style tracing.
%%% buffers trace messages, and flushes them when;
%%% it gets a stop from the controller
%%% reaches count=0
@@ -271,10 +271,10 @@ mk_port(Conf) ->
%%% message queue too long
%%% a trace message is too big
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%
+%%
-record(ld,{daddy,where,count,maxqueue,maxsize}).
-init_local_pid(Conf) ->
+init_local_pid(Conf) ->
erlang:start_timer(fetch(time,Conf),self(),fetch(daddy,Conf)),
loop_lp({#ld{daddy=fetch(daddy,Conf),
where=fetch(where,Conf),
@@ -289,7 +289,7 @@ buffering(no) -> no.
loop_lp({LD,Buff,Count}=State) ->
maybe_exit(msg_queue,LD),
maybe_exit(msg_count,{LD,Buff,Count}),
- receive
+ receive
{timeout,_,Daddy} -> Daddy ! {local_stop,timeout},
flush(LD,Buff),exit(timeout);
stop -> flush(LD,Buff),exit(local_done);
@@ -306,14 +306,14 @@ msg(LD,Buff,Count,Item) ->
buff(no,LD,Item) -> send_one(LD,Item),no;
buff(Buff,_LD,Item) -> [Item|Buff].
-maybe_exit(msg_count,{LD,Buff,0}) ->
- flush(LD,Buff),
+maybe_exit(msg_count,{LD,Buff,0}) ->
+ flush(LD,Buff),
exit(msg_count);
maybe_exit(msg_queue,#ld{maxqueue=MQ}) ->
maybe_exit_queue(MQ);
-maybe_exit(msg_size,{#ld{maxsize=MS},{call,_,_,{MFA,B}}}) when is_binary(B)->
+maybe_exit(msg_size,{#ld{maxsize=MS},{call,_,_,{MFA,B}}}) when is_binary(B)->
maybe_exit_call(MS,MFA,B);
-maybe_exit(msg_size,{#ld{maxsize=MS},{call,_,_,MFA}}) ->
+maybe_exit(msg_size,{#ld{maxsize=MS},{call,_,_,MFA}}) ->
maybe_exit_call(MS,MFA,<<>>);
maybe_exit(_,_) -> ok.
@@ -336,15 +336,15 @@ maybe_exit_stack(MS,B) ->
false-> ok
end.
-%% recurse through the args
+%% recurse through the args
%% exit if there is a long list or a large binary
-maybe_exit_args(MS,T) when is_tuple(T) ->
+maybe_exit_args(MS,T) when is_tuple(T) ->
maybe_exit_args(MS,tuple_to_list(T));
-maybe_exit_args(MS,L) when length(L) < MS ->
+maybe_exit_args(MS,L) when length(L) < MS ->
lists:foreach(fun(E)->maybe_exit_args(MS,E)end,L);
-maybe_exit_args(MS,L) when MS =< length(L) ->
+maybe_exit_args(MS,L) when MS =< length(L) ->
exit({arg_length,length(L)});
-maybe_exit_args(MS,B) when MS < byte_size(B) ->
+maybe_exit_args(MS,B) when MS < byte_size(B) ->
exit({arg_size,byte_size(B)});
maybe_exit_args(_,_) ->
ok.
@@ -370,10 +370,10 @@ pi(P) when is_pid(P) ->
end;
{_,Nam} -> Nam;
undefined -> dead
- catch
+ catch
error:badarg -> node(P)
end;
-pi(P) when is_port(P) ->
+pi(P) when is_port(P) ->
{name,N} = erlang:port_info(P,name),
[Hd|_] = string:tokens(N," "),
reverse(hd(string:tokens(reverse(Hd),"/")));
View
70 src/redbug.erl
@@ -2,7 +2,7 @@
%%%-------------------------------------------------------------------
%%% File : redbg.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 24 Jan 2007 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
@@ -26,20 +26,20 @@
-record(cnf,{time = 15000 % ms
, msgs = 10 % unit
, proc = all % list of procs (or 'all')
- , target = node() % target node
- , cookie = '' % target node cookie
- , buffered = no % output buffering
+ , target = node() % target node
+ , cookie = '' % target node cookie
+ , buffered = no % output buffering
, arity = false % arity instead of args
, print_call = true % print calls (see `return_only')
, print_form = "~s~n" % format for printing
- , print_file = "" % file to print to (standard_io)
+ , print_file = "" % file to print to (standard_io)
, print_re = "" % regexp that must match to print
- , max_queue = 5000 % max # of msgs before suicide
- , max_msg_size = 50000 % max message size before suicide
+ , max_queue = 5000 % max # of msgs before suicide
+ , max_msg_size = 50000 % max message size before suicide
, file = "" % file to write trace msgs to
, file_size = 1 % file size (per file [Mb])
, file_count = 8 % number of files in wrap log
-
+
, trc = [] % cannot be set by user
, print_pid = [] % cannot be set by user
, trc_pid = [] % cannot be set by user
@@ -62,7 +62,7 @@ help() ->
, " 'trace messages' when certain events (such as a particular"
, " function being called) occur."
, " The trace messages are either printed (i.e. human readable)"
- , " to a file or to the screen; or written to a trc file."
+ , " to a file or to the screen; or written to a trc file."
, " Using a trc file puts less stress on the system, but"
, " there is no way to count the messages (so the msgs opt"
, " is ignored), and the files can only be read by special tools"
@@ -75,7 +75,7 @@ help() ->
, " the RTP has the form: \"<mfa> when <guards> -> <actions>\""
, " where <mfa> can be;"
, " \"mod\", \"mod:fun\", \"mod:fun/3\" or \"mod:fun('_',atom,X)\""
- , " <guard> is something like;"
+ , " <guard> is something like;"
, " \"X==1\" or \"is_atom(A)\""
, " and <action> is;"
, " \"return\" and/or \"stack\" (separated by \";\")"
@@ -110,7 +110,7 @@ help() ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
unix([Node,Time,Msgs,Trc]) -> unix([Node,Time,Msgs,Trc,"all"]);
unix([Node,Time,Msgs,Trc,Proc]) ->
- try
+ try
Cnf = #cnf{time = to_int(Time),
msgs = to_int(Msgs),
trc = to_term(Trc),
@@ -119,10 +119,10 @@ unix([Node,Time,Msgs,Trc,Proc]) ->
self() ! {start,Cnf},
init(),
maybe_halt(0)
- catch
+ catch
exit:exiting ->
maybe_halt(0);
- C:R ->
+ C:R ->
io:fwrite("~p~n",[{C,R,erlang:get_stacktrace()}]),
maybe_halt(1)
end;
@@ -168,10 +168,10 @@ start(Trc,{Tag,Val}) -> start(Trc, [{Tag,Val}]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
start(Trc,Props) when is_list(Props) ->
case whereis(redbug) of
- undefined ->
+ undefined ->
Cnf = make_cnf(Trc,Props),
assert_cookie(Cnf),
- try
+ try
register(redbug, spawn(fun init/0)),
redbug ! {start,Cnf},
ok
@@ -185,7 +185,7 @@ assert_cookie(#cnf{cookie=''}) -> ok;
assert_cookie(Cnf) -> erlang:set_cookie(Cnf#cnf.target,Cnf#cnf.cookie).
%% turn the proplist inta a #cnf{}
-make_cnf(Trc,Props) ->
+make_cnf(Trc,Props) ->
make_cnf(Props,#cnf{trc=Trc},record_info(fields,cnf)).
make_cnf([],Cnf,_) -> Cnf;
@@ -193,7 +193,7 @@ make_cnf([{Tag,Val}|Props],Cnf,Tags) ->
make_cnf(Props,setelement(findex(Tag,Tags)+1,Cnf,Val),Tags).
findex(Tag,[]) -> exit({field_not_allowed,Tag});
-findex(Tag,[Tag|_]) -> 1;
+findex(Tag,[Tag|_]) -> 1;
findex(Tag,[_|Tags]) -> findex(Tag,Tags)+1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% the main redbug process
@@ -201,11 +201,11 @@ findex(Tag,[_|Tags]) -> findex(Tag,Tags)+1.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init() ->
process_flag(trap_exit,true),
- receive
- {start,Cnf} ->
- try
- starting(do_start(Cnf))
- catch
+ receive
+ {start,Cnf} ->
+ try
+ starting(do_start(Cnf))
+ catch
C:R -> ?log([{C,R},{stack,erlang:get_stacktrace()}])
end
end,
@@ -225,7 +225,7 @@ running(Cnf = #cnf{trc_pid=TrcPid,print_pid=PrintPid}) ->
maybe_alert_printer(Cnf),
receive
{stop,Args} -> prf:config(prf_redbug,prfTrc,{stop,{self(),Args}}),
- stopping(Cnf);
+ stopping(Cnf);
{prfTrc,{stopping,_,_}} -> stopping(Cnf);
{'EXIT',TrcPid,_} -> stopping(Cnf);
{prfTrc,{not_started,R,TrcPid}} -> ?log([{not_started,R}]);
@@ -286,7 +286,7 @@ mk_the_print_fun(Cnf = #cnf{print_re=RE}) ->
end.
get_fd("") -> standard_io;
-get_fd(FN) ->
+get_fd(FN) ->
case file:open(FN,[write]) of
{ok,FD} -> FD;
_ -> exit({cannot_open,FN})
@@ -296,9 +296,9 @@ get_fd(FN) ->
%%% pack the cnf record into a proplist for prf consumption
%%% Proplist = list({Tag,Val})
%%% Tag = time | flags | rtps | procs | where
-%%% Where = {term_buffer,{Pid,Count,MaxQueue,MaxSize}} |
+%%% Where = {term_buffer,{Pid,Count,MaxQueue,MaxSize}} |
%%% {term_stream,{Pid,Count,MaxQueue,MaxSize}} |
-%%% {file,File,Size,Count} |
+%%% {file,File,Size,Count} |
%%% {ip,Port,Queue}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pack(Cnf) ->
@@ -326,7 +326,7 @@ conf_term(Cnf) ->
Cnf#cnf.max_msg_size}}.
maybe_arity(#cnf{arity=true},Flags) -> [arity|Flags];
-maybe_arity(_,Flags) -> Flags.
+maybe_arity(_,Flags) -> Flags.
chk_time(Time) when is_integer(Time) -> Time;
chk_time(X) -> exit({bad_time,X}).
@@ -378,8 +378,8 @@ slist(X) -> [X].
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
printi(PrintFun) ->
- receive
- {trace_consumer,TC} ->
+ receive
+ {trace_consumer,TC} ->
erlang:monitor(process,TC),
printl(PrintFun)
end.
@@ -396,11 +396,11 @@ outer(PrintFun,[Msg|Msgs]) ->
{'call',{MFA,Bin},PI,TS} ->
PrintFun(flat("~n~s <~p> ~p",[ts(TS),PI,MFA])),
foreach(fun(L)->PrintFun(flat(" ~s",[L])) end, stak(Bin));
- {'retn',{MFA,Val},PI,TS} ->
+ {'retn',{MFA,Val},PI,TS} ->
PrintFun(flat("~n~s <~p> ~p -> ~p",[ts(TS),PI,MFA,Val]));
- {'send',{MSG,To},PI,TS} ->
+ {'send',{MSG,To},PI,TS} ->
PrintFun(flat("~n~s <~p> <~p> <<< ~p",[ts(TS),PI,To,MSG]));
- {'recv',MSG,PI,TS} ->
+ {'recv',MSG,PI,TS} ->
PrintFun(flat("~n~s <~p> <<< ~p",[ts(TS),PI,MSG]));
_ ->
PrintFun(flat("~n~p", [Msg]))
@@ -418,9 +418,9 @@ stak(Bin) ->
munge(I,Out) ->
case reverse(I) of
"..."++_ -> [truncated|Out];
- _ ->
+ _ ->
case string:str(I, "Return addr") of
- 0 ->
+ 0 ->
case string:str(I, "cp = ") of
0 -> Out;
_ -> [mfaf(I)|Out]
@@ -441,7 +441,7 @@ to_int(L) -> list_to_integer(L).
to_atom(L) -> list_to_atom(L).
to_term("_") -> '_';
-to_term(Str) ->
+to_term(Str) ->
{done, {ok, Toks, 1}, []} = erl_scan:tokens([], "["++Str++"]. ", 1),
case erl_parse:parse_term(Toks) of
{ok, [Term]} -> Term;
View
2  src/redbugConsumer.erl
@@ -1,7 +1,7 @@
%%%-------------------------------------------------------------------
%%% File : redbugConsumer.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
-%%% Description :
+%%% Description :
%%%
%%% Created : 23 Jan 2007 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
View
20 src/redbug_msc.erl
@@ -78,15 +78,15 @@ ca_fun({list,Es},{Vars,O}) ->
ca_fun({tuple,Es},{Vars,O}) ->
{Vs,Ps} = ca_fun_list(Es,Vars),
{Vs,O++[list_to_tuple(Ps)]};
-ca_fun({var,'_'},{Vars,O}) ->
+ca_fun({var,'_'},{Vars,O}) ->
{Vars,O++['_']};
-ca_fun({var,Var},{Vars,O}) ->
+ca_fun({var,Var},{Vars,O}) ->
case proplists:get_value(Var,Vars) of
undefined -> V = list_to_atom("\$"++integer_to_list(length(Vars)+1));
V -> ok
end,
{[{Var,V}|Vars],O++[V]};
-ca_fun({Type,Val},{Vars,O}) ->
+ca_fun({Type,Val},{Vars,O}) ->
assert_type(Type,Val),
{Vars,O++[Val]}.
@@ -97,14 +97,14 @@ ca_fun_list(Es,Vars) ->
{Vars,[]},
Es).
-assert_type(Type,Val) ->
+assert_type(Type,Val) ->
case lists:member(Type,[integer,atom,string]) of
true -> ok;
false-> exit({bad_type,{Type,Val}})
end.
-
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% parser
+%% parser
%% accepts strings like;
%% "a","a:b","a:b/2","a:b(X,y)",
%% "a:b(X,Y)when is_record(X,rec) and Y==0, (X==z)"
@@ -155,11 +155,11 @@ body_fun(Str) ->
end