Index: lldb/source/Host/common/Editline.cpp =================================================================== --- lldb/source/Host/common/Editline.cpp +++ lldb/source/Host/common/Editline.cpp @@ -171,23 +171,27 @@ } const char *GetHistoryFilePath() { + // Compute the history path lazily. if (m_path.empty() && m_history && !m_prefix.empty()) { - FileSpec parent_path("~/.lldb"); - FileSystem::Instance().Resolve(parent_path); - char history_path[PATH_MAX]; - if (!llvm::sys::fs::create_directory(parent_path.GetPath())) { - snprintf(history_path, sizeof(history_path), "~/.lldb/%s-history", - m_prefix.c_str()); + llvm::SmallString<128> home_directory; + llvm::sys::path::home_directory(home_directory); + + llvm::SmallString<128> lldb_history_file = home_directory; + llvm::sys::path::append(lldb_history_file, ".lldb"); + if (!llvm::sys::fs::create_directory(lldb_history_file)) { + std::string filename = m_prefix + "-history"; + llvm::sys::path::append(lldb_history_file, filename); } else { - snprintf(history_path, sizeof(history_path), "~/%s-widehistory", - m_prefix.c_str()); + std::string filename = m_prefix + "-widehistory"; + lldb_history_file = home_directory; + llvm::sys::path::append(lldb_history_file, filename); } - auto file_spec = FileSpec(history_path); - FileSystem::Instance().Resolve(file_spec); - m_path = file_spec.GetPath(); + m_path = lldb_history_file.str(); } + if (m_path.empty()) - return NULL; + return nullptr; + return m_path.c_str(); }