pman trace shell bug or initial_call bug

Samuel Rivas samuel@REDACTED
Mon Sep 27 11:15:10 CEST 2004


  The trace shell option of pman is no longer working. Pman hangs
forever when you try to trace the shell process.

  The problem is in pman_shell:find_shell function. It assumes the shell
process is the one that has the {initial_call,{shell,evaluator,3}}
tuple within its process info, but some change has broken this: a process
created with spawn_link will have {erlang, apply, 2} as its initial_call
value.

  I've attached a patch that solves the pman problem adding a dictionary
entry so that the shell process can be recognized again, but seems a
"dirty" solution. IMO it would be worth restoring the former behaviour
of the spawn functions, but it is beyond my knowledge so far :(

  Any ideas?

  Best regards.
-- 
	Samuel
-------------- next part --------------
--- otp_src_R9C-2/lib/stdlib/src/shell.erl	2003-11-27 13:48:30.000000000 +0100
+++ otp_src_R9C-2-patched/lib/stdlib/src/shell.erl	2004-09-24 15:06:47.000000000 +0200
@@ -333,6 +333,7 @@
 
 evaluator(Shell, Bs, Ds) ->
     init_dict(Ds),
+    put(shell, yes),
     case application:get_env(stdlib, restricted_shell) of
 	undefined ->
 	    eval_loop(Shell, Bs);
--- otp_src_R9C-2/lib/pman/src/pman_shell.erl	2000-08-22 14:07:15.000000000 +0200
+++ otp_src_R9C-2-patched/lib/pman/src/pman_shell.erl	2004-09-24 15:28:05.000000000 +0200
@@ -70,8 +70,13 @@
 %% Constants
 %%
 
+%% XXX: This will not work any longer. Initial call after being spanw_linked is
+%% {erlang, apply, 2} so this feature is not usefull at all to identify the
+%% shell process, I use the process dictionary either.
+
 %% Initial call function for the shell. Used to find the shell process.
 -define(SHELL_INITIAL_CALL, {shell, evaluator, 3}).
+
 -define (PMAN_DB, pman_db).  % The pman db for trace windows
 
 
@@ -294,10 +299,15 @@
     lists:max(Ack);
 
 find_shell([P|Tail], Ack) ->
-    case erlang:process_info(P, initial_call) of
-	{initial_call, ?SHELL_INITIAL_CALL} ->
-	    find_shell(Tail, [P|Ack]);
-	_ ->
+    case erlang:process_info(P, dictionary) of
+	{dictionary, Dict} -> 
+		case lists:keysearch(shell, 1, Dict) of
+		    {value, {shell, yes}} ->
+			find_shell(Tail, [P|Ack]);
+		    _ ->
+			find_shell(Tail, Ack)
+		end;
+	  _ ->
 	    find_shell(Tail, Ack)
     end.
 


More information about the erlang-bugs mailing list