return result;
}
- int DumpOneProfile(const std::string& banner, const std::string& filename, int fd,
- const std::vector<const DexFile*>* dex_files, std::string* dump) {
+ int DumpOneProfile(const std::string& banner,
+ const std::string& filename,
+ int fd,
+ const std::vector<std::unique_ptr<const DexFile>>* dex_files,
+ std::string* dump) {
if (!filename.empty()) {
fd = open(filename.c_str(), O_RDWR);
if (fd < 0) {
// Open apk/zip files and and read dex files.
MemMap::Init(); // for ZipArchive::OpenFromFd
- std::vector<const DexFile*> dex_files;
+ std::vector<std::unique_ptr<const DexFile>> dex_files;
assert(dex_locations_.size() == apks_fd_.size());
static constexpr bool kVerifyChecksum = true;
for (size_t i = 0; i < dex_locations_.size(); ++i) {
continue;
}
for (std::unique_ptr<const DexFile>& dex_file : dex_files_for_location) {
- dex_files.push_back(dex_file.release());
+ dex_files.emplace_back(std::move(dex_file));
}
}
return total;
}
+// Produce a non-owning vector from a vector.
+template<typename T>
+const std::vector<T*>* MakeNonOwningVector(const std::vector<std::unique_ptr<T>>* owning_vector) {
+ auto non_owning_vector = new std::vector<T*>();
+ for (auto& element : *owning_vector) {
+ non_owning_vector->push_back(element.get());
+ }
+ return non_owning_vector;
+}
+
+std::string ProfileCompilationInfo::DumpInfo(
+ const std::vector<std::unique_ptr<const DexFile>>* dex_files,
+ bool print_full_dex_location) const {
+ std::unique_ptr<const std::vector<const DexFile*>> non_owning_dex_files(
+ MakeNonOwningVector(dex_files));
+ return DumpInfo(non_owning_dex_files.get(), print_full_dex_location);
+}
+
std::string ProfileCompilationInfo::DumpInfo(const std::vector<const DexFile*>* dex_files,
bool print_full_dex_location) const {
std::ostringstream os;
#ifndef ART_RUNTIME_JIT_PROFILE_COMPILATION_INFO_H_
#define ART_RUNTIME_JIT_PROFILE_COMPILATION_INFO_H_
+#include <memory>
#include <set>
#include <vector>
// If dex_files is not null then the method indices will be resolved to their
// names.
// This is intended for testing and debugging.
+ std::string DumpInfo(const std::vector<std::unique_ptr<const DexFile>>* dex_files,
+ bool print_full_dex_location = true) const;
std::string DumpInfo(const std::vector<const DexFile*>* dex_files,
bool print_full_dex_location = true) const;