Commit f08ff9ca authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Debugger - Stage 3 (artf511247)



Change-Id: Id1c3432bf8b314655b84ee653959dda2cd299c41
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 6ace577b
......@@ -37,7 +37,7 @@ include $(TOP)/Makefile.cfg
ALLDIRS := common compiler2 repgen xsdconvert
ifndef MINGW
ALLDIRS += core core2 mctr2 loggerplugins
ALLDIRS += mctr2 core core2 loggerplugins
endif
# JNI not supported on Cygwin or Mingw
......
......@@ -110,11 +110,12 @@ string array_dimensions_to_string(Ttcn::ArrayDimensions* p_dims)
return ret_val;
}
void calculate_type_name_and_print_function_from_type(Type* p_type,
Type* p_type_last,
Module* p_module,
string& p_type_name,
string& p_print_function)
void calculate_type_name_and_debug_functions_from_type(Type* p_type,
Type* p_type_last,
Module* p_module,
string& p_type_name,
string& p_print_function,
string& p_set_function)
{
if (p_type_last->get_typetype() == Type::T_COMPONENT) {
p_type_name = "component";
......@@ -142,13 +143,17 @@ void calculate_type_name_and_print_function_from_type(Type* p_type,
p_type_name = p_type_last->get_dispname();
}
const Module* var_type_mod = p_type_last->get_my_scope()->get_scope_mod();
string module_prefix;
if (var_type_mod != p_module) {
p_print_function = var_type_mod->get_modid().get_name() + "::";
module_prefix = var_type_mod->get_modid().get_name() + "::";
}
else {
p_print_function.clear();
p_print_function = module_prefix + "print_var_" +
var_type_mod->get_modid().get_ttcnname();
if (p_type_last->get_typetype() != Type::T_SIGNATURE &&
p_type_last->get_typetype() != Type::T_PORT) {
p_set_function = module_prefix + "set_var_" +
var_type_mod->get_modid().get_ttcnname();
}
p_print_function += "print_var_" + var_type_mod->get_modid().get_ttcnname();
}
else {
// built-in type, get the TTCN-3 version of the type if possible
......@@ -182,23 +187,34 @@ char* generate_code_debugger_add_var(char* str, Common::Assignment* var_ass,
}
bool is_lazy_param = false;
bool is_constant = false;
switch (var_ass->get_asstype()) {
case Common::Assignment::A_PAR_VAL:
case Common::Assignment::A_PAR_VAL_IN:
case Common::Assignment::A_PAR_TEMPL_IN:
case Common::Assignment::A_PAR_TEMPL_IN: {
if (var_ass->get_lazy_eval()) {
// lazy parameters have their own printing function
is_lazy_param = true;
}
break;
Ttcn::FormalPar* fpar = dynamic_cast<Ttcn::FormalPar*>(var_ass);
is_constant = fpar == NULL || !fpar->get_used_as_lvalue();
break; }
case Common::Assignment::A_CONST:
case Common::Assignment::A_EXT_CONST:
case Common::Assignment::A_MODULEPAR:
case Common::Assignment::A_MODULEPAR_TEMP:
case Common::Assignment::A_TEMPLATE:
is_constant = scope_name != NULL;
default:
break;
}
// recreate the TTCN-3 version of the type name and determine the type's printing function
string type_name, print_function;
// recreate the TTCN-3 version of the type name and determine the type's
// printing and overwriting functions
string type_name, print_function, set_function;
print_function = is_lazy_param ? "TTCN3_Debugger::print_lazy_param<" :
"TTCN3_Debugger::print_base_var";
set_function = "TTCN3_Debugger::set_base_var";
if (var_ass->get_asstype() == Common::Assignment::A_TIMER ||
var_ass->get_asstype() == Common::Assignment::A_PAR_TIMER) {
type_name = "timer";
......@@ -242,8 +258,9 @@ char* generate_code_debugger_add_var(char* str, Common::Assignment* var_ass,
dims_str += t->get_dimension()->get_stringRepr();
t = t->get_ofType()->get_type_refd_last();
}
string dummy;
calculate_type_name_and_print_function_from_type(t, t, current_mod, type_name, dummy);
string dummy1, dummy2;
calculate_type_name_and_debug_functions_from_type(t, t, current_mod,
type_name, dummy1, dummy2);
type_name += dims_str;
if (!is_lazy_param) {
switch (var_ass->get_asstype()) {
......@@ -257,20 +274,27 @@ char* generate_code_debugger_add_var(char* str, Common::Assignment* var_ass,
print_function = string("TTCN3_Debugger::print_template_array<") +
function_params_for_array_type(var_type, current_mod, true) +
string(">");
set_function = string("TTCN3_Debugger::set_template_array<") +
function_params_for_array_type(var_type, current_mod, true) +
string(">");
break;
default:
// value array
print_function = string("TTCN3_Debugger::print_value_array<") +
function_params_for_array_type(var_type, current_mod, false) +
string(">");
set_function = string("TTCN3_Debugger::set_value_array<") +
function_params_for_array_type(var_type, current_mod, false) +
string(">");
break;
}
}
}
else {
string dummy;
calculate_type_name_and_print_function_from_type(var_ass->get_Type(),
var_type, current_mod, type_name, is_lazy_param ? dummy : print_function);
calculate_type_name_and_debug_functions_from_type(var_ass->get_Type(),
var_type, current_mod, type_name, is_lazy_param ? dummy : print_function,
set_function);
}
}
......@@ -295,7 +319,7 @@ char* generate_code_debugger_add_var(char* str, Common::Assignment* var_ass,
print_function += ">";
}
return mputprintf(str, "%s%s_scope%sadd_variable(&%s, \"%s\", \"%s\", %s);\n",
return mputprintf(str, "%s%s_scope%sadd_variable(&%s, \"%s\", \"%s\", %s%s%s);\n",
scope_name != NULL ? " " : "", // add indenting for global variables
scope_name != NULL ? scope_name : "debug", // the prefix of the debugger scope:
// ("global" for global variables, "debug" for local variables,
......@@ -307,7 +331,9 @@ char* generate_code_debugger_add_var(char* str, Common::Assignment* var_ass,
// so the lazy parameter evaluation code is not generated)
var_ass->get_id().get_ttcnname().c_str(), // variable name in TTCN-3
type_name.c_str(), // variable type in TTCN-3, with a suffix if it's a template
print_function.c_str()); // variable printing function
print_function.c_str(), // variable printing function
is_constant ? "" : ", ", is_constant ? "" : set_function.c_str());
// variable overwriting function (not generated for constants)
}
char* generate_code_debugger_function_init(char* str, Common::Assignment* func_ass)
......
......@@ -11521,11 +11521,9 @@ error:
break;
case OPTYPE_DECODE: {
Ttcn::ActualParList *parlist = u.expr.r1->get_parlist();
Common::Assignment *ass = u.expr.r1->get_refd_assignment();
if (parlist) str = parlist->rearrange_init_code(str, usage_mod);
parlist = u.expr.r2->get_parlist();
ass = u.expr.r2->get_refd_assignment();
if (parlist) str = parlist->rearrange_init_code(str, usage_mod);
break; }
case OPTYPE_HOSTID:
......
......@@ -578,7 +578,8 @@ namespace Asn {
void Module::generate_debugger_functions(output_struct *output)
{
char* str = NULL;
char* print_str = NULL;
char* overwrite_str = NULL;
for (size_t i = 0; i < asss->get_nof_asss(); ++i) {
Asn::Assignment* asn_ass = dynamic_cast<Asn::Assignment*>(asss->get_ass_byIndex(i));
if (asn_ass->get_ass_pard() != NULL) {
......@@ -594,36 +595,58 @@ namespace Asn {
// only structured types and enums are needed
// for instances of parameterized types, the last reference, which is
// not itself an instance of a parameterized type, holds the type's display name
str = mputprintf(str,
print_str = mputprintf(print_str,
" %sif (!strcmp(p_var.type_name, \"%s\")) {\n"
" ((const %s*)p_var.value)->log();\n"
" ((const %s*)ptr)->log();\n"
" }\n"
" else if (!strcmp(p_var.type_name, \"%s template\")) {\n"
" ((const %s_template*)p_var.value)->log();\n"
" ((const %s_template*)ptr)->log();\n"
" }\n"
, (str != NULL) ? "else " : ""
, (print_str != NULL) ? "else " : ""
, t->get_dispname().c_str(), t->get_genname_value(this).c_str()
, 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"
" else if (!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()
, t->get_dispname().c_str(), t->get_genname_value(this).c_str());
}
}
}
if (str != NULL) {
if (print_str != NULL) {
// don't generate an empty printing function
output->header.class_defs = mputprintf(output->header.class_defs,
"/* Debugger printing function for types declared in this module */\n\n"
"extern CHARSTRING print_var_%s(const TTCN3_Debugger::variable_t& p_var);\n",
get_modid().get_ttcnname().c_str());
"/* Debugger printing and overwriting functions for types declared in this module */\n\n"
"extern CHARSTRING print_var_%s(const TTCN3_Debugger::variable_t& p_var);\n"
"extern boolean set_var_%s(TTCN3_Debugger::variable_t& p_var, Module_Param& p_new_value);\n",
get_modid().get_ttcnname().c_str(), get_modid().get_ttcnname().c_str());
output->source.global_vars = mputprintf(output->source.global_vars,
"\n/* Debugger printing function for types declared in this module */\n"
"CHARSTRING print_var_%s(const TTCN3_Debugger::variable_t& p_var)\n"
"{\n"
" const void* ptr = p_var.set_function != NULL ? p_var.value : p_var.cvalue;\n"
" TTCN_Logger::begin_event_log2str();\n"
"%s"
" else {\n"
" TTCN_Logger::log_event_str(\"<unrecognized value or template>\");\n"
" }\n"
" return TTCN_Logger::end_event_log2str();\n"
"}\n", get_modid().get_ttcnname().c_str(), str);
"}\n\n"
"/* Debugger overwriting function for types declared in this module */\n"
"boolean set_var_%s(TTCN3_Debugger::variable_t& p_var, Module_Param& p_new_value)\n"
"{\n"
"%s"
" else {\n"
" return FALSE;\n"
" }\n"
" return TRUE;\n"
"}\n", get_modid().get_ttcnname().c_str(), print_str,
get_modid().get_ttcnname().c_str(), overwrite_str);
}
}
......
......@@ -3,7 +3,7 @@
compiler \- TTCN-3 and ASN.1 to C++ translator
.SH SYNOPSIS
.B compiler
.RB "[\| " \-abcdEfgijlLMpqrRsStuwxXyY " \|]"
.RB "[\| " \-abcdEfgijlLMnpqrRsStuwxXyY " \|]"
.RB "[\| " \-V
.IR " verb_level" " \|]"
.RB "[\| " \-K
......@@ -167,6 +167,9 @@ operation and the
.B present
template restriction accordingly.
.TP
.B \-n
Activates the debugger and generates extra code for storing debug information.
.TP
.BI \-o " dir"
The output files (including Test Port skeletons) will be placed into
the directory specified by
......
......@@ -384,7 +384,7 @@ static boolean is_valid_asn1_filename(const char* file_name)
static void usage()
{
fprintf(stderr, "\n"
"usage: %s [-abcdEfgijlLOpqrRsStuwxXyY] [-K file] [-z file] [-V verb_level]\n"
"usage: %s [-abcdEfgijlLMnOpqrRsStuwxXyY] [-K file] [-z file] [-V verb_level]\n"
" [-o dir] [-U none|type] [-P modulename.top_level_pdu_name] [-Q number] ...\n"
" [-T] module.ttcn [-A] module.asn ...\n"
" or %s -v\n"
......@@ -405,6 +405,7 @@ static void usage()
" -l: include source line info in C++ code\n"
" -L: add source line info for logging\n"
" -M: allow 'omit' in template value lists (legacy behavior)\n"
" -n: activate debugger (generates extra code for debugging)\n"
" -o dir: output files will be placed into dir\n"
" -p: parse only (no semantic check or code generation)\n"
" -P pduname: define top-level pdu\n"
......@@ -791,7 +792,7 @@ int main(int argc, char *argv[])
break;
}
}
/* Checking incompatible options */
if (vflag) {
if (Aflag || Lflag || Pflag || Tflag || Vflag || Yflag ||
......
......@@ -262,6 +262,7 @@ struct makefile_struct {
boolean outparamboundness;
boolean omit_in_value_list;
boolean warnings_for_bad_variants;
boolean activate_debugger;
boolean disable_predef_ext_folder;
struct string_list* solspeclibraries; /* not owned */
struct string_list* sol8speclibraries; /* not owned */
......@@ -327,6 +328,7 @@ static void init_makefile_struct(struct makefile_struct *makefile)
makefile->outparamboundness = FALSE;
makefile->omit_in_value_list = FALSE;
makefile->warnings_for_bad_variants = FALSE;
makefile->activate_debugger = FALSE;
makefile->solspeclibraries = NULL;
makefile->sol8speclibraries = NULL;
makefile->linuxspeclibraries = NULL;
......@@ -2054,6 +2056,7 @@ static void print_makefile(struct makefile_struct *makefile)
(makefile->outparamboundness ? " -Y" : ""),
(makefile->omit_in_value_list ? " -M" : ""),
(makefile->warnings_for_bad_variants ? " -E" : ""),
(makefile->activate_debugger ? " -n" : ""),
(makefile->tcov_file_name ? makefile->tcov_file_name : ""),
(makefile->profiled_file_list ? " -z $(PROFILED_FILE_LIST)" : ""),
/* end of COMPILER FLAGS */
......@@ -2939,7 +2942,7 @@ static void print_makefile(struct makefile_struct *makefile)
"# Platform specific additional libraries:\n"
"#\n", fp);
fputs("SOLARIS_LIBS = -lsocket -lnsl -lxml2", fp);
fputs("SOLARIS_LIBS = -lsocket -lnsl -lxml2 -lcurses", fp);
#ifdef USAGE_STATS
fputs(" -lresolv", fp);
#endif
......@@ -2954,7 +2957,7 @@ static void print_makefile(struct makefile_struct *makefile)
}
fputs("\n", fp);
fputs("SOLARIS8_LIBS = -lsocket -lnsl -lxml2", fp);
fputs("SOLARIS8_LIBS = -lsocket -lnsl -lxml2 -lcurses", fp);
#ifdef USAGE_STATS
fputs(" -lresolv", fp);
#endif
......@@ -2969,7 +2972,7 @@ static void print_makefile(struct makefile_struct *makefile)
}
fputs("\n", fp);
fputs("LINUX_LIBS = -lxml2", fp);
fputs("LINUX_LIBS = -lxml2 -lncurses", fp);
#ifdef USAGE_STATS
fputs(" -lpthread -lrt", fp);
#endif
......@@ -2984,7 +2987,7 @@ static void print_makefile(struct makefile_struct *makefile)
}
fputs("\n", fp);
fputs("FREEBSD_LIBS = -lxml2", fp);
fputs("FREEBSD_LIBS = -lxml2 -lncurses", fp);
if (makefile->freebsdspeclibraries) {
struct string_list* act_elem = makefile->freebsdspeclibraries;
while (act_elem) {
......@@ -2996,7 +2999,7 @@ static void print_makefile(struct makefile_struct *makefile)
}
fputs("\n", fp);
fputs("WIN32_LIBS = -lxml2", fp);
fputs("WIN32_LIBS = -lxml2 -lncurses", fp);
if (makefile->win32speclibraries) {
struct string_list* act_elem = makefile->win32speclibraries;
while (act_elem) {
......@@ -3816,7 +3819,8 @@ static void generate_makefile(size_t n_arguments, char *arguments[],
const char* cxxcompiler, const char* optlevel, const char* optflags, boolean disableber, boolean disableraw, boolean disabletext,
boolean disablexer, boolean disablejson, boolean forcexerinasn, boolean defaultasomit, boolean gccmsgformat,
boolean linenumbersonlymsg, boolean includesourceinfo, boolean addsourcelineinfo, boolean suppresswarnings,
boolean outparamboundness, boolean omit_in_value_list, boolean warnings_for_bad_variants, boolean disable_predef_ext_folder, struct string_list* solspeclibraries,
boolean outparamboundness, boolean omit_in_value_list, boolean warnings_for_bad_variants, boolean activate_debugger,
boolean disable_predef_ext_folder, struct string_list* solspeclibraries,
struct string_list* sol8speclibraries, struct string_list* linuxspeclibraries, struct string_list* freebsdspeclibraries,
struct string_list* win32speclibraries, const char* ttcn3preprocessor, struct string_list* linkerlibraries,
struct string_list* additionalObjects, struct string_list* linkerlibsearchpath, char* generatorCommandOutput,
......@@ -3868,6 +3872,7 @@ static void generate_makefile(size_t n_arguments, char *arguments[],
makefile.outparamboundness = outparamboundness;
makefile.omit_in_value_list = omit_in_value_list;
makefile.warnings_for_bad_variants = warnings_for_bad_variants;
makefile.activate_debugger = activate_debugger;
makefile.disable_predef_ext_folder = disable_predef_ext_folder;
makefile.solspeclibraries = solspeclibraries;
makefile.sol8speclibraries = sol8speclibraries;
......@@ -4003,7 +4008,7 @@ static void generate_makefile(size_t n_arguments, char *arguments[],
static void usage(void)
{
fprintf(stderr, "\n"
"usage: %s [-abc" C_flag "dDEfFglLmMprRstTVwWXZ] [-K file] [-z file ] [-P dir]"
"usage: %s [-abc" C_flag "dDEfFglLmMnprRstTVwWXZ] [-K file] [-z file ] [-P dir]"
" [-U none|type] [-e ets_name] [-o dir|file]\n"
" [-t project_descriptor.tpd [-b buildconfig]]\n"
" [-O file] ... module_name ... testport_name ...\n"
......@@ -4026,6 +4031,7 @@ static void usage(void)
" -L: create makefile with library archive as the default target\n"
" -m: always use makedepend for dependencies\n"
" -M: allow 'omit' in template value lists (legacy behavior)\n"
" -n: activate debugger (generates extra code for debugging)\n"
" -o dir|file: write the Makefile to the given directory or file\n"
" -O file: add the given file to the Makefile as other file\n"
" -p: generate Makefile with TTCN-3 preprocessing\n"
......@@ -4093,7 +4099,7 @@ int main(int argc, char *argv[])
gfflag = FALSE, lnflag = FALSE, isflag = FALSE, asflag = FALSE,
swflag = FALSE, Vflag = FALSE, Dflag = FALSE, Wflag = FALSE,
djflag = FALSE, Zflag = FALSE, Hflag = FALSE, Mflag = FALSE,
diflag = FALSE, zflag = FALSE, Eflag = FALSE;
diflag = FALSE, zflag = FALSE, Eflag = FALSE, nflag = FALSE;
boolean error_flag = FALSE;
char *output_file = NULL;
char *ets_name = NULL;
......@@ -4150,7 +4156,7 @@ int main(int argc, char *argv[])
}
for ( ; ; ) {
int c = getopt(argc, argv, "O:ab:c" C_flag "dDe:EfFgI:K:o:lLmMpP:rRst:TU:vVwWXYz:ZH");
int c = getopt(argc, argv, "O:ab:c" C_flag "dDe:EfFgI:K:o:lLmMnpP:rRst:TU:vVwWXYz:ZH");
if (c == -1) break;
switch (c) {
case 'O':
......@@ -4225,6 +4231,9 @@ int main(int argc, char *argv[])
case 'M':
SET_FLAG(M);
break;
case 'n':
SET_FLAG(n);
break;
case 'p':
SET_FLAG(p);
break;
......@@ -4301,7 +4310,7 @@ int main(int argc, char *argv[])
if ( aflag || bflag || cflag || Cflag || dflag || eflag || fflag || Fflag || gflag
|| mflag || oflag || lflag || pflag || Pflag || rflag || Rflag || sflag
|| tflag || Tflag || Vflag || wflag || Xflag || Kflag || Dflag || Wflag || Yflag
|| Zflag || Hflag || Mflag || zflag || Eflag || n_other_files > 0 || n_search_paths > 0)
|| Zflag || Hflag || Mflag || zflag || Eflag || nflag || n_other_files > 0 || n_search_paths > 0)
error_flag = TRUE;
}
......@@ -4487,7 +4496,7 @@ int main(int argc, char *argv[])
&Rflag, &lflag, &mflag, &Pflag, &Lflag, rflag, Fflag, Tflag, output_file, &abs_work_dir, sub_project_dirs, program_name, prj_graph_fp,
create_symlink_list,ttcn3_prep_includes, ttcn3_prep_defines,ttcn3_prep_undefines, prep_includes, prep_defines, prep_undefines, &csflag,
&quflag, &dsflag, &cxxcompiler, &optlevel, &optflags, &dbflag, &drflag, &dtflag, &dxflag, &djflag, &fxflag, &doflag, &gfflag, &lnflag, &isflag,
&asflag, &swflag, &Yflag, &Mflag, &Eflag, &diflag, solspeclibraries, sol8speclibraries, linuxspeclibraries, freebsdspeclibraries, win32speclibraries, &ttcn3prep,
&asflag, &swflag, &Yflag, &Mflag, &Eflag, &nflag, &diflag, solspeclibraries, sol8speclibraries, linuxspeclibraries, freebsdspeclibraries, win32speclibraries, &ttcn3prep,
linkerlibraries, additionalObjects, linkerlibsearchpath, Vflag, Dflag, &Zflag, &Hflag,
&generatorCommandOutput, target_placement_list, Wflag, run_command_list, required_configs, &profiled_file_list, search_paths, n_search_paths);
......@@ -4526,7 +4535,7 @@ int main(int argc, char *argv[])
Rflag, lflag, mflag, Cflag, code_splitting_mode, tcov_file_name, profiled_file_list,
Lflag, Zflag, Hflag, rflag ? sub_project_dirs : NULL, ttcn3_prep_includes,
ttcn3_prep_defines, ttcn3_prep_undefines, prep_includes, prep_defines, prep_undefines, csflag, quflag, dsflag, cxxcompiler, optlevel, optflags, dbflag,
drflag, dtflag, dxflag, djflag, fxflag, doflag, gfflag, lnflag, isflag, asflag, swflag, Yflag, Mflag, Eflag, diflag, solspeclibraries,
drflag, dtflag, dxflag, djflag, fxflag, doflag, gfflag, lnflag, isflag, asflag, swflag, Yflag, Mflag, Eflag, nflag, diflag, solspeclibraries,
sol8speclibraries, linuxspeclibraries, freebsdspeclibraries, win32speclibraries, ttcn3prep, linkerlibraries, additionalObjects,
linkerlibsearchpath, generatorCommandOutput, target_placement_list);
}
......
......@@ -2912,7 +2912,8 @@ namespace Ttcn {
void Module::generate_debugger_functions(output_struct *output)
{
char* str = NULL;
char* print_str = NULL;
char* overwrite_str = NULL;
for (size_t i = 0; i < asss->get_nof_asss(); ++i) {
Def_Type* def = dynamic_cast<Def_Type*>(asss->get_ass_byIndex(i));
if (def != NULL) {
......@@ -2920,41 +2921,74 @@ namespace Ttcn {
if (!t->is_ref() && t->get_typetype() != Type::T_COMPONENT) {
// don't generate code for subtypes
if (t->get_typetype() != Type::T_SIGNATURE) {
str = mputprintf(str,
print_str = mputprintf(print_str,
" %sif (!strcmp(p_var.type_name, \"%s\")) {\n"
" ((const %s*)p_var.value)->log();\n"
" ((const %s*)ptr)->log();\n"
" }\n"
, (str != NULL) ? "else " : ""
, (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());
}
}
if (t->get_typetype() != Type::T_PORT) {
str = mputprintf(str,
print_str = mputprintf(print_str,
" %sif (!strcmp(p_var.type_name, \"%s template\")) {\n"
" ((const %s_template*)p_var.value)->log();\n"
" ((const %s_template*)ptr)->log();\n"
" }\n"
, (str != NULL) ? "else " : ""
, (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"
" ((%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());
}
}
}
}
}
if (str != NULL) {
if (print_str != NULL) {
// don't generate an empty printing function
output->header.class_defs = mputprintf(output->header.class_defs,
"/* Debugger printing function for types declared in this module */\n\n"
"/* Debugger printing and overwriting functions for types declared in this module */\n\n"
"extern CHARSTRING print_var_%s(const TTCN3_Debugger::variable_t& p_var);\n",
get_modid().get_ttcnname().c_str());
output->source.global_vars = mputprintf(output->source.global_vars,
"\n/* Debugger printing function for types declared in this module */\n"
"CHARSTRING print_var_%s(const TTCN3_Debugger::variable_t& p_var)\n"
"{\n"
" const void* ptr = p_var.set_function != NULL ? p_var.value : p_var.cvalue;\n"
" TTCN_Logger::begin_event_log2str();\n"
"%s"
" else {\n"
" TTCN_Logger::log_event_str(\"<unrecognized value or template>\");\n"
" }\n"
" return TTCN_Logger::end_event_log2str();\n"
"}\n", get_modid().get_ttcnname().c_str(), str);
"}\n", get_modid().get_ttcnname().c_str(), print_str);
}
if (overwrite_str != NULL) {
// don't generate an empty overwriting function
output->header.class_defs = mputprintf(output->header.class_defs,
"extern boolean set_var_%s(TTCN3_Debugger::variable_t& p_var, Module_Param& p_new_value);\n",
get_modid().get_ttcnname().c_str());
output->source.global_vars = mputprintf(output->source.global_vars,
"\n/* Debugger overwriting function for types declared in this module */\n"
"boolean set_var_%s(TTCN3_Debugger::variable_t& p_var, Module_Param& p_new_value)\n"
"{\n"
"%s"
" else {\n"
" return FALSE;\n"
" }\n"
" return TRUE;\n"
"}\n", get_modid().get_ttcnname().c_str(), overwrite_str);
}
}
......@@ -7542,6 +7576,9 @@ namespace Ttcn {
"timer_value);\n");
body = create_location_object(body, "TESTCASE", dispname_str);
body = fp_list->generate_shadow_objects(body);
if (debugger_active) {
body = generate_code_debugger_function_init(body, this);
}
body = mputprintf(body, "try {\n"
"TTCN_Runtime::begin_testcase(\"%s\", \"%s\", ",
my_scope->get_scope_mod()->get_modid().get_dispname().c_str(),
......@@ -7553,9 +7590,6 @@ namespace Ttcn {
body = system_type->get_CompBody()->generate_code_comptype_name(body);
else body = runs_on_body->generate_code_comptype_name(body);
body = mputstr(body, ", has_timer, timer_value);\n");
if (debugger_active) {
body = generate_code_debugger_function_init(body, this);
}
body = block->generate_code(body);
body = mputprintf(body,
"} catch (const TC_Error& tc_error) {\n"
......
......@@ -3,7 +3,7 @@
ttcn3_makefilegen \- Makefile Generator
.SH SYNOPSIS
.B ttcn3_makefilegen
.RB "[\| " \-acdEfglMpRsw " \|]"
.RB "[\| " \-acdEfglMnpRsw " \|]"
.RB "[\| " \-e
.IR " ETS_name" " \|]"
.RB "[\| " \-o
......@@ -126,6 +126,9 @@ operation and the
.B present
template restriction accordingly.
.TP
.B \-n
Activates the debugger and generates extra code for storing debug information.
.TP
.B \-p
Generate Makefile with
.I TTCN-3 preprocessing.
......
......@@ -633,7 +633,8 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char* tpdName, co
struct string_list* prep_defines, struct string_list* prep_undefines, boolean *p_csflag, boolean *p_quflag, boolean* p_dsflag,
char** cxxcompiler, char** optlevel, char** optflags, boolean* p_dbflag, boolean* p_drflag, boolean* p_dtflag, boolean* p_dxflag,
boolean* p_djflag, boolean* p_fxflag, boolean* p_doflag, boolean* p_gfflag, boolean* p_lnflag, boolean* p_isflag,
boolean* p_asflag, boolean* p_swflag, boolean* p_Yflag, boolean* p_Mflag, boolean *p_Eflag, boolean* p_diflag, struct string_list* solspeclibs, struct string_list* sol8speclibs,
boolean* p_asflag, boolean* p_swflag, boolean* p_Yflag, boolean* p_Mflag, boolean *p_Eflag, boolean* p_nflag,
boolean* p_diflag, struct string_list* solspeclibs, struct string_list* sol8speclibs,
struct string_list* linuxspeclibs, struct string_list* freebsdspeclibs, struct string_list* win32speclibs, char** ttcn3prep,
struct string_list* linkerlibs, struct string_list* additionalObjects, struct string_list* linkerlibsearchp, boolean Vflag, boolean Dflag,
boolean *p_Zflag, boolean *p_Hflag, char** generatorCommandOutput, struct string2_list* target_placement_list, boolean prefix_workdir,
......@@ -652,7 +653,8 @@ extern "C" tpd_result process_tpd(const char *p_tpd_name, const char *actcfg,
struct string_list* prep_defines, struct string_list* prep_undefines, boolean *p_csflag, boolean *p_quflag, boolean* p_dsflag,
char** cxxcompiler, char** optlevel, char** optflags, boolean* p_dbflag, boolean* p_drflag, boolean* p_dtflag, boolean* p_dxflag,
boolean* p_djflag, boolean* p_fxflag, boolean* p_doflag, boolean* p_gfflag, boolean* p_lnflag, boolean* p_isflag,
boolean* p_asflag, boolean* p_swflag, boolean* p_Yflag, boolean* p_Mflag, boolean* p_Eflag, boolean* p_diflag, struct string_list* solspeclibs, struct string_list* sol8speclibs,
boolean* p_asflag, boolean* p_swflag, boolean* p_Yflag, boolean* p_Mflag, boolean* p_Eflag, boolean* p_nflag,
boolean* p_diflag, struct string_list* solspeclibs, struct string_list* sol8speclibs,
struct string_list* linuxspeclibs, struct string_list* freebsdspeclibs, struct string_list* win32speclibs, char** ttcn3prep,
string_list* linkerlibs, string_list* additionalObjects, string_list* linkerlibsearchp, boolean Vflag, boolean Dflag, boolean *p_Zflag,
boolean *p_Hflag, char** generatorCommandOutput, struct string2_list* target_placement_list, boolean prefix_workdir,
......@@ -675,7 +677,7 @@ extern "C" tpd_result process_tpd(const char *p_tpd_name, const char *actcfg,
prep_undefines, p_csflag, p_quflag, p_dsflag, cxxcompiler,
optlevel, optflags, p_dbflag, p_drflag, p_dtflag, p_dxflag, p_djflag,
p_fxflag, p_doflag, p_gfflag, p_lnflag, p_isflag,
p_asflag, p_swflag, p_Yflag, p_Mflag, p_Eflag, p_diflag, solspeclibs, sol8speclibs,
p_asflag, p_swflag, p_Yflag, p_Mflag, p_Eflag, p_nflag, p_diflag, solspeclibs, sol8speclibs,
linuxspeclibs, freebsdspeclibs, win32speclibs, ttcn3prep,
linkerlibs, additionalObjects, linkerlibsearchp, Vflag, Dflag, p_Zflag,
p_Hflag, generatorCommandOutput, target_placement_list, prefix_workdir,
......@@ -724,7 +726,8 @@ static tpd_result process_tpd_internal(const char *p_tpd_name, char *tpdName, co
struct string_list* prep_defines, struct string_list* prep_undefines, boolean *p_csflag, boolean *p_quflag, boolean* p_dsflag,
char** cxxcompil