util: Add a "writefile" unit test to the m5 utility.
[gem5.git] / util / m5 / src / usage.cc
index 620d8cd2ec466856654386a83d074d0eddd8c4b9..78bfb413638b06e8b0ab706b0a7e2eb914e9da46 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <cinttypes>
-#include <cstdio>
 #include <cstdlib>
+#include <iostream>
 
-#include "commands.hh"
+#include "call_type.hh"
+#include "command.hh"
 #include "usage.hh"
 
-const char *progname = "{progname}";
+std::string progname;
 
 void
 usage()
 {
-    fprintf(stderr, "Usage: %s [call type] <command> [arguments]\n", progname);
-    fprintf(stderr, "\n");
-    fprintf(stderr, "Call types:\n");
-#   if ENABLE_CT_addr
-    fprintf(stderr, "    --addr %s%s\n",
-#   if defined(M5OP_ADDR)
-            "[address override]",
-#   else
-            "<address override>",
-#   endif
-            DEFAULT_CT_addr ? " (default)" : "");
-    fprintf(stderr, "        Use the address based invocation method.\n");
-#   if defined(M5OP_ADDR)
-    fprintf(stderr, "        The default address is %#" PRIx64 ".\n",
-            (uint64_t)M5OP_ADDR);
-#   endif
-#   endif
-#   if ENABLE_CT_inst
-    fprintf(stderr, "    --inst%s\n", DEFAULT_CT_inst ? " (default)" : "");
-    fprintf(stderr, "        Use the instruction based invocation method.\n");
-#   endif
-#   if ENABLE_CT_semi
-    fprintf(stderr, "    --semi%s\n", DEFAULT_CT_semi ? " (default)" : "");
-    fprintf(stderr, "        Use the semi-hosting based invocation method.\n");
-#   endif
-    fprintf(stderr, "\n");
-    fprintf(stderr, "Commands:\n");
-    for (int i = 0; i < num_commands; ++i) {
-        fprintf(stderr, "    %s %s\n",
-                command_table[i].name, command_table[i].usage);
-    }
-    fprintf(stderr, "\n");
-    fprintf(stderr, "All times in nanoseconds!\n");
+    std::cerr << "Usage: " << progname <<
+        "[call type] <command> [arguments]" << std::endl <<
+        std::endl <<
+        "Call types:" << std::endl <<
+        CallType::usageSummary() <<
+        std::endl <<
+        "Commands:" << std::endl <<
+        Command::usageSummary() <<
+        std::endl <<
+        "All times in nanoseconds!" << std::endl;
 
     exit(1);
 }