Select Git revision
-
Martin Nilsson authored
Rev: lib/modules/Protocols.pmod/IPv6.pmod:1.3 Rev: lib/modules/Sql.pmod/null.pike:1.2
Martin Nilsson authoredRev: lib/modules/Protocols.pmod/IPv6.pmod:1.3 Rev: lib/modules/Sql.pmod/null.pike:1.2
dmalloc.h 10.58 KiB
/*
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
*/
#ifndef DMALLOC_H
#define DMALLOC_H
PMOD_EXPORT extern void *debug_xalloc(size_t);
PMOD_EXPORT extern void debug_xfree(void *);
PMOD_EXPORT extern void *debug_xmalloc(size_t);
PMOD_EXPORT extern void *debug_xcalloc(size_t,size_t);
PMOD_EXPORT extern void *debug_xrealloc(void *,size_t);
PMOD_EXPORT char *debug_xstrdup(const char *src);
#if defined (HAVE_EXECINFO_H) && defined (HAVE_BACKTRACE)
/* GNU libc provides some tools to inspect the stack. */
#include <execinfo.h>
typedef void *c_stack_frame;
#define DUMP_C_STACK_TRACE() do { \
c_stack_frame bt[100]; \
int n = backtrace (bt, 100); \
backtrace_symbols_fd (bt, n, 2); \
} while (0)
#else
#undef DMALLOC_C_STACK_TRACE
#define DUMP_C_STACK_TRACE() do {} while (0)
#endif
#define DMALLOC_NAMED_LOCATION(NAME) \
(("NS" __FILE__ ":" DEFINETOSTR(__LINE__) NAME )+1)
#define DMALLOC_LOCATION() DMALLOC_NAMED_LOCATION("")
/* Location types in loc[0]:
* 'S': static (DMALLOC_NAMED_LOCATION)
* 'D': dynamic (dynamic_location)
* 'B': dynamic with backtrace (debug_malloc_update_location_bt)
* 'T': memory map template
* 'M': memory map
*/
typedef char *LOCATION;
#define LOCATION_TYPE(X) ((X)[0])
#define LOCATION_NAME(X) ((X)+1)
#define LOCATION_IS_DYNAMIC(X) \
(LOCATION_TYPE (X)=='D' || LOCATION_TYPE (X) == 'B')
#ifdef DMALLOC_TRACE
#define DMALLOC_TRACELOGSIZE 131072
extern char *dmalloc_tracelog[DMALLOC_TRACELOGSIZE];
extern size_t dmalloc_tracelogptr;
#define DMALLOC_TRACE_LOG(X) (dmalloc_tracelog[ dmalloc_tracelogptr = (dmalloc_tracelogptr +1 )%DMALLOC_TRACELOGSIZE ] = (X))
#endif /* DMALLOC_TRACE */
#ifdef PIKE_DEBUG
PMOD_EXPORT extern int gc_external_refs_zapped;
PMOD_EXPORT void gc_check_zapped (void *a, TYPE_T type, const char *file, INT_TYPE line);
#endif
#ifdef DO_PIKE_CLEANUP
extern int exit_with_cleanup;
extern int exit_cleanup_in_progress;
#define DO_IF_PIKE_CLEANUP(X) X
#else