util: Make m5 commands return a bool instead of calling usage.

By delegating actually calling usage() elsewhere, we can remove a dependency
from the commands themselves, and also make testing easier since we won't
exit() every time we call a command with bad arguments.

Change-Id: I6b8e2cb77ce0456b16673f10349362cc53218bba
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27565
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2020-04-07 00:40:27 -07:00
parent ff82cba034
commit 8a4fcdee4d
15 changed files with 51 additions and 39 deletions

View File

@@ -31,19 +31,21 @@
#include "args.hh"
#include "command.hh"
#include "dispatch_table.hh"
#include "usage.hh"
namespace
{
void
bool
do_initparam(const DispatchTable &dt, Args &args)
{
uint64_t key_str[2];
if (!args.pop(key_str, 2))
usage();
return false;
uint64_t val = (*dt.m5_init_param)(key_str[0], key_str[1]);
std::cout << val;
return true;
}
Command init_param = {