#include "utils/swap_space.h"
#include "verifier/method_verifier.h"
#include "verifier/method_verifier-inl.h"
+#include "verifier/verifier_log_mode.h"
namespace art {
class VerifyClassVisitor : public CompilationVisitor {
public:
- VerifyClassVisitor(const ParallelCompilationManager* manager, LogSeverity log_level)
+ VerifyClassVisitor(const ParallelCompilationManager* manager, verifier::HardFailLogMode log_level)
: manager_(manager), log_level_(log_level) {}
virtual void Visit(size_t class_def_index) REQUIRES(!Locks::mutator_lock_) OVERRIDE {
private:
const ParallelCompilationManager* const manager_;
- const LogSeverity log_level_;
+ const verifier::HardFailLogMode log_level_;
};
void CompilerDriver::VerifyDexFile(jobject class_loader,
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
ParallelCompilationManager context(class_linker, class_loader, this, &dex_file, dex_files,
thread_pool);
- LogSeverity log_level = GetCompilerOptions().AbortOnHardVerifierFailure()
- ? LogSeverity::INTERNAL_FATAL
- : LogSeverity::WARNING;
+ verifier::HardFailLogMode log_level = GetCompilerOptions().AbortOnHardVerifierFailure()
+ ? verifier::HardFailLogMode::kLogInternalFatal
+ : verifier::HardFailLogMode::kLogWarning;
VerifyClassVisitor visitor(&context, log_level);
context.ForAll(0, dex_file.NumClassDefs(), &visitor, thread_count);
}
LogMessage::LogMessage(const char* file, unsigned int line, LogSeverity severity, int error)
: data_(new LogMessageData(file, line, severity, error)) {
if (PrintDirectly(severity)) {
- static constexpr char kLogCharacters[] = { 'N', 'V', 'D', 'I', 'W', 'E', 'F', 'F' };
+ static constexpr char kLogCharacters[] = { 'V', 'D', 'I', 'W', 'E', 'F', 'F' };
static_assert(arraysize(kLogCharacters) == static_cast<size_t>(INTERNAL_FATAL) + 1,
"Wrong character array size");
stream() << ProgramInvocationShortName() << " " << kLogCharacters[static_cast<size_t>(severity)]
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) {
+ } else {
if (data_->GetSeverity() < gMinimumLogSeverity) {
return; // No need to format something we're not going to output.
}
#ifdef ART_TARGET_ANDROID
static const android_LogPriority kLogSeverityToAndroidLogPriority[] = {
- ANDROID_LOG_VERBOSE, // NONE, use verbose as stand-in, will never be printed.
ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN,
ANDROID_LOG_ERROR, ANDROID_LOG_FATAL, ANDROID_LOG_FATAL
};
void LogMessage::LogLine(const char* file, unsigned int line, LogSeverity log_severity,
const char* message) {
- if (log_severity == LogSeverity::NONE) {
- return;
- }
-
#ifdef ART_TARGET_ANDROID
const char* tag = ProgramInvocationShortName();
int priority = kLogSeverityToAndroidLogPriority[static_cast<size_t>(log_severity)];
LOG_PRI(priority, tag, "%s", message);
}
#else
- static const char* log_characters = "NVDIWEFF";
+ static const char* log_characters = "VDIWEFF";
CHECK_EQ(strlen(log_characters), INTERNAL_FATAL + 1U);
char severity = log_characters[log_severity];
fprintf(stderr, "%s %c %5d %5d %s:%u] %s\n",
void LogMessage::LogLineLowStack(const char* file, unsigned int line, LogSeverity log_severity,
const char* message) {
- if (log_severity == LogSeverity::NONE) {
- return;
- }
-
#ifdef ART_TARGET_ANDROID
// Use android_writeLog() to avoid stack-based buffers used by android_printLog().
const char* tag = ProgramInvocationShortName();
android_writeLog(priority, tag, message);
}
#else
- static constexpr char kLogCharacters[] = { 'N', 'V', 'D', 'I', 'W', 'E', 'F', 'F' };
+ static constexpr char kLogCharacters[] = { 'V', 'D', 'I', 'W', 'E', 'F', 'F' };
static_assert(arraysize(kLogCharacters) == static_cast<size_t>(INTERNAL_FATAL) + 1,
"Wrong character array size");
namespace art {
enum LogSeverity {
- NONE, // Fake level, don't log at all.
VERBOSE,
DEBUG,
INFO,
return false;
}
-void ClassLinker::VerifyClass(Thread* self, Handle<mirror::Class> klass, LogSeverity log_level) {
+void ClassLinker::VerifyClass(Thread* self,
+ Handle<mirror::Class> klass,
+ verifier::HardFailLogMode log_level) {
{
// TODO: assert that the monitor on the Class is held
ObjectLock<mirror::Class> lock(self, klass);
#include "jni.h"
#include "oat_file.h"
#include "object_callbacks.h"
+#include "verifier/verifier_log_mode.h"
namespace art {
void VerifyClass(Thread* self,
Handle<mirror::Class> klass,
- LogSeverity log_level = LogSeverity::NONE)
+ verifier::HardFailLogMode log_level = verifier::HardFailLogMode::kLogNone)
REQUIRES_SHARED(Locks::mutator_lock_)
REQUIRES(!dex_lock_);
bool VerifyClassUsingOatFile(const DexFile& dex_file,
mirror::Class* klass,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
- LogSeverity log_level,
+ HardFailLogMode log_level,
std::string* error) {
if (klass->IsVerified()) {
return kNoFailure;
Handle<mirror::ClassLoader> class_loader,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
- LogSeverity log_level,
+ HardFailLogMode log_level,
bool need_precise_constants,
std::string* error_string) {
DCHECK(it != nullptr);
const DexFile::ClassDef& class_def,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
- LogSeverity log_level,
+ HardFailLogMode log_level,
std::string* error) {
ScopedTrace trace(__FUNCTION__);
uint32_t method_access_flags,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
- LogSeverity log_level,
+ HardFailLogMode log_level,
bool need_precise_constants,
std::string* hard_failure_msg) {
MethodVerifier::FailureData result;
} else {
CHECK(verifier.have_pending_hard_failure_);
if (VLOG_IS_ON(verifier)) {
- log_level = LogSeverity::VERBOSE;
+ log_level = std::max(HardFailLogMode::kLogVerbose, log_level);
}
- if (log_level > LogSeverity::VERBOSE) {
- verifier.DumpFailures(LOG(log_level) << "Verification error in "
- << PrettyMethod(method_idx, *dex_file) << "\n");
+ if (log_level >= HardFailLogMode::kLogVerbose) {
+ LogSeverity severity;
+ switch (log_level) {
+ case HardFailLogMode::kLogVerbose:
+ severity = LogSeverity::VERBOSE;
+ break;
+ case HardFailLogMode::kLogWarning:
+ severity = LogSeverity::WARNING;
+ break;
+ case HardFailLogMode::kLogInternalFatal:
+ severity = LogSeverity::INTERNAL_FATAL;
+ break;
+ default:
+ LOG(FATAL) << "Unsupported log-level " << static_cast<uint32_t>(log_level);
+ UNREACHABLE();
+ }
+ verifier.DumpFailures(LOG(severity) << "Verification error in "
+ << PrettyMethod(method_idx, *dex_file) << "\n");
}
if (hard_failure_msg != nullptr) {
CHECK(!verifier.failure_messages_.empty());
#include "method_reference.h"
#include "register_line.h"
#include "reg_type_cache.h"
+#include "verifier_log_mode.h"
namespace art {
mirror::Class* klass,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
- LogSeverity log_level,
+ HardFailLogMode log_level,
std::string* error)
REQUIRES_SHARED(Locks::mutator_lock_);
static FailureKind VerifyClass(Thread* self,
const DexFile::ClassDef& class_def,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
- LogSeverity log_level,
+ HardFailLogMode log_level,
std::string* error)
REQUIRES_SHARED(Locks::mutator_lock_);
Handle<mirror::ClassLoader> class_loader,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
- LogSeverity log_level,
+ HardFailLogMode log_level,
bool need_precise_constants,
std::string* error_string)
REQUIRES_SHARED(Locks::mutator_lock_);
uint32_t method_access_flags,
CompilerCallbacks* callbacks,
bool allow_soft_failures,
- LogSeverity log_level,
+ HardFailLogMode log_level,
bool need_precise_constants,
std::string* hard_failure_msg)
REQUIRES_SHARED(Locks::mutator_lock_);
#include "common_runtime_test.h"
#include "dex_file.h"
#include "scoped_thread_state_change.h"
+#include "verifier_log_mode.h"
namespace art {
namespace verifier {
// Verify the class
std::string error_msg;
- MethodVerifier::FailureKind failure = MethodVerifier::VerifyClass(self,
- klass,
- nullptr,
- true,
- LogSeverity::WARNING,
- &error_msg);
+ MethodVerifier::FailureKind failure = MethodVerifier::VerifyClass(
+ self, klass, nullptr, true, HardFailLogMode::kLogWarning, &error_msg);
ASSERT_TRUE(failure == MethodVerifier::kNoFailure) << error_msg;
}
--- /dev/null
+/*
+ * Copyright (C) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_RUNTIME_VERIFIER_VERIFIER_LOG_MODE_H_
+#define ART_RUNTIME_VERIFIER_VERIFIER_LOG_MODE_H_
+
+namespace art {
+namespace verifier {
+
+enum class HardFailLogMode {
+ kLogNone, // Don't log hard failures at all.
+ kLogVerbose, // Log with severity VERBOSE.
+ kLogWarning, // Log with severity WARNING.
+ kLogInternalFatal, // Log with severity INTERNAL_FATAL
+};
+
+} // namespace verifier
+} // namespace art
+
+#endif // ART_RUNTIME_VERIFIER_VERIFIER_LOG_MODE_H_