Author: martin
Date: 2006-04-03 09:54:26 -0400 (Mon, 03 Apr 2006)
New Revision: 58953

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

        * frontend/Interpreter.cs
        (Interpreter.Threads): Removed; we don't keep a separate hash
        table here anymore, but use `Process.Threads' instead.
        (Interpreter.Processes): New public property.

        * frontend/Command.cs
        (Show.ShowProcessesCommand): Added `show processes' command.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2006-04-03 13:52:57 UTC (rev 58952)
+++ trunk/debugger/ChangeLog    2006-04-03 13:54:26 UTC (rev 58953)
@@ -1,5 +1,15 @@
 2006-04-03  Martin Baulig  <[EMAIL PROTECTED]>
 
+       * frontend/Interpreter.cs
+       (Interpreter.Threads): Removed; we don't keep a separate hash
+       table here anymore, but use `Process.Threads' instead.
+       (Interpreter.Processes): New public property.
+
+       * frontend/Command.cs
+       (Show.ShowProcessesCommand): Added `show processes' command.
+
+2006-04-03  Martin Baulig  <[EMAIL PROTECTED]>
+
        * backends/Process.cs
        (Process.ID): New public property.
        (Process.Threads): New public property.

Modified: trunk/debugger/frontend/Command.cs
===================================================================
--- trunk/debugger/frontend/Command.cs  2006-04-03 13:52:57 UTC (rev 58952)
+++ trunk/debugger/frontend/Command.cs  2006-04-03 13:54:26 UTC (rev 58953)
@@ -1320,6 +1320,37 @@
        public class ShowCommand : NestedCommand, IDocumentableCommand
        {
 #region show subcommands
+               private class ShowProcessesCommand : DebuggerCommand
+               {
+                       protected override void DoExecute (ScriptingContext 
context)
+                       {
+                               bool printed_something = false;
+                               foreach (Process process in 
context.Interpreter.Processes) {
+                                       string prefix = process == 
context.Interpreter.MainProcess ?
+                                               "(*)" : "   ";
+
+                                       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 += " ...";
+                                       }
+                                       context.Print ("{0} Process #{1} 
({2}:{3:x})", prefix,
+                                                      process.ID, 
process.MainThread.PID,
+                                                      command_line);
+                                       printed_something = true;
+                               }
+                       }
+               }
+
                private class ShowThreadsCommand : DebuggerCommand
                {
                        protected override void DoExecute (ScriptingContext 
context)
@@ -1329,7 +1360,8 @@
                                        current_id = 
context.Interpreter.CurrentThread.ID;
 
                                bool printed_something = false;
-                               foreach (Thread proc in 
context.Interpreter.Threads) {
+                               Process process = 
context.Interpreter.MainProcess;
+                               foreach (Thread proc in process.Threads) {
                                        string prefix = proc.ID == current_id ? 
"(*)" : "   ";
                                        context.Print ("{0} {1} ({2}:{3:x})", 
prefix, proc,
                                                       proc.PID, proc.TID);
@@ -1550,6 +1582,8 @@
 
                public ShowCommand ()
                {
+                       RegisterSubcommand ("procs", typeof 
(ShowProcessesCommand));
+                       RegisterSubcommand ("processes", typeof 
(ShowProcessesCommand));
                        RegisterSubcommand ("threads", typeof 
(ShowThreadsCommand));
                        RegisterSubcommand ("registers", typeof 
(ShowRegistersCommand));
                        RegisterSubcommand ("regs", typeof 
(ShowRegistersCommand));

Modified: trunk/debugger/frontend/Interpreter.cs
===================================================================
--- trunk/debugger/frontend/Interpreter.cs      2006-04-03 13:52:57 UTC (rev 
58952)
+++ trunk/debugger/frontend/Interpreter.cs      2006-04-03 13:54:26 UTC (rev 
58953)
@@ -26,7 +26,6 @@
                Debugger debugger;
                Process main_process;
                Thread main_thread;
-               Hashtable procs;
 
                Hashtable styles;
                StyleBase current_style;
@@ -68,8 +67,6 @@
 
                        Report.Initialize (ReportWriter);
 
-                       procs = new Hashtable ();
-
                        styles = new Hashtable ();
                        styles.Add ("cli", new StyleCLI (this));
                        styles.Add ("emacs", new StyleEmacs (this));
@@ -203,14 +200,6 @@
                        set { exit_code = value; }
                }
 
-               public Thread[] Threads {
-                       get {
-                               Thread[] retval = new Thread [procs.Count];
-                               procs.Values.CopyTo (retval, 0);
-                               return retval;
-                       }
-               }
-
                public void Abort ()
                {
                        Print ("Caught fatal error while running 
non-interactively; exiting!");
@@ -394,9 +383,6 @@
 
                                CurrentThread = main_thread;
 
-                               foreach (Thread thread in threads)
-                                       procs.Add (thread.ID, thread);
-
                                return main_process;
                        } catch (TargetException e) {
                                Kill ();
@@ -444,8 +430,6 @@
 
                protected void ThreadCreated (Thread thread)
                {
-                       procs.Add (thread.ID, thread);
-
                        if (initialized)
                                Print ("New thread @{0}", thread.ID);
                }
@@ -527,7 +511,6 @@
 
                protected void ThreadExited (Thread thread)
                {
-                       procs.Remove (thread.ID);
                        if (thread == main_thread) {
                                TargetExited ();
                                CurrentThread = null;
@@ -537,11 +520,6 @@
                protected void TargetExited ()
                {
                        if (main_process != null) {
-                               foreach (Thread proc in Threads) {
-                                       if (proc.Process == main_process)
-                                               procs.Remove (proc.ID);
-                               }
-
                                if ((main_thread != null) &&
                                    (main_thread.Process == main_process)) {
                                        main_thread = null;
@@ -549,7 +527,6 @@
                                        CurrentThread = null;
                                }
                        } else {
-                               procs = new Hashtable ();
                                CurrentThread = null;
                                main_thread = null;
                                main_process = null;
@@ -574,7 +551,7 @@
                        if (number == -1)
                                return CurrentThread;
 
-                       foreach (Thread proc in Threads)
+                       foreach (Thread proc in MainProcess.Threads)
                                if (proc.ID == number)
                                        return proc;
 
@@ -736,6 +713,15 @@
                        return path;
                }
 
+               public Process[] Processes {
+                       get {
+                               if (debugger == null)
+                                       throw new ScriptingException ("No 
target.");
+
+                               return debugger.Processes;
+                       }
+               }
+
                protected class InterpreterEventSink : MarshalByRefObject
                {
                        Interpreter interpreter;

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

Reply via email to