public EmonicInterpreter.threadData GetThreads(bool execute) { if (execute) { EmonicInterpreter.threadList.Clear(); // remove all previous elements from the list EmonicLineInterpreter.AddCmd("show threads"); } EmonicInterpreter.threadData td = EmonicInterpreter.GetNextThreadLine(); return(td); }
protected override object DoExecute(ScriptingContext context) { int current_id = -1; if (context.Interpreter.HasCurrentThread) { current_id = context.Interpreter.CurrentThread.ID; } bool printed_something = false; Process[] processes = context.Interpreter.Processes; for (int i = 0; i < processes.Length; i++) { context.Print("Process {0}:", context.Interpreter.PrintProcess(processes[i])); Mono.Debugger.Thread[] threads = processes[i].GetThreads(); for (int j = 0; j < threads.Length; j++) { string prefix = threads[j].ID == current_id ? "(*)" : " "; context.Print("{0} {1} ({2}:{3:x}) {4}", prefix, threads[j], threads[j].PID, threads[j].TID, threads[j].State); printed_something = true; EmonicInterpreter.threadData td = new EmonicInterpreter.threadData(); td.processNumber = processes[i].ID; td.PID = processes[i].MainThread.PID; td.processCmdLine = context.Interpreter.PrintCommandLineArgs(processes[i]); td.threadNumber = threads[j].ID; if ((threads[j].ThreadFlags & Mono.Debugger.Thread.Flags.Daemon) != 0) { td.daemonThread = true; } else { td.daemonThread = false; } td.threadState = threads[j].State != Mono.Debugger.TargetState.Stopped; td.currentThread = threads[j].ID == current_id; td.TID = threads[j].PID; // we take the PID of the thread here, not really the TID td.moreData = j + 1 < threads.Length || i + 1 < processes.Length; EmonicInterpreter.threadList.Add(td); } } if (!printed_something) { context.Print("No target."); // generate an invalid response EmonicInterpreter.threadData td = new EmonicInterpreter.threadData(); td.processNumber = -1; td.PID = -1; td.processCmdLine = ""; td.threadNumber = -1; td.daemonThread = false; td.threadState = false; td.currentThread = false; td.TID = -1; td.moreData = false; EmonicInterpreter.threadList.Add(td); } return(null); }
protected override object DoExecute(ScriptingContext context) { int current_id = -1; if (context.Interpreter.HasCurrentThread) current_id = context.Interpreter.CurrentThread.ID; bool printed_something = false; Process[] processes = context.Interpreter.Processes; for (int i=0; i<processes.Length; i++) { context.Print ("Process {0}:", context.Interpreter.PrintProcess (processes[i])); Mono.Debugger.Thread[] threads = processes[i].GetThreads(); for (int j=0; j<threads.Length; j++) { string prefix = threads[j].ID == current_id ? "(*)" : " "; context.Print ("{0} {1} ({2}:{3:x}) {4}", prefix, threads[j], threads[j].PID, threads[j].TID, threads[j].State); printed_something = true; EmonicInterpreter.threadData td = new EmonicInterpreter.threadData(); td.processNumber = processes[i].ID; td.PID = processes[i].MainThread.PID; td.processCmdLine = context.Interpreter.PrintCommandLineArgs(processes[i]); td.threadNumber = threads[j].ID; if ((threads[j].ThreadFlags & Mono.Debugger.Thread.Flags.Daemon) != 0) td.daemonThread = true; else td.daemonThread = false; td.threadState = threads[j].State != Mono.Debugger.TargetState.Stopped; td.currentThread = threads[j].ID == current_id; td.TID = threads[j].PID; // we take the PID of the thread here, not really the TID td.moreData = j+1<threads.Length || i+1<processes.Length; EmonicInterpreter.threadList.Add(td); } } if (!printed_something) { context.Print ("No target."); // generate an invalid response EmonicInterpreter.threadData td = new EmonicInterpreter.threadData(); td.processNumber = -1; td.PID = -1; td.processCmdLine = ""; td.threadNumber = -1; td.daemonThread = false; td.threadState = false; td.currentThread = false; td.TID = -1; td.moreData = false; EmonicInterpreter.threadList.Add(td); } return null; }