diff options
author | gatecat <gatecat@ds0.me> | 2021-09-17 09:29:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-17 09:29:38 +0100 |
commit | 7c82a04df5f5ba963791c327d5f9282cb20b4261 (patch) | |
tree | 3495455016bbdabf032cdca3ae2c60cbced58cfb /common/command.cc | |
parent | 67bd349e8f38d91a15f54340b29cc77ef156727f (diff) | |
parent | 1e4f706ace7d84f8edcfd74ae444047fab836f77 (diff) | |
download | nextpnr-7c82a04df5f5ba963791c327d5f9282cb20b4261.tar.gz nextpnr-7c82a04df5f5ba963791c327d5f9282cb20b4261.tar.bz2 nextpnr-7c82a04df5f5ba963791c327d5f9282cb20b4261.zip |
Merge pull request #813 from YosysHQ/gatecat/py-on-fail
command: Allow running Python on failure for state introspection
Diffstat (limited to 'common/command.cc')
-rw-r--r-- | common/command.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/common/command.cc b/common/command.cc index 34bb93cb..954a3442 100644 --- a/common/command.cc +++ b/common/command.cc @@ -122,6 +122,8 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("pre-place", po::value<std::vector<std::string>>(), "python file to run before placement"); general.add_options()("pre-route", po::value<std::vector<std::string>>(), "python file to run before routing"); general.add_options()("post-route", po::value<std::vector<std::string>>(), "python file to run after routing"); + general.add_options()("on-failure", po::value<std::vector<std::string>>(), + "python file to run in event of crash for design introspection"); #endif general.add_options()("json", po::value<std::string>(), "JSON design file to ingest"); @@ -184,6 +186,15 @@ po::options_description CommandHandler::getGeneralOptions() return general; } +namespace { +static CommandHandler *global_command_handler = nullptr; +void script_terminate_handler() +{ + if (global_command_handler != nullptr) + global_command_handler->run_script_hook("on-failure"); +} +}; // namespace + void CommandHandler::setupContext(Context *ctx) { if (ctx->settings.find(ctx->id("seed")) != ctx->settings.end()) @@ -321,6 +332,10 @@ void CommandHandler::setupContext(Context *ctx) int CommandHandler::executeMain(std::unique_ptr<Context> ctx) { + if (vm.count("on-failure")) { + global_command_handler = this; + std::set_terminate(script_terminate_handler); + } if (vm.count("test")) { ctx->archcheck(); return 0; |