本文整理汇总了C++中StringExtractorGDBRemote类的典型用法代码示例。如果您正苦于以下问题:C++ StringExtractorGDBRemote类的具体用法?C++ StringExtractorGDBRemote怎么用?C++ StringExtractorGDBRemote使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringExtractorGDBRemote类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendPacketNoLock
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_Mode(
StringExtractorGDBRemote &packet) {
packet.SetFilePos(::strlen("vFile:mode:"));
std::string path;
packet.GetHexByteString(path);
if (!path.empty()) {
Error error;
const uint32_t mode = File::GetPermissions(FileSpec{path, true}, error);
StreamString response;
response.Printf("F%u", mode);
if (mode == 0 || error.Fail())
response.Printf(",%i", (int)error.GetError());
return SendPacketNoLock(response.GetString());
}
return SendErrorResponse(23);
}
示例2: SendUnimplementedResponse
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerPlatform::Handle_QSetWorkingDir (StringExtractorGDBRemote &packet)
{
packet.SetFilePos (::strlen ("QSetWorkingDir:"));
std::string path;
packet.GetHexByteString (path);
#ifdef _WIN32
// Not implemented on Windows
return SendUnimplementedResponse ("GDBRemoteCommunicationServerPlatform::Handle_QSetWorkingDir unimplemented");
#else
// If this packet is sent to a platform, then change the current working directory
if (::chdir(path.c_str()) != 0)
return SendErrorResponse (errno);
return SendOKResponse ();
#endif
}
示例3: TEST_F
TEST_F(GDBRemoteClientBaseTest, SendContinueAndWait) {
StringExtractorGDBRemote response;
ContinueFixture fix;
if (HasFailure())
return;
// Continue. The inferior will stop with a signal.
ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("T01"));
ASSERT_EQ(eStateStopped, fix.SendCPacket(response));
ASSERT_EQ("T01", response.GetStringRef());
ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response));
ASSERT_EQ("c", response.GetStringRef());
// Continue. The inferior will exit.
ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("W01"));
ASSERT_EQ(eStateExited, fix.SendCPacket(response));
ASSERT_EQ("W01", response.GetStringRef());
ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response));
ASSERT_EQ("c", response.GetStringRef());
// Continue. The inferior will get killed.
ASSERT_EQ(PacketResult::Success, fix.server.SendPacket("X01"));
ASSERT_EQ(eStateExited, fix.SendCPacket(response));
ASSERT_EQ("X01", response.GetStringRef());
ASSERT_EQ(PacketResult::Success, fix.server.GetPacket(response));
ASSERT_EQ("c", response.GetStringRef());
}
示例4: SendPacketNoLock
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServer::Handle_qPlatform_chmod (StringExtractorGDBRemote &packet)
{
packet.SetFilePos(::strlen("qPlatform_chmod:"));
mode_t mode = packet.GetHexMaxU32(false, UINT32_MAX);
if (packet.GetChar() == ',')
{
std::string path;
packet.GetHexByteString(path);
Error error = Host::SetFilePermissions (path.c_str(), mode);
if (error.Success())
return SendPacketNoLock ("OK", 2);
else
return SendErrorResponse(error.GetError());
}
return SendErrorResponse(19);
}
示例5: SendPacket
bool
GDBRemoteCommunicationServer::Handle_qUserName (StringExtractorGDBRemote &packet)
{
// Packet format: "qUserName:%i" where %i is the uid
packet.SetFilePos(::strlen ("qUserName:"));
uint32_t uid = packet.GetU32 (UINT32_MAX);
if (uid != UINT32_MAX)
{
std::string name;
if (Host::GetUserName (uid, name))
{
StreamString response;
response.PutCStringAsRawHex8 (name.c_str());
return SendPacket (response);
}
}
return SendErrorResponse (5);
}
示例6: SendErrorResponse
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServer::SendIllFormedResponse(
const StringExtractorGDBRemote &failed_packet, const char *message) {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
if (log)
log->Printf("GDBRemoteCommunicationServer::%s: ILLFORMED: '%s' (%s)",
__FUNCTION__, failed_packet.GetStringRef().c_str(),
message ? message : "");
return SendErrorResponse(0x03);
}
示例7: TEST_F
TEST_F(GDBRemoteClientBaseTest, SendPacketAndReceiveResponseWithOutputSupport) {
StringExtractorGDBRemote response;
StreamString command_output;
ASSERT_EQ(PacketResult::Success, server.SendPacket("O"));
ASSERT_EQ(PacketResult::Success, server.SendPacket("O48656c6c6f2c"));
ASSERT_EQ(PacketResult::Success, server.SendPacket("O20"));
ASSERT_EQ(PacketResult::Success, server.SendPacket("O"));
ASSERT_EQ(PacketResult::Success, server.SendPacket("O776f726c64"));
ASSERT_EQ(PacketResult::Success, server.SendPacket("OK"));
PacketResult result = client.SendPacketAndReceiveResponseWithOutputSupport(
"qRcmd,test", response, true,
[&command_output](llvm::StringRef output) { command_output << output; });
ASSERT_EQ(PacketResult::Success, result);
ASSERT_EQ("OK", response.GetStringRef());
ASSERT_EQ("Hello, world", command_output.GetString().str());
}
示例8: SendPacketNoLock
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qPlatform_chmod (StringExtractorGDBRemote &packet)
{
packet.SetFilePos(::strlen("qPlatform_chmod:"));
mode_t mode = packet.GetHexMaxU32(false, UINT32_MAX);
if (packet.GetChar() == ',')
{
std::string path;
packet.GetHexByteString(path);
Error error = FileSystem::SetFilePermissions(FileSpec{path, true}, mode);
StreamGDBRemote response;
response.Printf("F%u", error.GetError());
return SendPacketNoLock(response.GetData(), response.GetSize());
}
return SendErrorResponse(19);
}
示例9: SendUnimplementedResponse
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_pWrite(
StringExtractorGDBRemote &packet) {
#ifdef _WIN32
return SendUnimplementedResponse("GDBRemoteCommunicationServerCommon::Handle_"
"vFile_pWrite() unimplemented");
#else
packet.SetFilePos(::strlen("vFile:pwrite:"));
StreamGDBRemote response;
response.PutChar('F');
int fd = packet.GetU32(UINT32_MAX);
if (packet.GetChar() == ',') {
off_t offset = packet.GetU64(UINT32_MAX);
if (packet.GetChar() == ',') {
std::string buffer;
if (packet.GetEscapedBinaryData(buffer)) {
const ssize_t bytes_written =
::pwrite(fd, buffer.data(), buffer.size(), offset);
const int save_errno = bytes_written == -1 ? errno : 0;
response.Printf("%zi", bytes_written);
if (save_errno)
response.Printf(",%i", save_errno);
} else {
response.Printf("-1,%i", EINVAL);
}
return SendPacketNoLock(response.GetString());
}
}
return SendErrorResponse(27);
#endif
}
示例10: TEST_F
TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) {
std::thread server_thread([this] {
for (;;) {
StringExtractorGDBRemote request;
PacketResult result = server.GetPacket(request);
if (result == PacketResult::ErrorDisconnected)
return;
ASSERT_EQ(PacketResult::Success, result);
StringRef ref = request.GetStringRef();
ASSERT_TRUE(ref.consume_front("qSpeedTest:response_size:"));
int size;
ASSERT_FALSE(ref.consumeInteger(10, size)) << "ref: " << ref;
std::string response(size, 'X');
ASSERT_EQ(PacketResult::Success, server.SendPacket(response));
}
});
StreamString ss;
client.TestPacketSpeed(10, 32, 32, 4096, true, ss);
client.Disconnect();
server_thread.join();
GTEST_LOG_(INFO) << "Formatted output: " << ss.GetData();
auto object_sp = StructuredData::ParseJSON(ss.GetString());
ASSERT_TRUE(bool(object_sp));
auto dict_sp = object_sp->GetAsDictionary();
ASSERT_TRUE(bool(dict_sp));
object_sp = dict_sp->GetValueForKey("packet_speeds");
ASSERT_TRUE(bool(object_sp));
dict_sp = object_sp->GetAsDictionary();
ASSERT_TRUE(bool(dict_sp));
int num_packets;
ASSERT_TRUE(dict_sp->GetValueForKeyAsInteger("num_packets", num_packets))
<< ss.GetString();
ASSERT_EQ(10, num_packets);
}
示例11: SendErrorResponse
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerPlatform::Handle_qKillSpawnedProcess(
StringExtractorGDBRemote &packet) {
packet.SetFilePos(::strlen("qKillSpawnedProcess:"));
lldb::pid_t pid = packet.GetU64(LLDB_INVALID_PROCESS_ID);
// verify that we know anything about this pid.
// Scope for locker
{
std::lock_guard<std::recursive_mutex> guard(m_spawned_pids_mutex);
if (m_spawned_pids.find(pid) == m_spawned_pids.end()) {
// not a pid we know about
return SendErrorResponse(10);
}
}
// go ahead and attempt to kill the spawned process
if (KillSpawnedProcess(pid))
return SendOKResponse();
else
return SendErrorResponse(11);
}
示例12: SendOKResponse
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServer::Handle_qSpeedTest (StringExtractorGDBRemote &packet)
{
packet.SetFilePos(::strlen ("qSpeedTest:"));
std::string key;
std::string value;
bool success = packet.GetNameColonValue(key, value);
if (success && key.compare("response_size") == 0)
{
uint32_t response_size = Args::StringToUInt32(value.c_str(), 0, 0, &success);
if (success)
{
if (response_size == 0)
return SendOKResponse();
StreamString response;
uint32_t bytes_left = response_size;
response.PutCString("data:");
while (bytes_left > 0)
{
if (bytes_left >= 26)
{
response.PutCString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
bytes_left -= 26;
}
else
{
response.Printf ("%*.*s;", bytes_left, bytes_left, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
bytes_left = 0;
}
}
return SendPacketNoLock (response.GetData(), response.GetSize());
}
}
return SendErrorResponse (7);
}
示例13: lock
bool GDBRemoteClientBase::ShouldStop(const UnixSignals &signals,
StringExtractorGDBRemote &response) {
std::lock_guard<std::mutex> lock(m_mutex);
if (m_async_count == 0)
return true; // We were not interrupted. The process stopped on its own.
// Older debugserver stubs (before April 2016) can return two
// stop-reply packets in response to a ^C packet.
// Additionally, all debugservers still return two stop replies if
// the inferior stops due to some other reason before the remote
// stub manages to interrupt it. We need to wait for this
// additional packet to make sure the packet sequence does not get
// skewed.
StringExtractorGDBRemote extra_stop_reply_packet;
uint32_t timeout_usec = 100000; // 100ms
ReadPacket(extra_stop_reply_packet, timeout_usec, false);
// Interrupting is typically done using SIGSTOP or SIGINT, so if
// the process stops with some other signal, we definitely want to
// stop.
const uint8_t signo = response.GetHexU8(UINT8_MAX);
if (signo != signals.GetSignalNumberFromName("SIGSTOP") &&
signo != signals.GetSignalNumberFromName("SIGINT"))
return true;
// We probably only stopped to perform some async processing, so continue
// after that is done.
// TODO: This is not 100% correct, as the process may have been stopped with
// SIGINT or SIGSTOP
// that was not caused by us (e.g. raise(SIGINT)). This will normally cause a
// stop, but if it's
// done concurrently with a async interrupt, that stop will get eaten
// (llvm.org/pr20231).
return false;
}
示例14: SendUnimplementedResponse
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServer::Handle_vFile_pRead (StringExtractorGDBRemote &packet)
{
#ifdef _WIN32
// Not implemented on Windows
return SendUnimplementedResponse("GDBRemoteCommunicationServer::Handle_vFile_pRead() unimplemented");
#else
StreamGDBRemote response;
packet.SetFilePos(::strlen("vFile:pread:"));
int fd = packet.GetS32(-1);
if (packet.GetChar() == ',')
{
uint64_t count = packet.GetU64(UINT64_MAX);
if (packet.GetChar() == ',')
{
uint64_t offset = packet.GetU64(UINT32_MAX);
if (count == UINT64_MAX)
{
response.Printf("F-1:%i", EINVAL);
return SendPacketNoLock(response.GetData(), response.GetSize());
}
std::string buffer(count, 0);
const ssize_t bytes_read = ::pread (fd, &buffer[0], buffer.size(), offset);
const int save_errno = bytes_read == -1 ? errno : 0;
response.PutChar('F');
response.Printf("%zi", bytes_read);
if (save_errno)
response.Printf(",%i", save_errno);
else
{
response.PutChar(';');
response.PutEscapedBytes(&buffer[0], bytes_read);
}
return SendPacketNoLock(response.GetData(), response.GetSize());
}
}
return SendErrorResponse(21);
#endif
}
示例15: WaitForPacketWithTimeoutMicroSecondsNoLock
//void *
//GDBRemoteCommunicationServer::AsyncThread (void *arg)
//{
// GDBRemoteCommunicationServer *server = (GDBRemoteCommunicationServer*) arg;
//
// Log *log;// (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
// if (log)
// log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) thread starting...", __FUNCTION__, arg, process->GetID());
//
// StringExtractorGDBRemote packet;
//
// while ()
// {
// if (packet.
// }
//
// if (log)
// log->Printf ("ProcessGDBRemote::%s (arg = %p, pid = %i) thread exiting...", __FUNCTION__, arg, process->GetID());
//
// process->m_async_thread = LLDB_INVALID_HOST_THREAD;
// return NULL;
//}
//
bool
GDBRemoteCommunicationServer::GetPacketAndSendResponse (uint32_t timeout_usec,
Error &error,
bool &interrupt,
bool &quit)
{
StringExtractorGDBRemote packet;
PacketResult packet_result = WaitForPacketWithTimeoutMicroSecondsNoLock (packet, timeout_usec);
if (packet_result == PacketResult::Success)
{
const StringExtractorGDBRemote::ServerPacketType packet_type = packet.GetServerPacketType ();
switch (packet_type)
{
case StringExtractorGDBRemote::eServerPacketType_nack:
case StringExtractorGDBRemote::eServerPacketType_ack:
break;
case StringExtractorGDBRemote::eServerPacketType_invalid:
error.SetErrorString("invalid packet");
quit = true;
break;
case StringExtractorGDBRemote::eServerPacketType_interrupt:
error.SetErrorString("interrupt received");
interrupt = true;
break;
default:
case StringExtractorGDBRemote::eServerPacketType_unimplemented:
packet_result = SendUnimplementedResponse (packet.GetStringRef().c_str());
break;
case StringExtractorGDBRemote::eServerPacketType_A:
packet_result = Handle_A (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qfProcessInfo:
packet_result = Handle_qfProcessInfo (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qsProcessInfo:
packet_result = Handle_qsProcessInfo (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qC:
packet_result = Handle_qC (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qHostInfo:
packet_result = Handle_qHostInfo (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qLaunchGDBServer:
packet_result = Handle_qLaunchGDBServer (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qKillSpawnedProcess:
packet_result = Handle_qKillSpawnedProcess (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qLaunchSuccess:
packet_result = Handle_qLaunchSuccess (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qGroupName:
packet_result = Handle_qGroupName (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qProcessInfoPID:
packet_result = Handle_qProcessInfoPID (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qSpeedTest:
packet_result = Handle_qSpeedTest (packet);
break;
case StringExtractorGDBRemote::eServerPacketType_qUserName:
//.........这里部分代码省略.........