diff options
author | Dan Gudmundsson <[email protected]> | 2013-11-19 11:00:32 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2014-01-27 16:13:57 +0100 |
commit | 5a30dd40a691d610def7b1f00cf39ed0d78eb900 (patch) | |
tree | a9f607e6f972be384b6dbc8f230b85142824da87 /lib/observer/src/cdv_term_wx.erl | |
parent | cf20035dc7a4fbab47ce17b99b674e4db5eb7a07 (diff) | |
download | otp-5a30dd40a691d610def7b1f00cf39ed0d78eb900.tar.gz otp-5a30dd40a691d610def7b1f00cf39ed0d78eb900.tar.bz2 otp-5a30dd40a691d610def7b1f00cf39ed0d78eb900.zip |
observer: Use crashdump_viewer's term viewer to display large terms and binaries
Diffstat (limited to 'lib/observer/src/cdv_term_wx.erl')
-rw-r--r-- | lib/observer/src/cdv_term_wx.erl | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/lib/observer/src/cdv_term_wx.erl b/lib/observer/src/cdv_term_wx.erl index e029a75b29..9b83249eae 100644 --- a/lib/observer/src/cdv_term_wx.erl +++ b/lib/observer/src/cdv_term_wx.erl @@ -21,26 +21,28 @@ detail_pages/0]). %% Callbacks for cdv_detail_win -get_details({T,Key}) -> +get_details({_, {T,Key}}) -> [{Key,Term}] = ets:lookup(T,Key), - {ok,{"Expanded Term", Term, []}}. + {ok,{"Expanded Term", [Term, T], []}}. detail_pages() -> [{"Term", fun init_term_page/2}]. -init_term_page(ParentWin, Term) -> +init_term_page(ParentWin, [Term, Tab]) -> + Expanded = expand(Term, true), + BinSaved = expand(Term, Tab), cdv_multi_panel:start_link( ParentWin, - [{"Format \~p",cdv_html_page,format_term_fun("~p",Term)}, - {"Format \~tp",cdv_html_page,format_term_fun("~tp",Term)}, - {"Format \~w",cdv_html_page,format_term_fun("~w",Term)}, - {"Format \~s",cdv_html_page,format_term_fun("~s",expand(Term))}, - {"Format \~ts",cdv_html_page,format_term_fun("~ts",expand(Term))}]). + [{"Format \~p",cdv_html_page,format_term_fun("~p",BinSaved,Tab)}, + {"Format \~tp",cdv_html_page,format_term_fun("~tp",BinSaved,Tab)}, + {"Format \~w",cdv_html_page,format_term_fun("~w",BinSaved,Tab)}, + {"Format \~s",cdv_html_page,format_term_fun("~s",Expanded,Tab)}, + {"Format \~ts",cdv_html_page,format_term_fun("~ts",Expanded,Tab)}]). -format_term_fun(Format,Term) -> +format_term_fun(Format,Term,Tab) -> fun() -> try io_lib:format(Format,[Term]) of - Str -> plain_html(Str) + Str -> {expand, plain_html(Str), Tab} catch error:badarg -> Warning = "This term can not be formatted with " ++ Format, crashdump_viewer_html:warning(Warning) @@ -50,17 +52,24 @@ format_term_fun(Format,Term) -> plain_html(Text) -> crashdump_viewer_html:plain_page(Text). -expand(['#CDVBin',Offset,Size,Pos]) -> +expand(['#CDVBin',Offset,Size,Pos], true) -> {ok,Bin} = crashdump_viewer:expand_binary({Offset,Size,Pos}), Bin; -expand([H|T]) -> - case expand(T) of +expand(Bin, Tab) when is_binary(Bin), not is_boolean(Tab) -> + <<Preview:80, _/binary>> = Bin, + Size = byte_size(Bin), + Hash = erlang:phash2(Bin), + Key = {Preview, Size, Hash}, + ets:insert(Tab, {Key,Bin}), + ['#OBSBin',Preview,Size,Hash]; +expand([H|T], Expand) -> + case expand(T, Expand) of ET when is_list(ET) -> - [expand(H)|ET]; + [expand(H, Expand)|ET]; ET -> % The tail is an expanded binary - cannot append with | - [expand(H),ET] + [expand(H, Expand),ET] end; -expand(Tuple) when is_tuple(Tuple) -> - list_to_tuple(expand(tuple_to_list(Tuple))); -expand(Term) -> +expand(Tuple, Expand) when is_tuple(Tuple) -> + list_to_tuple(expand(tuple_to_list(Tuple), Expand)); +expand(Term, _) -> Term. |