summaryrefslogtreecommitdiffstats
path: root/logd/LogStatistics.cpp
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-12-17 09:58:43 -0800
committerMark Salyzyn <salyzyn@google.com>2015-12-18 13:17:37 -0800
commitee3b838e13dc2140ac2051c1012d471effd0fd5f (patch)
tree719546e74db20cf649f4c814bcd8d06f1a3526fc /logd/LogStatistics.cpp
parent5d8742feb66b8dc8aee0c8ce4fc2f5617f3e7f8b (diff)
downloadsystem_core-ee3b838e13dc2140ac2051c1012d471effd0fd5f.tar.gz
system_core-ee3b838e13dc2140ac2051c1012d471effd0fd5f.tar.bz2
system_core-ee3b838e13dc2140ac2051c1012d471effd0fd5f.zip
logd: statistics per-pid filter
Primarily gives access to the Chattiest TIDs and TAGs associated with a pid. Has a secondary effect of allowing us to pull out the command line, comm and in some cases the associated PACKAGE for a specific pid while the logs are still present even if the executable is gone. Bug: 26029733 Bug: 21615139 Change-Id: I1ea63165a680a9318360579b70b1512078ed5682
Diffstat (limited to 'logd/LogStatistics.cpp')
-rw-r--r--logd/LogStatistics.cpp43
1 files changed, 29 insertions, 14 deletions
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index bf0e30b09..afaefc25f 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -205,7 +205,7 @@ std::string UidEntry::formatHeader(const std::string &name, log_id_t id) const {
}
std::string UidEntry::format(const LogStatistics &stat, log_id_t id) const {
- uid_t uid = getKey();
+ uid_t uid = getUid();
std::string name = android::base::StringPrintf("%u", uid);
const char *nameTmp = stat.uidToName(uid);
if (nameTmp) {
@@ -287,8 +287,8 @@ std::string PidEntry::formatHeader(const std::string &name, log_id_t /* id */) c
std::string PidEntry::format(const LogStatistics &stat, log_id_t /* id */) const {
uid_t uid = getUid();
- std::string name = android::base::StringPrintf("%5u/%u",
- getKey(), uid);
+ pid_t pid = getPid();
+ std::string name = android::base::StringPrintf("%5u/%u", pid, uid);
const char *nameTmp = getName();
if (nameTmp) {
name += android::base::StringPrintf(
@@ -325,7 +325,7 @@ std::string TidEntry::formatHeader(const std::string &name, log_id_t /* id */) c
std::string TidEntry::format(const LogStatistics &stat, log_id_t /* id */) const {
uid_t uid = getUid();
std::string name = android::base::StringPrintf("%5u/%u",
- getKey(), uid);
+ getTid(), uid);
const char *nameTmp = getName();
if (nameTmp) {
name += android::base::StringPrintf(
@@ -388,7 +388,8 @@ std::string TagEntry::format(const LogStatistics & /* stat */, log_id_t /* id */
return formatLine(name, size, pruned);
}
-std::string LogStatistics::format(uid_t uid, unsigned int logMask) const {
+std::string LogStatistics::format(uid_t uid, pid_t pid,
+ unsigned int logMask) const {
static const unsigned short spaces_total = 19;
// Report on total logging, current and for all time
@@ -461,24 +462,38 @@ std::string LogStatistics::format(uid_t uid, unsigned int logMask) const {
name = (uid == AID_ROOT)
? "Chattiest UIDs in %s log buffer:"
: "Logging for your UID in %s log buffer:";
- output += uidTable[id].format(*this, uid, name, id);
+ output += uidTable[id].format(*this, uid, pid, name, id);
}
if (enable) {
- name = (uid == AID_ROOT) ? "Chattiest PIDs:" : "Logging for this PID:";
- output += pidTable.format(*this, uid, name);
- name = "Chattiest TIDs:";
- output += tidTable.format(*this, uid, name);
+ name = ((uid == AID_ROOT) && !pid)
+ ? "Chattiest PIDs:"
+ : "Logging for this PID:";
+ output += pidTable.format(*this, uid, pid, name);
+ name = "Chattiest TIDs";
+ if (pid) {
+ name += android::base::StringPrintf(" for PID %d", pid);
+ }
+ name += ":";
+ output += tidTable.format(*this, uid, pid, name);
}
if (enable && (logMask & (1 << LOG_ID_EVENTS))) {
- name = "Chattiest events log buffer TAGs:";
- output += tagTable.format(*this, uid, name, LOG_ID_EVENTS);
+ name = "Chattiest events log buffer TAGs";
+ if (pid) {
+ name += android::base::StringPrintf(" for PID %d", pid);
+ }
+ name += ":";
+ output += tagTable.format(*this, uid, pid, name, LOG_ID_EVENTS);
}
if (enable && (logMask & (1 << LOG_ID_SECURITY))) {
- name = "Chattiest security log buffer TAGs:";
- output += securityTagTable.format(*this, uid, name, LOG_ID_SECURITY);
+ name = "Chattiest security log buffer TAGs";
+ if (pid) {
+ name += android::base::StringPrintf(" for PID %d", pid);
+ }
+ name += ":";
+ output += securityTagTable.format(*this, uid, pid, name, LOG_ID_SECURITY);
}
return output;