Merge "align user experience on Android bug tool"

This commit is contained in:
TreeHugger Robot 2022-11-02 06:56:17 +00:00 committed by Android (Google) Code Review
commit c293c73188

View file

@ -246,6 +246,7 @@ Dumpstate::Dumpstate()
// if the specified section is not supported. // if the specified section is not supported.
void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) { void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
bool dumpAll = (sectionName == kAllSections); bool dumpAll = (sectionName == kAllSections);
std::string dumpFiles;
for (const auto &section : mTextSections) { for (const auto &section : mTextSections) {
if (dumpAll || sectionName == section.first) { if (dumpAll || sectionName == section.first) {
@ -259,11 +260,13 @@ void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
} }
} }
// Execute all programs under vendor/bin/dump/ // Execute all or designated programs under vendor/bin/dump/
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir("/vendor/bin/dump"), closedir); std::unique_ptr<DIR, decltype(&closedir)> dir(opendir("/vendor/bin/dump"), closedir);
if (!dir) { if (!dir) {
ALOGE("Fail To Open Dir vendor/bin/dump/"); ALOGE("Fail To Open Dir vendor/bin/dump/");
} else { ::android::base::WriteStringToFd("Fail To Open Dir vendor/bin/dump/\n", fd);
return;
}
dirent *entry; dirent *entry;
while ((entry = readdir(dir.get())) != nullptr) { while ((entry = readdir(dir.get())) != nullptr) {
// Skip '.', '..' // Skip '.', '..'
@ -271,9 +274,14 @@ void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
continue; continue;
} }
std::string bin(entry->d_name); std::string bin(entry->d_name);
auto startTime = startSection(fd, "/vendor/bin/dump/"+bin); dumpFiles = dumpFiles + " " + bin;
if (dumpAll || sectionName == bin) {
auto startTime = startSection(fd, bin);
RunCommandToFd(fd, "/vendor/bin/dump/"+bin, {"/vendor/bin/dump/"+bin}); RunCommandToFd(fd, "/vendor/bin/dump/"+bin, {"/vendor/bin/dump/"+bin});
endSection(fd, "/vendor/bin/dump/"+bin, startTime); endSection(fd, bin, startTime);
if (!dumpAll) {
return;
}
} }
} }
@ -287,6 +295,7 @@ void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
for (const auto &section : mTextSections) { for (const auto &section : mTextSections) {
::android::base::WriteStringToFd(" " + section.first, fd); ::android::base::WriteStringToFd(" " + section.first, fd);
} }
::android::base::WriteStringToFd(dumpFiles, fd);
::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. modem) are" ::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. modem) are"
"not avalable from the command line.\n", fd); "not avalable from the command line.\n", fd);
} }