blob: 675b6927468cb1188fd06173d42f4f4832e55b55 [file] [log] [blame]
Mark Salyzyn34facab2014-02-06 14:48:50 -08001/*
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
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070017#include <algorithm> // std::max
Mark Salyzyn9a038632014-04-07 07:05:40 -070018#include <fcntl.h>
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070019#include <stdio.h>
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070020#include <string.h>
21#include <unistd.h>
Mark Salyzyn34facab2014-02-06 14:48:50 -080022
23#include <log/logger.h>
24#include <private/android_filesystem_config.h>
25#include <utils/String8.h>
26
27#include "LogStatistics.h"
28
Mark Salyzyn77187782015-05-12 15:21:31 -070029LogStatistics::LogStatistics() : enable(false) {
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070030 log_id_for_each(id) {
31 mSizes[id] = 0;
32 mElements[id] = 0;
33 mSizesTotal[id] = 0;
34 mElementsTotal[id] = 0;
Mark Salyzyn34facab2014-02-06 14:48:50 -080035 }
36}
37
Mark Salyzyn720f6d12015-03-16 08:26:05 -070038namespace android {
39
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070040// caller must own and free character string
Mark Salyzyn81b3eab2015-04-13 14:24:45 -070041char *pidToName(pid_t pid) {
Mark Salyzyn9a038632014-04-07 07:05:40 -070042 char *retval = NULL;
Mark Salyzynae4d9282014-10-15 08:49:39 -070043 if (pid == 0) { // special case from auditd/klogd for kernel
44 retval = strdup("logd");
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070045 } else {
Mark Salyzyn9a038632014-04-07 07:05:40 -070046 char buffer[512];
47 snprintf(buffer, sizeof(buffer), "/proc/%u/cmdline", pid);
48 int fd = open(buffer, O_RDONLY);
49 if (fd >= 0) {
50 ssize_t ret = read(fd, buffer, sizeof(buffer));
51 if (ret > 0) {
52 buffer[sizeof(buffer)-1] = '\0';
53 // frameworks intermediate state
54 if (strcmp(buffer, "<pre-initialized>")) {
55 retval = strdup(buffer);
56 }
57 }
58 close(fd);
59 }
60 }
61 return retval;
62}
63
Mark Salyzyn720f6d12015-03-16 08:26:05 -070064}
65
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070066void LogStatistics::add(LogBufferElement *e) {
67 log_id_t log_id = e->getLogId();
68 unsigned short size = e->getMsgLen();
Mark Salyzyn34facab2014-02-06 14:48:50 -080069 mSizes[log_id] += size;
70 ++mElements[log_id];
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070071
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070072 mSizesTotal[log_id] += size;
73 ++mElementsTotal[log_id];
Mark Salyzyn720f6d12015-03-16 08:26:05 -070074
Mark Salyzynae4d9282014-10-15 08:49:39 -070075 if (log_id == LOG_ID_KERNEL) {
76 return;
77 }
78
79 uidTable[log_id].add(e->getUid(), e);
80
Mark Salyzyn720f6d12015-03-16 08:26:05 -070081 if (!enable) {
82 return;
83 }
84
Mark Salyzyn81b3eab2015-04-13 14:24:45 -070085 pidTable.add(e->getPid(), e);
Mark Salyzyn344bff42015-04-13 14:24:45 -070086
87 uint32_t tag = e->getTag();
88 if (tag) {
89 tagTable.add(tag, e);
90 }
Mark Salyzyn34facab2014-02-06 14:48:50 -080091}
92
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070093void LogStatistics::subtract(LogBufferElement *e) {
94 log_id_t log_id = e->getLogId();
95 unsigned short size = e->getMsgLen();
Mark Salyzyn34facab2014-02-06 14:48:50 -080096 mSizes[log_id] -= size;
97 --mElements[log_id];
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070098
Mark Salyzynae4d9282014-10-15 08:49:39 -070099 if (log_id == LOG_ID_KERNEL) {
100 return;
101 }
102
Mark Salyzyn81b3eab2015-04-13 14:24:45 -0700103 uidTable[log_id].subtract(e->getUid(), e);
Mark Salyzyn34facab2014-02-06 14:48:50 -0800104
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700105 if (!enable) {
106 return;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800107 }
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700108
Mark Salyzyn81b3eab2015-04-13 14:24:45 -0700109 pidTable.subtract(e->getPid(), e);
Mark Salyzyn344bff42015-04-13 14:24:45 -0700110
111 uint32_t tag = e->getTag();
112 if (tag) {
113 tagTable.subtract(tag, e);
114 }
Mark Salyzyn34facab2014-02-06 14:48:50 -0800115}
116
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700117// Atomically set an entry to drop
118// entry->setDropped(1) must follow this call, caller should do this explicitly.
119void LogStatistics::drop(LogBufferElement *e) {
120 log_id_t log_id = e->getLogId();
121 unsigned short size = e->getMsgLen();
122 mSizes[log_id] -= size;
123
Mark Salyzyn81b3eab2015-04-13 14:24:45 -0700124 uidTable[log_id].drop(e->getUid(), e);
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700125
126 if (!enable) {
127 return;
128 }
129
Mark Salyzyn81b3eab2015-04-13 14:24:45 -0700130 pidTable.drop(e->getPid(), e);
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700131}
132
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700133// caller must own and free character string
134char *LogStatistics::uidToName(uid_t uid) {
135 // Local hard coded favourites
136 if (uid == AID_LOGD) {
137 return strdup("auditd");
Mark Salyzyn34facab2014-02-06 14:48:50 -0800138 }
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700139
140 // Android hard coded
141 const struct android_id_info *info = android_ids;
142
143 for (size_t i = 0; i < android_id_count; ++i) {
144 if (info->aid == uid) {
145 return strdup(info->name);
146 }
147 ++info;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800148 }
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700149
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700150 // Parse /data/system/packages.list
Mark Salyzyn023f51f2015-04-29 12:48:45 -0700151 uid_t userId = uid % AID_USER;
152 char *name = android::uidToName(userId);
153 if (!name && (userId > (AID_SHARED_GID_START - AID_APP))) {
154 name = android::uidToName(userId - (AID_SHARED_GID_START - AID_APP));
155 }
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700156 if (name) {
157 return name;
158 }
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700159
160 // report uid -> pid(s) -> pidToName if unique
161 ssize_t index = -1;
162 while ((index = pidTable.next(index)) != -1) {
163 const PidEntry &entry = pidTable.entryAt(index);
164
165 if (entry.getUid() == uid) {
166 const char *n = entry.getName();
167
168 if (n) {
169 if (!name) {
170 name = strdup(n);
171 } else if (strcmp(name, n)) {
172 free(name);
Mark Salyzyn023f51f2015-04-29 12:48:45 -0700173 name = NULL;
174 break;
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700175 }
176 }
177 }
178 }
179
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700180 // No one
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700181 return name;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800182}
183
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700184static void format_line(android::String8 &output,
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700185 android::String8 &name, android::String8 &size, android::String8 &pruned) {
186 static const size_t pruned_len = 6;
187 static const size_t total_len = 70 + pruned_len;
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700188
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700189 ssize_t drop_len = std::max(pruned.length() + 1, pruned_len);
190 ssize_t size_len = std::max(size.length() + 1,
191 total_len - name.length() - drop_len - 1);
192
193 if (pruned.length()) {
194 output.appendFormat("%s%*s%*s\n", name.string(),
195 (int)size_len, size.string(),
196 (int)drop_len, pruned.string());
197 } else {
198 output.appendFormat("%s%*s\n", name.string(),
199 (int)size_len, size.string());
200 }
Mark Salyzyn34facab2014-02-06 14:48:50 -0800201}
202
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700203void LogStatistics::format(char **buf, uid_t uid, unsigned int logMask) {
Mark Salyzyn9a038632014-04-07 07:05:40 -0700204 static const unsigned short spaces_total = 19;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800205
206 if (*buf) {
Greg Hackmann239605e2014-04-06 21:25:58 -0700207 free(*buf);
Mark Salyzyn34facab2014-02-06 14:48:50 -0800208 *buf = NULL;
209 }
210
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700211 // Report on total logging, current and for all time
Mark Salyzyn34facab2014-02-06 14:48:50 -0800212
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700213 android::String8 output("size/num");
214 size_t oldLength;
215 short spaces = 1;
216
217 log_id_for_each(id) {
218 if (!(logMask & (1 << id))) {
Mark Salyzync8a576c2014-04-04 16:35:59 -0700219 continue;
220 }
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700221 oldLength = output.length();
Mark Salyzync8a576c2014-04-04 16:35:59 -0700222 if (spaces < 0) {
223 spaces = 0;
224 }
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700225 output.appendFormat("%*s%s", spaces, "", android_log_id_to_name(id));
226 spaces += spaces_total + oldLength - output.length();
Mark Salyzyn34facab2014-02-06 14:48:50 -0800227 }
228
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700229 spaces = 4;
230 output.appendFormat("\nTotal");
Mark Salyzyn34facab2014-02-06 14:48:50 -0800231
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700232 log_id_for_each(id) {
233 if (!(logMask & (1 << id))) {
234 continue;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800235 }
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700236 oldLength = output.length();
237 if (spaces < 0) {
238 spaces = 0;
239 }
240 output.appendFormat("%*s%zu/%zu", spaces, "",
241 sizesTotal(id), elementsTotal(id));
242 spaces += spaces_total + oldLength - output.length();
Mark Salyzyn34facab2014-02-06 14:48:50 -0800243 }
244
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700245 spaces = 6;
246 output.appendFormat("\nNow");
Mark Salyzyn34facab2014-02-06 14:48:50 -0800247
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700248 log_id_for_each(id) {
249 if (!(logMask & (1 << id))) {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800250 continue;
251 }
252
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700253 size_t els = elements(id);
Mark Salyzyn34facab2014-02-06 14:48:50 -0800254 if (els) {
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700255 oldLength = output.length();
Mark Salyzyne457b742014-02-19 17:18:31 -0800256 if (spaces < 0) {
257 spaces = 0;
258 }
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700259 output.appendFormat("%*s%zu/%zu", spaces, "", sizes(id), els);
260 spaces -= output.length() - oldLength;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800261 }
262 spaces += spaces_total;
263 }
264
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700265 // Report on Chattiest
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700266
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700267 // Chattiest by application (UID)
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700268 static const size_t maximum_sorted_entries = 32;
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700269 log_id_for_each(id) {
270 if (!(logMask & (1 << id))) {
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700271 continue;
272 }
273
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700274 bool headerPrinted = false;
275 std::unique_ptr<const UidEntry *[]> sorted = sort(maximum_sorted_entries, id);
276 ssize_t index = -1;
277 while ((index = uidTable_t::next(index, sorted, maximum_sorted_entries)) >= 0) {
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700278 const UidEntry *entry = sorted[index];
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700279 uid_t u = entry->getKey();
280 if ((uid != AID_ROOT) && (u != uid)) {
281 continue;
282 }
283
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700284 if (!headerPrinted) {
Mark Salyzyn5720d2c2015-04-21 07:43:16 -0700285 output.appendFormat("\n\n");
286 android::String8 name("");
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700287 if (uid == AID_ROOT) {
Mark Salyzyn5720d2c2015-04-21 07:43:16 -0700288 name.appendFormat(
289 "Chattiest UIDs in %s log buffer:",
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700290 android_log_id_to_name(id));
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700291 } else {
Mark Salyzyn5720d2c2015-04-21 07:43:16 -0700292 name.appendFormat(
293 "Logging for your UID in %s log buffer:",
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700294 android_log_id_to_name(id));
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700295 }
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700296 android::String8 size("Size");
297 android::String8 pruned("Pruned");
Mark Salyzynae769232015-03-17 17:17:25 -0700298 if (!worstUidEnabledForLogid(id)) {
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700299 pruned.setTo("");
300 }
301 format_line(output, name, size, pruned);
Mark Salyzyn5720d2c2015-04-21 07:43:16 -0700302
303 name.setTo("UID PACKAGE");
304 size.setTo("BYTES");
305 pruned.setTo("LINES");
306 if (!worstUidEnabledForLogid(id)) {
307 pruned.setTo("");
308 }
309 format_line(output, name, size, pruned);
310
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700311 headerPrinted = true;
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700312 }
313
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700314 android::String8 name("");
315 name.appendFormat("%u", u);
316 char *n = uidToName(u);
317 if (n) {
318 name.appendFormat("%*s%s", (int)std::max(6 - name.length(), (size_t)1), "", n);
319 free(n);
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700320 }
321
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700322 android::String8 size("");
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700323 size.appendFormat("%zu", entry->getSizes());
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700324
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700325 android::String8 pruned("");
326 size_t dropped = entry->getDropped();
327 if (dropped) {
328 pruned.appendFormat("%zu", dropped);
329 }
330
331 format_line(output, name, size, pruned);
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700332 }
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700333 }
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700334
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700335 if (enable) {
Mark Salyzyn81b3eab2015-04-13 14:24:45 -0700336 // Pid table
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700337 bool headerPrinted = false;
338 std::unique_ptr<const PidEntry *[]> sorted = pidTable.sort(maximum_sorted_entries);
339 ssize_t index = -1;
340 while ((index = pidTable.next(index, sorted, maximum_sorted_entries)) >= 0) {
341 const PidEntry *entry = sorted[index];
342 uid_t u = entry->getUid();
343 if ((uid != AID_ROOT) && (u != uid)) {
344 continue;
345 }
346
347 if (!headerPrinted) {
Mark Salyzyn5720d2c2015-04-21 07:43:16 -0700348 output.appendFormat("\n\n");
349 android::String8 name("");
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700350 if (uid == AID_ROOT) {
Mark Salyzyn5720d2c2015-04-21 07:43:16 -0700351 name.appendFormat("Chattiest PIDs:");
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700352 } else {
Mark Salyzyn5720d2c2015-04-21 07:43:16 -0700353 name.appendFormat("Logging for this PID:");
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700354 }
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700355 android::String8 size("Size");
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700356 android::String8 pruned("Pruned");
357 format_line(output, name, size, pruned);
Mark Salyzyn5720d2c2015-04-21 07:43:16 -0700358
359 name.setTo(" PID/UID COMMAND LINE");
360 size.setTo("BYTES");
361 pruned.setTo("LINES");
362 format_line(output, name, size, pruned);
363
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700364 headerPrinted = true;
365 }
366
367 android::String8 name("");
368 name.appendFormat("%5u/%u", entry->getKey(), u);
369 const char *n = entry->getName();
370 if (n) {
371 name.appendFormat("%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", n);
372 } else {
373 char *un = uidToName(u);
374 if (un) {
375 name.appendFormat("%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", un);
376 free(un);
377 }
378 }
379
380 android::String8 size("");
381 size.appendFormat("%zu", entry->getSizes());
382
Mark Salyzynab0dcf62015-03-16 12:04:09 -0700383 android::String8 pruned("");
384 size_t dropped = entry->getDropped();
385 if (dropped) {
386 pruned.appendFormat("%zu", dropped);
387 }
388
389 format_line(output, name, size, pruned);
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700390 }
Mark Salyzyn8e72c532014-03-26 10:46:39 -0700391 }
392
Mark Salyzyn344bff42015-04-13 14:24:45 -0700393 if (enable && (logMask & (1 << LOG_ID_EVENTS))) {
394 // Tag table
395 bool headerPrinted = false;
396 std::unique_ptr<const TagEntry *[]> sorted = tagTable.sort(maximum_sorted_entries);
397 ssize_t index = -1;
398 while ((index = tagTable.next(index, sorted, maximum_sorted_entries)) >= 0) {
399 const TagEntry *entry = sorted[index];
400 uid_t u = entry->getUid();
401 if ((uid != AID_ROOT) && (u != uid)) {
402 continue;
403 }
404
405 android::String8 pruned("");
406
407 if (!headerPrinted) {
408 output.appendFormat("\n\n");
409 android::String8 name("Chattiest events log buffer TAGs:");
410 android::String8 size("Size");
411 format_line(output, name, size, pruned);
412
413 name.setTo(" TAG/UID TAGNAME");
414 size.setTo("BYTES");
415 format_line(output, name, size, pruned);
416
417 headerPrinted = true;
418 }
419
420 android::String8 name("");
421 if (u == (uid_t)-1) {
422 name.appendFormat("%7u", entry->getKey());
423 } else {
424 name.appendFormat("%7u/%u", entry->getKey(), u);
425 }
426 const char *n = entry->getName();
427 if (n) {
428 name.appendFormat("%*s%s", (int)std::max(14 - name.length(), (size_t)1), "", n);
429 }
430
431 android::String8 size("");
432 size.appendFormat("%zu", entry->getSizes());
433
434 format_line(output, name, size, pruned);
435 }
436 }
437
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700438 *buf = strdup(output.string());
Mark Salyzyn34facab2014-02-06 14:48:50 -0800439}
Mark Salyzyn4ba03872014-04-07 07:15:33 -0700440
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700441namespace android {
442
443uid_t pidToUid(pid_t pid) {
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700444 char buffer[512];
445 snprintf(buffer, sizeof(buffer), "/proc/%u/status", pid);
446 FILE *fp = fopen(buffer, "r");
447 if (fp) {
448 while (fgets(buffer, sizeof(buffer), fp)) {
449 int uid;
Mark Salyzync32afdf2015-04-14 13:07:29 -0700450 if (sscanf(buffer, "Uid: %d", &uid) == 1) {
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700451 fclose(fp);
452 return uid;
Mark Salyzyn4ba03872014-04-07 07:15:33 -0700453 }
454 }
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -0700455 fclose(fp);
Mark Salyzyn4ba03872014-04-07 07:15:33 -0700456 }
Mark Salyzyne3aeeee2015-03-17 07:56:32 -0700457 return AID_LOGD; // associate this with the logger
Mark Salyzyn4ba03872014-04-07 07:15:33 -0700458}
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700459
460}
461
462uid_t LogStatistics::pidToUid(pid_t pid) {
Mark Salyzyn81b3eab2015-04-13 14:24:45 -0700463 return pidTable.entryAt(pidTable.add(pid)).getUid();
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700464}
465
466// caller must free character string
467char *LogStatistics::pidToName(pid_t pid) {
Mark Salyzyn81b3eab2015-04-13 14:24:45 -0700468 const char *name = pidTable.entryAt(pidTable.add(pid)).getName();
469 if (!name) {
470 return NULL;
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700471 }
Mark Salyzyn81b3eab2015-04-13 14:24:45 -0700472 return strdup(name);
Mark Salyzyn720f6d12015-03-16 08:26:05 -0700473}