blob: e4aba3f8adae10e31ee61c2fe31f52cd4a09e44e [file] [log] [blame]
Richard Uhler66d874d2015-01-15 09:37:19 -08001/*
2 * Copyright (C) 2014 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
17#ifndef ART_RUNTIME_OAT_FILE_ASSISTANT_H_
18#define ART_RUNTIME_OAT_FILE_ASSISTANT_H_
19
20#include <cstdint>
21#include <memory>
Narayan Kamath8943c1d2016-05-02 13:14:48 +010022#include <sstream>
Richard Uhler66d874d2015-01-15 09:37:19 -080023#include <string>
24
25#include "arch/instruction_set.h"
26#include "base/scoped_flock.h"
27#include "base/unix_file/fd_file.h"
Andreas Gampe29d38e72016-03-23 15:31:51 +000028#include "compiler_filter.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080029#include "oat_file.h"
30#include "os.h"
Richard Uhler66d874d2015-01-15 09:37:19 -080031
32namespace art {
33
Mathieu Chartierfbc31082016-01-24 11:59:56 -080034namespace gc {
35namespace space {
36class ImageSpace;
37} // namespace space
38} // namespace gc
39
Richard Uhler66d874d2015-01-15 09:37:19 -080040// Class for assisting with oat file management.
41//
42// This class collects common utilities for determining the status of an oat
43// file on the device, updating the oat file, and loading the oat file.
44//
45// The oat file assistant is intended to be used with dex locations not on the
46// boot class path. See the IsInBootClassPath method for a way to check if the
47// dex location is in the boot class path.
Richard Uhler66d874d2015-01-15 09:37:19 -080048class OatFileAssistant {
49 public:
Richard Uhler95abd042015-03-24 09:51:28 -070050 enum DexOptNeeded {
51 // kNoDexOptNeeded - The code for this dex location is up to date and can
52 // be used as is.
53 // Matches Java: dalvik.system.DexFile.NO_DEXOPT_NEEDED = 0
54 kNoDexOptNeeded = 0,
Richard Uhler66d874d2015-01-15 09:37:19 -080055
Richard Uhler95abd042015-03-24 09:51:28 -070056 // kDex2OatNeeded - In order to make the code for this dex location up to
57 // date, dex2oat must be run on the dex file.
58 // Matches Java: dalvik.system.DexFile.DEX2OAT_NEEDED = 1
59 kDex2OatNeeded = 1,
Richard Uhler66d874d2015-01-15 09:37:19 -080060
Richard Uhler95abd042015-03-24 09:51:28 -070061 // kPatchOatNeeded - In order to make the code for this dex location up to
62 // date, patchoat must be run on the odex file.
63 // Matches Java: dalvik.system.DexFile.PATCHOAT_NEEDED = 2
64 kPatchOatNeeded = 2,
65
66 // kSelfPatchOatNeeded - In order to make the code for this dex location
67 // up to date, patchoat must be run on the oat file.
68 // Matches Java: dalvik.system.DexFile.SELF_PATCHOAT_NEEDED = 3
69 kSelfPatchOatNeeded = 3,
70 };
71
72 enum OatStatus {
73 // kOatOutOfDate - An oat file is said to be out of date if the file does
Calin Juravleb077e152016-02-18 18:47:37 +000074 // not exist, is out of date with respect to the dex file or boot image,
75 // or does not meet the target compilation type.
Richard Uhler95abd042015-03-24 09:51:28 -070076 kOatOutOfDate,
77
78 // kOatNeedsRelocation - An oat file is said to need relocation if the
79 // code is up to date, but not yet properly relocated for address space
80 // layout randomization (ASLR). In this case, the oat file is neither
81 // "out of date" nor "up to date".
82 kOatNeedsRelocation,
83
84 // kOatUpToDate - An oat file is said to be up to date if it is not out of
Richard Uhler66d874d2015-01-15 09:37:19 -080085 // date and has been properly relocated for the purposes of ASLR.
Richard Uhler95abd042015-03-24 09:51:28 -070086 kOatUpToDate,
Richard Uhler66d874d2015-01-15 09:37:19 -080087 };
88
89 // Constructs an OatFileAssistant object to assist the oat file
90 // corresponding to the given dex location with the target instruction set.
91 //
Mathieu Chartier2cebb242015-04-21 16:50:40 -070092 // The dex_location must not be null and should remain available and
Richard Uhler66d874d2015-01-15 09:37:19 -080093 // unchanged for the duration of the lifetime of the OatFileAssistant object.
94 // Typically the dex_location is the absolute path to the original,
95 // un-optimized dex file.
96 //
Richard Uhler66d874d2015-01-15 09:37:19 -080097 // Note: Currently the dex_location must have an extension.
98 // TODO: Relax this restriction?
99 //
100 // The isa should be either the 32 bit or 64 bit variant for the current
101 // device. For example, on an arm device, use arm or arm64. An oat file can
102 // be loaded executable only if the ISA matches the current runtime.
Andreas Gampe29d38e72016-03-23 15:31:51 +0000103 //
Andreas Gampe29d38e72016-03-23 15:31:51 +0000104 // load_executable should be true if the caller intends to try and load
105 // executable code for this dex location.
Calin Juravleb077e152016-02-18 18:47:37 +0000106 OatFileAssistant(const char* dex_location,
Calin Juravleb077e152016-02-18 18:47:37 +0000107 const InstructionSet isa,
Richard Uhler66d874d2015-01-15 09:37:19 -0800108 bool load_executable);
109
110 // Constructs an OatFileAssistant, providing an explicit target oat_location
111 // to use instead of the standard oat location.
Calin Juravleb077e152016-02-18 18:47:37 +0000112 OatFileAssistant(const char* dex_location,
113 const char* oat_location,
Calin Juravleb077e152016-02-18 18:47:37 +0000114 const InstructionSet isa,
115 bool load_executable);
Richard Uhler66d874d2015-01-15 09:37:19 -0800116
117 ~OatFileAssistant();
118
119 // Returns true if the dex location refers to an element of the boot class
120 // path.
121 bool IsInBootClassPath();
122
123 // Obtains a lock on the target oat file.
124 // Only one OatFileAssistant object can hold the lock for a target oat file
125 // at a time. The Lock is released automatically when the OatFileAssistant
126 // object goes out of scope. The Lock() method must not be called if the
127 // lock has already been acquired.
128 //
129 // Returns true on success.
130 // Returns false on error, in which case error_msg will contain more
131 // information on the error.
132 //
133 // The 'error_msg' argument must not be null.
134 //
135 // This is intended to be used to avoid race conditions when multiple
136 // processes generate oat files, such as when a foreground Activity and
137 // a background Service both use DexClassLoaders pointing to the same dex
138 // file.
139 bool Lock(std::string* error_msg);
140
Richard Uhler95abd042015-03-24 09:51:28 -0700141 // Return what action needs to be taken to produce up-to-date code for this
Andreas Gampe29d38e72016-03-23 15:31:51 +0000142 // dex location that is at least as good as an oat file generated with the
Richard Uhlerd1472a22016-04-15 15:18:56 -0700143 // given compiler filter. profile_changed should be true to indicate the
144 // profile has recently changed for this dex location.
145 DexOptNeeded GetDexOptNeeded(CompilerFilter::Filter target_compiler_filter,
146 bool profile_changed = false);
Richard Uhler66d874d2015-01-15 09:37:19 -0800147
Richard Uhler01be6812016-05-17 10:34:52 -0700148 // Returns true if there is up-to-date code for this dex location,
149 // irrespective of the compiler filter of the up-to-date code.
150 bool IsUpToDate();
151
Richard Uhler1e860612016-03-30 12:17:55 -0700152 // Return code used when attempting to generate updated code.
153 enum ResultOfAttemptToUpdate {
154 kUpdateFailed, // We tried making the code up to date, but
155 // encountered an unexpected failure.
156 kUpdateNotAttempted, // We wanted to update the code, but determined we
157 // should not make the attempt.
158 kUpdateSucceeded // We successfully made the code up to date
159 // (possibly by doing nothing).
160 };
161
Richard Uhler66d874d2015-01-15 09:37:19 -0800162 // Attempts to generate or relocate the oat file as needed to make it up to
Richard Uhlerf4b34872016-04-13 11:03:46 -0700163 // date based on the current runtime and compiler options.
Richard Uhlerd1472a22016-04-15 15:18:56 -0700164 // profile_changed should be true to indicate the profile has recently
165 // changed for this dex location.
166 //
167 // Returns the result of attempting to update the code.
Richard Uhler66d874d2015-01-15 09:37:19 -0800168 //
Richard Uhler1e860612016-03-30 12:17:55 -0700169 // If the result is not kUpdateSucceeded, the value of error_msg will be set
170 // to a string describing why there was a failure or the update was not
171 // attempted. error_msg must not be null.
Richard Uhlerd1472a22016-04-15 15:18:56 -0700172 ResultOfAttemptToUpdate MakeUpToDate(bool profile_changed, std::string* error_msg);
Richard Uhler66d874d2015-01-15 09:37:19 -0800173
174 // Returns an oat file that can be used for loading dex files.
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700175 // Returns null if no suitable oat file was found.
Richard Uhler66d874d2015-01-15 09:37:19 -0800176 //
177 // After this call, no other methods of the OatFileAssistant should be
178 // called, because access to the loaded oat file has been taken away from
179 // the OatFileAssistant object.
180 std::unique_ptr<OatFile> GetBestOatFile();
181
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800182 // Open and returns an image space associated with the oat file.
Richard Uhler4c7f1932016-04-15 15:51:21 -0700183 static gc::space::ImageSpace* OpenImageSpace(const OatFile* oat_file);
Mathieu Chartierfbc31082016-01-24 11:59:56 -0800184
Richard Uhler66d874d2015-01-15 09:37:19 -0800185 // Loads the dex files in the given oat file for the given dex location.
186 // The oat file should be up to date for the given dex location.
187 // This loads multiple dex files in the case of multidex.
188 // Returns an empty vector if no dex files for that location could be loaded
189 // from the oat file.
190 //
191 // The caller is responsible for freeing the dex_files returned, if any. The
192 // dex_files will only remain valid as long as the oat_file is valid.
193 static std::vector<std::unique_ptr<const DexFile>> LoadDexFiles(
194 const OatFile& oat_file, const char* dex_location);
195
Richard Uhler9b994ea2015-06-24 08:44:19 -0700196 // Returns true if there are dex files in the original dex location that can
197 // be compiled with dex2oat for this dex location.
198 // Returns false if there is no original dex file, or if the original dex
199 // file is an apk/zip without a classes.dex entry.
200 bool HasOriginalDexFiles();
201
Richard Uhler63434112015-03-16 14:32:16 -0700202 // If the dex file has been installed with a compiled oat file alongside
203 // it, the compiled oat file will have the extension .odex, and is referred
204 // to as the odex file. It is called odex for legacy reasons; the file is
205 // really an oat file. The odex file will often, but not always, have a
206 // patch delta of 0 and need to be relocated before use for the purposes of
207 // ASLR. The odex file is treated as if it were read-only.
Richard Uhler66d874d2015-01-15 09:37:19 -0800208 // These methods return the location and status of the odex file for the dex
209 // location.
210 // Notes:
211 // * OdexFileName may return null if the odex file name could not be
212 // determined.
213 const std::string* OdexFileName();
214 bool OdexFileExists();
Richard Uhler95abd042015-03-24 09:51:28 -0700215 OatStatus OdexFileStatus();
Richard Uhler66d874d2015-01-15 09:37:19 -0800216 bool OdexFileIsOutOfDate();
217 bool OdexFileNeedsRelocation();
218 bool OdexFileIsUpToDate();
Narayan Kamath8943c1d2016-05-02 13:14:48 +0100219 // Must only be called if the associated odex file exists, i.e, if
220 // |OdexFileExists() == true|.
221 CompilerFilter::Filter OdexFileCompilerFilter();
Richard Uhler66d874d2015-01-15 09:37:19 -0800222
223 // When the dex files is compiled on the target device, the oat file is the
224 // result. The oat file will have been relocated to some
225 // (possibly-out-of-date) offset for ASLR.
226 // These methods return the location and status of the target oat file for
227 // the dex location.
228 //
229 // Notes:
Richard Uhler66d874d2015-01-15 09:37:19 -0800230 // * OatFileName may return null if the oat file name could not be
231 // determined.
232 const std::string* OatFileName();
233 bool OatFileExists();
Richard Uhler95abd042015-03-24 09:51:28 -0700234 OatStatus OatFileStatus();
Richard Uhler66d874d2015-01-15 09:37:19 -0800235 bool OatFileIsOutOfDate();
236 bool OatFileNeedsRelocation();
237 bool OatFileIsUpToDate();
Narayan Kamath8943c1d2016-05-02 13:14:48 +0100238 // Must only be called if the associated oat file exists, i.e, if
239 // |OatFileExists() == true|.
240 CompilerFilter::Filter OatFileCompilerFilter();
Richard Uhler66d874d2015-01-15 09:37:19 -0800241
Richard Uhlere8109f72016-04-18 10:40:50 -0700242 // Return the status for a given opened oat file with respect to the dex
243 // location.
Richard Uhler95abd042015-03-24 09:51:28 -0700244 OatStatus GivenOatFileStatus(const OatFile& file);
Richard Uhler66d874d2015-01-15 09:37:19 -0800245
Richard Uhler95abd042015-03-24 09:51:28 -0700246 // Generates the oat file by relocation from the named input file.
Richard Uhler66d874d2015-01-15 09:37:19 -0800247 // This does not check the current status before attempting to relocate the
248 // oat file.
Richard Uhler66d874d2015-01-15 09:37:19 -0800249 //
Richard Uhler1e860612016-03-30 12:17:55 -0700250 // If the result is not kUpdateSucceeded, the value of error_msg will be set
251 // to a string describing why there was a failure or the update was not
252 // attempted. error_msg must not be null.
253 ResultOfAttemptToUpdate RelocateOatFile(const std::string* input_file, std::string* error_msg);
Richard Uhler66d874d2015-01-15 09:37:19 -0800254
Richard Uhlerf4b34872016-04-13 11:03:46 -0700255 // Generate the oat file from the dex file using the current runtime
256 // compiler options.
Richard Uhler66d874d2015-01-15 09:37:19 -0800257 // This does not check the current status before attempting to generate the
258 // oat file.
Richard Uhler66d874d2015-01-15 09:37:19 -0800259 //
Richard Uhler1e860612016-03-30 12:17:55 -0700260 // If the result is not kUpdateSucceeded, the value of error_msg will be set
261 // to a string describing why there was a failure or the update was not
262 // attempted. error_msg must not be null.
Richard Uhlerf4b34872016-04-13 11:03:46 -0700263 ResultOfAttemptToUpdate GenerateOatFile(std::string* error_msg);
Richard Uhler66d874d2015-01-15 09:37:19 -0800264
265 // Executes dex2oat using the current runtime configuration overridden with
266 // the given arguments. This does not check to see if dex2oat is enabled in
267 // the runtime configuration.
268 // Returns true on success.
269 //
270 // If there is a failure, the value of error_msg will be set to a string
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700271 // describing why there was failure. error_msg must not be null.
Richard Uhler66d874d2015-01-15 09:37:19 -0800272 //
273 // TODO: The OatFileAssistant probably isn't the right place to have this
274 // function.
275 static bool Dex2Oat(const std::vector<std::string>& args, std::string* error_msg);
276
277 // Constructs the odex file name for the given dex location.
278 // Returns true on success, in which case odex_filename is set to the odex
279 // file name.
Richard Uhlere8e48ae2016-04-19 12:41:04 -0700280 // Returns false on error, in which case error_msg describes the error and
281 // odex_filename is not changed.
Richard Uhler66d874d2015-01-15 09:37:19 -0800282 // Neither odex_filename nor error_msg may be null.
283 static bool DexFilenameToOdexFilename(const std::string& location,
284 InstructionSet isa, std::string* odex_filename, std::string* error_msg);
285
Jeff Haofd336c32016-04-07 19:46:31 -0700286 static uint32_t CalculateCombinedImageChecksum(InstructionSet isa = kRuntimeISA);
Jeff Haob11ffb72016-04-07 15:40:54 -0700287
Richard Uhler66d874d2015-01-15 09:37:19 -0800288 private:
289 struct ImageInfo {
290 uint32_t oat_checksum = 0;
291 uintptr_t oat_data_begin = 0;
292 int32_t patch_delta = 0;
293 std::string location;
294 };
295
296 // Returns the path to the dalvik cache directory.
297 // Does not check existence of the cache or try to create it.
298 // Includes the trailing slash.
299 // Returns an empty string if we can't get the dalvik cache directory path.
300 std::string DalvikCacheDirectory();
301
Richard Uhler66d874d2015-01-15 09:37:19 -0800302 // Returns the current image location.
303 // Returns an empty string if the image location could not be retrieved.
304 //
305 // TODO: This method should belong with an image file manager, not
306 // the oat file assistant.
307 static std::string ImageLocation();
308
309 // Gets the dex checksum required for an up-to-date oat file.
310 // Returns dex_checksum if a required checksum was located. Returns
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700311 // null if the required checksum was not found.
Richard Uhler66d874d2015-01-15 09:37:19 -0800312 // The caller shouldn't clean up or free the returned pointer.
Richard Uhler9b994ea2015-06-24 08:44:19 -0700313 // This sets the has_original_dex_files_ field to true if a checksum was
314 // found for the dex_location_ dex file.
Richard Uhler66d874d2015-01-15 09:37:19 -0800315 const uint32_t* GetRequiredDexChecksum();
316
317 // Returns the loaded odex file.
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700318 // Loads the file if needed. Returns null if the file failed to load.
Richard Uhler66d874d2015-01-15 09:37:19 -0800319 // The caller shouldn't clean up or free the returned pointer.
320 const OatFile* GetOdexFile();
321
Andreas Gampe29d38e72016-03-23 15:31:51 +0000322 // Returns true if the compiler filter used to generate the odex file is at
Richard Uhlerd1472a22016-04-15 15:18:56 -0700323 // least as good as the given target filter. profile_changed should be true
324 // to indicate the profile has recently changed for this dex location.
325 bool OdexFileCompilerFilterIsOkay(CompilerFilter::Filter target, bool profile_changed);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000326
Richard Uhler5f946da2015-07-17 12:28:32 -0700327 // Returns true if the odex file is opened executable.
328 bool OdexFileIsExecutable();
329
Richard Uhlerd1537b52016-03-29 13:27:41 -0700330 // Returns true if the odex file has patch info required to run patchoat.
331 bool OdexFileHasPatchInfo();
332
Richard Uhler66d874d2015-01-15 09:37:19 -0800333 // Clear any cached information about the odex file that depends on the
334 // contents of the file.
335 void ClearOdexFileCache();
336
337 // Returns the loaded oat file.
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700338 // Loads the file if needed. Returns null if the file failed to load.
Richard Uhler66d874d2015-01-15 09:37:19 -0800339 // The caller shouldn't clean up or free the returned pointer.
340 const OatFile* GetOatFile();
341
Andreas Gampe29d38e72016-03-23 15:31:51 +0000342 // Returns true if the compiler filter used to generate the oat file is at
Richard Uhlerd1472a22016-04-15 15:18:56 -0700343 // least as good as the given target filter. profile_changed should be true
344 // to indicate the profile has recently changed for this dex location.
345 bool OatFileCompilerFilterIsOkay(CompilerFilter::Filter target, bool profile_changed);
Andreas Gampe29d38e72016-03-23 15:31:51 +0000346
Richard Uhler5f946da2015-07-17 12:28:32 -0700347 // Returns true if the oat file is opened executable.
348 bool OatFileIsExecutable();
349
Richard Uhlerd1537b52016-03-29 13:27:41 -0700350 // Returns true if the oat file has patch info required to run patchoat.
351 bool OatFileHasPatchInfo();
352
Richard Uhler66d874d2015-01-15 09:37:19 -0800353 // Clear any cached information about the oat file that depends on the
354 // contents of the file.
355 void ClearOatFileCache();
356
357 // Returns the loaded image info.
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700358 // Loads the image info if needed. Returns null if the image info failed
Richard Uhler66d874d2015-01-15 09:37:19 -0800359 // to load.
360 // The caller shouldn't clean up or free the returned pointer.
361 const ImageInfo* GetImageInfo();
362
Jeff Haob11ffb72016-04-07 15:40:54 -0700363 uint32_t GetCombinedImageChecksum();
364
Richard Uhler66d874d2015-01-15 09:37:19 -0800365 // To implement Lock(), we lock a dummy file where the oat file would go
366 // (adding ".flock" to the target file name) and retain the lock for the
367 // remaining lifetime of the OatFileAssistant object.
Richard Uhler66d874d2015-01-15 09:37:19 -0800368 ScopedFlock flock_;
369
Richard Uhler740eec92015-10-15 15:12:23 -0700370 std::string dex_location_;
Richard Uhler66d874d2015-01-15 09:37:19 -0800371
372 // In a properly constructed OatFileAssistant object, isa_ should be either
373 // the 32 or 64 bit variant for the current device.
374 const InstructionSet isa_ = kNone;
375
Richard Uhler66d874d2015-01-15 09:37:19 -0800376 // Whether we will attempt to load oat files executable.
377 bool load_executable_ = false;
378
379 // Cached value of the required dex checksum.
380 // This should be accessed only by the GetRequiredDexChecksum() method.
Richard Uhler9b994ea2015-06-24 08:44:19 -0700381 uint32_t cached_required_dex_checksum_;
382 bool required_dex_checksum_attempted_ = false;
383 bool required_dex_checksum_found_;
384 bool has_original_dex_files_;
Richard Uhler66d874d2015-01-15 09:37:19 -0800385
386 // Cached value of the odex file name.
387 // This should be accessed only by the OdexFileName() method.
Richard Uhlere8e48ae2016-04-19 12:41:04 -0700388 // The sentinel value "" is used if the odex file name could not be
389 // determined.
Richard Uhler66d874d2015-01-15 09:37:19 -0800390 bool cached_odex_file_name_attempted_ = false;
Richard Uhler66d874d2015-01-15 09:37:19 -0800391 std::string cached_odex_file_name_;
392
393 // Cached value of the loaded odex file.
394 // Use the GetOdexFile method rather than accessing this directly, unless you
395 // know the odex file isn't out of date.
396 bool odex_file_load_attempted_ = false;
397 std::unique_ptr<OatFile> cached_odex_file_;
398
Richard Uhlere8109f72016-04-18 10:40:50 -0700399 // Cached results for OdexFileStatus
400 bool odex_file_status_attempted_ = false;
401 OatStatus cached_odex_file_status_;
Richard Uhler66d874d2015-01-15 09:37:19 -0800402
403 // Cached value of the oat file name.
404 // This should be accessed only by the OatFileName() method.
Richard Uhlere8e48ae2016-04-19 12:41:04 -0700405 // The sentinel value "" is used if the oat file name could not be
406 // determined.
Richard Uhler66d874d2015-01-15 09:37:19 -0800407 bool cached_oat_file_name_attempted_ = false;
Richard Uhler66d874d2015-01-15 09:37:19 -0800408 std::string cached_oat_file_name_;
409
Richard Uhlerb361d942015-05-07 10:52:28 -0700410 // Cached value of the loaded oat file.
Richard Uhler66d874d2015-01-15 09:37:19 -0800411 // Use the GetOatFile method rather than accessing this directly, unless you
Richard Uhlerb361d942015-05-07 10:52:28 -0700412 // know the oat file isn't out of date.
Richard Uhler66d874d2015-01-15 09:37:19 -0800413 bool oat_file_load_attempted_ = false;
414 std::unique_ptr<OatFile> cached_oat_file_;
415
Richard Uhlere8109f72016-04-18 10:40:50 -0700416 // Cached results for OatFileStatus
417 bool oat_file_status_attempted_ = false;
418 OatStatus cached_oat_file_status_;
Richard Uhler66d874d2015-01-15 09:37:19 -0800419
420 // Cached value of the image info.
421 // Use the GetImageInfo method rather than accessing these directly.
422 // TODO: The image info should probably be moved out of the oat file
423 // assistant to an image file manager.
424 bool image_info_load_attempted_ = false;
425 bool image_info_load_succeeded_ = false;
426 ImageInfo cached_image_info_;
Jeff Haob11ffb72016-04-07 15:40:54 -0700427 uint32_t combined_image_checksum_ = 0;
Richard Uhler66d874d2015-01-15 09:37:19 -0800428
Richard Uhler66d874d2015-01-15 09:37:19 -0800429 // For debugging only.
430 // If this flag is set, the oat or odex file has been released to the user
431 // of the OatFileAssistant object and the OatFileAssistant object is in a
432 // bad state and should no longer be used.
433 bool oat_file_released_ = false;
434
435 DISALLOW_COPY_AND_ASSIGN(OatFileAssistant);
436};
437
Narayan Kamath8943c1d2016-05-02 13:14:48 +0100438std::ostream& operator << (std::ostream& stream, const OatFileAssistant::OatStatus status);
439
Richard Uhler66d874d2015-01-15 09:37:19 -0800440} // namespace art
441
442#endif // ART_RUNTIME_OAT_FILE_ASSISTANT_H_