Author: martin
Date: 2006-04-03 13:24:31 -0400 (Mon, 03 Apr 2006)
New Revision: 58964

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/backends/Debugger.cs
   trunk/debugger/backends/ThreadManager.cs
   trunk/debugger/frontend/Command.cs
   trunk/debugger/frontend/Interpreter.cs
Log:
2006-04-03  Martin Baulig  <[EMAIL PROTECTED]>

        * frontend/Interpreter.cs: Inform the user about newly created and
        exited processes.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2006-04-03 17:07:15 UTC (rev 58963)
+++ trunk/debugger/ChangeLog    2006-04-03 17:24:31 UTC (rev 58964)
@@ -1,5 +1,10 @@
 2006-04-03  Martin Baulig  <[EMAIL PROTECTED]>
 
+       * frontend/Interpreter.cs: Inform the user about newly created and
+       exited processes.
+
+2006-04-03  Martin Baulig  <[EMAIL PROTECTED]>
+
        * frontend/Interpreter.cs
        (Interpreter.MainProcess): Removed.
        (Interpreter.CurrentProcess): New public property.

Modified: trunk/debugger/backends/Debugger.cs
===================================================================
--- trunk/debugger/backends/Debugger.cs 2006-04-03 17:07:15 UTC (rev 58963)
+++ trunk/debugger/backends/Debugger.cs 2006-04-03 17:24:31 UTC (rev 58964)
@@ -109,6 +109,7 @@
 
                        ProcessStart start = new ProcessStart (options);
                        main_process = thread_manager.StartApplication (start);
+                       process_hash.Add (main_process, main_process);
                        return main_process;
                }
 
@@ -121,6 +122,7 @@
 
                        ProcessStart start = new ProcessStart (options, pid);
                        main_process = thread_manager.StartApplication (start);
+                       process_hash.Add (main_process, main_process);
                        return main_process;
                }
 
@@ -134,6 +136,7 @@
 
                        ProcessStart start = new ProcessStart (options, 
core_file);
                        main_process = thread_manager.OpenCoreFile (start, out 
threads);
+                       process_hash.Add (main_process, main_process);
                        return main_process;
                }
 

Modified: trunk/debugger/backends/ThreadManager.cs
===================================================================
--- trunk/debugger/backends/ThreadManager.cs    2006-04-03 17:07:15 UTC (rev 
58963)
+++ trunk/debugger/backends/ThreadManager.cs    2006-04-03 17:24:31 UTC (rev 
58964)
@@ -105,7 +105,6 @@
                {
                        Process process = CreateProcess (start);
                        process.WaitForApplication ();
-                       backend.OnProcessCreatedEvent (process);
                        return process;
                }
 
@@ -116,7 +115,6 @@
                        CoreFile core = CoreFile.OpenCoreFile (this, start);
 
                        threads = core.Threads;
-                       backend.OnProcessCreatedEvent (core);
                        return core;
                }
 

Modified: trunk/debugger/frontend/Command.cs
===================================================================
--- trunk/debugger/frontend/Command.cs  2006-04-03 17:07:15 UTC (rev 58963)
+++ trunk/debugger/frontend/Command.cs  2006-04-03 17:24:31 UTC (rev 58964)
@@ -1328,33 +1328,14 @@
                                        string prefix = process == 
context.Interpreter.CurrentProcess ?
                                                "(*)" : "   ";
 
-                                       context.Print ("{0} {1}", prefix, 
PrintProcess (process));
+                                       context.Print ("{0} Process {1}", 
prefix,
+                                                      
context.Interpreter.PrintProcess (process));
                                        printed_something = true;
                                }
                        }
-
-                       protected string PrintProcess (Process process)
-                       {
-                               bool first = true;
-                               StringBuilder sb = new StringBuilder ();
-                               foreach (string arg in 
process.CommandLineArguments) {
-                                       if (first)
-                                               first = false;
-                                       else
-                                               sb.Append (" ");
-                                       sb.Append (arg);
-                               }
-                               string command_line = sb.ToString ();
-                               if (command_line.Length > 70) {
-                                       command_line = command_line.Substring 
(0, 70);
-                                       command_line += " ...";
-                               }
-                               return String.Format ("Process #{0} ({1}:{2})", 
process.ID,
-                                                     process.MainThread.PID, 
command_line);
-                       }
                }
 
-               private class ShowThreadsCommand : ShowProcessesCommand
+               private class ShowThreadsCommand : DebuggerCommand
                {
                        protected override void DoExecute (ScriptingContext 
context)
                        {
@@ -1364,7 +1345,8 @@
 
                                bool printed_something = false;
                                foreach (Process process in 
context.Interpreter.Processes) {
-                                       context.Print ("{0}:", PrintProcess 
(process));
+                                       context.Print ("Process {0}:",
+                                                      
context.Interpreter.PrintProcess (process));
                                        foreach (Thread proc in 
process.Threads) {
                                                string prefix = proc.ID == 
current_id ? "(*)" : "   ";
                                                context.Print ("  {0} {1} 
({2}:{3:x})", prefix, proc,

Modified: trunk/debugger/frontend/Interpreter.cs
===================================================================
--- trunk/debugger/frontend/Interpreter.cs      2006-04-03 17:07:15 UTC (rev 
58963)
+++ trunk/debugger/frontend/Interpreter.cs      2006-04-03 17:24:31 UTC (rev 
58964)
@@ -420,7 +420,8 @@
                protected void ThreadCreated (Thread thread)
                {
                        if (!thread.IsDaemon)
-                               Print ("New thread @{0}", thread.ID);
+                               Print ("Process {0} created new thread @{1}.",
+                                      PrintProcess (thread.Process), 
thread.ID);
                }
 
                public void Wait (Thread thread)
@@ -498,8 +499,15 @@
                                current_thread = null;
                }
 
+               protected void ProcessCreated (Process process)
+               {
+                       Print ("Created new process {0}.", PrintProcess 
(process));
+               }
+
                protected void ProcessExited (Process process)
                {
+                       if (process != main_process)
+                               Print ("Process {0} exited.", PrintProcess 
(process));
                        if (process == main_process) {
                                current_process = main_process = null;
                                current_thread = null;
@@ -712,6 +720,26 @@
                        }
                }
 
+               public string PrintProcess (Process process)
+               {
+                       bool first = true;
+                       StringBuilder sb = new StringBuilder ();
+                       foreach (string arg in process.CommandLineArguments) {
+                               if (first)
+                                       first = false;
+                               else
+                                       sb.Append (" ");
+                               sb.Append (arg);
+                       }
+                       string command_line = sb.ToString ();
+                       if (command_line.Length > 70) {
+                               command_line = command_line.Substring (0, 70);
+                               command_line += " ...";
+                       }
+                       return String.Format ("#{0} ({1}:{2})", process.ID,
+                                             process.MainThread.PID, 
command_line);
+               }
+
                protected class InterpreterEventSink : MarshalByRefObject
                {
                        Interpreter interpreter;
@@ -722,6 +750,7 @@
 
                                backend.TargetExitedEvent += target_exited;
                                backend.ThreadCreatedEvent += thread_created;
+                               backend.ProcessCreatedEvent += process_created;
                                backend.ProcessReachedMainEvent += 
process_reached_main;
                                backend.ProcessExitedEvent += process_exited;
                        }
@@ -732,6 +761,11 @@
                                interpreter.ThreadCreated (thread);
                        }
 
+                       public void process_created (Debugger debugger, Process 
process)
+                       {
+                               interpreter.ProcessCreated (process);
+                       }
+
                        public void process_reached_main (Debugger debugger, 
Process process)
                        {
                        }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to