Search in sources :

Example 6 with ProcessInfo

use of com.intellij.execution.process.ProcessInfo in project intellij-community by JetBrains.

the class ProcessListTest method testMac_DoNotIncludeProcessedChangedOnTheSecondPSRun.

public void testMac_DoNotIncludeProcessedChangedOnTheSecondPSRun() throws Exception {
    List<ProcessInfo> infos = ProcessListUtil.parseMacOutput("   PID STAT USER    COMM\n\n" + "     1 S    user    /dir/file\n" + "     2 S    user    /dir/file\n" + "     3 S    user    /dir/file\n" + "     4 S    user    /dir/file\n", "   PID STAT USER    COMMAND\n\n" + "     1 S    user    /dir/file param\n" + "     2 S    user    /dir/ffff\n" + "     3 S    user    /dir/file1\n" + "     4 S    user    /dir/file/1\n");
    assertOrderedEquals(infos, new ProcessInfo(1, "/dir/file param", "file", "param", "/dir/file"));
}
Also used : ProcessInfo(com.intellij.execution.process.ProcessInfo)

Example 7 with ProcessInfo

use of com.intellij.execution.process.ProcessInfo in project intellij-community by JetBrains.

the class AttachToLocalProcessAction method addToHistory.

public static void addToHistory(@NotNull Project project, @NotNull AttachItem item) {
    LinkedHashMap<String, HistoryItem> history = project.getUserData(HISTORY_KEY);
    if (history == null) {
        project.putUserData(HISTORY_KEY, history = new LinkedHashMap<>());
    }
    ProcessInfo processInfo = item.getProcessInfo();
    history.remove(processInfo.getCommandLine());
    history.put(processInfo.getCommandLine(), new HistoryItem(processInfo, item.getGroup(), item.getSelectedDebugger().getDebuggerDisplayName()));
    while (history.size() > 4) {
        history.remove(history.keySet().iterator().next());
    }
}
Also used : ProcessInfo(com.intellij.execution.process.ProcessInfo) LinkedHashMap(com.intellij.util.containers.hash.LinkedHashMap)

Example 8 with ProcessInfo

use of com.intellij.execution.process.ProcessInfo in project intellij-community by JetBrains.

the class AttachToLocalProcessActionTest method testHistoryGroup.

public void testHistoryGroup() throws Exception {
    TestAttachGroup group1 = new TestAttachGroup("group1", 1);
    TestAttachGroup group2 = new TestAttachGroup("group2", 2);
    List<XLocalAttachDebugger> debuggers1 = createDebuggers("gdb1", "lldb1");
    List<XLocalAttachDebugger> debuggers2 = createDebuggers("gdb2", "lldb2");
    List<AttachItem> originalItems = collectAttachItems(getProject(), new ProcessInfo[] { new ProcessInfo(1, "command line 1", "exec1", "args1"), new ProcessInfo(2, "command line 2", "exec2", "args2") }, DumbProgressIndicator.INSTANCE, new TestDebuggerProvider(1, group1, debuggers1), new TestDebuggerProvider(2, group2, debuggers2));
    // one item in history
    addToHistory(getProject(), originalItems.get(0));
    assertItems("----Recent----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2));
    // several items in history
    addToHistory(getProject(), originalItems.get(1));
    assertItems("----Recent----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2));
    // put most recent item on top
    addToHistory(getProject(), originalItems.get(0));
    assertItems("----Recent----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2));
    // put debugger used in history item on top
    addToHistory(getProject(), originalItems.get(0).getSubItems().get(1));
    addToHistory(getProject(), originalItems.get(1).getSubItems().get(1));
    assertItems("----Recent----\n" + "20 exec20: lldb2\n" + "    gdb2\n" + "    lldb2\n" + "10 exec10: lldb1\n" + "    gdb1\n" + "    lldb1\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2));
    // filter unavailable history items
    assertItems("----Recent----\n" + "20 exec20: lldb2\n" + "    gdb2\n" + "    lldb2\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 10", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2));
    assertItems("----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 10", "exec10", "args10"), new ProcessInfo(20, "command line 20", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2));
    // history items available again:
    assertItems("----Recent----\n" + "20 exec20: lldb2\n" + "    gdb2\n" + "    lldb2\n" + "10 exec10: lldb1\n" + "    gdb1\n" + "    lldb1\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers2));
    // filter items from history by suitable group
    assertItems("----Recent----\n" + "10 exec10: lldb1\n" + "    gdb1\n" + "    lldb1\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group1, debuggers2));
    assertItems("----Recent----\n" + "20 exec20: lldb2\n" + "    gdb2\n" + "    lldb2\n" + "----group2----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group2, debuggers1), new TestDebuggerProvider(20, group2, debuggers2));
    // filter by group equality, not by name
    assertItems("----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, new TestAttachGroup(group1.getGroupName(), group1.getOrder()), debuggers1), new TestDebuggerProvider(20, new TestAttachGroup(group2.getGroupName(), group2.getOrder()), debuggers2));
    // filter items from history by available debugger
    assertItems("----Recent----\n" + "10 exec10: lldb1\n" + "    gdb1\n" + "    lldb1\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb1\n" + "    gdb1\n" + "    lldb1\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, debuggers1), new TestDebuggerProvider(20, group2, debuggers1));
    // filter debuggers by name, not by equality
    assertItems("----Recent----\n" + "20 exec20: lldb2\n" + "    gdb2\n" + "    lldb2\n" + "10 exec10: lldb1\n" + "    gdb1\n" + "    lldb1\n" + "----group1----\n" + "10 exec10: gdb1\n" + "    gdb1\n" + "    lldb1\n" + "----group2----\n" + "20 exec20: gdb2\n" + "    gdb2\n" + "    lldb2\n", new ProcessInfo[] { new ProcessInfo(10, "command line 1", "exec10", "args10"), new ProcessInfo(20, "command line 2", "exec20", "args20") }, new TestDebuggerProvider(10, group1, createDebuggers("gdb1", "lldb1")), new TestDebuggerProvider(20, group2, createDebuggers("gdb2", "lldb2")));
}
Also used : XLocalAttachDebugger(com.intellij.xdebugger.attach.XLocalAttachDebugger) ProcessInfo(com.intellij.execution.process.ProcessInfo)

Example 9 with ProcessInfo

use of com.intellij.execution.process.ProcessInfo in project intellij-community by JetBrains.

the class ProcessListTest method testWindows_WMIC.

public void testWindows_WMIC() throws Exception {
    List<ProcessInfo> infos = ProcessListUtil.parseWMICOutput("Caption                   CommandLine                                            ExecutablePath                          ProcessId  \n" + "smss.exe                                                                                                                 304        \n" + "sihost.exe                sihost.exe                                                                                     3052       \n" + "taskhostw.exe             taskhostw.exe {222A245B-E637-4AE9-A93F-A59CA119A75E}                                           3068       \n" + "explorer.exe              C:\\WINDOWS\\Explorer.EXE                                C:\\WINDOWS\\Explorer.EXE                                          3164       \n" + "TPAutoConnect.exe         TPAutoConnect.exe -q -i vmware -a COM1 -F 30                                                   3336       \n" + "conhost.exe               \\??\\C:\\WINDOWS\\system32\\conhost.exe 0x4                \\??\\C:\\WINDOWS\\system32\\conhost.exe     3348       \n");
    assertOrderedEquals(infos, new ProcessInfo(304, "smss.exe", "smss.exe", ""), new ProcessInfo(3052, "sihost.exe", "sihost.exe", ""), new ProcessInfo(3068, "taskhostw.exe {222A245B-E637-4AE9-A93F-A59CA119A75E}", "taskhostw.exe", "{222A245B-E637-4AE9-A93F-A59CA119A75E}"), new ProcessInfo(3164, "C:\\WINDOWS\\Explorer.EXE", "explorer.exe", "", "C:\\WINDOWS\\Explorer.EXE"), new ProcessInfo(3336, "TPAutoConnect.exe -q -i vmware -a COM1 -F 30", "TPAutoConnect.exe", "-q -i vmware -a COM1 -F 30"), new ProcessInfo(3348, "\\??\\C:\\WINDOWS\\system32\\conhost.exe 0x4", "conhost.exe", "0x4", "\\??\\C:\\WINDOWS\\system32\\conhost.exe"));
}
Also used : ProcessInfo(com.intellij.execution.process.ProcessInfo)

Example 10 with ProcessInfo

use of com.intellij.execution.process.ProcessInfo in project intellij-community by JetBrains.

the class ProcessListTest method testWindows_TaskList.

public void testWindows_TaskList() throws Exception {
    List<ProcessInfo> infos = ProcessListUtil.parseListTasksOutput("\"smss.exe\",\"304\",\"Services\",\"0\",\"224 K\",\"Unknown\",\"N/A\",\"0:00:00\",\"N/A\"\n" + "\"sihost.exe\",\"3052\",\"Console\",\"1\",\"10,924 K\",\"Running\",\"VM-WINDOWS\\Anton Makeev\",\"0:00:02\",\"N/A\"\n" + "\"taskhostw.exe\",\"3068\",\"Console\",\"1\",\"5,860 K\",\"Running\",\"VM-WINDOWS\\Anton Makeev\",\"0:00:00\",\"Task Host Window\"\n" + "\"explorer.exe\",\"3164\",\"Console\",\"1\",\"30,964 K\",\"Running\",\"VM-WINDOWS\\Anton Makeev\",\"0:00:04\",\"N/A\"\n" + "\"TPAutoConnect.exe\",\"3336\",\"Console\",\"1\",\"5,508 K\",\"Running\",\"VM-WINDOWS\\Anton Makeev\",\"0:00:04\",\"HiddenTPAutoConnectWindow\"\n" + "\"conhost.exe\",\"3348\",\"Console\",\"1\",\"1,172 K\",\"Unknown\",\"VM-WINDOWS\\Anton Makeev\",\"0:00:00\",\"N/A\"\n");
    assertOrderedEquals(infos, new ProcessInfo(304, "smss.exe", "smss.exe", ""), new ProcessInfo(3052, "sihost.exe", "sihost.exe", ""), new ProcessInfo(3068, "taskhostw.exe", "taskhostw.exe", ""), new ProcessInfo(3164, "explorer.exe", "explorer.exe", ""), new ProcessInfo(3336, "TPAutoConnect.exe", "TPAutoConnect.exe", ""), new ProcessInfo(3348, "conhost.exe", "conhost.exe", ""));
}
Also used : ProcessInfo(com.intellij.execution.process.ProcessInfo)

Aggregations

ProcessInfo (com.intellij.execution.process.ProcessInfo)19 Nullable (org.jetbrains.annotations.Nullable)4 UserDataHolderBase (com.intellij.openapi.util.UserDataHolderBase)3 XLocalAttachDebugger (com.intellij.xdebugger.attach.XLocalAttachDebugger)3 ArrayList (java.util.ArrayList)3 Pair (com.intellij.openapi.util.Pair)1 MultiMap (com.intellij.util.containers.MultiMap)1 LinkedHashMap (com.intellij.util.containers.hash.LinkedHashMap)1 XLocalAttachDebuggerProvider (com.intellij.xdebugger.attach.XLocalAttachDebuggerProvider)1 XLocalAttachGroup (com.intellij.xdebugger.attach.XLocalAttachGroup)1 TIntObjectHashMap (gnu.trove.TIntObjectHashMap)1 NotNull (org.jetbrains.annotations.NotNull)1