blob: 2c2d785cea9a93a300b61141b0cc9807a671394d [file] [log] [blame]
Mark Salyzyn7b30ff82015-01-26 13:41:33 -08001// Copyright 2006-2015 The Android Open Source Project
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08002
Mark Salyzyn65772ca2013-12-13 11:10:11 -08003#include <assert.h>
4#include <ctype.h>
5#include <errno.h>
6#include <fcntl.h>
Aristidis Papaioannoueba73442014-10-16 22:19:55 -07007#include <math.h>
Mark Salyzyn65772ca2013-12-13 11:10:11 -08008#include <stdio.h>
9#include <stdlib.h>
10#include <stdarg.h>
11#include <string.h>
12#include <signal.h>
13#include <time.h>
14#include <unistd.h>
Traian Schiau59763032015-04-10 15:51:39 +030015#include <sys/cdefs.h>
Mark Salyzyn65772ca2013-12-13 11:10:11 -080016#include <sys/socket.h>
17#include <sys/stat.h>
18#include <arpa/inet.h>
19
20#include <cutils/sockets.h>
Mark Salyzyn95132e92013-11-22 10:55:48 -080021#include <log/log.h>
Mark Salyzynfa3716b2014-02-14 16:05:05 -080022#include <log/log_read.h>
Colin Cross9227bd32013-07-23 16:59:20 -070023#include <log/logger.h>
24#include <log/logd.h>
25#include <log/logprint.h>
26#include <log/event_tag_map.h>
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080027
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080028#define DEFAULT_MAX_ROTATED_LOGS 4
29
30static AndroidLogFormat * g_logformat;
31
32/* logd prefixes records with a length field */
33#define RECORD_LENGTH_FIELD_SIZE_BYTES sizeof(uint32_t)
34
Joe Onorato6fa09a02010-02-26 10:04:23 -080035struct log_device_t {
Mark Salyzyn95132e92013-11-22 10:55:48 -080036 const char* device;
Joe Onorato6fa09a02010-02-26 10:04:23 -080037 bool binary;
Mark Salyzyn95132e92013-11-22 10:55:48 -080038 struct logger *logger;
39 struct logger_list *logger_list;
Joe Onorato6fa09a02010-02-26 10:04:23 -080040 bool printed;
Joe Onorato6fa09a02010-02-26 10:04:23 -080041
Joe Onorato6fa09a02010-02-26 10:04:23 -080042 log_device_t* next;
43
Mark Salyzyn5f6738a2015-02-27 13:41:34 -080044 log_device_t(const char* d, bool b) {
Joe Onorato6fa09a02010-02-26 10:04:23 -080045 device = d;
46 binary = b;
Joe Onorato6fa09a02010-02-26 10:04:23 -080047 next = NULL;
48 printed = false;
Traian Schiau59763032015-04-10 15:51:39 +030049 logger = NULL;
50 logger_list = NULL;
Joe Onorato6fa09a02010-02-26 10:04:23 -080051 }
Joe Onorato6fa09a02010-02-26 10:04:23 -080052};
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080053
54namespace android {
55
56/* Global Variables */
57
58static const char * g_outputFileName = NULL;
Traian Schiau59763032015-04-10 15:51:39 +030059// 0 means "no log rotation"
60static size_t g_logRotateSizeKBytes = 0;
61// 0 means "unbounded"
62static size_t g_maxRotatedLogs = DEFAULT_MAX_ROTATED_LOGS;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080063static int g_outFD = -1;
Traian Schiau59763032015-04-10 15:51:39 +030064static size_t g_outByteCount = 0;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080065static int g_printBinary = 0;
Mark Salyzyn9421b0c2015-02-26 14:33:35 -080066static int g_devCount = 0; // >1 means multiple
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080067
Traian Schiau59763032015-04-10 15:51:39 +030068__noreturn static void logcat_panic(bool showHelp, const char *fmt, ...) __printflike(2,3);
69
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080070static int openLogFile (const char *pathname)
71{
Edwin Vane80b221c2012-08-13 12:55:07 -040072 return open(pathname, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080073}
74
75static void rotateLogs()
76{
77 int err;
78
79 // Can't rotate logs if we're not outputting to a file
80 if (g_outputFileName == NULL) {
81 return;
82 }
83
84 close(g_outFD);
85
Aristidis Papaioannoueba73442014-10-16 22:19:55 -070086 // Compute the maximum number of digits needed to count up to g_maxRotatedLogs in decimal.
87 // eg: g_maxRotatedLogs == 30 -> log10(30) == 1.477 -> maxRotationCountDigits == 2
88 int maxRotationCountDigits =
89 (g_maxRotatedLogs > 0) ? (int) (floor(log10(g_maxRotatedLogs) + 1)) : 0;
90
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080091 for (int i = g_maxRotatedLogs ; i > 0 ; i--) {
92 char *file0, *file1;
93
Aristidis Papaioannoueba73442014-10-16 22:19:55 -070094 asprintf(&file1, "%s.%.*d", g_outputFileName, maxRotationCountDigits, i);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080095
96 if (i - 1 == 0) {
97 asprintf(&file0, "%s", g_outputFileName);
98 } else {
Aristidis Papaioannoueba73442014-10-16 22:19:55 -070099 asprintf(&file0, "%s.%.*d", g_outputFileName, maxRotationCountDigits, i - 1);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800100 }
101
Traian Schiau59763032015-04-10 15:51:39 +0300102 if (!file0 || !file1) {
103 perror("while rotating log files");
104 break;
105 }
106
107 err = rename(file0, file1);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800108
109 if (err < 0 && errno != ENOENT) {
110 perror("while rotating log files");
111 }
112
113 free(file1);
114 free(file0);
115 }
116
Traian Schiau59763032015-04-10 15:51:39 +0300117 g_outFD = openLogFile(g_outputFileName);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800118
119 if (g_outFD < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300120 logcat_panic(false, "couldn't open output file");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800121 }
122
123 g_outByteCount = 0;
124
125}
126
Mark Salyzyn95132e92013-11-22 10:55:48 -0800127void printBinary(struct log_msg *buf)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800128{
Mark Salyzyn95132e92013-11-22 10:55:48 -0800129 size_t size = buf->len();
130
131 TEMP_FAILURE_RETRY(write(g_outFD, buf, size));
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800132}
133
Mark Salyzyn95132e92013-11-22 10:55:48 -0800134static void processBuffer(log_device_t* dev, struct log_msg *buf)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800135{
Mathias Agopian50844522010-03-17 16:10:26 -0700136 int bytesWritten = 0;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800137 int err;
138 AndroidLogEntry entry;
139 char binaryMsgBuf[1024];
140
Joe Onorato6fa09a02010-02-26 10:04:23 -0800141 if (dev->binary) {
Mark Salyzyn9421b0c2015-02-26 14:33:35 -0800142 static bool hasOpenedEventTagMap = false;
143 static EventTagMap *eventTagMap = NULL;
144
145 if (!eventTagMap && !hasOpenedEventTagMap) {
146 eventTagMap = android_openEventTagMap(EVENT_TAG_MAP_FILE);
147 hasOpenedEventTagMap = true;
148 }
Mark Salyzyn95132e92013-11-22 10:55:48 -0800149 err = android_log_processBinaryLogBuffer(&buf->entry_v1, &entry,
Mark Salyzyn9421b0c2015-02-26 14:33:35 -0800150 eventTagMap,
Mark Salyzyn95132e92013-11-22 10:55:48 -0800151 binaryMsgBuf,
152 sizeof(binaryMsgBuf));
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800153 //printf(">>> pri=%d len=%d msg='%s'\n",
154 // entry.priority, entry.messageLen, entry.message);
155 } else {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800156 err = android_log_processLogBuffer(&buf->entry_v1, &entry);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800157 }
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800158 if (err < 0) {
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800159 goto error;
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800160 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800161
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800162 if (android_log_shouldPrintLine(g_logformat, entry.tag, entry.priority)) {
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800163 bytesWritten = android_log_printLogLine(g_logformat, g_outFD, &entry);
164
165 if (bytesWritten < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300166 logcat_panic(false, "output error");
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800167 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800168 }
169
170 g_outByteCount += bytesWritten;
171
Mark Salyzyn95132e92013-11-22 10:55:48 -0800172 if (g_logRotateSizeKBytes > 0
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800173 && (g_outByteCount / 1024) >= g_logRotateSizeKBytes
174 ) {
175 rotateLogs();
176 }
177
178error:
179 //fprintf (stderr, "Error processing record\n");
180 return;
181}
182
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800183static void maybePrintStart(log_device_t* dev, bool printDividers) {
184 if (!dev->printed || printDividers) {
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800185 if (g_devCount > 1 && !g_printBinary) {
186 char buf[1024];
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800187 snprintf(buf, sizeof(buf), "--------- %s %s\n",
188 dev->printed ? "switch to" : "beginning of",
Mark Salyzyn95132e92013-11-22 10:55:48 -0800189 dev->device);
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800190 if (write(g_outFD, buf, strlen(buf)) < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300191 logcat_panic(false, "output error");
Joe Onorato6fa09a02010-02-26 10:04:23 -0800192 }
193 }
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800194 dev->printed = true;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800195 }
196}
197
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800198static void setupOutput()
199{
200
201 if (g_outputFileName == NULL) {
202 g_outFD = STDOUT_FILENO;
203
204 } else {
205 struct stat statbuf;
206
207 g_outFD = openLogFile (g_outputFileName);
208
209 if (g_outFD < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300210 logcat_panic(false, "couldn't open output file");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800211 }
212
Traian Schiau59763032015-04-10 15:51:39 +0300213 if (fstat(g_outFD, &statbuf) == -1) {
214 close(g_outFD);
215 logcat_panic(false, "couldn't get output file stat\n");
216 }
217
218 if ((size_t) statbuf.st_size > SIZE_MAX || statbuf.st_size < 0) {
219 close(g_outFD);
220 logcat_panic(false, "invalid output file stat\n");
221 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800222
223 g_outByteCount = statbuf.st_size;
224 }
225}
226
227static void show_help(const char *cmd)
228{
229 fprintf(stderr,"Usage: %s [options] [filterspecs]\n", cmd);
230
231 fprintf(stderr, "options include:\n"
232 " -s Set default filter to silent.\n"
Mark Salyzynbba894a2015-03-09 09:32:56 -0700233 " Like specifying filterspec '*:S'\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800234 " -f <filename> Log to file. Default to stdout\n"
Traian Schiau59763032015-04-10 15:51:39 +0300235 " -r <kbytes> Rotate log every kbytes. Requires -f\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800236 " -n <count> Sets max number of rotated logs to <count>, default 4\n"
Pierre Zurekead88fc2010-10-17 22:39:37 +0200237 " -v <format> Sets the log print format, where <format> is:\n\n"
Mark Salyzyne1f20042015-05-06 08:40:40 -0700238 " brief color long process raw tag thread threadtime time usec\n\n"
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800239 " -D print dividers between each log buffer\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800240 " -c clear (flush) the entire log and exit\n"
241 " -d dump the log and then exit (don't block)\n"
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800242 " -t <count> print only the most recent <count> lines (implies -d)\n"
Mark Salyzyn190b7ac2014-09-01 10:41:33 -0700243 " -t '<time>' print most recent lines since specified time (implies -d)\n"
Mark Salyzyn5d3d1f12013-12-09 13:47:00 -0800244 " -T <count> print only the most recent <count> lines (does not imply -d)\n"
Mark Salyzyn190b7ac2014-09-01 10:41:33 -0700245 " -T '<time>' print most recent lines since specified time (not imply -d)\n"
246 " count is pure numerical, time is 'MM-DD hh:mm:ss.mmm'\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800247 " -g get the size of the log's ring buffer and exit\n"
Mark Salyzyn7c975ac2014-12-15 10:01:31 -0800248 " -L dump logs from prior to last reboot\n"
Mark Salyzyn34facab2014-02-06 14:48:50 -0800249 " -b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',\n"
Mark Salyzyn99f47a92014-04-07 14:58:08 -0700250 " 'events', 'crash' or 'all'. Multiple -b parameters are\n"
251 " allowed and results are interleaved. The default is\n"
252 " -b main -b system -b crash.\n"
Mark Salyzyn34facab2014-02-06 14:48:50 -0800253 " -B output the log in binary.\n"
Mark Salyzynbbbe14f2014-04-11 13:49:43 -0700254 " -S output statistics.\n"
255 " -G <size> set size of log ring buffer, may suffix with K or M.\n"
256 " -p print prune white and ~black list. Service is specified as\n"
257 " UID, UID/PID or /PID. Weighed for quicker pruning if prefix\n"
258 " with ~, otherwise weighed for longevity if unadorned. All\n"
259 " other pruning activity is oldest first. Special case ~!\n"
260 " represents an automatic quicker pruning for the noisiest\n"
261 " UID as determined by the current statistics.\n"
262 " -P '<list> ...' set prune white and ~black list, using same format as\n"
263 " printed above. Must be quoted.\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800264
265 fprintf(stderr,"\nfilterspecs are a series of \n"
266 " <tag>[:priority]\n\n"
267 "where <tag> is a log component tag (or * for all) and priority is:\n"
Mark Salyzynbba894a2015-03-09 09:32:56 -0700268 " V Verbose (default for <tag>)\n"
269 " D Debug (default for '*')\n"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800270 " I Info\n"
271 " W Warn\n"
272 " E Error\n"
273 " F Fatal\n"
Mark Salyzynbba894a2015-03-09 09:32:56 -0700274 " S Silent (suppress all output)\n"
275 "\n'*' by itself means '*:D' and <tag> by itself means <tag>:V.\n"
276 "If no '*' filterspec or -s on command line, all filter defaults to '*:V'.\n"
277 "eg: '*:S <tag>' prints only <tag>, '<tag>:S' suppresses all <tag> log messages.\n"
278 "\nIf not specified on the command line, filterspec is set from ANDROID_LOG_TAGS.\n"
279 "\nIf not specified with -v on command line, format is set from ANDROID_PRINTF_LOG\n"
Mark Salyzyn649fc602014-09-16 09:15:15 -0700280 "or defaults to \"threadtime\"\n\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800281}
282
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800283static int setLogFormat(const char * formatString)
284{
285 static AndroidLogPrintFormat format;
286
287 format = android_log_formatFromString(formatString);
288
289 if (format == FORMAT_OFF) {
290 // FORMAT_OFF means invalid string
291 return -1;
292 }
293
Mark Salyzyne1f20042015-05-06 08:40:40 -0700294 return android_log_setPrintFormat(g_logformat, format);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800295}
296
Mark Salyzyn671e3432014-05-06 07:34:59 -0700297static const char multipliers[][2] = {
298 { "" },
299 { "K" },
300 { "M" },
301 { "G" }
302};
303
304static unsigned long value_of_size(unsigned long value)
305{
306 for (unsigned i = 0;
307 (i < sizeof(multipliers)/sizeof(multipliers[0])) && (value >= 1024);
308 value /= 1024, ++i) ;
309 return value;
310}
311
312static const char *multiplier_of_size(unsigned long value)
313{
314 unsigned i;
315 for (i = 0;
316 (i < sizeof(multipliers)/sizeof(multipliers[0])) && (value >= 1024);
317 value /= 1024, ++i) ;
318 return multipliers[i];
319}
320
Traian Schiau59763032015-04-10 15:51:39 +0300321/*String to unsigned int, returns -1 if it fails*/
322static bool getSizeTArg(char *ptr, size_t *val, size_t min = 0,
323 size_t max = SIZE_MAX)
324{
325 char *endp;
326 errno = 0;
327 size_t ret = (size_t) strtoll(ptr, &endp, 0);
328
329 if (endp[0] != '\0' || errno != 0 ) {
330 return false;
331 }
332
333 if (ret > max || ret < min) {
334 return false;
335 }
336
337 *val = ret;
338 return true;
339}
340
341static void logcat_panic(bool showHelp, const char *fmt, ...)
342{
Mark Salyzyn77d7e812015-04-13 09:27:57 -0700343 va_list args;
344 va_start(args, fmt);
345 vfprintf(stderr, fmt, args);
346 va_end(args);
Traian Schiau59763032015-04-10 15:51:39 +0300347
348 if (showHelp) {
349 show_help(getprogname());
350 }
351
352 exit(EXIT_FAILURE);
353}
354
355} /* namespace android */
356
357
Joe Onorato6fa09a02010-02-26 10:04:23 -0800358int main(int argc, char **argv)
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800359{
Traian Schiau59763032015-04-10 15:51:39 +0300360 using namespace android;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800361 int err;
362 int hasSetLogFormat = 0;
363 int clearLog = 0;
364 int getLogSize = 0;
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800365 unsigned long setLogSize = 0;
366 int getPruneList = 0;
367 char *setPruneList = NULL;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800368 int printStatistics = 0;
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800369 int mode = ANDROID_LOG_RDONLY;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800370 const char *forceFilters = NULL;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800371 log_device_t* devices = NULL;
372 log_device_t* dev;
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800373 bool printDividers = false;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800374 struct logger_list *logger_list;
Traian Schiau59763032015-04-10 15:51:39 +0300375 size_t tail_lines = 0;
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800376 log_time tail_time(log_time::EPOCH);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800377
Mark Salyzyn65772ca2013-12-13 11:10:11 -0800378 signal(SIGPIPE, exit);
379
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800380 g_logformat = android_log_format_new();
381
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800382 if (argc == 2 && 0 == strcmp(argv[1], "--help")) {
Traian Schiau59763032015-04-10 15:51:39 +0300383 show_help(argv[0]);
384 return EXIT_SUCCESS;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800385 }
386
387 for (;;) {
388 int ret;
389
Traian Schiau59763032015-04-10 15:51:39 +0300390 ret = getopt(argc, argv, ":cdDLt:T:gG:sQf:r:n:v:b:BSpP:");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800391
392 if (ret < 0) {
393 break;
394 }
395
396 switch(ret) {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800397 case 's':
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800398 // default to all silent
399 android_log_addFilterRule(g_logformat, "*:s");
400 break;
401
402 case 'c':
403 clearLog = 1;
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800404 mode |= ANDROID_LOG_WRONLY;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800405 break;
406
Mark Salyzyn7c975ac2014-12-15 10:01:31 -0800407 case 'L':
408 mode |= ANDROID_LOG_PSTORE;
409 break;
410
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800411 case 'd':
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800412 mode |= ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800413 break;
414
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800415 case 't':
Mark Salyzyn2d3f38a2015-01-26 10:46:44 -0800416 mode |= ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK;
Mark Salyzyn5d3d1f12013-12-09 13:47:00 -0800417 /* FALLTHRU */
418 case 'T':
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800419 if (strspn(optarg, "0123456789") != strlen(optarg)) {
420 char *cp = tail_time.strptime(optarg,
421 log_time::default_format);
422 if (!cp) {
Traian Schiau59763032015-04-10 15:51:39 +0300423 logcat_panic(false,
424 "-%c \"%s\" not in \"%s\" time format\n",
425 ret, optarg, log_time::default_format);
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800426 }
427 if (*cp) {
428 char c = *cp;
429 *cp = '\0';
430 fprintf(stderr,
431 "WARNING: -%c \"%s\"\"%c%s\" time truncated\n",
432 ret, optarg, c, cp + 1);
433 *cp = c;
434 }
435 } else {
Traian Schiau59763032015-04-10 15:51:39 +0300436 if (!getSizeTArg(optarg, &tail_lines, 1)) {
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800437 fprintf(stderr,
438 "WARNING: -%c %s invalid, setting to 1\n",
439 ret, optarg);
440 tail_lines = 1;
441 }
442 }
Dan Egnord1d3b6d2010-03-11 20:32:17 -0800443 break;
444
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800445 case 'D':
446 printDividers = true;
447 break;
448
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800449 case 'g':
450 getLogSize = 1;
451 break;
452
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800453 case 'G': {
Traian Schiau59763032015-04-10 15:51:39 +0300454 char *cp;
455 if (strtoll(optarg, &cp, 0) > 0) {
456 setLogSize = strtoll(optarg, &cp, 0);
457 } else {
458 setLogSize = 0;
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800459 }
460
461 switch(*cp) {
462 case 'g':
463 case 'G':
464 setLogSize *= 1024;
465 /* FALLTHRU */
466 case 'm':
467 case 'M':
468 setLogSize *= 1024;
469 /* FALLTHRU */
470 case 'k':
471 case 'K':
472 setLogSize *= 1024;
473 /* FALLTHRU */
474 case '\0':
475 break;
476
477 default:
478 setLogSize = 0;
479 }
480
481 if (!setLogSize) {
482 fprintf(stderr, "ERROR: -G <num><multiplier>\n");
Traian Schiau59763032015-04-10 15:51:39 +0300483 return EXIT_FAILURE;
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800484 }
485 }
486 break;
487
488 case 'p':
489 getPruneList = 1;
490 break;
491
492 case 'P':
493 setPruneList = optarg;
494 break;
495
Joe Onorato6fa09a02010-02-26 10:04:23 -0800496 case 'b': {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800497 if (strcmp(optarg, "all") == 0) {
498 while (devices) {
499 dev = devices;
500 devices = dev->next;
501 delete dev;
502 }
503
Mark Salyzynd0bd1b12014-10-10 15:25:38 -0700504 devices = dev = NULL;
Traian Schiau59763032015-04-10 15:51:39 +0300505 g_devCount = 0;
Mark Salyzynd0bd1b12014-10-10 15:25:38 -0700506 for(int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
507 const char *name = android_log_id_to_name((log_id_t)i);
508 log_id_t log_id = android_name_to_log_id(name);
509
510 if (log_id != (log_id_t)i) {
511 continue;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800512 }
Mark Salyzynd0bd1b12014-10-10 15:25:38 -0700513
514 bool binary = strcmp(name, "events") == 0;
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800515 log_device_t* d = new log_device_t(name, binary);
Mark Salyzynd0bd1b12014-10-10 15:25:38 -0700516
517 if (dev) {
518 dev->next = d;
519 dev = d;
520 } else {
521 devices = dev = d;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800522 }
Traian Schiau59763032015-04-10 15:51:39 +0300523 g_devCount++;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800524 }
525 break;
526 }
527
Joe Onorato6fa09a02010-02-26 10:04:23 -0800528 bool binary = strcmp(optarg, "events") == 0;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800529
530 if (devices) {
531 dev = devices;
532 while (dev->next) {
533 dev = dev->next;
534 }
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800535 dev->next = new log_device_t(optarg, binary);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800536 } else {
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800537 devices = new log_device_t(optarg, binary);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800538 }
Traian Schiau59763032015-04-10 15:51:39 +0300539 g_devCount++;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800540 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800541 break;
542
543 case 'B':
Traian Schiau59763032015-04-10 15:51:39 +0300544 g_printBinary = 1;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800545 break;
546
547 case 'f':
548 // redirect output to a file
Traian Schiau59763032015-04-10 15:51:39 +0300549 g_outputFileName = optarg;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800550
551 break;
552
553 case 'r':
Traian Schiau59763032015-04-10 15:51:39 +0300554 if (!getSizeTArg(optarg, &g_logRotateSizeKBytes, 1)) {
555 logcat_panic(true, "Invalid parameter %s to -r\n", optarg);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800556 }
557 break;
558
559 case 'n':
Traian Schiau59763032015-04-10 15:51:39 +0300560 if (!getSizeTArg(optarg, &g_maxRotatedLogs, 1)) {
561 logcat_panic(true, "Invalid parameter %s to -n\n", optarg);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800562 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800563 break;
564
565 case 'v':
566 err = setLogFormat (optarg);
567 if (err < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300568 logcat_panic(true, "Invalid parameter %s to -v\n", optarg);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800569 }
Mark Salyzyne1f20042015-05-06 08:40:40 -0700570 hasSetLogFormat |= err;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800571 break;
572
573 case 'Q':
574 /* this is a *hidden* option used to start a version of logcat */
575 /* in an emulated device only. it basically looks for androidboot.logcat= */
576 /* on the kernel command line. If something is found, it extracts a log filter */
577 /* and uses it to run the program. If nothing is found, the program should */
578 /* quit immediately */
579#define KERNEL_OPTION "androidboot.logcat="
580#define CONSOLE_OPTION "androidboot.console="
581 {
582 int fd;
583 char* logcat;
584 char* console;
585 int force_exit = 1;
586 static char cmdline[1024];
587
588 fd = open("/proc/cmdline", O_RDONLY);
589 if (fd >= 0) {
590 int n = read(fd, cmdline, sizeof(cmdline)-1 );
591 if (n < 0) n = 0;
592 cmdline[n] = 0;
593 close(fd);
594 } else {
595 cmdline[0] = 0;
596 }
597
598 logcat = strstr( cmdline, KERNEL_OPTION );
599 console = strstr( cmdline, CONSOLE_OPTION );
600 if (logcat != NULL) {
601 char* p = logcat + sizeof(KERNEL_OPTION)-1;;
602 char* q = strpbrk( p, " \t\n\r" );;
603
604 if (q != NULL)
605 *q = 0;
606
607 forceFilters = p;
608 force_exit = 0;
609 }
610 /* if nothing found or invalid filters, exit quietly */
Traian Schiau59763032015-04-10 15:51:39 +0300611 if (force_exit) {
612 return EXIT_SUCCESS;
613 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800614
615 /* redirect our output to the emulator console */
616 if (console) {
617 char* p = console + sizeof(CONSOLE_OPTION)-1;
618 char* q = strpbrk( p, " \t\n\r" );
619 char devname[64];
620 int len;
621
622 if (q != NULL) {
623 len = q - p;
624 } else
625 len = strlen(p);
626
627 len = snprintf( devname, sizeof(devname), "/dev/%.*s", len, p );
628 fprintf(stderr, "logcat using %s (%d)\n", devname, len);
629 if (len < (int)sizeof(devname)) {
630 fd = open( devname, O_WRONLY );
631 if (fd >= 0) {
632 dup2(fd, 1);
633 dup2(fd, 2);
634 close(fd);
635 }
636 }
637 }
638 }
639 break;
640
Mark Salyzyn34facab2014-02-06 14:48:50 -0800641 case 'S':
642 printStatistics = 1;
643 break;
644
Traian Schiau59763032015-04-10 15:51:39 +0300645 case ':':
646 logcat_panic(true, "Option -%c needs an argument\n", optopt);
647 break;
648
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800649 default:
Traian Schiau59763032015-04-10 15:51:39 +0300650 logcat_panic(true, "Unrecognized Option %c\n", optopt);
651 break;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800652 }
653 }
654
Joe Onorato6fa09a02010-02-26 10:04:23 -0800655 if (!devices) {
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800656 dev = devices = new log_device_t("main", false);
Traian Schiau59763032015-04-10 15:51:39 +0300657 g_devCount = 1;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800658 if (android_name_to_log_id("system") == LOG_ID_SYSTEM) {
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800659 dev = dev->next = new log_device_t("system", false);
Traian Schiau59763032015-04-10 15:51:39 +0300660 g_devCount++;
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800661 }
Mark Salyzyn99f47a92014-04-07 14:58:08 -0700662 if (android_name_to_log_id("crash") == LOG_ID_CRASH) {
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800663 dev = dev->next = new log_device_t("crash", false);
Traian Schiau59763032015-04-10 15:51:39 +0300664 g_devCount++;
Mark Salyzyn99f47a92014-04-07 14:58:08 -0700665 }
Joe Onorato6fa09a02010-02-26 10:04:23 -0800666 }
667
Traian Schiau59763032015-04-10 15:51:39 +0300668 if (g_logRotateSizeKBytes != 0 && g_outputFileName == NULL) {
669 logcat_panic(true, "-r requires -f as well\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800670 }
671
Traian Schiau59763032015-04-10 15:51:39 +0300672 setupOutput();
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800673
674 if (hasSetLogFormat == 0) {
675 const char* logFormat = getenv("ANDROID_PRINTF_LOG");
676
677 if (logFormat != NULL) {
678 err = setLogFormat(logFormat);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800679 if (err < 0) {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800680 fprintf(stderr, "invalid format in ANDROID_PRINTF_LOG '%s'\n",
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800681 logFormat);
682 }
Mark Salyzyn649fc602014-09-16 09:15:15 -0700683 } else {
684 setLogFormat("threadtime");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800685 }
686 }
687
688 if (forceFilters) {
689 err = android_log_addFilterString(g_logformat, forceFilters);
690 if (err < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300691 logcat_panic(false, "Invalid filter expression in logcat args\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800692 }
693 } else if (argc == optind) {
694 // Add from environment variable
695 char *env_tags_orig = getenv("ANDROID_LOG_TAGS");
696
697 if (env_tags_orig != NULL) {
698 err = android_log_addFilterString(g_logformat, env_tags_orig);
699
Mark Salyzyn95132e92013-11-22 10:55:48 -0800700 if (err < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300701 logcat_panic(true,
702 "Invalid filter expression in ANDROID_LOG_TAGS\n");
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800703 }
704 }
705 } else {
706 // Add from commandline
707 for (int i = optind ; i < argc ; i++) {
708 err = android_log_addFilterString(g_logformat, argv[i]);
709
Mark Salyzyn95132e92013-11-22 10:55:48 -0800710 if (err < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300711 logcat_panic(true, "Invalid filter expression '%s'\n", argv[i]);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800712 }
713 }
714 }
715
Joe Onorato6fa09a02010-02-26 10:04:23 -0800716 dev = devices;
Mark Salyzynfa3716b2014-02-14 16:05:05 -0800717 if (tail_time != log_time::EPOCH) {
718 logger_list = android_logger_list_alloc_time(mode, tail_time, 0);
719 } else {
720 logger_list = android_logger_list_alloc(mode, tail_lines, 0);
721 }
Joe Onorato6fa09a02010-02-26 10:04:23 -0800722 while (dev) {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800723 dev->logger_list = logger_list;
724 dev->logger = android_logger_open(logger_list,
725 android_name_to_log_id(dev->device));
726 if (!dev->logger) {
Traian Schiau59763032015-04-10 15:51:39 +0300727 logcat_panic(false, "Unable to open log device '%s'\n",
728 dev->device);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800729 }
Joe Onorato6fa09a02010-02-26 10:04:23 -0800730
731 if (clearLog) {
732 int ret;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800733 ret = android_logger_clear(dev->logger);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800734 if (ret) {
Traian Schiau59763032015-04-10 15:51:39 +0300735 logcat_panic(false, "failed to clear the log");
Joe Onorato6fa09a02010-02-26 10:04:23 -0800736 }
Joe Onorato6fa09a02010-02-26 10:04:23 -0800737 }
738
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800739 if (setLogSize && android_logger_set_log_size(dev->logger, setLogSize)) {
Traian Schiau59763032015-04-10 15:51:39 +0300740 logcat_panic(false, "failed to set the log size");
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800741 }
742
Joe Onorato6fa09a02010-02-26 10:04:23 -0800743 if (getLogSize) {
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800744 long size, readable;
Joe Onorato6fa09a02010-02-26 10:04:23 -0800745
Mark Salyzyn95132e92013-11-22 10:55:48 -0800746 size = android_logger_get_log_size(dev->logger);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800747 if (size < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300748 logcat_panic(false, "failed to get the log size");
Joe Onorato6fa09a02010-02-26 10:04:23 -0800749 }
750
Mark Salyzyn95132e92013-11-22 10:55:48 -0800751 readable = android_logger_get_log_readable_size(dev->logger);
Joe Onorato6fa09a02010-02-26 10:04:23 -0800752 if (readable < 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300753 logcat_panic(false, "failed to get the readable log size");
Joe Onorato6fa09a02010-02-26 10:04:23 -0800754 }
755
Mark Salyzyn671e3432014-05-06 07:34:59 -0700756 printf("%s: ring buffer is %ld%sb (%ld%sb consumed), "
Joe Onorato6fa09a02010-02-26 10:04:23 -0800757 "max entry is %db, max payload is %db\n", dev->device,
Mark Salyzyn671e3432014-05-06 07:34:59 -0700758 value_of_size(size), multiplier_of_size(size),
759 value_of_size(readable), multiplier_of_size(readable),
Joe Onorato6fa09a02010-02-26 10:04:23 -0800760 (int) LOGGER_ENTRY_MAX_LEN, (int) LOGGER_ENTRY_MAX_PAYLOAD);
761 }
762
763 dev = dev->next;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800764 }
765
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800766 if (setPruneList) {
Traian Schiau59763032015-04-10 15:51:39 +0300767 size_t len = strlen(setPruneList);
768 /*extra 32 bytes are needed by android_logger_set_prune_list */
769 size_t bLen = len + 32;
770 char *buf = NULL;
771 if (asprintf(&buf, "%-*s", (int)(bLen - 1), setPruneList) > 0) {
772 buf[len] = '\0';
773 if (android_logger_set_prune_list(logger_list, buf, bLen)) {
774 logcat_panic(false, "failed to set the prune list");
775 }
776 free(buf);
777 } else {
778 logcat_panic(false, "failed to set the prune list (alloc)");
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800779 }
780 }
781
Mark Salyzyn1c950472014-04-01 17:19:47 -0700782 if (printStatistics || getPruneList) {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800783 size_t len = 8192;
784 char *buf;
785
786 for(int retry = 32;
787 (retry >= 0) && ((buf = new char [len]));
Traian Schiau59763032015-04-10 15:51:39 +0300788 delete [] buf, buf = NULL, --retry) {
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800789 if (getPruneList) {
790 android_logger_get_prune_list(logger_list, buf, len);
791 } else {
792 android_logger_get_statistics(logger_list, buf, len);
793 }
Mark Salyzyn34facab2014-02-06 14:48:50 -0800794 buf[len-1] = '\0';
Traian Schiau59763032015-04-10 15:51:39 +0300795 if (atol(buf) < 3) {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800796 delete [] buf;
797 buf = NULL;
798 break;
799 }
Traian Schiau59763032015-04-10 15:51:39 +0300800 size_t ret = atol(buf) + 1;
801 if (ret <= len) {
802 len = ret;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800803 break;
804 }
Traian Schiau59763032015-04-10 15:51:39 +0300805 len = ret;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800806 }
807
808 if (!buf) {
Traian Schiau59763032015-04-10 15:51:39 +0300809 logcat_panic(false, "failed to read data");
Mark Salyzyn34facab2014-02-06 14:48:50 -0800810 }
811
812 // remove trailing FF
813 char *cp = buf + len - 1;
814 *cp = '\0';
815 bool truncated = *--cp != '\f';
816 if (!truncated) {
817 *cp = '\0';
818 }
819
820 // squash out the byte count
821 cp = buf;
822 if (!truncated) {
Mark Salyzyn22e287d2014-03-21 13:12:16 -0700823 while (isdigit(*cp)) {
824 ++cp;
825 }
826 if (*cp == '\n') {
Mark Salyzyn34facab2014-02-06 14:48:50 -0800827 ++cp;
828 }
829 }
830
831 printf("%s", cp);
832 delete [] buf;
Traian Schiau59763032015-04-10 15:51:39 +0300833 return EXIT_SUCCESS;
Mark Salyzyn34facab2014-02-06 14:48:50 -0800834 }
835
836
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800837 if (getLogSize) {
Traian Schiau59763032015-04-10 15:51:39 +0300838 return EXIT_SUCCESS;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800839 }
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800840 if (setLogSize || setPruneList) {
Traian Schiau59763032015-04-10 15:51:39 +0300841 return EXIT_SUCCESS;
Mark Salyzyndfa7a072014-02-11 12:29:31 -0800842 }
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800843 if (clearLog) {
Traian Schiau59763032015-04-10 15:51:39 +0300844 return EXIT_SUCCESS;
Joe Onoratoe2bf2ea2010-03-01 09:11:54 -0800845 }
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800846
847 //LOG_EVENT_INT(10, 12345);
848 //LOG_EVENT_LONG(11, 0x1122334455667788LL);
849 //LOG_EVENT_STRING(0, "whassup, doc?");
850
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800851 dev = NULL;
Mark Salyzyn5f6738a2015-02-27 13:41:34 -0800852 log_device_t unexpected("unexpected", false);
Mark Salyzyn95132e92013-11-22 10:55:48 -0800853 while (1) {
854 struct log_msg log_msg;
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800855 log_device_t* d;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800856 int ret = android_logger_list_read(logger_list, &log_msg);
857
858 if (ret == 0) {
Traian Schiau59763032015-04-10 15:51:39 +0300859 logcat_panic(false, "read: unexpected EOF!\n");
Mark Salyzyn95132e92013-11-22 10:55:48 -0800860 }
861
862 if (ret < 0) {
863 if (ret == -EAGAIN) {
864 break;
865 }
866
867 if (ret == -EIO) {
Traian Schiau59763032015-04-10 15:51:39 +0300868 logcat_panic(false, "read: unexpected EOF!\n");
Mark Salyzyn95132e92013-11-22 10:55:48 -0800869 }
870 if (ret == -EINVAL) {
Traian Schiau59763032015-04-10 15:51:39 +0300871 logcat_panic(false, "read: unexpected length.\n");
Mark Salyzyn95132e92013-11-22 10:55:48 -0800872 }
Traian Schiau59763032015-04-10 15:51:39 +0300873 logcat_panic(false, "logcat read failure");
Mark Salyzyn95132e92013-11-22 10:55:48 -0800874 }
875
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800876 for(d = devices; d; d = d->next) {
877 if (android_name_to_log_id(d->device) == log_msg.id()) {
Mark Salyzyn95132e92013-11-22 10:55:48 -0800878 break;
879 }
880 }
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800881 if (!d) {
Traian Schiau59763032015-04-10 15:51:39 +0300882 g_devCount = 2; // set to Multiple
Mark Salyzyn9421b0c2015-02-26 14:33:35 -0800883 d = &unexpected;
884 d->binary = log_msg.id() == LOG_ID_EVENTS;
Mark Salyzyn95132e92013-11-22 10:55:48 -0800885 }
886
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800887 if (dev != d) {
888 dev = d;
Traian Schiau59763032015-04-10 15:51:39 +0300889 maybePrintStart(dev, printDividers);
Mark Salyzyn7b30ff82015-01-26 13:41:33 -0800890 }
Traian Schiau59763032015-04-10 15:51:39 +0300891 if (g_printBinary) {
892 printBinary(&log_msg);
Mark Salyzyn95132e92013-11-22 10:55:48 -0800893 } else {
Traian Schiau59763032015-04-10 15:51:39 +0300894 processBuffer(dev, &log_msg);
Mark Salyzyn95132e92013-11-22 10:55:48 -0800895 }
896 }
897
898 android_logger_list_free(logger_list);
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800899
Traian Schiau59763032015-04-10 15:51:39 +0300900 return EXIT_SUCCESS;
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -0800901}