mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
[build] Remove last platform -> vm and bin -> vm dependencies. Fix some ODR violations.
Change some static_libraries to source_sets to make ODR violations link-time errors. This is needed to enable (stop suppressing) -fvisibility=hidden in Fuchsia product builds. Change-Id: I699cec8d4b516beab9cebf9db0a522a7ff99e004 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99822 Reviewed-by: Zach Anderson <zra@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
3aef424c9c
commit
971f4845d7
|
@ -31,7 +31,7 @@ template("build_libdart_builtin") {
|
|||
if (defined(invoker.extra_configs)) {
|
||||
extra_configs += invoker.extra_configs
|
||||
}
|
||||
static_library(target_name) {
|
||||
source_set(target_name) {
|
||||
configs += [
|
||||
"..:dart_arch_config",
|
||||
"..:dart_config",
|
||||
|
@ -51,13 +51,7 @@ template("build_libdart_builtin") {
|
|||
"*_test.cc",
|
||||
"*_test.h",
|
||||
])
|
||||
sources = [
|
||||
"log_android.cc",
|
||||
"log_fuchsia.cc",
|
||||
"log_linux.cc",
|
||||
"log_macos.cc",
|
||||
"log_win.cc",
|
||||
] + builtin_impl_sources
|
||||
sources = builtin_impl_sources
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +149,6 @@ template("build_gen_snapshot") {
|
|||
|
||||
# Very limited native resolver provided.
|
||||
"$target_gen_dir/abi_version.cc",
|
||||
"builtin_common.cc",
|
||||
"builtin_gen_snapshot.cc",
|
||||
"dfe.cc",
|
||||
"dfe.h",
|
||||
|
@ -278,9 +271,6 @@ template("build_gen_snapshot_dart_io") {
|
|||
custom_sources_filter = [
|
||||
"*_test.cc",
|
||||
"*_test.h",
|
||||
"builtin.cc",
|
||||
"builtin_common.cc",
|
||||
"builtin_gen_snapshot.cc",
|
||||
]
|
||||
if (!is_mac && !is_ios) {
|
||||
# Dart tree uses *_macos.* instead of *_mac.*
|
||||
|
@ -293,7 +283,7 @@ template("build_gen_snapshot_dart_io") {
|
|||
|
||||
defines = [ "DART_IO_SECURE_SOCKET_DISABLED" ]
|
||||
|
||||
sources = io_impl_sources + builtin_impl_sources + cli_impl_sources
|
||||
sources = io_impl_sources + cli_impl_sources
|
||||
sources += [
|
||||
"io_natives.cc",
|
||||
"io_natives.h",
|
||||
|
@ -392,16 +382,11 @@ template("dart_io") {
|
|||
]
|
||||
}
|
||||
|
||||
sources = io_impl_sources + builtin_impl_sources + cli_impl_sources
|
||||
sources = io_impl_sources + cli_impl_sources
|
||||
sources += [
|
||||
"builtin_natives.cc",
|
||||
"io_natives.cc",
|
||||
"io_natives.h",
|
||||
"log_android.cc",
|
||||
"log_linux.cc",
|
||||
"log_macos.cc",
|
||||
"log_win.cc",
|
||||
"log.h",
|
||||
] + extra_sources
|
||||
|
||||
if (is_linux || is_win || is_fuchsia) {
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#endif
|
||||
|
||||
#include "bin/error_exit.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/platform.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -66,7 +66,7 @@ void InitializeCrashpadClient() {
|
|||
SetStdHandle(STD_ERROR_HANDLE, original_stderr);
|
||||
|
||||
if (!success) {
|
||||
Log::PrintErr("Failed to start the crash handler!\n");
|
||||
Syslog::PrintErr("Failed to start the crash handler!\n");
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
crashpad::CrashpadInfo::GetCrashpadInfo()
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "bin/utils.h"
|
||||
#include "include/dart_tools_api.h"
|
||||
#include "platform/utils.h"
|
||||
#include "vm/os.h"
|
||||
|
||||
extern "C" {
|
||||
#if !defined(EXCLUDE_CFE_AND_KERNEL_PLATFORM)
|
||||
|
@ -137,23 +136,22 @@ bool DFE::InitKernelServiceAndPlatformDills(int target_abi_version) {
|
|||
|
||||
// Look in the old abi version directory.
|
||||
char* script_uri =
|
||||
OS::SCreate(NULL, "%s%s/%d/%s", dir_prefix.get(), kAbiVersionsDir,
|
||||
target_abi_version, kPlatformStrongDillFile);
|
||||
Utils::SCreate("%s%s/%d/%s", dir_prefix.get(), kAbiVersionsDir,
|
||||
target_abi_version, kPlatformStrongDillFile);
|
||||
if (!TryReadKernelFile(script_uri,
|
||||
const_cast<uint8_t**>(&platform_strong_dill_),
|
||||
&platform_strong_dill_size_)) {
|
||||
Log::PrintErr("Can't find old ABI dill file: %s\n", script_uri);
|
||||
Syslog::PrintErr("Can't find old ABI dill file: %s\n", script_uri);
|
||||
free(script_uri);
|
||||
return false;
|
||||
}
|
||||
free(script_uri);
|
||||
script_uri =
|
||||
OS::SCreate(NULL, "%s%s/%d/%s", dir_prefix.get(), kAbiVersionsDir,
|
||||
target_abi_version, kKernelServiceDillFile);
|
||||
script_uri = Utils::SCreate("%s%s/%d/%s", dir_prefix.get(), kAbiVersionsDir,
|
||||
target_abi_version, kKernelServiceDillFile);
|
||||
if (!TryReadKernelFile(script_uri,
|
||||
const_cast<uint8_t**>(&kernel_service_dill_),
|
||||
&kernel_service_dill_size_)) {
|
||||
Log::PrintErr("Can't find old ABI dill file: %s\n", script_uri);
|
||||
Syslog::PrintErr("Can't find old ABI dill file: %s\n", script_uri);
|
||||
free(script_uri);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -164,7 +162,7 @@ bool DFE::InitKernelServiceAndPlatformDills(int target_abi_version) {
|
|||
|
||||
// Look for the frontend snapshot next to the executable.
|
||||
frontend_filename_ =
|
||||
OS::SCreate(NULL, "%s%s", dir_prefix.get(), kKernelServiceSnapshot);
|
||||
Utils::SCreate("%s%s", dir_prefix.get(), kKernelServiceSnapshot);
|
||||
if (File::Exists(NULL, frontend_filename_)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -174,8 +172,8 @@ bool DFE::InitKernelServiceAndPlatformDills(int target_abi_version) {
|
|||
// If the frontend snapshot is not found next to the executable, then look for
|
||||
// it in the "snapshots" directory.
|
||||
frontend_filename_ =
|
||||
OS::SCreate(NULL, "%s%s%s%s", dir_prefix.get(), kSnapshotsDirectory,
|
||||
File::PathSeparator(), kKernelServiceSnapshot);
|
||||
Utils::SCreate("%s%s%s%s", dir_prefix.get(), kSnapshotsDirectory,
|
||||
File::PathSeparator(), kKernelServiceSnapshot);
|
||||
if (File::Exists(NULL, frontend_filename_)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/io_buffer.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "bin/typed_data_utils.h"
|
||||
#include "bin/utils.h"
|
||||
#include "include/dart_api.h"
|
||||
#include "platform/assert.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "bin/utils.h"
|
||||
#include "bin/utils_win.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#undef DeleteFile
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
#include "bin/error_exit.h"
|
||||
|
||||
#include "bin/eventhandler.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/platform.h"
|
||||
#include "bin/process.h"
|
||||
#include "include/dart_api.h"
|
||||
#include "platform/assert.h"
|
||||
#include "platform/globals.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -18,7 +18,7 @@ namespace bin {
|
|||
void ErrorExit(int exit_code, const char* format, ...) {
|
||||
va_list arguments;
|
||||
va_start(arguments, format);
|
||||
Log::VPrintErr(format, arguments);
|
||||
Syslog::VPrintErr(format, arguments);
|
||||
va_end(arguments);
|
||||
|
||||
Dart_ShutdownIsolate();
|
||||
|
@ -28,7 +28,7 @@ void ErrorExit(int exit_code, const char* format, ...) {
|
|||
|
||||
char* error = Dart_Cleanup();
|
||||
if (error != NULL) {
|
||||
Log::PrintErr("VM cleanup failed: %s\n", error);
|
||||
Syslog::PrintErr("VM cleanup failed: %s\n", error);
|
||||
free(error);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
#include "bin/dartutils.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/socket.h"
|
||||
#include "bin/thread.h"
|
||||
#include "bin/utils.h"
|
||||
#include "platform/hashmap.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
// Android doesn't define EPOLLRDHUP.
|
||||
|
@ -269,33 +269,33 @@ void EventHandlerImplementation::HandleInterruptFd() {
|
|||
|
||||
#ifdef DEBUG_POLL
|
||||
static void PrintEventMask(intptr_t fd, intptr_t events) {
|
||||
Log::Print("%d ", fd);
|
||||
Syslog::Print("%d ", fd);
|
||||
if ((events & EPOLLIN) != 0) {
|
||||
Log::Print("EPOLLIN ");
|
||||
Syslog::Print("EPOLLIN ");
|
||||
}
|
||||
if ((events & EPOLLPRI) != 0) {
|
||||
Log::Print("EPOLLPRI ");
|
||||
Syslog::Print("EPOLLPRI ");
|
||||
}
|
||||
if ((events & EPOLLOUT) != 0) {
|
||||
Log::Print("EPOLLOUT ");
|
||||
Syslog::Print("EPOLLOUT ");
|
||||
}
|
||||
if ((events & EPOLLERR) != 0) {
|
||||
Log::Print("EPOLLERR ");
|
||||
Syslog::Print("EPOLLERR ");
|
||||
}
|
||||
if ((events & EPOLLHUP) != 0) {
|
||||
Log::Print("EPOLLHUP ");
|
||||
Syslog::Print("EPOLLHUP ");
|
||||
}
|
||||
if ((events & EPOLLRDHUP) != 0) {
|
||||
Log::Print("EPOLLRDHUP ");
|
||||
Syslog::Print("EPOLLRDHUP ");
|
||||
}
|
||||
int all_events =
|
||||
EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDHUP;
|
||||
if ((events & ~all_events) != 0) {
|
||||
Log::Print("(and %08x) ", events & ~all_events);
|
||||
Syslog::Print("(and %08x) ", events & ~all_events);
|
||||
}
|
||||
Log::Print("(available %d) ", FDUtils::AvailableBytes(fd));
|
||||
Syslog::Print("(available %d) ", FDUtils::AvailableBytes(fd));
|
||||
|
||||
Log::Print("\n");
|
||||
Syslog::Print("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/socket.h"
|
||||
#include "bin/thread.h"
|
||||
#include "bin/utils.h"
|
||||
#include "platform/hashmap.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
// The EventHandler for Fuchsia uses its "ports v2" API:
|
||||
|
@ -56,14 +56,14 @@
|
|||
#define LOG_ERR(msg, ...) \
|
||||
{ \
|
||||
int err = errno; \
|
||||
Log::PrintErr("Dart EventHandler ERROR: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
Syslog::PrintErr("Dart EventHandler ERROR: %s:%d: " msg, __FILE__, \
|
||||
__LINE__, ##__VA_ARGS__); \
|
||||
errno = err; \
|
||||
}
|
||||
#if defined(EVENTHANDLER_LOG_INFO)
|
||||
#define LOG_INFO(msg, ...) \
|
||||
Log::Print("Dart EventHandler INFO: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__)
|
||||
Syslog::Print("Dart EventHandler INFO: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__)
|
||||
#else
|
||||
#define LOG_INFO(msg, ...)
|
||||
#endif // defined(EVENTHANDLER_LOG_INFO)
|
||||
|
|
|
@ -21,9 +21,9 @@
|
|||
#include "bin/dartutils.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/socket.h"
|
||||
#include "bin/thread.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
namespace dart {
|
||||
|
@ -290,33 +290,33 @@ void EventHandlerImplementation::UpdateTimerFd() {
|
|||
|
||||
#ifdef DEBUG_POLL
|
||||
static void PrintEventMask(intptr_t fd, intptr_t events) {
|
||||
Log::Print("%d ", fd);
|
||||
Syslog::Print("%d ", fd);
|
||||
if ((events & EPOLLIN) != 0) {
|
||||
Log::Print("EPOLLIN ");
|
||||
Syslog::Print("EPOLLIN ");
|
||||
}
|
||||
if ((events & EPOLLPRI) != 0) {
|
||||
Log::Print("EPOLLPRI ");
|
||||
Syslog::Print("EPOLLPRI ");
|
||||
}
|
||||
if ((events & EPOLLOUT) != 0) {
|
||||
Log::Print("EPOLLOUT ");
|
||||
Syslog::Print("EPOLLOUT ");
|
||||
}
|
||||
if ((events & EPOLLERR) != 0) {
|
||||
Log::Print("EPOLLERR ");
|
||||
Syslog::Print("EPOLLERR ");
|
||||
}
|
||||
if ((events & EPOLLHUP) != 0) {
|
||||
Log::Print("EPOLLHUP ");
|
||||
Syslog::Print("EPOLLHUP ");
|
||||
}
|
||||
if ((events & EPOLLRDHUP) != 0) {
|
||||
Log::Print("EPOLLRDHUP ");
|
||||
Syslog::Print("EPOLLRDHUP ");
|
||||
}
|
||||
int all_events =
|
||||
EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDHUP;
|
||||
if ((events & ~all_events) != 0) {
|
||||
Log::Print("(and %08x) ", events & ~all_events);
|
||||
Syslog::Print("(and %08x) ", events & ~all_events);
|
||||
}
|
||||
Log::Print("(available %d) ", FDUtils::AvailableBytes(fd));
|
||||
Syslog::Print("(available %d) ", FDUtils::AvailableBytes(fd));
|
||||
|
||||
Log::Print("\n");
|
||||
Syslog::Print("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#include "bin/dartutils.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/socket.h"
|
||||
#include "bin/thread.h"
|
||||
#include "bin/utils.h"
|
||||
#include "platform/hashmap.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
namespace dart {
|
||||
|
@ -284,37 +284,38 @@ void EventHandlerImplementation::HandleInterruptFd() {
|
|||
|
||||
#ifdef DEBUG_KQUEUE
|
||||
static void PrintEventMask(intptr_t fd, struct kevent* event) {
|
||||
Log::Print("%d ", static_cast<int>(fd));
|
||||
Syslog::Print("%d ", static_cast<int>(fd));
|
||||
|
||||
Log::Print("filter=0x%x:", event->filter);
|
||||
Syslog::Print("filter=0x%x:", event->filter);
|
||||
if (event->filter == EVFILT_READ) {
|
||||
Log::Print("EVFILT_READ ");
|
||||
Syslog::Print("EVFILT_READ ");
|
||||
}
|
||||
if (event->filter == EVFILT_WRITE) {
|
||||
Log::Print("EVFILT_WRITE ");
|
||||
Syslog::Print("EVFILT_WRITE ");
|
||||
}
|
||||
|
||||
Log::Print("flags: %x: ", event->flags);
|
||||
Syslog::Print("flags: %x: ", event->flags);
|
||||
if ((event->flags & EV_EOF) != 0) {
|
||||
Log::Print("EV_EOF ");
|
||||
Syslog::Print("EV_EOF ");
|
||||
}
|
||||
if ((event->flags & EV_ERROR) != 0) {
|
||||
Log::Print("EV_ERROR ");
|
||||
Syslog::Print("EV_ERROR ");
|
||||
}
|
||||
if ((event->flags & EV_CLEAR) != 0) {
|
||||
Log::Print("EV_CLEAR ");
|
||||
Syslog::Print("EV_CLEAR ");
|
||||
}
|
||||
if ((event->flags & EV_ADD) != 0) {
|
||||
Log::Print("EV_ADD ");
|
||||
Syslog::Print("EV_ADD ");
|
||||
}
|
||||
if ((event->flags & EV_DELETE) != 0) {
|
||||
Log::Print("EV_DELETE ");
|
||||
Syslog::Print("EV_DELETE ");
|
||||
}
|
||||
|
||||
Log::Print("- fflags: %d ", event->fflags);
|
||||
Log::Print("- data: %ld ", event->data);
|
||||
Log::Print("(available %d) ", static_cast<int>(FDUtils::AvailableBytes(fd)));
|
||||
Log::Print("\n");
|
||||
Syslog::Print("- fflags: %d ", event->fflags);
|
||||
Syslog::Print("- data: %ld ", event->data);
|
||||
Syslog::Print("(available %d) ",
|
||||
static_cast<int>(FDUtils::AvailableBytes(fd)));
|
||||
Syslog::Print("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#include "bin/builtin.h"
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/socket.h"
|
||||
#include "bin/thread.h"
|
||||
#include "bin/utils.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include "platform/utils.h"
|
||||
|
||||
|
@ -1420,7 +1420,7 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
|
|||
if (!ok && (overlapped == NULL)) {
|
||||
if (GetLastError() == ERROR_ABANDONED_WAIT_0) {
|
||||
// The completion port should never be closed.
|
||||
Log::Print("Completion port closed\n");
|
||||
Syslog::Print("Completion port closed\n");
|
||||
UNREACHABLE();
|
||||
} else {
|
||||
// Timeout is signalled by false result and NULL in overlapped.
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "bin/reference_counting.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
namespace dart {
|
||||
|
@ -62,7 +62,7 @@ void File::Close() {
|
|||
if (err != 0) {
|
||||
const int kBufferSize = 1024;
|
||||
char error_buf[kBufferSize];
|
||||
Log::PrintErr("%s\n", Utils::StrError(errno, error_buf, kBufferSize));
|
||||
Syslog::PrintErr("%s\n", Utils::StrError(errno, error_buf, kBufferSize));
|
||||
}
|
||||
}
|
||||
handle_->set_fd(kClosedFd);
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
namespace dart {
|
||||
|
@ -61,7 +61,7 @@ void File::Close() {
|
|||
if (err != 0) {
|
||||
const int kBufferSize = 1024;
|
||||
char error_buf[kBufferSize];
|
||||
Log::PrintErr("%s\n", Utils::StrError(errno, error_buf, kBufferSize));
|
||||
Syslog::PrintErr("%s\n", Utils::StrError(errno, error_buf, kBufferSize));
|
||||
}
|
||||
}
|
||||
handle_->set_fd(kClosedFd);
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
namespace dart {
|
||||
|
@ -61,7 +61,7 @@ void File::Close() {
|
|||
if (err != 0) {
|
||||
const int kBufferSize = 1024;
|
||||
char error_buf[kBufferSize];
|
||||
Log::PrintErr("%s\n", Utils::StrError(errno, error_buf, kBufferSize));
|
||||
Syslog::PrintErr("%s\n", Utils::StrError(errno, error_buf, kBufferSize));
|
||||
}
|
||||
}
|
||||
handle_->set_fd(kClosedFd);
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
namespace dart {
|
||||
|
@ -62,7 +62,7 @@ void File::Close() {
|
|||
const int kBufferSize = 1024;
|
||||
char error_message[kBufferSize];
|
||||
Utils::StrError(errno, error_message, kBufferSize);
|
||||
Log::PrintErr("%s\n", error_message);
|
||||
Syslog::PrintErr("%s\n", error_message);
|
||||
}
|
||||
}
|
||||
handle_->set_fd(kClosedFd);
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/eventhandler.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/utils.h"
|
||||
#include "bin/utils_win.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/directory.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "bin/utils.h"
|
||||
#include "bin/utils_win.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
namespace dart {
|
||||
|
@ -59,7 +59,7 @@ void File::Close() {
|
|||
} else {
|
||||
int err = close(closing_fd);
|
||||
if (err != 0) {
|
||||
Log::PrintErr("%s\n", strerror(errno));
|
||||
Syslog::PrintErr("%s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
handle_->set_fd(kClosedFd);
|
||||
|
@ -91,13 +91,13 @@ MappedMemory* File::Map(File::MapType type, int64_t position, int64_t length) {
|
|||
|
||||
void* addr = VirtualAlloc(NULL, length, MEM_COMMIT | MEM_RESERVE, prot_alloc);
|
||||
if (addr == NULL) {
|
||||
Log::PrintErr("VirtualAlloc failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("VirtualAlloc failed %d\n", GetLastError());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SetPosition(position);
|
||||
if (!ReadFully(addr, length)) {
|
||||
Log::PrintErr("ReadFully failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("ReadFully failed %d\n", GetLastError());
|
||||
VirtualFree(addr, 0, MEM_RELEASE);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ MappedMemory* File::Map(File::MapType type, int64_t position, int64_t length) {
|
|||
DWORD old_prot;
|
||||
bool result = VirtualProtect(addr, length, prot_final, &old_prot);
|
||||
if (!result) {
|
||||
Log::PrintErr("VirtualProtect failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("VirtualProtect failed %d\n", GetLastError());
|
||||
VirtualFree(addr, 0, MEM_RELEASE);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
#include "bin/eventhandler.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/loader.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/options.h"
|
||||
#include "bin/platform.h"
|
||||
#include "bin/snapshot_utils.h"
|
||||
#include "bin/thread.h"
|
||||
#include "bin/utils.h"
|
||||
#include "bin/vmservice_impl.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include "include/dart_api.h"
|
||||
#include "include/dart_tools_api.h"
|
||||
|
@ -46,7 +46,7 @@ static const int kErrorExitCode = 255;
|
|||
#define CHECK_RESULT(result) \
|
||||
if (Dart_IsError(result)) { \
|
||||
intptr_t exit_code = 0; \
|
||||
Log::PrintErr("Error: %s\n", Dart_GetError(result)); \
|
||||
Syslog::PrintErr("Error: %s\n", Dart_GetError(result)); \
|
||||
if (Dart_IsCompilationError(result)) { \
|
||||
exit_code = kCompilationErrorExitCode; \
|
||||
} else if (Dart_IsApiError(result)) { \
|
||||
|
@ -152,7 +152,7 @@ static bool IsSnapshottingForPrecompilation() {
|
|||
|
||||
// clang-format off
|
||||
static void PrintUsage() {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Usage: gen_snapshot [<vm-flags>] [<options>] <dart-kernel-file> \n"
|
||||
" \n"
|
||||
"Common options: \n"
|
||||
|
@ -194,7 +194,7 @@ static void PrintUsage() {
|
|||
" \n"
|
||||
"\n");
|
||||
if (verbose) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"The following options are only used for VM development and may\n"
|
||||
"be changed in any future version:\n");
|
||||
const char* print_flags = "--print_flags";
|
||||
|
@ -237,13 +237,13 @@ static int ParseArguments(int argc,
|
|||
PrintUsage();
|
||||
Platform::Exit(0);
|
||||
} else if (version) {
|
||||
Log::PrintErr("Dart VM version: %s\n", Dart_VersionString());
|
||||
Syslog::PrintErr("Dart VM version: %s\n", Dart_VersionString());
|
||||
Platform::Exit(0);
|
||||
}
|
||||
|
||||
// Verify consistency of arguments.
|
||||
if (inputs->count() < 1) {
|
||||
Log::PrintErr("At least one input is required\n");
|
||||
Syslog::PrintErr("At least one input is required\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ static int ParseArguments(int argc,
|
|||
case kCore: {
|
||||
if ((vm_snapshot_data_filename == NULL) ||
|
||||
(isolate_snapshot_data_filename == NULL)) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Building a core snapshot requires specifying output files for "
|
||||
"--vm_snapshot_data and --isolate_snapshot_data.\n\n");
|
||||
return -1;
|
||||
|
@ -263,7 +263,7 @@ static int ParseArguments(int argc,
|
|||
(vm_snapshot_instructions_filename == NULL) ||
|
||||
(isolate_snapshot_data_filename == NULL) ||
|
||||
(isolate_snapshot_instructions_filename == NULL)) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Building a core JIT snapshot requires specifying output "
|
||||
"files for --vm_snapshot_data, --vm_snapshot_instructions, "
|
||||
"--isolate_snapshot_data and --isolate_snapshot_instructions.\n\n");
|
||||
|
@ -277,7 +277,7 @@ static int ParseArguments(int argc,
|
|||
(isolate_snapshot_data_filename == NULL) ||
|
||||
((isolate_snapshot_instructions_filename == NULL) &&
|
||||
(reused_instructions_filename == NULL))) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Building an app JIT snapshot requires specifying input files for "
|
||||
"--load_vm_snapshot_data and --load_vm_snapshot_instructions, an "
|
||||
" output file for --isolate_snapshot_data, and either an output "
|
||||
|
@ -293,7 +293,7 @@ static int ParseArguments(int argc,
|
|||
(vm_snapshot_instructions_filename == NULL) ||
|
||||
(isolate_snapshot_data_filename == NULL) ||
|
||||
(isolate_snapshot_instructions_filename == NULL))) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Building an AOT snapshot as blobs requires specifying output "
|
||||
"file for --blobs_container_filename or "
|
||||
"files for --vm_snapshot_data, --vm_snapshot_instructions, "
|
||||
|
@ -305,7 +305,7 @@ static int ParseArguments(int argc,
|
|||
(vm_snapshot_instructions_filename != NULL) ||
|
||||
(isolate_snapshot_data_filename != NULL) ||
|
||||
(isolate_snapshot_instructions_filename != NULL))) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Building an AOT snapshot as blobs requires specifying output "
|
||||
"file for --blobs_container_filename or "
|
||||
"files for --vm_snapshot_data, --vm_snapshot_instructions, "
|
||||
|
@ -317,7 +317,7 @@ static int ParseArguments(int argc,
|
|||
}
|
||||
case kAppAOTAssembly: {
|
||||
if (assembly_filename == NULL) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Building an AOT snapshot as assembly requires specifying "
|
||||
"an output file for --assembly.\n\n");
|
||||
return -1;
|
||||
|
@ -326,7 +326,7 @@ static int ParseArguments(int argc,
|
|||
}
|
||||
case kVMAOTAssembly: {
|
||||
if (assembly_filename == NULL) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Building an AOT snapshot as assembly requires specifying "
|
||||
"an output file for --assembly.\n\n");
|
||||
return -1;
|
||||
|
@ -336,14 +336,14 @@ static int ParseArguments(int argc,
|
|||
}
|
||||
|
||||
if (!obfuscate && obfuscation_map_filename != NULL) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"--obfuscation_map=<...> should only be specified when obfuscation is "
|
||||
"enabled by --obfuscate flag.\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (obfuscate && !IsSnapshottingForPrecompilation()) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Obfuscation can only be enabled when building AOT snapshot.\n\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ static int ParseArguments(int argc,
|
|||
static File* OpenFile(const char* filename) {
|
||||
File* file = File::Open(NULL, filename, File::kWriteTruncate);
|
||||
if (file == NULL) {
|
||||
Log::PrintErr("Error: Unable to write file: %s\n\n", filename);
|
||||
Syslog::PrintErr("Error: Unable to write file: %s\n\n", filename);
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(kErrorExitCode);
|
||||
|
@ -368,7 +368,7 @@ static void WriteFile(const char* filename,
|
|||
File* file = OpenFile(filename);
|
||||
RefCntReleaseScope<File> rs(file);
|
||||
if (!file->WriteFully(buffer, size)) {
|
||||
Log::PrintErr("Error: Unable to write file: %s\n\n", filename);
|
||||
Syslog::PrintErr("Error: Unable to write file: %s\n\n", filename);
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(kErrorExitCode);
|
||||
|
@ -378,7 +378,7 @@ static void WriteFile(const char* filename,
|
|||
static void ReadFile(const char* filename, uint8_t** buffer, intptr_t* size) {
|
||||
File* file = File::Open(NULL, filename, File::kRead);
|
||||
if (file == NULL) {
|
||||
Log::PrintErr("Unable to open file %s\n", filename);
|
||||
Syslog::PrintErr("Unable to open file %s\n", filename);
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(kErrorExitCode);
|
||||
|
@ -387,7 +387,7 @@ static void ReadFile(const char* filename, uint8_t** buffer, intptr_t* size) {
|
|||
*size = file->Length();
|
||||
*buffer = reinterpret_cast<uint8_t*>(malloc(*size));
|
||||
if (!file->ReadFully(*buffer, *size)) {
|
||||
Log::PrintErr("Unable to read file %s\n", filename);
|
||||
Syslog::PrintErr("Unable to read file %s\n", filename);
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(kErrorExitCode);
|
||||
|
@ -479,7 +479,7 @@ static std::unique_ptr<MappedMemory> MapFile(const char* filename,
|
|||
const uint8_t** buffer) {
|
||||
File* file = File::Open(NULL, filename, File::kRead);
|
||||
if (file == NULL) {
|
||||
Log::PrintErr("Failed to open: %s\n", filename);
|
||||
Syslog::PrintErr("Failed to open: %s\n", filename);
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
RefCntReleaseScope<File> rs(file);
|
||||
|
@ -491,7 +491,7 @@ static std::unique_ptr<MappedMemory> MapFile(const char* filename,
|
|||
}
|
||||
MappedMemory* mapping = file->Map(type, 0, length);
|
||||
if (mapping == NULL) {
|
||||
Log::PrintErr("Failed to read: %s\n", filename);
|
||||
Syslog::PrintErr("Failed to read: %s\n", filename);
|
||||
exit(kErrorExitCode);
|
||||
}
|
||||
*buffer = reinterpret_cast<const uint8_t*>(mapping->address());
|
||||
|
@ -597,7 +597,7 @@ static void StreamingWriteCallback(void* callback_data,
|
|||
intptr_t size) {
|
||||
File* file = reinterpret_cast<File*>(callback_data);
|
||||
if (!file->WriteFully(buffer, size)) {
|
||||
Log::PrintErr("Error: Unable to write snapshot file\n\n");
|
||||
Syslog::PrintErr("Error: Unable to write snapshot file\n\n");
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(kErrorExitCode);
|
||||
|
@ -629,10 +629,10 @@ static void CreateAndWritePrecompiledSnapshot() {
|
|||
std::unique_ptr<MappedMemory> mapped_shared_instructions;
|
||||
if (shared_blobs_filename != NULL) {
|
||||
AppSnapshot* shared_blobs = NULL;
|
||||
Log::PrintErr("Shared blobs in gen_snapshot are for testing only.\n");
|
||||
Syslog::PrintErr("Shared blobs in gen_snapshot are for testing only.\n");
|
||||
shared_blobs = Snapshot::TryReadAppSnapshot(shared_blobs_filename);
|
||||
if (shared_blobs == NULL) {
|
||||
Log::PrintErr("Failed to load: %s\n", shared_blobs_filename);
|
||||
Syslog::PrintErr("Failed to load: %s\n", shared_blobs_filename);
|
||||
Dart_ExitScope();
|
||||
Dart_ShutdownIsolate();
|
||||
exit(kErrorExitCode);
|
||||
|
@ -732,7 +732,7 @@ static int CreateIsolateAndSnapshot(const CommandLineOptions& inputs) {
|
|||
}
|
||||
if (isolate == NULL) {
|
||||
delete isolate_data;
|
||||
Log::PrintErr("%s\n", error);
|
||||
Syslog::PrintErr("%s\n", error);
|
||||
free(error);
|
||||
return kErrorExitCode;
|
||||
}
|
||||
|
@ -821,7 +821,7 @@ int main(int argc, char** argv) {
|
|||
DartUtils::SetEnvironment(environment);
|
||||
|
||||
if (!Platform::Initialize()) {
|
||||
Log::PrintErr("Initialization failed\n");
|
||||
Syslog::PrintErr("Initialization failed\n");
|
||||
return kErrorExitCode;
|
||||
}
|
||||
Console::SaveConfig();
|
||||
|
@ -847,7 +847,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
char* error = Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
|
||||
if (error != NULL) {
|
||||
Log::PrintErr("Setting VM flags failed: %s\n", error);
|
||||
Syslog::PrintErr("Setting VM flags failed: %s\n", error);
|
||||
free(error);
|
||||
return kErrorExitCode;
|
||||
}
|
||||
|
@ -889,7 +889,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
error = Dart_Initialize(&init_params);
|
||||
if (error != NULL) {
|
||||
Log::PrintErr("VM initialization failed: %s\n", error);
|
||||
Syslog::PrintErr("VM initialization failed: %s\n", error);
|
||||
free(error);
|
||||
return kErrorExitCode;
|
||||
}
|
||||
|
@ -901,7 +901,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
error = Dart_Cleanup();
|
||||
if (error != NULL) {
|
||||
Log::PrintErr("VM cleanup failed: %s\n", error);
|
||||
Syslog::PrintErr("VM cleanup failed: %s\n", error);
|
||||
free(error);
|
||||
}
|
||||
EventHandler::Stop();
|
||||
|
|
|
@ -292,7 +292,7 @@ void Loader::ResolveDependenciesAsFilePaths() {
|
|||
Dart_Handle result =
|
||||
Loader::ResolveAsFilePath(uri, &file_path, &file_path_length);
|
||||
if (Dart_IsError(result)) {
|
||||
Log::Print("Error resolving dependency: %s\n", Dart_GetError(result));
|
||||
Syslog::Print("Error resolving dependency: %s\n", Dart_GetError(result));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "bin/gzip.h"
|
||||
#include "bin/isolate_data.h"
|
||||
#include "bin/loader.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/main_options.h"
|
||||
#include "bin/platform.h"
|
||||
#include "bin/process.h"
|
||||
|
@ -37,6 +36,7 @@
|
|||
#include "platform/globals.h"
|
||||
#include "platform/growable_array.h"
|
||||
#include "platform/hashmap.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/text_buffer.h"
|
||||
|
||||
extern "C" {
|
||||
|
@ -186,7 +186,7 @@ static void WriteDepsFile(Dart_Isolate isolate) {
|
|||
|
||||
static void OnExitHook(int64_t exit_code) {
|
||||
if (Dart_CurrentIsolate() != main_isolate) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"A snapshot was requested, but a secondary isolate "
|
||||
"performed a hard exit (%" Pd64 ").\n",
|
||||
exit_code);
|
||||
|
@ -450,7 +450,7 @@ static Dart_Isolate CreateAndSetupKernelIsolate(const char* script_uri,
|
|||
}
|
||||
|
||||
if (isolate == NULL) {
|
||||
Log::PrintErr("%s\n", *error);
|
||||
Syslog::PrintErr("%s\n", *error);
|
||||
delete isolate_data;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -698,7 +698,7 @@ static void OnIsolateShutdown(void* callback_data) {
|
|||
|
||||
Dart_Handle sticky_error = Dart_GetStickyError();
|
||||
if (!Dart_IsNull(sticky_error) && !Dart_IsFatalError(sticky_error)) {
|
||||
Log::PrintErr("%s\n", Dart_GetError(sticky_error));
|
||||
Syslog::PrintErr("%s\n", Dart_GetError(sticky_error));
|
||||
}
|
||||
|
||||
IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data);
|
||||
|
@ -812,13 +812,13 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
|
|||
&exit_code);
|
||||
|
||||
if (isolate == NULL) {
|
||||
Log::PrintErr("%s\n", error);
|
||||
Syslog::PrintErr("%s\n", error);
|
||||
free(error);
|
||||
error = NULL;
|
||||
Process::TerminateExitCodeHandler();
|
||||
error = Dart_Cleanup();
|
||||
if (error != NULL) {
|
||||
Log::PrintErr("VM cleanup failed: %s\n", error);
|
||||
Syslog::PrintErr("VM cleanup failed: %s\n", error);
|
||||
free(error);
|
||||
}
|
||||
Process::ClearAllSignalHandlers();
|
||||
|
@ -838,7 +838,8 @@ bool RunMainIsolate(const char* script_name, CommandLineOptions* dart_options) {
|
|||
reinterpret_cast<IsolateData*>(Dart_IsolateData(isolate));
|
||||
if (Options::gen_snapshot_kind() == kKernel) {
|
||||
if (vm_run_app_snapshot) {
|
||||
Log::PrintErr("Cannot create a script snapshot from an app snapshot.\n");
|
||||
Syslog::PrintErr(
|
||||
"Cannot create a script snapshot from an app snapshot.\n");
|
||||
// The snapshot would contain references to the app snapshot instead of
|
||||
// the core snapshot.
|
||||
Platform::Exit(kErrorExitCode);
|
||||
|
@ -977,7 +978,7 @@ void main(int argc, char** argv) {
|
|||
|
||||
// Perform platform specific initialization.
|
||||
if (!Platform::Initialize()) {
|
||||
Log::PrintErr("Initialization failed\n");
|
||||
Syslog::PrintErr("Initialization failed\n");
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1019,7 @@ void main(int argc, char** argv) {
|
|||
// script was specified on the command line.
|
||||
char* error = Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
|
||||
if (error != NULL) {
|
||||
Log::PrintErr("Setting VM flags failed: %s\n", error);
|
||||
Syslog::PrintErr("Setting VM flags failed: %s\n", error);
|
||||
free(error);
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
|
@ -1047,11 +1048,13 @@ void main(int argc, char** argv) {
|
|||
#else
|
||||
AppSnapshot* shared_blobs = NULL;
|
||||
if (Options::shared_blobs_filename() != NULL) {
|
||||
Log::PrintErr("Shared blobs in the standalone VM are for testing only.\n");
|
||||
Syslog::PrintErr(
|
||||
"Shared blobs in the standalone VM are for testing only.\n");
|
||||
shared_blobs =
|
||||
Snapshot::TryReadAppSnapshot(Options::shared_blobs_filename());
|
||||
if (shared_blobs == NULL) {
|
||||
Log::PrintErr("Failed to load: %s\n", Options::shared_blobs_filename());
|
||||
Syslog::PrintErr("Failed to load: %s\n",
|
||||
Options::shared_blobs_filename());
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
const uint8_t* ignored;
|
||||
|
@ -1089,14 +1092,14 @@ void main(int argc, char** argv) {
|
|||
|
||||
char* error = nullptr;
|
||||
if (!dart::embedder::InitOnce(&error)) {
|
||||
Log::PrintErr("Stanalone embedder initialization failed: %s\n", error);
|
||||
Syslog::PrintErr("Stanalone embedder initialization failed: %s\n", error);
|
||||
free(error);
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
|
||||
error = Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
|
||||
if (error != NULL) {
|
||||
Log::PrintErr("Setting VM flags failed: %s\n", error);
|
||||
Syslog::PrintErr("Setting VM flags failed: %s\n", error);
|
||||
free(error);
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
|
@ -1142,7 +1145,7 @@ void main(int argc, char** argv) {
|
|||
error = Dart_Initialize(&init_params);
|
||||
if (error != NULL) {
|
||||
EventHandler::Stop();
|
||||
Log::PrintErr("VM initialization failed: %s\n", error);
|
||||
Syslog::PrintErr("VM initialization failed: %s\n", error);
|
||||
free(error);
|
||||
Platform::Exit(kErrorExitCode);
|
||||
}
|
||||
|
@ -1154,7 +1157,7 @@ void main(int argc, char** argv) {
|
|||
|
||||
// Run the main isolate until we aren't told to restart.
|
||||
while (RunMainIsolate(script_name, &dart_options)) {
|
||||
Log::PrintErr("Restarting VM\n");
|
||||
Syslog::PrintErr("Restarting VM\n");
|
||||
}
|
||||
|
||||
// Terminate process exit-code handler.
|
||||
|
@ -1162,7 +1165,7 @@ void main(int argc, char** argv) {
|
|||
|
||||
error = Dart_Cleanup();
|
||||
if (error != NULL) {
|
||||
Log::PrintErr("VM cleanup failed: %s\n", error);
|
||||
Syslog::PrintErr("VM cleanup failed: %s\n", error);
|
||||
free(error);
|
||||
}
|
||||
Process::ClearAllSignalHandlers();
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "bin/abi_version.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/options.h"
|
||||
#include "bin/platform.h"
|
||||
#include "platform/syslog.h"
|
||||
#if !defined(DART_IO_SECURE_SOCKET_DISABLED)
|
||||
#include "bin/security_context.h"
|
||||
#endif // !defined(DART_IO_SECURE_SOCKET_DISABLED)
|
||||
|
@ -114,19 +114,19 @@ DEFINE_BOOL_OPTION_CB(hot_reload_rollback_test_mode,
|
|||
hot_reload_rollback_test_mode_callback);
|
||||
|
||||
void Options::PrintVersion() {
|
||||
Log::PrintErr("Dart VM version: %s\n", Dart_VersionString());
|
||||
Syslog::PrintErr("Dart VM version: %s\n", Dart_VersionString());
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
void Options::PrintUsage() {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Usage: dart [<vm-flags>] <dart-script-file> [<script-arguments>]\n"
|
||||
"\n"
|
||||
"Executes the Dart script <dart-script-file> with "
|
||||
"the given list of <script-arguments>.\n"
|
||||
"\n");
|
||||
if (!Options::verbose_option()) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Common VM flags:\n"
|
||||
"--enable-asserts\n"
|
||||
" Enable assert statements.\n"
|
||||
|
@ -157,7 +157,7 @@ void Options::PrintUsage() {
|
|||
"--version\n"
|
||||
" Print the VM version.\n");
|
||||
} else {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Supported options:\n"
|
||||
"--enable-asserts\n"
|
||||
" Enable assert statements.\n"
|
||||
|
@ -288,7 +288,7 @@ bool Options::ProcessEnableVmServiceOption(const char* arg,
|
|||
if (!ExtractPortAndAddress(
|
||||
value, &vm_service_server_port_, &vm_service_server_ip_,
|
||||
DEFAULT_VM_SERVICE_SERVER_PORT, DEFAULT_VM_SERVICE_SERVER_IP)) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"unrecognized --enable-vm-service option syntax. "
|
||||
"Use --enable-vm-service[=<port number>[/<bind address>]]\n");
|
||||
return false;
|
||||
|
@ -309,7 +309,7 @@ bool Options::ProcessObserveOption(const char* arg,
|
|||
if (!ExtractPortAndAddress(
|
||||
value, &vm_service_server_port_, &vm_service_server_ip_,
|
||||
DEFAULT_VM_SERVICE_SERVER_PORT, DEFAULT_VM_SERVICE_SERVER_IP)) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"unrecognized --observe option syntax. "
|
||||
"Use --observe[=<port number>[/<bind address>]]\n");
|
||||
return false;
|
||||
|
@ -338,14 +338,15 @@ bool Options::ProcessAbiVersionOption(const char* arg,
|
|||
if (value[i] >= '0' && value[i] <= '9') {
|
||||
ver = (ver * 10) + value[i] - '0';
|
||||
} else {
|
||||
Log::PrintErr("--use_abi_version must be an int\n");
|
||||
Syslog::PrintErr("--use_abi_version must be an int\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (ver < AbiVersion::GetOldestSupported() ||
|
||||
ver > AbiVersion::GetCurrent()) {
|
||||
Log::PrintErr("--use_abi_version must be between %d and %d inclusive\n",
|
||||
AbiVersion::GetOldestSupported(), AbiVersion::GetCurrent());
|
||||
Syslog::PrintErr("--use_abi_version must be between %d and %d inclusive\n",
|
||||
AbiVersion::GetOldestSupported(),
|
||||
AbiVersion::GetCurrent());
|
||||
return false;
|
||||
}
|
||||
target_abi_version_ = ver;
|
||||
|
@ -438,7 +439,7 @@ int Options::ParseArguments(int argc,
|
|||
|
||||
// snapshot_depfile is an alias for depfile. Passing them both is an error.
|
||||
if ((snapshot_deps_filename_ != NULL) && (depfile_ != NULL)) {
|
||||
Log::PrintErr("Specify only one of --depfile and --snapshot_depfile\n");
|
||||
Syslog::PrintErr("Specify only one of --depfile and --snapshot_depfile\n");
|
||||
return -1;
|
||||
}
|
||||
if (snapshot_deps_filename_ != NULL) {
|
||||
|
@ -447,32 +448,34 @@ int Options::ParseArguments(int argc,
|
|||
}
|
||||
|
||||
if ((Options::package_root() != NULL) && (packages_file_ != NULL)) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Specifying both a packages directory and a packages "
|
||||
"file is invalid.\n");
|
||||
return -1;
|
||||
}
|
||||
if ((Options::package_root() != NULL) &&
|
||||
(strlen(Options::package_root()) == 0)) {
|
||||
Log::PrintErr("Empty package root specified.\n");
|
||||
Syslog::PrintErr("Empty package root specified.\n");
|
||||
return -1;
|
||||
}
|
||||
if ((packages_file_ != NULL) && (strlen(packages_file_) == 0)) {
|
||||
Log::PrintErr("Empty package file name specified.\n");
|
||||
Syslog::PrintErr("Empty package file name specified.\n");
|
||||
return -1;
|
||||
}
|
||||
if ((gen_snapshot_kind_ != kNone) && (snapshot_filename_ == NULL)) {
|
||||
Log::PrintErr("Generating a snapshot requires a filename (--snapshot).\n");
|
||||
Syslog::PrintErr(
|
||||
"Generating a snapshot requires a filename (--snapshot).\n");
|
||||
return -1;
|
||||
}
|
||||
if ((gen_snapshot_kind_ == kNone) && (depfile_ != NULL) &&
|
||||
(snapshot_filename_ == NULL) && (depfile_output_filename_ == NULL)) {
|
||||
Log::PrintErr("Generating a depfile requires an output filename"
|
||||
" (--depfile-output-filename or --snapshot).\n");
|
||||
Syslog::PrintErr(
|
||||
"Generating a depfile requires an output filename"
|
||||
" (--depfile-output-filename or --snapshot).\n");
|
||||
return -1;
|
||||
}
|
||||
if ((gen_snapshot_kind_ != kNone) && vm_run_app_snapshot) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Specifying an option to generate a snapshot and"
|
||||
" run using a snapshot is invalid.\n");
|
||||
return -1;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#include "bin/builtin.h"
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/reference_counting.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
|
|
@ -45,7 +45,7 @@ NamespaceImpl::~NamespaceImpl() {
|
|||
if (fdio_ns_ != NULL) {
|
||||
zx_status_t status = fdio_ns_destroy(fdio_ns_);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("fdio_ns_destroy: %s\n", zx_status_get_string(status));
|
||||
Syslog::PrintErr("fdio_ns_destroy: %s\n", zx_status_get_string(status));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,12 +69,12 @@ bool OptionProcessor::ProcessEnvironmentOption(
|
|||
const char* equals_pos = strchr(arg, '=');
|
||||
if (equals_pos == NULL) {
|
||||
// No equal sign (name without value) currently not supported.
|
||||
Log::PrintErr("No value given to -D option\n");
|
||||
Syslog::PrintErr("No value given to -D option\n");
|
||||
return true;
|
||||
}
|
||||
int name_len = equals_pos - arg;
|
||||
if (name_len == 0) {
|
||||
Log::PrintErr("No name given to -D option\n");
|
||||
Syslog::PrintErr("No name given to -D option\n");
|
||||
return true;
|
||||
}
|
||||
// Split name=value into name and value.
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#define RUNTIME_BIN_OPTIONS_H_
|
||||
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "platform/globals.h"
|
||||
#include "platform/hashmap.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -68,7 +68,7 @@ class CallbackOptionProcessor : public OptionProcessor {
|
|||
return false; \
|
||||
} \
|
||||
if (*value == '\0') { \
|
||||
Log::PrintErr("Empty value for option " #name "\n"); \
|
||||
Syslog::PrintErr("Empty value for option " #name "\n"); \
|
||||
return false; \
|
||||
} \
|
||||
callback; \
|
||||
|
@ -89,12 +89,12 @@ class CallbackOptionProcessor : public OptionProcessor {
|
|||
return true; \
|
||||
} \
|
||||
} \
|
||||
Log::PrintErr( \
|
||||
Syslog::PrintErr( \
|
||||
"Unrecognized value for " #name ": '%s'\nValid values are: ", value); \
|
||||
for (intptr_t i = 0; kNames[i] != NULL; i++) { \
|
||||
Log::PrintErr("%s%s", i > 0 ? ", " : "", kNames[i]); \
|
||||
Syslog::PrintErr("%s%s", i > 0 ? ", " : "", kNames[i]); \
|
||||
} \
|
||||
Log::PrintErr("\n"); \
|
||||
Syslog::PrintErr("\n"); \
|
||||
})
|
||||
|
||||
#define DEFINE_BOOL_OPTION_CB(name, callback) \
|
||||
|
@ -106,7 +106,7 @@ class CallbackOptionProcessor : public OptionProcessor {
|
|||
return false; \
|
||||
} \
|
||||
if (*value == '=') { \
|
||||
Log::PrintErr("Non-empty value for option " #name "\n"); \
|
||||
Syslog::PrintErr("Non-empty value for option " #name "\n"); \
|
||||
return false; \
|
||||
} \
|
||||
if (*value != '\0') { \
|
||||
|
@ -127,7 +127,7 @@ class CallbackOptionProcessor : public OptionProcessor {
|
|||
return false; \
|
||||
} \
|
||||
if (*value == '=') { \
|
||||
Log::PrintErr("Non-empty value for option " #name "\n"); \
|
||||
Syslog::PrintErr("Non-empty value for option " #name "\n"); \
|
||||
return false; \
|
||||
} \
|
||||
if (*value != '\0') { \
|
||||
|
@ -152,7 +152,7 @@ class CallbackOptionProcessor : public OptionProcessor {
|
|||
return false; \
|
||||
} \
|
||||
if (*value == '=') { \
|
||||
Log::PrintErr("Non-empty value for option " #long_name "\n"); \
|
||||
Syslog::PrintErr("Non-empty value for option " #long_name "\n"); \
|
||||
return false; \
|
||||
} \
|
||||
if (*value != '\0') { \
|
||||
|
|
|
@ -26,7 +26,7 @@ int Platform::script_index_ = 1;
|
|||
char** Platform::argv_ = NULL;
|
||||
|
||||
static void segv_handler(int signal, siginfo_t* siginfo, void* context) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"\n===== CRASH =====\n"
|
||||
"si_signo=%s(%d), si_code=%d, si_addr=%p\n",
|
||||
strsignal(siginfo->si_signo), siginfo->si_signo, siginfo->si_code,
|
||||
|
|
|
@ -26,7 +26,7 @@ int Platform::script_index_ = 1;
|
|||
char** Platform::argv_ = NULL;
|
||||
|
||||
static void segv_handler(int signal, siginfo_t* siginfo, void* context) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"\n===== CRASH =====\n"
|
||||
"si_signo=%s(%d), si_code=%d, si_addr=%p\n",
|
||||
strsignal(siginfo->si_signo), siginfo->si_signo, siginfo->si_code,
|
||||
|
|
|
@ -34,7 +34,7 @@ int Platform::script_index_ = 1;
|
|||
char** Platform::argv_ = NULL;
|
||||
|
||||
static void segv_handler(int signal, siginfo_t* siginfo, void* context) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"\n===== CRASH =====\n"
|
||||
"si_signo=%s(%d), si_code=%d, si_addr=%p\n",
|
||||
strsignal(siginfo->si_signo), siginfo->si_signo, siginfo->si_code,
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "bin/console.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "platform/syslog.h"
|
||||
#if !defined(PLATFORM_DISABLE_SOCKET)
|
||||
#include "bin/socket.h"
|
||||
#endif
|
||||
|
@ -73,7 +73,7 @@ class PlatformWin {
|
|||
EXCEPTION_ACCESS_VIOLATION) ||
|
||||
(ExceptionInfo->ExceptionRecord->ExceptionCode ==
|
||||
EXCEPTION_ILLEGAL_INSTRUCTION)) {
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"\n===== CRASH =====\n"
|
||||
"ExceptionCode=%d, ExceptionFlags=%d, ExceptionAddress=%p\n",
|
||||
ExceptionInfo->ExceptionRecord->ExceptionCode,
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
|
||||
#include "bin/dartutils.h"
|
||||
#include "bin/io_buffer.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "bin/platform.h"
|
||||
#include "bin/socket.h"
|
||||
#include "bin/utils.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include "include/dart_api.h"
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#include "bin/fdutils.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "bin/reference_counting.h"
|
||||
#include "bin/thread.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/utils.h"
|
||||
|
|
|
@ -31,16 +31,16 @@
|
|||
#include "bin/fdutils.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "bin/namespace_fuchsia.h"
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
// #define PROCESS_LOGGING 1
|
||||
#if defined(PROCESS_LOGGING)
|
||||
#define LOG_ERR(msg, ...) Log::PrintErr("Dart Process: " msg, ##__VA_ARGS__)
|
||||
#define LOG_INFO(msg, ...) Log::Print("Dart Process: " msg, ##__VA_ARGS__)
|
||||
#define LOG_ERR(msg, ...) Syslog::PrintErr("Dart Process: " msg, ##__VA_ARGS__)
|
||||
#define LOG_INFO(msg, ...) Syslog::Print("Dart Process: " msg, ##__VA_ARGS__)
|
||||
#else
|
||||
#define LOG_ERR(msg, ...)
|
||||
#define LOG_INFO(msg, ...)
|
||||
|
@ -207,8 +207,8 @@ class ExitCodeHandler {
|
|||
pkt.key = kShutdownPacketKey;
|
||||
zx_status_t status = zx_port_queue(port_, &pkt);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("ExitCodeHandler: zx_port_queue failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
Syslog::PrintErr("ExitCodeHandler: zx_port_queue failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,8 +249,8 @@ class ExitCodeHandler {
|
|||
zx_status_t status = zx_object_get_info(
|
||||
process, ZX_INFO_PROCESS, &proc_info, sizeof(proc_info), NULL, NULL);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("ExitCodeHandler: zx_object_get_info failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
Syslog::PrintErr("ExitCodeHandler: zx_object_get_info failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
} else {
|
||||
return_code = proc_info.return_code;
|
||||
}
|
||||
|
@ -270,8 +270,8 @@ class ExitCodeHandler {
|
|||
ASSERT((result == -1) || (result == sizeof(exit_code_fd)));
|
||||
if ((result == -1) && (errno != EPIPE)) {
|
||||
int err = errno;
|
||||
Log::PrintErr("Failed to write exit code for process %d: errno=%d\n",
|
||||
process, err);
|
||||
Syslog::PrintErr("Failed to write exit code for process %d: errno=%d\n",
|
||||
process, err);
|
||||
}
|
||||
LOG_INFO("ExitCodeHandler thread wrote %ld bytes to fd %ld\n", result,
|
||||
exit_code_fd);
|
||||
|
@ -365,8 +365,8 @@ bool Process::Wait(intptr_t pid,
|
|||
zx_handle_t port;
|
||||
zx_status_t status = zx_port_create(0, &port);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("Process::Wait: zx_port_create failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
Syslog::PrintErr("Process::Wait: zx_port_create failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -390,8 +390,8 @@ bool Process::Wait(intptr_t pid,
|
|||
zx_port_packet_t pkt;
|
||||
status = zx_port_wait(port, ZX_TIME_INFINITE, &pkt);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("Process::Wait: zx_port_wait failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
Syslog::PrintErr("Process::Wait: zx_port_wait failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
IOHandle* event_handle = reinterpret_cast<IOHandle*>(pkt.key);
|
||||
|
@ -434,7 +434,8 @@ bool Process::Wait(intptr_t pid,
|
|||
exit_tmp = NULL;
|
||||
}
|
||||
} else {
|
||||
Log::PrintErr("Process::Wait: Unexpected wait key: %p\n", event_handle);
|
||||
Syslog::PrintErr("Process::Wait: Unexpected wait key: %p\n",
|
||||
event_handle);
|
||||
}
|
||||
if (out_tmp != NULL) {
|
||||
if (!out_tmp->AsyncWait(port, events, out_key)) {
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#include "bin/fdutils.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/reference_counting.h"
|
||||
#include "bin/thread.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/utils.h"
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#include "bin/dartutils.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/namespace.h"
|
||||
#include "bin/thread.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/utils.h"
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
#include "bin/dartutils.h"
|
||||
#include "bin/eventhandler.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/socket.h"
|
||||
#include "bin/thread.h"
|
||||
#include "bin/utils.h"
|
||||
#include "bin/utils_win.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -229,7 +229,7 @@ static bool CreateProcessPipe(HANDLE handles[2],
|
|||
NULL);
|
||||
|
||||
if (handles[kWriteHandle] == INVALID_HANDLE_VALUE) {
|
||||
Log::PrintErr("CreateNamedPipe failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("CreateNamedPipe failed %d\n", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ static bool CreateProcessPipe(HANDLE handles[2],
|
|||
CreateFileW(pipe_name, GENERIC_READ, 0, &inherit_handle, OPEN_EXISTING,
|
||||
FILE_READ_ATTRIBUTES | FILE_FLAG_OVERLAPPED, NULL);
|
||||
if (handles[kReadHandle] == INVALID_HANDLE_VALUE) {
|
||||
Log::PrintErr("CreateFile failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("CreateFile failed %d\n", GetLastError());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
@ -252,7 +252,7 @@ static bool CreateProcessPipe(HANDLE handles[2],
|
|||
NULL);
|
||||
|
||||
if (handles[kReadHandle] == INVALID_HANDLE_VALUE) {
|
||||
Log::PrintErr("CreateNamedPipe failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("CreateNamedPipe failed %d\n", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ static bool CreateProcessPipe(HANDLE handles[2],
|
|||
(type == kInheritWrite) ? &inherit_handle : NULL, OPEN_EXISTING,
|
||||
FILE_WRITE_ATTRIBUTES | FILE_FLAG_OVERLAPPED, NULL);
|
||||
if (handles[kWriteHandle] == INVALID_HANDLE_VALUE) {
|
||||
Log::PrintErr("CreateFile failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("CreateFile failed %d\n", GetLastError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ static void CloseProcessPipe(HANDLE handles[2]) {
|
|||
for (int i = kReadHandle; i < kWriteHandle; i++) {
|
||||
if (handles[i] != INVALID_HANDLE_VALUE) {
|
||||
if (!CloseHandle(handles[i])) {
|
||||
Log::PrintErr("CloseHandle failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("CloseHandle failed %d\n", GetLastError());
|
||||
}
|
||||
handles[i] = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ static HANDLE OpenNul() {
|
|||
HANDLE nul = CreateFile(L"NUL", GENERIC_READ | GENERIC_WRITE, 0,
|
||||
&inherit_handle, OPEN_EXISTING, 0, NULL);
|
||||
if (nul == INVALID_HANDLE_VALUE) {
|
||||
Log::PrintErr("CloseHandle failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("CloseHandle failed %d\n", GetLastError());
|
||||
}
|
||||
return nul;
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ class ProcessStarter {
|
|||
reinterpret_cast<STARTUPINFOW*>(&startup_info), &process_info);
|
||||
|
||||
if (result == 0) {
|
||||
Log::PrintErr("CreateProcessW failed %d\n", GetLastError());
|
||||
Syslog::PrintErr("CreateProcessW failed %d\n", GetLastError());
|
||||
return CleanupAndReturnError();
|
||||
}
|
||||
|
||||
|
@ -605,7 +605,7 @@ class ProcessStarter {
|
|||
int status = GenerateNames<4>(pipe_names);
|
||||
if (status != 0) {
|
||||
SetOsErrorMessage(os_error_message_);
|
||||
Log::PrintErr("UuidCreateSequential failed %d\n", status);
|
||||
Syslog::PrintErr("UuidCreateSequential failed %d\n", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,15 +53,15 @@ static const char* kernel_snapshot = NULL;
|
|||
static int run_matches = 0;
|
||||
|
||||
void TestCase::Run() {
|
||||
bin::Log::Print("Running test: %s\n", name());
|
||||
Syslog::Print("Running test: %s\n", name());
|
||||
(*run_)();
|
||||
bin::Log::Print("Done: %s\n", name());
|
||||
Syslog::Print("Done: %s\n", name());
|
||||
}
|
||||
|
||||
void RawTestCase::Run() {
|
||||
bin::Log::Print("Running raw test: %s\n", name());
|
||||
Syslog::Print("Running raw test: %s\n", name());
|
||||
(*run_)();
|
||||
bin::Log::Print("Done: %s\n", name());
|
||||
Syslog::Print("Done: %s\n", name());
|
||||
}
|
||||
|
||||
void TestCaseBase::RunTest() {
|
||||
|
@ -69,7 +69,7 @@ void TestCaseBase::RunTest() {
|
|||
this->Run();
|
||||
run_matches++;
|
||||
} else if (run_filter == kList) {
|
||||
bin::Log::Print("%s\n", this->name());
|
||||
Syslog::Print("%s\n", this->name());
|
||||
run_matches++;
|
||||
}
|
||||
}
|
||||
|
@ -78,17 +78,17 @@ void Benchmark::RunBenchmark() {
|
|||
if ((run_filter == kAllBenchmarks) ||
|
||||
(strcmp(run_filter, this->name()) == 0)) {
|
||||
this->Run();
|
||||
bin::Log::Print("%s(%s): %" Pd64 "\n", this->name(), this->score_kind(),
|
||||
this->score());
|
||||
Syslog::Print("%s(%s): %" Pd64 "\n", this->name(), this->score_kind(),
|
||||
this->score());
|
||||
run_matches++;
|
||||
} else if (run_filter == kList) {
|
||||
bin::Log::Print("%s\n", this->name());
|
||||
Syslog::Print("%s\n", this->name());
|
||||
run_matches++;
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintUsage() {
|
||||
bin::Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Usage: one of the following\n"
|
||||
" run_vm_tests --list\n"
|
||||
" run_vm_tests [--dfe=<snapshot file name>] --benchmarks\n"
|
||||
|
@ -235,7 +235,7 @@ static int Main(int argc, const char** argv) {
|
|||
|
||||
// Perform platform specific initialization.
|
||||
if (!dart::bin::Platform::Initialize()) {
|
||||
bin::Log::PrintErr("Initialization failed\n");
|
||||
Syslog::PrintErr("Initialization failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ static int Main(int argc, const char** argv) {
|
|||
if (strncmp(argv[arg_pos], "--dfe", strlen("--dfe")) == 0) {
|
||||
const char* delim = strstr(argv[arg_pos], "=");
|
||||
if (delim == NULL || strlen(delim + 1) == 0) {
|
||||
bin::Log::PrintErr("Invalid value for the option: %s\n", argv[arg_pos]);
|
||||
Syslog::PrintErr("Invalid value for the option: %s\n", argv[arg_pos]);
|
||||
PrintUsage();
|
||||
return 1;
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ static int Main(int argc, const char** argv) {
|
|||
|
||||
char* error = Flags::ProcessCommandLineFlags(dart_argc, dart_argv);
|
||||
if (error != NULL) {
|
||||
bin::Log::PrintErr("Failed to parse flags: %s\n", error);
|
||||
Syslog::PrintErr("Failed to parse flags: %s\n", error);
|
||||
free(error);
|
||||
return 1;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ static int Main(int argc, const char** argv) {
|
|||
nullptr /* entropy_source */, nullptr /* get_service_assets */,
|
||||
start_kernel_isolate);
|
||||
if (error != nullptr) {
|
||||
bin::Log::PrintErr("Failed to initialize VM: %s\n", error);
|
||||
Syslog::PrintErr("Failed to initialize VM: %s\n", error);
|
||||
free(error);
|
||||
return 1;
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ static int Main(int argc, const char** argv) {
|
|||
|
||||
error = Dart::Cleanup();
|
||||
if (error != nullptr) {
|
||||
bin::Log::PrintErr("Failed shutdown VM: %s\n", error);
|
||||
Syslog::PrintErr("Failed shutdown VM: %s\n", error);
|
||||
free(error);
|
||||
return 1;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ static int Main(int argc, const char** argv) {
|
|||
|
||||
// Print a warning message if no tests or benchmarks were matched.
|
||||
if (run_matches == 0) {
|
||||
bin::Log::PrintErr("No tests matched: %s\n", run_filter);
|
||||
Syslog::PrintErr("No tests matched: %s\n", run_filter);
|
||||
return 1;
|
||||
}
|
||||
if (Expect::failed()) {
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
#include <openssl/x509.h>
|
||||
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/secure_socket_utils.h"
|
||||
#include "bin/security_context.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/text_buffer.h"
|
||||
|
||||
// Return the error from the containing function if handle is an error handle.
|
||||
|
@ -492,25 +492,25 @@ void SSLFilter::Connect(const char* hostname,
|
|||
if (is_server_) {
|
||||
status = SSL_accept(ssl_);
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("SSL_accept status: %d\n", status);
|
||||
Syslog::Print("SSL_accept status: %d\n", status);
|
||||
}
|
||||
if (status != 1) {
|
||||
// TODO(whesse): expect a needs-data error here. Handle other errors.
|
||||
error = SSL_get_error(ssl_, status);
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("SSL_accept error: %d\n", error);
|
||||
Syslog::Print("SSL_accept error: %d\n", error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
status = SSL_connect(ssl_);
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("SSL_connect status: %d\n", status);
|
||||
Syslog::Print("SSL_connect status: %d\n", status);
|
||||
}
|
||||
if (status != 1) {
|
||||
// TODO(whesse): expect a needs-data error here. Handle other errors.
|
||||
error = SSL_get_error(ssl_, status);
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("SSL_connect error: %d\n", error);
|
||||
Syslog::Print("SSL_connect error: %d\n", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -542,10 +542,10 @@ void SSLFilter::Handshake() {
|
|||
// should give us the hostname check.
|
||||
int result = SSL_get_verify_result(ssl_);
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("Handshake verification status: %d\n", result);
|
||||
Syslog::Print("Handshake verification status: %d\n", result);
|
||||
X509* peer_certificate = SSL_get_peer_certificate(ssl_);
|
||||
if (peer_certificate == NULL) {
|
||||
Log::Print("No peer certificate received\n");
|
||||
Syslog::Print("No peer certificate received\n");
|
||||
} else {
|
||||
X509_NAME* s_name = X509_get_subject_name(peer_certificate);
|
||||
printf("Peer certificate SN: ");
|
||||
|
@ -655,7 +655,7 @@ int SSLFilter::ProcessWritePlaintextBuffer(int start, int end) {
|
|||
SSL_write(ssl_, buffers_[kWritePlaintext] + start, length);
|
||||
if (bytes_processed < 0) {
|
||||
if (SSL_LOG_DATA) {
|
||||
Log::Print("SSL_write returned error %d\n", bytes_processed);
|
||||
Syslog::Print("SSL_write returned error %d\n", bytes_processed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -666,7 +666,8 @@ int SSLFilter::ProcessWritePlaintextBuffer(int start, int end) {
|
|||
int SSLFilter::ProcessReadEncryptedBuffer(int start, int end) {
|
||||
int length = end - start;
|
||||
if (SSL_LOG_DATA)
|
||||
Log::Print("Entering ProcessReadEncryptedBuffer with %d bytes\n", length);
|
||||
Syslog::Print("Entering ProcessReadEncryptedBuffer with %d bytes\n",
|
||||
length);
|
||||
int bytes_processed = 0;
|
||||
if (length > 0) {
|
||||
bytes_processed =
|
||||
|
@ -675,14 +676,14 @@ int SSLFilter::ProcessReadEncryptedBuffer(int start, int end) {
|
|||
bool retry = BIO_should_retry(socket_side_);
|
||||
if (!retry) {
|
||||
if (SSL_LOG_DATA)
|
||||
Log::Print("BIO_write failed in ReadEncryptedBuffer\n");
|
||||
Syslog::Print("BIO_write failed in ReadEncryptedBuffer\n");
|
||||
}
|
||||
bytes_processed = 0;
|
||||
}
|
||||
}
|
||||
if (SSL_LOG_DATA)
|
||||
Log::Print("Leaving ProcessReadEncryptedBuffer wrote %d bytes\n",
|
||||
bytes_processed);
|
||||
Syslog::Print("Leaving ProcessReadEncryptedBuffer wrote %d bytes\n",
|
||||
bytes_processed);
|
||||
return bytes_processed;
|
||||
}
|
||||
|
||||
|
@ -694,13 +695,13 @@ int SSLFilter::ProcessWriteEncryptedBuffer(int start, int end) {
|
|||
BIO_read(socket_side_, buffers_[kWriteEncrypted] + start, length);
|
||||
if (bytes_processed < 0) {
|
||||
if (SSL_LOG_DATA)
|
||||
Log::Print("WriteEncrypted BIO_read returned error %d\n",
|
||||
bytes_processed);
|
||||
Syslog::Print("WriteEncrypted BIO_read returned error %d\n",
|
||||
bytes_processed);
|
||||
return 0;
|
||||
} else {
|
||||
if (SSL_LOG_DATA)
|
||||
Log::Print("WriteEncrypted BIO_read wrote %d bytes\n",
|
||||
bytes_processed);
|
||||
Syslog::Print("WriteEncrypted BIO_read wrote %d bytes\n",
|
||||
bytes_processed);
|
||||
}
|
||||
}
|
||||
return bytes_processed;
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
#include "platform/globals.h"
|
||||
|
||||
#include "bin/file.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/secure_socket_filter.h"
|
||||
#include "bin/security_context.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -75,10 +75,10 @@ void SecureSocketUtils::CheckStatusSSL(int status,
|
|||
}
|
||||
if (SSL_LOG_STATUS) {
|
||||
int error = ERR_get_error();
|
||||
Log::PrintErr("Failed: %s status %d", message, status);
|
||||
Syslog::PrintErr("Failed: %s status %d", message, status);
|
||||
char error_string[SSL_ERROR_MESSAGE_BUFFER_SIZE];
|
||||
ERR_error_string_n(error, error_string, SSL_ERROR_MESSAGE_BUFFER_SIZE);
|
||||
Log::PrintErr("ERROR: %d %s\n", error, error_string);
|
||||
Syslog::PrintErr("ERROR: %d %s\n", error, error_string);
|
||||
}
|
||||
SecureSocketUtils::ThrowIOException(status, type, message, ssl);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
|
||||
#include "bin/directory.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/secure_socket_filter.h"
|
||||
#include "bin/secure_socket_utils.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
// Return the error from the containing function if handle is an error handle.
|
||||
#define RETURN_IF_ERROR(handle) \
|
||||
|
@ -324,7 +324,7 @@ void SSLCertContext::SetClientAuthoritiesBytes(
|
|||
|
||||
void SSLCertContext::LoadRootCertFile(const char* file) {
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("Looking for trusted roots in %s\n", file);
|
||||
Syslog::Print("Looking for trusted roots in %s\n", file);
|
||||
}
|
||||
if (!File::Exists(NULL, file)) {
|
||||
SecureSocketUtils::ThrowIOException(-1, "TlsException",
|
||||
|
@ -334,14 +334,14 @@ void SSLCertContext::LoadRootCertFile(const char* file) {
|
|||
SecureSocketUtils::CheckStatus(status, "TlsException",
|
||||
"Failure trusting builtin roots");
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("Trusting roots from: %s\n", file);
|
||||
Syslog::Print("Trusting roots from: %s\n", file);
|
||||
}
|
||||
}
|
||||
|
||||
void SSLCertContext::AddCompiledInCerts() {
|
||||
if (root_certificates_pem == NULL) {
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("Missing compiled-in roots\n");
|
||||
Syslog::Print("Missing compiled-in roots\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ void SSLCertContext::AddCompiledInCerts() {
|
|||
|
||||
void SSLCertContext::LoadRootCertCache(const char* cache) {
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("Looking for trusted roots in %s\n", cache);
|
||||
Syslog::Print("Looking for trusted roots in %s\n", cache);
|
||||
}
|
||||
if (Directory::Exists(NULL, cache) != Directory::EXISTS) {
|
||||
SecureSocketUtils::ThrowIOException(-1, "TlsException",
|
||||
|
@ -380,7 +380,7 @@ void SSLCertContext::LoadRootCertCache(const char* cache) {
|
|||
SecureSocketUtils::CheckStatus(status, "TlsException",
|
||||
"Failure trusting builtin roots");
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("Trusting roots from: %s\n", cache);
|
||||
Syslog::Print("Trusting roots from: %s\n", cache);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -778,7 +778,7 @@ static Dart_Handle ASN1TimeToMilliseconds(ASN1_TIME* aTime) {
|
|||
M_ASN1_UTCTIME_free(epoch_start);
|
||||
if (result != 1) {
|
||||
// TODO(whesse): Propagate an error to Dart.
|
||||
Log::PrintErr("ASN1Time error %d\n", result);
|
||||
Syslog::PrintErr("ASN1Time error %d\n", result);
|
||||
}
|
||||
return Dart_NewInteger((86400LL * days + seconds) * 1000LL);
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
#include "bin/directory.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/secure_socket_filter.h"
|
||||
#include "bin/secure_socket_utils.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
#include "bin/directory.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/secure_socket_filter.h"
|
||||
#include "bin/secure_socket_utils.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
#include "bin/directory.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/secure_socket_filter.h"
|
||||
#include "bin/secure_socket_utils.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -60,7 +60,7 @@ void SSLCertContext::TrustBuiltinRoots() {
|
|||
// Fall back on the compiled-in certs if the standard locations don't exist,
|
||||
// or we aren't on Linux.
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("Trusting compiled-in roots\n");
|
||||
Syslog::Print("Trusting compiled-in roots\n");
|
||||
}
|
||||
AddCompiledInCerts();
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
#include "bin/directory.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/secure_socket_filter.h"
|
||||
#include "bin/secure_socket_utils.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -43,7 +43,7 @@ void SSLCertContext::TrustBuiltinRoots() {
|
|||
// Fall back on the compiled-in certs if the standard locations don't exist,
|
||||
// or we aren't on Linux.
|
||||
if (SSL_LOG_STATUS) {
|
||||
Log::Print("Trusting compiled-in roots\n");
|
||||
Syslog::Print("Trusting compiled-in roots\n");
|
||||
}
|
||||
AddCompiledInCerts();
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ void Snapshot::WriteAppSnapshot(const char* filename,
|
|||
|
||||
file->SetPosition(Utils::RoundUp(file->Position(), kAppSnapshotPageSize));
|
||||
if (LOG_SECTION_BOUNDARIES) {
|
||||
Log::PrintErr("%" Px64 ": VM Data\n", file->Position());
|
||||
Syslog::PrintErr("%" Px64 ": VM Data\n", file->Position());
|
||||
}
|
||||
if (!file->WriteFully(vm_data_buffer, vm_data_size)) {
|
||||
ErrorExit(kErrorExitCode, "Unable to write snapshot file '%s'\n", filename);
|
||||
|
@ -302,7 +302,7 @@ void Snapshot::WriteAppSnapshot(const char* filename,
|
|||
if (vm_instructions_size != 0) {
|
||||
file->SetPosition(Utils::RoundUp(file->Position(), kAppSnapshotPageSize));
|
||||
if (LOG_SECTION_BOUNDARIES) {
|
||||
Log::PrintErr("%" Px64 ": VM Instructions\n", file->Position());
|
||||
Syslog::PrintErr("%" Px64 ": VM Instructions\n", file->Position());
|
||||
}
|
||||
if (!file->WriteFully(vm_instructions_buffer, vm_instructions_size)) {
|
||||
ErrorExit(kErrorExitCode, "Unable to write snapshot file '%s'\n",
|
||||
|
@ -312,7 +312,7 @@ void Snapshot::WriteAppSnapshot(const char* filename,
|
|||
|
||||
file->SetPosition(Utils::RoundUp(file->Position(), kAppSnapshotPageSize));
|
||||
if (LOG_SECTION_BOUNDARIES) {
|
||||
Log::PrintErr("%" Px64 ": Isolate Data\n", file->Position());
|
||||
Syslog::PrintErr("%" Px64 ": Isolate Data\n", file->Position());
|
||||
}
|
||||
if (!file->WriteFully(isolate_data_buffer, isolate_data_size)) {
|
||||
ErrorExit(kErrorExitCode, "Unable to write snapshot file '%s'\n", filename);
|
||||
|
@ -321,7 +321,7 @@ void Snapshot::WriteAppSnapshot(const char* filename,
|
|||
if (isolate_instructions_size != 0) {
|
||||
file->SetPosition(Utils::RoundUp(file->Position(), kAppSnapshotPageSize));
|
||||
if (LOG_SECTION_BOUNDARIES) {
|
||||
Log::PrintErr("%" Px64 ": Isolate Instructions\n", file->Position());
|
||||
Syslog::PrintErr("%" Px64 ": Isolate Instructions\n", file->Position());
|
||||
}
|
||||
if (!file->WriteFully(isolate_instructions_buffer,
|
||||
isolate_instructions_size)) {
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include <errno.h> // NOLINT
|
||||
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -104,7 +104,7 @@ intptr_t Socket::CreateBindDatagram(const RawAddr& addr,
|
|||
|
||||
if (reusePort) {
|
||||
// ignore reusePort - not supported on this platform.
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Dart Socket ERROR: %s:%d: `reusePort` not supported for "
|
||||
"Android.",
|
||||
__FILE__, __LINE__);
|
||||
|
|
|
@ -37,13 +37,14 @@
|
|||
#define LOG_ERR(msg, ...) \
|
||||
{ \
|
||||
int err = errno; \
|
||||
Log::PrintErr("Dart Socket ERROR: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
Syslog::PrintErr("Dart Socket ERROR: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
errno = err; \
|
||||
}
|
||||
#if defined(SOCKET_LOG_INFO)
|
||||
#define LOG_INFO(msg, ...) \
|
||||
Log::Print("Dart Socket INFO: %s:%d: " msg, __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
Syslog::Print("Dart Socket INFO: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__)
|
||||
#else
|
||||
#define LOG_INFO(msg, ...)
|
||||
#endif // defined(SOCKET_LOG_INFO)
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
#include "bin/eventhandler.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/socket_base_win.h"
|
||||
#include "bin/thread.h"
|
||||
#include "bin/utils.h"
|
||||
#include "bin/utils_win.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -51,7 +51,7 @@ bool SocketBase::Initialize() {
|
|||
if (err == 0) {
|
||||
socket_initialized = true;
|
||||
} else {
|
||||
Log::PrintErr("Unable to initialize Winsock: %d\n", WSAGetLastError());
|
||||
Syslog::PrintErr("Unable to initialize Winsock: %d\n", WSAGetLastError());
|
||||
}
|
||||
return (err == 0);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
#include "bin/eventhandler.h"
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
// #define SOCKET_LOG_INFO 1
|
||||
// #define SOCKET_LOG_ERROR 1
|
||||
|
@ -24,13 +24,14 @@
|
|||
#define LOG_ERR(msg, ...) \
|
||||
{ \
|
||||
int err = errno; \
|
||||
Log::PrintErr("Dart Socket ERROR: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
Syslog::PrintErr("Dart Socket ERROR: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__); \
|
||||
errno = err; \
|
||||
}
|
||||
#if defined(SOCKET_LOG_INFO)
|
||||
#define LOG_INFO(msg, ...) \
|
||||
Log::Print("Dart Socket INFO: %s:%d: " msg, __FILE__, __LINE__, ##__VA_ARGS__)
|
||||
Syslog::Print("Dart Socket INFO: %s:%d: " msg, __FILE__, __LINE__, \
|
||||
##__VA_ARGS__)
|
||||
#else
|
||||
#define LOG_INFO(msg, ...)
|
||||
#endif // defined(SOCKET_LOG_INFO)
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include <errno.h> // NOLINT
|
||||
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/log.h"
|
||||
#include "platform/signal_blocker.h"
|
||||
#include "platform/syslog.h"
|
||||
#include "platform/utils.h"
|
||||
|
||||
namespace dart {
|
||||
|
@ -105,11 +105,11 @@ intptr_t Socket::CreateBindDatagram(const RawAddr& addr,
|
|||
}
|
||||
const int kBufferSize = 1024;
|
||||
char error_buf[kBufferSize];
|
||||
Log::PrintErr("Dart Socket ERROR: %s:%d: %s.", __FILE__, __LINE__,
|
||||
Utils::StrError(errno, error_buf, kBufferSize));
|
||||
Syslog::PrintErr("Dart Socket ERROR: %s:%d: %s.", __FILE__, __LINE__,
|
||||
Utils::StrError(errno, error_buf, kBufferSize));
|
||||
}
|
||||
#else // !defined SO_REUSEPORT
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Dart Socket ERROR: %s:%d: `reusePort` not available on this Linux "
|
||||
"version.",
|
||||
__FILE__, __LINE__);
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
#include "bin/eventhandler.h"
|
||||
#include "bin/file.h"
|
||||
#include "bin/lockers.h"
|
||||
#include "bin/log.h"
|
||||
#include "bin/socket.h"
|
||||
#include "bin/socket_base_win.h"
|
||||
#include "bin/thread.h"
|
||||
#include "bin/utils.h"
|
||||
#include "bin/utils_win.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -171,7 +171,7 @@ intptr_t Socket::CreateBindDatagram(const RawAddr& addr,
|
|||
|
||||
if (reusePort) {
|
||||
// ignore reusePort - not supported on this platform.
|
||||
Log::PrintErr(
|
||||
Syslog::PrintErr(
|
||||
"Dart Socket ERROR: %s:%d: `reusePort` not supported for "
|
||||
"Windows.",
|
||||
__FILE__, __LINE__);
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
#include <errno.h> // NOLINT
|
||||
#include <time.h> // NOLINT
|
||||
|
||||
#include "bin/log.h"
|
||||
#include "bin/utils.h"
|
||||
#include "bin/utils_win.h"
|
||||
#include "platform/assert.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
@ -22,8 +22,8 @@ void FormatMessageIntoBuffer(DWORD code, wchar_t* buffer, int buffer_length) {
|
|||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, buffer_length, NULL);
|
||||
if (message_size == 0) {
|
||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
|
||||
Log::PrintErr("FormatMessage failed for error code %d (error %d)\n", code,
|
||||
GetLastError());
|
||||
Syslog::PrintErr("FormatMessage failed for error code %d (error %d)\n",
|
||||
code, GetLastError());
|
||||
}
|
||||
_snwprintf(buffer, buffer_length, L"OS Error %d", code);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "include/dart_native_api.h"
|
||||
#include "platform/assert.h"
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/bootstrap_natives.h"
|
||||
#include "vm/class_finalizer.h"
|
||||
#include "vm/dart.h"
|
||||
|
@ -21,7 +22,6 @@
|
|||
#include "vm/service.h"
|
||||
#include "vm/snapshot.h"
|
||||
#include "vm/symbols.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "vm/bootstrap_natives.h"
|
||||
|
||||
#include "include/dart_api.h"
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/dart_api_impl.h"
|
||||
#include "vm/exceptions.h"
|
||||
#include "vm/isolate.h"
|
||||
|
@ -12,7 +13,6 @@
|
|||
#include "vm/object.h"
|
||||
#include "vm/object_store.h"
|
||||
#include "vm/symbols.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import("../configs.gni")
|
|||
import("platform_sources.gni")
|
||||
|
||||
library_for_all_configs("libdart_platform") {
|
||||
target_type = "static_library"
|
||||
target_type = "source_set"
|
||||
public_configs = [ "../vm:libdart_vm_config" ]
|
||||
sources = platform_sources
|
||||
include_dirs = [ ".." ]
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "include/dart_api.h"
|
||||
#include "platform/globals.h"
|
||||
#include "vm/os.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
@ -29,7 +29,7 @@ void DynamicAssertionHelper::Print(const char* format, va_list arguments) {
|
|||
sizeof(buffer) - file_and_line_length, format, arguments);
|
||||
|
||||
// Print the buffer on stderr and/or syslog.
|
||||
OS::PrintErr("%s\n", buffer);
|
||||
Syslog::PrintErr("%s\n", buffer);
|
||||
}
|
||||
|
||||
void Assert::Fail(const char* format, ...) {
|
||||
|
@ -40,7 +40,8 @@ void Assert::Fail(const char* format, ...) {
|
|||
|
||||
// Abort right away.
|
||||
Dart_DumpNativeStackTrace(NULL);
|
||||
OS::Abort();
|
||||
Dart_PrepareToAbort();
|
||||
abort();
|
||||
}
|
||||
|
||||
void Expect::Fail(const char* format, ...) {
|
||||
|
|
|
@ -27,8 +27,16 @@ platform_sources = [
|
|||
"memory_sanitizer.h",
|
||||
"safe_stack.h",
|
||||
"signal_blocker.h",
|
||||
"syslog.h",
|
||||
"syslog_android.cc",
|
||||
"syslog_fuchsia.cc",
|
||||
"syslog_linux.cc",
|
||||
"syslog_macos.cc",
|
||||
"syslog_win.cc",
|
||||
"text_buffer.cc",
|
||||
"text_buffer.h",
|
||||
"unicode.cc",
|
||||
"unicode.h",
|
||||
"utils.cc",
|
||||
"utils.h",
|
||||
"utils_android.cc",
|
||||
|
|
|
@ -2,17 +2,16 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef RUNTIME_BIN_LOG_H_
|
||||
#define RUNTIME_BIN_LOG_H_
|
||||
#ifndef RUNTIME_PLATFORM_SYSLOG_H_
|
||||
#define RUNTIME_PLATFORM_SYSLOG_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "platform/globals.h"
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
class Log {
|
||||
class Syslog {
|
||||
public:
|
||||
// Print formatted output for debugging.
|
||||
static void Print(const char* format, ...) PRINTF_ATTRIBUTE(1, 2) {
|
||||
|
@ -35,10 +34,9 @@ class Log {
|
|||
|
||||
private:
|
||||
DISALLOW_ALLOCATION();
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(Log);
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(Syslog);
|
||||
};
|
||||
|
||||
} // namespace bin
|
||||
} // namespace dart
|
||||
|
||||
#endif // RUNTIME_BIN_LOG_H_
|
||||
#endif // RUNTIME_PLATFORM_SYSLOG_H_
|
|
@ -5,18 +5,17 @@
|
|||
#include "platform/globals.h"
|
||||
#if defined(HOST_OS_ANDROID)
|
||||
|
||||
#include "bin/log.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include <android/log.h> // NOLINT
|
||||
#include <stdio.h> // NOLINT
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
// TODO(gram): We should be buffering the data and only outputting
|
||||
// it when we see a '\n'.
|
||||
|
||||
void Log::VPrint(const char* format, va_list args) {
|
||||
void Syslog::VPrint(const char* format, va_list args) {
|
||||
// If we launch the DartVM inside "adb shell" we will only get messages
|
||||
// (critical ones or not) if we print them to stdout/stderr.
|
||||
// We also log using android's logging system.
|
||||
|
@ -25,7 +24,7 @@ void Log::VPrint(const char* format, va_list args) {
|
|||
__android_log_vprint(ANDROID_LOG_INFO, "Dart", format, args);
|
||||
}
|
||||
|
||||
void Log::VPrintErr(const char* format, va_list args) {
|
||||
void Syslog::VPrintErr(const char* format, va_list args) {
|
||||
// If we launch the DartVM inside "adb shell" we will only get messages
|
||||
// (critical ones or not) if we print them to stdout/stderr.
|
||||
// We also log using android's logging system.
|
||||
|
@ -34,7 +33,6 @@ void Log::VPrintErr(const char* format, va_list args) {
|
|||
__android_log_vprint(ANDROID_LOG_ERROR, "Dart", format, args);
|
||||
}
|
||||
|
||||
} // namespace bin
|
||||
} // namespace dart
|
||||
|
||||
#endif // defined(HOST_OS_ANDROID)
|
|
@ -5,24 +5,22 @@
|
|||
#include "platform/globals.h"
|
||||
#if defined(HOST_OS_FUCHSIA)
|
||||
|
||||
#include "bin/log.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include <stdio.h> // NOLINT
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
void Log::VPrint(const char* format, va_list args) {
|
||||
void Syslog::VPrint(const char* format, va_list args) {
|
||||
vfprintf(stdout, format, args);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::VPrintErr(const char* format, va_list args) {
|
||||
void Syslog::VPrintErr(const char* format, va_list args) {
|
||||
vfprintf(stderr, format, args);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
} // namespace bin
|
||||
} // namespace dart
|
||||
|
||||
#endif // defined(HOST_OS_FUCHSIA)
|
|
@ -5,24 +5,22 @@
|
|||
#include "platform/globals.h"
|
||||
#if defined(HOST_OS_LINUX)
|
||||
|
||||
#include "bin/log.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include <stdio.h> // NOLINT
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
void Log::VPrint(const char* format, va_list args) {
|
||||
void Syslog::VPrint(const char* format, va_list args) {
|
||||
vfprintf(stdout, format, args);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::VPrintErr(const char* format, va_list args) {
|
||||
void Syslog::VPrintErr(const char* format, va_list args) {
|
||||
vfprintf(stderr, format, args);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
} // namespace bin
|
||||
} // namespace dart
|
||||
|
||||
#endif // defined(HOST_OS_LINUX)
|
|
@ -5,24 +5,22 @@
|
|||
#include "platform/globals.h"
|
||||
#if defined(HOST_OS_MACOS)
|
||||
|
||||
#include "bin/log.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include <stdio.h> // NOLINT
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
void Log::VPrint(const char* format, va_list args) {
|
||||
void Syslog::VPrint(const char* format, va_list args) {
|
||||
vfprintf(stdout, format, args);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::VPrintErr(const char* format, va_list args) {
|
||||
void Syslog::VPrintErr(const char* format, va_list args) {
|
||||
vfprintf(stderr, format, args);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
} // namespace bin
|
||||
} // namespace dart
|
||||
|
||||
#endif // defined(HOST_OS_MACOS)
|
|
@ -5,24 +5,22 @@
|
|||
#include "platform/globals.h"
|
||||
#if defined(HOST_OS_WINDOWS)
|
||||
|
||||
#include "bin/log.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
#include <stdio.h> // NOLINT
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
|
||||
void Log::VPrint(const char* format, va_list args) {
|
||||
void Syslog::VPrint(const char* format, va_list args) {
|
||||
vfprintf(stdout, format, args);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void Log::VPrintErr(const char* format, va_list args) {
|
||||
void Syslog::VPrintErr(const char* format, va_list args) {
|
||||
vfprintf(stderr, format, args);
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
} // namespace bin
|
||||
} // namespace dart
|
||||
|
||||
#endif // defined(HOST_OS_WINDOWS)
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#include "platform/assert.h"
|
||||
#include "platform/globals.h"
|
||||
#include "platform/unicode.h"
|
||||
#include "platform/utils.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
275
runtime/platform/unicode.cc
Normal file
275
runtime/platform/unicode.cc
Normal file
|
@ -0,0 +1,275 @@
|
|||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "platform/unicode.h"
|
||||
|
||||
#include "platform/allocation.h"
|
||||
#include "platform/globals.h"
|
||||
#include "platform/syslog.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
// clang-format off
|
||||
const int8_t Utf8::kTrailBytes[256] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
const uint32_t Utf8::kMagicBits[7] = {0, // Padding.
|
||||
0x00000000, 0x00003080, 0x000E2080,
|
||||
0x03C82080, 0xFA082080, 0x82082080};
|
||||
|
||||
// Minimum values of code points used to check shortest form.
|
||||
const uint32_t Utf8::kOverlongMinimum[7] = {0, // Padding.
|
||||
0x0, 0x80, 0x800,
|
||||
0x10000, 0xFFFFFFFF, 0xFFFFFFFF};
|
||||
|
||||
// Returns the most restricted coding form in which the sequence of utf8
|
||||
// characters in 'utf8_array' can be represented in, and the number of
|
||||
// code units needed in that form.
|
||||
intptr_t Utf8::CodeUnitCount(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
Type* type) {
|
||||
intptr_t len = 0;
|
||||
Type char_type = kLatin1;
|
||||
for (intptr_t i = 0; i < array_len; i++) {
|
||||
uint8_t code_unit = utf8_array[i];
|
||||
if (!IsTrailByte(code_unit)) {
|
||||
++len;
|
||||
if (!IsLatin1SequenceStart(code_unit)) { // > U+00FF
|
||||
if (IsSupplementarySequenceStart(code_unit)) { // >= U+10000
|
||||
char_type = kSupplementary;
|
||||
++len;
|
||||
} else if (char_type == kLatin1) {
|
||||
char_type = kBMP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*type = char_type;
|
||||
return len;
|
||||
}
|
||||
|
||||
// Returns true if str is a valid NUL-terminated UTF-8 string.
|
||||
bool Utf8::IsValid(const uint8_t* utf8_array, intptr_t array_len) {
|
||||
intptr_t i = 0;
|
||||
while (i < array_len) {
|
||||
uint32_t ch = utf8_array[i] & 0xFF;
|
||||
intptr_t j = 1;
|
||||
if (ch >= 0x80) {
|
||||
int8_t num_trail_bytes = kTrailBytes[ch];
|
||||
bool is_malformed = false;
|
||||
for (; j < num_trail_bytes; ++j) {
|
||||
if ((i + j) < array_len) {
|
||||
uint8_t code_unit = utf8_array[i + j];
|
||||
is_malformed |= !IsTrailByte(code_unit);
|
||||
ch = (ch << 6) + code_unit;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ch -= kMagicBits[num_trail_bytes];
|
||||
if (!((is_malformed == false) && (j == num_trail_bytes) &&
|
||||
!Utf::IsOutOfRange(ch) && !IsNonShortestForm(ch, j))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
i += j;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
intptr_t Utf8::Length(int32_t ch) {
|
||||
if (ch <= kMaxOneByteChar) {
|
||||
return 1;
|
||||
} else if (ch <= kMaxTwoByteChar) {
|
||||
return 2;
|
||||
} else if (ch <= kMaxThreeByteChar) {
|
||||
return 3;
|
||||
}
|
||||
ASSERT(ch <= kMaxFourByteChar);
|
||||
return 4;
|
||||
}
|
||||
|
||||
intptr_t Utf8::Encode(int32_t ch, char* dst) {
|
||||
static const int kMask = ~(1 << 6);
|
||||
if (ch <= kMaxOneByteChar) {
|
||||
dst[0] = ch;
|
||||
return 1;
|
||||
}
|
||||
if (ch <= kMaxTwoByteChar) {
|
||||
dst[0] = 0xC0 | (ch >> 6);
|
||||
dst[1] = 0x80 | (ch & kMask);
|
||||
return 2;
|
||||
}
|
||||
if (ch <= kMaxThreeByteChar) {
|
||||
dst[0] = 0xE0 | (ch >> 12);
|
||||
dst[1] = 0x80 | ((ch >> 6) & kMask);
|
||||
dst[2] = 0x80 | (ch & kMask);
|
||||
return 3;
|
||||
}
|
||||
ASSERT(ch <= kMaxFourByteChar);
|
||||
dst[0] = 0xF0 | (ch >> 18);
|
||||
dst[1] = 0x80 | ((ch >> 12) & kMask);
|
||||
dst[2] = 0x80 | ((ch >> 6) & kMask);
|
||||
dst[3] = 0x80 | (ch & kMask);
|
||||
return 4;
|
||||
}
|
||||
|
||||
intptr_t Utf8::Decode(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
int32_t* dst) {
|
||||
uint32_t ch = utf8_array[0] & 0xFF;
|
||||
intptr_t i = 1;
|
||||
if (ch >= 0x80) {
|
||||
intptr_t num_trail_bytes = kTrailBytes[ch];
|
||||
bool is_malformed = false;
|
||||
for (; i < num_trail_bytes; ++i) {
|
||||
if (i < array_len) {
|
||||
uint8_t code_unit = utf8_array[i];
|
||||
is_malformed |= !IsTrailByte(code_unit);
|
||||
ch = (ch << 6) + code_unit;
|
||||
} else {
|
||||
*dst = -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ch -= kMagicBits[num_trail_bytes];
|
||||
if (!((is_malformed == false) && (i == num_trail_bytes) &&
|
||||
!Utf::IsOutOfRange(ch) && !IsNonShortestForm(ch, i))) {
|
||||
*dst = -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
*dst = ch;
|
||||
return i;
|
||||
}
|
||||
intptr_t Utf8::ReportInvalidByte(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
intptr_t len) {
|
||||
intptr_t i = 0;
|
||||
intptr_t j = 0;
|
||||
intptr_t num_bytes;
|
||||
for (; (i < array_len) && (j < len); i += num_bytes, ++j) {
|
||||
int32_t ch;
|
||||
bool is_supplementary = IsSupplementarySequenceStart(utf8_array[i]);
|
||||
num_bytes = Utf8::Decode(&utf8_array[i], (array_len - i), &ch);
|
||||
if (ch == -1) {
|
||||
break; // Invalid input.
|
||||
}
|
||||
if (is_supplementary) {
|
||||
j = j + 1;
|
||||
}
|
||||
}
|
||||
Syslog::PrintErr("Invalid UTF8 sequence encountered, ");
|
||||
for (intptr_t idx = 0; idx < 10 && (i + idx) < array_len; idx++) {
|
||||
Syslog::PrintErr("(Error Code: %X + idx: %" Pd " )", utf8_array[idx + i],
|
||||
(idx + i));
|
||||
}
|
||||
Syslog::PrintErr("\n");
|
||||
return i;
|
||||
}
|
||||
|
||||
bool Utf8::DecodeToLatin1(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
uint8_t* dst,
|
||||
intptr_t len) {
|
||||
intptr_t i = 0;
|
||||
intptr_t j = 0;
|
||||
intptr_t num_bytes;
|
||||
for (; (i < array_len) && (j < len); i += num_bytes, ++j) {
|
||||
int32_t ch;
|
||||
ASSERT(IsLatin1SequenceStart(utf8_array[i]));
|
||||
num_bytes = Utf8::Decode(&utf8_array[i], (array_len - i), &ch);
|
||||
if (ch == -1) {
|
||||
return false; // Invalid input.
|
||||
}
|
||||
ASSERT(Utf::IsLatin1(ch));
|
||||
dst[j] = ch;
|
||||
}
|
||||
if ((i < array_len) && (j == len)) {
|
||||
return false; // Output overflow.
|
||||
}
|
||||
return true; // Success.
|
||||
}
|
||||
|
||||
bool Utf8::DecodeToUTF16(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
uint16_t* dst,
|
||||
intptr_t len) {
|
||||
intptr_t i = 0;
|
||||
intptr_t j = 0;
|
||||
intptr_t num_bytes;
|
||||
for (; (i < array_len) && (j < len); i += num_bytes, ++j) {
|
||||
int32_t ch;
|
||||
bool is_supplementary = IsSupplementarySequenceStart(utf8_array[i]);
|
||||
num_bytes = Utf8::Decode(&utf8_array[i], (array_len - i), &ch);
|
||||
if (ch == -1) {
|
||||
return false; // Invalid input.
|
||||
}
|
||||
if (is_supplementary) {
|
||||
if (j == (len - 1)) return false; // Output overflow.
|
||||
Utf16::Encode(ch, &dst[j]);
|
||||
j = j + 1;
|
||||
} else {
|
||||
dst[j] = ch;
|
||||
}
|
||||
}
|
||||
if ((i < array_len) && (j == len)) {
|
||||
return false; // Output overflow.
|
||||
}
|
||||
return true; // Success.
|
||||
}
|
||||
|
||||
bool Utf8::DecodeToUTF32(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
int32_t* dst,
|
||||
intptr_t len) {
|
||||
intptr_t i = 0;
|
||||
intptr_t j = 0;
|
||||
intptr_t num_bytes;
|
||||
for (; (i < array_len) && (j < len); i += num_bytes, ++j) {
|
||||
int32_t ch;
|
||||
num_bytes = Utf8::Decode(&utf8_array[i], (array_len - i), &ch);
|
||||
if (ch == -1) {
|
||||
return false; // Invalid input.
|
||||
}
|
||||
dst[j] = ch;
|
||||
}
|
||||
if ((i < array_len) && (j == len)) {
|
||||
return false; // Output overflow.
|
||||
}
|
||||
return true; // Success.
|
||||
}
|
||||
|
||||
bool Utf8::DecodeCStringToUTF32(const char* str, int32_t* dst, intptr_t len) {
|
||||
ASSERT(str != NULL);
|
||||
intptr_t array_len = strlen(str);
|
||||
const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(str);
|
||||
return Utf8::DecodeToUTF32(utf8_array, array_len, dst, len);
|
||||
}
|
||||
|
||||
void Utf16::Encode(int32_t codepoint, uint16_t* dst) {
|
||||
ASSERT(codepoint > Utf16::kMaxCodeUnit);
|
||||
ASSERT(dst != NULL);
|
||||
dst[0] = (Utf16::kLeadSurrogateOffset + (codepoint >> 10));
|
||||
dst[1] = (0xDC00 + (codepoint & 0x3FF));
|
||||
}
|
||||
|
||||
} // namespace dart
|
|
@ -2,11 +2,11 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef RUNTIME_VM_UNICODE_H_
|
||||
#define RUNTIME_VM_UNICODE_H_
|
||||
#ifndef RUNTIME_PLATFORM_UNICODE_H_
|
||||
#define RUNTIME_PLATFORM_UNICODE_H_
|
||||
|
||||
#include "vm/allocation.h"
|
||||
#include "vm/globals.h"
|
||||
#include "platform/allocation.h"
|
||||
#include "platform/globals.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
@ -56,11 +56,11 @@ class Utf8 : AllStatic {
|
|||
static intptr_t Length(const String& str);
|
||||
|
||||
static intptr_t Encode(int32_t ch, char* dst);
|
||||
static intptr_t Encode(const String& src, char* dst, intptr_t len);
|
||||
|
||||
static intptr_t Decode(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
int32_t* ch);
|
||||
static intptr_t Encode(const String& src, char* dst, intptr_t len);
|
||||
|
||||
static bool DecodeToLatin1(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
|
@ -224,4 +224,4 @@ class CaseMapping : AllStatic {
|
|||
|
||||
} // namespace dart
|
||||
|
||||
#endif // RUNTIME_VM_UNICODE_H_
|
||||
#endif // RUNTIME_PLATFORM_UNICODE_H_
|
|
@ -108,4 +108,30 @@ uint32_t Utils::WordHash(intptr_t key) {
|
|||
return static_cast<uint32_t>(a);
|
||||
}
|
||||
|
||||
char* Utils::SCreate(const char* format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
char* buffer = VSCreate(format, args);
|
||||
va_end(args);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
char* Utils::VSCreate(const char* format, va_list args) {
|
||||
// Measure.
|
||||
va_list measure_args;
|
||||
va_copy(measure_args, args);
|
||||
intptr_t len = VSNPrint(NULL, 0, format, measure_args);
|
||||
va_end(measure_args);
|
||||
|
||||
char* buffer = reinterpret_cast<char*>(malloc(len + 1));
|
||||
ASSERT(buffer != NULL);
|
||||
|
||||
// Print.
|
||||
va_list print_args;
|
||||
va_copy(print_args, args);
|
||||
VSNPrint(buffer, len + 1, format, print_args);
|
||||
va_end(print_args);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -386,6 +386,10 @@ class Utils {
|
|||
static int SNPrint(char* str, size_t size, const char* format, ...)
|
||||
PRINTF_ATTRIBUTE(3, 4);
|
||||
static int VSNPrint(char* str, size_t size, const char* format, va_list args);
|
||||
|
||||
// Allocate a string and print formatted output into a malloc'd buffer.
|
||||
static char* SCreate(const char* format, ...) PRINTF_ATTRIBUTE(1, 2);
|
||||
static char* VSCreate(const char* format, va_list args);
|
||||
};
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
static_library("libdouble_conversion") {
|
||||
source_set("libdouble_conversion") {
|
||||
configs += [
|
||||
"../../..:dart_arch_config",
|
||||
"../../..:dart_config",
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "vm/compiler/aot/precompiler.h"
|
||||
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/class_finalizer.h"
|
||||
#include "vm/code_patcher.h"
|
||||
#include "vm/compiler/aot/aot_call_specializer.h"
|
||||
|
@ -49,7 +50,6 @@
|
|||
#include "vm/timer.h"
|
||||
#include "vm/type_table.h"
|
||||
#include "vm/type_testing_stubs.h"
|
||||
#include "vm/unicode.h"
|
||||
#include "vm/version.h"
|
||||
|
||||
namespace dart {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
#include "vm/kernel_loader.h"
|
||||
#endif
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/compiler/aot/precompiler.h"
|
||||
#include "vm/exceptions.h"
|
||||
#include "vm/flags.h"
|
||||
|
@ -49,7 +50,6 @@
|
|||
#include "vm/symbols.h"
|
||||
#include "vm/tags.h"
|
||||
#include "vm/thread_registry.h"
|
||||
#include "vm/unicode.h"
|
||||
#include "vm/uri.h"
|
||||
#include "vm/version.h"
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "vm/dart_api_message.h"
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/snapshot_ids.h"
|
||||
#include "vm/symbols.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "platform/assert.h"
|
||||
|
||||
#include "include/dart_native_api.h"
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/dart_entry.h"
|
||||
#include "vm/debugger.h"
|
||||
#include "vm/heap/safepoint.h"
|
||||
|
@ -16,7 +17,6 @@
|
|||
#include "vm/service_event.h"
|
||||
#include "vm/thread_registry.h"
|
||||
#include "vm/timeline.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
#include "platform/assert.h"
|
||||
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/json_writer.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "include/dart_api.h"
|
||||
#include "platform/assert.h"
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/bit_vector.h"
|
||||
#include "vm/bootstrap.h"
|
||||
#include "vm/class_finalizer.h"
|
||||
|
@ -55,7 +56,6 @@
|
|||
#include "vm/timeline.h"
|
||||
#include "vm/type_table.h"
|
||||
#include "vm/type_testing_stubs.h"
|
||||
#include "vm/unicode.h"
|
||||
#include "vm/zone_text_buffer.h"
|
||||
|
||||
namespace dart {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "vm/regexp.h"
|
||||
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/dart_entry.h"
|
||||
#include "vm/regexp_assembler.h"
|
||||
#include "vm/regexp_assembler_bytecode.h"
|
||||
|
@ -12,7 +13,6 @@
|
|||
#include "vm/symbols.h"
|
||||
#include "vm/thread.h"
|
||||
#include "vm/unibrow-inl.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
#define Z (zone())
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "vm/regexp_assembler_ir.h"
|
||||
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/bit_vector.h"
|
||||
#include "vm/compiler/backend/il_printer.h"
|
||||
#include "vm/compiler/frontend/flow_graph_builder.h"
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "vm/resolver.h"
|
||||
#include "vm/runtime_entry.h"
|
||||
#include "vm/stack_frame.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
#define Z zone()
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
#include "vm/regexp_interpreter.h"
|
||||
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/regexp_assembler.h"
|
||||
#include "vm/regexp_bytecodes.h"
|
||||
#include "vm/unibrow-inl.h"
|
||||
#include "vm/unibrow.h"
|
||||
#include "vm/unicode.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "include/dart_native_api.h"
|
||||
#include "platform/globals.h"
|
||||
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/base64.h"
|
||||
#include "vm/compiler/jit/compiler.h"
|
||||
#include "vm/cpu.h"
|
||||
|
@ -41,7 +42,6 @@
|
|||
#include "vm/symbols.h"
|
||||
#include "vm/timeline.h"
|
||||
#include "vm/type_table.h"
|
||||
#include "vm/unicode.h"
|
||||
#include "vm/version.h"
|
||||
|
||||
namespace dart {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "include/dart_tools_api.h"
|
||||
#include "platform/assert.h"
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/class_finalizer.h"
|
||||
#include "vm/clustered_snapshot.h"
|
||||
#include "vm/dart_api_impl.h"
|
||||
|
@ -17,7 +18,6 @@
|
|||
#include "vm/snapshot.h"
|
||||
#include "vm/symbols.h"
|
||||
#include "vm/timer.h"
|
||||
#include "vm/unicode.h"
|
||||
#include "vm/unit_test.h"
|
||||
|
||||
namespace dart {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "vm/symbols.h"
|
||||
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/handles.h"
|
||||
#include "vm/hash_table.h"
|
||||
#include "vm/isolate.h"
|
||||
|
@ -13,7 +14,6 @@
|
|||
#include "vm/reusable_handles.h"
|
||||
#include "vm/snapshot_ids.h"
|
||||
#include "vm/type_table.h"
|
||||
#include "vm/unicode.h"
|
||||
#include "vm/visitor.h"
|
||||
|
||||
namespace dart {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "vm/unicode.h"
|
||||
#include "platform/unicode.h"
|
||||
|
||||
#include "vm/allocation.h"
|
||||
#include "vm/globals.h"
|
||||
|
@ -10,103 +10,6 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
// clang-format off
|
||||
const int8_t Utf8::kTrailBytes[256] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
const uint32_t Utf8::kMagicBits[7] = {0, // Padding.
|
||||
0x00000000, 0x00003080, 0x000E2080,
|
||||
0x03C82080, 0xFA082080, 0x82082080};
|
||||
|
||||
// Minimum values of code points used to check shortest form.
|
||||
const uint32_t Utf8::kOverlongMinimum[7] = {0, // Padding.
|
||||
0x0, 0x80, 0x800,
|
||||
0x10000, 0xFFFFFFFF, 0xFFFFFFFF};
|
||||
|
||||
// Returns the most restricted coding form in which the sequence of utf8
|
||||
// characters in 'utf8_array' can be represented in, and the number of
|
||||
// code units needed in that form.
|
||||
intptr_t Utf8::CodeUnitCount(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
Type* type) {
|
||||
intptr_t len = 0;
|
||||
Type char_type = kLatin1;
|
||||
for (intptr_t i = 0; i < array_len; i++) {
|
||||
uint8_t code_unit = utf8_array[i];
|
||||
if (!IsTrailByte(code_unit)) {
|
||||
++len;
|
||||
if (!IsLatin1SequenceStart(code_unit)) { // > U+00FF
|
||||
if (IsSupplementarySequenceStart(code_unit)) { // >= U+10000
|
||||
char_type = kSupplementary;
|
||||
++len;
|
||||
} else if (char_type == kLatin1) {
|
||||
char_type = kBMP;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*type = char_type;
|
||||
return len;
|
||||
}
|
||||
|
||||
// Returns true if str is a valid NUL-terminated UTF-8 string.
|
||||
bool Utf8::IsValid(const uint8_t* utf8_array, intptr_t array_len) {
|
||||
intptr_t i = 0;
|
||||
while (i < array_len) {
|
||||
uint32_t ch = utf8_array[i] & 0xFF;
|
||||
intptr_t j = 1;
|
||||
if (ch >= 0x80) {
|
||||
int8_t num_trail_bytes = kTrailBytes[ch];
|
||||
bool is_malformed = false;
|
||||
for (; j < num_trail_bytes; ++j) {
|
||||
if ((i + j) < array_len) {
|
||||
uint8_t code_unit = utf8_array[i + j];
|
||||
is_malformed |= !IsTrailByte(code_unit);
|
||||
ch = (ch << 6) + code_unit;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ch -= kMagicBits[num_trail_bytes];
|
||||
if (!((is_malformed == false) && (j == num_trail_bytes) &&
|
||||
!Utf::IsOutOfRange(ch) && !IsNonShortestForm(ch, j))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
i += j;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
intptr_t Utf8::Length(int32_t ch) {
|
||||
if (ch <= kMaxOneByteChar) {
|
||||
return 1;
|
||||
} else if (ch <= kMaxTwoByteChar) {
|
||||
return 2;
|
||||
} else if (ch <= kMaxThreeByteChar) {
|
||||
return 3;
|
||||
}
|
||||
ASSERT(ch <= kMaxFourByteChar);
|
||||
return 4;
|
||||
}
|
||||
|
||||
// A constant mask that can be 'and'ed with a word of data to determine if it
|
||||
// is all ASCII (with no Latin1 characters).
|
||||
#if defined(ARCH_IS_64_BIT)
|
||||
|
@ -164,31 +67,6 @@ intptr_t Utf8::Length(const String& str) {
|
|||
return length;
|
||||
}
|
||||
|
||||
intptr_t Utf8::Encode(int32_t ch, char* dst) {
|
||||
static const int kMask = ~(1 << 6);
|
||||
if (ch <= kMaxOneByteChar) {
|
||||
dst[0] = ch;
|
||||
return 1;
|
||||
}
|
||||
if (ch <= kMaxTwoByteChar) {
|
||||
dst[0] = 0xC0 | (ch >> 6);
|
||||
dst[1] = 0x80 | (ch & kMask);
|
||||
return 2;
|
||||
}
|
||||
if (ch <= kMaxThreeByteChar) {
|
||||
dst[0] = 0xE0 | (ch >> 12);
|
||||
dst[1] = 0x80 | ((ch >> 6) & kMask);
|
||||
dst[2] = 0x80 | (ch & kMask);
|
||||
return 3;
|
||||
}
|
||||
ASSERT(ch <= kMaxFourByteChar);
|
||||
dst[0] = 0xF0 | (ch >> 18);
|
||||
dst[1] = 0x80 | ((ch >> 12) & kMask);
|
||||
dst[2] = 0x80 | ((ch >> 6) & kMask);
|
||||
dst[3] = 0x80 | (ch & kMask);
|
||||
return 4;
|
||||
}
|
||||
|
||||
intptr_t Utf8::Encode(const String& src, char* dst, intptr_t len) {
|
||||
uintptr_t array_len = len;
|
||||
intptr_t pos = 0;
|
||||
|
@ -252,144 +130,4 @@ intptr_t Utf8::Encode(const String& src, char* dst, intptr_t len) {
|
|||
return pos;
|
||||
}
|
||||
|
||||
intptr_t Utf8::Decode(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
int32_t* dst) {
|
||||
uint32_t ch = utf8_array[0] & 0xFF;
|
||||
intptr_t i = 1;
|
||||
if (ch >= 0x80) {
|
||||
intptr_t num_trail_bytes = kTrailBytes[ch];
|
||||
bool is_malformed = false;
|
||||
for (; i < num_trail_bytes; ++i) {
|
||||
if (i < array_len) {
|
||||
uint8_t code_unit = utf8_array[i];
|
||||
is_malformed |= !IsTrailByte(code_unit);
|
||||
ch = (ch << 6) + code_unit;
|
||||
} else {
|
||||
*dst = -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ch -= kMagicBits[num_trail_bytes];
|
||||
if (!((is_malformed == false) && (i == num_trail_bytes) &&
|
||||
!Utf::IsOutOfRange(ch) && !IsNonShortestForm(ch, i))) {
|
||||
*dst = -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
*dst = ch;
|
||||
return i;
|
||||
}
|
||||
intptr_t Utf8::ReportInvalidByte(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
intptr_t len) {
|
||||
intptr_t i = 0;
|
||||
intptr_t j = 0;
|
||||
intptr_t num_bytes;
|
||||
for (; (i < array_len) && (j < len); i += num_bytes, ++j) {
|
||||
int32_t ch;
|
||||
bool is_supplementary = IsSupplementarySequenceStart(utf8_array[i]);
|
||||
num_bytes = Utf8::Decode(&utf8_array[i], (array_len - i), &ch);
|
||||
if (ch == -1) {
|
||||
break; // Invalid input.
|
||||
}
|
||||
if (is_supplementary) {
|
||||
j = j + 1;
|
||||
}
|
||||
}
|
||||
OS::PrintErr("Invalid UTF8 sequence encountered, ");
|
||||
for (intptr_t idx = 0; idx < 10 && (i + idx) < array_len; idx++) {
|
||||
OS::PrintErr("(Error Code: %X + idx: %" Pd " )", utf8_array[idx + i],
|
||||
(idx + i));
|
||||
}
|
||||
OS::PrintErr("\n");
|
||||
return i;
|
||||
}
|
||||
|
||||
bool Utf8::DecodeToLatin1(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
uint8_t* dst,
|
||||
intptr_t len) {
|
||||
intptr_t i = 0;
|
||||
intptr_t j = 0;
|
||||
intptr_t num_bytes;
|
||||
for (; (i < array_len) && (j < len); i += num_bytes, ++j) {
|
||||
int32_t ch;
|
||||
ASSERT(IsLatin1SequenceStart(utf8_array[i]));
|
||||
num_bytes = Utf8::Decode(&utf8_array[i], (array_len - i), &ch);
|
||||
if (ch == -1) {
|
||||
return false; // Invalid input.
|
||||
}
|
||||
ASSERT(Utf::IsLatin1(ch));
|
||||
dst[j] = ch;
|
||||
}
|
||||
if ((i < array_len) && (j == len)) {
|
||||
return false; // Output overflow.
|
||||
}
|
||||
return true; // Success.
|
||||
}
|
||||
|
||||
bool Utf8::DecodeToUTF16(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
uint16_t* dst,
|
||||
intptr_t len) {
|
||||
intptr_t i = 0;
|
||||
intptr_t j = 0;
|
||||
intptr_t num_bytes;
|
||||
for (; (i < array_len) && (j < len); i += num_bytes, ++j) {
|
||||
int32_t ch;
|
||||
bool is_supplementary = IsSupplementarySequenceStart(utf8_array[i]);
|
||||
num_bytes = Utf8::Decode(&utf8_array[i], (array_len - i), &ch);
|
||||
if (ch == -1) {
|
||||
return false; // Invalid input.
|
||||
}
|
||||
if (is_supplementary) {
|
||||
if (j == (len - 1)) return false; // Output overflow.
|
||||
Utf16::Encode(ch, &dst[j]);
|
||||
j = j + 1;
|
||||
} else {
|
||||
dst[j] = ch;
|
||||
}
|
||||
}
|
||||
if ((i < array_len) && (j == len)) {
|
||||
return false; // Output overflow.
|
||||
}
|
||||
return true; // Success.
|
||||
}
|
||||
|
||||
bool Utf8::DecodeToUTF32(const uint8_t* utf8_array,
|
||||
intptr_t array_len,
|
||||
int32_t* dst,
|
||||
intptr_t len) {
|
||||
intptr_t i = 0;
|
||||
intptr_t j = 0;
|
||||
intptr_t num_bytes;
|
||||
for (; (i < array_len) && (j < len); i += num_bytes, ++j) {
|
||||
int32_t ch;
|
||||
num_bytes = Utf8::Decode(&utf8_array[i], (array_len - i), &ch);
|
||||
if (ch == -1) {
|
||||
return false; // Invalid input.
|
||||
}
|
||||
dst[j] = ch;
|
||||
}
|
||||
if ((i < array_len) && (j == len)) {
|
||||
return false; // Output overflow.
|
||||
}
|
||||
return true; // Success.
|
||||
}
|
||||
|
||||
bool Utf8::DecodeCStringToUTF32(const char* str, int32_t* dst, intptr_t len) {
|
||||
ASSERT(str != NULL);
|
||||
intptr_t array_len = strlen(str);
|
||||
const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(str);
|
||||
return Utf8::DecodeToUTF32(utf8_array, array_len, dst, len);
|
||||
}
|
||||
|
||||
void Utf16::Encode(int32_t codepoint, uint16_t* dst) {
|
||||
ASSERT(codepoint > Utf16::kMaxCodeUnit);
|
||||
ASSERT(dst != NULL);
|
||||
dst[0] = (Utf16::kLeadSurrogateOffset + (codepoint >> 10));
|
||||
dst[1] = (0xDC00 + (codepoint & 0x3FF));
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "vm/unicode.h"
|
||||
#include "platform/unicode.h"
|
||||
|
||||
namespace dart {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "vm/unicode.h"
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/globals.h"
|
||||
#include "vm/unit_test.h"
|
||||
|
||||
|
|
|
@ -345,7 +345,6 @@ vm_sources = [
|
|||
"unibrow.cc",
|
||||
"unibrow.h",
|
||||
"unicode.cc",
|
||||
"unicode.h",
|
||||
"unicode_data.cc",
|
||||
"uri.cc",
|
||||
"uri.h",
|
||||
|
|
Loading…
Reference in a new issue