mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
<rdar://problem/14146606>
Fixed an issue where environment variables that contained special characters '$' and '#' would hose up the GDB server packet. We now use the QEnvironmentHexEncoded packet that has existed for a long time when we need to. Also added code that will stop sending the QEnvironmentHexEncoded and QEnvironment packets if they aren't supported. llvm-svn: 192373
This commit is contained in:
@@ -75,6 +75,8 @@ GDBRemoteCommunicationClient::GDBRemoteCommunicationClient(bool is_platform) :
|
||||
m_supports_z2 (true),
|
||||
m_supports_z3 (true),
|
||||
m_supports_z4 (true),
|
||||
m_supports_QEnvironment (true),
|
||||
m_supports_QEnvironmentHexEncoded (true),
|
||||
m_curr_tid (LLDB_INVALID_THREAD_ID),
|
||||
m_curr_tid_run (LLDB_INVALID_THREAD_ID),
|
||||
m_num_supported_hardware_watchpoints (0),
|
||||
@@ -219,6 +221,8 @@ GDBRemoteCommunicationClient::ResetDiscoverableSettings()
|
||||
m_supports_z2 = true;
|
||||
m_supports_z3 = true;
|
||||
m_supports_z4 = true;
|
||||
m_supports_QEnvironment = true;
|
||||
m_supports_QEnvironmentHexEncoded = true;
|
||||
m_host_arch.Clear();
|
||||
m_process_arch.Clear();
|
||||
}
|
||||
@@ -1014,15 +1018,61 @@ GDBRemoteCommunicationClient::SendEnvironmentPacket (char const *name_equal_valu
|
||||
if (name_equal_value && name_equal_value[0])
|
||||
{
|
||||
StreamString packet;
|
||||
packet.Printf("QEnvironment:%s", name_equal_value);
|
||||
StringExtractorGDBRemote response;
|
||||
if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false))
|
||||
bool send_hex_encoding = false;
|
||||
for (const char *p = name_equal_value; *p != '\0' && send_hex_encoding == false; ++p)
|
||||
{
|
||||
if (response.IsOKResponse())
|
||||
return 0;
|
||||
uint8_t error = response.GetError();
|
||||
if (error)
|
||||
return error;
|
||||
if (isprint(*p))
|
||||
{
|
||||
switch (*p)
|
||||
{
|
||||
case '$':
|
||||
case '#':
|
||||
send_hex_encoding = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have non printable characters, lets hex encode this...
|
||||
send_hex_encoding = true;
|
||||
}
|
||||
}
|
||||
|
||||
StringExtractorGDBRemote response;
|
||||
if (send_hex_encoding)
|
||||
{
|
||||
if (m_supports_QEnvironmentHexEncoded)
|
||||
{
|
||||
packet.PutCString("QEnvironmentHexEncoded:");
|
||||
packet.PutBytesAsRawHex8 (name_equal_value, strlen(name_equal_value));
|
||||
if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false))
|
||||
{
|
||||
if (response.IsOKResponse())
|
||||
return 0;
|
||||
uint8_t error = response.GetError();
|
||||
if (error)
|
||||
return error;
|
||||
if (response.IsUnsupportedResponse())
|
||||
m_supports_QEnvironmentHexEncoded = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (m_supports_QEnvironment)
|
||||
{
|
||||
packet.Printf("QEnvironment:%s", name_equal_value);
|
||||
if (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false))
|
||||
{
|
||||
if (response.IsOKResponse())
|
||||
return 0;
|
||||
uint8_t error = response.GetError();
|
||||
if (error)
|
||||
return error;
|
||||
if (response.IsUnsupportedResponse())
|
||||
m_supports_QEnvironment = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -446,7 +446,9 @@ protected:
|
||||
m_supports_z1:1,
|
||||
m_supports_z2:1,
|
||||
m_supports_z3:1,
|
||||
m_supports_z4:1;
|
||||
m_supports_z4:1,
|
||||
m_supports_QEnvironment:1,
|
||||
m_supports_QEnvironmentHexEncoded:1;
|
||||
|
||||
|
||||
lldb::tid_t m_curr_tid; // Current gdb remote protocol thread index for all other operations
|
||||
|
||||
Reference in New Issue
Block a user