mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 11:15:47 +00:00
lib: Add tracing capabilities to command matcher
Compile with -DTRACE_MATCHER to enable matcher debugging to stdout. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
3871154b72
commit
b4f56274fa
@ -116,6 +116,13 @@ command_match (struct graph *cmdgraph,
|
|||||||
assert (*el);
|
assert (*el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TRACE_MATCHER
|
||||||
|
if (!*el)
|
||||||
|
fprintf (stdout, "No match\n");
|
||||||
|
else
|
||||||
|
fprintf (stdout, "Matched command\n->string %s\n->desc %s\n", (*el)->string, (*el)->doc);
|
||||||
|
#endif
|
||||||
|
|
||||||
// free the leader token we alloc'd
|
// free the leader token we alloc'd
|
||||||
XFREE (MTYPE_TMP, vector_slot (vvline, 0));
|
XFREE (MTYPE_TMP, vector_slot (vvline, 0));
|
||||||
// free vector
|
// free vector
|
||||||
@ -184,6 +191,26 @@ command_match_r (struct graph_node *start, vector vline, unsigned int n)
|
|||||||
// get the current operating input token
|
// get the current operating input token
|
||||||
char *input_token = vector_slot (vline, n);
|
char *input_token = vector_slot (vline, n);
|
||||||
|
|
||||||
|
#ifdef TRACE_MATCHER
|
||||||
|
fprintf (stdout, "\"%s\" matches \"%s\" (%d) ? ", input_token, token->text, token->type);
|
||||||
|
switch (match_token (token, input_token))
|
||||||
|
{
|
||||||
|
case trivial_match:
|
||||||
|
fprintf (stdout, "trivial_match ");
|
||||||
|
break;
|
||||||
|
case no_match:
|
||||||
|
fprintf (stdout, "no_match ");
|
||||||
|
break;
|
||||||
|
case partly_match:
|
||||||
|
fprintf (stdout, "partly_match ");
|
||||||
|
break;
|
||||||
|
case exact_match:
|
||||||
|
fprintf (stdout, "exact_match ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fprintf (stdout, "(minimum: %d)\n", minmatch);
|
||||||
|
#endif
|
||||||
|
|
||||||
// if we don't match this node, die
|
// if we don't match this node, die
|
||||||
if (match_token (token, input_token) < minmatch)
|
if (match_token (token, input_token) < minmatch)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -301,19 +328,35 @@ command_complete (struct graph *graph,
|
|||||||
for (ALL_LIST_ELEMENTS_RO (current,node,gn))
|
for (ALL_LIST_ELEMENTS_RO (current,node,gn))
|
||||||
{
|
{
|
||||||
struct cmd_token *token = gn->data;
|
struct cmd_token *token = gn->data;
|
||||||
|
#ifdef TRACE_MATCHER
|
||||||
|
fprintf (stdout, "\"%s\" matches \"%s\" (%d) ? ", input_token, token->text, token->type);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (match_token (token, input_token))
|
switch (match_token (token, input_token))
|
||||||
{
|
{
|
||||||
case trivial_match:
|
case trivial_match:
|
||||||
|
#ifdef TRACE_MATCHER
|
||||||
|
fprintf (stdout, "trivial_match\n");
|
||||||
|
#endif
|
||||||
case partly_match:
|
case partly_match:
|
||||||
|
#ifdef TRACE_MATCHER
|
||||||
|
fprintf (stdout, "partly_match\n");
|
||||||
|
#endif
|
||||||
if (idx == vector_active (vline) - 1)
|
if (idx == vector_active (vline) - 1)
|
||||||
{
|
{
|
||||||
listnode_add (next, gn);
|
listnode_add (next, gn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case exact_match:
|
case exact_match:
|
||||||
|
#ifdef TRACE_MATCHER
|
||||||
|
fprintf (stdout, "exact_match\n");
|
||||||
|
#endif
|
||||||
add_nexthops (next, gn);
|
add_nexthops (next, gn);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
#ifdef TRACE_MATCHER
|
||||||
|
fprintf (stdout, "no_match\n");
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user