summaryrefslogtreecommitdiffstats
path: root/debuggerd/tombstone.cpp
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2013-12-12 12:21:20 -0800
committerMark Salyzyn <salyzyn@google.com>2014-01-27 15:17:13 -0800
commitfca0bd1a38597b83f6511d0c7c971fce75dc8123 (patch)
treebd5f439a26dbd792d2f0ef6a5b4b6730a5385c56 /debuggerd/tombstone.cpp
parent1345f38e4419607ea9c5b24109e5bd6df52dcffa (diff)
downloadsystem_core-fca0bd1a38597b83f6511d0c7c971fce75dc8123.zip
system_core-fca0bd1a38597b83f6511d0c7c971fce75dc8123.tar.gz
system_core-fca0bd1a38597b83f6511d0c7c971fce75dc8123.tar.bz2
debuggerd: Support newline split in log messages
(cherry picked from commit 706fad2b5fd96fb9b705795af1c11ef44d8a8fe9) Change-Id: I2c19f12ef027ab1e1455ce78824537da1b03edcd
Diffstat (limited to 'debuggerd/tombstone.cpp')
-rw-r--r--debuggerd/tombstone.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/debuggerd/tombstone.cpp b/debuggerd/tombstone.cpp
index 436b845..b4c57cc 100644
--- a/debuggerd/tombstone.cpp
+++ b/debuggerd/tombstone.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2013 The Android Open Source Project
+ * Copyright (C) 2012-2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -512,9 +512,6 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename,
//
// We want to display it in the same format as "logcat -v threadtime"
// (although in this case the pid is redundant).
- //
- // TODO: scan for line breaks ('\n') and display each text line
- // on a separate line, prefixed with the header, like logcat does.
static const char* kPrioChars = "!.VDIWEFS";
unsigned hdr_size = log_entry.entry.hdr_size;
if (!hdr_size) {
@@ -526,9 +523,9 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename,
msg = tag + strlen(tag) + 1;
// consume any trailing newlines
- char* eatnl = msg + strlen(msg) - 1;
- while (eatnl >= msg && *eatnl == '\n') {
- *eatnl-- = '\0';
+ char* nl = msg + strlen(msg) - 1;
+ while (nl >= msg && *nl == '\n') {
+ *nl-- = '\0';
}
char prioChar = (prio < strlen(kPrioChars) ? kPrioChars[prio] : '?');
@@ -540,9 +537,20 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename,
ptm = localtime_r(&sec, &tmBuf);
strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm);
- _LOG(log, 0, "%s.%03d %5d %5d %c %-8s: %s\n",
- timeBuf, entry->nsec / 1000000, entry->pid, entry->tid,
- prioChar, tag, msg);
+ // Look for line breaks ('\n') and display each text line
+ // on a separate line, prefixed with the header, like logcat does.
+ do {
+ nl = strchr(msg, '\n');
+ if (nl) {
+ *nl = '\0';
+ ++nl;
+ }
+
+ _LOG(log, 0, "%s.%03d %5d %5d %c %-8s: %s\n",
+ timeBuf, entry->nsec / 1000000, entry->pid, entry->tid,
+ prioChar, tag, msg);
+
+ } while ((msg = nl));
}
android_logger_list_free(logger_list);