[Lldb-commits] [lldb] r187818 - Fix bug in Host::getLLDBPath() due to misusing Twine

Daniel Malea daniel.malea at intel.com
Tue Aug 6 14:40:08 PDT 2013


Author: dmalea
Date: Tue Aug  6 16:40:08 2013
New Revision: 187818

URL: http://llvm.org/viewvc/llvm-project?rev=187818&view=rev
Log:
Fix bug in Host::getLLDBPath() due to misusing Twine
- use SmallString instead
- original implementation resulted in incorrect behaviour of lldb -P

Fix by Kal Conley!


Modified:
    lldb/trunk/source/Host/common/Host.cpp

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=187818&r1=187817&r2=187818&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Tue Aug  6 16:40:08 2013
@@ -53,9 +53,10 @@
 #include "lldb/Target/Process.h"
 #include "lldb/Target/TargetList.h"
 
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MachO.h"
-#include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
 
 
 
@@ -1031,17 +1032,15 @@ Host::GetLLDBPath (PathType path_type, F
                         ::strncpy (framework_pos, "/Resources/Python", PATH_MAX - (framework_pos - raw_path));
                     }
 #else
-                    llvm::Twine python_version_dir;
-                    python_version_dir = "/python"
-                                       + llvm::Twine(PY_MAJOR_VERSION)
-                                       + "."
-                                       + llvm::Twine(PY_MINOR_VERSION)
-                                       + "/site-packages";
+                    llvm::SmallString<256> python_version_dir;
+                    llvm::raw_svector_ostream os(python_version_dir);
+                    os << "/python" << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << "/site-packages";
+                    os.flush();
 
                     // We may get our string truncated. Should we protect
                     // this with an assert?
 
-                    ::strncat(raw_path, python_version_dir.str().c_str(),
+                    ::strncat(raw_path, python_version_dir.c_str(),
                               sizeof(raw_path) - strlen(raw_path) - 1);
 
 #endif





More information about the lldb-commits mailing list