diff options
| author | Chaoren Lin <chaorenl@google.com> | 2015-05-29 19:52:29 +0000 |
|---|---|---|
| committer | Chaoren Lin <chaorenl@google.com> | 2015-05-29 19:52:29 +0000 |
| commit | d3173f34e8546a96b8d0df0d9de133f88f10c127 (patch) | |
| tree | 5e778446085cbd4a4d43fc3b488b3ac6ff17f2b5 /lldb/source/Host/posix/HostProcessPosix.cpp | |
| parent | 375432e4d8f50212bca3d9228e349b5a00f770d7 (diff) | |
| download | llvm-d3173f34e8546a96b8d0df0d9de133f88f10c127.zip llvm-d3173f34e8546a96b8d0df0d9de133f88f10c127.tar.gz llvm-d3173f34e8546a96b8d0df0d9de133f88f10c127.tar.bz2 | |
Refactor many file functions to use FileSpec over strings.
Summary:
This should solve the issue of sending denormalized paths over gdb-remote
if we stick to GetPath(false) in GDBRemoteCommunicationClient, and let the
server handle any denormalization.
Reviewers: ovyalov, zturner, vharron, clayborg
Reviewed By: clayborg
Subscribers: tberghammer, emaste, lldb-commits
Differential Revision: http://reviews.llvm.org/D9728
llvm-svn: 238604
Diffstat (limited to 'lldb/source/Host/posix/HostProcessPosix.cpp')
| -rw-r--r-- | lldb/source/Host/posix/HostProcessPosix.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lldb/source/Host/posix/HostProcessPosix.cpp b/lldb/source/Host/posix/HostProcessPosix.cpp index 8e19add..5761a79 100644 --- a/lldb/source/Host/posix/HostProcessPosix.cpp +++ b/lldb/source/Host/posix/HostProcessPosix.cpp @@ -69,28 +69,25 @@ Error HostProcessPosix::GetMainModule(FileSpec &file_spec) const // Use special code here because proc/[pid]/exe is a symbolic link. char link_path[PATH_MAX]; - char exe_path[PATH_MAX] = ""; - if (snprintf (link_path, PATH_MAX, "/proc/%" PRIu64 "/exe", m_process) <= 0) + if (snprintf(link_path, PATH_MAX, "/proc/%" PRIu64 "/exe", m_process) != 1) { error.SetErrorString("Unable to build /proc/<pid>/exe string"); return error; } - error = FileSystem::Readlink(link_path, exe_path, llvm::array_lengthof(exe_path)); + error = FileSystem::Readlink(FileSpec{link_path, false}, file_spec); if (!error.Success()) return error; - const ssize_t len = strlen(exe_path); // If the binary has been deleted, the link name has " (deleted)" appended. // Remove if there. - static const ssize_t deleted_len = strlen(" (deleted)"); - if (len > deleted_len && - !strcmp(exe_path + len - deleted_len, " (deleted)")) + if (file_spec.GetFilename().GetStringRef().endswith(" (deleted)")) { - exe_path[len - deleted_len] = 0; + const char *filename = file_spec.GetFilename().GetCString(); + static const size_t deleted_len = strlen(" (deleted)"); + const size_t len = file_spec.GetFilename().GetLength(); + file_spec.GetFilename().SetCStringWithLength(filename, len - deleted_len); } - - file_spec.SetFile(exe_path, false); return error; } |
