tools/trace-malloc/lib/nsTraceMallocCallbacks.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/trace-malloc/lib/nsTraceMallocCallbacks.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/* declarations needed by both nsTraceMalloc.c and nsWinTraceMalloc.cpp */
    1.11 +
    1.12 +#ifndef NSTRACEMALLOCCALLBACKS_H
    1.13 +#define NSTRACEMALLOCCALLBACKS_H
    1.14 +
    1.15 +#include <stdint.h>
    1.16 +#include <stdlib.h>
    1.17 +
    1.18 +#ifdef __cplusplus
    1.19 +extern "C" {
    1.20 +#endif
    1.21 +
    1.22 +/* Used by backtrace. */
    1.23 +typedef struct stack_buffer_info {
    1.24 +    void **buffer;
    1.25 +    size_t size;
    1.26 +    size_t entries;
    1.27 +} stack_buffer_info;
    1.28 +
    1.29 +typedef struct tm_thread tm_thread;
    1.30 +struct tm_thread {
    1.31 +    /*
    1.32 +     * This counter suppresses tracing, in case any tracing code needs
    1.33 +     * to malloc.
    1.34 +     */
    1.35 +    uint32_t suppress_tracing;
    1.36 +
    1.37 +    /* buffer for backtrace, below */
    1.38 +    stack_buffer_info backtrace_buf;
    1.39 +};
    1.40 +
    1.41 +/* implemented in nsTraceMalloc.c */
    1.42 +tm_thread * tm_get_thread(void);
    1.43 +
    1.44 +/* implemented in nsTraceMalloc.c */
    1.45 +PR_EXTERN(void) MallocCallback(void *aPtr, size_t aSize, uint32_t start, uint32_t end, tm_thread *t);
    1.46 +PR_EXTERN(void) CallocCallback(void *aPtr, size_t aCount, size_t aSize, uint32_t start, uint32_t end, tm_thread *t);
    1.47 +PR_EXTERN(void) ReallocCallback(void *aPin, void* aPout, size_t aSize, uint32_t start, uint32_t end, tm_thread *t);
    1.48 +PR_EXTERN(void) FreeCallback(void *aPtr, uint32_t start, uint32_t end, tm_thread *t);
    1.49 +
    1.50 +#ifdef XP_WIN32
    1.51 +/* implemented in nsTraceMalloc.c */
    1.52 +PR_EXTERN(void) StartupHooker();
    1.53 +PR_EXTERN(void) ShutdownHooker();
    1.54 +
    1.55 +/* implemented in nsWinTraceMalloc.cpp */
    1.56 +void* dhw_orig_malloc(size_t);
    1.57 +void* dhw_orig_calloc(size_t, size_t);
    1.58 +void* dhw_orig_realloc(void*, size_t);
    1.59 +void dhw_orig_free(void*);
    1.60 +
    1.61 +#endif /* defined(XP_WIN32) */
    1.62 +
    1.63 +#ifdef __cplusplus
    1.64 +}
    1.65 +#endif
    1.66 +
    1.67 +#endif /* !defined(NSTRACEMALLOCCALLBACKS_H) */

mercurial