summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/RNBRemote.cpp
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2011-06-25 01:55:21 +0000
committerJason Molenda <jmolenda@apple.com>2011-06-25 01:55:21 +0000
commitd8a2aaa47222df9185a9d9c8d1131dba197c751e (patch)
tree7a31f111d1d24273c73c44344ed644d51b82b406 /lldb/tools/debugserver/source/RNBRemote.cpp
parent8fbb89ffa4dc56215fcde3768ec3bafe0acc3213 (diff)
downloadbcm5719-llvm-d8a2aaa47222df9185a9d9c8d1131dba197c751e.tar.gz
bcm5719-llvm-d8a2aaa47222df9185a9d9c8d1131dba197c751e.zip
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. llvm-svn: 133857
Diffstat (limited to 'lldb/tools/debugserver/source/RNBRemote.cpp')
-rw-r--r--lldb/tools/debugserver/source/RNBRemote.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp
index cc3091da631..654f6c57def 100644
--- a/lldb/tools/debugserver/source/RNBRemote.cpp
+++ b/lldb/tools/debugserver/source/RNBRemote.cpp
@@ -175,6 +175,7 @@ RNBRemote::CreatePacketTable ()
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 @@ RNBRemote::HandlePacket_QEnvironment (const char *p)
}
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;
OpenPOWER on IntegriCloud