blob: 1c8a8925d870e083b35fb3061cfb9daa592c336c [file] [log] [blame]
Elliott Hugheseb02a122012-06-12 11:35:40 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Ian Rogerse63db272014-07-15 15:36:11 -070017#include "common_runtime_test.h"
18
19#include <dirent.h>
20#include <dlfcn.h>
21#include <fcntl.h>
22#include <ScopedLocalRef.h>
Andreas Gampe369810a2015-01-14 19:53:31 -080023#include <stdlib.h>
Ian Rogerse63db272014-07-15 15:36:11 -070024
25#include "../../external/icu/icu4c/source/common/unicode/uvernum.h"
Andreas Gampe1fe5e5c2014-07-11 21:14:35 -070026#include "base/macros.h"
Elliott Hughes07ed66b2012-12-12 18:34:25 -080027#include "base/logging.h"
Ian Rogerse63db272014-07-15 15:36:11 -070028#include "base/stl_util.h"
29#include "base/stringprintf.h"
30#include "base/unix_file/fd_file.h"
31#include "class_linker.h"
32#include "compiler_callbacks.h"
33#include "dex_file.h"
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070034#include "gc_root-inl.h"
Ian Rogerse63db272014-07-15 15:36:11 -070035#include "gc/heap.h"
Elliott Hugheseb02a122012-06-12 11:35:40 -070036#include "gtest/gtest.h"
Ian Rogerse63db272014-07-15 15:36:11 -070037#include "jni_internal.h"
38#include "mirror/class_loader.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080039#include "mem_map.h"
Ian Rogerse63db272014-07-15 15:36:11 -070040#include "noop_compiler_callbacks.h"
41#include "os.h"
42#include "runtime-inl.h"
43#include "scoped_thread_state_change.h"
44#include "thread.h"
45#include "well_known_classes.h"
Elliott Hugheseb02a122012-06-12 11:35:40 -070046
47int main(int argc, char **argv) {
Andreas Gampe369810a2015-01-14 19:53:31 -080048 // Gtests can be very noisy. For example, an executable with multiple tests will trigger native
49 // bridge warnings. The following line reduces the minimum log severity to ERROR and suppresses
50 // everything else. In case you want to see all messages, comment out the line.
51 setenv("ANDROID_LOG_TAGS", "*:e", 1);
52
Elliott Hugheseb02a122012-06-12 11:35:40 -070053 art::InitLogging(argv);
Ian Rogersc7dd2952014-10-21 23:31:19 -070054 LOG(::art::INFO) << "Running main() from common_runtime_test.cc...";
Elliott Hugheseb02a122012-06-12 11:35:40 -070055 testing::InitGoogleTest(&argc, argv);
56 return RUN_ALL_TESTS();
57}
Ian Rogerse63db272014-07-15 15:36:11 -070058
59namespace art {
60
61ScratchFile::ScratchFile() {
62 // ANDROID_DATA needs to be set
63 CHECK_NE(static_cast<char*>(nullptr), getenv("ANDROID_DATA")) <<
64 "Are you subclassing RuntimeTest?";
65 filename_ = getenv("ANDROID_DATA");
66 filename_ += "/TmpFile-XXXXXX";
67 int fd = mkstemp(&filename_[0]);
68 CHECK_NE(-1, fd);
Andreas Gampe4303ba92014-11-06 01:00:46 -080069 file_.reset(new File(fd, GetFilename(), true));
Ian Rogerse63db272014-07-15 15:36:11 -070070}
71
72ScratchFile::ScratchFile(const ScratchFile& other, const char* suffix) {
73 filename_ = other.GetFilename();
74 filename_ += suffix;
75 int fd = open(filename_.c_str(), O_RDWR | O_CREAT, 0666);
76 CHECK_NE(-1, fd);
Andreas Gampe4303ba92014-11-06 01:00:46 -080077 file_.reset(new File(fd, GetFilename(), true));
Ian Rogerse63db272014-07-15 15:36:11 -070078}
79
80ScratchFile::ScratchFile(File* file) {
81 CHECK(file != NULL);
82 filename_ = file->GetPath();
83 file_.reset(file);
84}
85
86ScratchFile::~ScratchFile() {
87 Unlink();
88}
89
90int ScratchFile::GetFd() const {
91 return file_->Fd();
92}
93
Andreas Gampee21dc3d2014-12-08 16:59:43 -080094void ScratchFile::Close() {
Andreas Gampe4303ba92014-11-06 01:00:46 -080095 if (file_.get() != nullptr) {
96 if (file_->FlushCloseOrErase() != 0) {
97 PLOG(WARNING) << "Error closing scratch file.";
98 }
99 }
Andreas Gampee21dc3d2014-12-08 16:59:43 -0800100}
101
102void ScratchFile::Unlink() {
103 if (!OS::FileExists(filename_.c_str())) {
104 return;
105 }
106 Close();
Ian Rogerse63db272014-07-15 15:36:11 -0700107 int unlink_result = unlink(filename_.c_str());
108 CHECK_EQ(0, unlink_result);
109}
110
111CommonRuntimeTest::CommonRuntimeTest() {}
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800112CommonRuntimeTest::~CommonRuntimeTest() {
113 // Ensure the dex files are cleaned up before the runtime.
114 loaded_dex_files_.clear();
115 runtime_.reset();
116}
Ian Rogerse63db272014-07-15 15:36:11 -0700117
Andreas Gampe7747c8d2014-08-06 14:53:03 -0700118void CommonRuntimeTest::SetUpAndroidRoot() {
Ian Rogerse63db272014-07-15 15:36:11 -0700119 if (IsHost()) {
120 // $ANDROID_ROOT is set on the device, but not necessarily on the host.
121 // But it needs to be set so that icu4c can find its locale data.
122 const char* android_root_from_env = getenv("ANDROID_ROOT");
123 if (android_root_from_env == nullptr) {
124 // Use ANDROID_HOST_OUT for ANDROID_ROOT if it is set.
125 const char* android_host_out = getenv("ANDROID_HOST_OUT");
126 if (android_host_out != nullptr) {
127 setenv("ANDROID_ROOT", android_host_out, 1);
128 } else {
129 // Build it from ANDROID_BUILD_TOP or cwd
130 std::string root;
131 const char* android_build_top = getenv("ANDROID_BUILD_TOP");
132 if (android_build_top != nullptr) {
133 root += android_build_top;
134 } else {
135 // Not set by build server, so default to current directory
136 char* cwd = getcwd(nullptr, 0);
137 setenv("ANDROID_BUILD_TOP", cwd, 1);
138 root += cwd;
139 free(cwd);
140 }
141#if defined(__linux__)
142 root += "/out/host/linux-x86";
143#elif defined(__APPLE__)
144 root += "/out/host/darwin-x86";
145#else
146#error unsupported OS
147#endif
148 setenv("ANDROID_ROOT", root.c_str(), 1);
149 }
150 }
151 setenv("LD_LIBRARY_PATH", ":", 0); // Required by java.lang.System.<clinit>.
152
153 // Not set by build server, so default
154 if (getenv("ANDROID_HOST_OUT") == nullptr) {
155 setenv("ANDROID_HOST_OUT", getenv("ANDROID_ROOT"), 1);
156 }
157 }
Andreas Gampe7747c8d2014-08-06 14:53:03 -0700158}
Ian Rogerse63db272014-07-15 15:36:11 -0700159
Andreas Gampe7747c8d2014-08-06 14:53:03 -0700160void CommonRuntimeTest::SetUpAndroidData(std::string& android_data) {
Ian Rogerse63db272014-07-15 15:36:11 -0700161 // On target, Cannot use /mnt/sdcard because it is mounted noexec, so use subdir of dalvik-cache
Andreas Gampe5a79fde2014-08-06 13:12:26 -0700162 if (IsHost()) {
163 const char* tmpdir = getenv("TMPDIR");
164 if (tmpdir != nullptr && tmpdir[0] != 0) {
165 android_data = tmpdir;
166 } else {
167 android_data = "/tmp";
168 }
169 } else {
170 android_data = "/data/dalvik-cache";
171 }
172 android_data += "/art-data-XXXXXX";
Ian Rogerse63db272014-07-15 15:36:11 -0700173 if (mkdtemp(&android_data[0]) == nullptr) {
174 PLOG(FATAL) << "mkdtemp(\"" << &android_data[0] << "\") failed";
175 }
176 setenv("ANDROID_DATA", android_data.c_str(), 1);
177}
178
Andreas Gampe7747c8d2014-08-06 14:53:03 -0700179void CommonRuntimeTest::TearDownAndroidData(const std::string& android_data, bool fail_on_error) {
180 if (fail_on_error) {
181 ASSERT_EQ(rmdir(android_data.c_str()), 0);
182 } else {
183 rmdir(android_data.c_str());
184 }
185}
186
Igor Murashkin37743352014-11-13 14:38:00 -0800187std::string CommonRuntimeTest::GetCoreArtLocation() {
188 return GetCoreFileLocation("art");
189}
190
191std::string CommonRuntimeTest::GetCoreOatLocation() {
192 return GetCoreFileLocation("oat");
193}
Andreas Gampe7747c8d2014-08-06 14:53:03 -0700194
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800195std::unique_ptr<const DexFile> CommonRuntimeTest::LoadExpectSingleDexFile(const char* location) {
196 std::vector<std::unique_ptr<const DexFile>> dex_files;
Ian Rogerse63db272014-07-15 15:36:11 -0700197 std::string error_msg;
Richard Uhler66d874d2015-01-15 09:37:19 -0800198 MemMap::Init();
Ian Rogerse63db272014-07-15 15:36:11 -0700199 if (!DexFile::Open(location, location, &error_msg, &dex_files)) {
200 LOG(FATAL) << "Could not open .dex file '" << location << "': " << error_msg << "\n";
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800201 UNREACHABLE();
Ian Rogerse63db272014-07-15 15:36:11 -0700202 } else {
203 CHECK_EQ(1U, dex_files.size()) << "Expected only one dex file in " << location;
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800204 return std::move(dex_files[0]);
Ian Rogerse63db272014-07-15 15:36:11 -0700205 }
206}
207
208void CommonRuntimeTest::SetUp() {
Andreas Gampe7747c8d2014-08-06 14:53:03 -0700209 SetUpAndroidRoot();
210 SetUpAndroidData(android_data_);
Ian Rogerse63db272014-07-15 15:36:11 -0700211 dalvik_cache_.append(android_data_.c_str());
212 dalvik_cache_.append("/dalvik-cache");
213 int mkdir_result = mkdir(dalvik_cache_.c_str(), 0700);
214 ASSERT_EQ(mkdir_result, 0);
215
Ian Rogerse63db272014-07-15 15:36:11 -0700216 std::string min_heap_string(StringPrintf("-Xms%zdm", gc::Heap::kDefaultInitialSize / MB));
217 std::string max_heap_string(StringPrintf("-Xmx%zdm", gc::Heap::kDefaultMaximumSize / MB));
218
219 callbacks_.reset(new NoopCompilerCallbacks());
220
221 RuntimeOptions options;
Richard Uhlerc2752592015-01-02 13:28:22 -0800222 std::string boot_class_path_string = "-Xbootclasspath:" + GetLibCoreDexFileName();
223 options.push_back(std::make_pair(boot_class_path_string, nullptr));
Ian Rogerse63db272014-07-15 15:36:11 -0700224 options.push_back(std::make_pair("-Xcheck:jni", nullptr));
Richard Uhlerc2752592015-01-02 13:28:22 -0800225 options.push_back(std::make_pair(min_heap_string, nullptr));
226 options.push_back(std::make_pair(max_heap_string, nullptr));
Ian Rogerse63db272014-07-15 15:36:11 -0700227 options.push_back(std::make_pair("compilercallbacks", callbacks_.get()));
228 SetUpRuntimeOptions(&options);
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800229
Richard Uhler66d874d2015-01-15 09:37:19 -0800230 PreRuntimeCreate();
Ian Rogerse63db272014-07-15 15:36:11 -0700231 if (!Runtime::Create(options, false)) {
232 LOG(FATAL) << "Failed to create runtime";
233 return;
234 }
Richard Uhler66d874d2015-01-15 09:37:19 -0800235 PostRuntimeCreate();
Ian Rogerse63db272014-07-15 15:36:11 -0700236 runtime_.reset(Runtime::Current());
237 class_linker_ = runtime_->GetClassLinker();
238 class_linker_->FixupDexCaches(runtime_->GetResolutionMethod());
239 class_linker_->RunRootClinits();
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800240 boot_class_path_ = class_linker_->GetBootClassPath();
241 java_lang_dex_file_ = boot_class_path_[0];
242
Ian Rogerse63db272014-07-15 15:36:11 -0700243
244 // Runtime::Create acquired the mutator_lock_ that is normally given away when we
245 // Runtime::Start, give it away now and then switch to a more managable ScopedObjectAccess.
246 Thread::Current()->TransitionFromRunnableToSuspended(kNative);
247
248 // We're back in native, take the opportunity to initialize well known classes.
249 WellKnownClasses::Init(Thread::Current()->GetJniEnv());
250
251 // Create the heap thread pool so that the GC runs in parallel for tests. Normally, the thread
252 // pool is created by the runtime.
253 runtime_->GetHeap()->CreateThreadPool();
254 runtime_->GetHeap()->VerifyHeap(); // Check for heap corruption before the test
Richard Uhlerc2752592015-01-02 13:28:22 -0800255
256 // Get the boot class path from the runtime so it can be used in tests.
257 boot_class_path_ = class_linker_->GetBootClassPath();
258 ASSERT_FALSE(boot_class_path_.empty());
259 java_lang_dex_file_ = boot_class_path_[0];
Ian Rogerse63db272014-07-15 15:36:11 -0700260}
261
Alex Lighta59dd802014-07-02 16:28:08 -0700262void CommonRuntimeTest::ClearDirectory(const char* dirpath) {
263 ASSERT_TRUE(dirpath != nullptr);
264 DIR* dir = opendir(dirpath);
Ian Rogerse63db272014-07-15 15:36:11 -0700265 ASSERT_TRUE(dir != nullptr);
266 dirent* e;
Alex Lighta59dd802014-07-02 16:28:08 -0700267 struct stat s;
Ian Rogerse63db272014-07-15 15:36:11 -0700268 while ((e = readdir(dir)) != nullptr) {
269 if ((strcmp(e->d_name, ".") == 0) || (strcmp(e->d_name, "..") == 0)) {
270 continue;
271 }
Jeff Haof0a3f092014-07-24 16:26:09 -0700272 std::string filename(dirpath);
Ian Rogerse63db272014-07-15 15:36:11 -0700273 filename.push_back('/');
274 filename.append(e->d_name);
Alex Lighta59dd802014-07-02 16:28:08 -0700275 int stat_result = lstat(filename.c_str(), &s);
276 ASSERT_EQ(0, stat_result) << "unable to stat " << filename;
277 if (S_ISDIR(s.st_mode)) {
278 ClearDirectory(filename.c_str());
279 int rmdir_result = rmdir(filename.c_str());
280 ASSERT_EQ(0, rmdir_result) << filename;
281 } else {
282 int unlink_result = unlink(filename.c_str());
283 ASSERT_EQ(0, unlink_result) << filename;
284 }
Ian Rogerse63db272014-07-15 15:36:11 -0700285 }
286 closedir(dir);
Alex Lighta59dd802014-07-02 16:28:08 -0700287}
288
289void CommonRuntimeTest::TearDown() {
290 const char* android_data = getenv("ANDROID_DATA");
291 ASSERT_TRUE(android_data != nullptr);
292 ClearDirectory(dalvik_cache_.c_str());
Ian Rogerse63db272014-07-15 15:36:11 -0700293 int rmdir_cache_result = rmdir(dalvik_cache_.c_str());
294 ASSERT_EQ(0, rmdir_cache_result);
Andreas Gampe7747c8d2014-08-06 14:53:03 -0700295 TearDownAndroidData(android_data_, true);
Ian Rogerse63db272014-07-15 15:36:11 -0700296
297 // icu4c has a fixed 10-element array "gCommonICUDataArray".
298 // If we run > 10 tests, we fill that array and u_setCommonData fails.
299 // There's a function to clear the array, but it's not public...
300 typedef void (*IcuCleanupFn)();
301 void* sym = dlsym(RTLD_DEFAULT, "u_cleanup_" U_ICU_VERSION_SHORT);
302 CHECK(sym != nullptr) << dlerror();
303 IcuCleanupFn icu_cleanup_fn = reinterpret_cast<IcuCleanupFn>(sym);
304 (*icu_cleanup_fn)();
305
Ian Rogerse63db272014-07-15 15:36:11 -0700306 Runtime::Current()->GetHeap()->VerifyHeap(); // Check for heap corruption after the test
307}
308
309std::string CommonRuntimeTest::GetLibCoreDexFileName() {
310 return GetDexFileName("core-libart");
311}
312
313std::string CommonRuntimeTest::GetDexFileName(const std::string& jar_prefix) {
314 if (IsHost()) {
315 const char* host_dir = getenv("ANDROID_HOST_OUT");
316 CHECK(host_dir != nullptr);
317 return StringPrintf("%s/framework/%s-hostdex.jar", host_dir, jar_prefix.c_str());
318 }
319 return StringPrintf("%s/framework/%s.jar", GetAndroidRoot(), jar_prefix.c_str());
320}
321
322std::string CommonRuntimeTest::GetTestAndroidRoot() {
323 if (IsHost()) {
324 const char* host_dir = getenv("ANDROID_HOST_OUT");
325 CHECK(host_dir != nullptr);
326 return host_dir;
327 }
328 return GetAndroidRoot();
329}
330
Andreas Gampe1fe5e5c2014-07-11 21:14:35 -0700331// Check that for target builds we have ART_TARGET_NATIVETEST_DIR set.
332#ifdef ART_TARGET
333#ifndef ART_TARGET_NATIVETEST_DIR
334#error "ART_TARGET_NATIVETEST_DIR not set."
335#endif
336// Wrap it as a string literal.
337#define ART_TARGET_NATIVETEST_DIR_STRING STRINGIFY(ART_TARGET_NATIVETEST_DIR) "/"
338#else
339#define ART_TARGET_NATIVETEST_DIR_STRING ""
340#endif
341
Richard Uhler66d874d2015-01-15 09:37:19 -0800342std::string CommonRuntimeTest::GetTestDexFileName(const char* name) {
Ian Rogerse63db272014-07-15 15:36:11 -0700343 CHECK(name != nullptr);
344 std::string filename;
345 if (IsHost()) {
346 filename += getenv("ANDROID_HOST_OUT");
347 filename += "/framework/";
348 } else {
Andreas Gampe1fe5e5c2014-07-11 21:14:35 -0700349 filename += ART_TARGET_NATIVETEST_DIR_STRING;
Ian Rogerse63db272014-07-15 15:36:11 -0700350 }
351 filename += "art-gtest-";
352 filename += name;
353 filename += ".jar";
Richard Uhler66d874d2015-01-15 09:37:19 -0800354 return filename;
355}
356
357std::vector<std::unique_ptr<const DexFile>> CommonRuntimeTest::OpenTestDexFiles(const char* name) {
358 std::string filename = GetTestDexFileName(name);
Ian Rogerse63db272014-07-15 15:36:11 -0700359 std::string error_msg;
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800360 std::vector<std::unique_ptr<const DexFile>> dex_files;
Ian Rogerse63db272014-07-15 15:36:11 -0700361 bool success = DexFile::Open(filename.c_str(), filename.c_str(), &error_msg, &dex_files);
362 CHECK(success) << "Failed to open '" << filename << "': " << error_msg;
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800363 for (auto& dex_file : dex_files) {
Ian Rogerse63db272014-07-15 15:36:11 -0700364 CHECK_EQ(PROT_READ, dex_file->GetPermissions());
365 CHECK(dex_file->IsReadOnly());
366 }
Ian Rogerse63db272014-07-15 15:36:11 -0700367 return dex_files;
368}
369
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800370std::unique_ptr<const DexFile> CommonRuntimeTest::OpenTestDexFile(const char* name) {
371 std::vector<std::unique_ptr<const DexFile>> vector = OpenTestDexFiles(name);
Ian Rogerse63db272014-07-15 15:36:11 -0700372 EXPECT_EQ(1U, vector.size());
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800373 return std::move(vector[0]);
Ian Rogerse63db272014-07-15 15:36:11 -0700374}
375
376jobject CommonRuntimeTest::LoadDex(const char* dex_name) {
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800377 std::vector<std::unique_ptr<const DexFile>> dex_files = OpenTestDexFiles(dex_name);
378 std::vector<const DexFile*> class_path;
Ian Rogerse63db272014-07-15 15:36:11 -0700379 CHECK_NE(0U, dex_files.size());
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800380 for (auto& dex_file : dex_files) {
381 class_path.push_back(dex_file.get());
Ian Rogerse63db272014-07-15 15:36:11 -0700382 class_linker_->RegisterDexFile(*dex_file);
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800383 loaded_dex_files_.push_back(std::move(dex_file));
Ian Rogerse63db272014-07-15 15:36:11 -0700384 }
Ian Rogers68d8b422014-07-17 11:09:10 -0700385 Thread* self = Thread::Current();
386 JNIEnvExt* env = self->GetJniEnv();
387 ScopedLocalRef<jobject> class_loader_local(env,
388 env->AllocObject(WellKnownClasses::dalvik_system_PathClassLoader));
389 jobject class_loader = env->NewGlobalRef(class_loader_local.get());
390 self->SetClassLoaderOverride(class_loader_local.get());
Richard Uhlerfbef44d2014-12-23 09:48:51 -0800391 Runtime::Current()->SetCompileTimeClassPath(class_loader, class_path);
Ian Rogerse63db272014-07-15 15:36:11 -0700392 return class_loader;
393}
394
Igor Murashkin37743352014-11-13 14:38:00 -0800395std::string CommonRuntimeTest::GetCoreFileLocation(const char* suffix) {
396 CHECK(suffix != nullptr);
397
398 std::string location;
399 if (IsHost()) {
400 const char* host_dir = getenv("ANDROID_HOST_OUT");
401 CHECK(host_dir != NULL);
402 location = StringPrintf("%s/framework/core.%s", host_dir, suffix);
403 } else {
404 location = StringPrintf("/data/art-test/core.%s", suffix);
405 }
406
407 return location;
408}
409
Ian Rogerse63db272014-07-15 15:36:11 -0700410CheckJniAbortCatcher::CheckJniAbortCatcher() : vm_(Runtime::Current()->GetJavaVM()) {
Ian Rogers68d8b422014-07-17 11:09:10 -0700411 vm_->SetCheckJniAbortHook(Hook, &actual_);
Ian Rogerse63db272014-07-15 15:36:11 -0700412}
413
414CheckJniAbortCatcher::~CheckJniAbortCatcher() {
Ian Rogers68d8b422014-07-17 11:09:10 -0700415 vm_->SetCheckJniAbortHook(nullptr, nullptr);
Ian Rogerse63db272014-07-15 15:36:11 -0700416 EXPECT_TRUE(actual_.empty()) << actual_;
417}
418
419void CheckJniAbortCatcher::Check(const char* expected_text) {
420 EXPECT_TRUE(actual_.find(expected_text) != std::string::npos) << "\n"
421 << "Expected to find: " << expected_text << "\n"
422 << "In the output : " << actual_;
423 actual_.clear();
424}
425
426void CheckJniAbortCatcher::Hook(void* data, const std::string& reason) {
427 // We use += because when we're hooking the aborts like this, multiple problems can be found.
428 *reinterpret_cast<std::string*>(data) += reason;
429}
430
431} // namespace art
432
433namespace std {
434
435template <typename T>
436std::ostream& operator<<(std::ostream& os, const std::vector<T>& rhs) {
437os << ::art::ToString(rhs);
438return os;
439}
440
441} // namespace std