Skip to content

Commit

Permalink
Support local gdb but remote target, testing ongoing: checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
haneefdm committed Apr 27, 2019
1 parent 8b0884c commit 8fb5bd1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/MICore/Debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ protected void OnStateChanged(string mode, Results results)
{
}
else if (mode == "connected")
{
{
IsTargetRemoteOrExtendedRemote = true;
if (this.ProcessState == ProcessState.NotConnected)
this.ProcessState = ProcessState.Running;

Expand Down Expand Up @@ -578,6 +579,8 @@ public Task CmdBreak(BreakRequest request)
return CmdBreakInternal();
}

private bool IsTargetRemoteOrExtendedRemote { get; set; }

internal bool IsLocalGdb()
{
return (this.MICommandFactory.Mode == MIMode.Gdb &&
Expand Down Expand Up @@ -614,7 +617,7 @@ public async Task<Results> CmdTerminate()
// the normal path of sending an internal async break so we can exit doesn't work.
// Therefore, we will call TerminateProcess on the debuggee with the exit code of 0
// to terminate debugging.
if (this.IsLocalGdb() &&
if (this.IsLocalGdb() && !IsTargetRemoteOrExtendedRemote &&
(this.IsCygwin || this.IsMinGW) &&
_debuggeePids.Count > 0)
{
Expand Down Expand Up @@ -655,6 +658,7 @@ public async Task<Results> CmdTerminate()
/// <returns>True if any pids were terminated successfully</returns>
private bool TerminateAllPids()
{
Debug.Assert(IsTargetRemoteOrExtendedRemote == false, "should not terminate PIDs if target is remote");
var terminated = false;
foreach (var pid in _debuggeePids)
{
Expand Down Expand Up @@ -704,7 +708,7 @@ public Task CmdBreakInternal()

// Note that interrupt doesn't work on OS X with gdb:
// https://sourceware.org/bugzilla/show_bug.cgi?id=20035
if (IsLocalGdb())
if (IsLocalGdb() && !IsTargetRemoteOrExtendedRemote)
{
bool useSignal = false;
int debuggeePid = 0;
Expand Down Expand Up @@ -892,6 +896,7 @@ private Task<Results> CmdAsyncInternal(string command, ResultClass expectedResul

private Task<Results> CmdBreakUnix(int debugeePid, ResultClass expectedResultClass)
{
Debug.Assert(IsTargetRemoteOrExtendedRemote == false, "Don't use SIGINT to break if target is remote");
// Send sigint to the debuggee process. This is the equivalent of hitting ctrl-c on the console.
// This will cause gdb to async-break. This is necessary because gdb does not support async break
// when attached.
Expand Down Expand Up @@ -1209,6 +1214,14 @@ public void ProcessStdOutLine(string line)
Results results = _miResults.ParseCommandOutput(noprefix);
Logger.WriteLine(id + ": elapsed time " + (int)(DateTime.Now - waitingOperation.StartTime).TotalMilliseconds);
waitingOperation.OnComplete(results, this.MICommandFactory);
if (noprefix.StartsWith("connected", StringComparison.Ordinal))
{
// You can have a local gdb, but a remote program, running wherever, locally or exernal devices via
// USB/serial/tty/tcp ports through a gdb-server. We get this response from gdb when user requests a
// `-target-select [remote | extended-remote] ...` command via launch commands or manually.
// Pids can be fake and/or may not be on this computer
IsTargetRemoteOrExtendedRemote = true;
}
return;
}
}
Expand Down

0 comments on commit 8fb5bd1

Please sign in to comment.