%%% File : dump_dbg.erl %%% Author : Chandrashekhar Mullaparthi %%% Description : %%% Created : 7 Jan 2009 by Chandrashekhar Mullaparthi -module(dump_dbg). -vsn('$Id: $ '). -url('$URL: $ '). -export([go/1]). -include_lib("kernel/include/file.hrl"). go(File) -> io:format("Trying to dump contents of ~s~n", [File]), case file:read_file_info(File) of {ok, #file_info{type = regular}} -> decode_dbg_file(File); Err -> io:format("~s not accessible: ~p~n", [File, Err]), ok end. decode_dbg_file(File) -> Outputfile = File ++ ".txt", Tid = ets:new(dump_dbg, [ordered_set, public]), Fun = fun(Msg, Acc) -> ets:insert(Tid, {now(), Msg}), Acc + 1 end, dbg:trace_client(file, File, {Fun, 0}), {ok, Iod} = file:open(Outputfile, [write, raw]), ets:foldl(fun({_, Msg}, Acc) -> Msg_1 = io_lib:format("~1000.p~n", [Msg]), file:write(Iod, Msg_1), Acc end, 0, Tid), file:close(Iod), ets:delete(Tid), io:format("Done~n", []).