From 9826c3e458c3a6d91277b55e956e02c326f9887c Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 17 Aug 2016 10:28:48 -0700 Subject: [PATCH] Add newline for INTERNAL_FATAL automatically Before, the behavior was different compared to other log levels that automatically added newlines. Bug: 30913672 Test: test-art-host Change-Id: I02147d8ac7ea38f3e93450ef5290cdfed7b5a2eb --- runtime/base/logging.cc | 5 ++++- runtime/gc/collector/mark_sweep.cc | 7 +++---- runtime/well_known_classes.cc | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/runtime/base/logging.cc b/runtime/base/logging.cc index 3ee15a246..28352cb2c 100644 --- a/runtime/base/logging.cc +++ b/runtime/base/logging.cc @@ -193,7 +193,10 @@ LogMessage::LogMessage(const char* file, unsigned int line, LogSeverity severity } } LogMessage::~LogMessage() { - if (!PrintDirectly(data_->GetSeverity()) && data_->GetSeverity() != LogSeverity::NONE) { + if (PrintDirectly(data_->GetSeverity())) { + // Add newline at the end to match the not printing directly behavior. + std::cerr << '\n'; + } else if (data_->GetSeverity() != LogSeverity::NONE) { if (data_->GetSeverity() < gMinimumLogSeverity) { return; // No need to format something we're not going to output. } diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index 1d15ee733..2335ccbaa 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -436,8 +436,7 @@ class MarkSweep::MarkObjectSlowPath { << " num_of_ref_fields=" << (holder_->IsClass() ? holder_->AsClass()->NumReferenceStaticFields() - : holder_->GetClass()->NumReferenceInstanceFields()) - << "\n"; + : holder_->GetClass()->NumReferenceInstanceFields()); // Print the memory content of the holder. for (size_t i = 0; i < holder_size / sizeof(uint32_t); ++i) { uint32_t* p = reinterpret_cast(holder_); @@ -447,7 +446,7 @@ class MarkSweep::MarkObjectSlowPath { } PrintFileToLog("/proc/self/maps", LogSeverity::INTERNAL_FATAL); MemMap::DumpMaps(LOG(INTERNAL_FATAL), true); - LOG(INTERNAL_FATAL) << "Attempting see if it's a bad thread root\n"; + LOG(INTERNAL_FATAL) << "Attempting see if it's a bad thread root"; mark_sweep_->VerifySuspendedThreadRoots(); LOG(FATAL) << "Can't mark invalid object"; } @@ -575,7 +574,7 @@ class MarkSweep::VerifyRootVisitor : public SingleRootVisitor { if (heap->GetLiveBitmap()->GetContinuousSpaceBitmap(root) == nullptr) { space::LargeObjectSpace* large_object_space = heap->GetLargeObjectsSpace(); if (large_object_space != nullptr && !large_object_space->Contains(root)) { - LOG(INTERNAL_FATAL) << "Found invalid root: " << root << " " << info << "\n"; + LOG(INTERNAL_FATAL) << "Found invalid root: " << root << " " << info; } } } diff --git a/runtime/well_known_classes.cc b/runtime/well_known_classes.cc index ddce344af..2c992753f 100644 --- a/runtime/well_known_classes.cc +++ b/runtime/well_known_classes.cc @@ -181,7 +181,7 @@ static jfieldID CacheField(JNIEnv* env, jclass c, bool is_static, if (fid == nullptr) { ScopedObjectAccess soa(env); if (soa.Self()->IsExceptionPending()) { - LOG(INTERNAL_FATAL) << soa.Self()->GetException()->Dump() << '\n'; + LOG(INTERNAL_FATAL) << soa.Self()->GetException()->Dump(); } std::ostringstream os; WellKnownClasses::ToClass(c)->DumpClass(os, mirror::Class::kDumpClassFullDetail); @@ -198,7 +198,7 @@ jmethodID CacheMethod(JNIEnv* env, jclass c, bool is_static, if (mid == nullptr) { ScopedObjectAccess soa(env); if (soa.Self()->IsExceptionPending()) { - LOG(INTERNAL_FATAL) << soa.Self()->GetException()->Dump() << '\n'; + LOG(INTERNAL_FATAL) << soa.Self()->GetException()->Dump(); } std::ostringstream os; WellKnownClasses::ToClass(c)->DumpClass(os, mirror::Class::kDumpClassFullDetail); -- 2.11.0