83
83
{Window, Grid,Frame, Visible} =
84
84
pman_win:pman_window(Grid_size, OSModuleExcluded, LINode),
86
Noshell = case pman_shell:find_shell() of
87
91
Pman_data = #gs_pman{win=Window, grid=Grid, frame=Frame,
153
158
%% ---------------------------------------------------------------
155
160
update_nodes_menu(Pman_data) ->
156
OSNodesNew = ordsets:list_to_set(get_nodes()),
157
OSNodesOld = ordsets:list_to_set(Pman_data#gs_pman.nodes),
161
OSNodesNew = ordsets:from_list(get_nodes()),
162
OSNodesOld = ordsets:from_list(Pman_data#gs_pman.nodes),
159
164
OSNodesAdd = ordsets:subtract(OSNodesNew,OSNodesOld),
160
165
OSNodesDelete = ordsets:subtract(OSNodesOld,OSNodesNew),
180
185
%% Returnd: New position Int
181
186
%% ---------------------------------------------------------------
183
check_focus_choice(To, 0) -> 1;
188
check_focus_choice(_To, 0) -> 1;
184
189
check_focus_choice(0, Size) -> Size;
185
190
check_focus_choice(To, Size) ->
201
206
get_pos([], _, _) ->
204
get_pos([Element | Rest], Element, Count) ->
209
get_pos([Element | _Rest], Element, Count) ->
207
212
get_pos([_ | Rest], Element, Count) ->
334
339
%% New processes however, will be covered by the filters.
337
execute_cmd('Show All',Pman_data,Data,Args) ->
342
execute_cmd('Show All',Pman_data,_Data,_Args) ->
339
344
OSPidAll = pman_process:r_processes(Pman_data#gs_pman.node),
350
355
%% Open a list of not shown (hidden + new + system) processes (PIDS)
351
356
%% where the user can select which processes shall be shown.
353
execute_cmd('Show Selected',Pman_data,Data,Args) ->
358
execute_cmd('Show Selected',Pman_data,_Data,_Args) ->
355
360
%% Open a dialog with a list of all PIDs that are not currently shown
356
361
OSPidAll = pman_process:r_processes(Pman_data#gs_pman.node),
399
404
%% Add the selected PIDs from the dialog to the list
400
405
%% of explicitly shown PIDs
401
406
OSPidShown = ordsets:union(Pman_data#gs_pman.show_pids,
402
ordsets:list_to_set(List2)),
407
ordsets:from_list(List2)),
403
408
New_Pman_data = Pman_data#gs_pman{show_pids = OSPidShown},
405
410
%% Refresh the list of PIDs
414
419
%% Start Help window
416
execute_cmd('Help',Pman_data,Data,Args) ->
417
HelpFile = filename:join(code:priv_dir(pman), "../doc/index.html"),
421
execute_cmd('Help',Pman_data,_Data,_Args) ->
422
HelpFile = filename:join([code:lib_dir(pman), "doc", "html", "index.html"]),
418
423
tool_utils:open_help(gse:start([{kernel, true}]), HelpFile),
422
427
%% Trace the shell
424
execute_cmd('Trace Shell',Pman_data,Data,Args) ->
425
Shell = pman_shell:find_shell(),
426
pman_shell:start({{shell,Shell},self()},Pman_data#gs_pman.options),
429
execute_cmd('Trace Shell',Pman_data,_Data,_Args) ->
430
case pman_shell:find_shell() of
434
pman_shell:start({{shell,Shell},self()},Pman_data#gs_pman.options),
435
Pman_data#gs_pman{noshell = false}
431
439
%% Start Trace Window
433
execute_cmd('Trace Process',Pman_data,Data,Args) ->
441
execute_cmd('Trace Process',Pman_data,_Data,_Args) ->
434
442
case get_pid_in_focus(Pman_data) of
443
451
%% Open trace windows for all pids linked to the pid in focus
445
execute_cmd('All Links',Pman_data,Data,Args) ->
453
execute_cmd('All Links',Pman_data,_Data,_Args) ->
446
454
case get_pid_in_focus(Pman_data) of
447
455
false -> Pman_data;
448
456
{true,{pidfunc,Pid,_}} ->
456
464
%% Open trace window for a specific pid linked to the pid in focus
458
execute_cmd({'Links',LPid},Pman_data,Data,Args) ->
466
execute_cmd({'Links',LPid},Pman_data,_Data,_Args) ->
459
467
case get_pid_in_focus(Pman_data) of
460
468
false -> Pman_data;
461
{true,{pidfunc,Pid,_}} ->
469
{true,{pidfunc,_Pid,_}} ->
462
470
pman_shell:start(LPid, Pman_data#gs_pman.options),
466
474
%% Kill the pid in focus
468
execute_cmd('Kill',Pman_data,Data,Args) ->
476
execute_cmd('Kill',Pman_data,_Data,_Args) ->
469
477
case get_pid_in_focus(Pman_data) of
477
485
%% Open window with module information
479
execute_cmd('Module',Pman_data,Data,Args) ->
487
execute_cmd('Module',Pman_data,_Data,_Args) ->
480
488
case get_pid_in_focus(Pman_data) of
481
489
false -> Pman_data; %0
491
499
%% Hide an explicitly selected process (PID).
494
execute_cmd('Hide Selected Process', Pman_data, Data, Args) ->
502
execute_cmd('Hide Selected Process', Pman_data, _Data, _Args) ->
495
503
case get_pid_in_focus(Pman_data) of
496
504
%% No process selected
523
531
%% The selected modules are added to the list of hidden modules.
526
execute_cmd('Hide Modules',Pman_data,Data,Args) ->
534
execute_cmd('Hide Modules',Pman_data,_Data,_Args) ->
528
536
%% Get all loaded modules, and then strip unnecessary info
536
ordsets:list_to_set(lists:map(MapFun, LITupleLoaded)),
544
ordsets:from_list(lists:map(MapFun, LITupleLoaded)),
538
546
%% Let the user select which of the loaded modules to exclude from the
539
547
%% process overview
546
554
{cancelled, _Reason} ->
549
OSDialogResult = ordsets:list_to_set(Selection),
557
OSDialogResult = ordsets:from_list(Selection),
551
559
OSModuleHidden = ordsets:union(OSDialogResult,
552
560
Pman_data#gs_pman.hide_modules),
566
574
%% I.e. they will remain hidden, but will be shown if the filter is
569
execute_cmd('Hide All',Pman_data,Data,Args) ->
577
execute_cmd('Hide All',Pman_data,_Data,_Args) ->
571
579
OSPidAll = pman_process:r_processes(Pman_data#gs_pman.node),
593
601
%% Explicitly show a specific process (PID)
596
execute_cmd('Show Selected Process', Pman_data, Data, Args) ->
604
execute_cmd('Show Selected Process', Pman_data, _Data, _Args) ->
597
605
case get_pid_in_focus(Pman_data) of
599
607
%% No process selected
615
623
%% Set default options for tracing
618
execute_cmd('Default Options',Pman_data,Data,Args) ->
626
execute_cmd('Default Options',Pman_data,_Data,_Args) ->
619
627
OldOptions = Pman_data#gs_pman.options,
620
628
NewOptions = pman_options:dialog(Pman_data#gs_pman.win,
621
629
"Default Trace Options",
623
631
case NewOptions of
627
635
Pman_data#gs_pman{options=Options}
631
639
%% Save the set default options to the users pman-frofile file
634
execute_cmd('Save Options', Pman_data,Data,Args)->
642
execute_cmd('Save Options', Pman_data,_Data,_Args)->
635
643
%% Platform dependent code for determining where to store
636
644
%% the user options
637
645
FileName = pman_osdepend:options_file_name(),
644
652
pman_osdepend:mkdir_for_file(FileName),
646
654
case catch pman_options:save_to_file(Options,FileName) of
647
{'EXIT', {file_problem, Reason}} ->
655
{'EXIT', {file_problem, _Reason}} ->
648
656
tool_utils:notify(Parent,"Could not save options.");
650
658
tool_utils:notify(Parent,"Options saved in\n" ++ FileName)
658
666
%% Exit the application
660
execute_cmd('Exit',Pman_data,Data,Args) ->
668
execute_cmd('Exit',Pman_data,_Data,_Args) ->
661
669
gs:destroy(Pman_data#gs_pman.win),
687
695
%% this must be "forwarded" to the geometry managing frame.
688
696
%% It is also forwarded to a "manual" geometry manager for the grid.
690
execute_cmd({configure,W,H,X,Y},Pman_data,Data,Args) ->
698
execute_cmd({configure,W,H,_X,_Y},Pman_data,_Data,_Args) ->
692
700
gse:resize(Pman_data#gs_pman.frame, W, H-?MENU_HEIGHT),
712
720
%% The checkbutton for hiding system processes has been selected.
714
execute_cmd('Hide System', Pman_data, Data, Args ) ->
722
execute_cmd('Hide System', Pman_data, _Data, Args ) ->
715
723
[_Text, _Group, Bool|_Rest] = Args,
716
724
New_Pman_data = Pman_data#gs_pman{hide_system=Bool},
717
725
refresh(New_Pman_data);
724
732
%% The checkbutton for hiding new processes has been selected.
726
execute_cmd('Auto Hide New', Pman_data, Data, Args ) ->
734
execute_cmd('Auto Hide New', Pman_data, _Data, Args ) ->
727
735
[_Text, _Group, Bool|_Rest] = Args,
729
737
Pman_data2 = Pman_data#gs_pman{hide_new=Bool},
739
execute_cmd(Cmd,Pman_data,Data,Args) -> Pman_data.
747
execute_cmd(_Cmd,Pman_data,_Data,_Args) -> Pman_data.
741
749
%% ---------------------------------------------------------------
742
750
%% Execute the Various command requests received Through events
762
769
%% Single click in the process list sets focus to the clicked process
763
770
{gs,_Gl,click,{pidfunc,_,_},[_Col,Row|_T]} when integer(Row) ->
764
771
focus(Row,Pman_data);
765
{gs,_Gl,doubleclick,{pidfunc,P,M},[Col,Row| _]} when integer(Row) ->
772
{gs,_Gl,doubleclick,{pidfunc,_P,_M},[_Col,Row| _]} when integer(Row) ->
766
773
execute_cmd('Trace Process',Pman_data,[],[]);
768
775
%%Menu Commands / Button presses
779
786
{gs,_W,keypress,[],['Return',_,0,0]} ->
780
787
execute_cmd('Trace',Pman_data,[],[]);
781
{gs,_W,keypress,D,[Key,_,0,1]} ->
788
{gs,_W,keypress,_D,[Key,_,0,1]} ->
782
789
execute_cmd(key(Key),Pman_data,[],[]);
816
823
disable_pid_actions() ->
817
lists:foreach({gse, disable}, ?REQUIRES_FOCUS).
824
lists:foreach(fun(X) -> gse:disable(X) end, ?REQUIRES_FOCUS).
820
827
enable_pid_actions() ->
821
lists:foreach({gse, enable}, ?REQUIRES_FOCUS).
828
lists:foreach(fun(X) -> gse:enable(X) end, ?REQUIRES_FOCUS).
831
%% Check if node is running in noshell mode and if so disable the
832
%% 'Trace Shell' menu option.
834
trace_shell_possible(#gs_pman{noshell = true}) ->
835
gse:disable('Trace Shell');
836
trace_shell_possible(_) ->
827
839
%% ---------------------------------------------------------------
828
840
%% The main loop for the pman window
964
976
%% All processes are now displayed.
965
977
%% Now set the focus appropriately.
967
Pman_data4=set_focus(OSPidShow,Pman_data3),
979
Pman_data4 = set_focus(OSPidShow,Pman_data3),
972
981
focus(Pman_data4#gs_pman.focus, Pman_data3),
983
trace_shell_possible(Pman_data4),
1040
1051
case Pman_data#gs_pman.hide_system of
1043
lists:filter({pman_process, is_system_process},
1054
lists:filter(fun(P) -> pman_process:is_system_process(P) end,
1045
1056
ordsets:union(OSPidDontShow1, OSPidSystem);