bool
CommunicationKDP::SendRequestAndGetReply (const CommandType command,
- const uint8_t request_sequence_id,
- const PacketStreamType &request_packet,
+ const PacketStreamType &request_packet,
DataExtractor &reply_packet)
{
if (IsRunning())
// NOTE: this only works for packets that are in native endian byte order
assert (request_packet.GetSize() == *((uint16_t *)(request_packet.GetData() + 2)));
#endif
- if (SendRequestPacketNoLock(request_packet))
+ lldb::offset_t offset = 1;
+ const uint32_t num_retries = 3;
+ for (uint32_t i=0; i<num_retries; ++i)
{
- if (WaitForPacketWithTimeoutMicroSecondsNoLock (reply_packet, GetPacketTimeoutInMicroSeconds ()))
+ if (SendRequestPacketNoLock(request_packet))
{
- lldb::offset_t offset = 0;
- const uint8_t reply_command = reply_packet.GetU8 (&offset);
- const uint8_t reply_sequence_id = reply_packet.GetU8 (&offset);
- if ((reply_command & eCommandTypeMask) == command)
+ const uint8_t request_sequence_id = (uint8_t)request_packet.GetData()[1];
+ if (WaitForPacketWithTimeoutMicroSecondsNoLock (reply_packet, GetPacketTimeoutInMicroSeconds ()))
{
- if (request_sequence_id == reply_sequence_id)
+ offset = 0;
+ const uint8_t reply_command = reply_packet.GetU8 (&offset);
+ const uint8_t reply_sequence_id = reply_packet.GetU8 (&offset);
+ if ((reply_command & eCommandTypeMask) == command)
{
- if (command == KDP_RESUMECPUS)
- m_is_running.SetValue(true, eBroadcastAlways);
- return true;
+ if (request_sequence_id == reply_sequence_id)
+ {
+ if (command == KDP_RESUMECPUS)
+ m_is_running.SetValue(true, eBroadcastAlways);
+ return true;
+ }
}
}
}
const CommandType command = KDP_CONNECT;
// Length is 82 uint16_t and the length of the greeting C string with the terminating NULL
const uint32_t command_length = 8 + 2 + 2 + ::strlen(greeting) + 1;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
// Always send connect ports as little endian
request_packet.SetByteOrder (eByteOrderLittle);
request_packet.SetByteOrder (m_byte_order);
request_packet.PutCString (greeting);
DataExtractor reply_packet;
- return SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet);
+ return SendRequestAndGetReply (command, request_packet, reply_packet);
}
void
const CommandType command = KDP_REATTACH;
// Length is 8 bytes for the header plus 2 bytes for the reply UDP port
const uint32_t command_length = 8 + 2;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
// Always send connect ports as little endian
request_packet.SetByteOrder (eByteOrderLittle);
request_packet.PutHex16(reply_port);
request_packet.SetByteOrder (m_byte_order);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
// Reset the sequence ID to zero for reattach
ClearKDPSettings ();
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = KDP_VERSION;
const uint32_t command_length = 8;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
lldb::offset_t offset = 8;
m_kdp_version_version = reply_packet.GetU32 (&offset);
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = KDP_IMAGEPATH;
const uint32_t command_length = 8;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
const char *path = reply_packet.PeekCStr(8);
if (path && path[0])
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = KDP_HOSTINFO;
const uint32_t command_length = 8;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
lldb::offset_t offset = 8;
m_kdp_hostinfo_cpu_mask = reply_packet.GetU32 (&offset);
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = KDP_KERNELVERSION;
const uint32_t command_length = 8;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
const char *kernel_version_cstr = reply_packet.PeekCStr(8);
if (kernel_version_cstr && kernel_version_cstr[0])
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = KDP_DISCONNECT;
const uint32_t command_length = 8;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
// Are we supposed to get a reply for disconnect?
}
const CommandType command = use_64 ? KDP_READMEM64 : KDP_READMEM;
// Size is header + address size + uint32_t length
const uint32_t command_length = 8 + command_addr_byte_size + 4;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutMaxHex64 (addr, command_addr_byte_size);
request_packet.PutHex32 (dst_len);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
lldb::offset_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
const CommandType command = use_64 ? KDP_WRITEMEM64 : KDP_WRITEMEM;
// Size is header + address size + uint32_t length
const uint32_t command_length = 8 + command_addr_byte_size + 4 + src_len;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutMaxHex64 (addr, command_addr_byte_size);
request_packet.PutHex32 (src_len);
request_packet.PutRawBytes(src, src_len);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
lldb::offset_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
// Size is header + address size + uint32_t length
const uint32_t command_length = 8 + src_len;
const CommandType command = (CommandType)command_byte;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutRawBytes(src, src_len);
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
lldb::offset_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
const CommandType command = KDP_READREGS;
// Size is header + 4 byte cpu and 4 byte flavor
const uint32_t command_length = 8 + 4 + 4;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutHex32 (cpu);
request_packet.PutHex32 (flavor);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
lldb::offset_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
const CommandType command = KDP_WRITEREGS;
// Size is header + 4 byte cpu and 4 byte flavor
const uint32_t command_length = 8 + 4 + 4 + src_len;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutHex32 (cpu);
request_packet.PutHex32 (flavor);
request_packet.Write(src, src_len);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
lldb::offset_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = KDP_RESUMECPUS;
const uint32_t command_length = 12;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutHex32(GetCPUMask());
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
return true;
return false;
}
(use_64 ? KDP_BREAKPOINT_REMOVE64 : KDP_BREAKPOINT_REMOVE);
const uint32_t command_length = 8 + command_addr_byte_size;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
request_packet.PutMaxHex64 (addr, command_addr_byte_size);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
{
lldb::offset_t offset = 8;
uint32_t kdp_error = reply_packet.GetU32 (&offset);
PacketStreamType request_packet (Stream::eBinary, m_addr_byte_size, m_byte_order);
const CommandType command = KDP_SUSPEND;
const uint32_t command_length = 8;
- const uint32_t request_sequence_id = m_request_sequence_id;
MakeRequestPacketHeader (command, request_packet, command_length);
DataExtractor reply_packet;
- if (SendRequestAndGetReply (command, request_sequence_id, request_packet, reply_packet))
+ if (SendRequestAndGetReply (command, request_packet, reply_packet))
return true;
return false;
}