[Lldb-commits] [lldb] r133857 - in /lldb/trunk/tools/debugserver/source: RNBRemote.cpp RNBRemote.h
Jason Molenda
jmolenda at apple.com
Fri Jun 24 18:55:21 PDT 2011
Author: jmolenda
Date: Fri Jun 24 20:55:21 2011
New Revision: 133857
URL: http://llvm.org/viewvc/llvm-project?rev=133857&view=rev
Log:
Add support for a QEnvironmentHexEncoded packet which takes its
arguments in hex-encoded form instead of the old QEnvironment packet
which takes them as plain-text strings. Environment variables
containing remote protocol special chars like '#' would fail to set
with QEnvironment.
Modified:
lldb/trunk/tools/debugserver/source/RNBRemote.cpp
lldb/trunk/tools/debugserver/source/RNBRemote.h
Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=133857&r1=133856&r2=133857&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Fri Jun 24 20:55:21 2011
@@ -175,6 +175,7 @@
t.push_back (Packet (set_max_packet_size, &RNBRemote::HandlePacket_QSetMaxPacketSize , NULL, "QSetMaxPacketSize:", "Tell " DEBUGSERVER_PROGRAM_NAME " the max sized packet gdb can handle"));
t.push_back (Packet (set_max_payload_size, &RNBRemote::HandlePacket_QSetMaxPayloadSize , NULL, "QSetMaxPayloadSize:", "Tell " DEBUGSERVER_PROGRAM_NAME " the max sized payload gdb can handle"));
t.push_back (Packet (set_environment_variable, &RNBRemote::HandlePacket_QEnvironment , NULL, "QEnvironment:", "Add an environment variable to the inferior's environment"));
+ t.push_back (Packet (set_environment_variable_hex, &RNBRemote::HandlePacket_QEnvironmentHexEncoded , NULL, "QEnvironmentHexEncoded:", "Add an environment variable to the inferior's environment"));
t.push_back (Packet (set_launch_arch, &RNBRemote::HandlePacket_QLaunchArch , NULL, "QLaunchArch:", "Set the architecture to use when launching a process for hosts that can run multiple architecture slices from universal files."));
t.push_back (Packet (set_disable_aslr, &RNBRemote::HandlePacket_QSetDisableASLR , NULL, "QSetDisableASLR:", "Set wether to disable ASLR when launching the process with the set argv ('A') packet"));
t.push_back (Packet (set_stdin, &RNBRemote::HandlePacket_QSetSTDIO , NULL, "QSetSTDIN:", "Set the standard input for a process to be launched with the 'A' packet"));
@@ -1909,6 +1910,53 @@
}
rnb_err_t
+RNBRemote::HandlePacket_QEnvironmentHexEncoded (const char *p)
+{
+ /* This sets the environment for the target program. The packet is of the form:
+
+ QEnvironmentHexEncoded:VARIABLE=VALUE
+
+ The VARIABLE=VALUE part is sent hex-encoded so chracters like '#' with special
+ meaning in the remote protocol won't break it.
+ */
+
+ DNBLogThreadedIf (LOG_RNB_REMOTE, "%8u RNBRemote::%s Handling QEnvironmentHexEncoded: \"%s\"",
+ (uint32_t)m_comm.Timer().ElapsedMicroSeconds(true), __FUNCTION__, p);
+
+ p += sizeof ("QEnvironmentHexEncoded:") - 1;
+
+ std::string arg;
+ const char *c;
+ c = p;
+ while (*c != '\0')
+ {
+ if (*(c + 1) == '\0')
+ {
+ return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'QEnvironmentHexEncoded' pkt");
+ }
+ char smallbuf[3];
+ smallbuf[0] = *c;
+ smallbuf[1] = *(c + 1);
+ smallbuf[2] = '\0';
+ errno = 0;
+ int ch = strtoul (smallbuf, NULL, 16);
+ if (errno != 0 && ch == 0)
+ {
+ return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "non-hex char in arg on 'QEnvironmentHexEncoded' pkt");
+ }
+ arg.push_back(ch);
+ c += 2;
+ }
+
+ RNBContext& ctx = Context();
+ if (arg.length() > 0)
+ ctx.PushEnvironment (arg.c_str());
+
+ return SendPacket ("OK");
+}
+
+
+rnb_err_t
RNBRemote::HandlePacket_QLaunchArch (const char *p)
{
p += sizeof ("QLaunchArch:") - 1;
Modified: lldb/trunk/tools/debugserver/source/RNBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.h?rev=133857&r1=133856&r2=133857&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/RNBRemote.h (original)
+++ lldb/trunk/tools/debugserver/source/RNBRemote.h Fri Jun 24 20:55:21 2011
@@ -98,6 +98,7 @@
set_max_packet_size, // 'QSetMaxPacketSize:'
set_max_payload_size, // 'QSetMaxPayloadSize:'
set_environment_variable, // 'QEnvironment:'
+ set_environment_variable_hex, // 'QEnvironmentHexEncoded:'
set_launch_arch, // 'QLaunchArch:'
set_disable_aslr, // 'QSetDisableASLR:'
set_stdin, // 'QSetSTDIN:'
@@ -171,6 +172,7 @@
rnb_err_t HandlePacket_QSetMaxPayloadSize (const char *p);
rnb_err_t HandlePacket_QSetMaxPacketSize (const char *p);
rnb_err_t HandlePacket_QEnvironment (const char *p);
+ rnb_err_t HandlePacket_QEnvironmentHexEncoded (const char *p);
rnb_err_t HandlePacket_QLaunchArch (const char *p);
rnb_err_t HandlePacket_QPrefixRegisterPacketsWithThreadID (const char *p);
rnb_err_t HandlePacket_last_signal (const char *p);
More information about the lldb-commits
mailing list