1 /* 2 * Copyright (C) 2011 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_PARSED_OPTIONS_H_ 18 #define ART_RUNTIME_PARSED_OPTIONS_H_ 19 20 #include <string> 21 #include <string_view> 22 #include <vector> 23 24 #include <jni.h> 25 26 #include "arch/instruction_set.h" 27 #include "gc/collector_type.h" 28 #include "gc/space/large_object_space.h" 29 // #include "jit/profile_saver_options.h" 30 #include "runtime_globals.h" 31 #include "runtime_options.h" 32 33 namespace art { 34 35 class CompilerCallbacks; 36 class DexFile; 37 struct RuntimeArgumentMap; 38 39 typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions; 40 41 template <typename TVariantMap, 42 template <typename TKeyValue> class TVariantMapKey> 43 struct CmdlineParser; 44 45 class ParsedOptions { 46 public: 47 using RuntimeParser = CmdlineParser<RuntimeArgumentMap, RuntimeArgumentMap::Key>; 48 // Create a parser that can turn user-defined input into a RuntimeArgumentMap. 49 // This visibility is effectively for testing-only, and normal code does not 50 // need to create its own parser. 51 static std::unique_ptr<RuntimeParser> MakeParser(bool ignore_unrecognized); 52 53 // returns true if parsing succeeds, and stores the resulting options into runtime_options 54 static bool Parse(const RuntimeOptions& options, 55 bool ignore_unrecognized, 56 RuntimeArgumentMap* runtime_options); 57 58 bool (*hook_is_sensitive_thread_)(); 59 jint (*hook_vfprintf_)(FILE* stream, const char* format, va_list ap); 60 void (*hook_exit_)(jint status); 61 void (*hook_abort_)(); 62 63 private: 64 ParsedOptions(); 65 66 bool ProcessSpecialOptions(const RuntimeOptions& options, 67 RuntimeArgumentMap* runtime_options, 68 std::vector<std::string>* out_options); 69 70 void Usage(const char* fmt, ...); 71 void UsageMessage(FILE* stream, const char* fmt, ...); 72 void UsageMessageV(FILE* stream, const char* fmt, va_list ap); 73 74 void Exit(int status); 75 void Abort(); 76 77 bool DoParse(const RuntimeOptions& options, 78 bool ignore_unrecognized, 79 RuntimeArgumentMap* runtime_options); 80 }; 81 82 } // namespace art 83 84 #endif // ART_RUNTIME_PARSED_OPTIONS_H_ 85