mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-13 03:31:22 +00:00
Fixed the continue command. Add the getregisters command.
This commit is contained in:
parent
36c30ac44c
commit
3828af03ab
8 changed files with 107 additions and 12 deletions
23
source/Cosmos.GdbClient/BasicCommands/BreakCommand.cs
Normal file
23
source/Cosmos.GdbClient/BasicCommands/BreakCommand.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
23
source/Cosmos.GdbClient/BasicCommands/GetRegistersCommand.cs
Normal file
23
source/Cosmos.GdbClient/BasicCommands/GetRegistersCommand.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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" />
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace Cosmos.GdbClient
|
|||
{
|
||||
public class GdbConnection
|
||||
{
|
||||
|
||||
private TcpClient _client;
|
||||
private NetworkStream _stream;
|
||||
private string _host;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue