1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 458066 - cannot specify pid to Standalone Debugger

- allow pid to be specified following -a option for Standalone debugger
- if pid is specified, use it to set the ATTR_ATTACH_PROCESS_ID
  setting for the launch configuration
- setting the pid will cause the process dialog not to appear and
  the debugger will attempt to debug the given process
- an invalid pid will result in in the dialog being opened
- the pid is not used with the -r option and is ignored
- updated the README file and docs

Change-Id: I5a1d39f97285ad41dcb986dfb4692f9d808bafeb
This commit is contained in:
Jeff Johnston 2015-01-28 19:14:22 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent 5df84dcfe0
commit f433cb1e85
7 changed files with 51 additions and 16 deletions

View file

@ -16,11 +16,11 @@
The script contains the command-line needed to start Eclipse and to pass appropriate
parameters at start-up. The following are the command-line options supported:
<h4>-a</h4>
<h4>-a [pid]</h4>
<p>This option specifies that you want to attach and debug an existing executable that is running on your system.
The option will bring up a dialog which contains a list of current executables running and you may choose the
executable(s) you wish to attach to. You also have the option of starting a new executable, if desired, but you
cannot specify a build log using this method.
If no pid is specified or an invalid pid is specified, the option will bring up a dialog which contains a list of current executables running and you may choose the
executable(s) you wish to attach to. The dialog will also give you the option of starting a new executable, if desired, but you
cannot specify a build log using this method. When used at the same as the -r option, the pid argument is ignored.
<h4>-b &lt;build log&gt;</h4>
<p>This option specifies an optional build log to use for indexing the source. The build log

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.cdt.debug.application;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Version: 1.1.0.qualifier
Bundle-Activator: org.eclipse.cdt.debug.application.Activator
Bundle-Vendor: %provider
Require-Bundle: org.eclipse.ui,

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<version>1.0.0-SNAPSHOT</version>
<version>1.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.debug.application</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -20,8 +20,11 @@ The script takes a few options which are mentioned below:
-consoleLog : if you want error messages reported directly to the command console
-a : specify attaching to an existing executable on system. A dialog will
be brought up to allow you to select which one.
-a [pid] : specify attaching to an existing executable running on system. If no pid is
specified, a dialog will be brought up to allow you to select an executable
from the list of existing processes. The same dialog will be brought up if
the specified pid is invalid. The pid is not used for a remote debugging
session triggered by the -r option described below.
-b $PATH : path to build log for an executable. This will be used to figure out
include paths and compilation flags. This option assumes you will

View file

@ -1,6 +1,6 @@
#!/bin/sh
###############################################################################
# Copyright (c) 2014 Red Hat, Inc. and others
# Copyright (c) 2014, 2015 Red Hat, Inc. and others
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@ -27,7 +27,7 @@ Indexing assist options:
-b BUILD_LOG build log to use for compiler includes/flags
Target options:
-a attach to an existing process (list will be shown)
-a [pid] attach using the optional pid or prompt for a pid
-c COREFILE debug core-file (should also specify executable)
-e EXECUTABLE [ARGS...] debug given executable (passing ARGS to main)
-r ADDRESS:PORT debug toward the specified remote server. Can be

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2014 Red Hat, Inc.
* Copyright (c) 2013, 2015 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -143,6 +143,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
String arguments = null;
String remoteAddress = null;
String remotePort = null;
String pid = null;
String[] args = Platform.getCommandLineArgs();
try {
@ -161,6 +162,14 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
// Make sure 'executable' is still null in case we are dealing with a remote
// session that is also an attach, as the -r flag could have been set first
executable = null;
// Check for optional pid
if (i + 1 < args.length) {
if (!args[i+1].startsWith("-")) { //$NON-NLS-1$
++i;
pid = args[i];
}
}
}
else if ("-c".equals(args[i])) { //$NON-NLS-1$
++i;
@ -347,7 +356,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
remotePort != null && remotePort.length() > 0) {
config = DebugRemoteExecutable.createLaunchConfig(monitor, buildLog, executable, remoteAddress, remotePort, attachExecutable);
} else if (attachExecutable) {
config = DebugAttachedExecutable.createLaunchConfig(monitor, buildLog);
config = DebugAttachedExecutable.createLaunchConfig(monitor, buildLog, pid);
} else if (corefile != null && corefile.length() > 0) {
config = DebugCoreFile.createLaunchConfig(monitor, buildLog, executable, corefile);
} else if (executable != null && executable.length() > 0) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014 Red Hat, Inc.
* Copyright (c) 2014, 2015 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -82,15 +82,28 @@ public class DebugAttachedExecutable {
* Import given executable into the Executables project then create a launch configuration.
*
* @param monitor
* @param executable
* @param buildLog
* @param arguments
* @throws CoreException
* @throws InterruptedException
*/
public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor,
String buildLog)
throws CoreException, InterruptedException {
return createLaunchConfig(monitor, buildLog, null);
}
/**
* Import given executable into the Executables project then create a launch configuration.
*
* @param monitor
* @param buildLog
* @param pid
* @throws CoreException
* @throws InterruptedException
*/
public static ILaunchConfiguration createLaunchConfig(IProgressMonitor monitor,
String buildLog, String pid)
throws CoreException, InterruptedException {
ILaunchConfiguration config = null;
String defaultProjectName = "Executables"; //$NON-NLS-1$
@ -202,7 +215,7 @@ public class DebugAttachedExecutable {
}
}
config = createConfiguration(true);
config = createConfiguration(pid, true);
monitor.worked(1);
return config;
}
@ -212,6 +225,10 @@ public class DebugAttachedExecutable {
}
protected static ILaunchConfiguration createConfiguration(boolean save) {
return createConfiguration(null, save);
}
protected static ILaunchConfiguration createConfiguration(String pid, boolean save) {
ILaunchConfiguration config = null;
try {
ILaunchConfigurationType configType = getLaunchConfigType();
@ -226,6 +243,12 @@ public class DebugAttachedExecutable {
wc.setAttribute(
ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY,
(String) null);
if (pid != null) {
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID,
Integer.valueOf(pid));
}
if (save) {
config = wc.doSave();
} else {