\doxysection{src/vty/talloc\+\_\+ctx\+\_\+vty.c File Reference}
\label{talloc__ctx__vty_8c}\index{src/vty/talloc\_ctx\_vty.c@{src/vty/talloc\_ctx\_vty.c}}


Osmocom talloc context introspection via VTY.  


{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$regex.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/command.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/vty.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ walk\+\_\+cb\+\_\+params}
\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ BASE\+\_\+\+CMD\+\_\+\+STR}~ \char`\"{}show talloc-\/context (application$\vert$global$\vert$all) (full$\vert$brief$\vert$DEPTH)\char`\"{}
\item 
\#define \textbf{ BASE\+\_\+\+CMD\+\_\+\+DESCR}
\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ walk\+\_\+filter\+\_\+type} \{ \newline
\textbf{ WALK\+\_\+\+FILTER\+\_\+\+NONE} = 0
, \newline
\textbf{ WALK\+\_\+\+FILTER\+\_\+\+REGEXP}
, \newline
\textbf{ WALK\+\_\+\+FILTER\+\_\+\+TREE}
 \}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static void \textbf{ talloc\+\_\+ctx\+\_\+walk\+\_\+cb} (const void $\ast$chunk, int \textbf{ depth}, int max\+\_\+depth, int is\+\_\+ref, void $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Print a talloc memory hierarchy to the given VTY. \end{DoxyCompactList}\item 
static void \textbf{ talloc\+\_\+ctx\+\_\+walk} (const char $\ast$ctx, const char $\ast$\textbf{ depth}, struct \textbf{ walk\+\_\+cb\+\_\+params} $\ast$\textbf{ params})
\begin{DoxyCompactList}\small\item\em Parse talloc context and depth values from a VTY command. \end{DoxyCompactList}\item 
\textbf{ DEFUN} (show\+\_\+talloc\+\_\+ctx, show\+\_\+talloc\+\_\+ctx\+\_\+cmd, \textbf{ BASE\+\_\+\+CMD\+\_\+\+STR}, \textbf{ BASE\+\_\+\+CMD\+\_\+\+DESCR})
\item 
\textbf{ DEFUN} (show\+\_\+talloc\+\_\+ctx\+\_\+filter, show\+\_\+talloc\+\_\+ctx\+\_\+filter\+\_\+cmd, \textbf{ BASE\+\_\+\+CMD\+\_\+\+STR} \char`\"{} filter REGEXP\char`\"{}, BASE\+\_\+\+CMD\+\_\+\+DESCR \char`\"{}Filter chunks using regular \textbf{ expression\textbackslash{}n}\char`\"{} \char`\"{}Regular \textbf{ expression\textbackslash{}n}\char`\"{})
\item 
\textbf{ DEFUN} (show\+\_\+talloc\+\_\+ctx\+\_\+tree, show\+\_\+talloc\+\_\+ctx\+\_\+tree\+\_\+cmd, \textbf{ BASE\+\_\+\+CMD\+\_\+\+STR} \char`\"{} tree ADDRESS\char`\"{}, BASE\+\_\+\+CMD\+\_\+\+DESCR \char`\"{}Display only a specific \textbf{ memory} \textbf{ chunk\textbackslash{}n}\char`\"{} \char`\"{}Chunk address (e.\+g. 0xdeadbeef)\textbackslash{}\textbf{ n}\char`\"{})
\item 
void \textbf{ osmo\+\_\+talloc\+\_\+vty\+\_\+add\+\_\+cmds} (void)
\begin{DoxyCompactList}\small\item\em Install VTY commands for talloc context introspection. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
void $\ast$ \textbf{ tall\+\_\+vty\+\_\+ctx}
\item 
struct \textbf{ host} \textbf{ host}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Osmocom talloc context introspection via VTY. 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{talloc__ctx__vty_8c_a546dd73432493b70737676687cd669f4}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!BASE\_CMD\_DESCR@{BASE\_CMD\_DESCR}}
\index{BASE\_CMD\_DESCR@{BASE\_CMD\_DESCR}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{BASE\_CMD\_DESCR}
{\footnotesize\ttfamily \#define BASE\+\_\+\+CMD\+\_\+\+DESCR}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{        SHOW\_STR \textcolor{stringliteral}{"{}Show talloc memory hierarchy\(\backslash\)n"{}} \(\backslash\)}
\DoxyCodeLine{        \textcolor{stringliteral}{"{}Application's context\(\backslash\)n"{}} \(\backslash\)}
\DoxyCodeLine{        \textcolor{stringliteral}{"{}Global context (OTC\_GLOBAL)\(\backslash\)n"{}} \(\backslash\)}
\DoxyCodeLine{        \textcolor{stringliteral}{"{}All contexts, if NULL-\/context tracking is enabled\(\backslash\)n"{}} \(\backslash\)}
\DoxyCodeLine{        \textcolor{stringliteral}{"{}Display a full talloc memory hierarchy\(\backslash\)n"{}} \(\backslash\)}
\DoxyCodeLine{        \textcolor{stringliteral}{"{}Display a brief talloc memory hierarchy\(\backslash\)n"{}} \(\backslash\)}
\DoxyCodeLine{        \textcolor{stringliteral}{"{}Specify required maximal depth value\(\backslash\)n"{}}}

\end{DoxyCode}
\mbox{\label{talloc__ctx__vty_8c_afb91b81840cf4b99ca5a89840f1afdbb}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!BASE\_CMD\_STR@{BASE\_CMD\_STR}}
\index{BASE\_CMD\_STR@{BASE\_CMD\_STR}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{BASE\_CMD\_STR}
{\footnotesize\ttfamily \#define BASE\+\_\+\+CMD\+\_\+\+STR~ \char`\"{}show talloc-\/context (application$\vert$global$\vert$all) (full$\vert$brief$\vert$DEPTH)\char`\"{}}



\doxysubsection{Enumeration Type Documentation}
\mbox{\label{talloc__ctx__vty_8c_a481f68fa40cf10198a2afae3a35e3e39}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!walk\_filter\_type@{walk\_filter\_type}}
\index{walk\_filter\_type@{walk\_filter\_type}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{walk\_filter\_type}
{\footnotesize\ttfamily enum \textbf{ walk\+\_\+filter\+\_\+type}}

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{WALK\_FILTER\_NONE@{WALK\_FILTER\_NONE}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!WALK\_FILTER\_NONE@{WALK\_FILTER\_NONE}}}\mbox{\label{talloc__ctx__vty_8c_a481f68fa40cf10198a2afae3a35e3e39a30498c0ab05452b0638d8dcec6c6a006}} 
WALK\+\_\+\+FILTER\+\_\+\+NONE&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{WALK\_FILTER\_REGEXP@{WALK\_FILTER\_REGEXP}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!WALK\_FILTER\_REGEXP@{WALK\_FILTER\_REGEXP}}}\mbox{\label{talloc__ctx__vty_8c_a481f68fa40cf10198a2afae3a35e3e39a7489708beb81a43fd73bc81331912840}} 
WALK\+\_\+\+FILTER\+\_\+\+REGEXP&\\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{WALK\_FILTER\_TREE@{WALK\_FILTER\_TREE}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!WALK\_FILTER\_TREE@{WALK\_FILTER\_TREE}}}\mbox{\label{talloc__ctx__vty_8c_a481f68fa40cf10198a2afae3a35e3e39a98c551561e75e3024bccc5fd489649d8}} 
WALK\+\_\+\+FILTER\+\_\+\+TREE&\\
\hline

\end{DoxyEnumFields}


\doxysubsection{Function Documentation}
\mbox{\label{talloc__ctx__vty_8c_a4e4ba2b29ad80091003b33ba60c20b0c}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!DEFUN@{DEFUN}}
\index{DEFUN@{DEFUN}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{DEFUN()\hspace{0.1cm}{\footnotesize\ttfamily [1/3]}}
{\footnotesize\ttfamily DEFUN (\begin{DoxyParamCaption}\item[{show\+\_\+talloc\+\_\+ctx}]{,  }\item[{show\+\_\+talloc\+\_\+ctx\+\_\+cmd}]{,  }\item[{\textbf{ BASE\+\_\+\+CMD\+\_\+\+STR}}]{,  }\item[{\textbf{ BASE\+\_\+\+CMD\+\_\+\+DESCR}}]{ }\end{DoxyParamCaption})}



References \textbf{ argv}, \textbf{ CMD\+\_\+\+SUCCESS}, \textbf{ params}, \textbf{ talloc\+\_\+ctx\+\_\+walk()}, \textbf{ vty}, and \textbf{ WALK\+\_\+\+FILTER\+\_\+\+NONE}.

\mbox{\label{talloc__ctx__vty_8c_ae6af5d046bb0b1dce91ec9b1fb0bb411}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!DEFUN@{DEFUN}}
\index{DEFUN@{DEFUN}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{DEFUN()\hspace{0.1cm}{\footnotesize\ttfamily [2/3]}}
{\footnotesize\ttfamily DEFUN (\begin{DoxyParamCaption}\item[{show\+\_\+talloc\+\_\+ctx\+\_\+filter}]{,  }\item[{show\+\_\+talloc\+\_\+ctx\+\_\+filter\+\_\+cmd}]{,  }\item[{\textbf{ BASE\+\_\+\+CMD\+\_\+\+STR} \char`\"{} filter REGEXP\char`\"{}}]{,  }\item[{\textbf{ BASE\+\_\+\+CMD\+\_\+\+DESCR} \char`\"{}Filter chunks using regular \textbf{ expression\textbackslash{}n}\char`\"{} \char`\"{}Regular \textbf{ expression\textbackslash{}n}\char`\"{}}]{ }\end{DoxyParamCaption})}



References \textbf{ argv}, \textbf{ CMD\+\_\+\+SUCCESS}, \textbf{ CMD\+\_\+\+WARNING}, \textbf{ params}, \textbf{ talloc\+\_\+ctx\+\_\+walk()}, \textbf{ vty}, \textbf{ VTY\+\_\+\+NEWLINE}, \textbf{ vty\+\_\+out()}, and \textbf{ WALK\+\_\+\+FILTER\+\_\+\+REGEXP}.

\mbox{\label{talloc__ctx__vty_8c_ab19d7d7eca40208254c78191847b7b29}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!DEFUN@{DEFUN}}
\index{DEFUN@{DEFUN}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{DEFUN()\hspace{0.1cm}{\footnotesize\ttfamily [3/3]}}
{\footnotesize\ttfamily DEFUN (\begin{DoxyParamCaption}\item[{show\+\_\+talloc\+\_\+ctx\+\_\+tree}]{,  }\item[{show\+\_\+talloc\+\_\+ctx\+\_\+tree\+\_\+cmd}]{,  }\item[{\textbf{ BASE\+\_\+\+CMD\+\_\+\+STR} \char`\"{} tree ADDRESS\char`\"{}}]{,  }\item[{\textbf{ BASE\+\_\+\+CMD\+\_\+\+DESCR} \char`\"{}Display only a specific \textbf{ memory} \textbf{ chunk\textbackslash{}n}\char`\"{} \char`\"{}Chunk address (e.\+g. 0xdeadbeef)\textbackslash{}\textbf{ n}\char`\"{}}]{ }\end{DoxyParamCaption})}



References \textbf{ argv}, \textbf{ CMD\+\_\+\+SUCCESS}, \textbf{ CMD\+\_\+\+WARNING}, \textbf{ params}, \textbf{ talloc\+\_\+ctx\+\_\+walk()}, \textbf{ vty}, \textbf{ VTY\+\_\+\+NEWLINE}, \textbf{ vty\+\_\+out()}, and \textbf{ WALK\+\_\+\+FILTER\+\_\+\+TREE}.

\mbox{\label{talloc__ctx__vty_8c_af79841d88224443e132ee87d9d948122}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!osmo\_talloc\_vty\_add\_cmds@{osmo\_talloc\_vty\_add\_cmds}}
\index{osmo\_talloc\_vty\_add\_cmds@{osmo\_talloc\_vty\_add\_cmds}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{osmo\_talloc\_vty\_add\_cmds()}
{\footnotesize\ttfamily void osmo\+\_\+talloc\+\_\+vty\+\_\+add\+\_\+cmds (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



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 \textbf{ install\+\_\+lib\+\_\+element\+\_\+ve()}.

\mbox{\label{talloc__ctx__vty_8c_a537c7df1d78cec3de5e57ffef5b838aa}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!talloc\_ctx\_walk@{talloc\_ctx\_walk}}
\index{talloc\_ctx\_walk@{talloc\_ctx\_walk}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{talloc\_ctx\_walk()}
{\footnotesize\ttfamily static void talloc\+\_\+ctx\+\_\+walk (\begin{DoxyParamCaption}\item[{const char $\ast$}]{ctx,  }\item[{const char $\ast$}]{depth,  }\item[{struct \textbf{ walk\+\_\+cb\+\_\+params} $\ast$}]{params }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Parse talloc context and depth values from a VTY command. 


\begin{DoxyParams}{Parameters}
{\em ctx} & The context to be printed (a string from argv) \\
\hline
{\em depth} & The report depth (a string from argv) \\
\hline
{\em params} & The \doxyref{walk\+\_\+cb\+\_\+params}{p.}{structwalk__cb__params} struct instance \\
\hline
\end{DoxyParams}


References \textbf{ host\+::app\+\_\+info}, \textbf{ depth}, \textbf{ OTC\+\_\+\+GLOBAL}, \textbf{ params}, \textbf{ vty\+\_\+app\+\_\+info\+::tall\+\_\+ctx}, and \textbf{ talloc\+\_\+ctx\+\_\+walk\+\_\+cb()}.



Referenced by \textbf{ DEFUN()}.

\mbox{\label{talloc__ctx__vty_8c_a9a6354d04a9a3df292d8a4747982c632}} 
\index{talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}!talloc\_ctx\_walk\_cb@{talloc\_ctx\_walk\_cb}}
\index{talloc\_ctx\_walk\_cb@{talloc\_ctx\_walk\_cb}!talloc\_ctx\_vty.c@{talloc\_ctx\_vty.c}}
\doxysubsubsection{talloc\_ctx\_walk\_cb()}
{\footnotesize\ttfamily static void talloc\+\_\+ctx\+\_\+walk\+\_\+cb (\begin{DoxyParamCaption}\item[{const void $\ast$}]{chunk,  }\item[{int}]{depth,  }\item[{int}]{max\+\_\+depth,  }\item[{int}]{is\+\_\+ref,  }\item[{void $\ast$}]{data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [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.


\begin{DoxyParams}{Parameters}
{\em chunk} & The talloc chunk to be printed \\
\hline
{\em depth} & Current depth value \\
\hline
{\em max\+\_\+depth} & Maximal depth of report (negative means full) \\
\hline
{\em is\+\_\+ref} & Is this chunk a reference? \\
\hline
{\em data} & The \doxyref{walk\+\_\+cb\+\_\+params}{p.}{structwalk__cb__params} struct instance \\
\hline
\end{DoxyParams}
A filter is being bypassed while current depth value is higher than the \textquotesingle{}depth\+\_\+pass\textquotesingle{}, i.\+e. the callback does processing the child memory chunks. As soon as this condition becomes false, we need to \textquotesingle{}enable\textquotesingle{} 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 \textquotesingle{}disable\textquotesingle{} a filter for child chunks (current\+\_\+depth $>$ depth\+\_\+pass).

References \textbf{ walk\+\_\+cb\+\_\+params\+::chunk\+\_\+ptr}, \textbf{ data}, \textbf{ depth}, \textbf{ walk\+\_\+cb\+\_\+params\+::depth\+\_\+pass}, \textbf{ walk\+\_\+cb\+\_\+params\+::filter}, \textbf{ walk\+\_\+cb\+\_\+params\+::regexp}, \textbf{ walk\+\_\+cb\+\_\+params\+::vty}, \textbf{ VTY\+\_\+\+NEWLINE}, \textbf{ vty\+\_\+out()}, \textbf{ WALK\+\_\+\+FILTER\+\_\+\+REGEXP}, and \textbf{ WALK\+\_\+\+FILTER\+\_\+\+TREE}.



Referenced by \textbf{ talloc\+\_\+ctx\+\_\+walk()}.

