Skip to content

Commit

Permalink
changed the file structure to the traditional src/ebin/priv etc.
Browse files Browse the repository at this point in the history
  fixed a bug in sherk_ets:f2t


git-svn-id: https://eper.googlecode.com/svn/trunk@76 5f96f306-4121-0410-aeb0-fb9935354dc2
  • Loading branch information
massemanet committed May 17, 2007
1 parent eaeb39e commit 4b7cf8b
Show file tree
Hide file tree
Showing 44 changed files with 124 additions and 106 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
2007-05-17 Mats Cronqvist <locmacr@mwlx084>

* src/sherk_ets.erl:
f2t/1 (file2tab) was broken...

2007-05-10 Mats Cronqvist <locmacr@mwlx084>

* redbug/redbug.erl:
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
@@ -1,4 +1,4 @@
SUBDIRS = dtop gperf ntop prf redbug sherk
SUBDIRS = src bin

clean-local:
-find . -name "*~" -exec rm {} \;
4 changes: 4 additions & 0 deletions bin/Makefile.am
@@ -0,0 +1,4 @@
bindir = $(ERLANG_INSTALL_LIB_DIR_eper)/priv/bin
dist_bin_SCRIPTS = dtop gperf gperf ntop redbug sherk

EXTRA_DIST = $(dist_bin_SCRIPTS)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 3 additions & 7 deletions configure.ac
@@ -1,4 +1,4 @@
AC_INIT(Various Erlang performance related tools, 0.34,
AC_INIT(Various Erlang performance related tools, 0.35,
mats.cronqvist@ericsson.com, eper)
dnl Require autoconf version >=2.59c. first one with erlang macros
AC_PREREQ(2.59c)
Expand Down Expand Up @@ -36,12 +36,8 @@ AC_SUBST([GTKDOCLINKS], [$_gtkdoclinks])
dnl Specify the files to instantiate.
AC_CONFIG_FILES([ \
Makefile \
dtop/Makefile \
gperf/Makefile \
ntop/Makefile \
prf/Makefile \
redbug/Makefile \
sherk/Makefile \
src/Makefile \
bin/Makefile \
])

AC_OUTPUT
File renamed without changes.
17 changes: 0 additions & 17 deletions dtop/Makefile.am

This file was deleted.

20 changes: 0 additions & 20 deletions gperf/Makefile.am

This file was deleted.

47 changes: 0 additions & 47 deletions sherk/sherk_tab.erl

This file was deleted.

32 changes: 32 additions & 0 deletions src/Makefile.am
@@ -0,0 +1,32 @@
erlsrcdir = $(ERLANG_INSTALL_LIB_DIR_eper)/src

erlsrc_DATA = ntop.erl ntopConsumer.erl \
dtop.erl dtopConsumer.erl \
gperf.erl gperfConsumer.erl gperfGtk.erl \
gperf.erl gperfConsumer.erl gperfGtk.erl \
prfNet.erl prfSys.erl prfPrc.erl prfTrc.erl \
prf.erl prfHost.erl prfTarg.erl prfClient.erl \
prfNet.erl prfSys.erl prfPrc.erl prfTrc.erl \
prf.erl prfHost.erl prfTarg.erl prfClient.erl \
prfNet.erl prfSys.erl prfPrc.erl prfTrc.erl \
prf.erl prfHost.erl prfTarg.erl prfClient.erl \
redbug.erl redbugConsumer.erl \
sherk.erl sherk_tab.erl sherk_prof.erl \
sherk_tree.erl sherk_list.erl sherk_scan.erl sherk_aquire.erl \
sherk_target.erl sherk_ets.erl

gladedir = $(ERLANG_INSTALL_LIB_DIR_eper)/priv/glade
glade_DATA = gperf.gladep gperf.glade \
sherk.gladep sherk.glade

erlbeamdir = $(ERLANG_INSTALL_LIB_DIR_eper)/ebin
erlbeam_DATA = $(patsubst %.erl, %.beam, $(erlsrc_DATA))

EXTRA_DIST = $(erlsrc_DATA)
CLEANFILES = $(erlbeam_DATA)

all: $(erlbeam_DATA)

%.beam: %.erl
echo $(PWD)
$(ERLC) $(ERLCFLAGS) $<
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions redbug/redbug.erl → src/redbug.erl
Expand Up @@ -61,8 +61,6 @@ start(X) ->
io:fwrite("bad args: ~p~n",[X]),
erlang:halt(1).

start(Time,Msgs,Trc) -> start(Time,Msgs,Trc,all).

start(Time,Msgs,Trc) -> go(Time,Msgs,Trc,#cnf{}).

start(Time,Msgs,Trc,Proc) -> go(Time,Msgs,Trc,#cnf{proc=Proc}).
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 24 additions & 12 deletions sherk/sherk_ets.erl → src/sherk_ets.erl
Expand Up @@ -59,21 +59,26 @@ lup(Tab, Key) ->
%% tab2file/2 and file2tab/1 replacements
%% stores multiple tabs in compressed files

%% file format is;
%% <<TabInfoSize:32/integer>>,<<TabInfo:TabInfoSize/binary>>,
%% [<<ObjectSize:32/integer>>,<<Object:ObjectSize/binary>>,...]
%% <<0:32/integer>>

t2f(Tabs, File) when is_list(Tabs) ->
case file:open(File,[write,compressed,raw,binary]) of
{error,R} ->
exit({error_opening,R,File});
{ok,FD} ->
try t2f(Tabs,FD,0)
after file:close(FD)
end
after file:close(FD)
end
end.

t2f([],_FD,N) -> N;
t2f([Tab|Tabs],FD,N) ->
file:write(FD,<<0:32/integer>>),
t2f_f(make_info(Tab),FD),
ets:foldl(fun t2f_f/2,FD,Tab),
file:write(FD,<<0:32/integer>>),
t2f(Tabs,FD,N+1).

make_info(Tab) ->
Expand All @@ -95,7 +100,7 @@ f2t(File) ->
{error,R} ->
exit({error_opening,R,File});
{ok,FD} ->
try f2t_f(FD), do_tabs(f2t_f(FD),FD,[])
try do_tabs(get_tab_header(FD),FD,[])
after file:close(FD)
end
end.
Expand All @@ -105,26 +110,33 @@ do_tabs(eof,_FD,O) ->
do_tabs({Name,Opts},FD,O) ->
new(Name,Opts),
Cnt = f2t(FD,Name,0),
do_tabs(f2t_f(FD),FD,[{Name,Cnt}|O]).
do_tabs(get_tab_header(FD),FD,[{Name,Cnt}|O]).

get_tab_header(FD) ->
try f2t_f(FD)
catch
throw:eof -> eof;
_:X -> exit({bad_header,X})
end.


f2t(FD,Tab,N) ->
try
ets:insert(Tab,f2t_f(FD)),
f2t(FD,Tab,N+1)
catch
throw:eof -> N;
throw:bot -> N
throw:delimiter -> N;
throw:eof -> exit({unexpected_eof})
end.

f2t_f(FD) ->
case file:read(FD,4) of
{ok,<<0:32/integer>>} -> throw(bot);
eof -> throw(eof);
{ok,<<0:32/integer>>} -> throw(delimiter);
{ok,<<Size:32/integer>>} ->
case file:read(FD,Size) of
{ok,Bin} -> binary_to_term(Bin);
{error,R} -> exit({error_reading,R});
eof -> exit({unexpected_eof})
R -> exit({error_reading_term,R})
end;
eof -> throw(eof);
{error,R} -> exit({error_reading,R})
R -> exit({error_reading_size,R})
end.
File renamed without changes.
File renamed without changes.
File renamed without changes.
55 changes: 55 additions & 0 deletions src/sherk_tab.erl
@@ -0,0 +1,55 @@
%%%-------------------------------------------------------------------
%%% File : sherk_tab.erl
%%% Author : Mats Cronqvist <locmacr@mwlx084>
%%% Description :
%%%
%%% Created : 21 Aug 2006 by Mats Cronqvist <locmacr@mwlx084>
%%%-------------------------------------------------------------------
-module(sherk_tab).

-export([assert/1,check_file/1]).

-import(filename,[dirname/1,join/1,basename/2]).

-include_lib("kernel/include/file.hrl").

-define(LOG(T), sherk:log(process_info(self()),T)).

assert(File) ->
TabFile = dirname(File)++"/."++basename(File,".trz")++".etz",
{ok,#file_info{mtime=MT}} = file:read_file_info(File),
case file:read_file_info(TabFile) of
{ok,#file_info{mtime=TabMT}} when MT < TabMT ->
%% the tab file exists and is up-to-date
case sherk_ets:lup(sherk_prof, file) of
File -> ?LOG({is_cached,TabFile});
_ ->
?LOG(restoring_tab),
try sherk_ets:f2t(TabFile)
catch
_:X ->
?LOG({deleting_bad_tab_file,X}),
file:delete(TabFile),
assert(File)
end
end;
_ ->
%% make tab and save it
?LOG([creating_tab]),
sherk_scan:go(File,'',sherk_prof,0,''),
ets:insert(sherk_prof, {file, File}),
try
?LOG(storing_tab),
sherk_ets:t2f([sherk_prof,sherk_scan],TabFile)
catch
_:_ -> ?LOG({creation_failed,TabFile})
end
end,
?LOG([folding_pids]),
ets:foldl(fun store_pid/2, [], sherk_prof),
?LOG([done]).

store_pid({{{pid,time},P},_},_) -> ets:insert(sherk_prof,{sherk:to_str(P),P});
store_pid(_,_) -> ok.

check_file(File) -> ".trz" = filename:extension(File).
File renamed without changes.
File renamed without changes.

0 comments on commit 4b7cf8b

Please sign in to comment.