[nnc debug] Add command line options (#1079)
authorDenis Maksimenko/AI Tools Lab /SRR/Assistant Engineer/삼성전자 <d.maksimenko@partner.samsung.com>
Mon, 20 Aug 2018 16:58:16 +0000 (19:58 +0300)
committerРоман Михайлович Русяев/AI Tools Lab /SRR/Staff Engineer/삼성전자 <r.rusyaev@samsung.com>
Mon, 20 Aug 2018 16:58:16 +0000 (19:58 +0300)
Add options to enable nnc_debug. They will be processed later by compiler driver.

Signed-off-by: Denis Maksimenko <d.maksimenko@partner.samsung.com>
contrib/nnc/include/Options.h
contrib/nnc/src/Options.cpp
contrib/nnc/support/include/CommandLine.h
contrib/nnc/support/src/CLOptionChecker.cpp

index 2b8726e..16d808a 100644 (file)
@@ -16,6 +16,8 @@ namespace clopt
  */
 extern Option<std::string> pluginsPath;
 extern Option<bool> pluginVerbose;
+extern Option<std::string> debugMode;
+extern Option<std::string> debugZones;
 
 /**
  * @brief frontend options
index 7849e12..b0d91a6 100644 (file)
@@ -22,6 +22,16 @@ Option<bool> pluginVerbose(optname("--plugins-verbose"),
                            overview("verbose printing when plugins will be being searched"),
                            false,
                            optional(true));
+Option<std::string> debugMode(optname("--debug"),
+                               overview("turn debugging on (optional: provide filename)"),
+                               "-", // when option is not passed to command line
+                               optional(true),
+                               optvalues(""),
+                               checkDebugFile);
+Option<std::string> debugZones(optname("--debug-area"),
+                               overview("if specified, debug code will be executed only in given areas"),
+                               "",
+                               optional(true));
 
 /**
  * @breif Options for frontend
index 63d2ec1..4cf9c19 100644 (file)
@@ -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
index 4722c7e..b275202 100644 (file)
@@ -4,6 +4,7 @@
 #include "CommandLine.h"
 
 #include <sys/types.h>
+#include <unistd.h>
 #include <dirent.h>
 
 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<const Option<std::string> &>(option);
+
+  if (access(in_file.c_str(), W_OK) != 0) {
+    throw BadOption("Has no permission to open debug output file");
+  }
+} // checkDebugFile
+
 } // clopt
 } // contirb
 } // nncc