[Lldb-commits] [lldb] r337030 - No longer pass a StringRef to the Python API

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 13 11:13:46 PDT 2018


Author: teemperor
Date: Fri Jul 13 11:13:46 2018
New Revision: 337030

URL: http://llvm.org/viewvc/llvm-project?rev=337030&view=rev
Log:
No longer pass a StringRef to the Python API

Summary:
The refactoring patch for DoExecute missed this case of a variadic function that just silently
accepts a StringRef which it then tries to reinterpret as a C-string.

This should fix the Windows builds.

Reviewers: stella.stamenova

Reviewed By: stella.stamenova

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D49309

Modified:
    lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=337030&r1=337029&r2=337030&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Fri Jul 13 11:13:46 2018
@@ -753,6 +753,8 @@ static void ReadThreadBytesReceived(void
 bool ScriptInterpreterPython::ExecuteOneLine(
     llvm::StringRef command, CommandReturnObject *result,
     const ExecuteScriptOptions &options) {
+  std::string command_str = command.str();
+
   if (!m_valid_session)
     return false;
 
@@ -855,7 +857,7 @@ bool ScriptInterpreterPython::ExecuteOne
           if (PyCallable_Check(m_run_one_line_function.get())) {
             PythonObject pargs(
                 PyRefType::Owned,
-                Py_BuildValue("(Os)", session_dict.get(), command));
+                Py_BuildValue("(Os)", session_dict.get(), command_str.c_str()));
             if (pargs.IsValid()) {
               PythonObject return_value(
                   PyRefType::Owned,
@@ -895,7 +897,6 @@ bool ScriptInterpreterPython::ExecuteOne
 
     // The one-liner failed.  Append the error message.
     if (result) {
-      std::string command_str = command.str();
       result->AppendErrorWithFormat(
           "python failed attempting to evaluate '%s'\n", command_str.c_str());
     }




More information about the lldb-commits mailing list