<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi,<div><br></div><div>I took it on myself to write a little module. This will produce a crash report that will display most of the important data that can be loaded into the crash dump viewer. From Erlang run report:crash_report(). <div><br></div><div>The crash dump goes to /tmp/erl_crash.dump and can be viewed from Erlang via your browser when you run crashdump_viewer:start(). from your Erlang shell.</div><div><br></div><div>=========<br><div><br></div><div><div><div>-module(report).</div><div><br></div><div>-export([crash_report/0]).</div><div><br></div><div>crash_report() -></div><div>    Date = erlang:list_to_binary(rfc1123_local_date()),</div><div>    Header = binary:list_to_bin([<<"=erl_crash_dump:0.2\n">>,Date,<<"\nSystem version: ">>]),</div><div>    Ets = ets_info(),</div><div>    Report = binary:list_to_bin([Header,erlang:list_to_binary(erlang:system_info(system_version)),erlang:system_info(info),erlang:system_info(procs),Ets,erlang:system_info(dist),</div><div>                <<"=loaded_modules\n">>,binary:replace(erlang:system_info(loaded),<<"\n">>,<<"\n=mod:">>,[global])]),</div><div>    file:write_file("/tmp/erl_crash.dump",Report).</div><div><br></div><div>ets_info() -></div><div>    binary:list_to_bin([ets_table_info(T)||T<-ets:all()]).</div><div><br></div><div>ets_table_info(Table) -></div><div>    Info = ets:info(Table),</div><div>    Owner = erlang:list_to_binary(erlang:pid_to_list(proplists:get_value(owner,Info))),</div><div>    TableN = erlang:list_to_binary(erlang:atom_to_list(proplists:get_value(name,Info))),</div><div>    Name = erlang:list_to_binary(erlang:atom_to_list(proplists:get_value(name,Info))),</div><div>    Objects = erlang:list_to_binary(erlang:integer_to_list(proplists:get_value(size,Info))),</div><div>    binary:list_to_bin([<<"=ets:">>,Owner,<<"\nTable: ">>,TableN,<<"\nName: ">>,Name,<<"\nObjects: ">>,Objects,<<"\n">>]).</div><div><br></div><div>rfc1123_local_date() -></div><div>    rfc1123_local_date(os:timestamp()).</div><div>rfc1123_local_date({A,B,C}) -></div><div>    rfc1123_local_date(calendar:now_to_local_time({A,B,C}));</div><div>rfc1123_local_date({{YYYY,MM,DD},{Hour,Min,Sec}}) -></div><div>    DayNumber = calendar:day_of_the_week({YYYY,MM,DD}),</div><div>    lists:flatten(</div><div>        io_lib:format("~s, ~2.2.0w ~3.s ~4.4.0w ~2.2.0w:~2.2.0w:~2.2.0w GMT",</div><div>            [httpd_util:day(DayNumber),DD,httpd_util:month(MM),YYYY,Hour,Min,Sec]));</div><div>rfc1123_local_date(Epoch) when erlang:is_integer(Epoch) -></div><div>    rfc1123_local_date(calendar:gregorian_seconds_to_datetime(Epoch+62167219200)).</div></div><div><br></div><br><div><hr id="stopSpelling">From: vladdu55@gmail.com<br>Date: Thu, 20 Feb 2014 10:30:39 +0100<br>To: mabrek@gmail.com<br>CC: erlang-questions@erlang.org<br>Subject: Re: [erlang-questions] Creating a diagnostic memory dump of live erlang VM<br><br><div dir="ltr"><div class="ecxgmail_extra"><div class="ecxgmail_quote">Hi,</div><div class="ecxgmail_quote"><br></div><div class="ecxgmail_quote">On Thu, Feb 20, 2014 at 9:26 AM, Anton Lebedevich <span dir="ltr"><<a href="mailto:mabrek@gmail.com" target="_blank">mabrek@gmail.com</a>></span> wrote:<br>

<blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;"><div>Another thing which I missed a lot after converting from java to erlang<br></div>
is a thread dump. It turned out that it's possible to get all<br>
stacktraces for all processes (even with function arguments) via<br>
erlang:system_info(procs).<br>
<br>
It returns them as text so it's better to dump it to file immediately:<br>
file:write_file("/tmp/procs.txt",erlang:system_info(procs)).<br>
<br>
Format of these traces is quite interesting (undocumented) the best<br>
description I found is in the mailing list<br>
<a href="http://erlang.org/pipermail/erlang-questions/2012-November/070609.html" target="_blank">http://erlang.org/pipermail/erlang-questions/2012-November/070609.html</a></blockquote><div><br></div><div>I might just as well ask the obvious question: why is not this information available even as normal Erlang terms, so that one doesn't need to parse it? When writing a crash dump, it doesn't matter, but if it should be used at runtime it's a pain to parse it... This applies to the other results from system_info/1 that are dumped as text.</div>

<div><br></div><div>regards,</div><div>Vlad</div><div><br></div></div></div></div>
<br>_______________________________________________
erlang-questions mailing list
erlang-questions@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions</div></div></div></div>                                       </div></body>
</html>