Loading...
Searching...
No Matches
talloc_ctx_vty.c File Reference

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.
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.
| 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.

## Variables

void * | tall_vty_ctx
struct host | host

## Detailed Description

Osmocom talloc context introspection via VTY.

## Macro Definition Documentation

## BASE_CMD_DESCR

#define BASE_CMD_DESCR

Value:
SHOW_STR "Show talloc memory hierarchy\n" \
"Application's context\n" \
"Global context (OTC_GLOBAL)\n" \
"All contexts, if NULL-context tracking is enabled\n" \
"Display a full talloc memory hierarchy\n" \
"Display a brief talloc memory hierarchy\n" \
"Specify required maximal depth value\n"
SHOW_STR
#define SHOW_STR
Definition command.h:372

Referenced by DEFUN(), DEFUN(), and DEFUN().

## BASE_CMD_STR

#define BASE_CMD_STR "show talloc-context (application|global|all) (full|brief|DEPTH)"

Referenced by DEFUN(), DEFUN(), and DEFUN().

## Enumeration Type Documentation

## walk_filter_type

enum walk_filter_type

Enumerator
WALK_FILTER_NONE |
WALK_FILTER_REGEXP |
WALK_FILTER_TREE |

## Function Documentation

## DEFUN() [1/3]

DEFUN | ( | show_talloc_ctx | ,
|  | show_talloc_ctx_cmd | ,
|  | BASE_CMD_STR | ,
|  | BASE_CMD_DESCR | )

References argv, BASE_CMD_DESCR, BASE_CMD_STR, CMD_SUCCESS, talloc_ctx_walk(), and WALK_FILTER_NONE.

## DEFUN() [2/3]

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, BASE_CMD_DESCR, BASE_CMD_STR, CMD_SUCCESS, CMD_WARNING, talloc_ctx_walk(), VTY_NEWLINE, vty_out(), and WALK_FILTER_REGEXP.

## DEFUN() [3/3]

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, BASE_CMD_DESCR, BASE_CMD_STR, CMD_SUCCESS, CMD_WARNING, talloc_ctx_walk(), VTY_NEWLINE, vty_out(), and WALK_FILTER_TREE.

## osmo_talloc_vty_add_cmds()

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().

## talloc_ctx_walk()

void talloc_ctx_walk | ( | const char * | ctx,
|  | const char * | depth,
|  | struct walk_cb_params * | params )

static

Parse talloc context and depth values from a VTY command.

Parameters

  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, vty_app_info::tall_ctx, and talloc_ctx_walk_cb().

Referenced by DEFUN(), DEFUN(), and DEFUN().

## talloc_ctx_walk_cb()

void talloc_ctx_walk_cb | ( | const void * | chunk,
|  | int | depth,
|  | int | max_depth,
|  | int | is_ref,
|  | void * | data )

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.

Parameters

  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, 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().