diff --git a/apps/restconf/clixon_http1_parse.y b/apps/restconf/clixon_http1_parse.y index c1bcc76a..ec0ce6b2 100644 --- a/apps/restconf/clixon_http1_parse.y +++ b/apps/restconf/clixon_http1_parse.y @@ -109,8 +109,8 @@ * Disable it to stop any calls to clixon_debug. Having it on by default would mean very large debug outputs. */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(1,(s)) -#define _PARSE_DEBUG1(s, s1) clixon_debug(1,(s), (s1)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s)) +#define _PARSE_DEBUG1(s, s1) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s), (s1)) #else #define _PARSE_DEBUG(s) #define _PARSE_DEBUG1(s, s1) diff --git a/apps/restconf/restconf_http1.c b/apps/restconf/restconf_http1.c index 3d6f5fa3..b043a4cd 100644 --- a/apps/restconf/restconf_http1.c +++ b/apps/restconf/restconf_http1.c @@ -93,7 +93,7 @@ _http1_parse(clixon_handle h, clixon_http1_yacc hy = {0,}; int ret; - clixon_debug(CLIXON_DBG_RESTCONF, "\n%s", str); + clixon_debug(CLIXON_DBG_PARSE, "%s", str); if (strlen(str) == 0) goto ok; hy.hy_parse_string = str; @@ -122,7 +122,7 @@ _http1_parse(clixon_handle h, ok: retval = 0; done: - clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval); + clixon_debug(CLIXON_DBG_PARSE, "retval:%d", retval); return retval; } diff --git a/doc/DEVELOP.md b/doc/DEVELOP.md index 5c8ca3c1..17d67d4a 100644 --- a/doc/DEVELOP.md +++ b/doc/DEVELOP.md @@ -103,6 +103,12 @@ Get restconf daemon status: curl -Ssik -X POST -H "Content-Type: application/yang-data+json" http://localhost/restconf/operations/clixon-lib:process-control -d '{"clixon-lib:input":{"name":"restconf","operation":"status"}}' ``` +### Debug parsing + +Yacc: Enable _PARSE_DEBUG macro in corresponding yacc file. +Lex: Add -d in Makefile for corresponding lex file. +Run program with -D parse -D detail + ### Make your own simplified yang and configuration file. ``` cat < /tmp/my.yang diff --git a/lib/clixon/clixon_debug.h b/lib/clixon/clixon_debug.h index ad3ee35f..9e6f5570 100644 --- a/lib/clixon/clixon_debug.h +++ b/lib/clixon/clixon_debug.h @@ -75,6 +75,7 @@ #define CLIXON_DBG_EVENT 0x00004000 /* Event processing */ #define CLIXON_DBG_RPC 0x00008000 /* RPC handling */ #define CLIXON_DBG_STREAM 0x00010000 /* Notification streams */ +#define CLIXON_DBG_PARSE 0x00020000 /* Parser */ /* External applications */ #define CLIXON_DBG_APP 0x00100000 /* External application */ diff --git a/lib/src/clixon_api_path_parse.y b/lib/src/clixon_api_path_parse.y index 0ac9eba5..cf4b1790 100644 --- a/lib/src/clixon_api_path_parse.y +++ b/lib/src/clixon_api_path_parse.y @@ -121,8 +121,8 @@ * Disable it to stop any calls to clixon_debug. Having it on by default would mean very large debug outputs. */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(1,(s)) -#define _PARSE_DEBUG1(s, s1) clixon_debug(1,(s), (s1)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s)) +#define _PARSE_DEBUG1(s, s1) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s), (s1)) #else #define _PARSE_DEBUG(s) #define _PARSE_DEBUG1(s, s1) diff --git a/lib/src/clixon_debug.c b/lib/src/clixon_debug.c index c3235eeb..783d70ae 100644 --- a/lib/src/clixon_debug.c +++ b/lib/src/clixon_debug.c @@ -101,6 +101,7 @@ static const map_str2int dbgmap[] = { {"event", CLIXON_DBG_EVENT}, {"rpc", CLIXON_DBG_RPC}, {"stream", CLIXON_DBG_STREAM}, + {"parse", CLIXON_DBG_PARSE}, {"app", CLIXON_DBG_APP}, {"app2", CLIXON_DBG_APP2}, {"app3", CLIXON_DBG_APP3}, diff --git a/lib/src/clixon_instance_id_parse.y b/lib/src/clixon_instance_id_parse.y index 4ac89398..6ae4b5a7 100644 --- a/lib/src/clixon_instance_id_parse.y +++ b/lib/src/clixon_instance_id_parse.y @@ -129,7 +129,7 @@ /* Enable for debugging, steals some cycles otherwise */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(1,(s)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s)) #else #define _PARSE_DEBUG(s) #endif diff --git a/lib/src/clixon_json.c b/lib/src/clixon_json.c index 714a62fd..490fef1c 100644 --- a/lib/src/clixon_json.c +++ b/lib/src/clixon_json.c @@ -1451,7 +1451,7 @@ _json_parse(char *str, int i; int failed = 0; /* yang assignment */ - clixon_debug(CLIXON_DBG_DEFAULT, "%d %s", yb, str); + clixon_debug(CLIXON_DBG_PARSE, "%s", str); jy.jy_parse_string = str; jy.jy_linenum = 1; jy.jy_current = xt; @@ -1537,7 +1537,7 @@ _json_parse(char *str, goto done; retval = 1; done: - clixon_debug(CLIXON_DBG_DEFAULT, "retval:%d", retval); + clixon_debug(CLIXON_DBG_PARSE, "retval:%d", retval); if (cberr) cbuf_free(cberr); json_parse_exit(&jy); diff --git a/lib/src/clixon_json_parse.y b/lib/src/clixon_json_parse.y index 2cc51639..708c72a0 100644 --- a/lib/src/clixon_json_parse.y +++ b/lib/src/clixon_json_parse.y @@ -139,7 +139,7 @@ object. /* Enable for debugging, steals some cycles otherwise */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(1,(s)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s)) #else #define _PARSE_DEBUG(s) #endif diff --git a/lib/src/clixon_path.c b/lib/src/clixon_path.c index 01f60a5d..01b81605 100644 --- a/lib/src/clixon_path.c +++ b/lib/src/clixon_path.c @@ -132,7 +132,7 @@ api_path_parse(char *api_path, int retval = -1; clixon_api_path_yacc ay = {0,}; - clixon_debug(CLIXON_DBG_DEFAULT, "api_path:%s", api_path); + clixon_debug(CLIXON_DBG_PARSE, "%s", api_path); ay.ay_parse_string = api_path; ay.ay_name = "api-path parser"; ay.ay_linenum = 1; @@ -151,6 +151,7 @@ api_path_parse(char *api_path, *cplist = ay.ay_top; retval = 0; done: + clixon_debug(CLIXON_DBG_PARSE, "retval: %d", retval); return retval; } @@ -177,7 +178,7 @@ instance_id_parse(char *path, int retval = -1; clixon_instance_id_yacc iy = {0,}; - clixon_debug(CLIXON_DBG_DEFAULT, "path:%s", path); + clixon_debug(CLIXON_DBG_PARSE, "%s", path); iy.iy_parse_string = path; iy.iy_name = "instance-id parser"; iy.iy_linenum = 1; @@ -196,6 +197,7 @@ instance_id_parse(char *path, *cplist = iy.iy_top; retval = 0; done: + clixon_debug(CLIXON_DBG_PARSE, "retval: %d", retval); return retval; } diff --git a/lib/src/clixon_text_syntax.c b/lib/src/clixon_text_syntax.c index 5441ca8b..cd6d7e17 100644 --- a/lib/src/clixon_text_syntax.c +++ b/lib/src/clixon_text_syntax.c @@ -1010,7 +1010,7 @@ _text_syntax_parse(char *str, int failed = 0; /* yang assignment */ cxobj *xc; - clixon_debug(CLIXON_DBG_DEFAULT, "%d %s", yb, str); + clixon_debug(CLIXON_DBG_PARSE, "%s", str); if (yb != YB_MODULE && yb != YB_MODULE_NEXT){ clixon_err(OE_YANG, EINVAL, "yb must be YB_MODULE or YB_MODULE_NEXT"); return -1; @@ -1067,7 +1067,7 @@ _text_syntax_parse(char *str, goto done; retval = 1; done: - clixon_debug(CLIXON_DBG_DEFAULT, "retval:%d", retval); + clixon_debug(CLIXON_DBG_PARSE, "retval:%d", retval); if (cberr) cbuf_free(cberr); clixon_text_syntax_parsel_exit(&ts); diff --git a/lib/src/clixon_text_syntax_parse.y b/lib/src/clixon_text_syntax_parse.y index e7dcf08b..0bb953fc 100644 --- a/lib/src/clixon_text_syntax_parse.y +++ b/lib/src/clixon_text_syntax_parse.y @@ -86,7 +86,7 @@ /* Enable for debugging, steals some cycles otherwise */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(1,(s)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s)) #else #define _PARSE_DEBUG(s) #endif diff --git a/lib/src/clixon_validate.c b/lib/src/clixon_validate.c index 239471ce..129d7bd8 100644 --- a/lib/src/clixon_validate.c +++ b/lib/src/clixon_validate.c @@ -1272,7 +1272,7 @@ xml_yang_validate_all(clixon_handle h, } if (yang_config(yt) != 0){ ret = yang_check_when_xpath(xt, xml_parent(xt), yt, &hit, &nr, &xpath); - clixon_debug(CLIXON_DBG_XPATH, "nr:%d xpath:%s return:%d", nr, xpath, ret); + clixon_debug(CLIXON_DBG_XPATH|CLIXON_DBG_DETAIL, "nr:%d xpath:%s return:%d", nr, xpath, ret); if (ret < 0) goto done; diff --git a/lib/src/clixon_xml_parse.y b/lib/src/clixon_xml_parse.y index 1b19a55f..39158340 100644 --- a/lib/src/clixon_xml_parse.y +++ b/lib/src/clixon_xml_parse.y @@ -88,7 +88,7 @@ /* Enable for debugging, steals some cycles otherwise */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(1,(s)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s)) #else #define _PARSE_DEBUG(s) #endif @@ -450,7 +450,7 @@ element1 : ESLASH {_XY->xy_xelement = NULL; | '>' { xml_parse_endslash_pre(_XY); } elist { xml_parse_endslash_mid(_XY); } endtag { xml_parse_endslash_post(_XY); - _PARSE_DEBUG("element1 -> > elist endtag");} + _PARSE_DEBUG("element1 -> elist endtag");} ; endtag : BSLASH NAME '>' @@ -505,4 +505,3 @@ attvalue : '\"' STRING '\"' { $$=$2; /* $2 must be consumed */} ; %% - diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index 40f510fc..e34e9b04 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -558,7 +558,7 @@ xpath_parse(const char *xpath, clixon_xpath_yacc xpy = {0,}; cbuf *cb = NULL; - clixon_debug(CLIXON_DBG_XPATH | CLIXON_DBG_DETAIL, "xpath %s", xpath); + clixon_debug(CLIXON_DBG_PARSE, "%s", xpath); if (xpath == NULL){ clixon_err(OE_XML, EINVAL, "XPath is NULL"); goto done; @@ -583,7 +583,7 @@ xpath_parse(const char *xpath, goto done; } xpath_tree_print_cb(cb, xpy.xpy_top); - clixon_debug(CLIXON_DBG_ALWAYS, "xpath parse tree:\n%s", cbuf_get(cb)); + clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL, "xpath parse tree:\n%s", cbuf_get(cb)); } xpath_parse_exit(&xpy); xpath_scan_exit(&xpy); @@ -593,6 +593,7 @@ xpath_parse(const char *xpath, } retval = 0; done: + clixon_debug(CLIXON_DBG_PARSE, "retval:%d", retval); if (cb) cbuf_free(cb); if (xpy.xpy_top) diff --git a/lib/src/clixon_xpath_parse.y b/lib/src/clixon_xpath_parse.y index 21a19da8..3da7b7fb 100644 --- a/lib/src/clixon_xpath_parse.y +++ b/lib/src/clixon_xpath_parse.y @@ -138,9 +138,9 @@ * Disable it to stop any calls to clixon_debug. Having it on by default would mean very large debug outputs. */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(1,(s)) -#define _PARSE_DEBUG1(s, s1) clixon_debug(1,(s), (s1)) -#define _PARSE_DEBUG2(s, s1, s2) clixon_debug(1,(s), (s1), (s2)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s)) +#define _PARSE_DEBUG1(s, s1) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s), (s1)) +#define _PARSE_DEBUG2(s, s1, s2) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL,(s), (s1), (s2)) #else #define _PARSE_DEBUG(s) #define _PARSE_DEBUG1(s, s1) diff --git a/lib/src/clixon_yang_parse.y b/lib/src/clixon_yang_parse.y index 2897d4ca..028388a8 100644 --- a/lib/src/clixon_yang_parse.y +++ b/lib/src/clixon_yang_parse.y @@ -204,8 +204,8 @@ * Disable it to stop any calls to clixon_debug. Having it on by default would mean very large debug outputs. */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_YANG, (s)) -#define _PARSE_DEBUG1(s, s1) clixon_debug(CLIXON_DBG_YANG, (s), (s1)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL, (s)) +#define _PARSE_DEBUG1(s, s1) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL, (s), (s1)) #else #define _PARSE_DEBUG(s) #define _PARSE_DEBUG1(s, s1) diff --git a/lib/src/clixon_yang_parse_lib.c b/lib/src/clixon_yang_parse_lib.c index e4e96141..de4b03aa 100644 --- a/lib/src/clixon_yang_parse_lib.c +++ b/lib/src/clixon_yang_parse_lib.c @@ -795,6 +795,7 @@ yang_parse_str(char *str, clixon_yang_yacc yy = {0,}; yang_stmt *ymod = NULL; + clixon_debug(CLIXON_DBG_PARSE, "%s", str); if (yspec == NULL){ clixon_err(OE_YANG, 0, "Yang parse need top level yang spec"); goto done; @@ -831,7 +832,8 @@ yang_parse_str(char *str, /* Add filename for debugging and errors, see also ys_linenum on (each symbol?) */ if (yang_filename_set(ymod, name) < 0) goto done; - done: + done: + clixon_debug(CLIXON_DBG_PARSE, "retval:%p", ymod); ystack_pop(&yy); if (yy.yy_stack) free (yy.yy_stack); diff --git a/lib/src/clixon_yang_schemanode_parse.y b/lib/src/clixon_yang_schemanode_parse.y index c9564c80..5df09178 100644 --- a/lib/src/clixon_yang_schemanode_parse.y +++ b/lib/src/clixon_yang_schemanode_parse.y @@ -96,7 +96,7 @@ /* Enable for debugging, steals some cycles otherwise */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_YANG, (s)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL, (s)) #else #define _PARSE_DEBUG(s) #endif diff --git a/lib/src/clixon_yang_sub_parse.c b/lib/src/clixon_yang_sub_parse.c index df231f1b..69b9b6a1 100644 --- a/lib/src/clixon_yang_sub_parse.c +++ b/lib/src/clixon_yang_sub_parse.c @@ -83,7 +83,7 @@ yang_subparse(char *str, int retval = -1; clixon_yang_sub_parse_yacc ife = {0,}; - clixon_debug(CLIXON_DBG_YANG | CLIXON_DBG_DETAIL, "%s", str); + clixon_debug(CLIXON_DBG_PARSE, "%s", str); ife.if_parse_string = str; ife.if_linenum = linenum; if (enabled) @@ -102,6 +102,7 @@ yang_subparse(char *str, *enabled = ife.if_enabled; retval = 0; done: + clixon_debug(CLIXON_DBG_PARSE, "retval:%d", retval); clixon_yang_sub_parsel_exit(&ife); return retval; } @@ -125,7 +126,7 @@ yang_schema_nodeid_subparse(char *str, int retval = -1; clixon_yang_schemanode_yacc ife = {0,}; - clixon_debug(CLIXON_DBG_YANG | CLIXON_DBG_DETAIL, "%s", str); + clixon_debug(CLIXON_DBG_PARSE, "%s", str); ife.if_parse_string = str; ife.if_linenum = linenum; ife.if_mainfile = mainfile; @@ -139,6 +140,7 @@ yang_schema_nodeid_subparse(char *str, } retval = 0; done: + clixon_debug(CLIXON_DBG_PARSE, "retval:%d", retval); clixon_yang_schemanode_parsel_exit(&ife); return retval; } diff --git a/lib/src/clixon_yang_sub_parse.y b/lib/src/clixon_yang_sub_parse.y index f247de26..004dfdbe 100644 --- a/lib/src/clixon_yang_sub_parse.y +++ b/lib/src/clixon_yang_sub_parse.y @@ -106,7 +106,7 @@ /* Enable for debugging, steals some cycles otherwise */ #if 0 -#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_YANG, (s)) +#define _PARSE_DEBUG(s) clixon_debug(CLIXON_DBG_PARSE|CLIXON_DBG_DETAIL, (s)) #else #define _PARSE_DEBUG(s) #endif