move dump cpu to gs-common
After this patch, cpu and soc dump in total on ROM P45537572(panther) took: ------ Section end: dump_soc ------ Elapsed msec: 12 While previous cpu dump on ROM 9386726(panther) took: ------ Section end: cpu ------ Elapsed msec: 1445 Bug: 240530709 Test: adb bugreport Change-Id: I33bc01c05a944c4c171c3874d963d02d708fec6c
This commit is contained in:
parent
716028d789
commit
7fbb67dd18
@ -13,6 +13,7 @@ cc_binary {
|
|||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libbase",
|
"libbase",
|
||||||
"libdump",
|
"libdump",
|
||||||
|
"liblog",
|
||||||
],
|
],
|
||||||
vendor: true,
|
vendor: true,
|
||||||
relative_install_path: "dump",
|
relative_install_path: "dump",
|
||||||
|
@ -14,6 +14,19 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include <dump/pixel_dump.h>
|
#include <dump/pixel_dump.h>
|
||||||
|
#include <android-base/file.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <log/log.h>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
std::string readFile(const std::string& file_path) {
|
||||||
|
std::string content;
|
||||||
|
if(android::base::ReadFileToString(file_path.c_str(), &content)) {
|
||||||
|
return std::regex_replace(content, std::regex("\\r\\n|\\r|\\n"),"");
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
// Dump chip ID.
|
// Dump chip ID.
|
||||||
int main() {
|
int main() {
|
||||||
@ -23,5 +36,48 @@ int main() {
|
|||||||
dumpFileContent("PRODUCT ID", "/sys/devices/system/chip-id/product_id");
|
dumpFileContent("PRODUCT ID", "/sys/devices/system/chip-id/product_id");
|
||||||
dumpFileContent("REVISION", "/sys/devices/system/chip-id/revision");
|
dumpFileContent("REVISION", "/sys/devices/system/chip-id/revision");
|
||||||
dumpFileContent("RAW STR", "/sys/devices/system/chip-id/raw_str");
|
dumpFileContent("RAW STR", "/sys/devices/system/chip-id/raw_str");
|
||||||
|
dumpFileContent("CPU present", "/sys/devices/system/cpu/present");
|
||||||
|
dumpFileContent("CPU online", "/sys/devices/system/cpu/online");
|
||||||
|
|
||||||
|
printf("------ CPU time-in-state ------\n");
|
||||||
|
std::string states;
|
||||||
|
std::unique_ptr<DIR, decltype(&closedir)> cpudir(opendir("/sys/devices/system/cpu/"), closedir);
|
||||||
|
if (!cpudir) {
|
||||||
|
ALOGE("Fail To Open Dir /sys/devices/system/cpu/");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
dirent *entry;
|
||||||
|
while ((entry = readdir(cpudir.get())) != nullptr) {
|
||||||
|
std::string core(entry->d_name);
|
||||||
|
if (core.find("cpu") != std::string::npos) {
|
||||||
|
std::string path("/sys/devices/system/cpu/" + core + "/cpufreq/stats/time_in_state");
|
||||||
|
if(!access(path.c_str(), R_OK)){
|
||||||
|
dumpFileContent(path.c_str(), path.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string cpu_idle_path("/sys/devices/system/cpu/" + core + "/cpuidle");
|
||||||
|
std::unique_ptr<DIR, decltype(&closedir)> statedir(opendir(cpu_idle_path.c_str()), closedir);
|
||||||
|
if (!statedir) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
dirent *state_entry;
|
||||||
|
while ((state_entry = readdir(statedir.get())) != nullptr) {
|
||||||
|
std::string cpu_idle_state_path(state_entry->d_name);
|
||||||
|
std::string full_state_path;
|
||||||
|
full_state_path += cpu_idle_path;
|
||||||
|
full_state_path += "/";
|
||||||
|
full_state_path += cpu_idle_state_path;
|
||||||
|
if (cpu_idle_state_path.find("state") != std::string::npos) {
|
||||||
|
std::string name(full_state_path + "/name");
|
||||||
|
std::string desc(full_state_path + "/desc");
|
||||||
|
std::string time(full_state_path + "/time");
|
||||||
|
std::string usage(full_state_path + "/usage");
|
||||||
|
states += full_state_path+": "+readFile(name)+" "+readFile(desc)+" "+readFile(time)+" "+readFile(usage)+"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("------ CPU cpuidle ------\n%s\n", states.c_str());
|
||||||
|
|
||||||
|
dumpFileContent("INTERRUPTS", "/proc/interrupts");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user