summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Target')
-rw-r--r--lldb/source/Target/Platform.cpp8
-rw-r--r--lldb/source/Target/ProcessLaunchInfo.cpp7
-rw-r--r--lldb/source/Target/TargetList.cpp20
3 files changed, 16 insertions, 19 deletions
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index d8db53663f1..4f285e09807 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -523,11 +523,11 @@ void Platform::AddClangModuleCompilationOptions(
FileSpec Platform::GetWorkingDirectory() {
if (IsHost()) {
- char cwd[PATH_MAX];
- if (getcwd(cwd, sizeof(cwd)))
- return FileSpec{cwd, true};
- else
+ llvm::SmallString<64> cwd;
+ if (llvm::sys::fs::current_path(cwd))
return FileSpec{};
+ else
+ return FileSpec(cwd, true);
} else {
if (!m_working_dir)
m_working_dir = GetRemoteWorkingDirectory();
diff --git a/lldb/source/Target/ProcessLaunchInfo.cpp b/lldb/source/Target/ProcessLaunchInfo.cpp
index 92d9371b541..334a43eb9c1 100644
--- a/lldb/source/Target/ProcessLaunchInfo.cpp
+++ b/lldb/source/Target/ProcessLaunchInfo.cpp
@@ -23,6 +23,7 @@
#include "lldb/Target/Target.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/FileSystem.h"
#if !defined(_WIN32)
#include <limits.h>
@@ -368,10 +369,8 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell(
if (working_dir) {
new_path += working_dir.GetPath();
} else {
- char current_working_dir[PATH_MAX];
- const char *cwd =
- getcwd(current_working_dir, sizeof(current_working_dir));
- if (cwd && cwd[0])
+ llvm::SmallString<64> cwd;
+ if (! llvm::sys::fs::current_path(cwd))
new_path += cwd;
}
std::string curr_path;
diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp
index 0637cffddcc..4b2730fa8e2 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -7,11 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "llvm/ADT/SmallString.h"
-
// Project includes
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Debugger.h"
@@ -29,6 +24,10 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/TargetList.h"
+// Other libraries and framework includes
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -369,12 +368,11 @@ Error TargetList::CreateTargetInternal(Debugger &debugger,
if (file.IsRelative() && !user_exe_path.empty()) {
// Ignore paths that start with "./" and "../"
if (!user_exe_path.startswith("./") && !user_exe_path.startswith("../")) {
- char cwd[PATH_MAX];
- if (getcwd(cwd, sizeof(cwd))) {
- std::string cwd_user_exe_path(cwd);
- cwd_user_exe_path += '/';
- cwd_user_exe_path += user_exe_path;
- FileSpec cwd_file(cwd_user_exe_path, false);
+ llvm::SmallString<64> cwd;
+ if (! llvm::sys::fs::current_path(cwd)) {
+ cwd += '/';
+ cwd += user_exe_path;
+ FileSpec cwd_file(cwd, false);
if (cwd_file.Exists())
file = cwd_file;
}
OpenPOWER on IntegriCloud