diff --git a/Tools/StarletBootstrapProbe/StarletBootstrapProbe.cpp b/Tools/StarletBootstrapProbe/StarletBootstrapProbe.cpp index 8e3494e894..317ab046f5 100644 --- a/Tools/StarletBootstrapProbe/StarletBootstrapProbe.cpp +++ b/Tools/StarletBootstrapProbe/StarletBootstrapProbe.cpp @@ -423,8 +423,15 @@ int main(int argc, char** argv) SBR1Mode sbr1 = SBR1Mode::None; ExpectedOutcome expected = ExpectedOutcome::Idle; bool outcome_selected = false; - std::optional cycles_text; + std::optional cycles; bool broadway_h1a = false; + // --cycles' bound: MAX_CYCLES, or MAX_CLIENT_CYCLES when --broadway-h1a is among the options + // (ProbeBudget.h), known before they are read so that --cycles is read where it stands. + const auto is_client = [](const char* argument) { + return std::string_view(argument) == "--broadway-h1a"; + }; + const u64 max_cycles = + std::any_of(argv + 2, argv + argc, is_client) ? MAX_CLIENT_CYCLES : MAX_CYCLES; std::optional package_path; std::optional script_path; for (int index = 2; index < argc; ++index) @@ -462,13 +469,14 @@ int main(int argc, char** argv) } else if (option == "--cycles") { - // Given once; read below, once the mode, which bounds it, is known. - if (cycles_text || index + 1 == argc) + // A whole number of slices, at most max_cycles (ProbeBudget.h); given once. + if (cycles || index + 1 == argc || !(cycles = ParseCycles(argv[index + 1], max_cycles))) { - std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", once\n"; + std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", at most " + << max_cycles << ", once\n"; return 2; } - cycles_text = argv[++index]; + ++index; } else if (option == "--jit") jit = true; @@ -516,16 +524,6 @@ int main(int argc, char** argv) std::cerr << "--broadway-h1a takes --sbr1-record: the loader's monitor reads the record\n"; return 2; } - // A whole number of slices, at most MAX_CYCLES, or MAX_CLIENT_CYCLES with the client - // (ProbeBudget.h). - const u64 max_cycles = broadway_h1a ? MAX_CLIENT_CYCLES : MAX_CYCLES; - std::optional cycles; - if (cycles_text && !(cycles = ParseCycles(*cycles_text, max_cycles))) - { - std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", at most " - << max_cycles << ", once\n"; - return 2; - } // The package file read and checked before anything is set up: a refused file ends the run // before StarOS starts.