Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _LOGD_LOG_STATISTICS_H__ |
| 18 | #define _LOGD_LOG_STATISTICS_H__ |
| 19 | |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 20 | #include <memory> |
| 21 | #include <stdlib.h> |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 22 | #include <sys/types.h> |
| 23 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 24 | #include <algorithm> // std::max |
| 25 | #include <string> // std::string |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 26 | #include <unordered_map> |
| 27 | |
Mark Salyzyn | 0dd4431 | 2016-09-28 15:54:45 -0700 | [diff] [blame] | 28 | #include <android/log.h> |
Elliott Hughes | 4f71319 | 2015-12-04 22:00:26 -0800 | [diff] [blame] | 29 | #include <android-base/stringprintf.h> |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 30 | #include <private/android_filesystem_config.h> |
Mark Salyzyn | 97c1c2b | 2015-03-10 13:51:35 -0700 | [diff] [blame] | 31 | |
| 32 | #include "LogBufferElement.h" |
Mark Salyzyn | 5ac5c6b | 2015-08-28 08:02:59 -0700 | [diff] [blame] | 33 | #include "LogUtils.h" |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 34 | |
| 35 | #define log_id_for_each(i) \ |
Chih-Hung Hsieh | f0f94fe | 2016-05-18 15:47:19 -0700 | [diff] [blame] | 36 | for (log_id_t i = LOG_ID_MIN; (i) < LOG_ID_MAX; (i) = (log_id_t) ((i) + 1)) |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 37 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 38 | class LogStatistics; |
| 39 | |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 40 | template <typename TKey, typename TEntry> |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 41 | class LogHashtable { |
| 42 | |
| 43 | std::unordered_map<TKey, TEntry> map; |
| 44 | |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 45 | size_t bucket_size() const { |
| 46 | size_t count = 0; |
| 47 | for (size_t idx = 0; idx < map.bucket_count(); ++idx) { |
| 48 | size_t bucket_size = map.bucket_size(idx); |
| 49 | if (bucket_size == 0) bucket_size = 1; |
| 50 | count += bucket_size; |
| 51 | } |
| 52 | float load_factor = map.max_load_factor(); |
| 53 | if (load_factor < 1.0) return count; |
| 54 | return count * load_factor; |
| 55 | } |
| 56 | |
| 57 | static const size_t unordered_map_per_entry_overhead = sizeof(void*); |
| 58 | static const size_t unordered_map_bucket_overhead = sizeof(void*); |
| 59 | |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 60 | public: |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 61 | |
Mark Salyzyn | b067229 | 2016-10-06 10:09:24 -0700 | [diff] [blame] | 62 | size_t size() const { return map.size(); } |
| 63 | |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 64 | // Estimate unordered_map memory usage. |
| 65 | size_t sizeOf() const { |
| 66 | return sizeof(*this) + |
Mark Salyzyn | b067229 | 2016-10-06 10:09:24 -0700 | [diff] [blame] | 67 | (size() * (sizeof(TEntry) + unordered_map_per_entry_overhead)) + |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 68 | (bucket_size() * sizeof(size_t) + unordered_map_bucket_overhead); |
| 69 | } |
| 70 | |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 71 | typedef typename std::unordered_map<TKey, TEntry>::iterator iterator; |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 72 | typedef typename std::unordered_map<TKey, TEntry>::const_iterator const_iterator; |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 73 | |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 74 | std::unique_ptr<const TEntry *[]> sort(uid_t uid, pid_t pid, |
| 75 | size_t len) const { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 76 | if (!len) { |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 77 | std::unique_ptr<const TEntry *[]> sorted(NULL); |
| 78 | return sorted; |
| 79 | } |
| 80 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 81 | const TEntry **retval = new const TEntry* [len]; |
| 82 | memset(retval, 0, sizeof(*retval) * len); |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 83 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 84 | for(const_iterator it = map.begin(); it != map.end(); ++it) { |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 85 | const TEntry &entry = it->second; |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 86 | |
| 87 | if ((uid != AID_ROOT) && (uid != entry.getUid())) { |
| 88 | continue; |
| 89 | } |
| 90 | if (pid && entry.getPid() && (pid != entry.getPid())) { |
| 91 | continue; |
| 92 | } |
| 93 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 94 | size_t sizes = entry.getSizes(); |
| 95 | ssize_t index = len - 1; |
| 96 | while ((!retval[index] || (sizes > retval[index]->getSizes())) |
| 97 | && (--index >= 0)) |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 98 | ; |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 99 | if (++index < (ssize_t)len) { |
| 100 | size_t num = len - index - 1; |
| 101 | if (num) { |
| 102 | memmove(&retval[index + 1], &retval[index], |
| 103 | num * sizeof(retval[0])); |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 104 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 105 | retval[index] = &entry; |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | std::unique_ptr<const TEntry *[]> sorted(retval); |
| 109 | return sorted; |
| 110 | } |
| 111 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 112 | inline iterator add(TKey key, LogBufferElement *element) { |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 113 | iterator it = map.find(key); |
| 114 | if (it == map.end()) { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 115 | it = map.insert(std::make_pair(key, TEntry(element))).first; |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 116 | } else { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 117 | it->second.add(element); |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 118 | } |
| 119 | return it; |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 120 | } |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 121 | |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 122 | inline iterator add(TKey key) { |
| 123 | iterator it = map.find(key); |
| 124 | if (it == map.end()) { |
| 125 | it = map.insert(std::make_pair(key, TEntry(key))).first; |
| 126 | } else { |
| 127 | it->second.add(key); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 128 | } |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 129 | return it; |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 132 | void subtract(TKey key, LogBufferElement *element) { |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 133 | iterator it = map.find(key); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 134 | if ((it != map.end()) && it->second.subtract(element)) { |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 135 | map.erase(it); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 136 | } |
| 137 | } |
| 138 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 139 | inline void drop(TKey key, LogBufferElement *element) { |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 140 | iterator it = map.find(key); |
| 141 | if (it != map.end()) { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 142 | it->second.drop(element); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 146 | inline iterator begin() { return map.begin(); } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 147 | inline const_iterator begin() const { return map.begin(); } |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 148 | inline iterator end() { return map.end(); } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 149 | inline const_iterator end() const { return map.end(); } |
Mark Salyzyn | 511338d | 2015-05-19 09:12:30 -0700 | [diff] [blame] | 150 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 151 | std::string format( |
| 152 | const LogStatistics &stat, |
| 153 | uid_t uid, |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 154 | pid_t pid, |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 155 | const std::string &name = std::string(""), |
| 156 | log_id_t id = LOG_ID_MAX) const { |
| 157 | static const size_t maximum_sorted_entries = 32; |
| 158 | std::string output; |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 159 | std::unique_ptr<const TEntry *[]> sorted = sort(uid, pid, |
| 160 | maximum_sorted_entries); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 161 | if (!sorted.get()) { |
| 162 | return output; |
| 163 | } |
| 164 | bool headerPrinted = false; |
| 165 | for (size_t index = 0; index < maximum_sorted_entries; ++index) { |
| 166 | const TEntry *entry = sorted[index]; |
| 167 | if (!entry) { |
| 168 | break; |
| 169 | } |
| 170 | if (entry->getSizes() <= (sorted[0]->getSizes() / 100)) { |
| 171 | break; |
| 172 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 173 | if (!headerPrinted) { |
| 174 | output += "\n\n"; |
| 175 | output += entry->formatHeader(name, id); |
| 176 | headerPrinted = true; |
| 177 | } |
| 178 | output += entry->format(stat, id); |
| 179 | } |
| 180 | return output; |
| 181 | } |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 182 | |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 183 | }; |
| 184 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 185 | namespace EntryBaseConstants { |
| 186 | static constexpr size_t pruned_len = 14; |
| 187 | static constexpr size_t total_len = 80; |
| 188 | } |
| 189 | |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 190 | struct EntryBase { |
Mark Salyzyn | 97c1c2b | 2015-03-10 13:51:35 -0700 | [diff] [blame] | 191 | size_t size; |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 192 | |
| 193 | EntryBase():size(0) { } |
Chih-Hung Hsieh | 9e70ba6 | 2016-08-02 11:31:44 -0700 | [diff] [blame] | 194 | explicit EntryBase(LogBufferElement *element):size(element->getMsgLen()) { } |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 195 | |
| 196 | size_t getSizes() const { return size; } |
| 197 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 198 | inline void add(LogBufferElement *element) { size += element->getMsgLen(); } |
| 199 | inline bool subtract(LogBufferElement *element) { |
| 200 | size -= element->getMsgLen(); |
| 201 | return !size; |
| 202 | } |
| 203 | |
| 204 | static std::string formatLine( |
| 205 | const std::string &name, |
| 206 | const std::string &size, |
| 207 | const std::string &pruned) { |
| 208 | ssize_t drop_len = std::max(pruned.length() + 1, |
| 209 | EntryBaseConstants::pruned_len); |
| 210 | ssize_t size_len = std::max(size.length() + 1, |
| 211 | EntryBaseConstants::total_len |
| 212 | - name.length() - drop_len - 1); |
| 213 | |
| 214 | if (pruned.length()) { |
| 215 | return android::base::StringPrintf("%s%*s%*s\n", name.c_str(), |
| 216 | (int)size_len, size.c_str(), |
| 217 | (int)drop_len, pruned.c_str()); |
| 218 | } else { |
| 219 | return android::base::StringPrintf("%s%*s\n", name.c_str(), |
| 220 | (int)size_len, size.c_str()); |
| 221 | } |
| 222 | } |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 223 | }; |
| 224 | |
| 225 | struct EntryBaseDropped : public EntryBase { |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 226 | size_t dropped; |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 227 | |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 228 | EntryBaseDropped():dropped(0) { } |
Chih-Hung Hsieh | 9e70ba6 | 2016-08-02 11:31:44 -0700 | [diff] [blame] | 229 | explicit EntryBaseDropped(LogBufferElement *element): |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 230 | EntryBase(element), |
Mark Salyzyn | 6a06694 | 2016-07-14 15:34:30 -0700 | [diff] [blame] | 231 | dropped(element->getDropped()) { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 232 | } |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 233 | |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 234 | size_t getDropped() const { return dropped; } |
| 235 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 236 | inline void add(LogBufferElement *element) { |
| 237 | dropped += element->getDropped(); |
| 238 | EntryBase::add(element); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 239 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 240 | inline bool subtract(LogBufferElement *element) { |
| 241 | dropped -= element->getDropped(); |
| 242 | return EntryBase::subtract(element) && !dropped; |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 243 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 244 | inline void drop(LogBufferElement *element) { |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 245 | dropped += 1; |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 246 | EntryBase::subtract(element); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 247 | } |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 248 | }; |
| 249 | |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 250 | struct UidEntry : public EntryBaseDropped { |
| 251 | const uid_t uid; |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 252 | pid_t pid; |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 253 | |
Chih-Hung Hsieh | 9e70ba6 | 2016-08-02 11:31:44 -0700 | [diff] [blame] | 254 | explicit UidEntry(LogBufferElement *element): |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 255 | EntryBaseDropped(element), |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 256 | uid(element->getUid()), |
| 257 | pid(element->getPid()) { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 258 | } |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 259 | |
| 260 | inline const uid_t&getKey() const { return uid; } |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 261 | inline const uid_t&getUid() const { return getKey(); } |
| 262 | inline const pid_t&getPid() const { return pid; } |
| 263 | |
| 264 | inline void add(LogBufferElement *element) { |
| 265 | if (pid != element->getPid()) { |
| 266 | pid = -1; |
| 267 | } |
| 268 | EntryBase::add(element); |
| 269 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 270 | |
| 271 | std::string formatHeader(const std::string &name, log_id_t id) const; |
| 272 | std::string format(const LogStatistics &stat, log_id_t id) const; |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 273 | }; |
| 274 | |
| 275 | namespace android { |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 276 | uid_t pidToUid(pid_t pid); |
| 277 | } |
| 278 | |
| 279 | struct PidEntry : public EntryBaseDropped { |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 280 | const pid_t pid; |
| 281 | uid_t uid; |
| 282 | char *name; |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 283 | |
Chih-Hung Hsieh | 9e70ba6 | 2016-08-02 11:31:44 -0700 | [diff] [blame] | 284 | explicit PidEntry(pid_t pid): |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 285 | EntryBaseDropped(), |
| 286 | pid(pid), |
| 287 | uid(android::pidToUid(pid)), |
| 288 | name(android::pidToName(pid)) { |
| 289 | } |
Chih-Hung Hsieh | 9e70ba6 | 2016-08-02 11:31:44 -0700 | [diff] [blame] | 290 | explicit PidEntry(LogBufferElement *element): |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 291 | EntryBaseDropped(element), |
| 292 | pid(element->getPid()), |
| 293 | uid(element->getUid()), |
| 294 | name(android::pidToName(pid)) { |
| 295 | } |
| 296 | PidEntry(const PidEntry &element): |
| 297 | EntryBaseDropped(element), |
| 298 | pid(element.pid), |
| 299 | uid(element.uid), |
| 300 | name(element.name ? strdup(element.name) : NULL) { |
| 301 | } |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 302 | ~PidEntry() { free(name); } |
| 303 | |
| 304 | const pid_t&getKey() const { return pid; } |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 305 | const pid_t&getPid() const { return getKey(); } |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 306 | const uid_t&getUid() const { return uid; } |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 307 | const char*getName() const { return name; } |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 308 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 309 | inline void add(pid_t newPid) { |
Mark Salyzyn | 0eeb06b | 2016-12-02 10:08:48 -0800 | [diff] [blame] | 310 | if (name && !fastcmp<strncmp>(name, "zygote", 6)) { |
Mark Salyzyn | aa43ae2 | 2015-04-20 10:27:38 -0700 | [diff] [blame] | 311 | free(name); |
| 312 | name = NULL; |
| 313 | } |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 314 | if (!name) { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 315 | name = android::pidToName(newPid); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 316 | } |
| 317 | } |
| 318 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 319 | inline void add(LogBufferElement *element) { |
| 320 | uid_t incomingUid = element->getUid(); |
| 321 | if (getUid() != incomingUid) { |
| 322 | uid = incomingUid; |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 323 | free(name); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 324 | name = android::pidToName(element->getPid()); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 325 | } else { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 326 | add(element->getPid()); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 327 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 328 | EntryBaseDropped::add(element); |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 329 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 330 | |
| 331 | std::string formatHeader(const std::string &name, log_id_t id) const; |
| 332 | std::string format(const LogStatistics &stat, log_id_t id) const; |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 333 | }; |
Mark Salyzyn | 81b3eab | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 334 | |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 335 | struct TidEntry : public EntryBaseDropped { |
| 336 | const pid_t tid; |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 337 | pid_t pid; |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 338 | uid_t uid; |
| 339 | char *name; |
| 340 | |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 341 | TidEntry(pid_t tid, pid_t pid): |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 342 | EntryBaseDropped(), |
| 343 | tid(tid), |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 344 | pid(pid), |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 345 | uid(android::pidToUid(tid)), |
| 346 | name(android::tidToName(tid)) { |
| 347 | } |
Chih-Hung Hsieh | 9e70ba6 | 2016-08-02 11:31:44 -0700 | [diff] [blame] | 348 | explicit TidEntry(LogBufferElement *element): |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 349 | EntryBaseDropped(element), |
| 350 | tid(element->getTid()), |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 351 | pid(element->getPid()), |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 352 | uid(element->getUid()), |
| 353 | name(android::tidToName(tid)) { |
| 354 | } |
| 355 | TidEntry(const TidEntry &element): |
| 356 | EntryBaseDropped(element), |
| 357 | tid(element.tid), |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 358 | pid(element.pid), |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 359 | uid(element.uid), |
| 360 | name(element.name ? strdup(element.name) : NULL) { |
| 361 | } |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 362 | ~TidEntry() { free(name); } |
| 363 | |
| 364 | const pid_t&getKey() const { return tid; } |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 365 | const pid_t&getTid() const { return getKey(); } |
| 366 | const pid_t&getPid() const { return pid; } |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 367 | const uid_t&getUid() const { return uid; } |
| 368 | const char*getName() const { return name; } |
| 369 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 370 | inline void add(pid_t incomingTid) { |
Mark Salyzyn | 0eeb06b | 2016-12-02 10:08:48 -0800 | [diff] [blame] | 371 | if (name && !fastcmp<strncmp>(name, "zygote", 6)) { |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 372 | free(name); |
| 373 | name = NULL; |
| 374 | } |
| 375 | if (!name) { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 376 | name = android::tidToName(incomingTid); |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 377 | } |
| 378 | } |
| 379 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 380 | inline void add(LogBufferElement *element) { |
| 381 | uid_t incomingUid = element->getUid(); |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 382 | pid_t incomingPid = element->getPid(); |
| 383 | if ((getUid() != incomingUid) || (getPid() != incomingPid)) { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 384 | uid = incomingUid; |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 385 | pid = incomingPid; |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 386 | free(name); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 387 | name = android::tidToName(element->getTid()); |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 388 | } else { |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 389 | add(element->getTid()); |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 390 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 391 | EntryBaseDropped::add(element); |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 392 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 393 | |
| 394 | std::string formatHeader(const std::string &name, log_id_t id) const; |
| 395 | std::string format(const LogStatistics &stat, log_id_t id) const; |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 396 | }; |
| 397 | |
Mark Salyzyn | 6a06694 | 2016-07-14 15:34:30 -0700 | [diff] [blame] | 398 | struct TagEntry : public EntryBaseDropped { |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 399 | const uint32_t tag; |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 400 | pid_t pid; |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 401 | uid_t uid; |
| 402 | |
Chih-Hung Hsieh | 9e70ba6 | 2016-08-02 11:31:44 -0700 | [diff] [blame] | 403 | explicit TagEntry(LogBufferElement *element): |
Mark Salyzyn | 6a06694 | 2016-07-14 15:34:30 -0700 | [diff] [blame] | 404 | EntryBaseDropped(element), |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 405 | tag(element->getTag()), |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 406 | pid(element->getPid()), |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 407 | uid(element->getUid()) { |
| 408 | } |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 409 | |
| 410 | const uint32_t&getKey() const { return tag; } |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 411 | const pid_t&getPid() const { return pid; } |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 412 | const uid_t&getUid() const { return uid; } |
Mark Salyzyn | 807e40e | 2016-09-22 09:56:51 -0700 | [diff] [blame] | 413 | const char*getName(size_t &len) const { return android::tagToName(&len, tag); } |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 414 | |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 415 | inline void add(LogBufferElement *element) { |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 416 | if (uid != element->getUid()) { |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 417 | uid = -1; |
| 418 | } |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 419 | if (pid != element->getPid()) { |
| 420 | pid = -1; |
| 421 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 422 | EntryBase::add(element); |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 423 | } |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 424 | |
| 425 | std::string formatHeader(const std::string &name, log_id_t id) const; |
| 426 | std::string format(const LogStatistics &stat, log_id_t id) const; |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 427 | }; |
| 428 | |
Mark Salyzyn | 6a06694 | 2016-07-14 15:34:30 -0700 | [diff] [blame] | 429 | template <typename TEntry> |
| 430 | class LogFindWorst { |
| 431 | std::unique_ptr<const TEntry *[]> sorted; |
| 432 | |
| 433 | public: |
| 434 | |
Chih-Hung Hsieh | 9e70ba6 | 2016-08-02 11:31:44 -0700 | [diff] [blame] | 435 | explicit LogFindWorst(std::unique_ptr<const TEntry *[]> &&sorted) : sorted(std::move(sorted)) { } |
Mark Salyzyn | 6a06694 | 2016-07-14 15:34:30 -0700 | [diff] [blame] | 436 | |
| 437 | void findWorst(int &worst, |
| 438 | size_t &worst_sizes, size_t &second_worst_sizes, |
| 439 | size_t threshold) { |
| 440 | if (sorted.get() && sorted[0] && sorted[1]) { |
| 441 | worst_sizes = sorted[0]->getSizes(); |
| 442 | if ((worst_sizes > threshold) |
| 443 | // Allow time horizon to extend roughly tenfold, assume |
| 444 | // average entry length is 100 characters. |
| 445 | && (worst_sizes > (10 * sorted[0]->getDropped()))) { |
| 446 | worst = sorted[0]->getKey(); |
| 447 | second_worst_sizes = sorted[1]->getSizes(); |
| 448 | if (second_worst_sizes < threshold) { |
| 449 | second_worst_sizes = threshold; |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | void findWorst(int &worst, |
| 456 | size_t worst_sizes, size_t &second_worst_sizes) { |
| 457 | if (sorted.get() && sorted[0] && sorted[1]) { |
| 458 | worst = sorted[0]->getKey(); |
| 459 | second_worst_sizes = worst_sizes |
| 460 | - sorted[0]->getSizes() |
| 461 | + sorted[1]->getSizes(); |
| 462 | } |
| 463 | } |
| 464 | }; |
| 465 | |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 466 | // Log Statistics |
| 467 | class LogStatistics { |
Mark Salyzyn | c723df8 | 2015-08-24 11:08:00 -0700 | [diff] [blame] | 468 | friend UidEntry; |
| 469 | |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 470 | size_t mSizes[LOG_ID_MAX]; |
| 471 | size_t mElements[LOG_ID_MAX]; |
Mark Salyzyn | 58b8be8 | 2015-09-30 07:40:09 -0700 | [diff] [blame] | 472 | size_t mDroppedElements[LOG_ID_MAX]; |
Mark Salyzyn | 97c1c2b | 2015-03-10 13:51:35 -0700 | [diff] [blame] | 473 | size_t mSizesTotal[LOG_ID_MAX]; |
| 474 | size_t mElementsTotal[LOG_ID_MAX]; |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 475 | bool enable; |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 476 | |
Mark Salyzyn | 97c1c2b | 2015-03-10 13:51:35 -0700 | [diff] [blame] | 477 | // uid to size list |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 478 | typedef LogHashtable<uid_t, UidEntry> uidTable_t; |
Mark Salyzyn | 97c1c2b | 2015-03-10 13:51:35 -0700 | [diff] [blame] | 479 | uidTable_t uidTable[LOG_ID_MAX]; |
Mark Salyzyn | e457b74 | 2014-02-19 17:18:31 -0800 | [diff] [blame] | 480 | |
Mark Salyzyn | bec3c3d | 2015-08-28 08:02:59 -0700 | [diff] [blame] | 481 | // pid of system to size list |
| 482 | typedef LogHashtable<pid_t, PidEntry> pidSystemTable_t; |
| 483 | pidSystemTable_t pidSystemTable[LOG_ID_MAX]; |
| 484 | |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 485 | // pid to uid list |
| 486 | typedef LogHashtable<pid_t, PidEntry> pidTable_t; |
| 487 | pidTable_t pidTable; |
| 488 | |
Mark Salyzyn | 17ed679 | 2015-04-20 13:35:15 -0700 | [diff] [blame] | 489 | // tid to uid list |
| 490 | typedef LogHashtable<pid_t, TidEntry> tidTable_t; |
| 491 | tidTable_t tidTable; |
| 492 | |
Mark Salyzyn | 344bff4 | 2015-04-13 14:24:45 -0700 | [diff] [blame] | 493 | // tag list |
| 494 | typedef LogHashtable<uint32_t, TagEntry> tagTable_t; |
| 495 | tagTable_t tagTable; |
| 496 | |
Mark Salyzyn | 083b037 | 2015-12-04 10:59:45 -0800 | [diff] [blame] | 497 | // security tag list |
| 498 | tagTable_t securityTagTable; |
| 499 | |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 500 | size_t sizeOf() const { |
| 501 | size_t size = sizeof(*this) + pidTable.sizeOf() + tidTable.sizeOf() + |
Mark Salyzyn | b067229 | 2016-10-06 10:09:24 -0700 | [diff] [blame] | 502 | tagTable.sizeOf() + securityTagTable.sizeOf() + |
| 503 | (pidTable.size() * sizeof(pidTable_t::iterator)) + |
| 504 | (tagTable.size() * sizeof(tagTable_t::iterator)); |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 505 | for(auto it : pidTable) { |
| 506 | const char* name = it.second.getName(); |
| 507 | if (name) size += strlen(name) + 1; |
| 508 | } |
| 509 | for(auto it : tidTable) { |
| 510 | const char* name = it.second.getName(); |
| 511 | if (name) size += strlen(name) + 1; |
| 512 | } |
| 513 | log_id_for_each(id) { |
| 514 | size += uidTable[id].sizeOf(); |
Mark Salyzyn | b067229 | 2016-10-06 10:09:24 -0700 | [diff] [blame] | 515 | size += uidTable[id].size() * sizeof(uidTable_t::iterator); |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 516 | size += pidSystemTable[id].sizeOf(); |
Mark Salyzyn | b067229 | 2016-10-06 10:09:24 -0700 | [diff] [blame] | 517 | size += pidSystemTable[id].size() * sizeof(pidSystemTable_t::iterator); |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 518 | } |
| 519 | return size; |
| 520 | } |
| 521 | |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 522 | public: |
Mark Salyzyn | 6d981af | 2016-10-06 09:55:21 -0700 | [diff] [blame] | 523 | |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 524 | LogStatistics(); |
| 525 | |
Mark Salyzyn | 720f6d1 | 2015-03-16 08:26:05 -0700 | [diff] [blame] | 526 | void enableStatistics() { enable = true; } |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 527 | |
Mark Salyzyn | 97c1c2b | 2015-03-10 13:51:35 -0700 | [diff] [blame] | 528 | void add(LogBufferElement *entry); |
| 529 | void subtract(LogBufferElement *entry); |
Mark Salyzyn | ab0dcf6 | 2015-03-16 12:04:09 -0700 | [diff] [blame] | 530 | // entry->setDropped(1) must follow this call |
| 531 | void drop(LogBufferElement *entry); |
Mark Salyzyn | aaad42f | 2015-09-30 07:40:09 -0700 | [diff] [blame] | 532 | // Correct for coalescing two entries referencing dropped content |
Mark Salyzyn | 58b8be8 | 2015-09-30 07:40:09 -0700 | [diff] [blame] | 533 | void erase(LogBufferElement *element) { |
| 534 | log_id_t log_id = element->getLogId(); |
| 535 | --mElements[log_id]; |
| 536 | --mDroppedElements[log_id]; |
| 537 | } |
Mark Salyzyn | e457b74 | 2014-02-19 17:18:31 -0800 | [diff] [blame] | 538 | |
Mark Salyzyn | 6a06694 | 2016-07-14 15:34:30 -0700 | [diff] [blame] | 539 | LogFindWorst<UidEntry> sort(uid_t uid, pid_t pid, size_t len, log_id id) { |
| 540 | return LogFindWorst<UidEntry>(uidTable[id].sort(uid, pid, len)); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 541 | } |
Mark Salyzyn | 6a06694 | 2016-07-14 15:34:30 -0700 | [diff] [blame] | 542 | LogFindWorst<PidEntry> sortPids(uid_t uid, pid_t pid, size_t len, log_id id) { |
| 543 | return LogFindWorst<PidEntry>(pidSystemTable[id].sort(uid, pid, len)); |
| 544 | } |
| 545 | LogFindWorst<TagEntry> sortTags(uid_t uid, pid_t pid, size_t len, log_id) { |
| 546 | return LogFindWorst<TagEntry>(tagTable.sort(uid, pid, len)); |
Mark Salyzyn | bec3c3d | 2015-08-28 08:02:59 -0700 | [diff] [blame] | 547 | } |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 548 | |
| 549 | // fast track current value by id only |
| 550 | size_t sizes(log_id_t id) const { return mSizes[id]; } |
| 551 | size_t elements(log_id_t id) const { return mElements[id]; } |
Mark Salyzyn | 58b8be8 | 2015-09-30 07:40:09 -0700 | [diff] [blame] | 552 | size_t realElements(log_id_t id) const { |
| 553 | return mElements[id] - mDroppedElements[id]; |
| 554 | } |
Mark Salyzyn | 97c1c2b | 2015-03-10 13:51:35 -0700 | [diff] [blame] | 555 | size_t sizesTotal(log_id_t id) const { return mSizesTotal[id]; } |
| 556 | size_t elementsTotal(log_id_t id) const { return mElementsTotal[id]; } |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 557 | |
Mark Salyzyn | ee3b838 | 2015-12-17 09:58:43 -0800 | [diff] [blame] | 558 | std::string format(uid_t uid, pid_t pid, unsigned int logMask) const; |
Mark Salyzyn | 9a03863 | 2014-04-07 07:05:40 -0700 | [diff] [blame] | 559 | |
Mark Salyzyn | ed777e9 | 2015-06-24 16:22:54 -0700 | [diff] [blame] | 560 | // helper (must be locked directly or implicitly by mLogElementsLock) |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 561 | const char *pidToName(pid_t pid) const; |
Mark Salyzyn | 4ba0387 | 2014-04-07 07:15:33 -0700 | [diff] [blame] | 562 | uid_t pidToUid(pid_t pid); |
Mark Salyzyn | 758058f | 2015-08-21 16:44:30 -0700 | [diff] [blame] | 563 | const char *uidToName(uid_t uid) const; |
Mark Salyzyn | 34facab | 2014-02-06 14:48:50 -0800 | [diff] [blame] | 564 | }; |
| 565 | |
| 566 | #endif // _LOGD_LOG_STATISTICS_H__ |