Simplify handling of exit_app in VerilatorSimCtrl::ParseCommandArgs

Now, we ensure to set exit_app whenever the caller of ParseCommandArgs
should stop immediately, which simplifies its behaviour somewhat. Even
nicer would be to change ParseCommandArgs to return a POSIX-style
error code, but that changes the API so I'm punting on that for now.

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/dv/verilator/simutil_verilator/cpp/verilator_sim_ctrl.cc b/hw/dv/verilator/simutil_verilator/cpp/verilator_sim_ctrl.cc
index 39a712a..c9d71e3 100644
--- a/hw/dv/verilator/simutil_verilator/cpp/verilator_sim_ctrl.cc
+++ b/hw/dv/verilator/simutil_verilator/cpp/verilator_sim_ctrl.cc
@@ -49,12 +49,9 @@
 
 int VerilatorSimCtrl::Exec(int argc, char **argv) {
   bool exit_app = false;
-  if (!ParseCommandArgs(argc, argv, exit_app)) {
-    return 1;
-  }
+  bool good_cmdline = ParseCommandArgs(argc, argv, exit_app);
   if (exit_app) {
-    // Successful exit requested by command argument parsing
-    return 0;
+    return good_cmdline ? 0 : 1;
   }
 
   RunSimulation();
@@ -88,6 +85,7 @@
         if (!tracing_possible_) {
           std::cerr << "ERROR: Tracing has not been enabled at compile time."
                     << std::endl;
+          exit_app = true;
           return false;
         }
         TraceOn();
@@ -101,6 +99,7 @@
         break;
       case ':':  // missing argument
         std::cerr << "ERROR: Missing argument." << std::endl << std::endl;
+        exit_app = true;
         return false;
       case '?':
       default:;
@@ -115,6 +114,7 @@
   // Parse arguments for all registered extensions
   for (auto it = extension_array_.begin(); it != extension_array_.end(); ++it) {
     if (!(*it)->ParseCLIArguments(argc, argv, exit_app)) {
+      exit_app = true;
       return false;
       if (exit_app) {
         return true;
diff --git a/hw/dv/verilator/simutil_verilator/cpp/verilator_sim_ctrl.h b/hw/dv/verilator/simutil_verilator/cpp/verilator_sim_ctrl.h
index dd7bb62..56e5655 100644
--- a/hw/dv/verilator/simutil_verilator/cpp/verilator_sim_ctrl.h
+++ b/hw/dv/verilator/simutil_verilator/cpp/verilator_sim_ctrl.h
@@ -57,7 +57,9 @@
   /**
    * Parse command line arguments
    *
-   * Process all recognized command-line arguments from argc/argv.
+   * Process all recognized command-line arguments from argc/argv. If a command
+   * line argument implies that we should exit immediately (like --help), sets
+   * exit_app. On failure, sets exit_app as well as returning false.
    *
    * @param argc, argv Standard C command line arguments
    * @param exit_app Indicate that program should terminate