aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src/observer_pro_wx.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2011-11-24 12:54:13 +0100
committerDan Gudmundsson <[email protected]>2011-11-24 12:54:13 +0100
commitd7eaea0d44fac1f0c67d67c188d6a635b0a4da4c (patch)
tree29acee8c984b45dc674bacc5191b5d6724bf4f55 /lib/observer/src/observer_pro_wx.erl
parentfcda85751547c4dbcea92f1142186ec9d571ba82 (diff)
downloadotp-d7eaea0d44fac1f0c67d67c188d6a635b0a4da4c.tar.gz
otp-d7eaea0d44fac1f0c67d67c188d6a635b0a4da4c.tar.bz2
otp-d7eaea0d44fac1f0c67d67c188d6a635b0a4da4c.zip
[observer] Add more trace functionality
Add logging output options, to file, shell or log-window. Add remove/change process options, trace patterns via right-click. Show traced nodes. Add possibility to add named processes, which will be traced on all nodes. Add menu to log window
Diffstat (limited to 'lib/observer/src/observer_pro_wx.erl')
-rw-r--r--lib/observer/src/observer_pro_wx.erl52
1 files changed, 42 insertions, 10 deletions
diff --git a/lib/observer/src/observer_pro_wx.erl b/lib/observer/src/observer_pro_wx.erl
index 3738bdba65..77f454ab21 100644
--- a/lib/observer/src/observer_pro_wx.erl
+++ b/lib/observer/src/observer_pro_wx.erl
@@ -44,10 +44,17 @@
-define(ID_REFRESH, 203).
-define(ID_REFRESH_INTERVAL, 204).
-define(ID_DUMP_TO_FILE, 205).
--define(ID_TRACEMENU, 206).
--define(ID_TRACE_ALL_MENU, 207).
--define(ID_TRACE_NEW_MENU, 208).
--define(ID_ACCUMULATE, 209).
+-define(ID_TRACE_PIDS, 206).
+-define(ID_TRACE_NAMES, 207).
+-define(ID_TRACE_NEW, 208).
+-define(ID_TRACE_ALL, 209).
+-define(ID_ACCUMULATE, 210).
+
+-define(TRACE_PIDS_STR, "Trace selected process identifiers").
+-define(TRACE_NAMES_STR, "Trace selected processes, "
+ "if a process have a registered name "
+ "processes with same name will be traced on all nodes").
+
%% Records
@@ -121,8 +128,9 @@ create_pro_menu(Parent, Holder) ->
#create_menu{id=?ID_REFRESH, text="Refresh\tCtrl-R"},
#create_menu{id=?ID_REFRESH_INTERVAL, text="Refresh Interval"}]},
{"Trace",
- [#create_menu{id=?ID_TRACEMENU, text="Trace selected processes"},
- #create_menu{id=?ID_TRACE_NEW_MENU, text="Trace new processes"}
+ [#create_menu{id=?ID_TRACE_PIDS, text="Trace processes"},
+ #create_menu{id=?ID_TRACE_NAMES, text="Trace named processes (all nodes)"},
+ #create_menu{id=?ID_TRACE_NEW, text="Trace new processes"}
%% , #create_menu{id=?ID_TRACE_ALL_MENU, text="Trace all processes"}
]}
],
@@ -300,7 +308,7 @@ handle_event(#wx{id=?ID_PROC},
Opened2 = start_procinfo(Pid, Panel, Opened),
{noreply, State#state{procinfo_menu_pids=Opened2}};
-handle_event(#wx{id=?ID_TRACEMENU}, #state{sel={_, Pids}, panel=Panel}=State) ->
+handle_event(#wx{id=?ID_TRACE_PIDS}, #state{sel={_, Pids}, panel=Panel}=State) ->
case Pids of
[] ->
observer_wx:create_txt_dialog(Panel, "No selected processes", "Tracer", ?wxICON_EXCLAMATION),
@@ -310,7 +318,18 @@ handle_event(#wx{id=?ID_TRACEMENU}, #state{sel={_, Pids}, panel=Panel}=State) -
{noreply, State}
end;
-handle_event(#wx{id=?ID_TRACE_NEW_MENU, event=#wxCommand{type=command_menu_selected}}, State) ->
+handle_event(#wx{id=?ID_TRACE_NAMES}, #state{sel={SelIds,_Pids}, holder=Holder, panel=Panel}=State) ->
+ case SelIds of
+ [] ->
+ observer_wx:create_txt_dialog(Panel, "No selected processes", "Tracer", ?wxICON_EXCLAMATION),
+ {noreply, State};
+ _ ->
+ PidsOrReg = call(Holder, {get_name_or_pid, self(), SelIds}),
+ observer_trace_wx:add_processes(observer_wx:get_tracer(), PidsOrReg),
+ {noreply, State}
+ end;
+
+handle_event(#wx{id=?ID_TRACE_NEW, event=#wxCommand{type=command_menu_selected}}, State) ->
observer_trace_wx:add_processes(observer_wx:get_tracer(), [new]),
{noreply, State};
@@ -336,8 +355,10 @@ handle_event(#wx{event=#wxList{type=command_list_item_right_click,
{ok, _} ->
Menu = wxMenu:new(),
wxMenu:append(Menu, ?ID_PROC, "Process info"),
- wxMenu:append(Menu, ?ID_TRACEMENU, "Trace selected"),
- wxMenu:append(Menu, ?ID_TRACEMENU, "Kill Process"),
+ wxMenu:append(Menu, ?ID_TRACE_PIDS, "Trace processes", [{help, ?TRACE_PIDS_STR}]),
+ wxMenu:append(Menu, ?ID_TRACE_NAMES, "Trace named processes (all nodes)",
+ [{help, ?TRACE_NAMES_STR}]),
+ wxMenu:append(Menu, ?ID_KILL, "Kill Process"),
wxWindow:popupMenu(Panel, Menu),
wxMenu:destroy(Menu)
end,
@@ -452,6 +473,9 @@ table_holder(#holder{info=#etop_info{procinfo=Info}, attrs=Attrs,
{get_rows_from_pids, From, Pids} ->
get_rows_from_pids(From, Pids, Info),
table_holder(S0);
+ {get_name_or_pid, From, Indices} ->
+ get_name_or_pid(From, Indices, Info),
+ table_holder(S0);
{get_node, From} ->
From ! {self(), Node},
@@ -537,6 +561,14 @@ get_pids(From, Indices, ProcInfo) ->
Processes = [(lists:nth(I+1, ProcInfo))#etop_proc_info.pid || I <- Indices],
From ! {self(), Processes}.
+get_name_or_pid(From, Indices, ProcInfo) ->
+ Get = fun(#etop_proc_info{name=Name}) when is_atom(Name) -> Name;
+ (#etop_proc_info{pid=Pid}) -> Pid
+ end,
+ Processes = [Get(lists:nth(I+1, ProcInfo)) || I <- Indices],
+ From ! {self(), Processes}.
+
+
get_row(From, Row, pid, Info) ->
Pid = case Row =:= -1 of
true -> {error, undefined};