diff options
author | Yabin Cui <yabinc@google.com> | 2015-05-04 20:27:57 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2015-05-05 14:23:10 -0700 |
commit | 7d59bb49fb47fbc82ef5c77d7aebf7174fd996e1 (patch) | |
tree | 8c090275f1d8f88edb80b8f7746751256e1538ba /simpleperf/utils.cpp | |
parent | 1352b82d4aed6b5dd64cffaa2aefec0cfd45aeaa (diff) | |
download | extras-7d59bb49fb47fbc82ef5c77d7aebf7174fd996e1.tar.gz |
Dump kernel/modules/thread mmap information in `simpleperf record`.
Bug: 19483574
Change-Id: Ia65cb12804a6dffa440501736a6229b2f7248958
Diffstat (limited to 'simpleperf/utils.cpp')
-rw-r--r-- | simpleperf/utils.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/simpleperf/utils.cpp b/simpleperf/utils.cpp index eea8988e..349cf5d1 100644 --- a/simpleperf/utils.cpp +++ b/simpleperf/utils.cpp @@ -16,6 +16,7 @@ #include "utils.h" +#include <dirent.h> #include <errno.h> #include <stdarg.h> #include <stdio.h> @@ -44,3 +45,34 @@ bool NextArgumentOrError(const std::vector<std::string>& args, size_t* pi) { ++*pi; return true; } + +void GetEntriesInDir(const std::string& dirpath, std::vector<std::string>* files, + std::vector<std::string>* subdirs) { + if (files != nullptr) { + files->clear(); + } + if (subdirs != nullptr) { + subdirs->clear(); + } + DIR* dir = opendir(dirpath.c_str()); + if (dir == nullptr) { + PLOG(DEBUG) << "can't open dir " << dirpath; + return; + } + dirent* entry; + while ((entry = readdir(dir)) != nullptr) { + if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) { + continue; + } + if (entry->d_type == DT_DIR) { + if (subdirs != nullptr) { + subdirs->push_back(entry->d_name); + } + } else { + if (files != nullptr) { + files->push_back(entry->d_name); + } + } + } + closedir(dir); +} |