diff options
author | Siri Hansen <[email protected]> | 2013-07-11 11:27:29 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2014-01-27 15:52:52 +0100 |
commit | e2d565532d25024c1c0552d8eaaddf90eed88629 (patch) | |
tree | ca6f09ddf4bde35b10868746f4ee2a33e3edea7e /lib/observer/src/cdv_mem_wx.erl | |
parent | 7d4e5e2458e0627882f49078b9757dd6ae21a6fe (diff) | |
download | otp-e2d565532d25024c1c0552d8eaaddf90eed88629.tar.gz otp-e2d565532d25024c1c0552d8eaaddf90eed88629.tar.bz2 otp-e2d565532d25024c1c0552d8eaaddf90eed88629.zip |
observer: add wx version of crashdump_viewer
The old web base crashdump_viewer is now removed.
Diffstat (limited to 'lib/observer/src/cdv_mem_wx.erl')
-rw-r--r-- | lib/observer/src/cdv_mem_wx.erl | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/observer/src/cdv_mem_wx.erl b/lib/observer/src/cdv_mem_wx.erl new file mode 100644 index 0000000000..413c7de761 --- /dev/null +++ b/lib/observer/src/cdv_mem_wx.erl @@ -0,0 +1,78 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2011-2013. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +-module(cdv_mem_wx). + +-export([get_info/0]). + +-include("crashdump_viewer.hrl"). +-include_lib("wx/include/wx.hrl"). + +get_info() -> + {AllocInfo,AllocTW} = get_alloc_info(), + [{"Memory",cdv_info_page,get_mem_info()} + | [{Title,cdv_table_page,{Cols,Data,AllocTW}} || + {Title,Cols,Data} <- AllocInfo]] ++ + [{"Allocated Areas",cdv_table_page,get_area_info()}]. + + +%%%----------------------------------------------------------------- +%%% Memory page +get_mem_info() -> + {ok,Info,TW} = crashdump_viewer:memory(), + {[{"Memory Information",gen_mem_info_fields(Info)}],Info,TW}. + +gen_mem_info_fields([{Key,_}|T]) -> + [{upper(atom_to_list(Key)),{bytes,Key}}|gen_mem_info_fields(T)]; +gen_mem_info_fields([]) -> + []. + +upper(Key) -> + string:join([string:to_upper([H]) ++ T || + [H|T] <- string:tokens(Key,"_")]," "). + + +%%%----------------------------------------------------------------- +%%% Allocated areas page +get_area_info() -> + {ok,Info0,TW} = crashdump_viewer:allocated_areas(), + Info = [tuple_to_list(R) || R <- Info0], + {area_columns(),Info,TW}. + +area_columns() -> + [{"", ?wxLIST_FORMAT_LEFT, 150}, + {"Allocated (bytes)",?wxLIST_FORMAT_RIGHT, 150}, + {"Used (bytes)", ?wxLIST_FORMAT_RIGHT, 150}]. + +%%%----------------------------------------------------------------- +%%% Allocator page +get_alloc_info() -> + {ok,Info,TW} = crashdump_viewer:allocator_info(), + {fix_alloc(Info),TW}. + +fix_alloc([{Title,Columns,Data}|Tables]) -> + [{Title,alloc_columns(Columns), + [[Key|Values] || {Key,Values} <- Data]} | + fix_alloc(Tables)]; +fix_alloc([{Title,[{_,V}|_]=Data}|Tables]) -> + fix_alloc([{Title,lists:duplicate(length(V),[]),Data}|Tables]); +fix_alloc([]) -> + []. + +alloc_columns(Columns) -> + [{"", ?wxLIST_FORMAT_LEFT, 200} | + [{Column, ?wxLIST_FORMAT_RIGHT, 150} || Column <- Columns]]. |