Bug 574403 - Show process ID in Console and Process Properties
Added new IProcess.ATTR_PROCESS_ID attribute that can be used by clients
to provide process id for launched processes. This attribute will be
shown in appropriate places in debugger like Console description and
properties page of the process.
Change-Id: I88387340a60b3b71b79651ce62bb54b775a93dd0
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.debug/+/189453
Tested-by: Platform Bot <platform-bot@eclipse.org>
diff --git a/org.eclipse.core.externaltools/META-INF/MANIFEST.MF b/org.eclipse.core.externaltools/META-INF/MANIFEST.MF
index ede6e8c..4c9f27f 100644
--- a/org.eclipse.core.externaltools/META-INF/MANIFEST.MF
+++ b/org.eclipse.core.externaltools/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.core.externaltools;singleton:=true
-Bundle-Version: 1.2.100.qualifier
+Bundle-Version: 1.2.200.qualifier
Bundle-Activator: org.eclipse.core.externaltools.internal.ExternalToolsCore
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
org.eclipse.debug.core;bundle-version="[3.9.0,4.0.0)",
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java
index d75dda2..b733eb9 100644
--- a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java
+++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.java
@@ -18,10 +18,12 @@
public class ExternalToolsProgramMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.core.externaltools.internal.launchConfigurations.ExternalToolsProgramMessages";//$NON-NLS-1$
+
public static String BackgroundResourceRefresher_0;
public static String ProgramLaunchDelegate_3;
public static String ProgramLaunchDelegate_4;
+ public static String ProgramLaunchDelegate_5;
public static String ExternalToolsUtil_Location_not_specified_by__0__1;
public static String ExternalToolsUtil_invalidLocation__0_;
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties
index 78a7473..7d91899 100644
--- a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties
+++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ExternalToolsProgramMessages.properties
@@ -16,6 +16,7 @@
ProgramLaunchDelegate_3=Running {0}...
ProgramLaunchDelegate_4=An IProcess could not be created for the launch
+ProgramLaunchDelegate_5=[pid: {0}]
ExternalToolsUtil_Location_not_specified_by__0__1=Location not specified by {0}
ExternalToolsUtil_invalidLocation__0_ = The file does not exist for the external tool named {0}.
diff --git a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java
index 4d599c5..f6efdb8 100644
--- a/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java
+++ b/org.eclipse.core.externaltools/src/org/eclipse/core/externaltools/internal/launchConfigurations/ProgramLaunchDelegate.java
@@ -119,7 +119,8 @@
ExternalToolsProgramMessages.ProgramLaunchDelegate_3,
new String[] { configuration.getName() }),
IProgressMonitor.UNKNOWN);
- process = DebugPlugin.newProcess(launch, p, location.toOSString(), processAttributes);
+ String label = getProcessLabel(location, p);
+ process = DebugPlugin.newProcess(launch, p, label, processAttributes);
}
if (p == null || process == null) {
if (p != null) {
@@ -158,6 +159,17 @@
}
}
+ private String getProcessLabel(IPath location, Process p) {
+ String label = location.toOSString();
+ try {
+ label += " " + NLS.bind(ExternalToolsProgramMessages.ProgramLaunchDelegate_5, new Object[] { //$NON-NLS-1$
+ p.pid() });
+ } catch (UnsupportedOperationException e) {
+ // ignore, pid() is not implemented in this JVM
+ }
+ return label;
+ }
+
private String[] buildCommandLine(ILaunchConfiguration configuration, IPath location) throws CoreException {
// resolve arguments
String[] arguments = ExternalToolsCoreUtil.getArguments(configuration);
diff --git a/org.eclipse.debug.core/.settings/.api_filters b/org.eclipse.debug.core/.settings/.api_filters
new file mode 100644
index 0000000..584b5ae
--- /dev/null
+++ b/org.eclipse.debug.core/.settings/.api_filters
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.debug.core" version="2">
+ <resource path="META-INF/MANIFEST.MF">
+ <filter comment="See bug 574403 and bug 578358 comment 8" id="926941240">
+ <message_arguments>
+ <message_argument value="3.19.0"/>
+ <message_argument value="3.18.300"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="core/org/eclipse/debug/core/model/IProcess.java" type="org.eclipse.debug.core.model.IProcess">
+ <filter comment="See bug 574403 and bug 578358 comment 8" id="403767336">
+ <message_arguments>
+ <message_argument value="org.eclipse.debug.core.model.IProcess"/>
+ <message_argument value="ATTR_PROCESS_ID"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/org.eclipse.debug.core/META-INF/MANIFEST.MF b/org.eclipse.debug.core/META-INF/MANIFEST.MF
index bf784b2..9c1ea44 100644
--- a/org.eclipse.debug.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.core; singleton:=true
-Bundle-Version: 3.18.400.qualifier
+Bundle-Version: 3.19.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.debug.core.DebugPlugin
Bundle-Vendor: %providerName
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IProcess.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IProcess.java
index e7d9aa3..2df9d2b 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IProcess.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/IProcess.java
@@ -62,6 +62,15 @@
String ATTR_PROCESS_LABEL = DebugPlugin.getUniqueIdentifier() + ".ATTR_PROCESS_LABEL"; //$NON-NLS-1$
/**
+ * Attribute key for a common, optional, process property. The value of this
+ * attribute specifies process id, displayed in the console description or
+ * in the debug view.
+ *
+ * @since 3.19
+ */
+ String ATTR_PROCESS_ID = DebugPlugin.getUniqueIdentifier() + ".ATTR_PROCESS_ID"; //$NON-NLS-1$
+
+ /**
* Returns a human-readable label for this process.
*
* @return a label for this process
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
index 35f17f8..193458f 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java
@@ -122,6 +122,11 @@
setLaunch(launch);
initializeAttributes(attributes);
fProcess = process;
+ try {
+ setAttribute(IProcess.ATTR_PROCESS_ID, Long.toString(process.pid()));
+ } catch (UnsupportedOperationException e) {
+ // ignore, pid() is not implemented in this JVM
+ }
fName = name;
fTerminated = true;
try {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
index f16c04c..72b5771 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java
@@ -189,6 +189,8 @@
public static String ProcessPropertyPage_10;
+ public static String ProcessPropertyPage_11;
+
public static String ProcessPropertyPage_1;
public static String ProcessPropertyPage_2;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
index ca4b938..a2a56c2 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
@@ -98,6 +98,7 @@
ProcessPropertyPage_Command_Line__1=Co&mmand Line:
ProcessPropertyPage_0=Run-&at time:
ProcessPropertyPage_10=&Terminated-at time:
+ProcessPropertyPage_11=PID:
ProcessPropertyPage_1=&Path:
ProcessPropertyPage_2=Process properties
ProcessPropertyPage_3=No path information available
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java
index 4e10ecc..4e086e8 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ProcessPropertyPage.java
@@ -57,10 +57,18 @@
Composite parent = SWTFactory.createComposite(ancestor, ancestor.getFont(), 1, 1, GridData.FILL_BOTH);
IProcess proc = getProcess();
-
+ Text text;
+ if (proc.getAttribute(IProcess.ATTR_PROCESS_ID) != null) {
+ SWTFactory.createLabel(parent, DebugPreferencesMessages.ProcessPropertyPage_11, fHeadingFont, 1);
+ text = SWTFactory.createText(parent, SWT.READ_ONLY, 1);
+ ((GridData) text.getLayoutData()).horizontalIndent = 10;
+ text.setText(proc.getAttribute(IProcess.ATTR_PROCESS_ID));
+ text.setBackground(parent.getBackground());
+ SWTFactory.createVerticalSpacer(parent, 2);
+ }
// create the process launch time section
SWTFactory.createLabel(parent, DebugPreferencesMessages.ProcessPropertyPage_0, fHeadingFont, 1);
- Text text = SWTFactory.createText(parent, SWT.READ_ONLY, 1);
+ text = SWTFactory.createText(parent, SWT.READ_ONLY, 1);
((GridData)text.getLayoutData()).horizontalIndent = 10;
PlatformUI.getWorkbench().getHelpSystem().setHelp(text, IDebugHelpContextIds.PROCESS_PAGE_RUN_AT);
text.setText(getLaunchTimeText(proc));
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
index 061e475..2799ab0 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java
@@ -361,6 +361,13 @@
buffer.append(MessageFormat.format(ConsoleMessages.ProcessConsole_commandLabel_withEnd,
procLabel, dateTimeFormat.format(terminateTime)));
}
+
+ String pid = process.getAttribute(IProcess.ATTR_PROCESS_ID);
+ if (pid != null && !pid.isBlank()) {
+ buffer.append(" [pid: "); //$NON-NLS-1$
+ buffer.append(pid);
+ buffer.append("]"); //$NON-NLS-1$
+ }
label = buffer.toString();
}
}