summaryrefslogtreecommitdiff
path: root/debuggerd/libdebuggerd/utility.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2018-02-13 13:16:17 -0800
committerElliott Hughes <enh@google.com>2018-04-13 17:34:20 -0700
commit1cc7bd80a6bc7f0908ae05b904cf9a0609609880 (patch)
tree6ade74f70af25a28e6164f287814de91c85530c1 /debuggerd/libdebuggerd/utility.cpp
parent07de83831f9a2bf67e1c4a4df72baed42b26c7e9 (diff)
debuggerd: remove maximum abort message length.
Let the logging implementation be the imposer of limits. Bug: http://b/64759619 Test: debuggerd_test Change-Id: I8bc73bf2301ce071668993b740880224846a4e75
Diffstat (limited to 'debuggerd/libdebuggerd/utility.cpp')
-rw-r--r--debuggerd/libdebuggerd/utility.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/debuggerd/libdebuggerd/utility.cpp b/debuggerd/libdebuggerd/utility.cpp
index d1538653d..1ad180073 100644
--- a/debuggerd/libdebuggerd/utility.cpp
+++ b/debuggerd/libdebuggerd/utility.cpp
@@ -74,25 +74,22 @@ void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) {
&& (log->crashed_tid == log->current_tid);
static bool write_to_kmsg = should_write_to_kmsg();
- char buf[512];
+ std::string msg;
va_list ap;
va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
+ android::base::StringAppendV(&msg, fmt, ap);
va_end(ap);
- size_t len = strlen(buf);
- if (len <= 0) {
- return;
- }
+ if (msg.empty()) return;
if (write_to_tombstone) {
- TEMP_FAILURE_RETRY(write(log->tfd, buf, len));
+ TEMP_FAILURE_RETRY(write(log->tfd, msg.c_str(), msg.size()));
}
if (write_to_logcat) {
- __android_log_buf_write(LOG_ID_CRASH, ANDROID_LOG_FATAL, LOG_TAG, buf);
+ __android_log_buf_write(LOG_ID_CRASH, ANDROID_LOG_FATAL, LOG_TAG, msg.c_str());
if (log->amfd_data != nullptr) {
- *log->amfd_data += buf;
+ *log->amfd_data += msg;
}
if (write_to_kmsg) {
@@ -100,11 +97,11 @@ void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) {
if (kmsg_fd.get() >= 0) {
// Our output might contain newlines which would otherwise be handled by the android logger.
// Split the lines up ourselves before sending to the kernel logger.
- if (buf[len - 1] == '\n') {
- buf[len - 1] = '\0';
+ if (msg.back() == '\n') {
+ msg.back() = '\0';
}
- std::vector<std::string> fragments = android::base::Split(buf, "\n");
+ std::vector<std::string> fragments = android::base::Split(msg, "\n");
for (const std::string& fragment : fragments) {
static constexpr char prefix[] = "<3>DEBUG: ";
struct iovec iov[3];