blob: 1039ff13e1be1471889db7fa73b151edfc88a57e [file] [log] [blame]
Brian Carlstrom934486c2011-07-12 23:42:50 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
Brian Carlstromb0460ea2011-07-29 10:08:05 -07003#include <dirent.h>
Elliott Hughes0af55432011-08-17 18:37:28 -07004#include <dlfcn.h>
Brian Carlstrom27ec9612011-09-19 20:20:38 -07005#include <sys/mman.h>
Brian Carlstromb0460ea2011-07-29 10:08:05 -07006#include <sys/stat.h>
7#include <sys/types.h>
8
Elliott Hughes90a33692011-08-30 13:27:07 -07009#include "UniquePtr.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070010#include "base64.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070011#include "class_linker.h"
Brian Carlstrom1f870082011-08-23 16:02:11 -070012#include "class_loader.h"
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -070013#include "compiler.h"
Ian Rogers2c8f6532011-09-02 17:16:34 -070014#include "constants.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070015#include "dex_file.h"
Brian Carlstrom33f741e2011-10-03 11:24:05 -070016#include "file.h"
Elliott Hughes90a33692011-08-30 13:27:07 -070017#include "gtest/gtest.h"
Brian Carlstrom1f870082011-08-23 16:02:11 -070018#include "heap.h"
Brian Carlstrom3320cf42011-10-04 14:58:28 -070019#include "oat_file.h"
Brian Carlstrom33f741e2011-10-03 11:24:05 -070020#include "os.h"
Brian Carlstrom1f870082011-08-23 16:02:11 -070021#include "runtime.h"
Elliott Hughes14134a12011-09-30 16:55:51 -070022#include "stl_util.h"
Elliott Hughes90a33692011-08-30 13:27:07 -070023#include "stringprintf.h"
24#include "thread.h"
Elliott Hughes0af55432011-08-17 18:37:28 -070025#include "unicode/uclean.h"
26#include "unicode/uvernum.h"
27
Brian Carlstrom934486c2011-07-12 23:42:50 -070028namespace art {
29
Brian Carlstrom9f30b382011-08-28 22:41:38 -070030static inline const DexFile* OpenDexFileBase64(const char* base64,
31 const std::string& location) {
Brian Carlstrom33f741e2011-10-03 11:24:05 -070032 // decode base64
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070033 CHECK(base64 != NULL);
34 size_t length;
Brian Carlstromf615a612011-07-23 12:50:34 -070035 byte* dex_bytes = DecodeBase64(base64, &length);
36 CHECK(dex_bytes != NULL);
Brian Carlstrom33f741e2011-10-03 11:24:05 -070037
38 // write to provided file
39 UniquePtr<File> file(OS::OpenFile(location.c_str(), true));
40 CHECK(file.get() != NULL);
41 if (!file->WriteFully(dex_bytes, length)) {
42 PLOG(FATAL) << "Failed to write base64 as dex file";
43 }
44 file.reset();
45
46 // read dex file
Brian Carlstrom58ae9412011-10-04 00:56:06 -070047 const DexFile* dex_file = DexFile::Open(location, "");
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070048 CHECK(dex_file != NULL);
Brian Carlstromf615a612011-07-23 12:50:34 -070049 return dex_file;
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070050}
51
Brian Carlstromdb4d5402011-08-09 12:18:28 -070052class ScratchFile {
53 public:
54 ScratchFile() {
Elliott Hughes34023802011-08-30 12:06:17 -070055 filename_ = getenv("ANDROID_DATA");
56 filename_ += "/TmpFile-XXXXXX";
57 fd_ = mkstemp(&filename_[0]);
Brian Carlstromdb4d5402011-08-09 12:18:28 -070058 CHECK_NE(-1, fd_);
59 }
60
61 ~ScratchFile() {
Elliott Hughes34023802011-08-30 12:06:17 -070062 int unlink_result = unlink(filename_.c_str());
Brian Carlstromdb4d5402011-08-09 12:18:28 -070063 CHECK_EQ(0, unlink_result);
64 int close_result = close(fd_);
65 CHECK_EQ(0, close_result);
66 }
67
68 const char* GetFilename() const {
Elliott Hughes34023802011-08-30 12:06:17 -070069 return filename_.c_str();
Brian Carlstromdb4d5402011-08-09 12:18:28 -070070 }
71
72 int GetFd() const {
73 return fd_;
74 }
75
76 private:
Elliott Hughes34023802011-08-30 12:06:17 -070077 std::string filename_;
Brian Carlstromdb4d5402011-08-09 12:18:28 -070078 int fd_;
79};
80
Brian Carlstromf734cf52011-08-17 16:28:14 -070081class CommonTest : public testing::Test {
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -070082 public:
Brian Carlstrom3320cf42011-10-04 14:58:28 -070083
84 static void MakeExecutable(const ByteArray* code_array) {
85 CHECK(code_array != NULL);
86 MakeExecutable(code_array->GetData(), code_array->GetLength());
87 }
88
89 static void MakeExecutable(const std::vector<uint8_t>& code) {
90 CHECK_NE(code.size(), 0U);
91 MakeExecutable(&code[0], code.size());
92 }
93
94 void MakeExecutable(Method* method) {
95 CHECK(method != NULL);
96
97 const CompiledInvokeStub* compiled_invoke_stub = compiler_->GetCompiledInvokeStub(method);
98 CHECK(compiled_invoke_stub != NULL) << PrettyMethod(method);
99 const std::vector<uint8_t>& invoke_stub = compiled_invoke_stub->GetCode();
100 MakeExecutable(invoke_stub);
101 const Method::InvokeStub* method_invoke_stub
102 = reinterpret_cast<const Method::InvokeStub*>(&invoke_stub[0]);
103 LOG(INFO) << "MakeExecutable " << PrettyMethod(method)
104 << " invoke_stub=" << reinterpret_cast<void*>(method_invoke_stub);
105
106 if (!method->IsAbstract()) {
107 const CompiledMethod* compiled_method = compiler_->GetCompiledMethod(method);
108 CHECK(compiled_method != NULL) << PrettyMethod(method);
109 const std::vector<uint8_t>& code = compiled_method->GetCode();
110 MakeExecutable(code);
111 const void* method_code
112 = CompiledMethod::CodePointer(&code[0], compiled_method->GetInstructionSet());
113 LOG(INFO) << "MakeExecutable " << PrettyMethod(method) << " code=" << method_code;
114 OatFile::OatMethod oat_method(method_code,
115 compiled_method->GetFrameSizeInBytes(),
116 compiled_method->GetReturnPcOffsetInBytes(),
117 compiled_method->GetCoreSpillMask(),
118 compiled_method->GetFpSpillMask(),
119 &compiled_method->GetMappingTable()[0],
120 &compiled_method->GetVmapTable()[0],
121 method_invoke_stub);
122 oat_method.LinkMethod(method);
123 } else {
124 MakeExecutable(runtime_->GetAbstractMethodErrorStubArray());
125 const void* method_code = runtime_->GetAbstractMethodErrorStubArray()->GetData();
126 LOG(INFO) << "MakeExecutable " << PrettyMethod(method) << " code=" << method_code;
127 OatFile::OatMethod oat_method(method_code,
128 kStackAlignment,
129 0,
130 0,
131 0,
132 NULL,
133 NULL,
134 method_invoke_stub);
135 oat_method.LinkMethod(method);
136 }
137 }
138
139 static void MakeExecutable(const void* code_start, size_t code_length) {
140 CHECK(code_start != NULL);
141 CHECK_NE(code_length, 0U);
142 uintptr_t data = reinterpret_cast<uintptr_t>(code_start);
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700143 uintptr_t base = RoundDown(data, kPageSize);
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700144 uintptr_t limit = RoundUp(data + code_length, kPageSize);
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700145 uintptr_t len = limit - base;
146 int result = mprotect(reinterpret_cast<void*>(base), len, PROT_READ | PROT_WRITE | PROT_EXEC);
147 CHECK_EQ(result, 0);
148 }
149
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700150 protected:
151 virtual void SetUp() {
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700152 is_host_ = getenv("ANDROID_BUILD_TOP") != NULL;
153
Elliott Hughes0af55432011-08-17 18:37:28 -0700154 if (is_host_) {
155 // $ANDROID_ROOT is set on the device, but not on the host.
156 // We need to set this so that icu4c can find its locale data.
157 std::string root;
158 root += getenv("ANDROID_BUILD_TOP");
159 root += "/out/host/linux-x86";
160 setenv("ANDROID_ROOT", root.c_str(), 1);
161 }
162
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700163 // On target, Cannot use /mnt/sdcard because it is mounted noexec, so use subdir of art-cache
164 android_data_ = (is_host_ ? "/tmp/art-data-XXXXXX" : "/data/art-cache/art-data-XXXXXX");
Elliott Hughes0f4c41d2011-09-04 14:58:03 -0700165 if (mkdtemp(&android_data_[0]) == NULL) {
166 PLOG(FATAL) << "mkdtemp(\"" << &android_data_[0] << "\") failed";
167 }
Elliott Hughes34023802011-08-30 12:06:17 -0700168 setenv("ANDROID_DATA", android_data_.c_str(), 1);
169 art_cache_.append(android_data_.c_str());
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700170 art_cache_.append("/art-cache");
171 int mkdir_result = mkdir(art_cache_.c_str(), 0700);
172 ASSERT_EQ(mkdir_result, 0);
173
Elliott Hughesa5b897e2011-08-16 11:33:06 -0700174 java_lang_dex_file_.reset(GetLibCoreDex());
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700175
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700176 std::string boot_class_path;
177 boot_class_path += "-Xbootclasspath:";
178 boot_class_path += GetLibCoreDexFileName();
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700179
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700180 Runtime::Options options;
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700181 options.push_back(std::make_pair(boot_class_path.c_str(), reinterpret_cast<void*>(NULL)));
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700182 options.push_back(std::make_pair("-Xcheck:jni", reinterpret_cast<void*>(NULL)));
Brian Carlstrome24fa612011-09-29 00:53:55 -0700183 options.push_back(std::make_pair("-Xms64m", reinterpret_cast<void*>(NULL)));
184 options.push_back(std::make_pair("-Xmx64m", reinterpret_cast<void*>(NULL)));
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700185 runtime_.reset(Runtime::Create(options, false));
Elliott Hughes90a33692011-08-30 13:27:07 -0700186 ASSERT_TRUE(runtime_.get() != NULL);
Carl Shapiro7a909592011-07-24 19:21:59 -0700187 class_linker_ = runtime_->GetClassLinker();
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700188
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700189 InstructionSet instruction_set = kNone;
Ian Rogers2c8f6532011-09-02 17:16:34 -0700190#if defined(__i386__)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700191 instruction_set = kX86;
Ian Rogers2c8f6532011-09-02 17:16:34 -0700192#elif defined(__arm__)
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700193 instruction_set = kThumb2;
Ian Rogers2c8f6532011-09-02 17:16:34 -0700194#endif
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700195 runtime_->SetJniStubArray(JniCompiler::CreateJniStub(instruction_set));
196 runtime_->SetAbstractMethodErrorStubArray(Compiler::CreateAbstractMethodErrorStub(instruction_set));
197 for (int i=0; i < Runtime::kLastTrampolineMethodType; i++) {
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700198 Runtime::TrampolineType type = Runtime::TrampolineType(i);
199 if (!runtime_->HasResolutionStubArray(type)) {
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700200 runtime_->SetResolutionStubArray(
201 Compiler::CreateResolutionStub(instruction_set, type), type);
Ian Rogers1cb0a1d2011-10-06 15:24:35 -0700202 }
203 }
Ian Rogers4f0d07c2011-10-06 23:38:47 -0700204 for (int i=0; i < Runtime::kLastCalleeSaveType; i++) {
205 Runtime::CalleeSaveType type = Runtime::CalleeSaveType(i);
206 if (!runtime_->HasCalleeSaveMethod(type)) {
207 runtime_->SetCalleeSaveMethod(
208 runtime_->CreateCalleeSaveMethod(instruction_set, type), type);
209 }
210 }
211 compiler_.reset(new Compiler(instruction_set));
Ian Rogers2c8f6532011-09-02 17:16:34 -0700212
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700213 Heap::VerifyHeap(); // Check for heap corruption before the test
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700214 }
215
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700216 virtual void TearDown() {
217 const char* android_data = getenv("ANDROID_DATA");
218 ASSERT_TRUE(android_data != NULL);
219 DIR* dir = opendir(art_cache_.c_str());
220 ASSERT_TRUE(dir != NULL);
221 while (true) {
222 struct dirent entry;
223 struct dirent* entry_ptr;
224 int readdir_result = readdir_r(dir, &entry, &entry_ptr);
225 ASSERT_EQ(0, readdir_result);
226 if (entry_ptr == NULL) {
227 break;
228 }
229 if ((strcmp(entry_ptr->d_name, ".") == 0) || (strcmp(entry_ptr->d_name, "..") == 0)) {
230 continue;
231 }
232 std::string filename(art_cache_);
233 filename.push_back('/');
234 filename.append(entry_ptr->d_name);
235 int unlink_result = unlink(filename.c_str());
236 ASSERT_EQ(0, unlink_result);
Jesse Wilsonac5b9e22011-07-27 15:11:13 -0400237 }
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700238 closedir(dir);
239 int rmdir_cache_result = rmdir(art_cache_.c_str());
240 ASSERT_EQ(0, rmdir_cache_result);
Elliott Hughes34023802011-08-30 12:06:17 -0700241 int rmdir_data_result = rmdir(android_data_.c_str());
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700242 ASSERT_EQ(0, rmdir_data_result);
Elliott Hughes0af55432011-08-17 18:37:28 -0700243
244 // icu4c has a fixed 10-element array "gCommonICUDataArray".
245 // If we run > 10 tests, we fill that array and u_setCommonData fails.
246 // There's a function to clear the array, but it's not public...
247 typedef void (*IcuCleanupFn)();
248 void* sym = dlsym(RTLD_DEFAULT, "u_cleanup_" U_ICU_VERSION_SHORT);
249 CHECK(sym != NULL);
250 IcuCleanupFn icu_cleanup_fn = reinterpret_cast<IcuCleanupFn>(sym);
251 (*icu_cleanup_fn)();
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700252
Ian Rogers0e073f72011-09-09 10:45:46 -0700253 compiler_.reset();
Ian Rogers2c8f6532011-09-02 17:16:34 -0700254
Ian Rogers0cfe1fb2011-08-26 03:29:44 -0700255 Heap::VerifyHeap(); // Check for heap corruption after the test
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700256 }
Jesse Wilsonac5b9e22011-07-27 15:11:13 -0400257
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700258 std::string GetLibCoreDexFileName() {
259 if (is_host_) {
260 const char* host_dir = getenv("ANDROID_HOST_OUT");
261 CHECK(host_dir != NULL);
262 return StringPrintf("%s/framework/core-hostdex.jar", host_dir);
263 }
264 return std::string("/system/framework/core.jar");
265 }
266
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700267 const DexFile* GetLibCoreDex() {
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700268 std::string libcore_dex_file_name = GetLibCoreDexFileName();
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700269 return DexFile::Open(libcore_dex_file_name, "");
Jesse Wilsonac5b9e22011-07-27 15:11:13 -0400270 }
271
Brian Carlstrom848a4b32011-09-04 11:29:27 -0700272 uint32_t FindTypeIdxByDescriptor(const DexFile& dex_file, const StringPiece& descriptor) {
273 for (size_t i = 0; i < dex_file.NumTypeIds(); i++) {
274 const DexFile::TypeId& type_id = dex_file.GetTypeId(i);
275 if (descriptor == dex_file.GetTypeDescriptor(type_id)) {
276 return i;
277 }
278 }
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700279 CHECK(false) << "Failed to find type index for " << descriptor;
Brian Carlstrom848a4b32011-09-04 11:29:27 -0700280 return 0;
281 }
282
283 uint32_t FindFieldIdxByDescriptorAndName(const DexFile& dex_file,
284 const StringPiece& class_descriptor,
285 const StringPiece& field_name) {
286 for (size_t i = 0; i < dex_file.NumFieldIds(); i++) {
287 const DexFile::FieldId& field_id = dex_file.GetFieldId(i);
288 if (class_descriptor == dex_file.GetFieldClassDescriptor(field_id)
289 && field_name == dex_file.GetFieldName(field_id)) {
290 return i;
291 }
292 }
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700293 CHECK(false) << "Failed to find field index for " << class_descriptor << " " << field_name;
Brian Carlstrom848a4b32011-09-04 11:29:27 -0700294 return 0;
295 }
296
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700297 const ClassLoader* AllocPathClassLoader(const DexFile* dex_file) {
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700298 CHECK(dex_file != NULL);
299 class_linker_->RegisterDexFile(*dex_file);
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700300 std::vector<const DexFile*> dex_files;
301 dex_files.push_back(dex_file);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700302 return PathClassLoader::Alloc(dex_files);
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700303 }
304
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700305 const DexFile* OpenTestDexFile(const char* name) {
306 CHECK(name != NULL);
307 std::string filename;
308 if (is_host_) {
309 // on the host, just read target dex file
310 filename += getenv("ANDROID_PRODUCT_OUT");
311 }
312 filename += "/system/framework/art-test-dex-";
313 filename += name;
314 filename += ".jar";
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700315 const DexFile* dex_file = DexFile::Open(filename, "");
Brian Carlstrom69b15fb2011-09-03 12:25:21 -0700316 CHECK(dex_file != NULL) << "Failed to open " << filename;
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700317 return dex_file;
318 }
319
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700320 const ClassLoader* LoadDex(const char* dex_name) {
321 const DexFile* dex_file = OpenTestDexFile(dex_name);
322 CHECK(dex_file != NULL);
323 loaded_dex_files_.push_back(dex_file);
324 class_linker_->RegisterDexFile(*dex_file);
325 std::vector<const DexFile*> class_path;
326 class_path.push_back(dex_file);
327 const ClassLoader* class_loader = PathClassLoader::Alloc(class_path);
328 CHECK(class_loader != NULL);
329 Thread::Current()->SetClassLoaderOverride(class_loader);
330 return class_loader;
331 }
332
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700333 void CompileMethod(Method* method) {
334 CHECK(method != NULL);
Ian Rogers2c8f6532011-09-02 17:16:34 -0700335 compiler_->CompileOne(method);
Brian Carlstrom3320cf42011-10-04 14:58:28 -0700336 MakeExecutable(method);
337
Brian Carlstrom16192862011-09-12 17:50:06 -0700338 MakeExecutable(runtime_->GetJniStubArray());
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700339 }
340
341 void CompileDirectMethod(const ClassLoader* class_loader,
342 const char* class_name,
343 const char* method_name,
344 const char* signature) {
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700345 std::string class_descriptor = DotToDescriptor(class_name);
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700346 Class* klass = class_linker_->FindClass(class_descriptor, class_loader);
347 CHECK(klass != NULL) << "Class not found " << class_name;
348 Method* method = klass->FindDirectMethod(method_name, signature);
Elliott Hughes0f4c41d2011-09-04 14:58:03 -0700349 CHECK(method != NULL) << "Direct method not found: "
350 << class_name << "." << method_name << signature;
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700351 CompileMethod(method);
352 }
353
354 void CompileVirtualMethod(const ClassLoader* class_loader,
355 const char* class_name,
356 const char* method_name,
357 const char* signature) {
Brian Carlstromf91c8c32011-09-21 17:30:34 -0700358 std::string class_descriptor = DotToDescriptor(class_name);
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700359 Class* klass = class_linker_->FindClass(class_descriptor, class_loader);
360 CHECK(klass != NULL) << "Class not found " << class_name;
361 Method* method = klass->FindVirtualMethod(method_name, signature);
Elliott Hughes0f4c41d2011-09-04 14:58:03 -0700362 CHECK(method != NULL) << "Virtual method not found: "
363 << class_name << "." << method_name << signature;
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700364 CompileMethod(method);
365 }
366
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700367 bool is_host_;
Elliott Hughes34023802011-08-30 12:06:17 -0700368 std::string android_data_;
Brian Carlstromb0460ea2011-07-29 10:08:05 -0700369 std::string art_cache_;
Elliott Hughes90a33692011-08-30 13:27:07 -0700370 UniquePtr<const DexFile> java_lang_dex_file_;
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700371 std::vector<const DexFile*> boot_class_path_;
Elliott Hughes90a33692011-08-30 13:27:07 -0700372 UniquePtr<Runtime> runtime_;
Ian Rogers0e073f72011-09-09 10:45:46 -0700373 // Owned by the runtime
Carl Shapiro7a909592011-07-24 19:21:59 -0700374 ClassLinker* class_linker_;
Ian Rogers0e073f72011-09-09 10:45:46 -0700375 UniquePtr<Compiler> compiler_;
Brian Carlstrom9baa4ae2011-09-01 21:14:14 -0700376
377 private:
378 std::vector<const DexFile*> loaded_dex_files_;
Brian Carlstrom578bbdc2011-07-21 14:07:47 -0700379};
380
Brian Carlstrom934486c2011-07-12 23:42:50 -0700381} // namespace art
Elliott Hughes34023802011-08-30 12:06:17 -0700382
383namespace std {
384
385// TODO: isn't gtest supposed to be able to print STL types for itself?
386template <typename T>
387std::ostream& operator<<(std::ostream& os, const std::vector<T>& rhs) {
Elliott Hughes14134a12011-09-30 16:55:51 -0700388 os << ::art::ToString(rhs);
Elliott Hughes34023802011-08-30 12:06:17 -0700389 return os;
390}
391
392} // namespace std