diff --git a/2018-12-local.target b/2018-12-local.target new file mode 100644 index 0000000..29a1a43 --- /dev/null +++ b/2018-12-local.target @@ -0,0 +1,14 @@ + + + + + +-Xms40m +-Xmx512M +-ea +-consolelog + + + + + \ No newline at end of file diff --git a/2018-12.target b/2018-12.target new file mode 100644 index 0000000..244aeab --- /dev/null +++ b/2018-12.target @@ -0,0 +1,79 @@ + + + + + +-Xms40m +-Xmx512M +-ea +-consolelog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/2020-06-local.target b/2020-06-local.target new file mode 100644 index 0000000..32cec92 --- /dev/null +++ b/2020-06-local.target @@ -0,0 +1,14 @@ + + + + + +-Xms40m +-Xmx512M +-ea +-consolelog + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 39346d5..55f5731 100644 --- a/README.md +++ b/README.md @@ -1 +1,16 @@ # DirectRemoteDebug + + +## Development + +### Setup +* Download/install "Eclipse IDE for eclipse committers" +* Download/install "Eclipse CDT 2018-12" +* Set up the target platform to point to the installation above. + +Older version is needed because: + +* org.eclipse.cdt.dsf.gdb.internal.ui.launching.CArgumentsTab; +* org.eclipse.cdt.dsf.gdb.internal.ui.launching.WorkingDirectoryBlock; + +are gone in newer versions. An update is required to get this code working This throws an exception in the newer versions, but the UI is able to recover, so this can still run on newer versions even missing the above \ No newline at end of file diff --git a/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/DirectRemoteDebugLaunchDelegate.java b/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/DirectRemoteDebugLaunchDelegate.java index 9a396f6..5192ba1 100644 --- a/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/DirectRemoteDebugLaunchDelegate.java +++ b/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/DirectRemoteDebugLaunchDelegate.java @@ -1,5 +1,9 @@ package org.eclipse.cdt.launch.remote.direct; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.util.concurrent.RejectedExecutionException; import org.eclipse.cdt.core.model.ICProject; @@ -21,7 +25,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.ISourceLocator; @@ -94,7 +97,7 @@ public void launch(ILaunchConfiguration config, String mode, final GdbLaunch l = (GdbLaunch)launch; try { remoteShell = RSEHelper.execCmdInRemoteShell(config, prelaunchCmd, gdbCommmand.toOSString(), "-version", //$NON-NLS-1$ - new SubProgressMonitor(monitor, 5)); + EclipseCompat.getSubMonitor(monitor, 5)); } catch(Exception el) { RSEHelper.abort(el.getMessage(), el, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); } @@ -107,6 +110,7 @@ public void launch(ILaunchConfiguration config, String mode, gdbReady[0] = false; final Object lock = new Object(); if (remoteShell != null) { + /* remoteShell.addOutputListener(new IHostShellOutputListener() { boolean working = true; @Override @@ -131,6 +135,7 @@ public void shellOutputChanged(IHostShellChangeEvent event) { } } }); + */ try { remoteProcess = new HostShellProcessAdapter(remoteShell); } @@ -138,6 +143,7 @@ public void shellOutputChanged(IHostShellChangeEvent event) { RSEHelper.abort(Messages.DirectRemoteDebugLaunchDelegate_5, e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); } synchronized(lock) { + BufferedReader br = new BufferedReader(new InputStreamReader(remoteProcess.getInputStream())); while (gdbReady[0] == false) { if (monitor.isCanceled() || !remoteShell.isActive()) { if (remoteProcess != null) { @@ -164,7 +170,21 @@ public void run() { } catch(InterruptedException e) { - } + } + try { + String lineString = br.readLine(); + if(lineString.contains("GNU gdb")) { //$NON-NLS-1$ + String versionString = br.readLine(); + version = LaunchUtils.getGDBVersionFromText(versionString); + } + if (lineString.contains("This GDB was configured as")) { //$NON-NLS-1$ + gdbReady[0] = true; + } + } catch (IOException e) { + + } + + } } } diff --git a/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/EclipseCompat.java b/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/EclipseCompat.java new file mode 100644 index 0000000..21944b3 --- /dev/null +++ b/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/EclipseCompat.java @@ -0,0 +1,20 @@ +package org.eclipse.cdt.launch.remote.direct; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubMonitor; +//import org.eclipse.core.runtime.SubProgressMonitor; + + +public class EclipseCompat { + /** + * Get the "SubProgressMonitor" + * @param monitor + * @param ticks + * @return + */ + public static IProgressMonitor getSubMonitor(IProgressMonitor monitor, int work) { + // One could use reflection here to choose between the newer + // and older versions if needed and backwards compat. is desired. + return SubMonitor.convert(monitor, work); + //return new SubProgressMonitor(monitor, ticks); + } +} diff --git a/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/RSEHelper.java b/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/RSEHelper.java index 59f9186..22f1943 100644 --- a/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/RSEHelper.java +++ b/src/org.eclipse.cdt.launch.remote.direct/src/org/eclipse/cdt/launch/remote/direct/RSEHelper.java @@ -11,7 +11,6 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.osgi.util.NLS; import org.eclipse.rse.core.RSECorePlugin; @@ -34,6 +33,8 @@ public class RSEHelper { * @param code * error code */ + + public static void abort(String message, Throwable exception, int code) throws CoreException { IStatus status; if (exception != null) { @@ -145,7 +146,7 @@ public static IHostShell execCmdInRemoteShell(ILaunchConfiguration config, IShellService shellService = null; shellService = (IShellService) getConnectedRemoteShellService(getCurrentConnection(config), - new SubProgressMonitor(monitor, 7)); + EclipseCompat.getSubMonitor(monitor, 7)); // This is necessary because runCommand does not actually run the // command right now. @@ -153,7 +154,7 @@ public static IHostShell execCmdInRemoteShell(ILaunchConfiguration config, IHostShell hostShell = null; if (shellService != null) { hostShell = shellService.launchShell( - "", env, new SubProgressMonitor(monitor, 3)); //$NON-NLS-1$ + "", env, EclipseCompat.getSubMonitor(monitor, 3)); //$NON-NLS-1$ hostShell.writeToShell(remoteCommand); }