Skip to content

Commit

Permalink
Send kill command rather than -exec-interrupt when remote attached. (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmaybee authored Nov 28, 2017
1 parent 3a4c8a9 commit 618cbde
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/MICore/Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ this._launchOptions is LocalLaunchOptions &&
private bool IsRemoteGdb()
{
return this.MICommandFactory.Mode == MIMode.Gdb &&
(this._launchOptions is PipeLaunchOptions ||
(this._launchOptions is PipeLaunchOptions || this._launchOptions is UnixShellPortLaunchOptions ||
(this._launchOptions is LocalLaunchOptions
&& !String.IsNullOrEmpty(((LocalLaunchOptions)this._launchOptions).MIDebuggerServerAddress)));
}
Expand Down Expand Up @@ -737,6 +737,14 @@ public Task CmdBreakInternal()
return Task.FromResult<Results>(new Results(ResultClass.done));
}
}
else if (IsRemoteGdb() && _transport is UnixShellPortTransport)
{
int pid = PidByInferior("i1");
if (pid != 0 && ((UnixShellPortTransport)_transport).Interrupt(pid))
{
return Task.FromResult<Results>(new Results(ResultClass.done));
}
}

var res = CmdAsync("-exec-interrupt", ResultClass.done);
return res.ContinueWith((t) =>
Expand Down
24 changes: 24 additions & 0 deletions src/MICore/Transports/UnixShellPortTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,29 @@ public bool CanExecuteCommand()
{
return true;
}

public bool Interrupt(int pid)
{
int exitCode = -1;
string output = null;
string error = null;
string killCmd = string.Format(CultureInfo.InvariantCulture, "kill -2 {0}", pid);

try
{
exitCode = ExecuteSyncCommand(MICoreResources.Info_KillingPipeProcess, killCmd, System.Threading.Timeout.Infinite, out output, out error);

if (exitCode != 0)
{
this._callback.OnStdErrorLine(string.Format(CultureInfo.InvariantCulture, MICoreResources.Warn_ProcessExit, killCmd, exitCode));
}
}
catch (Exception e)
{
this._callback.OnStdErrorLine(string.Format(CultureInfo.InvariantCulture, MICoreResources.Warn_ProcessException, killCmd, e.Message));
}

return exitCode == 0;
}
}
}

0 comments on commit 618cbde

Please sign in to comment.