From: Botond Baranyi Date: Wed, 8 Jun 2016 13:49:57 +0000 (+0200) Subject: debugger: added help in single mode UI, plus minor fixes X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=f57971feb6c9686f818a42258f37c751aad1f0a7;p=deliverable%2Ftitan.core.git debugger: added help in single mode UI, plus minor fixes Signed-off-by: Botond Baranyi --- diff --git a/compiler2/DebuggerStuff.cc b/compiler2/DebuggerStuff.cc index f379c09..72de2f9 100644 --- a/compiler2/DebuggerStuff.cc +++ b/compiler2/DebuggerStuff.cc @@ -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; } diff --git a/compiler2/makefile.c b/compiler2/makefile.c index 0c5639d..7d54fb2 100644 --- a/compiler2/makefile.c +++ b/compiler2/makefile.c @@ -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 diff --git a/core/Component.cc b/core/Component.cc index f01d540..72d63ef 100644 --- a/core/Component.cc +++ b/core/Component.cc @@ -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(); diff --git a/core/Debugger.cc b/core/Debugger.cc index 5d56425..97a8643 100644 --- a/core/Debugger.cc +++ b/core/Debugger.cc @@ -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() diff --git a/core/Debugger.hh b/core/Debugger.hh index de6eac1..be101ea 100644 --- a/core/Debugger.hh +++ b/core/Debugger.hh @@ -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); diff --git a/core/DebuggerUI.cc b/core/DebuggerUI.cc index 4ca6e5b..08509aa 100644 --- a/core/DebuggerUI.cc +++ b/core/DebuggerUI.cc @@ -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 " []", "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| [all|]", "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|", - "Set the test component to print debug information from." }, + D_SET_COMPONENT_TEXT " mtc|", "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 " ", @@ -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 diff --git a/core/DebuggerUI.hh b/core/DebuggerUI.hh index b3da252..f81513c 100644 --- a/core/DebuggerUI.hh +++ b/core/DebuggerUI.hh @@ -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 */ diff --git a/mctr2/cli/Cli.cc b/mctr2/cli/Cli.cc index 3216e55..bf10cfb 100644 --- a/mctr2/cli/Cli.cc +++ b/mctr2/cli/Cli.cc @@ -120,7 +120,7 @@ static const DebugCommand debug_command_list[] = { { D_SET_BREAKPOINT_TEXT, D_SET_BREAKPOINT, D_SET_BREAKPOINT_TEXT " []", "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| [all|]", "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 {