Fixed the continue command. Add the getregisters command.

This commit is contained in:
moitoius_cp 2008-01-30 16:45:45 +00:00
parent 36c30ac44c
commit 3828af03ab
8 changed files with 107 additions and 12 deletions

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Cosmos.GdbClient.BasicCommands
{
public class BreakCommand : CommandBase<object>
{
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);
}
}
}

View file

@ -9,7 +9,29 @@ namespace Cosmos.GdbClient.BasicCommands
/// </summary>
public class ContinueCommand : CommandBase<object>
{
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));
}
}
}

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Cosmos.GdbClient.BasicCommands
{
public class GetRegistersCommand : CommandBase<string[]>
{
public GetRegistersCommand() : base(GdbController.Instance) { }
protected override void Execute()
{
Controller.PacketReceived += new EventHandler<GdbPacketEventArgs>(Controller_PacketReceived);
Controller.Enqueue(new GdbPacket("g"));
}
void Controller_PacketReceived(object sender, GdbPacketEventArgs e)
{
Controller.PacketReceived -= new EventHandler<GdbPacketEventArgs>(Controller_PacketReceived);
Done(null);
}
}
}

View file

@ -40,8 +40,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BasicCommands\BreakCommand.cs" />
<Compile Include="BasicCommands\CommandBase.cs" />
<Compile Include="BasicCommands\ContinueCommand.cs" />
<Compile Include="BasicCommands\GetRegistersCommand.cs" />
<Compile Include="GdbConnection.cs" />
<Compile Include="GdbPacket.cs" />
<Compile Include="GdbController.cs" />

View file

@ -7,6 +7,7 @@ namespace Cosmos.GdbClient
{
public class GdbConnection
{
private TcpClient _client;
private NetworkStream _stream;
private string _host;

View file

@ -9,15 +9,18 @@ namespace Cosmos.GdbClient
/// </summary>
public class GdbController
{
private GdbConnection _connection;
private static GdbController _instance;
/// <summary>
/// Gets the connection.
/// Gets or sets the default GdbConnection instance.
/// </summary>
public GdbConnection Connection
public static GdbController Instance
{
get { return _connection; }
get { return GdbConnection._instance; }
set { GdbConnection._instance = value; }
}
private GdbConnection _connection;
/// <summary>
/// The parser queue.
/// </summary>
@ -155,13 +158,13 @@ namespace Cosmos.GdbClient
/// </summary>
private void GotAcknowledge()
{
OnAcknowledgementReceived();
lock (_sendQueue)
{
if (_sendQueue.Count != 0)
_sendQueue.Dequeue();
SendPacket();
}
OnAcknowledgementReceived();
}
/// <summary>
@ -205,5 +208,10 @@ namespace Cosmos.GdbClient
{
_connection.Open();
}
public void Close()
{
_connection.Close();
}
}
}

View file

@ -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);

View file

@ -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();
}
}
}