api: vppapitrace JSON/API trace converter

usage: vppapitrace.py [-h] [--debug] [--apidir APIDIR] {convert,replay} ...

optional arguments:
  -h, --help        show this help message and exit
  --debug           enable debug mode
  --apidir APIDIR   Location of JSON API definitions

subcommands:
  valid subcommands

  {convert,replay}  additional help
    convert         Convert API trace to JSON or Python and back
    replay          Replay messages to running VPP instance

To convert an API trace file to JSON:
vppapitrace convert /tmp/api.trace trace.json

To convert an (edited) JSON file back to API trace for replay:
vppapitrace convert trace.json api-edited.trace

To generate a Python file that can be replayed:
vppapitrace convert /tmp/api.trace trace.py
vppapitrace convert trace.json trace.py

Replay it to a running VPP instance:
vppapitrace replay --socket /tmp/api.trace

In VPP that file can be replayed with:
vpp# api trace replay api-edited.trace

This patch also modifies the API binary trace format, to include the
message id to message name table.

Change-Id: Ie6441efb53c1c93c9f778f6ae9c1758bccc8dd87
Type: refactor
Signed-off-by: Ole Troan <ot@cisco.com>
This commit is contained in:
Ole Troan
2019-07-30 15:38:13 +02:00
committed by Dave Barach
parent c54235776c
commit edfe2c0079
11 changed files with 694 additions and 228 deletions

View File

@ -68,29 +68,6 @@ vl_api_trace_plugin_msg_ids_t_print (vl_api_trace_plugin_msg_ids_t * a,
#include <vlibmemory/vl_memory_api_h.h>
#undef vl_endianfun
u8 *
vl_api_serialize_message_table (api_main_t * am, u8 * vector)
{
serialize_main_t _sm, *sm = &_sm;
hash_pair_t *hp;
u32 nmsg = hash_elts (am->msg_index_by_name_and_crc);
serialize_open_vector (sm, vector);
/* serialize the count */
serialize_integer (sm, nmsg, sizeof (u32));
/* *INDENT-OFF* */
hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
({
serialize_likely_small_unsigned_integer (sm, hp->value[0]);
serialize_cstring (sm, (char *) hp->key);
}));
/* *INDENT-ON* */
return serialize_close_vector (sm);
}
static void
vl_api_get_first_msg_id_t_handler (vl_api_get_first_msg_id_t * mp)
{