main/astobj2: Make REF_DEBUG a menuselect item; improve REF_DEBUG output

This patch does the following:
(1) It makes REF_DEBUG a meneselect item. Enabling REF_DEBUG now enables
    REF_DEBUG globally throughout Asterisk.
(2) The ref debug log file is now created in the AST_LOG_DIR directory.
    Every run will now blow away the previous run (as large ref files
    sometimes caused issues). We now also no longer open/close the file
    on each write, instead relying on fflush to make sure data gets written
    to the file (in case the ao2 call being performed is about to cause a
    crash)
(3) It goes with a comma delineated format for the ref debug file. This
    makes parsing much easier. This also now includes the thread ID of the
    thread that caused ref change.
(4) A new python script instead for refcounting has been added in the
    contrib/scripts folder.

Review: https://reviewboard.asterisk.org/r/3377/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@412114 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matthew Jordan
2014-04-11 01:33:03 +00:00
parent 85a69184c7
commit 751dc2b7da
9 changed files with 323 additions and 109 deletions

View File

@@ -33,7 +33,14 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <ctype.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <unistd.h>
#if defined(__APPLE__)
#include <mach/mach.h>
#elif defined(HAVE_SYS_THR_H)
#include <sys/thr.h>
#endif
#ifdef HAVE_DEV_URANDOM
#include <fcntl.h>
@@ -2276,6 +2283,24 @@ int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, co
}
#endif
int ast_get_tid(void)
{
int ret = -1;
#if defined (__linux) && defined(SYS_gettid)
ret = syscall(SYS_gettid); /* available since Linux 1.4.11 */
#elif defined(__sun)
ret = pthread_self();
#elif defined(__APPLE__)
ret = mach_thread_self();
mach_port_deallocate(mach_task_self(), ret);
#elif defined(__FreeBSD__) && defined(HAVE_SYS_THR_H)
long lwpid;
thr_self(&lwpid); /* available since sys/thr.h creation 2003 */
ret = lwpid;
#endif
return ret;
}
char *ast_utils_which(const char *binary, char *fullpath, size_t fullpath_size)
{
const char *envPATH = getenv("PATH");