Debug: Added PARSE debug flag
This commit is contained in:
parent
03a9c03b1c
commit
c353c6dcab
21 changed files with 45 additions and 31 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <<EOF > /tmp/my.yang
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */}
|
|||
;
|
||||
|
||||
%%
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -832,6 +833,7 @@ yang_parse_str(char *str,
|
|||
if (yang_filename_set(ymod, name) < 0)
|
||||
goto done;
|
||||
done:
|
||||
clixon_debug(CLIXON_DBG_PARSE, "retval:%p", ymod);
|
||||
ystack_pop(&yy);
|
||||
if (yy.yy_stack)
|
||||
free (yy.yy_stack);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue