Skip to content

Commit 9ac3d78

Browse files
committed
Bug 574403 - Show process ID for process element in Debug view
Added process id to the process element label in the Debug view. Change-Id: Id2c0e9a7b3240ce1b3a7a99689e07ca5bf0cf3eb Signed-off-by: Andrey Loskutov <[email protected]> Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/189972 Tested-by: JDT Bot <[email protected]> Tested-by: Sarika Sinha <[email protected]> Reviewed-by: Sarika Sinha <[email protected]>
1 parent 0105262 commit 9ac3d78

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public class LaunchingMessages extends NLS {
124124
public static String StandardVMDebugger_Establishing_debug_connection____5;
125125

126126
public static String StandardVMRunner__0____1___2;
127+
public static String StandardVMRunner__0____1___2_3;
127128
public static String StandardVMRunner__0__at_localhost__1__1;
128129
public static String StandardVMRunner_Specified_working_directory_does_not_exist_or_is_not_a_directory___0__3;
129130
public static String StandardVMRunner_Launching_VM____1;

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ StandardVMDebugger_Starting_virtual_machine____4=Starting virtual machine...
102102
StandardVMDebugger_Establishing_debug_connection____5=Establishing debug connection...
103103

104104
StandardVMRunner__0____1___2={0} ({1})
105+
StandardVMRunner__0____1___2_3={0} ({1}) [pid: {2}]
105106
StandardVMRunner__0__at_localhost__1__1={0} at localhost:{1}
106107
StandardVMRunner_Specified_working_directory_does_not_exist_or_is_not_a_directory___0__3=Specified working directory does not exist or is not a directory: {0}
107108
StandardVMRunner_Launching_VM____1=Launching VM...

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/Standard11xVMRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor m
132132
return;
133133
}
134134
String timestamp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
135-
IProcess process= DebugPlugin.newProcess(launch, p, renderProcessLabel(cmdLine, timestamp));
135+
IProcess process = DebugPlugin.newProcess(launch, p, renderProcessLabel(p, cmdLine, timestamp));
136136
process.setAttribute(DebugPlugin.ATTR_PATH, cmdLine[0]);
137137
process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine));
138138
String ltime = launch.getAttribute(DebugPlugin.ATTR_LAUNCH_TIMESTAMP);

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMDebugger.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor m
347347
return;
348348
}
349349
String timestamp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
350-
IProcess process= newProcess(launch, p, renderProcessLabel(cmdLine, timestamp), getDefaultProcessMap());
350+
IProcess process = newProcess(launch, p, renderProcessLabel(p, cmdLine, timestamp), getDefaultProcessMap());
351351
process.setAttribute(DebugPlugin.ATTR_PATH, cmdLine[0]);
352352
process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine));
353353
String ltime = launch.getAttribute(DebugPlugin.ATTR_LAUNCH_TIMESTAMP);

org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/StandardVMRunner.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,31 @@ protected String renderDebugTarget(String classToRun, int host) {
8181

8282
/**
8383
* Returns the 'rendered' name for the specified command line
84-
* @param commandLine the command line
85-
* @param timestamp the run-at time for the process
84+
*
85+
* @param p
86+
* @param commandLine
87+
* the command line
88+
* @param timestamp
89+
* the run-at time for the process
8690
* @return the name for the process
8791
*/
88-
public static String renderProcessLabel(String[] commandLine, String timestamp) {
89-
String format= LaunchingMessages.StandardVMRunner__0____1___2;
90-
return NLS.bind(format, new String[] { commandLine[0], timestamp });
92+
public static String renderProcessLabel(Process p, String[] commandLine, String timestamp) {
93+
String processId = getProcessId(p);
94+
if (processId == null) {
95+
String format = LaunchingMessages.StandardVMRunner__0____1___2;
96+
return NLS.bind(format, new String[] { commandLine[0], timestamp });
97+
}
98+
String format = LaunchingMessages.StandardVMRunner__0____1___2_3;
99+
return NLS.bind(format, new String[] { commandLine[0], timestamp, processId });
100+
}
101+
102+
private static String getProcessId(Process p) {
103+
try {
104+
return p != null ? Long.toString(p.pid()) : null;
105+
} catch (UnsupportedOperationException e) {
106+
// ignore, pid() is not implemented in this JVM
107+
}
108+
return null;
91109
}
92110

93111
/**
@@ -524,7 +542,7 @@ public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor m
524542
return;
525543
}
526544
String timestamp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
527-
IProcess process= newProcess(launch, p, renderProcessLabel(cmdLine, timestamp), getDefaultProcessMap());
545+
IProcess process = newProcess(launch, p, renderProcessLabel(p, cmdLine, timestamp), getDefaultProcessMap());
528546
process.setAttribute(DebugPlugin.ATTR_PATH, cmdLine[0]);
529547
process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine));
530548
String ltime = launch.getAttribute(DebugPlugin.ATTR_LAUNCH_TIMESTAMP);

0 commit comments

Comments
 (0)