diff options
author | Oleksiy Vyalov <ovyalov@google.com> | 2016-07-12 18:14:27 +0000 |
---|---|---|
committer | Oleksiy Vyalov <ovyalov@google.com> | 2016-07-12 18:14:27 +0000 |
commit | 9d90186d8c63e919dbd46fc6876ff0bf12d5981e (patch) | |
tree | 48f84425aaa7fd6c8e58612ff44bcb6a4f85663f /lldb/source/Host/linux/Host.cpp | |
parent | 5b2636a15277b2499f2bc1f4c1f009f9ed1bd3f1 (diff) | |
download | bcm5719-llvm-9d90186d8c63e919dbd46fc6876ff0bf12d5981e.tar.gz bcm5719-llvm-9d90186d8c63e919dbd46fc6876ff0bf12d5981e.zip |
Add logging to Linux Host::GetProcessAndStatInfo.
llvm-svn: 275198
Diffstat (limited to 'lldb/source/Host/linux/Host.cpp')
-rw-r--r-- | lldb/source/Host/linux/Host.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lldb/source/Host/linux/Host.cpp b/lldb/source/Host/linux/Host.cpp index cb7369fe7ae..62bf5362de0 100644 --- a/lldb/source/Host/linux/Host.cpp +++ b/lldb/source/Host/linux/Host.cpp @@ -8,12 +8,14 @@ //===----------------------------------------------------------------------===// // C Includes -#include <stdio.h> -#include <sys/utsname.h> -#include <sys/types.h> -#include <sys/stat.h> #include <dirent.h> +#include <errno.h> #include <fcntl.h> +#include <stdio.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <sys/utsname.h> // C++ Includes // Other libraries and framework includes @@ -291,15 +293,25 @@ GetProcessAndStatInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info, Proce ::memset (&stat_info, 0, sizeof(stat_info)); stat_info.ppid = LLDB_INVALID_PROCESS_ID; + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); + // 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", pid) <= 0) + { + if (log) + log->Printf("%s: failed to sprintf pid %" PRIu64, __FUNCTION__, pid); return false; + } ssize_t len = readlink (link_path, exe_path, sizeof(exe_path) - 1); if (len <= 0) + { + if (log) + log->Printf("%s: failed to read link %s: %s", __FUNCTION__, link_path, strerror(errno)); return false; + } // readlink does not append a null byte. exe_path[len] = 0; |