debugger: added help in single mode UI, plus minor fixes
authorBotond Baranyi <botond.baranyi@ericsson.com>
Wed, 8 Jun 2016 13:49:57 +0000 (15:49 +0200)
committerBotond Baranyi <botond.baranyi@ericsson.com>
Wed, 8 Jun 2016 13:49:57 +0000 (15:49 +0200)
Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com>
compiler2/DebuggerStuff.cc
compiler2/makefile.c
core/Component.cc
core/Debugger.cc
core/Debugger.hh
core/DebuggerUI.cc
core/DebuggerUI.hh
mctr2/cli/Cli.cc

index f379c09730fc43b848ed30aa1e7b386f79778567..72de2f91af3c8ddcc8159a8d3284df25018bc123 100644 (file)
@@ -204,7 +204,7 @@ char* generate_code_debugger_add_var(char* str, Common::Assignment* var_ass,
   case Common::Assignment::A_MODULEPAR:
   case Common::Assignment::A_MODULEPAR_TEMP:
   case Common::Assignment::A_TEMPLATE:
-    is_constant = scope_name != NULL;
+    is_constant = true; //scope_name != NULL;
   default:
     break;
   }
index 0c5639d28e03710aa389e1b8b80485fd6d2e3111..7d54fb21f9193bc0c340cecd4a41a87f93237971 100644 (file)
@@ -2018,7 +2018,7 @@ static void print_makefile(struct makefile_struct *makefile)
           "AR = ar\n"
           "ARFLAGS = \n\n"
           "# Flags for the TTCN-3 and ASN.1 compiler:\n"
-          "COMPILER_FLAGS =%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n\n"
+          "COMPILER_FLAGS =%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n\n"
           "# Execution mode: (either ttcn3 or ttcn3-parallel)\n"
           "TTCN3_LIB = ttcn3%s%s%s\n\n"
 #ifdef LICENSE
index f01d540f0f0ea380f1d6cacb479a33a123c793f2..72d63ef7f3fd90066ddb5f338c0ae9a6943ca7c8 100644 (file)
@@ -141,8 +141,9 @@ void COMPONENT::set_param(Module_Param& param) {
   if (param.get_type() == Module_Param::MP_Reference) {
     mp = param.get_referenced_param();
   }
-  if (Ttcn_String_Parsing::happening()) {
-    // accept all component values in case it's a string2ttcn operation
+  if (Ttcn_String_Parsing::happening() || Debugger_Value_Parsing::happening()) {
+    // accept all component values in case it's a string2ttcn operation or
+    // an overwrite operation through the debugger
     switch (mp->get_type()) {
     case Module_Param::MP_Integer:
       component_value = (component)mp->get_integer()->get_val();
index 5d5642508fbef1dd0c98f54c9d7156d2b788a703..97a8643e470bbdce9f132399f81e1770f021c9db 100644 (file)
@@ -657,7 +657,7 @@ void TTCN3_Debugger::test_execution_started()
       halt(NULL, false);
     }
   }
-  halt_at_start = false;
+  halt_at_start = true;
 }
 
 void TTCN3_Debugger::test_execution_finished()
index de6eac1d09ae473af184f7f4682a0acfd8ecb19c..be101ea0bd4c4c71477b30727c03f8bfbf7d9d4b 100644 (file)
@@ -223,13 +223,13 @@ private:
   /** adds a new breakpoint at the specified module and line with the specified
     * batch file (if not NULL), or changes the batch file of an existing
     * breakpoint
-    * handles the D_ADD_BREAKPOINT command */
+    * handles the D_SET_BREAKPOINT command */
   void set_breakpoint(const char* p_module, int p_line, const char* batch_file);
   
   /** removes the breakpoint from the specified module/line, if it exists
     * can also be used to remove all breakpoints from the specified module or
     * all breakpoints in all modules
-    * handles the D_REMOVE_BREAKPOINT command  */
+    * handles the D_REMOVE_BREAKPOINT command */
   void remove_breakpoint(const char* p_module, const char* p_line);
   
   /** switches an automatic breakpoint related to the specified event on or off
@@ -253,9 +253,19 @@ private:
   
   /** finds the variable with the specified name, and prints its value or an
     * error message
+    * the variable's value is printed using its log() function
     * handles (one parameter of) the D_PRINT_VARIABLE command */
   void print_variable(const char* p_var_name);
   
+  /** finds the variable with the specified name, and overwrites its value or
+    * displays an error message
+    * the new value is received in a string array; this is concatenated into one
+    * string (with one space separating each string element); then it is passed 
+    * to the module parameter parser, which creates a Module_Param object from it
+    * (if its syntax is correct)
+    * the variable's value is overwritten by passing the Module_Param object to
+    * its set_param() function
+    * handles the D_OVERWRITE_VARIABLE command */
   void overwrite_variable(const char* p_var_name, int p_value_element_count,
     char** p_value_elements);
   
index 4ca6e5b055cd23f558b1ae37cf9c939c4df1afb1..08509aa4e6727201a0e1a46f8301fdec131f997b 100644 (file)
@@ -20,6 +20,7 @@
 
 #define PROMPT_TEXT "DEBUG> "
 #define BATCH_TEXT "batch"
+#define HELP_TEXT "help"
 
 // use a different file, than the MCTR CLI, since not all commands are the same
 #define TTCN3_HISTORY_FILENAME ".ttcn3_history_single"
@@ -30,7 +31,7 @@ const TTCN_Debugger_UI::command_t TTCN_Debugger_UI::debug_command_list[] = {
   { D_SET_BREAKPOINT_TEXT, D_SET_BREAKPOINT,
     D_SET_BREAKPOINT_TEXT " <module> <line> [<batch_file>]",
     "Add a breakpoint at the specified location, or change the batch file of "
-    " an existing breakpoint." },
+    "an existing breakpoint." },
   { D_REMOVE_BREAKPOINT_TEXT, D_REMOVE_BREAKPOINT,
     D_REMOVE_BREAKPOINT_TEXT " all|<module> [all|<line>]", "Remove a breakpoint, "
     "or all breakpoints from a module, or all breakpoints from all modules." },
@@ -46,8 +47,8 @@ const TTCN_Debugger_UI::command_t TTCN_Debugger_UI::debug_command_list[] = {
     "Set whether a batch file should be executed automatically when test execution "
     "is halted (breakpoint-specific batch files override this setting)." },
   { D_SET_COMPONENT_TEXT, D_SET_COMPONENT,
-    D_SET_COMPONENT_TEXT " mtc|<component_reference>",
-    "Set the test component to print debug information from." },
+    D_SET_COMPONENT_TEXT " mtc|<component_reference>", "Set the test component "
+    "to print debug information from (not available in single mode)." },
   { D_PRINT_CALL_STACK_TEXT, D_PRINT_CALL_STACK, D_PRINT_CALL_STACK_TEXT,
     "Print call stack." },
   { D_SET_STACK_LEVEL_TEXT, D_SET_STACK_LEVEL, D_SET_STACK_LEVEL_TEXT " <level>",
@@ -158,9 +159,44 @@ void TTCN_Debugger_UI::process_command(const char* p_line_read)
     execute_batch_file(p_line_read + start);
     return;
   }
+  if (!strncmp(p_line_read + start, HELP_TEXT, end - start)) {
+    start = end;
+    get_next_argument_loc(p_line_read, len, start, end); // just to skip to the argument
+    help(p_line_read + start);
+    return;
+  }
   puts("Unknown command, try again...");
 }
 
+void TTCN_Debugger_UI::help(const char* p_argument)
+{
+  if (*p_argument == 0) {
+    puts("Help is available for the following commands:");
+    printf(BATCH_TEXT);
+    for (const command_t *command = debug_command_list;
+         command->name != NULL; command++) {
+      printf(" %s", command->name);
+    }
+    putchar('\n');
+  }
+  else {
+    for (const command_t *command = debug_command_list;
+         command->name != NULL; command++) {
+      if (!strncmp(p_argument, command->name, strlen(command->name))) {
+        printf("%s usage: %s\n%s\n", command->name, command->synopsis,
+          command->description);
+        return;
+      }
+    }
+    if (!strcmp(p_argument, BATCH_TEXT)) {
+      puts(BATCH_TEXT " usage: " BATCH_TEXT "\nRun commands from batch file.");
+    }
+    else {
+      printf("No help for %s.\n", p_argument);
+    }
+  }
+}
+
 void TTCN_Debugger_UI::init()
 {
   // initialize history library
index b3da252955d420a13afe441b09142bc7fb64fd21..f81513c8f153e81c7b5c097003005f3538130a1e 100644 (file)
@@ -44,6 +44,8 @@ class TTCN_Debugger_UI {
     * if it's not valid, an error message is displayed */
   static void process_command(const char* p_line_read);
   
+  static void help(const char* p_argument);
+  
 public:
   
   /** initializes the UI */
index 3216e558a95b2c45c50b0943a232e89d8b98e28b..bf10cfb2f0c8e49819d9590618f8f7f8f88a0a91 100644 (file)
@@ -120,7 +120,7 @@ static const DebugCommand debug_command_list[] = {
   { D_SET_BREAKPOINT_TEXT, D_SET_BREAKPOINT,
     D_SET_BREAKPOINT_TEXT " <module> <line> [<batch_file>]",
     "Add a breakpoint at the specified location, or change the batch file of "
-    " an existing breakpoint." },
+    "an existing breakpoint." },
   { D_REMOVE_BREAKPOINT_TEXT, D_REMOVE_BREAKPOINT,
     D_REMOVE_BREAKPOINT_TEXT " all|<module> [all|<line>]", "Remove a breakpoint, "
     "or all breakpoints from a module, or all breakpoints from all modules." },
@@ -480,6 +480,11 @@ void Cli::processCommand(char *line_read)
       memset(line_read, ' ', command_name_len);
       stripLWS(line_read);
       MainController::debug_command(command->commandID, line_read);
+      if (waitState == WAIT_EXECUTE_LIST && command->commandID == D_EXIT &&
+          !strcmp(line_read, "all")) {
+        // stop executing the list from the config file
+        waitState = WAIT_NOTHING;
+      }
       return;
     }
   }
@@ -733,11 +738,11 @@ void Cli::helpCallback(const char *arguments)
     puts("Help is available for the following commands:");
     for (const Command *command = command_list;
       command->name != NULL; command++) {
-      printf(" %s", command->name);
+      printf("%s ", command->name);
     }
     for (const DebugCommand *command = debug_command_list;
          command->name != NULL; command++) {
-      printf(" %s", command->name);
+      printf("%s ", command->name);
     }
     putchar('\n');
   } else {
This page took 0.031776 seconds and 5 git commands to generate.