From 788b5893060f19a95fdfe33f74c3c3efc1bfbc1a Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Wed, 20 Jul 2016 14:08:32 +0200 Subject: [PATCH] debugger: changed dprintcalls argument to limit number of displayed calls; fixed log function in custom ports to no longer cause compilation errors Change-Id: I234ee29060574fe5ff3de50d717b209899f5d2e9 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- compiler2/DebuggerStuff.cc | 4 +++- compiler2/ttcn3/AST_ttcn3.cc | 39 +++++++++++++++++------------------- core/Debugger.cc | 20 ++++++++++++------ 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/compiler2/DebuggerStuff.cc b/compiler2/DebuggerStuff.cc index 955f462bd..2fbbd2864 100644 --- a/compiler2/DebuggerStuff.cc +++ b/compiler2/DebuggerStuff.cc @@ -123,7 +123,6 @@ void calculate_type_name_and_debug_functions_from_type(Type* p_type, else if (p_type_last->is_structured_type() || p_type_last->get_typetype() == Type::T_ENUM_A || p_type_last->get_typetype() == Type::T_ENUM_T || - p_type_last->get_typetype() == Type::T_PORT || p_type_last->get_typetype() == Type::T_SIGNATURE || p_type_last->get_typetype() == Type::T_FUNCTION || p_type_last->get_typetype() == Type::T_ALTSTEP || @@ -165,6 +164,9 @@ void calculate_type_name_and_debug_functions_from_type(Type* p_type, // these ASN.1 string types are not converted right by Type::get_typetype_ttcn3() p_type_name = "universal charstring"; break; + case Type::T_PORT: + p_type_name = "port"; + break; case Type::T_UNRESTRICTEDSTRING: case Type::T_EMBEDDED_PDV: case Type::T_EXTERNAL: diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index 6859e36cc..44ecabe06 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -2918,7 +2918,8 @@ namespace Ttcn { Def_Type* def = dynamic_cast<Def_Type*>(asss->get_ass_byIndex(i)); if (def != NULL) { Type* t = def->get_Type(); - if (!t->is_ref() && t->get_typetype() != Type::T_COMPONENT) { + if (!t->is_ref() && t->get_typetype() != Type::T_COMPONENT && + t->get_typetype() != Type::T_PORT) { // don't generate code for subtypes if (t->get_typetype() != Type::T_SIGNATURE) { print_str = mputprintf(print_str, @@ -2927,30 +2928,26 @@ namespace Ttcn { " }\n" , (print_str != NULL) ? "else " : "" , t->get_dispname().c_str(), t->get_genname_value(this).c_str()); - if (t->get_typetype() != Type::T_PORT) { - overwrite_str = mputprintf(overwrite_str, - " %sif (!strcmp(p_var.type_name, \"%s\")) {\n" - " ((%s*)p_var.value)->set_param(p_new_value);\n" - " }\n" - , (overwrite_str != NULL) ? "else " : "" - , t->get_dispname().c_str(), t->get_genname_value(this).c_str()); - } + overwrite_str = mputprintf(overwrite_str, + " %sif (!strcmp(p_var.type_name, \"%s\")) {\n" + " ((%s*)p_var.value)->set_param(p_new_value);\n" + " }\n" + , (overwrite_str != NULL) ? "else " : "" + , t->get_dispname().c_str(), t->get_genname_value(this).c_str()); } - if (t->get_typetype() != Type::T_PORT) { - print_str = mputprintf(print_str, + print_str = mputprintf(print_str, + " %sif (!strcmp(p_var.type_name, \"%s template\")) {\n" + " ((const %s_template*)ptr)->log();\n" + " }\n" + , (print_str != NULL) ? "else " : "" + , t->get_dispname().c_str(), t->get_genname_value(this).c_str()); + if (t->get_typetype() != Type::T_SIGNATURE) { + overwrite_str = mputprintf(overwrite_str, " %sif (!strcmp(p_var.type_name, \"%s template\")) {\n" - " ((const %s_template*)ptr)->log();\n" + " ((%s_template*)p_var.value)->set_param(p_new_value);\n" " }\n" - , (print_str != NULL) ? "else " : "" + , (overwrite_str != NULL) ? "else " : "" , t->get_dispname().c_str(), t->get_genname_value(this).c_str()); - if (t->get_typetype() != Type::T_SIGNATURE) { - overwrite_str = mputprintf(overwrite_str, - " %sif (!strcmp(p_var.type_name, \"%s template\")) {\n" - " ((%s_template*)p_var.value)->set_param(p_new_value);\n" - " }\n" - , (overwrite_str != NULL) ? "else " : "" - , t->get_dispname().c_str(), t->get_genname_value(this).c_str()); - } } } } diff --git a/core/Debugger.cc b/core/Debugger.cc index d9b3a96f5..7bae62626 100644 --- a/core/Debugger.cc +++ b/core/Debugger.cc @@ -576,20 +576,25 @@ void TTCN3_Debugger::print_function_calls(const char* p_amount) function_calls.buffer.start == (function_calls.buffer.end + 1) % function_calls.buffer.size) ? function_calls.buffer.size : function_calls.buffer.end + 1; + bool invalid_arg = false; if (p_amount == NULL || strcmp(p_amount, "all") == 0) { amount = limit; } else if (is_numeric(p_amount)) { amount = strtol(p_amount, NULL, 10); - if (amount == 0 || amount > limit) { - print(DRET_NOTIFICATION, "Invalid number of function calls. Expected 1 - %d.", - limit); - return; + if (amount == 0) { + invalid_arg = true; + } + else if (amount > limit) { + amount = limit; } } else { - print(DRET_NOTIFICATION, "Argument 1 is invalid. Expected 'all' or integer " - "value (number of calls)."); + invalid_arg = true; + } + if (invalid_arg) { + print(DRET_NOTIFICATION, "Argument 1 is invalid. Expected 'all' or non-zero " + "integer value (number of calls)."); return; } for (int i = (function_calls.buffer.end - amount + function_calls.buffer.size + 1) % @@ -1230,6 +1235,9 @@ CHARSTRING TTCN3_Debugger::print_base_var(const TTCN3_Debugger::variable_t& p_va else if (!strcmp(p_var.type_name, "component template")) { ((const COMPONENT_template*)ptr)->log(); } + else if (!strcmp(p_var.type_name, "port")) { + ((const PORT*)ptr)->log(); // virtual + } else if (!strcmp(p_var.type_name, "default")) { ((const DEFAULT*)ptr)->log(); } -- GitLab