Review at  https://gerrit.osmocom.org/7265

configure.ac: add --enable-track-null option

This option allows one to enable tracking the use of talloc NULL
memory contexts. Useful when you want to observe not only the
application root context, but also other contexts, e.g. not
exposed by libosmocore.

In order to obserbe all existing contexts, use:

  OsmoBTS# show talloc-context all ...

Example of usage:

  OsmoBTS# show talloc-context all brief

  talloc report on 'null_context' (total 1302808 bytes in 5185 blocks)
    lapd context              contains    129 bytes in   5 blocks
    struct signal_handler     contains     40 bytes in   1 blocks
    struct pcu_sock_state     contains    120 bytes in   1 blocks
    struct lookup_helper      contains     24 bytes in   1 blocks
    struct signal_handler     contains     40 bytes in   1 blocks
    struct signal_handler     contains     40 bytes in   1 blocks
    abis                      contains  49065 bytes in  19 blocks
    struct signal_handler     contains     40 bytes in   1 blocks
    struct signal_handler     contains     40 bytes in   1 blocks
    struct signal_handler     contains     40 bytes in   1 blocks
    vty                       contains  93690 bytes in 5008 blocks
    logging                   contains   2862 bytes in   7 blocks
    OsmoBTS context           contains 1156678 bytes in 137 blocks

Change-Id: I5e9381902dace7dfd37f98b657e4697b5afcff96
---
M configure.ac
M src/common/main.c
2 files changed, 15 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/65/7265/1

diff --git a/configure.ac b/configure.ac
index b375806..db86979 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,16 @@
        CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
 fi
 
+AC_ARG_ENABLE(track_null,
+       AS_HELP_STRING([--enable-track-null],
+               [Enable tracking the use of talloc NULL memory contexts]),
+       [track_null=$enableval], [track_null="no"])
+if test x"$track_null" = x"yes"
+then
+       AC_DEFINE([TALLOC_TRACK_NULL], [1],
+               [Define to enable tracking the use of talloc NULL memory 
contexts])
+fi
+
 AC_ARG_ENABLE(werror,
        [AS_HELP_STRING(
                [--enable-werror],
diff --git a/src/common/main.c b/src/common/main.c
index df3c046..4186f59 100644
--- a/src/common/main.c
+++ b/src/common/main.c
@@ -233,6 +233,11 @@
 
        printf("((*))\n  |\n / \\ OsmoBTS\n");
 
+#ifdef TALLOC_TRACK_NULL
+       /* Track the use of NULL memory contexts */
+       talloc_enable_null_tracking();
+#endif
+
        tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context");
        msgb_talloc_ctx_init(tall_bts_ctx, 100*1024);
        bts_vty_info.tall_ctx = tall_bts_ctx;

-- 
To view, visit https://gerrit.osmocom.org/7265
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e9381902dace7dfd37f98b657e4697b5afcff96
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilira...@gmail.com>

Reply via email to