VPP-1024: rewrite buffer trajectory tracer
[vpp.git] / src / vnet / unix / gdb_funcs.c
index cfb4b24..40d0d66 100644 (file)
@@ -20,8 +20,8 @@
 #include <vlib/vlib.h>
 
 #include <vlib/threads.h>
-
-
+#include <vnet/vnet.h>
+#include <vppinfra/format.h>
 
 /**
  * @brief GDB callable function: vl - Return vector length of vector
@@ -135,6 +135,47 @@ void vlib_runtime_index_to_node_name (u32 index)
   fformat(stderr, "node runtime index %d name %s\n", index, nm->nodes[index]->name);
 }
 
+void gdb_show_errors (int verbose)
+{
+  extern vlib_cli_command_t vlib_cli_show_errors;
+  unformat_input_t input;
+  vlib_main_t * vm = vlib_get_main();
+
+  if (verbose == 0)
+    unformat_init_string (&input, "verbose 0", 9);
+  else if (verbose == 1)
+    unformat_init_string (&input, "verbose 1", 9);
+  else 
+    {
+      fformat(stderr, "verbose not 0 or 1\n");
+      return;
+    }
+
+  vlib_cli_show_errors.function (vm, &input, 0 /* cmd */);
+  unformat_free (&input);
+}  
+
+void gdb_show_session (int verbose)
+{
+  extern vlib_cli_command_t vlib_cli_show_session_command;
+  unformat_input_t input;
+  vlib_main_t * vm = vlib_get_main();
+
+  if (verbose == 0)
+    unformat_init_string (&input, "verbose 0", 9);
+  else if (verbose == 1)
+    unformat_init_string (&input, "verbose 1", 9);
+  else if (verbose == 2)
+    unformat_init_string (&input, "verbose 2", 9);
+  else 
+    {
+      fformat(stderr, "verbose not 0 - 2\n");
+      return;
+    }
+
+  vlib_cli_show_session_command.function (vm, &input, 0 /* cmd */);
+  unformat_free (&input);
+}  
 
 /**
  * @brief GDB callable function: show_gdb_command_fn - show gdb
@@ -149,8 +190,12 @@ show_gdb_command_fn (vlib_main_t * vm,
                      vlib_cli_command_t * cmd)
 {
   vlib_cli_output (vm, "vl(p) returns vec_len(p)");
+  vlib_cli_output (vm, "vb(b) returns vnet_buffer(b) [opaque]");
+  vlib_cli_output (vm, "vb2(b) returns vnet_buffer2(b) [opaque2]");
   vlib_cli_output (vm, "pe(p) returns pool_elts(p)");
   vlib_cli_output (vm, "pifi(p, i) returns pool_is_free_index(p, i)");
+  vlib_cli_output (vm, "gdb_show_errors(0|1) dumps error counters");
+  vlib_cli_output (vm, "gdb_show_session dumps session counters");
   vlib_cli_output (vm, "debug_hex_bytes (ptr, n_bytes) dumps n_bytes in hex");
   vlib_cli_output (vm, "vlib_dump_frame_ownership() does what it says");
   vlib_cli_output (vm, "vlib_runtime_index_to_node_name (index) prints NN");
@@ -164,6 +209,27 @@ VLIB_CLI_COMMAND (show_gdb_funcs_command, static) = {
   .function = show_gdb_command_fn,
 };
 
+vnet_buffer_opaque_t *vb (void *vb_arg)
+{
+    vlib_buffer_t *b = (vlib_buffer_t *)vb_arg;
+    vnet_buffer_opaque_t *rv;
+    
+    rv = vnet_buffer (b);
+
+    return rv;
+}
+
+vnet_buffer_opaque2_t *vb2 (void *vb_arg)
+{
+    vlib_buffer_t *b = (vlib_buffer_t *)vb_arg;
+    vnet_buffer_opaque2_t *rv;
+    
+    rv = vnet_buffer2(b);
+
+    return rv;
+}
+
+
 /* Cafeteria plan, maybe you don't want these functions */
 clib_error_t * 
 gdb_func_init (vlib_main_t * vm) { return 0; }