Loading debuggerd/debuggerd_test.cpp +38 −0 Original line number Diff line number Diff line Loading @@ -961,6 +961,44 @@ TEST_F(CrasherTest, abort_message) { ASSERT_MATCH(result, R"(Abort message: 'x{4045}')"); } TEST_F(CrasherTest, abort_message_newline_trimmed) { int intercept_result; unique_fd output_fd; StartProcess([]() { android_set_abort_message("Message with a newline.\n"); abort(); }); StartIntercept(&output_fd); FinishCrasher(); AssertDeath(SIGABRT); FinishIntercept(&intercept_result); ASSERT_EQ(1, intercept_result) << "tombstoned reported failure"; std::string result; ConsumeFd(std::move(output_fd), &result); ASSERT_MATCH(result, R"(Abort message: 'Message with a newline.')"); } TEST_F(CrasherTest, abort_message_multiple_newlines_trimmed) { int intercept_result; unique_fd output_fd; StartProcess([]() { android_set_abort_message("Message with multiple newlines.\n\n\n\n\n"); abort(); }); StartIntercept(&output_fd); FinishCrasher(); AssertDeath(SIGABRT); FinishIntercept(&intercept_result); ASSERT_EQ(1, intercept_result) << "tombstoned reported failure"; std::string result; ConsumeFd(std::move(output_fd), &result); ASSERT_MATCH(result, R"(Abort message: 'Message with multiple newlines.')"); } TEST_F(CrasherTest, abort_message_backtrace) { int intercept_result; unique_fd output_fd; Loading debuggerd/libdebuggerd/tombstone.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,12 @@ static void dump_abort_message(log_t* log, unwindstack::Memory* process_memory, return; } // Remove any trailing newlines. size_t index = length; while (index > 0 && (msg[index - 1] == '\0' || msg[index - 1] == '\n')) { --index; } msg[index] = '\0'; _LOG(log, logtype::HEADER, "Abort message: '%s'\n", &msg[0]); } Loading debuggerd/libdebuggerd/tombstone_proto.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -271,6 +271,13 @@ static void dump_abort_message(Tombstone* tombstone, unwindstack::Unwinder* unwi return; } // Remove any trailing newlines. size_t index = msg.size(); while (index > 0 && (msg[index - 1] == '\0' || msg[index - 1] == '\n')) { --index; } msg.resize(index); tombstone->set_abort_message(msg); } Loading Loading
debuggerd/debuggerd_test.cpp +38 −0 Original line number Diff line number Diff line Loading @@ -961,6 +961,44 @@ TEST_F(CrasherTest, abort_message) { ASSERT_MATCH(result, R"(Abort message: 'x{4045}')"); } TEST_F(CrasherTest, abort_message_newline_trimmed) { int intercept_result; unique_fd output_fd; StartProcess([]() { android_set_abort_message("Message with a newline.\n"); abort(); }); StartIntercept(&output_fd); FinishCrasher(); AssertDeath(SIGABRT); FinishIntercept(&intercept_result); ASSERT_EQ(1, intercept_result) << "tombstoned reported failure"; std::string result; ConsumeFd(std::move(output_fd), &result); ASSERT_MATCH(result, R"(Abort message: 'Message with a newline.')"); } TEST_F(CrasherTest, abort_message_multiple_newlines_trimmed) { int intercept_result; unique_fd output_fd; StartProcess([]() { android_set_abort_message("Message with multiple newlines.\n\n\n\n\n"); abort(); }); StartIntercept(&output_fd); FinishCrasher(); AssertDeath(SIGABRT); FinishIntercept(&intercept_result); ASSERT_EQ(1, intercept_result) << "tombstoned reported failure"; std::string result; ConsumeFd(std::move(output_fd), &result); ASSERT_MATCH(result, R"(Abort message: 'Message with multiple newlines.')"); } TEST_F(CrasherTest, abort_message_backtrace) { int intercept_result; unique_fd output_fd; Loading
debuggerd/libdebuggerd/tombstone.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,12 @@ static void dump_abort_message(log_t* log, unwindstack::Memory* process_memory, return; } // Remove any trailing newlines. size_t index = length; while (index > 0 && (msg[index - 1] == '\0' || msg[index - 1] == '\n')) { --index; } msg[index] = '\0'; _LOG(log, logtype::HEADER, "Abort message: '%s'\n", &msg[0]); } Loading
debuggerd/libdebuggerd/tombstone_proto.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -271,6 +271,13 @@ static void dump_abort_message(Tombstone* tombstone, unwindstack::Unwinder* unwi return; } // Remove any trailing newlines. size_t index = msg.size(); while (index > 0 && (msg[index - 1] == '\0' || msg[index - 1] == '\n')) { --index; } msg.resize(index); tombstone->set_abort_message(msg); } Loading