diff options
| author | 2017-04-27 19:54:29 +0000 | |
|---|---|---|
| committer | 2017-04-27 19:54:31 +0000 | |
| commit | 04471122e705aba2b3b30651457097a8f3ac97b6 (patch) | |
| tree | a0a72bfbaeff39ad8efe8ce9dbe8a3ec74f808f7 | |
| parent | 34ed966ae7e232817dd70afb924518b7cb8fb6a9 (diff) | |
| parent | fd80b17832b793801f10fa90e1d98324a3405e21 (diff) | |
Merge changes If6bd630c,Iade01cd5,I2ca823e1,Ib2899bce,I123f30f9
* changes:
ART: Blacklist dex2oat test under sanitization
ART: Fix leaks in oat symbolizer
ART: Free resources in dexlayout
ART: Destroy temporary holder in dex_ir
ART: Shut down runtime in dexoptanalyzer
| -rw-r--r-- | dex2oat/dex2oat_test.cc | 1 | ||||
| -rw-r--r-- | dexlayout/Android.bp | 1 | ||||
| -rw-r--r-- | dexlayout/dex_ir.cc | 4 | ||||
| -rw-r--r-- | dexlayout/dexlayout_main.cc | 12 | ||||
| -rw-r--r-- | dexoptanalyzer/dexoptanalyzer.cc | 2 | ||||
| -rw-r--r-- | oatdump/oatdump.cc | 39 |
6 files changed, 41 insertions, 18 deletions
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc index a267766456..d546072f58 100644 --- a/dex2oat/dex2oat_test.cc +++ b/dex2oat/dex2oat_test.cc @@ -884,6 +884,7 @@ class Dex2oatReturnCodeTest : public Dex2oatTest { }; TEST_F(Dex2oatReturnCodeTest, TestCreateRuntime) { + TEST_DISABLED_FOR_MEMORY_TOOL(); // b/19100793 int status = RunTest({ "--boot-image=/this/does/not/exist/yolo.oat" }); EXPECT_EQ(static_cast<int>(dex2oat::ReturnCode::kCreateRuntime), WEXITSTATUS(status)) << output_; } diff --git a/dexlayout/Android.bp b/dexlayout/Android.bp index 4b65c5299a..a2116cdc93 100644 --- a/dexlayout/Android.bp +++ b/dexlayout/Android.bp @@ -49,6 +49,7 @@ art_cc_binary { shared_libs: [ "libart", "libart-dexlayout", + "libbase", ], } diff --git a/dexlayout/dex_ir.cc b/dexlayout/dex_ir.cc index 3f715cf37f..f1c6f67a7c 100644 --- a/dexlayout/dex_ir.cc +++ b/dexlayout/dex_ir.cc @@ -451,8 +451,8 @@ AnnotationItem* Collections::CreateAnnotationItem(const DexFile::AnnotationItem* } uint8_t visibility = annotation->visibility_; const uint8_t* annotation_data = annotation->annotation_; - EncodedValue* encoded_value = - ReadEncodedValue(&annotation_data, DexFile::kDexAnnotationAnnotation, 0); + std::unique_ptr<EncodedValue> encoded_value( + ReadEncodedValue(&annotation_data, DexFile::kDexAnnotationAnnotation, 0)); // TODO: Calculate the size of the annotation. AnnotationItem* annotation_item = new AnnotationItem(visibility, encoded_value->ReleaseEncodedAnnotation()); diff --git a/dexlayout/dexlayout_main.cc b/dexlayout/dexlayout_main.cc index 38faf9688b..3c627ea6f0 100644 --- a/dexlayout/dexlayout_main.cc +++ b/dexlayout/dexlayout_main.cc @@ -170,14 +170,14 @@ int DexlayoutDriver(int argc, char** argv) { } // Open profile file. - ProfileCompilationInfo* profile_info = nullptr; + std::unique_ptr<ProfileCompilationInfo> profile_info; if (options.profile_file_name_) { int profile_fd = open(options.profile_file_name_, O_RDONLY); if (profile_fd < 0) { fprintf(stderr, "Can't open %s\n", options.profile_file_name_); return 1; } - profile_info = new ProfileCompilationInfo(); + profile_info.reset(new ProfileCompilationInfo()); if (!profile_info->Load(profile_fd)) { fprintf(stderr, "Can't read profile info from %s\n", options.profile_file_name_); return 1; @@ -185,13 +185,19 @@ int DexlayoutDriver(int argc, char** argv) { } // Create DexLayout instance. - DexLayout dex_layout(options, profile_info, out_file); + DexLayout dex_layout(options, profile_info.get(), out_file); // Process all files supplied on command line. int result = 0; while (optind < argc) { result |= dex_layout.ProcessFile(argv[optind++]); } // while + + if (options.output_file_name_) { + CHECK(out_file != nullptr && out_file != stdout); + fclose(out_file); + } + return result != 0; } diff --git a/dexoptanalyzer/dexoptanalyzer.cc b/dexoptanalyzer/dexoptanalyzer.cc index 965e4073ea..9a2eb7f8dd 100644 --- a/dexoptanalyzer/dexoptanalyzer.cc +++ b/dexoptanalyzer/dexoptanalyzer.cc @@ -216,6 +216,8 @@ class DexoptAnalyzer FINAL { if (!CreateRuntime()) { return kErrorCannotCreateRuntime; } + std::unique_ptr<Runtime> runtime(Runtime::Current()); + OatFileAssistant oat_file_assistant(dex_file_.c_str(), isa_, /*load_executable*/ false); // Always treat elements of the bootclasspath as up-to-date. // TODO(calin): this check should be in OatFileAssistant. diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index 878d0f2cfe..f07e0f9941 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -125,9 +125,12 @@ class OatSymbolizer FINAL { std::unique_ptr<const InstructionSetFeatures> features = InstructionSetFeatures::FromBitmap( isa, oat_file_->GetOatHeader().GetInstructionSetFeaturesBitmap()); - File* elf_file = OS::CreateEmptyFile(output_name_.c_str()); + std::unique_ptr<File> elf_file(OS::CreateEmptyFile(output_name_.c_str())); + if (elf_file == nullptr) { + return false; + } std::unique_ptr<BufferedOutputStream> output_stream( - MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(elf_file))); + MakeUnique<BufferedOutputStream>(MakeUnique<FileOutputStream>(elf_file.get()))); builder_.reset(new ElfBuilder<ElfTypes>(isa, features.get(), output_stream.get())); builder_->Start(); @@ -182,7 +185,17 @@ class OatSymbolizer FINAL { builder_->End(); - return builder_->Good(); + bool ret_value = builder_->Good(); + + builder_.reset(); + output_stream.reset(); + + if (elf_file->FlushCloseOrErase() != 0) { + return false; + } + elf_file.reset(); + + return ret_value; } void Walk() { @@ -2842,14 +2855,14 @@ static int DumpOat(Runtime* runtime, const char* oat_filename, OatDumperOptions* static int SymbolizeOat(const char* oat_filename, std::string& output_name, bool no_bits) { std::string error_msg; - OatFile* oat_file = OatFile::Open(oat_filename, - oat_filename, - nullptr, - nullptr, - false, - /*low_4gb*/false, - nullptr, - &error_msg); + std::unique_ptr<OatFile> oat_file(OatFile::Open(oat_filename, + oat_filename, + nullptr, + nullptr, + false, + /*low_4gb*/false, + nullptr, + &error_msg)); if (oat_file == nullptr) { fprintf(stderr, "Failed to open oat file from '%s': %s\n", oat_filename, error_msg.c_str()); return EXIT_FAILURE; @@ -2859,10 +2872,10 @@ static int SymbolizeOat(const char* oat_filename, std::string& output_name, bool // Try to produce an ELF file of the same type. This is finicky, as we have used 32-bit ELF // files for 64-bit code in the past. if (Is64BitInstructionSet(oat_file->GetOatHeader().GetInstructionSet())) { - OatSymbolizer<ElfTypes64> oat_symbolizer(oat_file, output_name, no_bits); + OatSymbolizer<ElfTypes64> oat_symbolizer(oat_file.get(), output_name, no_bits); result = oat_symbolizer.Symbolize(); } else { - OatSymbolizer<ElfTypes32> oat_symbolizer(oat_file, output_name, no_bits); + OatSymbolizer<ElfTypes32> oat_symbolizer(oat_file.get(), output_name, no_bits); result = oat_symbolizer.Symbolize(); } if (!result) { |