From 495db5b86cb4ba8d6068bfd7da0aa1399eee4a73 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Denis=20Maksimenko/AI=20Tools=20Lab=20/SRR/Assistant=20Engi?= =?utf8?q?neer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 20 Aug 2018 19:58:16 +0300 Subject: [PATCH] [nnc debug] Add command line options (#1079) Add options to enable nnc_debug. They will be processed later by compiler driver. Signed-off-by: Denis Maksimenko --- contrib/nnc/include/Options.h | 2 ++ contrib/nnc/src/Options.cpp | 10 ++++++++++ contrib/nnc/support/include/CommandLine.h | 1 + contrib/nnc/support/src/CLOptionChecker.cpp | 10 ++++++++++ 4 files changed, 23 insertions(+) diff --git a/contrib/nnc/include/Options.h b/contrib/nnc/include/Options.h index 2b8726e..16d808a 100644 --- a/contrib/nnc/include/Options.h +++ b/contrib/nnc/include/Options.h @@ -16,6 +16,8 @@ namespace clopt */ extern Option pluginsPath; extern Option pluginVerbose; +extern Option debugMode; +extern Option debugZones; /** * @brief frontend options diff --git a/contrib/nnc/src/Options.cpp b/contrib/nnc/src/Options.cpp index 7849e12..b0d91a6 100644 --- a/contrib/nnc/src/Options.cpp +++ b/contrib/nnc/src/Options.cpp @@ -22,6 +22,16 @@ Option pluginVerbose(optname("--plugins-verbose"), overview("verbose printing when plugins will be being searched"), false, optional(true)); +Option debugMode(optname("--debug"), + overview("turn debugging on (optional: provide filename)"), + "-", // when option is not passed to command line + optional(true), + optvalues(""), + checkDebugFile); +Option debugZones(optname("--debug-area"), + overview("if specified, debug code will be executed only in given areas"), + "", + optional(true)); /** * @breif Options for frontend diff --git a/contrib/nnc/support/include/CommandLine.h b/contrib/nnc/support/include/CommandLine.h index 63d2ec1..4cf9c19 100644 --- a/contrib/nnc/support/include/CommandLine.h +++ b/contrib/nnc/support/include/CommandLine.h @@ -503,6 +503,7 @@ void checkInFile(const BaseOption &); void checkOutFile(const BaseOption &); void checkOutDir(const BaseOption &); void checkPluginsPath(const BaseOption &); +void checkDebugFile(const BaseOption &); } // namespace clopt } // namespace contrib diff --git a/contrib/nnc/support/src/CLOptionChecker.cpp b/contrib/nnc/support/src/CLOptionChecker.cpp index 4722c7e..b275202 100644 --- a/contrib/nnc/support/src/CLOptionChecker.cpp +++ b/contrib/nnc/support/src/CLOptionChecker.cpp @@ -4,6 +4,7 @@ #include "CommandLine.h" #include +#include #include using namespace nncc::contrib::clopt; @@ -99,6 +100,15 @@ void checkOutDir(const BaseOption &option) } // checkOutDir +void checkDebugFile(const BaseOption &option) +{ + auto &in_file = dynamic_cast &>(option); + + if (access(in_file.c_str(), W_OK) != 0) { + throw BadOption("Has no permission to open debug output file"); + } +} // checkDebugFile + } // clopt } // contirb } // nncc -- 2.7.4