From 87a2f6fb6e4e3fb1cd10f70fdf9c49c39ed9c58d Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Wed, 28 Mar 2018 18:37:13 -0700 Subject: [PATCH] [M67 Dev][Tizen] Enable dlogutil for chromium and V8 This patch revised the implementation for V8 tag and removed unused codes. Following patch set has been migrated from tizen 4.0: [1] [Debugging] Dlog support on chromium https://review.tizen.org/gerrit/#/c/117909/ [2] Add dlog print for V8 module https://review.tizen.org/gerrit/#/c/120169/ https://review.tizen.org/gerrit/#/c/120695/ https://review.tizen.org/gerrit/#/c/120670/ https://review.tizen.org/gerrit/#/c/130508/ https://review.tizen.org/gerrit/#/c/143064/ [3] Print ASSERT error log to Tizen dlogutil https://review.tizen.org/gerrit/#/c/123738/ Reference: https://review.tizen.org/gerrit/#/c/174185/ Change-Id: I77861f94e8398a1223a16fa0ee2de0c972a461bf Signed-off-by: Youngsoo Choi --- base/BUILD.gn | 5 +++- base/logging.cc | 48 +++++++++++++++++++++++++++++++++- v8/BUILD.gn | 3 +++ v8/src/base/platform/platform-posix.cc | 11 ++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/base/BUILD.gn b/base/BUILD.gn index 6b025da..19d2664 100644 --- a/base/BUILD.gn +++ b/base/BUILD.gn @@ -1140,7 +1140,10 @@ jumbo_component("base") { } if (is_tizen) { - libs = [ "event" ] + libs = [ + "event", + "dlog", + ] } # winternl.h and NTSecAPI.h have different definitions of UNICODE_STRING. diff --git a/base/logging.cc b/base/logging.cc index 2dac3e2..1456c55 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -106,6 +106,11 @@ typedef pthread_mutex_t* MutexHandle; #include #endif +#if defined(OS_TIZEN) +#define LOG_TAG "CHROMIUM" +#include +#endif + namespace logging { namespace { @@ -161,6 +166,7 @@ base::LazyInstance>::Leaky // A log message handler that gets notified of every log message we process. LogMessageHandlerFunction log_message_handler = nullptr; +#if !defined(OS_TIZEN) // Helper functions to wrap platform differences. int32_t CurrentProcessId() { @@ -198,6 +204,7 @@ uint64_t TickCount() { return absolute_micro; #endif } +#endif void DeleteFilePath(const PathString& log_name) { #if defined(OS_WIN) @@ -775,15 +782,52 @@ LogMessage::~LogMessage() { break; } __android_log_write(priority, "chromium", str_newline.c_str()); -#endif +#elif defined(OS_TIZEN) + log_priority priority = DLOG_UNKNOWN; + switch (severity_) { + case LOG_INFO: + priority = DLOG_INFO; + break; + case LOG_WARNING: + priority = DLOG_WARN; + break; + case LOG_ERROR: + priority = DLOG_ERROR; + break; + case LOG_FATAL: + priority = DLOG_FATAL; + break; + } + dlog_print(priority, LOG_TAG, "%s", str_newline.c_str()); +#else ignore_result(fwrite(str_newline.data(), str_newline.size(), 1, stderr)); fflush(stderr); +#endif } else if (severity_ >= kAlwaysPrintErrorLevel) { // When we're only outputting to a log file, above a certain log level, we // should still output to stderr so that we can better detect and diagnose // problems with unit tests, especially on the buildbots. +#if defined(OS_TIZEN) + log_priority priority = DLOG_UNKNOWN; + switch (severity_) { + case LOG_INFO: + priority = DLOG_INFO; + break; + case LOG_WARNING: + priority = DLOG_WARN; + break; + case LOG_ERROR: + priority = DLOG_ERROR; + break; + case LOG_FATAL: + priority = DLOG_FATAL; + break; + } + dlog_print(priority, LOG_TAG, "%s", str_newline.c_str()); +#else ignore_result(fwrite(str_newline.data(), str_newline.size(), 1, stderr)); fflush(stderr); +#endif } // write to log file @@ -867,6 +911,7 @@ void LogMessage::Init(const char* file, int line) { // TODO(darin): It might be nice if the columns were fixed width. stream_ << '['; +#if !defined(OS_TIZEN) if (g_log_process_id) stream_ << CurrentProcessId() << ':'; if (g_log_thread_id) @@ -906,6 +951,7 @@ void LogMessage::Init(const char* file, int line) { } if (g_log_tickcount) stream_ << TickCount() << ':'; +#endif if (severity_ >= 0) stream_ << log_severity_name(severity_); else diff --git a/v8/BUILD.gn b/v8/BUILD.gn index 86d915c..0378e72 100644 --- a/v8/BUILD.gn +++ b/v8/BUILD.gn @@ -2731,6 +2731,9 @@ v8_component("v8_libbase") { "dl", "rt", ] + if (is_tizen) { + libs += [ "dlog" ] + } } else if (current_os == "aix") { sources += [ "src/base/debug/stack_trace_posix.cc", diff --git a/v8/src/base/platform/platform-posix.cc b/v8/src/base/platform/platform-posix.cc index fee6758..052ddce 100644 --- a/v8/src/base/platform/platform-posix.cc +++ b/v8/src/base/platform/platform-posix.cc @@ -31,6 +31,11 @@ #include // NOLINT #endif +#if defined(OS_TIZEN) +#define JS_LOG_TAG "V8" +#include +#endif + #include #include @@ -582,6 +587,8 @@ void OS::Print(const char* format, ...) { void OS::VPrint(const char* format, va_list args) { #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args); +#elif defined(OS_TIZEN) + dlog_vprint(DLOG_INFO, JS_LOG_TAG, format, args); #else vprintf(format, args); #endif @@ -599,6 +606,8 @@ void OS::FPrint(FILE* out, const char* format, ...) { void OS::VFPrint(FILE* out, const char* format, va_list args) { #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, format, args); +#elif defined(OS_TIZEN) + dlog_vprint(DLOG_INFO, JS_LOG_TAG, format, args); #else vfprintf(out, format, args); #endif @@ -616,6 +625,8 @@ void OS::PrintError(const char* format, ...) { void OS::VPrintError(const char* format, va_list args) { #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, format, args); +#elif defined(OS_TIZEN) + dlog_vprint(DLOG_ERROR, JS_LOG_TAG, format, args); #else vfprintf(stderr, format, args); #endif -- 2.7.4