2 * Copyright (c) 2016, Dresden University of Technology (TU Dresden)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
24 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * Authors: Christian Menard
38 #include "cli_parser.hh"
39 #include "sim/cxx_manager.hh"
42 CliParser::usage(const std::string
& prog_name
)
45 << "Usage: " << prog_name
46 << (" <config_file.ini> [ <option> ]\n\n"
49 " -o <offset> -- set memory offset\n"
50 " -d <flag> -- set a gem5 debug flag\n"
51 " (-<flag> clears a flag)\n"
52 " -v -- verbose output\n"
53 " -e <ticks> -- end of simulation after a \n"
54 " given number of ticks\n"
56 std::exit(EXIT_FAILURE
);
60 CliParser::parse(int argc
, char** argv
)
62 std::string
prog_name(argv
[0]);
64 unsigned int arg_ptr
= 1;
70 configFile
= std::string(argv
[arg_ptr
]);
79 while (arg_ptr
< argc
) {
80 std::string
option(argv
[arg_ptr
]);
82 unsigned num_args
= argc
- arg_ptr
;
88 std::string
flag(argv
[arg_ptr
]);
90 debugFlags
.push_back(flag
);
91 } else if (option
== "-e") {
95 std::istringstream(argv
[arg_ptr
]) >> simulationEnd
;
97 } else if (option
== "-v") {
99 } else if (option
== "-o") {
103 std::istringstream(argv
[arg_ptr
]) >> memoryOffset
;
110 } catch (CxxConfigManager::Exception
&e
) {
111 std::cerr
<< e
.name
<< ": " << e
.message
<< "\n";
112 std::exit(EXIT_FAILURE
);
119 CliParser::getDebugFlags()
121 std::stringstream ss
;
122 for (auto& flag
: debugFlags
) {