blob: dab0f55df80b5c04aaaae27cf3b0c7d12ca1378d [file] [log] [blame]
Brian Carlstrom491ca9e2014-03-02 18:24:38 -08001/*
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#include "parsed_options.h"
Ian Rogers576ca0c2014-06-06 15:58:22 -070018
Yi Kongc57c6802018-10-29 14:28:56 -070019#include <memory>
Ian Rogersc7dd2952014-10-21 23:31:19 -070020#include <sstream>
21
Andreas Gampe57943812017-12-06 21:39:13 -080022#include <android-base/logging.h>
Vladimir Marko91f10322018-12-07 18:04:10 +000023#include <android-base/strings.h>
Andreas Gampe57943812017-12-06 21:39:13 -080024
David Sehr891a50e2017-10-27 17:01:07 -070025#include "base/file_utils.h"
Alex Lighteb9da9e2020-07-13 16:10:03 -070026#include "base/indenter.h"
Andreas Gampe57943812017-12-06 21:39:13 -080027#include "base/macros.h"
David Sehrc431b9d2018-03-02 12:01:51 -080028#include "base/utils.h"
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080029#include "debugger.h"
Ian Rogers576ca0c2014-06-06 15:58:22 -070030#include "gc/heap.h"
Alex Lightf3677472019-06-26 16:31:53 -070031#include "jni_id_type.h"
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080032#include "monitor.h"
Ian Rogerse63db272014-07-15 15:36:11 -070033#include "runtime.h"
Alex Light7233c7e2016-07-28 10:07:45 -070034#include "ti/agent.h"
Ian Rogerse63db272014-07-15 15:36:11 -070035#include "trace.h"
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080036
Igor Murashkinaaebaa02015-01-26 10:55:53 -080037#include "cmdline_parser.h"
38#include "runtime_options.h"
39
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080040namespace art {
41
Igor Murashkinaaebaa02015-01-26 10:55:53 -080042using MemoryKiB = Memory<1024>;
43
Andreas Gampe313f4032014-08-29 16:01:25 -070044ParsedOptions::ParsedOptions()
Igor Murashkinaaebaa02015-01-26 10:55:53 -080045 : hook_is_sensitive_thread_(nullptr),
Andreas Gampe313f4032014-08-29 16:01:25 -070046 hook_vfprintf_(vfprintf),
47 hook_exit_(exit),
Igor Murashkinaaebaa02015-01-26 10:55:53 -080048 hook_abort_(nullptr) { // We don't call abort(3) by default; see
49 // Runtime::Abort
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080050}
Andreas Gampe313f4032014-08-29 16:01:25 -070051
Vladimir Marko88b2b802015-12-04 14:19:04 +000052bool ParsedOptions::Parse(const RuntimeOptions& options,
53 bool ignore_unrecognized,
54 RuntimeArgumentMap* runtime_options) {
Igor Murashkinb1d8c312015-08-04 11:18:43 -070055 CHECK(runtime_options != nullptr);
56
Vladimir Marko88b2b802015-12-04 14:19:04 +000057 ParsedOptions parser;
58 return parser.DoParse(options, ignore_unrecognized, runtime_options);
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080059}
60
Igor Murashkinaaebaa02015-01-26 10:55:53 -080061using RuntimeParser = CmdlineParser<RuntimeArgumentMap, RuntimeArgumentMap::Key>;
David Brazdil6dfdfef2019-04-11 17:39:11 +010062using HiddenapiPolicyValueMap =
63 std::initializer_list<std::pair<const char*, hiddenapi::EnforcementPolicy>>;
Brian Carlstrom491ca9e2014-03-02 18:24:38 -080064
Igor Murashkinaaebaa02015-01-26 10:55:53 -080065// Yes, the stack frame is huge. But we get called super early on (and just once)
66// to pass the command line arguments, so we'll probably be ok.
67// Ideas to avoid suppressing this diagnostic are welcome!
68#pragma GCC diagnostic push
69#pragma GCC diagnostic ignored "-Wframe-larger-than="
70
71std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognized) {
72 using M = RuntimeArgumentMap;
73
74 std::unique_ptr<RuntimeParser::Builder> parser_builder =
Yi Kongc57c6802018-10-29 14:28:56 -070075 std::make_unique<RuntimeParser::Builder>();
Igor Murashkinaaebaa02015-01-26 10:55:53 -080076
David Brazdil6dfdfef2019-04-11 17:39:11 +010077 HiddenapiPolicyValueMap hiddenapi_policy_valuemap =
78 {{"disabled", hiddenapi::EnforcementPolicy::kDisabled},
79 {"just-warn", hiddenapi::EnforcementPolicy::kJustWarn},
80 {"enabled", hiddenapi::EnforcementPolicy::kEnabled}};
81 DCHECK_EQ(hiddenapi_policy_valuemap.size(),
82 static_cast<size_t>(hiddenapi::EnforcementPolicy::kMax) + 1);
83
Igor Murashkinaaebaa02015-01-26 10:55:53 -080084 parser_builder->
Alex Lighteb9da9e2020-07-13 16:10:03 -070085 SetCategory("standard")
86 .Define({"-classpath _", "-cp _"})
87 .WithHelp("The classpath, separated by ':'")
88 .WithType<std::string>()
89 .IntoKey(M::ClassPath)
90 .Define("-D_")
91 .WithType<std::vector<std::string>>().AppendValues()
92 .IntoKey(M::PropertiesList)
93 .Define("-verbose:_")
94 .WithHelp("Switches for advanced logging. Multiple categories can be enabled separated by ','. Eg: -verbose:class,deopt")
95 .WithType<LogVerbosity>()
96 .IntoKey(M::Verbose)
97 .Define({"-help", "-h"})
98 .WithHelp("Print this help text.")
Igor Murashkinaaebaa02015-01-26 10:55:53 -080099 .IntoKey(M::Help)
100 .Define("-showversion")
101 .IntoKey(M::ShowVersion)
Alex Light7233c7e2016-07-28 10:07:45 -0700102 // TODO Re-enable -agentlib: once I have a good way to transform the values.
103 // .Define("-agentlib:_")
104 // .WithType<std::vector<ti::Agent>>().AppendValues()
105 // .IntoKey(M::AgentLib)
106 .Define("-agentpath:_")
Alex Lighteb9da9e2020-07-13 16:10:03 -0700107 .WithHelp("Load native agents.")
Andreas Gampeaadcbc62017-12-28 14:05:42 -0800108 .WithType<std::list<ti::AgentSpec>>().AppendValues()
Alex Light7233c7e2016-07-28 10:07:45 -0700109 .IntoKey(M::AgentPath)
Alex Lighteb9da9e2020-07-13 16:10:03 -0700110 .SetCategory("extended")
111 .Define("-Xbootclasspath:_")
112 .WithType<ParseStringList<':'>>() // std::vector<std::string>, split by :
113 .IntoKey(M::BootClassPath)
114 .Define("-Xcheck:jni")
115 .IntoKey(M::CheckJni)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800116 .Define("-Xms_")
117 .WithType<MemoryKiB>()
118 .IntoKey(M::MemoryInitialSize)
119 .Define("-Xmx_")
120 .WithType<MemoryKiB>()
121 .IntoKey(M::MemoryMaximumSize)
Alex Lighteb9da9e2020-07-13 16:10:03 -0700122 .Define("-Xss_")
123 .WithType<Memory<1>>()
124 .IntoKey(M::StackSize)
125 .Define("-Xint")
126 .WithValue(true)
127 .IntoKey(M::Interpret)
128 .SetCategory("Dalvik")
129 .Define("-Xzygote")
130 .WithHelp("Start as zygote")
131 .IntoKey(M::Zygote)
132 .Define("-Xjnitrace:_")
133 .WithType<std::string>()
134 .IntoKey(M::JniTrace)
135 .Define("-Xgc:_")
136 .WithType<XGcOption>()
137 .IntoKey(M::GcOption)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800138 .Define("-XX:HeapGrowthLimit=_")
139 .WithType<MemoryKiB>()
140 .IntoKey(M::HeapGrowthLimit)
141 .Define("-XX:HeapMinFree=_")
142 .WithType<MemoryKiB>()
143 .IntoKey(M::HeapMinFree)
144 .Define("-XX:HeapMaxFree=_")
145 .WithType<MemoryKiB>()
146 .IntoKey(M::HeapMaxFree)
147 .Define("-XX:NonMovingSpaceCapacity=_")
148 .WithType<MemoryKiB>()
149 .IntoKey(M::NonMovingSpaceCapacity)
150 .Define("-XX:HeapTargetUtilization=_")
151 .WithType<double>().WithRange(0.1, 0.9)
152 .IntoKey(M::HeapTargetUtilization)
153 .Define("-XX:ForegroundHeapGrowthMultiplier=_")
Mathieu Chartier11c273d2017-10-15 20:54:45 -0700154 .WithType<double>().WithRange(0.1, 5.0)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800155 .IntoKey(M::ForegroundHeapGrowthMultiplier)
Alex Lighteb9da9e2020-07-13 16:10:03 -0700156 .Define("-XX:LowMemoryMode")
157 .IntoKey(M::LowMemoryMode)
158 .Define("-Xprofile:_")
159 .WithType<TraceClockSource>()
160 .WithValueMap({{"threadcpuclock", TraceClockSource::kThreadCpu},
161 {"wallclock", TraceClockSource::kWall},
162 {"dualclock", TraceClockSource::kDual}})
163 .IntoKey(M::ProfileClock)
164 .Define("-Xjitthreshold:_")
165 .WithType<unsigned int>()
166 .IntoKey(M::JITCompileThreshold)
167 .SetCategory("ART")
168 .Define("-Ximage:_")
169 .WithType<std::string>()
170 .IntoKey(M::Image)
171 .Define("-Xprimaryzygote")
172 .IntoKey(M::PrimaryZygote)
173 .Define("-Xbootclasspath-locations:_")
174 .WithType<ParseStringList<':'>>() // std::vector<std::string>, split by :
175 .IntoKey(M::BootClassPathLocations)
176 .Define("-Ximage-load-order:_")
177 .WithType<gc::space::ImageSpaceLoadingOrder>()
178 .WithValueMap({{"system", gc::space::ImageSpaceLoadingOrder::kSystemFirst},
179 {"data", gc::space::ImageSpaceLoadingOrder::kDataFirst}})
180 .IntoKey(M::ImageSpaceLoadingOrder)
181 .Define("-Xjniopts:forcecopy")
182 .IntoKey(M::JniOptsForceCopy)
183 .Define("-XjdwpProvider:_")
184 .WithType<JdwpProvider>()
185 .IntoKey(M::JdwpProvider)
186 .Define("-XjdwpOptions:_")
187 .WithMetavar("OPTION[,OPTION...]")
188 .WithHelp("JDWP options. Eg suspend=n,server=y.")
189 .WithType<std::string>()
190 .IntoKey(M::JdwpOptions)
191 .Define("-XX:StopForNativeAllocs=_")
192 .WithType<MemoryKiB>()
193 .IntoKey(M::StopForNativeAllocs)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800194 .Define("-XX:ParallelGCThreads=_")
195 .WithType<unsigned int>()
196 .IntoKey(M::ParallelGCThreads)
197 .Define("-XX:ConcGCThreads=_")
198 .WithType<unsigned int>()
199 .IntoKey(M::ConcGCThreads)
Hans Boehmb2155572019-03-27 14:25:53 -0700200 .Define("-XX:FinalizerTimeoutMs=_")
201 .WithType<unsigned int>()
202 .IntoKey(M::FinalizerTimeoutMs)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800203 .Define("-XX:MaxSpinsBeforeThinLockInflation=_")
204 .WithType<unsigned int>()
205 .IntoKey(M::MaxSpinsBeforeThinLockInflation)
206 .Define("-XX:LongPauseLogThreshold=_") // in ms
207 .WithType<MillisecondsToNanoseconds>() // store as ns
208 .IntoKey(M::LongPauseLogThreshold)
209 .Define("-XX:LongGCLogThreshold=_") // in ms
210 .WithType<MillisecondsToNanoseconds>() // store as ns
211 .IntoKey(M::LongGCLogThreshold)
212 .Define("-XX:DumpGCPerformanceOnShutdown")
213 .IntoKey(M::DumpGCPerformanceOnShutdown)
Albert Mingkun Yangde94ea72018-11-16 10:15:49 +0000214 .Define("-XX:DumpRegionInfoBeforeGC")
215 .IntoKey(M::DumpRegionInfoBeforeGC)
216 .Define("-XX:DumpRegionInfoAfterGC")
217 .IntoKey(M::DumpRegionInfoAfterGC)
Mathieu Chartiera4885cb2015-03-09 15:38:54 -0700218 .Define("-XX:DumpJITInfoOnShutdown")
219 .IntoKey(M::DumpJITInfoOnShutdown)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800220 .Define("-XX:IgnoreMaxFootprint")
221 .IntoKey(M::IgnoreMaxFootprint)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800222 .Define("-XX:UseTLAB")
Hiroshi Yamauchif360ad02015-02-20 11:28:03 -0800223 .WithValue(true)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800224 .IntoKey(M::UseTLAB)
225 .Define({"-XX:EnableHSpaceCompactForOOM", "-XX:DisableHSpaceCompactForOOM"})
226 .WithValues({true, false})
227 .IntoKey(M::EnableHSpaceCompactForOOM)
Nicolas Geoffray6ee49712018-03-30 14:39:05 +0000228 .Define("-XX:DumpNativeStackOnSigQuit:_")
229 .WithType<bool>()
230 .WithValueMap({{"false", false}, {"true", true}})
231 .IntoKey(M::DumpNativeStackOnSigQuit)
Mathieu Chartierc42cb0e2017-10-13 11:35:00 -0700232 .Define("-XX:MadviseRandomAccess:_")
233 .WithType<bool>()
234 .WithValueMap({{"false", false}, {"true", true}})
235 .IntoKey(M::MadviseRandomAccess)
Mathieu Chartier1972a8e2015-03-05 17:12:54 -0800236 .Define("-Xusejit:_")
237 .WithType<bool>()
238 .WithValueMap({{"false", false}, {"true", true}})
Calin Juravleffc87072016-04-20 14:22:09 +0100239 .IntoKey(M::UseJitCompilation)
Nicolas Geoffraya59af8a2019-11-27 17:42:32 +0000240 .Define("-Xusetieredjit:_")
241 .WithType<bool>()
242 .WithValueMap({{"false", false}, {"true", true}})
243 .IntoKey(M::UseTieredJitCompilation)
Nicolas Geoffray56782292015-11-19 14:25:43 +0000244 .Define("-Xjitinitialsize:_")
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800245 .WithType<MemoryKiB>()
Nicolas Geoffray0a3be162015-11-18 11:15:22 +0000246 .IntoKey(M::JITCodeCacheInitialCapacity)
Nicolas Geoffray56782292015-11-19 14:25:43 +0000247 .Define("-Xjitmaxsize:_")
Nicolas Geoffray0a3be162015-11-18 11:15:22 +0000248 .WithType<MemoryKiB>()
249 .IntoKey(M::JITCodeCacheMaxCapacity)
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100250 .Define("-Xjitwarmupthreshold:_")
251 .WithType<unsigned int>()
252 .IntoKey(M::JITWarmupThreshold)
Nicolas Geoffray83f080a2016-03-08 16:50:21 +0000253 .Define("-Xjitosrthreshold:_")
254 .WithType<unsigned int>()
255 .IntoKey(M::JITOsrThreshold)
Calin Juravleb2771b42016-04-07 17:09:25 +0100256 .Define("-Xjitprithreadweight:_")
257 .WithType<unsigned int>()
258 .IntoKey(M::JITPriorityThreadWeight)
Calin Juravle155ff3d2016-04-27 14:14:58 +0100259 .Define("-Xjittransitionweight:_")
260 .WithType<unsigned int>()
261 .IntoKey(M::JITInvokeTransitionWeight)
Nicolas Geoffray47b95802018-05-16 15:42:17 +0100262 .Define("-Xjitpthreadpriority:_")
263 .WithType<int>()
264 .IntoKey(M::JITPoolThreadPthreadPriority)
Calin Juravle31f2c152015-10-23 17:56:15 +0100265 .Define("-Xjitsaveprofilinginfo")
Calin Juravle138dbff2016-06-28 19:36:58 +0100266 .WithType<ProfileSaverOptions>()
267 .AppendValues()
268 .IntoKey(M::ProfileSaverOpts)
Alex Lighteb9da9e2020-07-13 16:10:03 -0700269 // .Define("-Xps-_") // profile saver options -Xps-<key>:<value>
270 // .WithType<ProfileSaverOptions>()
271 // .AppendValues()
272 // .IntoKey(M::ProfileSaverOpts) // NOTE: Appends into same key as -Xjitsaveprofilinginfo
273 // profile saver options -Xps-<key>:<value> but are split-out for better help messages.
274 // The order of these is important. We want the wildcard one to be the
275 // only one actually matched so it needs to be first.
276 // TODO This should be redone.
277 .Define({"-Xps-_",
278 "-Xps-min-save-period-ms:_",
279 "-Xps-save-resolved-classes-delayed-ms:_",
280 "-Xps-hot-startup-method-samples:_",
281 "-Xps-min-methods-to-save:_",
282 "-Xps-min-classes-to-save:_",
283 "-Xps-min-notification-before-wake:_",
284 "-Xps-max-notification-before-wake:_",
285 "-Xps-profile-path:_"})
286 .WithHelp("profile-saver options -Xps-<key>:<value>")
Calin Juravle138dbff2016-06-28 19:36:58 +0100287 .WithType<ProfileSaverOptions>()
288 .AppendValues()
289 .IntoKey(M::ProfileSaverOpts) // NOTE: Appends into same key as -Xjitsaveprofilinginfo
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800290 .Define("-XX:HspaceCompactForOOMMinIntervalMs=_") // in ms
291 .WithType<MillisecondsToNanoseconds>() // store as ns
292 .IntoKey(M::HSpaceCompactForOOMMinIntervalsMs)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800293 .Define({"-Xrelocate", "-Xnorelocate"})
294 .WithValues({true, false})
295 .IntoKey(M::Relocate)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800296 .Define({"-Ximage-dex2oat", "-Xnoimage-dex2oat"})
297 .WithValues({true, false})
298 .IntoKey(M::ImageDex2Oat)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800299 .Define("-XX:LargeObjectSpace=_")
300 .WithType<gc::space::LargeObjectSpaceType>()
301 .WithValueMap({{"disabled", gc::space::LargeObjectSpaceType::kDisabled},
302 {"freelist", gc::space::LargeObjectSpaceType::kFreeList},
303 {"map", gc::space::LargeObjectSpaceType::kMap}})
304 .IntoKey(M::LargeObjectSpace)
305 .Define("-XX:LargeObjectThreshold=_")
306 .WithType<Memory<1>>()
307 .IntoKey(M::LargeObjectThreshold)
308 .Define("-XX:BackgroundGC=_")
309 .WithType<BackgroundGcOption>()
310 .IntoKey(M::BackgroundGc)
311 .Define("-XX:+DisableExplicitGC")
312 .IntoKey(M::DisableExplicitGC)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800313 .Define("-Xlockprofthreshold:_")
314 .WithType<unsigned int>()
315 .IntoKey(M::LockProfThreshold)
Andreas Gamped0210e52017-06-23 13:38:09 -0700316 .Define("-Xstackdumplockprofthreshold:_")
317 .WithType<unsigned int>()
318 .IntoKey(M::StackDumpLockProfThreshold)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800319 .Define("-Xmethod-trace")
320 .IntoKey(M::MethodTrace)
321 .Define("-Xmethod-trace-file:_")
322 .WithType<std::string>()
323 .IntoKey(M::MethodTraceFile)
324 .Define("-Xmethod-trace-file-size:_")
325 .WithType<unsigned int>()
326 .IntoKey(M::MethodTraceFileSize)
Andreas Gampe40da2862015-02-27 12:49:04 -0800327 .Define("-Xmethod-trace-stream")
328 .IntoKey(M::MethodTraceStreaming)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800329 .Define("-Xcompiler:_")
330 .WithType<std::string>()
331 .IntoKey(M::Compiler)
332 .Define("-Xcompiler-option _")
333 .WithType<std::vector<std::string>>()
334 .AppendValues()
335 .IntoKey(M::CompilerOptions)
336 .Define("-Ximage-compiler-option _")
337 .WithType<std::vector<std::string>>()
338 .AppendValues()
339 .IntoKey(M::ImageCompilerOptions)
340 .Define("-Xverify:_")
Igor Murashkin7617abd2015-07-10 18:27:47 -0700341 .WithType<verifier::VerifyMode>()
342 .WithValueMap({{"none", verifier::VerifyMode::kNone},
343 {"remote", verifier::VerifyMode::kEnable},
344 {"all", verifier::VerifyMode::kEnable},
345 {"softfail", verifier::VerifyMode::kSoftFail}})
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800346 .IntoKey(M::Verify)
347 .Define("-XX:NativeBridge=_")
348 .WithType<std::string>()
349 .IntoKey(M::NativeBridge)
Andreas Gampe9106e522015-03-31 14:54:03 -0700350 .Define("-Xzygote-max-boot-retry=_")
Narayan Kamath5a2be3f2015-02-16 13:51:51 +0000351 .WithType<unsigned int>()
352 .IntoKey(M::ZygoteMaxFailedBoots)
Calin Juravle01aaf6e2015-06-19 22:05:39 +0100353 .Define("-Xno-sig-chain")
354 .IntoKey(M::NoSigChain)
Dmitriy Ivanov785049f2014-07-18 10:08:57 -0700355 .Define("--cpu-abilist=_")
356 .WithType<std::string>()
357 .IntoKey(M::CpuAbiList)
Andreas Gampedd671252015-07-23 14:37:18 -0700358 .Define("-Xfingerprint:_")
359 .WithType<std::string>()
360 .IntoKey(M::Fingerprint)
Alex Lighteb7c1442015-08-31 13:17:42 -0700361 .Define("-Xexperimental:_")
362 .WithType<ExperimentalFlags>()
363 .AppendValues()
364 .IntoKey(M::Experimental)
Calin Juravled3e7c6c2016-02-04 19:07:51 +0000365 .Define("-Xforce-nb-testing")
366 .IntoKey(M::ForceNativeBridge)
Alex Light185d1342016-08-11 10:48:03 -0700367 .Define("-Xplugin:_")
Alex Lighteb9da9e2020-07-13 16:10:03 -0700368 .WithHelp("Load and initialize the specified art-plugin.")
Alex Light185d1342016-08-11 10:48:03 -0700369 .WithType<std::vector<Plugin>>().AppendValues()
370 .IntoKey(M::Plugins)
Mathieu Chartier3fceaf52017-01-22 13:33:40 -0800371 .Define("-XX:ThreadSuspendTimeout=_") // in ms
372 .WithType<MillisecondsToNanoseconds>() // store as ns
373 .IntoKey(M::ThreadSuspendTimeout)
Andreas Gampe1b35b462017-09-29 18:52:15 -0700374 .Define("-XX:GlobalRefAllocStackTraceLimit=_") // Number of free slots to enable tracing.
375 .WithType<unsigned int>()
376 .IntoKey(M::GlobalRefAllocStackTraceLimit)
Andreas Gampe1c5b42f2017-06-15 18:20:45 -0700377 .Define("-XX:SlowDebug=_")
378 .WithType<bool>()
379 .WithValueMap({{"false", false}, {"true", true}})
380 .IntoKey(M::SlowDebug)
David Brazdila7db0262018-01-16 17:13:35 +0000381 .Define("-Xtarget-sdk-version:_")
David Brazdil2bb2fbd2018-11-13 18:24:26 +0000382 .WithType<unsigned int>()
David Brazdila7db0262018-01-16 17:13:35 +0000383 .IntoKey(M::TargetSdkVersion)
David Brazdil6dfdfef2019-04-11 17:39:11 +0100384 .Define("-Xhidden-api-policy:_")
385 .WithType<hiddenapi::EnforcementPolicy>()
386 .WithValueMap(hiddenapi_policy_valuemap)
387 .IntoKey(M::HiddenApiPolicy)
388 .Define("-Xcore-platform-api-policy:_")
389 .WithType<hiddenapi::EnforcementPolicy>()
390 .WithValueMap(hiddenapi_policy_valuemap)
391 .IntoKey(M::CorePlatformApiPolicy)
Andreas Gampe25419b52018-02-08 21:30:26 -0800392 .Define("-Xuse-stderr-logger")
393 .IntoKey(M::UseStderrLogger)
Nicolas Geoffray66ff8a82018-02-28 13:27:55 +0000394 .Define("-Xonly-use-system-oat-files")
395 .IntoKey(M::OnlyUseSystemOatFiles)
Andreas Gampe0b0ffc12018-08-01 14:41:27 -0700396 .Define("-Xverifier-logging-threshold=_")
397 .WithType<unsigned int>()
398 .IntoKey(M::VerifierLoggingThreshold)
Andreas Gampe87658f32019-04-18 18:39:02 +0000399 .Define("-XX:FastClassNotFoundException=_")
400 .WithType<bool>()
401 .WithValueMap({{"false", false}, {"true", true}})
402 .IntoKey(M::FastClassNotFoundException)
Alex Light79d6c802019-06-27 15:50:11 +0000403 .Define("-Xopaque-jni-ids:_")
Alex Lighteb9da9e2020-07-13 16:10:03 -0700404 .WithHelp("Control the representation of jmethodID and jfieldID values")
Alex Lightf3677472019-06-26 16:31:53 -0700405 .WithType<JniIdType>()
406 .WithValueMap({{"true", JniIdType::kIndices},
407 {"false", JniIdType::kPointer},
408 {"swapable", JniIdType::kSwapablePointer},
409 {"pointer", JniIdType::kPointer},
410 {"indices", JniIdType::kIndices},
411 {"default", JniIdType::kDefault}})
Alex Light79d6c802019-06-27 15:50:11 +0000412 .IntoKey(M::OpaqueJniIds)
Alex Light4ca2f482019-11-25 16:07:22 -0800413 .Define("-Xauto-promote-opaque-jni-ids:_")
414 .WithType<bool>()
415 .WithValueMap({{"true", true}, {"false", false}})
416 .IntoKey(M::AutoPromoteOpaqueJniIds)
Andreas Gamped84794d2019-07-18 13:40:03 -0700417 .Define("-XX:VerifierMissingKThrowFatal=_")
418 .WithType<bool>()
419 .WithValueMap({{"false", false}, {"true", true}})
420 .IntoKey(M::VerifierMissingKThrowFatal)
Florian Mayer0972d082020-05-15 14:07:31 +0200421 .Define("-XX:PerfettoHprof=_")
422 .WithType<bool>()
423 .WithValueMap({{"false", false}, {"true", true}})
424 .IntoKey(M::PerfettoHprof)
Ulyana Trafimoviche886d682020-07-16 15:09:38 +0000425 .Define("--simulate-isa=_")
426 .WithType<InstructionSet>()
427 .WithValueMap({{"none", InstructionSet::kNone},
428 {"arm64", InstructionSet::kArm64}})
429 .IntoKey(M::SimulateInstructionSet)
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800430 .Ignore({
431 "-ea", "-da", "-enableassertions", "-disableassertions", "--runtime-arg", "-esa",
432 "-dsa", "-enablesystemassertions", "-disablesystemassertions", "-Xrs", "-Xint:_",
433 "-Xdexopt:_", "-Xnoquithandler", "-Xjnigreflimit:_", "-Xgenregmap", "-Xnogenregmap",
434 "-Xverifyopt:_", "-Xcheckdexsum", "-Xincludeselectedop", "-Xjitop:_",
Alex Lighteb9da9e2020-07-13 16:10:03 -0700435 "-Xincludeselectedmethod",
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800436 "-Xjitblocking", "-Xjitmethod:_", "-Xjitclass:_", "-Xjitoffset:_",
437 "-Xjitconfig:_", "-Xjitcheckcg", "-Xjitverbose", "-Xjitprofile",
438 "-Xjitdisableopt", "-Xjitsuspendpoll", "-XX:mainThreadStackSize=_"})
Alex Lighteb9da9e2020-07-13 16:10:03 -0700439 .IgnoreUnrecognized(ignore_unrecognized)
440 .OrderCategories({"standard", "extended", "Dalvik", "ART"});
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800441
442 // TODO: Move Usage information into this DSL.
443
Yi Kongc57c6802018-10-29 14:28:56 -0700444 return std::make_unique<RuntimeParser>(parser_builder->Build());
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800445}
446
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800447#pragma GCC diagnostic pop
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800448
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800449// Remove all the special options that have something in the void* part of the option.
450// If runtime_options is not null, put the options in there.
451// As a side-effect, populate the hooks from options.
452bool ParsedOptions::ProcessSpecialOptions(const RuntimeOptions& options,
453 RuntimeArgumentMap* runtime_options,
454 std::vector<std::string>* out_options) {
455 using M = RuntimeArgumentMap;
456
457 // TODO: Move the below loop into JNI
458 // Handle special options that set up hooks
459 for (size_t i = 0; i < options.size(); ++i) {
460 const std::string option(options[i].first);
461 // TODO: support -Djava.class.path
462 if (option == "bootclasspath") {
Vladimir Marko9bdf1082016-01-21 12:15:52 +0000463 auto boot_class_path = static_cast<std::vector<std::unique_ptr<const DexFile>>*>(
464 const_cast<void*>(options[i].second));
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800465
466 if (runtime_options != nullptr) {
467 runtime_options->Set(M::BootClassPathDexList, boot_class_path);
468 }
469 } else if (option == "compilercallbacks") {
470 CompilerCallbacks* compiler_callbacks =
471 reinterpret_cast<CompilerCallbacks*>(const_cast<void*>(options[i].second));
472 if (runtime_options != nullptr) {
473 runtime_options->Set(M::CompilerCallbacksPtr, compiler_callbacks);
474 }
475 } else if (option == "imageinstructionset") {
476 const char* isa_str = reinterpret_cast<const char*>(options[i].second);
477 auto&& image_isa = GetInstructionSetFromString(isa_str);
Vladimir Marko33bff252017-11-01 14:35:42 +0000478 if (image_isa == InstructionSet::kNone) {
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800479 Usage("%s is not a valid instruction set.", isa_str);
480 return false;
481 }
482 if (runtime_options != nullptr) {
483 runtime_options->Set(M::ImageInstructionSet, image_isa);
484 }
485 } else if (option == "sensitiveThread") {
486 const void* hook = options[i].second;
487 bool (*hook_is_sensitive_thread)() = reinterpret_cast<bool (*)()>(const_cast<void*>(hook));
488
489 if (runtime_options != nullptr) {
490 runtime_options->Set(M::HookIsSensitiveThread, hook_is_sensitive_thread);
491 }
492 } else if (option == "vfprintf") {
493 const void* hook = options[i].second;
494 if (hook == nullptr) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700495 Usage("vfprintf argument was nullptr");
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800496 return false;
497 }
498 int (*hook_vfprintf)(FILE *, const char*, va_list) =
499 reinterpret_cast<int (*)(FILE *, const char*, va_list)>(const_cast<void*>(hook));
500
501 if (runtime_options != nullptr) {
502 runtime_options->Set(M::HookVfprintf, hook_vfprintf);
503 }
504 hook_vfprintf_ = hook_vfprintf;
505 } else if (option == "exit") {
506 const void* hook = options[i].second;
507 if (hook == nullptr) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700508 Usage("exit argument was nullptr");
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800509 return false;
510 }
511 void(*hook_exit)(jint) = reinterpret_cast<void(*)(jint)>(const_cast<void*>(hook));
512 if (runtime_options != nullptr) {
513 runtime_options->Set(M::HookExit, hook_exit);
514 }
515 hook_exit_ = hook_exit;
516 } else if (option == "abort") {
517 const void* hook = options[i].second;
518 if (hook == nullptr) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700519 Usage("abort was nullptr\n");
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800520 return false;
521 }
522 void(*hook_abort)() = reinterpret_cast<void(*)()>(const_cast<void*>(hook));
523 if (runtime_options != nullptr) {
524 runtime_options->Set(M::HookAbort, hook_abort);
525 }
526 hook_abort_ = hook_abort;
Mathieu Chartier6f365cc2014-04-23 12:42:27 -0700527 } else {
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800528 // It is a regular option, that doesn't have a known 'second' value.
529 // Push it on to the regular options which will be parsed by our parser.
530 if (out_options != nullptr) {
531 out_options->push_back(option);
532 }
Mathieu Chartier6f365cc2014-04-23 12:42:27 -0700533 }
534 }
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800535
Mathieu Chartier6f365cc2014-04-23 12:42:27 -0700536 return true;
537}
538
Sebastien Hertzbba348e2015-06-01 08:28:18 +0200539// Intended for local changes only.
540static void MaybeOverrideVerbosity() {
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800541 // gLogVerbosity.class_linker = true; // TODO: don't check this in!
Mathieu Chartier66a55392016-02-19 10:25:39 -0800542 // gLogVerbosity.collector = true; // TODO: don't check this in!
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800543 // gLogVerbosity.compiler = true; // TODO: don't check this in!
Sebastien Hertzbba348e2015-06-01 08:28:18 +0200544 // gLogVerbosity.deopt = true; // TODO: don't check this in!
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800545 // gLogVerbosity.gc = true; // TODO: don't check this in!
546 // gLogVerbosity.heap = true; // TODO: don't check this in!
Mathieu Chartier765b2a02019-05-02 11:04:13 -0700547 // gLogVerbosity.interpreter = true; // TODO: don't check this in!
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800548 // gLogVerbosity.jdwp = true; // TODO: don't check this in!
549 // gLogVerbosity.jit = true; // TODO: don't check this in!
550 // gLogVerbosity.jni = true; // TODO: don't check this in!
551 // gLogVerbosity.monitor = true; // TODO: don't check this in!
Sebastien Hertzbba348e2015-06-01 08:28:18 +0200552 // gLogVerbosity.oat = true; // TODO: don't check this in!
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800553 // gLogVerbosity.profiler = true; // TODO: don't check this in!
554 // gLogVerbosity.signals = true; // TODO: don't check this in!
Phil Wang751beff2015-08-28 15:17:15 +0800555 // gLogVerbosity.simulator = true; // TODO: don't check this in!
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800556 // gLogVerbosity.startup = true; // TODO: don't check this in!
557 // gLogVerbosity.third_party_jni = true; // TODO: don't check this in!
558 // gLogVerbosity.threads = true; // TODO: don't check this in!
559 // gLogVerbosity.verifier = true; // TODO: don't check this in!
Sebastien Hertzbba348e2015-06-01 08:28:18 +0200560}
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800561
Vladimir Marko88b2b802015-12-04 14:19:04 +0000562bool ParsedOptions::DoParse(const RuntimeOptions& options,
563 bool ignore_unrecognized,
564 RuntimeArgumentMap* runtime_options) {
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800565 for (size_t i = 0; i < options.size(); ++i) {
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800566 if (true && options[0].first == "-Xzygote") {
Brian Carlstrom2ec65202014-03-03 15:16:37 -0800567 LOG(INFO) << "option[" << i << "]=" << options[i].first;
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800568 }
Brian Carlstrom2ec65202014-03-03 15:16:37 -0800569 }
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800570
571 auto parser = MakeParser(ignore_unrecognized);
572
573 // Convert to a simple string list (without the magic pointer options)
574 std::vector<std::string> argv_list;
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700575 if (!ProcessSpecialOptions(options, nullptr, &argv_list)) {
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800576 return false;
577 }
578
579 CmdlineResult parse_result = parser->Parse(argv_list);
580
581 // Handle parse errors by displaying the usage and potentially exiting.
582 if (parse_result.IsError()) {
583 if (parse_result.GetStatus() == CmdlineResult::kUsage) {
584 UsageMessage(stdout, "%s\n", parse_result.GetMessage().c_str());
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800585 Exit(0);
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800586 } else if (parse_result.GetStatus() == CmdlineResult::kUnknown && !ignore_unrecognized) {
587 Usage("%s\n", parse_result.GetMessage().c_str());
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800588 return false;
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800589 } else {
590 Usage("%s\n", parse_result.GetMessage().c_str());
591 Exit(0);
592 }
593
594 UNREACHABLE();
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800595 }
596
597 using M = RuntimeArgumentMap;
598 RuntimeArgumentMap args = parser->ReleaseArgumentsMap();
599
600 // -help, -showversion, etc.
601 if (args.Exists(M::Help)) {
602 Usage(nullptr);
603 return false;
604 } else if (args.Exists(M::ShowVersion)) {
Calin Juravle4707af82017-04-13 16:35:42 -0700605 UsageMessage(stdout,
606 "ART version %s %s\n",
607 Runtime::GetVersion(),
608 GetInstructionSetString(kRuntimeISA));
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800609 Exit(0);
610 } else if (args.Exists(M::BootClassPath)) {
Vladimir Marko91f10322018-12-07 18:04:10 +0000611 LOG(INFO) << "setting boot class path to " << args.Get(M::BootClassPath)->Join();
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800612 }
613
Nicolas Geoffraya5ca8eb2018-08-24 13:39:13 +0100614 if (args.GetOrDefault(M::Interpret)) {
615 if (args.Exists(M::UseJitCompilation) && *args.Get(M::UseJitCompilation)) {
616 Usage("-Xusejit:true and -Xint cannot be specified together\n");
617 Exit(0);
618 }
619 args.Set(M::UseJitCompilation, false);
Calin Juravleaf36e492016-04-27 18:50:45 +0100620 }
621
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800622 // Set a default boot class path if we didn't get an explicit one via command line.
Vladimir Marko91f10322018-12-07 18:04:10 +0000623 const char* env_bcp = getenv("BOOTCLASSPATH");
624 if (env_bcp != nullptr) {
625 args.SetIfMissing(M::BootClassPath, ParseStringList<':'>::Split(env_bcp));
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800626 }
627
628 // Set a default class path if we didn't get an explicit one via command line.
629 if (getenv("CLASSPATH") != nullptr) {
630 args.SetIfMissing(M::ClassPath, std::string(getenv("CLASSPATH")));
631 }
632
633 // Default to number of processors minus one since the main GC thread also does work.
Mathieu Chartier10d68862015-04-15 14:21:33 -0700634 args.SetIfMissing(M::ParallelGCThreads, gc::Heap::kDefaultEnableParallelGC ?
635 static_cast<unsigned int>(sysconf(_SC_NPROCESSORS_CONF) - 1u) : 0u);
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800636
Igor Murashkin9d4b6da2016-07-29 09:51:58 -0700637 // -verbose:
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800638 {
639 LogVerbosity *log_verbosity = args.Get(M::Verbose);
640 if (log_verbosity != nullptr) {
641 gLogVerbosity = *log_verbosity;
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800642 }
643 }
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800644
Sebastien Hertzbba348e2015-06-01 08:28:18 +0200645 MaybeOverrideVerbosity();
646
Andreas Gampe7c5acbb2018-09-20 13:54:52 -0700647 SetRuntimeDebugFlagsEnabled(args.GetOrDefault(M::SlowDebug));
Andreas Gampe1c5b42f2017-06-15 18:20:45 -0700648
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800649 // -Xprofile:
650 Trace::SetDefaultClockSource(args.GetOrDefault(M::ProfileClock));
651
652 if (!ProcessSpecialOptions(options, &args, nullptr)) {
653 return false;
654 }
655
656 {
657 // If not set, background collector type defaults to homogeneous compaction.
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800658 // If not low memory mode, semispace otherwise.
659
660 gc::CollectorType background_collector_type_;
Igor Murashkin5573c372017-11-16 13:34:30 -0800661 gc::CollectorType collector_type_ = (XGcOption{}).collector_type_;
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800662 bool low_memory_mode_ = args.Exists(M::LowMemoryMode);
663
664 background_collector_type_ = args.GetOrDefault(M::BackgroundGc);
665 {
666 XGcOption* xgc = args.Get(M::GcOption);
667 if (xgc != nullptr && xgc->collector_type_ != gc::kCollectorTypeNone) {
668 collector_type_ = xgc->collector_type_;
669 }
670 }
671
672 if (background_collector_type_ == gc::kCollectorTypeNone) {
Mathieu Chartierf75dce42019-04-08 09:36:23 -0700673 background_collector_type_ = low_memory_mode_ ?
674 gc::kCollectorTypeSS : gc::kCollectorTypeHomogeneousSpaceCompact;
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800675 }
676
677 args.Set(M::BackgroundGc, BackgroundGcOption { background_collector_type_ });
Mathieu Chartier6b2352b2014-08-20 14:13:18 -0700678 }
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800679
Vladimir Marko91f10322018-12-07 18:04:10 +0000680 const ParseStringList<':'>* boot_class_path_locations = args.Get(M::BootClassPathLocations);
681 if (boot_class_path_locations != nullptr && boot_class_path_locations->Size() != 0u) {
682 const ParseStringList<':'>* boot_class_path = args.Get(M::BootClassPath);
683 if (boot_class_path == nullptr ||
684 boot_class_path_locations->Size() != boot_class_path->Size()) {
685 Usage("The number of boot class path files does not match"
686 " the number of boot class path locations given\n"
687 " boot class path files (%zu): %s\n"
688 " boot class path locations (%zu): %s\n",
689 (boot_class_path != nullptr) ? boot_class_path->Size() : 0u,
690 (boot_class_path != nullptr) ? boot_class_path->Join().c_str() : "<nil>",
691 boot_class_path_locations->Size(),
692 boot_class_path_locations->Join().c_str());
693 return false;
Richard Uhlerc2752592015-01-02 13:28:22 -0800694 }
695 }
696
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800697 if (!args.Exists(M::CompilerCallbacksPtr) && !args.Exists(M::Image)) {
Nicolas Geoffrayde1b2a22019-02-27 09:10:57 +0000698 std::string image = GetDefaultBootImageLocation(GetAndroidRoot());
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800699 args.Set(M::Image, image);
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800700 }
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800701
Lin Zang8cd63ab2015-11-06 14:08:51 +0800702 // 0 means no growth limit, and growth limit should be always <= heap size
703 if (args.GetOrDefault(M::HeapGrowthLimit) <= 0u ||
704 args.GetOrDefault(M::HeapGrowthLimit) > args.GetOrDefault(M::MemoryMaximumSize)) {
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800705 args.Set(M::HeapGrowthLimit, args.GetOrDefault(M::MemoryMaximumSize));
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800706 }
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800707
708 *runtime_options = std::move(args);
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800709 return true;
Igor Murashkinaaebaa02015-01-26 10:55:53 -0800710}
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800711
712void ParsedOptions::Exit(int status) {
713 hook_exit_(status);
714}
715
716void ParsedOptions::Abort() {
717 hook_abort_();
718}
719
720void ParsedOptions::UsageMessageV(FILE* stream, const char* fmt, va_list ap) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700721 hook_vfprintf_(stream, fmt, ap);
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800722}
723
724void ParsedOptions::UsageMessage(FILE* stream, const char* fmt, ...) {
725 va_list ap;
726 va_start(ap, fmt);
727 UsageMessageV(stream, fmt, ap);
728 va_end(ap);
729}
730
731void ParsedOptions::Usage(const char* fmt, ...) {
732 bool error = (fmt != nullptr);
733 FILE* stream = error ? stderr : stdout;
734
735 if (fmt != nullptr) {
736 va_list ap;
737 va_start(ap, fmt);
738 UsageMessageV(stream, fmt, ap);
739 va_end(ap);
740 }
741
742 const char* program = "dalvikvm";
743 UsageMessage(stream, "%s: [options] class [argument ...]\n", program);
744 UsageMessage(stream, "\n");
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800745
Alex Lighteb9da9e2020-07-13 16:10:03 -0700746 std::stringstream oss;
747 VariableIndentationOutputStream vios(&oss);
748 auto parser = MakeParser(false);
749 parser->DumpHelp(vios);
750 UsageMessage(stream, oss.str().c_str());
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800751 Exit((error) ? 1 : 0);
752}
753
Brian Carlstrom491ca9e2014-03-02 18:24:38 -0800754} // namespace art