aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/unix
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2019-11-21 16:53:31 +0100
committerDamjan Marion <dmarion@me.com>2019-11-26 09:50:22 +0000
commit2b65f9ca04847b6e37861983183f5093b601fbb2 (patch)
tree554a43220fd0ba6b76d99bbb816b1db579ed1102 /src/vnet/unix
parente69f4714323e1f7e7754fef58a2d75949e146317 (diff)
misc: add gdb helpers for vlib buffers
Type: feature Change-Id: I7e619040857310fffd33c355f6c491a55f7a4a02 Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/vnet/unix')
-rw-r--r--src/vnet/unix/gdb_funcs.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/vnet/unix/gdb_funcs.c b/src/vnet/unix/gdb_funcs.c
index 2ebdd5960ca..6f0dd208caf 100644
--- a/src/vnet/unix/gdb_funcs.c
+++ b/src/vnet/unix/gdb_funcs.c
@@ -272,11 +272,13 @@ show_gdb_command_fn (vlib_main_t * vm,
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, "vbi(b) returns b index");
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, "gdb_show_traces() dumps buffer traces");
+ vlib_cli_output (vm, "gdb_validate_buffer(b) check vlib_buffer b sanity");
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");
@@ -314,6 +316,31 @@ vb2 (void *vb_arg)
return rv;
}
+u32
+vbi (vlib_buffer_t * b)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ vlib_buffer_main_t *bm = vm->buffer_main;
+ u32 bi = pointer_to_uword (b) - bm->buffer_mem_start;
+ bi >>= CLIB_LOG2_CACHE_LINE_BYTES;
+ return bi;
+}
+
+int
+gdb_validate_buffer (vlib_buffer_t * b)
+{
+ vlib_main_t *vm = vlib_get_main ();
+ u32 bi = vbi (b);
+ u8 *s =
+ vlib_validate_buffers (vm, &bi, 0, 1, VLIB_BUFFER_KNOWN_ALLOCATED, 1);
+ if (s)
+ {
+ fformat (stderr, "gdb_validate_buffer(): %v", s);
+ return -1;
+ }
+ fformat (stderr, "gdb_validate_buffer(): no error found\n");
+ return 0;
+}
/* Cafeteria plan, maybe you don't want these functions */
clib_error_t *