Implemented continue execution command

This commit is contained in:
Benito Palacios Sánchez 2014-12-10 23:58:16 +01:00
parent dfdf5ebdb1
commit cc85ea73fb
5 changed files with 76 additions and 1 deletions

View File

@ -27,6 +27,7 @@ using Moq;
using Moq.Protected;
using NitroDebugger;
using System.Threading;
using System.Text;
namespace UnitTests
{
@ -224,6 +225,23 @@ namespace UnitTests
StopSignal reason = this.client.AskHaltedReason();
Assert.IsTrue(reason.HasFlag(StopSignal.HostBreak));
}
[Test]
public void ContinueExecution()
{
this.serverStream.WriteByte(RawPacket.Ack);
this.client.ContinueExecution();
string rcv = this.Read();
Assert.AreEqual("c", rcv.Substring(1, rcv.Length - 4));
}
private string Read()
{
Thread.Sleep(50);
byte[] buffer = new byte[10 * 1024];
int read = this.serverStream.Read(buffer, 0, buffer.Length);
return Encoding.ASCII.GetString(buffer, 0, read);
}
}
}

View File

@ -137,6 +137,15 @@ namespace UnitTests
{
HaltedReasonCommand cmd = new HaltedReasonCommand();
Assert.AreEqual("?", cmd.Command);
Assert.AreEqual("?", cmd.Pack());
}
[Test]
public void CreateContinueCommand()
{
ContinueCommand cmd = new ContinueCommand();
Assert.AreEqual("c", cmd.Command);
Assert.AreEqual("c", cmd.Pack());
}
}
}

View File

@ -50,6 +50,7 @@
<Compile Include="RSP\Packets\OkReply.cs" />
<Compile Include="RSP\Packets\HaltedReasonCommand.cs" />
<Compile Include="RSP\Packets\StopSignalReply.cs" />
<Compile Include="RSP\Packets\ContinueCommand.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

View File

@ -109,6 +109,12 @@ namespace NitroDebugger.RSP
return ((StopSignalReply)response).Signal.HasFlag(StopSignal.HostBreak);
}
public void ContinueExecution()
{
ContinueCommand cont = new ContinueCommand();
this.SafeSending(cont);
}
private ReplyPacket SafeInterruption()
{
ReplyPacket response = null;
@ -139,7 +145,9 @@ namespace NitroDebugger.RSP
try {
this.presentation.SendCommand(command);
response = this.presentation.ReceiveReply();
if (validReplyTypes.Length > 0)
response = this.presentation.ReceiveReply();
} catch (SocketException) {
error = true;
} catch (ProtocolViolationException) {

View File

@ -0,0 +1,39 @@
//
// ContinueCommand.cs
//
// Author:
// Benito Palacios Sánchez <benito356@gmail.com>
//
// Copyright (c) 2014 Benito Palacios Sánchez
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using NitroDebugger.RSP;
namespace NitroDebugger.RSP.Packets
{
public class ContinueCommand : CommandPacket
{
public ContinueCommand()
: base("c")
{
}
protected override string PackArguments()
{
return "";
}
}
}