fixes CLI handling of plugin paramters in ISS

This commit is contained in:
Eyck Jentzsch 2023-07-05 08:32:05 +02:00
parent 7e45a25218
commit a32c83e1be
2 changed files with 19 additions and 11 deletions

View File

@ -40,11 +40,15 @@ set(LIB_SOURCES
if(TARGET ${CORE_NAME}_cpp) if(TARGET ${CORE_NAME}_cpp)
list(APPEND LIB_SOURCES ${${CORE_NAME}_OUTPUT_FILES}) list(APPEND LIB_SOURCES ${${CORE_NAME}_OUTPUT_FILES})
else() else()
FILE(GLOB GEN_SOURCES FILE(GLOB GEN_ISS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp)
${CMAKE_CURRENT_SOURCE_DIR}/src-gen/iss/arch/*.cpp FILE(GLOB GEN_VM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src-gen/vm/interp/vm_*.cpp)
${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})
list(APPEND LIB_SOURCES ${GEN_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() endif()
if(TARGET RapidJSON OR TARGET RapidJSON::RapidJSON) if(TARGET RapidJSON OR TARGET RapidJSON::RapidJSON)

View File

@ -31,6 +31,8 @@
*******************************************************************************/ *******************************************************************************/
#include <iostream> #include <iostream>
#include <vector>
#include <array>
#include "iss/factory.h" #include "iss/factory.h"
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
@ -170,27 +172,29 @@ int main(int argc, char *argv[]) {
if (clim.count("plugin")) { if (clim.count("plugin")) {
for (std::string const& opt_val : clim["plugin"].as<std::vector<std::string>>()) { for (std::string const& opt_val : clim["plugin"].as<std::vector<std::string>>()) {
std::string plugin_name=opt_val; std::string plugin_name=opt_val;
std::string filename{"cycles.txt"}; std::string arg{""};
std::size_t found = opt_val.find('='); std::size_t found = opt_val.find('=');
if (found != std::string::npos) { if (found != std::string::npos) {
plugin_name = opt_val.substr(0, found); 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") { 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); vm->register_plugin(*ic_plugin);
plugin_list.push_back(ic_plugin); plugin_list.push_back(ic_plugin);
} else if (plugin_name == "ce") { } 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); vm->register_plugin(*ce_plugin);
plugin_list.push_back(ce_plugin); plugin_list.push_back(ce_plugin);
} else if (plugin_name == "pctrace") { } else if (plugin_name == "pctrace") {
auto *plugin = new iss::plugin::pctrace(filename); auto *plugin = new iss::plugin::pctrace(arg);
vm->register_plugin(*plugin); vm->register_plugin(*plugin);
plugin_list.push_back(plugin); plugin_list.push_back(plugin);
} else { } else {
#ifndef WIN32 #ifndef WIN32
std::array<char const*, 1> a{{filename.c_str()}}; std::vector<char const*> a{};
if(arg.length())
a.push_back({arg.c_str()});
iss::plugin::loader l(plugin_name, {{"initPlugin"}}); iss::plugin::loader l(plugin_name, {{"initPlugin"}});
auto* plugin = l.call_function<iss::vm_plugin*>("initPlugin", a.size(), a.data()); auto* plugin = l.call_function<iss::vm_plugin*>("initPlugin", a.size(), a.data());
if(plugin){ if(plugin){