diff --git a/target/common/test/tb_bin.cc b/target/common/test/tb_bin.cc index 1177ae154..d8827fd2b 100644 --- a/target/common/test/tb_bin.cc +++ b/target/common/test/tb_bin.cc @@ -3,22 +3,24 @@ // SPDX-License-Identifier: SHL-0.51 #include +#include #include #include -#include #include "sim.hh" // Declare these as global variables bool WRAPPER_disable_tracing = false; -char* WRAPPER_trace_prefix = nullptr; +char *WRAPPER_trace_prefix = nullptr; void print_usage(const char *prog_name) { - std::cout << "Usage: " << prog_name << " [SNAX WRAPPER Options] [HTIF Options]\n" + std::cout << "Usage: " << prog_name + << " [SNAX WRAPPER Options] [HTIF Options]\n" << " Wrap Rocket Chip Emulator in SNAX RTL Simulator\n\n" << "SNAX WRAPPER Options:\n" << " --disable-tracing Disable Snitch tracing\n" - << " --prefix-trace=PREFIX Set trace prefix (cannot be used with --disable-tracing)\n\n"; + << " --prefix-trace=PREFIX Set trace prefix (cannot be used " + "with --disable-tracing)\n\n"; } int main(int argc, char **argv, char **env) { @@ -37,36 +39,41 @@ int main(int argc, char **argv, char **env) { if (strcmp(argv[i], "--disable-tracing") == 0) { WRAPPER_disable_tracing = true; } else if (strncmp(argv[i], "--prefix-trace=", 15) == 0) { - WRAPPER_trace_prefix = argv[i] + 15; // Extract the value after `--prefix-trace=` - } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { + WRAPPER_trace_prefix = + argv[i] + 15; // Extract the value after `--prefix-trace=` + } else if (strcmp(argv[i], "-h") == 0 || + strcmp(argv[i], "--help") == 0) { print_usage(argv[0]); - // Also show help from underlying fesvr function - // Note: - // If a binary is supplied, it will show both the snax wrapper help, - // AND continue with the execution of the program... - auto sim = std::make_unique(argc, argv); - return sim->run(); + // Also show help from underlying fesvr function + // Note: + // If a binary is supplied, it will show both the snax wrapper help, + // AND continue with the execution of the program... + auto sim = std::make_unique(argc, argv); + return sim->run(); return -1; } } // Validate conflicting options if (WRAPPER_disable_tracing && WRAPPER_trace_prefix != nullptr) { - std::cerr << "Error: --disable-tracing and --prefix-trace cannot be used together.\n"; - return 1; // Indicate an error + std::cerr << "Error: --disable-tracing and --prefix-trace cannot be " + "used together.\n"; + return 1; } // Prepare filtered arguments std::vector filtered_argv; for (int i = 0; i < argc; ++i) { // Skip custom options - if (strcmp(argv[i], "--disable-tracing") == 0 || strncmp(argv[i], "--prefix-trace=", 15) == 0) { + if (strcmp(argv[i], "--disable-tracing") == 0 || + strncmp(argv[i], "--prefix-trace=", 15) == 0) { continue; } filtered_argv.push_back(argv[i]); } - filtered_argv.push_back(nullptr); // Null-terminate for compatibility + filtered_argv.push_back(nullptr); // Null-terminate for compatibility // Pass the filtered arguments to fesvr argument handling - int filtered_argc = static_cast(filtered_argv.size()) - 1; // Exclude null terminator + int filtered_argc = + static_cast(filtered_argv.size()) - 1; // Exclude null terminator char **filtered_argv_ptr = filtered_argv.data(); auto sim = std::make_unique(filtered_argc, filtered_argv_ptr); return sim->run(); diff --git a/target/common/test/verilator_lib.cc b/target/common/test/verilator_lib.cc index ab674eb8d..09622a784 100644 --- a/target/common/test/verilator_lib.cc +++ b/target/common/test/verilator_lib.cc @@ -3,8 +3,8 @@ // SPDX-License-Identifier: SHL-0.51 #include -#include #include +#include #include "Vtestharness.h" #include "Vtestharness__Dpi.h" @@ -15,7 +15,7 @@ // Declare these as globally declared (and parsed) in tb_bin.cc extern bool WRAPPER_disable_tracing; -extern char* WRAPPER_trace_prefix; +extern char *WRAPPER_trace_prefix; namespace sim { @@ -118,9 +118,9 @@ svBit disable_tracing() { return WRAPPER_disable_tracing; } -const char* get_trace_file_prefix() { - if (WRAPPER_trace_prefix == nullptr){ - // Use the standard prefix, and create a logs directory if necessary +const char *get_trace_file_prefix() { + if (WRAPPER_trace_prefix == nullptr) { + // Use the standard prefix, and create a logs directory if necessary std::string foldername = "logs/"; std::filesystem::create_directories(foldername); static std::string log_file_name = "logs/";