1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Allow GdbLaunch#getGDBVersion() to be called more than once.

Originally, we used LaunchUtils.getGDBVersion() to fetch the GDB
version.  Because that method was used for any debug session, we didn't
cache the result of it.

Now that we moved the version handling to the GdbLaunch class, and that
this class is unique per session, we can cache the result of the
getGDBVersion(), allowing it to be called more than once.

Change-Id: I1a396134ca5c609224f8abb7b70d1e0866810497
This commit is contained in:
Marc Khouzam 2016-08-01 14:07:27 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent 80b05f860a
commit fbe9807877

View file

@ -114,6 +114,8 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr
private IMemoryBlockRetrievalManager fMemRetrievalManager;
private IDsfDebugServicesFactory fServiceFactory;
private ILaunchTarget fLaunchTarget;
private String fGdbVersion;
public GdbLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) {
super(launchConfiguration, mode, locator);
@ -500,14 +502,17 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr
/**
* This method actually launches 'gdb --version' to determine the version of
* the GDB that is being used. This method should ideally be called only
* once per session and the resulting version string stored for future uses.
* the GDB that is being used. The result is then cached for any future requests.
*
* A timeout is scheduled which will kill the process if it takes too long.
*
* @since 5.0
*/
public String getGDBVersion() throws CoreException {
if (fGdbVersion != null) {
return fGdbVersion;
}
String cmd = getGDBPath().toOSString() + " --version"; //$NON-NLS-1$
// Parse cmd to properly handle spaces and such things (bug 458499)
@ -559,7 +564,8 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr
"Could not determine GDB version using command: " + StringUtil.join(args, " "), //$NON-NLS-1$ //$NON-NLS-2$
detailedException));
}
return gdbVersion;
fGdbVersion = gdbVersion;
return fGdbVersion;
} catch (IOException e) {
throw new DebugException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED,
"Error with command: " + StringUtil.join(args, " "), e));//$NON-NLS-1$ //$NON-NLS-2$