libosmovty 1.10.0.10-24ad1
Osmocom VTY library
|
Osmocom talloc context introspection via VTY. More...
#include <stdio.h>
#include <regex.h>
#include <string.h>
#include <osmocom/core/talloc.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/vty.h>
Data Structures | |
struct | walk_cb_params |
Macros | |
#define | BASE_CMD_STR "show talloc-context (application|global|all) (full|brief|DEPTH)" |
#define | BASE_CMD_DESCR |
Enumerations | |
enum | walk_filter_type { WALK_FILTER_NONE = 0 , WALK_FILTER_REGEXP , WALK_FILTER_TREE } |
Functions | |
static void | talloc_ctx_walk_cb (const void *chunk, int depth, int max_depth, int is_ref, void *data) |
Print a talloc memory hierarchy to the given VTY. More... | |
static void | talloc_ctx_walk (const char *ctx, const char *depth, struct walk_cb_params *params) |
Parse talloc context and depth values from a VTY command. More... | |
DEFUN (show_talloc_ctx, show_talloc_ctx_cmd, BASE_CMD_STR, BASE_CMD_DESCR) | |
DEFUN (show_talloc_ctx_filter, show_talloc_ctx_filter_cmd, BASE_CMD_STR " filter REGEXP", BASE_CMD_DESCR "Filter chunks using regular expression\n" "Regular expression\n") | |
DEFUN (show_talloc_ctx_tree, show_talloc_ctx_tree_cmd, BASE_CMD_STR " tree ADDRESS", BASE_CMD_DESCR "Display only a specific memory chunk\n" "Chunk address (e.g. 0xdeadbeef)\n") | |
void | osmo_talloc_vty_add_cmds (void) |
Install VTY commands for talloc context introspection. More... | |
Variables | |
void * | tall_vty_ctx |
struct host | host |
Osmocom talloc context introspection via VTY.
#define BASE_CMD_DESCR |
#define BASE_CMD_STR "show talloc-context (application|global|all) (full|brief|DEPTH)" |
enum walk_filter_type |
DEFUN | ( | show_talloc_ctx | , |
show_talloc_ctx_cmd | , | ||
BASE_CMD_STR | , | ||
BASE_CMD_DESCR | |||
) |
References argv, CMD_SUCCESS, params, talloc_ctx_walk(), vty, and WALK_FILTER_NONE.
DEFUN | ( | show_talloc_ctx_filter | , |
show_talloc_ctx_filter_cmd | , | ||
BASE_CMD_STR " filter REGEXP" | , | ||
BASE_CMD_DESCR "Filter chunks using regular expression\n" "Regular expression\n" | |||
) |
References argv, CMD_SUCCESS, CMD_WARNING, params, talloc_ctx_walk(), vty, VTY_NEWLINE, vty_out(), and WALK_FILTER_REGEXP.
DEFUN | ( | show_talloc_ctx_tree | , |
show_talloc_ctx_tree_cmd | , | ||
BASE_CMD_STR " tree ADDRESS" | , | ||
BASE_CMD_DESCR "Display only a specific memory chunk\n" "Chunk address (e.g. 0xdeadbeef)\n" | |||
) |
References argv, CMD_SUCCESS, CMD_WARNING, params, talloc_ctx_walk(), vty, VTY_NEWLINE, vty_out(), and WALK_FILTER_TREE.
void osmo_talloc_vty_add_cmds | ( | void | ) |
Install VTY commands for talloc context introspection.
This installs a set of VTY commands for introspection of a talloc context. Call this once from your application if you want to support those commands.
References install_lib_element_ve().
|
static |
Parse talloc context and depth values from a VTY command.
ctx | The context to be printed (a string from argv) |
depth | The report depth (a string from argv) |
params | The walk_cb_params struct instance |
References host::app_info, depth, OTC_GLOBAL, params, vty_app_info::tall_ctx, and talloc_ctx_walk_cb().
Referenced by DEFUN().
|
static |
Print a talloc memory hierarchy to the given VTY.
To be called by the talloc_report_depth_cb(). If one of supported filters is specified, then only satisfying memory trees would be printed.
chunk | The talloc chunk to be printed |
depth | Current depth value |
max_depth | Maximal depth of report (negative means full) |
is_ref | Is this chunk a reference? |
data | The walk_cb_params struct instance |
A filter is being bypassed while current depth value is higher than the 'depth_pass', i.e. the callback does processing the child memory chunks. As soon as this condition becomes false, we need to 'enable' a filter, and resume the processing other chunks.
As soon as a filter passes any chunk, all the memory tree starting from one would be printed. To do that, we need to temporary 'disable' a filter for child chunks (current_depth > depth_pass).
References walk_cb_params::chunk_ptr, data, depth, walk_cb_params::depth_pass, walk_cb_params::filter, walk_cb_params::regexp, walk_cb_params::vty, VTY_NEWLINE, vty_out(), WALK_FILTER_REGEXP, and WALK_FILTER_TREE.
Referenced by talloc_ctx_walk().