aboutsummaryrefslogtreecommitdiffstats
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
parente69f4714323e1f7e7754fef58a2d75949e146317 (diff)
misc: add gdb helpers for vlib buffers
Type: feature Change-Id: I7e619040857310fffd33c355f6c491a55f7a4a02 Signed-off-by: Benoît Ganne <bganne@cisco.com>
-rw-r--r--src/vlib/buffer_funcs.h7
-rw-r--r--src/vnet/unix/gdb_funcs.c27
2 files changed, 34 insertions, 0 deletions
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index cfb48344648..58abdb18841 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -474,6 +474,13 @@ vlib_buffer_is_known (vlib_main_t * vm, u32 buffer_index)
u8 *vlib_validate_buffer (vlib_main_t * vm, u32 buffer_index,
uword follow_chain);
+u8 *vlib_validate_buffers (vlib_main_t * vm,
+ u32 * buffers,
+ uword next_buffer_stride,
+ uword n_buffers,
+ vlib_buffer_known_state_t known_state,
+ uword follow_buffer_next);
+
static_always_inline vlib_buffer_pool_t *
vlib_get_buffer_pool (vlib_main_t * vm, u8 buffer_pool_index)
{
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 *