From 8448f57b2a0119b1fde1e93545f01dcbb696459d Mon Sep 17 00:00:00 2001 From: ccalvarin Date: Fri, 6 Apr 2018 12:42:09 -0700 Subject: Remove die() and replace it with BAZEL_DIE, part of the logging framework. This will mean the messages will make it to the right output stream. RELNOTES: PiperOrigin-RevId: 191925662 --- third_party/ijar/BUILD | 3 ++ third_party/ijar/mapped_file_windows.cc | 88 +++++++++++++++++---------------- third_party/ijar/platform_utils.cc | 5 +- 3 files changed, 51 insertions(+), 45 deletions(-) (limited to 'third_party/ijar') diff --git a/third_party/ijar/BUILD b/third_party/ijar/BUILD index 90f74c5407..96f4066c01 100644 --- a/third_party/ijar/BUILD +++ b/third_party/ijar/BUILD @@ -31,6 +31,8 @@ cc_library( "//src:windows": [ "//src/main/cpp/util:errors", "//src/main/cpp/util:file", + "//src/main/cpp/util:logging", + "//src/main/cpp/util:strings", ], "//conditions:default": [ ], @@ -58,6 +60,7 @@ cc_library( deps = [ "//src/main/cpp/util:errors", "//src/main/cpp/util:file", + "//src/main/cpp/util:logging", ], ) diff --git a/third_party/ijar/mapped_file_windows.cc b/third_party/ijar/mapped_file_windows.cc index 6292605e86..b3327ed89d 100644 --- a/third_party/ijar/mapped_file_windows.cc +++ b/third_party/ijar/mapped_file_windows.cc @@ -19,12 +19,15 @@ #include "src/main/cpp/util/errors.h" #include "src/main/cpp/util/file_platform.h" +#include "src/main/cpp/util/logging.h" +#include "src/main/cpp/util/strings.h" #include "third_party/ijar/mapped_file.h" #define MAX_ERROR 2048 namespace devtools_ijar { +using std::string; using std::wstring; static char errmsg[MAX_ERROR] = ""; @@ -46,36 +49,37 @@ MappedInputFile::MappedInputFile(const char* name) { wstring wname; if (!blaze_util::AsAbsoluteWindowsPath(name, &wname)) { - blaze_util::die(255, - "MappedInputFile(%s): AsAbsoluteWindowsPath failed: %s", - name, blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedInputFile(" << name + << "): AsAbsoluteWindowsPath failed: " + << blaze_util::GetLastErrorString(); } HANDLE file = CreateFileW(wname.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (file == INVALID_HANDLE_VALUE) { - blaze_util::die(255, "MappedInputFile(%s): CreateFileW(%S) failed: %s", - name, wname.c_str(), - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedInputFile(" << name << "): CreateFileW(" + << blaze_util::WstringToString(wname) + << ") failed: " << blaze_util::GetLastErrorString(); } LARGE_INTEGER size; if (!GetFileSizeEx(file, &size)) { - blaze_util::die(255, "MappedInputFile(%s): GetFileSizeEx failed: %s", name, - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedInputFile(" << name << "): GetFileSizeEx failed: " + << blaze_util::GetLastErrorString(); } HANDLE mapping = CreateFileMapping(file, NULL, PAGE_READONLY, size.HighPart, size.LowPart, NULL); if (mapping == NULL || mapping == INVALID_HANDLE_VALUE) { - blaze_util::die(255, "MappedInputFile(%s): CreateFileMapping failed: %s", - name), - blaze_util::GetLastErrorString().c_str(); + BAZEL_DIE(255) << "MappedInputFile(" << name + << "): CreateFileMapping failed: " + << blaze_util::GetLastErrorString(); } void *view = MapViewOfFileEx(mapping, FILE_MAP_READ, 0, 0, 0, NULL); if (view == NULL) { - blaze_util::die(255, "MappedInputFile(%s): MapViewOfFileEx failed: %s", - name, blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedInputFile(" << name + << "): MapViewOfFileEx failed: " + << blaze_util::GetLastErrorString(); } impl_ = new MappedInputFileImpl(file, mapping); @@ -96,20 +100,18 @@ void MappedInputFile::Discard(size_t bytes) { int MappedInputFile::Close() { if (!UnmapViewOfFile(buffer_)) { - blaze_util::die(255, "MappedInputFile::Close: UnmapViewOfFile failed: %s", - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedInputFile::Close: UnmapViewOfFile failed: " + << blaze_util::GetLastErrorString(); } if (!CloseHandle(impl_->mapping_)) { - blaze_util::die( - 255, "MappedInputFile::Close: CloseHandle for mapping failed: %s", - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedInputFile::Close: CloseHandle for mapping failed: " + << blaze_util::GetLastErrorString(); } if (!CloseHandle(impl_->file_)) { - blaze_util::die(255, - "MappedInputFile::Close: CloseHandle for file failed: %s", - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedInputFile::Close: CloseHandle for file failed: " + << blaze_util::GetLastErrorString(); } return 0; @@ -132,29 +134,30 @@ MappedOutputFile::MappedOutputFile(const char* name, size_t estimated_size) { wstring wname; if (!blaze_util::AsAbsoluteWindowsPath(name, &wname)) { - blaze_util::die(255, - "MappedOutputFile(%s): AsAbsoluteWindowsPath failed: %s", - name, blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedOutputFile(" << name + << "): AsAbsoluteWindowsPath failed: " + << blaze_util::GetLastErrorString(); } HANDLE file = CreateFileW(wname.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if (file == INVALID_HANDLE_VALUE) { - blaze_util::die(255, "MappedOutputFile(%s): CreateFileW(%S) failed: %s", - name, wname.c_str(), - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedOutputFile(" << name << "): CreateFileW(" + << blaze_util::WstringToString(wname) + << ") failed: " << blaze_util::GetLastErrorString(); } HANDLE mapping = CreateFileMapping(file, NULL, PAGE_READWRITE, estimated_size >> 32, estimated_size & 0xffffffffUL, NULL); if (mapping == NULL || mapping == INVALID_HANDLE_VALUE) { - blaze_util::die(255, "MappedOutputFile(%s): CreateFileMapping failed: %s", - name); + BAZEL_DIE(255) << "MappedOutputFile(" << name + << "): CreateFileMapping failed: "; } void *view = MapViewOfFileEx(mapping, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL); if (view == NULL) { - blaze_util::die(255, "MappedOutputFile(%s): MapViewOfFileEx failed: %s", - name, blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedOutputFile(" << name + << "): MapViewOfFileEx failed: " + << blaze_util::GetLastErrorString(); CloseHandle(mapping); CloseHandle(file); return; @@ -171,30 +174,29 @@ MappedOutputFile::~MappedOutputFile() { int MappedOutputFile::Close(size_t size) { if (!UnmapViewOfFile(buffer_)) { - blaze_util::die(255, "MappedOutputFile::Close: UnmapViewOfFile failed: %s", - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedOutputFile::Close: UnmapViewOfFile failed: " + << blaze_util::GetLastErrorString(); } if (!CloseHandle(impl_->mapping_)) { - blaze_util::die( - 255, "MappedOutputFile::Close: CloseHandle for mapping failed: %s", - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) + << "MappedOutputFile::Close: CloseHandle for mapping failed: " + << blaze_util::GetLastErrorString(); } if (!SetFilePointer(impl_->file_, size, NULL, FILE_BEGIN)) { - blaze_util::die(255, "MappedOutputFile::Close: SetFilePointer failed: %s", - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedOutputFile::Close: SetFilePointer failed: " + << blaze_util::GetLastErrorString(); } if (!SetEndOfFile(impl_->file_)) { - blaze_util::die(255, "MappedOutputFile::Close: SetEndOfFile failed: %s", - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedOutputFile::Close: SetEndOfFile failed: " + << blaze_util::GetLastErrorString(); } if (!CloseHandle(impl_->file_)) { - blaze_util::die(255, - "MappedOutputFile::Close: CloseHandle for file failed: %s", - blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "MappedOutputFile::Close: CloseHandle for file failed: " + << blaze_util::GetLastErrorString(); } return 0; diff --git a/third_party/ijar/platform_utils.cc b/third_party/ijar/platform_utils.cc index 09818f7162..9633eb7cee 100644 --- a/third_party/ijar/platform_utils.cc +++ b/third_party/ijar/platform_utils.cc @@ -30,6 +30,7 @@ #include "src/main/cpp/util/errors.h" #include "src/main/cpp/util/file.h" #include "src/main/cpp/util/file_platform.h" +#include "src/main/cpp/util/logging.h" namespace devtools_ijar { @@ -39,8 +40,8 @@ bool stat_file(const char* path, Stat* result) { #if defined(COMPILER_MSVC) || defined(__CYGWIN__) std::wstring wpath; if (!blaze_util::AsAbsoluteWindowsPath(path, &wpath)) { - blaze_util::die(255, "stat_file: AsAbsoluteWindowsPath(%s) failed: %s", - path, blaze_util::GetLastErrorString().c_str()); + BAZEL_DIE(255) << "stat_file: AsAbsoluteWindowsPath(" << path + << ") failed: " << blaze_util::GetLastErrorString(); } bool success = false; BY_HANDLE_FILE_INFORMATION info; -- cgit v1.2.3