Author: tnorthover Date: Mon Nov 9 16:05:05 2015 New Revision: 252521 URL: http://llvm.org/viewvc/llvm-project?rev=252521&view=rev Log: Avoid sending bare '*' and '}' in an lldb-server packet
They get treated as special RLE encoding symbols and packets get corrupted. Most other packet types already know about this apparently, but QEnvironment missed these two. Should fix PR25300. Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py?rev=252521&r1=252520&r2=252521&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/TestProcessLaunch.py Mon Nov 9 16:05:05 2015 @@ -178,3 +178,24 @@ class ProcessLaunchTestCase(TestBase): if not success: self.fail(err_msg) + + def test_environment_with_special_char (self): + """Test that environment variables containing '*' and '}' are communicated correctly to the lldb-server.""" + d = {'CXX_SOURCES' : 'print_env.cpp'} + self.build(dictionary=d) + self.setTearDownCleanup(d) + exe = os.path.join (os.getcwd(), "a.out") + + evil_var = 'INIT*MIDDLE}TAIL' + + target = self.dbg.CreateTarget(exe) + process = target.LaunchSimple(None, ['EVIL=' + evil_var], self.get_process_working_directory()) + self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED) + + out = process.GetSTDOUT(len(evil_var))[:len(evil_var)] + if out != evil_var: + self.fail('The environment variable was mis-coded: %s\n' % repr(out)) + + newline = process.GetSTDOUT(1)[0] + if newline != '\r' and newline != '\n': + self.fail('Garbage at end of environment variable') Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp?rev=252521&view=auto ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp (added) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/process_launch/print_env.cpp Mon Nov 9 16:05:05 2015 @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +int main (int argc, char **argv) +{ + char *evil = getenv("EVIL"); + puts(evil); + + return 0; +} 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=252521&r1=252520&r2=252521&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Nov 9 16:05:05 2015 @@ -1584,6 +1584,7 @@ GDBRemoteCommunicationClient::SendEnviro case '$': case '#': case '*': + case '}': send_hex_encoding = true; break; default: _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits