diff --git a/source/Cosmos.GdbClient/BasicCommands/BreakCommand.cs b/source/Cosmos.GdbClient/BasicCommands/BreakCommand.cs new file mode 100644 index 000000000..54e10ddec --- /dev/null +++ b/source/Cosmos.GdbClient/BasicCommands/BreakCommand.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Cosmos.GdbClient.BasicCommands +{ + public class BreakCommand : CommandBase + { + public BreakCommand() : base(GdbController.Instance) { } + + protected override void Execute() + { + Controller.AcknowledgementReceived += new EventHandler(Controller_AcknowledgementReceived); + Controller.Enqueue(new GdbPacket("b")); + } + + void Controller_AcknowledgementReceived(object sender, EventArgs e) + { + Controller.AcknowledgementReceived -= new EventHandler(Controller_AcknowledgementReceived); + Done(null); + } + } +} diff --git a/source/Cosmos.GdbClient/BasicCommands/ContinueCommand.cs b/source/Cosmos.GdbClient/BasicCommands/ContinueCommand.cs index 5965c4a08..9014d7697 100644 --- a/source/Cosmos.GdbClient/BasicCommands/ContinueCommand.cs +++ b/source/Cosmos.GdbClient/BasicCommands/ContinueCommand.cs @@ -9,7 +9,29 @@ namespace Cosmos.GdbClient.BasicCommands /// public class ContinueCommand : CommandBase { - public ContinueCommand(GdbController controller) : base(controller) { } + private uint? _address; + + public uint? Address + { + get { return _address; } + set { _address = value; } + } + + private byte? _signal; + + public byte? Signal + { + get { return _signal; } + set { _signal = value; } + } + + public ContinueCommand() : base(GdbController.Instance) { } + + public ContinueCommand(uint? address) + : this() + { + _address = address; + } void Controller_AcknowledgementReceived(object sender, EventArgs e) { @@ -20,7 +42,19 @@ namespace Cosmos.GdbClient.BasicCommands protected override void Execute() { Controller.AcknowledgementReceived += new EventHandler(Controller_AcknowledgementReceived); - Controller.Enqueue(new GdbPacket("c")); + string cmd = "c"; + + if (_signal.HasValue) + { + cmd += _signal.Value.ToString("x"); + if (_address.HasValue) + cmd += ";"; + } + + if (_address.HasValue) + cmd += _address.Value.ToString("x"); + + Controller.Enqueue(new GdbPacket(cmd)); } } } \ No newline at end of file diff --git a/source/Cosmos.GdbClient/BasicCommands/GetRegistersCommand.cs b/source/Cosmos.GdbClient/BasicCommands/GetRegistersCommand.cs new file mode 100644 index 000000000..8129d0b61 --- /dev/null +++ b/source/Cosmos.GdbClient/BasicCommands/GetRegistersCommand.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Cosmos.GdbClient.BasicCommands +{ + public class GetRegistersCommand : CommandBase + { + public GetRegistersCommand() : base(GdbController.Instance) { } + + protected override void Execute() + { + Controller.PacketReceived += new EventHandler(Controller_PacketReceived); + Controller.Enqueue(new GdbPacket("g")); + } + + void Controller_PacketReceived(object sender, GdbPacketEventArgs e) + { + Controller.PacketReceived -= new EventHandler(Controller_PacketReceived); + Done(null); + } + } +} diff --git a/source/Cosmos.GdbClient/Cosmos.GdbClient.csproj b/source/Cosmos.GdbClient/Cosmos.GdbClient.csproj index 930e43450..72d711d19 100644 --- a/source/Cosmos.GdbClient/Cosmos.GdbClient.csproj +++ b/source/Cosmos.GdbClient/Cosmos.GdbClient.csproj @@ -40,8 +40,10 @@ + + diff --git a/source/Cosmos.GdbClient/GdbConnection.cs b/source/Cosmos.GdbClient/GdbConnection.cs index b8cd3231f..90e83cfc4 100644 --- a/source/Cosmos.GdbClient/GdbConnection.cs +++ b/source/Cosmos.GdbClient/GdbConnection.cs @@ -7,6 +7,7 @@ namespace Cosmos.GdbClient { public class GdbConnection { + private TcpClient _client; private NetworkStream _stream; private string _host; diff --git a/source/Cosmos.GdbClient/GdbController.cs b/source/Cosmos.GdbClient/GdbController.cs index 104143f9a..452d6bfff 100644 --- a/source/Cosmos.GdbClient/GdbController.cs +++ b/source/Cosmos.GdbClient/GdbController.cs @@ -9,15 +9,18 @@ namespace Cosmos.GdbClient /// public class GdbController { - private GdbConnection _connection; + private static GdbController _instance; /// - /// Gets the connection. + /// Gets or sets the default GdbConnection instance. /// - public GdbConnection Connection + public static GdbController Instance { - get { return _connection; } + get { return GdbConnection._instance; } + set { GdbConnection._instance = value; } } + private GdbConnection _connection; + /// /// The parser queue. /// @@ -155,13 +158,13 @@ namespace Cosmos.GdbClient /// private void GotAcknowledge() { - OnAcknowledgementReceived(); lock (_sendQueue) { if (_sendQueue.Count != 0) _sendQueue.Dequeue(); SendPacket(); } + OnAcknowledgementReceived(); } /// @@ -205,5 +208,10 @@ namespace Cosmos.GdbClient { _connection.Open(); } + + public void Close() + { + _connection.Close(); + } } } diff --git a/source/Cosmos.GdbClient/GdbPacket.cs b/source/Cosmos.GdbClient/GdbPacket.cs index 4c57c542d..4cf174f04 100644 --- a/source/Cosmos.GdbClient/GdbPacket.cs +++ b/source/Cosmos.GdbClient/GdbPacket.cs @@ -52,11 +52,11 @@ namespace Cosmos.GdbClient GdbPacket result = new GdbPacket(); result.PacketData = parts1[0]; - if (parts2.Length != 1) + /*if (parts2.Length != 1) { - result.SequenceId = parts2[0]; + //result.SequenceId = parts2[0]; result.PacketData = parts2[1]; - } + }*/ int modulo1 = ModuloChecksum(parts1[0]); int modulo2 = int.Parse(parts1[1], System.Globalization.NumberStyles.HexNumber); diff --git a/source/GdpClientTester/Program.cs b/source/GdpClientTester/Program.cs index f586f84bf..429cc2fd2 100644 --- a/source/GdpClientTester/Program.cs +++ b/source/GdpClientTester/Program.cs @@ -22,9 +22,13 @@ namespace GdpClientTester return; } - ContinueCommand cmd = new ContinueCommand(controller); - cmd.Send(); + new ContinueCommand().Send(); + Console.WriteLine("Running, press a key to break."); + Console.ReadLine(); + new BreakCommand().Send(); + new GetRegistersCommand().Send(); Console.WriteLine("Done"); + Console.ReadLine(); } } }