forked from OSchip/llvm-project
Add ProcessGDBRemote::GetAuxvData() and fix multiple-packet concatenation for binary data.
ProcessGDBRemote::GetAuxvData obtains the auxv from a remote gdbserver (via a binary-data packet), and returns the data as a DataBufferSP. The patch includes a small fix to GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses() to support binary file format packet returns (by not assuming each binary packet is a null-terminated string when concatenating them). llvm-svn: 202907
This commit is contained in:
parent
7a5830294f
commit
03904accc0
|
@ -66,6 +66,7 @@ GDBRemoteCommunicationClient::GDBRemoteCommunicationClient(bool is_platform) :
|
||||||
m_prepare_for_reg_writing_reply (eLazyBoolCalculate),
|
m_prepare_for_reg_writing_reply (eLazyBoolCalculate),
|
||||||
m_supports_p (eLazyBoolCalculate),
|
m_supports_p (eLazyBoolCalculate),
|
||||||
m_supports_QSaveRegisterState (eLazyBoolCalculate),
|
m_supports_QSaveRegisterState (eLazyBoolCalculate),
|
||||||
|
m_supports_qXfer_auxv_read (eLazyBoolCalculate),
|
||||||
m_supports_qXfer_libraries_read (eLazyBoolCalculate),
|
m_supports_qXfer_libraries_read (eLazyBoolCalculate),
|
||||||
m_supports_qXfer_libraries_svr4_read (eLazyBoolCalculate),
|
m_supports_qXfer_libraries_svr4_read (eLazyBoolCalculate),
|
||||||
m_supports_augmented_libraries_svr4_read (eLazyBoolCalculate),
|
m_supports_augmented_libraries_svr4_read (eLazyBoolCalculate),
|
||||||
|
@ -187,6 +188,16 @@ GDBRemoteCommunicationClient::GetQXferLibrariesReadSupported ()
|
||||||
return (m_supports_qXfer_libraries_read == eLazyBoolYes);
|
return (m_supports_qXfer_libraries_read == eLazyBoolYes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
GDBRemoteCommunicationClient::GetQXferAuxvReadSupported ()
|
||||||
|
{
|
||||||
|
if (m_supports_qXfer_auxv_read == eLazyBoolCalculate)
|
||||||
|
{
|
||||||
|
GetRemoteQSupported();
|
||||||
|
}
|
||||||
|
return (m_supports_qXfer_auxv_read == eLazyBoolYes);
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
GDBRemoteCommunicationClient::GetRemoteMaxPacketSize()
|
GDBRemoteCommunicationClient::GetRemoteMaxPacketSize()
|
||||||
{
|
{
|
||||||
|
@ -294,6 +305,7 @@ GDBRemoteCommunicationClient::ResetDiscoverableSettings()
|
||||||
m_supports_memory_region_info = eLazyBoolCalculate;
|
m_supports_memory_region_info = eLazyBoolCalculate;
|
||||||
m_prepare_for_reg_writing_reply = eLazyBoolCalculate;
|
m_prepare_for_reg_writing_reply = eLazyBoolCalculate;
|
||||||
m_attach_or_wait_reply = eLazyBoolCalculate;
|
m_attach_or_wait_reply = eLazyBoolCalculate;
|
||||||
|
m_supports_qXfer_auxv_read = eLazyBoolCalculate;
|
||||||
m_supports_qXfer_libraries_read = eLazyBoolCalculate;
|
m_supports_qXfer_libraries_read = eLazyBoolCalculate;
|
||||||
m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate;
|
m_supports_qXfer_libraries_svr4_read = eLazyBoolCalculate;
|
||||||
m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate;
|
m_supports_augmented_libraries_svr4_read = eLazyBoolCalculate;
|
||||||
|
@ -320,8 +332,9 @@ void
|
||||||
GDBRemoteCommunicationClient::GetRemoteQSupported ()
|
GDBRemoteCommunicationClient::GetRemoteQSupported ()
|
||||||
{
|
{
|
||||||
// Clear out any capabilities we expect to see in the qSupported response
|
// Clear out any capabilities we expect to see in the qSupported response
|
||||||
m_supports_qXfer_libraries_svr4_read = eLazyBoolNo;
|
m_supports_qXfer_auxv_read = eLazyBoolNo;
|
||||||
m_supports_qXfer_libraries_read = eLazyBoolNo;
|
m_supports_qXfer_libraries_read = eLazyBoolNo;
|
||||||
|
m_supports_qXfer_libraries_svr4_read = eLazyBoolNo;
|
||||||
m_supports_augmented_libraries_svr4_read = eLazyBoolNo;
|
m_supports_augmented_libraries_svr4_read = eLazyBoolNo;
|
||||||
m_max_packet_size = UINT64_MAX; // It's supposed to always be there, but if not, we assume no limit
|
m_max_packet_size = UINT64_MAX; // It's supposed to always be there, but if not, we assume no limit
|
||||||
|
|
||||||
|
@ -331,6 +344,8 @@ GDBRemoteCommunicationClient::GetRemoteQSupported ()
|
||||||
/*send_async=*/false) == PacketResult::Success)
|
/*send_async=*/false) == PacketResult::Success)
|
||||||
{
|
{
|
||||||
const char *response_cstr = response.GetStringRef().c_str();
|
const char *response_cstr = response.GetStringRef().c_str();
|
||||||
|
if (::strstr (response_cstr, "qXfer:auxv:read+"))
|
||||||
|
m_supports_qXfer_auxv_read = eLazyBoolYes;
|
||||||
if (::strstr (response_cstr, "qXfer:libraries-svr4:read+"))
|
if (::strstr (response_cstr, "qXfer:libraries-svr4:read+"))
|
||||||
m_supports_qXfer_libraries_svr4_read = eLazyBoolYes;
|
m_supports_qXfer_libraries_svr4_read = eLazyBoolYes;
|
||||||
if (::strstr (response_cstr, "augmented-libraries-svr4-read"))
|
if (::strstr (response_cstr, "augmented-libraries-svr4-read"))
|
||||||
|
@ -502,11 +517,8 @@ GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses
|
||||||
{
|
{
|
||||||
return PacketResult::ErrorReplyInvalid;
|
return PacketResult::ErrorReplyInvalid;
|
||||||
}
|
}
|
||||||
// Skip past m or l
|
// Concatenate the result so far (skipping 'm' or 'l')
|
||||||
const char *s = this_string.c_str() + 1;
|
response_string.append(this_string, 1, std::string::npos);
|
||||||
|
|
||||||
// Concatenate the result so far
|
|
||||||
response_string += s;
|
|
||||||
if (first_char == 'l')
|
if (first_char == 'l')
|
||||||
// We're done
|
// We're done
|
||||||
return PacketResult::Success;
|
return PacketResult::Success;
|
||||||
|
|
|
@ -383,6 +383,9 @@ public:
|
||||||
bool
|
bool
|
||||||
SetCurrentThreadForRun (uint64_t tid);
|
SetCurrentThreadForRun (uint64_t tid);
|
||||||
|
|
||||||
|
bool
|
||||||
|
GetQXferAuxvReadSupported ();
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GetQXferLibrariesReadSupported ();
|
GetQXferLibrariesReadSupported ();
|
||||||
|
|
||||||
|
@ -525,6 +528,7 @@ protected:
|
||||||
lldb_private::LazyBool m_prepare_for_reg_writing_reply;
|
lldb_private::LazyBool m_prepare_for_reg_writing_reply;
|
||||||
lldb_private::LazyBool m_supports_p;
|
lldb_private::LazyBool m_supports_p;
|
||||||
lldb_private::LazyBool m_supports_QSaveRegisterState;
|
lldb_private::LazyBool m_supports_QSaveRegisterState;
|
||||||
|
lldb_private::LazyBool m_supports_qXfer_auxv_read;
|
||||||
lldb_private::LazyBool m_supports_qXfer_libraries_read;
|
lldb_private::LazyBool m_supports_qXfer_libraries_read;
|
||||||
lldb_private::LazyBool m_supports_qXfer_libraries_svr4_read;
|
lldb_private::LazyBool m_supports_qXfer_libraries_svr4_read;
|
||||||
lldb_private::LazyBool m_supports_augmented_libraries_svr4_read;
|
lldb_private::LazyBool m_supports_augmented_libraries_svr4_read;
|
||||||
|
|
|
@ -3060,6 +3060,19 @@ ProcessGDBRemote::GetDynamicLoader ()
|
||||||
return m_dyld_ap.get();
|
return m_dyld_ap.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DataBufferSP
|
||||||
|
ProcessGDBRemote::GetAuxvData()
|
||||||
|
{
|
||||||
|
DataBufferSP buf;
|
||||||
|
if (m_gdb_comm.GetQXferAuxvReadSupported())
|
||||||
|
{
|
||||||
|
std::string response_string;
|
||||||
|
if (m_gdb_comm.SendPacketsAndConcatenateResponses("qXfer:auxv:read::", response_string) == GDBRemoteCommunication::PacketResult::Success)
|
||||||
|
buf.reset(new DataBufferHeap(response_string.c_str(), response_string.length()));
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class CommandObjectProcessGDBRemotePacketHistory : public CommandObjectParsed
|
class CommandObjectProcessGDBRemotePacketHistory : public CommandObjectParsed
|
||||||
{
|
{
|
||||||
|
|
|
@ -299,6 +299,9 @@ protected:
|
||||||
bool
|
bool
|
||||||
ParseRegisters(lldb_private::ScriptInterpreterObject *registers_array);
|
ParseRegisters(lldb_private::ScriptInterpreterObject *registers_array);
|
||||||
|
|
||||||
|
virtual const lldb::DataBufferSP
|
||||||
|
GetAuxvData();
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
/// Broadcaster event bits definitions.
|
/// Broadcaster event bits definitions.
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue