From b30b9549acaa0ffd4c94c2c50d0756416f9b58ee Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Mon, 22 Jun 2020 10:02:25 -0400 Subject: vlib: debug CLI macro expander, part deux Deal with circular macro definitions instead of crashing due to stack overflow. Separate macro tables, per CLI session Add documentation to the Sphinx docs Type: improvement Signed-off-by: Dave Barach Change-Id: I55fc9152bd37ad0c15fa3959f38b07b63100e634 --- docs/gettingstarted/developers/vlib.md | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'docs/gettingstarted') diff --git a/docs/gettingstarted/developers/vlib.md b/docs/gettingstarted/developers/vlib.md index 13844ab455a..59206e5ed4b 100644 --- a/docs/gettingstarted/developers/vlib.md +++ b/docs/gettingstarted/developers/vlib.md @@ -540,6 +540,54 @@ certain cli command has the potential to hurt packet processing performance by running for too long, do the work incrementally in a process node. The client can wait. +### Macro expansion + +The vpp debug CLI engine includes a recursive macro expander. This +is quite useful for factoring out address and/or interface name +specifics: + +``` + define ip1 192.168.1.1/24 + define ip2 192.168.2.1/24 + define iface1 GigabitEthernet3/0/0 + define iface2 loop1 + + set int ip address $iface1 $ip1 + set int ip address $iface2 $(ip2) + + undefine ip1 + undefine ip2 + undefine iface1 + undefine iface2 +``` + +Each socket (or telnet) debug CLI session has its own macro +tables. All debug CLI sessions which use CLI_INBAND binary API +messages share a single table. + +The macro expander recognizes circular defintions: + +``` + define foo \$(bar) + define bar \$(mumble) + define mumble \$(foo) +``` + +At 8 levels of recursion, the macro expander throws up its hands and +replies "CIRCULAR." + +### Macro-related debug CLI commands + +In addition to the "define" and "undefine" debug CLI commands, use +"show macro [noevaluate]" to dump the macro table. The "echo" debug +CLI command will evaluate and print its argument: + +``` + vpp# define foo This\ Is\ Foo + vpp# echo $foo + This Is Foo +``` + Handing off buffers between threads ----------------------------------- -- cgit 1.2.3-korg