From a32c83e1be3e65d73e2b8a346db721a891401acf Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Wed, 5 Jul 2023 08:32:05 +0200 Subject: [PATCH] fixes CLI handling of plugin paramters in ISS --- CMakeLists.txt | 14 +++++++++----- src/main.cpp | 16 ++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c5d2d5..2a36dad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,11 +40,15 @@ set(LIB_SOURCES if(TARGET ${CORE_NAME}_cpp) list(APPEND LIB_SOURCES ${${CORE_NAME}_OUTPUT_FILES}) else() - FILE(GLOB GEN_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp - ) - list(APPEND LIB_SOURCES ${GEN_SOURCES}) + FILE(GLOB GEN_ISS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp) + FILE(GLOB GEN_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp) + list(APPEND LIB_SOURCES ${GEN_ISS_SOURCES} ${GEN_VM_SOURCES}) + foreach(FILEPATH ${GEN_ISS_SOURCES}) + get_filename_component(CORE ${FILEPATH} NAME_WE) + string(TOUPPER ${CORE} CORE) + list(APPEND LIB_DEFINES CORE_${CORE}) + endforeach() + message("Defines are ${LIB_DEFINES}") endif() if(TARGET RapidJSON OR TARGET RapidJSON::RapidJSON) diff --git a/src/main.cpp b/src/main.cpp index a3999ad..5aeb3f8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,6 +31,8 @@ *******************************************************************************/ #include +#include +#include #include "iss/factory.h" #include @@ -170,27 +172,29 @@ int main(int argc, char *argv[]) { if (clim.count("plugin")) { for (std::string const& opt_val : clim["plugin"].as>()) { std::string plugin_name=opt_val; - std::string filename{"cycles.txt"}; + std::string arg{""}; std::size_t found = opt_val.find('='); if (found != std::string::npos) { plugin_name = opt_val.substr(0, found); - filename = opt_val.substr(found + 1, opt_val.size()); + arg = opt_val.substr(found + 1, opt_val.size()); } if (plugin_name == "ic") { - auto *ic_plugin = new iss::plugin::instruction_count(filename); + auto *ic_plugin = new iss::plugin::instruction_count(arg); vm->register_plugin(*ic_plugin); plugin_list.push_back(ic_plugin); } else if (plugin_name == "ce") { - auto *ce_plugin = new iss::plugin::cycle_estimate(filename); + auto *ce_plugin = new iss::plugin::cycle_estimate(arg); vm->register_plugin(*ce_plugin); plugin_list.push_back(ce_plugin); } else if (plugin_name == "pctrace") { - auto *plugin = new iss::plugin::pctrace(filename); + auto *plugin = new iss::plugin::pctrace(arg); vm->register_plugin(*plugin); plugin_list.push_back(plugin); } else { #ifndef WIN32 - std::array a{{filename.c_str()}}; + std::vector a{}; + if(arg.length()) + a.push_back({arg.c_str()}); iss::plugin::loader l(plugin_name, {{"initPlugin"}}); auto* plugin = l.call_function("initPlugin", a.size(), a.data()); if(plugin){