Commit 0fbccb95 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Added Makefile option for debugging parsers



Change-Id: I531f33d0fe22fce85dda6fd03d5cb198f949c9e5
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent b1183bcc
......@@ -54,6 +54,9 @@ PATH := ${PATH}:${TTCN3_DIR}/bin
# Set it to 'yes' for developing or 'no' for release.
DEBUG := no
# Set it to 'yes' to display debug information for parsers (very spammy)
PARSER_DEBUG := no
# Set it to 'yes' to generate coverage data (requires DEBUG=yes)
COVERAGE := no
......@@ -152,6 +155,10 @@ else
CPPFLAGS += -DNDEBUG
endif
ifeq ($(PARSER_DEBUG), yes)
CPPFLAGS += -DPARSER_DEBUG
endif
# MingW flags need to be passed to the preprocessor during ctags configure
CPPFLAGS += $(MINGW)
......@@ -216,6 +223,10 @@ ifeq ($(DEBUG), yes)
BISONFLAGS += -t -v
endif
ifeq ($(PARSER_DEBUG), yes)
BISONFLAGS += --debug --verbose
endif
ifeq ($(COVERAGE), yes)
CPPFLAGS += -DCOVERAGE_BUILD
COMPILERFLAGS += -fprofile-arcs -ftest-coverage
......
......@@ -298,6 +298,9 @@ extern int add_include_file(const std::string& filename)
extern int preproc_parse_file(const char *filename, string_chain_t **filenames,
string_map_t **defines)
{
#ifdef PARSER_DEBUG
config_preproc_yydebug = 1;
#endif
int error_flag = 0;
config_preproc_filenames=NULL;
config_preproc_defines=string_map_new();
......
......@@ -636,6 +636,9 @@ RE_Quadruple:
char* TTCN_pattern_to_regexp(const char* p_pattern, bool utf8)
{
#ifdef PARSER_DEBUG
pattern_yydebug = 1;
#endif
/* if you want to debug */
//pattern_yydebug=1;
......
......@@ -589,8 +589,9 @@ RE_Quadruple:
char* TTCN_pattern_to_regexp_uni(const char* p_pattern, bool p_nocase, int** groups)
{
/* if you want to debug */
//pattern_unidebug=1;
#ifdef PARSER_DEBUG
pattern_unidebug = 1;
#endif
ret_val=NULL;
user_groups = 0;
......
......@@ -3946,6 +3946,9 @@ LowerRef:
int asn1_parse_file(const char* filename, boolean generate_code)
{
#ifdef PARSER_DEBUG
yydebug = 1;
#endif
asn1_yy_parse_internal=false;
int retval=0;
asn1la_newfile(filename);
......@@ -3976,6 +3979,9 @@ int asn1_parse_file(const char* filename, boolean generate_code)
*/
int asn1_parse_string(const char* p_str)
{
#ifdef PARSER_DEBUG
yydebug = 1;
#endif
unsigned verb_level_backup=verb_level;
verb_level=0; // be vewy, vewy quiet
asn1la_newfile("<internal>");
......
......@@ -881,6 +881,9 @@ static void yyerror(const char *str)
/** Parse all extension attributes in a "with" statement */
ExtensionAttributes * parse_extattributes(WithAttribPath *w_attrib_path)
{
#ifdef PARSER_DEBUG
yydebug = 1;
#endif
extatrs = 0;
if (!w_attrib_path) FATAL_ERROR("parse_extattributes(): NULL pointer");
// Collect attributes from outer scopes
......
......@@ -11017,6 +11017,9 @@ static void ttcn3_error(const char *str)
int ttcn3_parse_file(const char* filename, boolean generate_code)
{
#ifdef PARSER_DEBUG
ttcn3_debug = 1;
#endif
anytype_access = false;
ttcn3_in = fopen(filename, "r");
if (ttcn3_in == NULL) {
......
......@@ -678,6 +678,9 @@ int parse_rawAST(RawAST *par, TextAST *textpar, XerAttributes *xerpar,
bool &xer_found, bool &ber_found, bool &json_found,
Common::Type::MessageEncodingType_t par_codec /* = Common::Type::CT_UNDEF */)
{
#ifdef PARSER_DEBUG
rawAST_debug = 1;
#endif
rawstruct=par;
textstruct=textpar;
xerstruct = xerpar;
......
......@@ -2286,6 +2286,9 @@ static void reset_configuration_options()
Module_Param* process_config_string2ttcn(const char* mp_str, boolean is_component)
{
#ifdef PARSER_DEBUG
config_process_debug = 1;
#endif
if (parsed_module_param!=NULL || parsing_error_messages!=NULL) TTCN_error("Internal error: previously parsed ttcn string was not cleared.");
// add the hidden keyword
std::string mp_string = (is_component) ? std::string("$#&&&(#TTCNSTRINGPARSING_COMPONENT$#&&^#% ") + mp_str
......@@ -2323,6 +2326,9 @@ Module_Param* process_config_string2ttcn(const char* mp_str, boolean is_componen
Module_Param* process_config_debugger_value(const char* mp_str)
{
#ifdef PARSER_DEBUG
config_process_debug = 1;
#endif
if (parsed_module_param != NULL || parsing_error_messages != NULL) {
ttcn3_debugger.print(DRET_NOTIFICATION,
"Internal error: previously parsed TTCN string was not cleared.");
......@@ -2376,6 +2382,9 @@ Module_Param* process_config_debugger_value(const char* mp_str)
boolean process_config_string(const char *config_string, int string_len)
{
#ifdef PARSER_DEBUG
config_process_debug = 1;
#endif
error_flag = FALSE;
struct yy_buffer_state *flex_buffer =
......@@ -2405,6 +2414,9 @@ boolean process_config_string(const char *config_string, int string_len)
boolean process_config_file(const char *file_name)
{
#ifdef PARSER_DEBUG
config_process_debug = 1;
#endif
error_flag = FALSE;
string_chain_t *filenames=NULL;
......
......@@ -1086,6 +1086,9 @@ optSemiColon:
int process_config_read_file(const char *file_name, config_data *pcfg)
{
#ifdef PARSER_DEBUG
config_read_debug = 1;
#endif
// reset "locals"
local_addr_set = FALSE;
tcp_listen_port_set = FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment