[Lldb-commits] [lldb] r192373 - <rdar://problem/14146606>
Greg Clayton
gclayton at apple.com
Thu Oct 10 10:53:50 PDT 2013
Author: gclayton
Date: Thu Oct 10 12:53:50 2013
New Revision: 192373
URL: http://llvm.org/viewvc/llvm-project?rev=192373&view=rev
Log:
<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.
Modified:
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=192373&r1=192372&r2=192373&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu Oct 10 12:53:50 2013
@@ -75,6 +75,8 @@ GDBRemoteCommunicationClient::GDBRemoteC
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::ResetDisco
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::SendEnviro
if (name_equal_value && name_equal_value[0])
{
StreamString packet;
- packet.Printf("QEnvironment:%s", name_equal_value);
+ bool send_hex_encoding = false;
+ for (const char *p = name_equal_value; *p != '\0' && send_hex_encoding == false; ++p)
+ {
+ 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 (SendPacketAndWaitForResponse (packet.GetData(), packet.GetSize(), response, false))
+ if (send_hex_encoding)
{
- if (response.IsOKResponse())
- return 0;
- uint8_t error = response.GetError();
- if (error)
- return error;
+ 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;
Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=192373&r1=192372&r2=192373&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Thu Oct 10 12:53:50 2013
@@ -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
More information about the lldb-commits
mailing list