Removed "function/code stack" debugging configure option (#4454)

Easily replaced w/third-party tools, e.g. libbacktrace
(https://github.com/ianlancetaylor/libbacktrace)
This commit is contained in:
Quincey Koziol
2024-05-03 03:30:45 -07:00
committed by GitHub
parent 1b6ae84d15
commit 63fcd583d0
18 changed files with 73 additions and 883 deletions
-2
View File
@@ -307,14 +307,12 @@ sub rewrite_func ($$$$$) {
# First remove:
# * /*in*/, /*out*/, /*in_out*/, and /*in,out*/ comments
# * preprocessor lines that start with #
# * H5FL_TRACKING_PARAMS macros (free list code only)
#
# then split the function arguments on commas
$args =~ s/\/\*\s*in\s*\*\///g; # Get rid of /*in*/
$args =~ s/\/\*\s*out\s*\*\///g; # Get rid of /*out*/
$args =~ s/\/\*\s*in,\s*out\s*\*\///g; # Get rid of /*in,out*/
$args =~ s/\/\*\s*in_out\s*\*\///g; # Get rid of /*in_out*/
$args =~ s/H5FL_TRACK_PARAMS//g; # Remove free list macro
$args =~ s/\n#.*?\n/\n/g; # Remove lines beginning with '#'
my @args = split /,[\s\n]*/, $args;
my $argno = 0;
-10
View File
@@ -495,16 +495,6 @@ if (HDF5_WANT_DCONV_EXCEPTION)
endif ()
MARK_AS_ADVANCED (HDF5_WANT_DCONV_EXCEPTION)
# ----------------------------------------------------------------------
# Check if they would like the function stack support compiled in
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_CODESTACK "Enable the function stack tracing (for developer debugging)." OFF)
mark_as_advanced (HDF5_ENABLE_CODESTACK)
if (HDF5_ENABLE_CODESTACK)
set (${HDF_PREFIX}_HAVE_CODESTACK 1)
endif ()
MARK_AS_ADVANCED (HDF5_ENABLE_CODESTACK)
# ----------------------------------------------------------------------
# Check if they would like to show all warnings (not suppressed internally)
#-----------------------------------------------------------------------------
-3
View File
@@ -110,9 +110,6 @@
/* Define to 1 if CLOCK_MONOTONIC_COARSE is available */
#cmakedefine H5_HAVE_CLOCK_MONOTONIC_COARSE @H5_HAVE_CLOCK_MONOTONIC_COARSE@
/* Define if the function stack tracing code is to be compiled in */
#cmakedefine H5_HAVE_CODESTACK @H5_HAVE_CODESTACK@
/* Define to 1 if you have the <curl/curl.h> header file. */
#cmakedefine H5_HAVE_CURL_CURL_H @H5_HAVE_CURL_H@
+1 -12
View File
@@ -157,17 +157,6 @@ if (HDF5_ENABLE_DEBUG_H5C_SANITY_CHECKS)
# list (APPEND HDF5_DEBUG_APIS H5C_DO_MEMORY_SANITY_CHECKS=1)
endif ()
option (HDF5_ENABLE_DEBUG_H5FL_TRACK "Enable tracking of free list allocations" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FL_TRACK)
if (HDF5_ENABLE_DEBUG_H5FL_TRACK)
list (APPEND HDF5_DEBUG_APIS H5FL_TRACK)
# Free list tracking requires the codestack functionality
set (HDF5_ENABLE_CODESTACK ON CACHE BOOL "Enable the function stack tracing (for developer debugging)." FORCE)
else ()
unset (HDF5_ENABLE_CODESTACK CACHE)
endif ()
option (HDF5_ENABLE_DEBUG_H5FS_ASSERT "Enable extra debugging of H5FS module" OFF)
mark_as_advanced (HDF5_ENABLE_DEBUG_H5FS_ASSERT)
if (HDF5_ENABLE_DEBUG_H5FS_ASSERT)
@@ -178,7 +167,7 @@ endif ()
# free lists entirely for developer build modes, as they can
# make certain types of issues (like references to stale pointers)
# much more difficult to debug
if (NOT HDF5_ENABLE_DEBUG_H5FL AND NOT HDF5_ENABLE_DEBUG_H5FL_TRACK)
if (NOT HDF5_ENABLE_DEBUG_H5FL)
list (APPEND HDF5_DEVELOPER_DEFS H5_NO_FREE_LISTS)
endif ()
-1
View File
@@ -88,7 +88,6 @@ Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@
Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@
API Tracing: @HDF5_ENABLE_TRACE@
Using memory checker: @HDF5_ENABLE_USING_MEMCHECKER@
Function Stack Tracing: @HDF5_ENABLE_CODESTACK@
Use file locking: @HDF5_FILE_LOCKING_SETTING@
Strict File Format Checks: @HDF5_STRICT_FORMAT_CHECKS@
Optimization Instrumentation: @HDF5_Enable_Instrument@
-34
View File
@@ -2884,40 +2884,6 @@ if test -n "$DEBUG_PKG_LIST"; then
done
fi
## ----------------------------------------------------------------------
## Check if they would like the function stack support compiled in
##
AC_MSG_CHECKING([whether function stack tracking is enabled])
AC_ARG_ENABLE([codestack],
[AS_HELP_STRING([--enable-codestack],
[Enable the function stack tracing (for developer debugging).
[default=no]
])],
[CODESTACK=$enableval])
## Set the default level.
if test "X-$CODESTACK" = X- ; then
CODESTACK=no
fi
## Allow this variable to be substituted in
## other files (src/libhdf5.settings.in, etc.)
AC_SUBST([CODESTACK])
case "X-$CODESTACK" in
X-yes)
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_CODESTACK], [1],
[Define if the function stack tracing code is to be compiled in])
;;
X-no)
AC_MSG_RESULT([no])
;;
*)
AC_MSG_ERROR([Unrecognized value: $CODESTACK])
;;
esac
## ----------------------------------------------------------------------
## Enable tracing of the API
##
-1
View File
@@ -842,7 +842,6 @@ HDF5_EXTERNAL_LIB_PREFIX "Use prefix for custom library naming."
HDF5_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF
HDF5_ENABLE_ALL_WARNINGS "Enable all warnings" OFF
HDF5_SHOW_ALL_WARNINGS "Show all warnings (i.e. not suppress "noisy" ones internally)" OFF
HDF5_ENABLE_CODESTACK "Enable the function stack tracing (for developer debugging)." OFF
HDF5_ENABLE_COVERAGE "Enable code coverage for Libraries and Programs" OFF
HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF
HDF5_ENABLE_DEPRECATED_SYMBOLS "Enable deprecated public API symbols" ON
+10
View File
@@ -47,6 +47,16 @@ New Features
Configuration:
-------------
- Removed "function/code stack" debugging configuration option:
CMake: HDF5_ENABLE_CODESTACK
Autotools: --enable-codestack
This was used to debug memory leaks internal to the library, but has been
broken for >1.5 years and is now easily replaced with third-party tools
(e.g. libbacktrace: https://github.com/ianlancetaylor/libbacktrace) on an
as-needed basis when debugging an issue.
- Added configure options for enabling/disabling non-standard programming
language features
-11
View File
@@ -99,14 +99,6 @@ set (H5C_HDRS
IDE_GENERATED_PROPERTIES ("H5C" "${H5C_HDRS}" "${H5C_SOURCES}" )
set (H5CS_SOURCES
${HDF5_SRC_DIR}/H5CS.c
)
set (H5CS_HDRS
)
IDE_GENERATED_PROPERTIES ("H5CS" "${H5CS_HDRS}" "${H5CS_SOURCES}" )
set (H5CX_SOURCES
${HDF5_SRC_DIR}/H5CX.c
)
@@ -777,7 +769,6 @@ set (common_SRCS
${H5B_SOURCES}
${H5B2_SOURCES}
${H5C_SOURCES}
${H5CS_SOURCES}
${H5CX_SOURCES}
${H5D_SOURCES}
${H5E_SOURCES}
@@ -872,8 +863,6 @@ set (H5_PRIVATE_HEADERS
${HDF5_SRC_DIR}/H5Cpkg.h
${HDF5_SRC_DIR}/H5Cprivate.h
${HDF5_SRC_DIR}/H5CSprivate.h
${HDF5_SRC_DIR}/H5CXprivate.h
${HDF5_SRC_DIR}/H5Dpkg.h
-295
View File
@@ -1,295 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: Provides internal function tracing in the form of a stack.
* The FUNC_ENTER() macro adds the function name to the function
* stack whenever a function is entered.
* As the functions return with FUNC_LEAVE,
* entries are removed from the stack.
*
* A function stack has a fixed maximum size. If this size is
* exceeded then the stack will be truncated and only the
* first called functions will have entries on the stack. This is
* expected to be a rare condition.
*
*/
#include "H5private.h" /* Generic Functions */
#include "H5CSprivate.h" /* Function stack */
#include "H5Eprivate.h" /* Error handling */
#include "H5MMprivate.h" /* Memory management */
#ifdef H5_HAVE_CODESTACK
#define H5CS_MIN_NSLOTS 16 /* Minimum number of records in an function stack */
/* A function stack */
typedef struct H5CS_t {
unsigned nused; /* Number of records currently used in stack */
unsigned nalloc; /* Number of records current allocated for stack */
const char **rec; /* Array of function records */
} H5CS_t;
#ifdef H5_HAVE_THREADSAFE
/*
* The per-thread function stack. pthread_once() initializes a special
* key that will be used by all threads to create a stack specific to
* each thread individually. The association of stacks to threads will
* be handled by the pthread library.
*
* In order for this macro to work, H5CS_get_my_stack() must be preceded
* by "H5CS_t *fstack =".
*/
static H5CS_t *H5CS__get_stack(void);
#define H5CS_get_my_stack() H5CS__get_stack()
#else /* H5_HAVE_THREADSAFE */
/*
* The function stack. Eventually we'll have some sort of global table so each
* thread has it's own stack. The stacks will be created on demand when the
* thread first calls H5CS_push(). */
H5CS_t H5CS_stack_g[1];
#define H5CS_get_my_stack() (H5CS_stack_g + 0)
#endif /* H5_HAVE_THREADSAFE */
#ifdef H5_HAVE_THREADSAFE
/*-------------------------------------------------------------------------
* Function: H5CS__get_stack
*
* Purpose: Support function for H5CS_get_my_stack() to initialize and
* acquire per-thread function stack.
*
* Return: Success: function stack (H5CS_t *)
*
* Failure: NULL
*
*-------------------------------------------------------------------------
*/
static H5CS_t *
H5CS__get_stack(void)
{
H5CS_t *fstack;
FUNC_ENTER_PACKAGE_NOERR_NOFS
fstack = H5TS_get_thread_local_value(H5TS_funcstk_key_g);
if (!fstack) {
/* No associated value with current thread - create one */
#ifdef H5_HAVE_WIN_THREADS
fstack = (H5CS_t *)LocalAlloc(
LPTR, sizeof(H5CS_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */
#else
fstack =
(H5CS_t *)malloc(sizeof(H5CS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */
#endif /* H5_HAVE_WIN_THREADS */
assert(fstack);
/* Set the thread-specific info */
fstack->nused = 0;
fstack->nalloc = 0;
fstack->rec = NULL;
/* (It's not necessary to release this in this API, it is
* released by the "key destructor" set up in the H5TS
* routines. See calls to pthread_key_create() in H5TS.c -QAK)
*/
H5TS_set_thread_local_value(H5TS_funcstk_key_g, (void *)fstack);
} /* end if */
FUNC_LEAVE_NOAPI_NOFS(fstack)
} /* end H5CS__get_stack() */
#endif /* H5_HAVE_THREADSAFE */
/*-------------------------------------------------------------------------
* Function: H5CS_print_stack
*
* Purpose: Prints a function stack.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5CS_print_stack(const H5CS_t *fstack, FILE *stream)
{
const int indent = 2; /* Indentation level */
int i; /* Local index ariable */
/* Don't push this function on the function stack... :-) */
FUNC_ENTER_NOAPI_NOERR_NOFS
/* Sanity check */
assert(fstack);
/* Default to outputting information to stderr */
if (!stream)
stream = stderr;
fprintf(stream, "HDF5-DIAG: Function stack from %s", H5_lib_vers_info_g);
/* try show the process or thread id in multiple processes cases*/
#ifdef H5_HAVE_THREADSAFE
fprintf(stream, " thread %" PRIu64 ".", H5TS_thread_id());
#endif
if (fstack && fstack->nused > 0)
fprintf(stream, " Back trace follows.");
fputc('\n', stream);
for (i = fstack->nused - 1; i >= 0; --i)
fprintf(stream, "%*s#%03d: Routine: %s\n", indent, "", i, fstack->rec[i]);
FUNC_LEAVE_NOAPI_NOFS(SUCCEED)
} /* end H5CS_print_stack() */
/*-------------------------------------------------------------------------
* Function: H5CS_push
*
* Purpose: Pushes a new record onto function stack for the current
* thread.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5CS_push(const char *func_name)
{
H5CS_t *fstack = H5CS_get_my_stack(); /* Current function stack for library */
/* Don't push this function on the function stack... :-) */
FUNC_ENTER_NOAPI_NOERR_NOFS
/* Sanity check */
assert(fstack);
assert(fstack->nused <= fstack->nalloc);
assert(func_name);
/* Check if we need to expand the stack of records */
if (fstack->nused == fstack->nalloc) {
size_t na = MAX((fstack->nalloc * 2), H5CS_MIN_NSLOTS);
/* Don't use H5MM_realloc here */
const char **x = (const char **)realloc(fstack->rec, na * sizeof(const char *));
/* (Avoid returning an error from this routine, currently -QAK) */
assert(x);
fstack->rec = x;
fstack->nalloc = na;
} /* end if */
/* Push the function name */
fstack->rec[fstack->nused] = func_name;
fstack->nused++;
FUNC_LEAVE_NOAPI_NOFS(SUCCEED)
} /* end H5CS_push() */
/*-------------------------------------------------------------------------
* Function: H5CS_pop
*
* Purpose: Pops a record off function stack for the current thread.
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5CS_pop(void)
{
H5CS_t *fstack = H5CS_get_my_stack();
/* Don't push this function on the function stack... :-) */
FUNC_ENTER_NOAPI_NOERR_NOFS
/* Sanity check */
assert(fstack);
assert(fstack->nused > 0);
/* Pop the function. */
fstack->nused--;
FUNC_LEAVE_NOAPI_NOFS(SUCCEED)
} /* end H5CS_pop() */
/*-------------------------------------------------------------------------
* Function: H5CS_copy_stack
*
* Purpose: Makes a copy of the current stack
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
H5CS_t *
H5CS_copy_stack(void)
{
H5CS_t *old_stack = H5CS_get_my_stack(); /* Existing function stack for library */
H5CS_t *new_stack; /* New function stack, for copy */
H5CS_t *ret_value = NULL; /* Return value */
/* Don't push this function on the function stack... :-) */
FUNC_ENTER_NOAPI_NOFS
/* Sanity check */
assert(old_stack);
/* Allocate a new stack */
/* (Don't use library allocate code, since this code stack supports it) */
if (NULL == (new_stack = calloc(1, sizeof(H5CS_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack");
if (NULL == (new_stack->rec = calloc(old_stack->nused, sizeof(const char *))))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "can't allocate function stack records");
/* Copy pointers on old stack to new one */
/* (Strings don't need to be duplicated, they are statically allocated) */
H5MM_memcpy(new_stack->rec, old_stack->rec, sizeof(char *) * old_stack->nused);
new_stack->nused = new_stack->nalloc = old_stack->nused;
/* Set the return value */
ret_value = new_stack;
done:
FUNC_LEAVE_NOAPI_NOFS(ret_value)
} /* end H5CS_copy_stack() */
/*-------------------------------------------------------------------------
* Function: H5CS_close_stack
*
* Purpose: Closes and frees a copy of a stack
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
H5CS_close_stack(H5CS_t *stack)
{
/* Don't push this function on the function stack... :-) */
FUNC_ENTER_NOAPI_NOERR_NOFS
/* Sanity check */
assert(stack);
/* Free stack */
/* The function name string are statically allocated (by the compiler)
* and are not allocated, so there's no need to free them.
*/
if (stack->rec) {
free(stack->rec);
stack->rec = NULL;
} /* end if */
if (stack)
free(stack);
FUNC_LEAVE_NOAPI_NOFS(SUCCEED)
} /* end H5CS_close_stack() */
#endif /* H5_HAVE_CODESTACK */
-30
View File
@@ -1,30 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Header file for function stacks, etc.
*/
#ifndef H5CSprivate_H
#define H5CSprivate_H
/* Private headers needed by this file */
#include "H5private.h"
/* Forward declarations for structure fields */
struct H5CS_t;
H5_DLL herr_t H5CS_push(const char *func_name);
H5_DLL herr_t H5CS_pop(void);
H5_DLL herr_t H5CS_print_stack(const struct H5CS_t *stack, FILE *stream);
H5_DLL struct H5CS_t *H5CS_copy_stack(void);
H5_DLL herr_t H5CS_close_stack(struct H5CS_t *stack);
#endif /* H5CSprivate_H */
+36 -339
View File
@@ -113,15 +113,6 @@ struct H5FL_fac_node_t {
/* The head of the list of factory things to garbage collect */
static H5FL_fac_gc_list_t H5FL_fac_gc_head = {0, NULL};
#ifdef H5FL_TRACK
/* Extra headers needed */
#include "H5CSprivate.h" /* Function stack */
/* Head of "outstanding allocations" list */
static H5FL_track_t *H5FL_out_head_g = NULL;
#endif /* H5FL_TRACK */
/* Forward declarations of local static functions */
static void *H5FL__malloc(size_t mem_size);
static herr_t H5FL__reg_init(H5FL_reg_head_t *head);
@@ -187,25 +178,6 @@ H5FL_term_package(void)
n += H5FL__arr_term();
n += H5FL__blk_term();
#ifdef H5FL_TRACK
/* If we haven't freed all the allocated memory, dump out the list now */
if (n > 0 && H5FL_out_head_g) {
H5FL_track_t *trk = H5FL_out_head_g;
/* Dump information about all the outstanding allocations */
while (trk != NULL) {
/* Print information about the outstanding block */
fprintf(stderr, "%s: Outstanding allocation:\n", __func__);
fprintf(stderr, "\tPtr: %p, File: %s, Function: %s, Line: %d\n",
(((unsigned char *)trk) + sizeof(H5FL_track_t)), trk->file, trk->func, trk->line);
H5CS_print_stack(trk->stack, stderr);
/* Advance to next node */
trk = trk->next;
} /* end while */
} /* end if */
#endif /* H5FL_TRACK */
FUNC_LEAVE_NOAPI(n)
} /* end H5FL_term_package() */
@@ -279,11 +251,6 @@ H5FL__reg_init(H5FL_reg_head_t *head)
if (head->size < sizeof(H5FL_reg_node_t))
head->size = sizeof(H5FL_reg_node_t);
/* Make certain there's room for tracking information, if any */
#ifdef H5FL_TRACK
head->size += sizeof(H5FL_track_t);
#endif /* H5FL_TRACK */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL__reg_init() */
@@ -310,32 +277,6 @@ H5FL_reg_free(H5FL_reg_head_t *head, void *obj)
assert(head);
assert(obj);
#ifdef H5FL_TRACK
{
H5FL_track_t *trk = obj = ((unsigned char *)obj) - sizeof(H5FL_track_t);
/* Free tracking information about the allocation location */
H5CS_close_stack(trk->stack);
/* The 'func' & 'file' strings are statically allocated (by the compiler)
* and are not allocated, so there's no need to free them.
*/
trk->file = NULL;
trk->func = NULL;
/* Remove from "outstanding allocations" list */
if (trk == H5FL_out_head_g) {
H5FL_out_head_g = H5FL_out_head_g->next;
if (H5FL_out_head_g)
H5FL_out_head_g->prev = NULL;
} /* end if */
else {
trk->prev->next = trk->next;
if (trk->next)
trk->next->prev = trk->prev;
} /* end else */
}
#endif /* H5FL_TRACK */
#ifdef H5FL_DEBUG
memset(obj, 255, head->size);
#endif /* H5FL_DEBUG */
@@ -381,7 +322,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS)
H5FL_reg_malloc(H5FL_reg_head_t *head)
{
void *ret_value = NULL; /* Pointer to object to return */
@@ -418,28 +359,6 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS)
head->allocated++;
} /* end else */
#ifdef H5FL_TRACK
/* Copy allocation location information */
((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack();
assert(((H5FL_track_t *)ret_value)->stack);
/* The 'call_func' & 'call_file' strings are statically allocated (by the compiler)
* there's no need to duplicate them.
*/
((H5FL_track_t *)ret_value)->file = call_file;
((H5FL_track_t *)ret_value)->func = call_func;
((H5FL_track_t *)ret_value)->line = call_line;
/* Add to "outstanding allocations" list */
((H5FL_track_t *)ret_value)->prev = NULL;
((H5FL_track_t *)ret_value)->next = H5FL_out_head_g;
if (H5FL_out_head_g)
H5FL_out_head_g->prev = (H5FL_track_t *)ret_value;
H5FL_out_head_g = (H5FL_track_t *)ret_value;
/* Adjust for allocation tracking information */
ret_value = ((unsigned char *)ret_value) + sizeof(H5FL_track_t);
#endif /* H5FL_TRACK */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_reg_malloc() */
@@ -455,7 +374,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS)
H5FL_reg_calloc(H5FL_reg_head_t *head)
{
void *ret_value = NULL; /* Pointer to object to return */
@@ -465,12 +384,11 @@ H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS)
assert(head);
/* Allocate the block */
if (NULL == (ret_value = H5FL_reg_malloc(head H5FL_TRACK_INFO_INT)))
if (NULL == (ret_value = H5FL_reg_malloc(head)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Clear to zeros */
/* (Accommodate tracking information, if present) */
memset(ret_value, 0, head->size - H5FL_TRACK_SIZE);
memset(ret_value, 0, head->size);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -803,7 +721,7 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size)
*-------------------------------------------------------------------------
*/
void *
H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS)
H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size)
{
H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */
H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */
@@ -844,8 +762,7 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS)
assert(free_list);
/* Allocate new node, with room for the page info header and the actual page data */
if (NULL ==
(temp = (H5FL_blk_list_t *)H5FL__malloc(sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE + size)))
if (NULL == (temp = (H5FL_blk_list_t *)H5FL__malloc(sizeof(H5FL_blk_list_t) + size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk");
/* Increment the number of blocks of this size */
@@ -861,28 +778,6 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS)
/* Set the return value to the block itself */
ret_value = ((char *)temp) + sizeof(H5FL_blk_list_t);
#ifdef H5FL_TRACK
/* Copy allocation location information */
((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack();
assert(((H5FL_track_t *)ret_value)->stack);
/* The 'call_func' & 'call_file' strings are statically allocated (by the compiler)
* there's no need to duplicate them.
*/
((H5FL_track_t *)ret_value)->file = call_file;
((H5FL_track_t *)ret_value)->func = call_func;
((H5FL_track_t *)ret_value)->line = call_line;
/* Add to "outstanding allocations" list */
((H5FL_track_t *)ret_value)->prev = NULL;
((H5FL_track_t *)ret_value)->next = H5FL_out_head_g;
if (H5FL_out_head_g)
H5FL_out_head_g->prev = (H5FL_track_t *)ret_value;
H5FL_out_head_g = (H5FL_track_t *)ret_value;
/* Adjust for allocation tracking information */
ret_value = ((unsigned char *)ret_value) + sizeof(H5FL_track_t);
#endif /* H5FL_TRACK */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_malloc() */
@@ -902,7 +797,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS)
H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size)
{
void *ret_value = NULL; /* Pointer to the block to return to the user */
@@ -913,7 +808,7 @@ H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS)
assert(size);
/* Allocate the block */
if (NULL == (ret_value = H5FL_blk_malloc(head, size H5FL_TRACK_INFO_INT)))
if (NULL == (ret_value = H5FL_blk_malloc(head, size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Clear the block to zeros */
@@ -952,46 +847,14 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block)
assert(head);
assert(block);
#ifdef H5FL_TRACK
{
unsigned char *block_ptr = ((unsigned char *)block) - sizeof(H5FL_track_t);
H5FL_track_t trk;
H5MM_memcpy(&trk, block_ptr, sizeof(H5FL_track_t));
/* Free tracking information about the allocation location */
H5CS_close_stack(trk.stack);
/* The 'func' & 'file' strings are statically allocated (by the compiler)
* and are not allocated, so there's no need to free them.
*/
trk.file = NULL;
trk.func = NULL;
/* Remove from "outstanding allocations" list */
if ((void *)block_ptr == (void *)H5FL_out_head_g) {
H5FL_out_head_g = H5FL_out_head_g->next;
if (H5FL_out_head_g)
H5FL_out_head_g->prev = NULL;
} /* end if */
else {
trk.prev->next = trk.next;
if (trk.next)
trk.next->prev = trk.prev;
} /* end else */
H5MM_memcpy(block_ptr, &trk, sizeof(H5FL_track_t));
}
#endif /* H5FL_TRACK */
/* Get the pointer to the native block info header in front of the native block to free */
temp =
(H5FL_blk_list_t *)((void *)((unsigned char *)block - (sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE)));
temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block - sizeof(H5FL_blk_list_t)));
/* Save the block's size for later */
free_size = temp->size;
#ifdef H5FL_DEBUG
memset(temp, 255, free_size + sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE);
memset(temp, 255, free_size + sizeof(H5FL_blk_list_t));
#endif /* H5FL_DEBUG */
/* Check if there is a free list for native blocks of this size */
@@ -1041,7 +904,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_PARAMS)
H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size)
{
void *ret_value = NULL; /* Return value */
@@ -1056,54 +919,24 @@ H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_
H5FL_blk_list_t *temp; /* Temp. ptr to the new block node allocated */
/* Get the pointer to the chunk info header in front of the chunk to free */
temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block -
(sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE)));
temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block - sizeof(H5FL_blk_list_t)));
/* check if we are actually changing the size of the buffer */
if (new_size != temp->size) {
size_t blk_size; /* Temporary block size */
if ((ret_value = H5FL_blk_malloc(head, new_size H5FL_TRACK_INFO_INT)) == NULL)
if (NULL == (ret_value = H5FL_blk_malloc(head, new_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for block");
blk_size = MIN(new_size, temp->size);
H5MM_memcpy(ret_value, block, blk_size);
H5FL_blk_free(head, block);
} /* end if */
else {
#ifdef H5FL_TRACK
{
unsigned char *block_ptr = ((unsigned char *)block) - sizeof(H5FL_track_t);
H5FL_track_t trk;
H5MM_memcpy(&trk, block_ptr, sizeof(H5FL_track_t));
/* Release previous tracking information */
H5CS_close_stack(trk.stack);
/* The 'func' & 'file' strings are statically allocated (by the compiler)
* and are not allocated, so there's no need to free them.
*/
trk.file = NULL;
trk.func = NULL;
/* Store new tracking information */
trk.stack = H5CS_copy_stack();
assert(trk.stack);
/* The 'call_func' & 'call_file' strings are statically allocated (by the compiler)
* there's no need to duplicate them.
*/
trk.file = call_file;
trk.func = call_func;
trk.line = call_line;
H5MM_memcpy(block_ptr, &trk, sizeof(H5FL_track_t));
}
#endif /* H5FL_TRACK */
else
ret_value = block;
} /* end if */
} /* end if */
} /* end if */
/* Not re-allocating, just allocate a fresh block */
else
ret_value = H5FL_blk_malloc(head, new_size H5FL_TRACK_INFO_INT);
ret_value = H5FL_blk_malloc(head, new_size);
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1371,39 +1204,8 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
/* Make certain that the free list is initialized */
assert(head->init);
#ifdef H5FL_TRACK
{
unsigned char *block_ptr = ((unsigned char *)obj) - sizeof(H5FL_track_t);
H5FL_track_t trk;
H5MM_memcpy(&trk, block_ptr, sizeof(H5FL_track_t));
/* Free tracking information about the allocation location */
H5CS_close_stack(trk.stack);
/* The 'func' & 'file' strings are statically allocated (by the compiler)
* and are not allocated, so there's no need to free them.
*/
trk.file = NULL;
trk.func = NULL;
/* Remove from "outstanding allocations" list */
if ((void *)block_ptr == H5FL_out_head_g) {
H5FL_out_head_g = H5FL_out_head_g->next;
if (H5FL_out_head_g)
H5FL_out_head_g->prev = NULL;
} /* end if */
else {
trk.prev->next = trk.next;
if (trk.next)
trk.next->prev = trk.prev;
} /* end else */
H5MM_memcpy(block_ptr, &trk, sizeof(H5FL_track_t));
}
#endif
/* Get the pointer to the info header in front of the block to free */
temp = (H5FL_arr_list_t *)((void *)((unsigned char *)obj - (sizeof(H5FL_arr_list_t) + H5FL_TRACK_SIZE)));
temp = (H5FL_arr_list_t *)((void *)((unsigned char *)obj - sizeof(H5FL_arr_list_t)));
/* Get the number of elements */
free_nelem = temp->nelem;
@@ -1453,7 +1255,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS)
H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem)
{
H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */
size_t mem_size; /* Size of memory block being recycled */
@@ -1494,8 +1296,7 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS)
} /* end if */
/* Otherwise allocate a node */
else {
if (NULL ==
(new_obj = (H5FL_arr_list_t *)H5FL__malloc(sizeof(H5FL_arr_list_t) + H5FL_TRACK_SIZE + mem_size)))
if (NULL == (new_obj = (H5FL_arr_list_t *)H5FL__malloc(sizeof(H5FL_arr_list_t) + mem_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Increment the number of blocks of this size */
@@ -1511,28 +1312,6 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS)
/* Get a pointer to the new block */
ret_value = ((char *)new_obj) + sizeof(H5FL_arr_list_t);
#ifdef H5FL_TRACK
/* Copy allocation location information */
((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack();
assert(((H5FL_track_t *)ret_value)->stack);
/* The 'call_func' & 'call_file' strings are statically allocated (by the compiler)
* there's no need to duplicate them.
*/
((H5FL_track_t *)ret_value)->file = call_file;
((H5FL_track_t *)ret_value)->func = call_func;
((H5FL_track_t *)ret_value)->line = call_line;
/* Add to "outstanding allocations" list */
((H5FL_track_t *)ret_value)->prev = NULL;
((H5FL_track_t *)ret_value)->next = H5FL_out_head_g;
if (H5FL_out_head_g)
H5FL_out_head_g->prev = (H5FL_track_t *)ret_value;
H5FL_out_head_g = (H5FL_track_t *)ret_value;
/* Adjust for allocation tracking information */
ret_value = ((unsigned char *)ret_value) + sizeof(H5FL_track_t);
#endif
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_arr_malloc() */
@@ -1548,7 +1327,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS)
H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem)
{
void *ret_value = NULL; /* Pointer to the block to return */
@@ -1559,7 +1338,7 @@ H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS)
assert(elem);
/* Allocate the array */
if (NULL == (ret_value = H5FL_arr_malloc(head, elem H5FL_TRACK_INFO_INT)))
if (NULL == (ret_value = H5FL_arr_malloc(head, elem)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Clear to zeros */
@@ -1580,7 +1359,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS)
H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem)
{
void *ret_value = NULL; /* Pointer to the block to return */
@@ -1592,7 +1371,7 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PA
/* Check if we are really allocating the object */
if (obj == NULL)
ret_value = H5FL_arr_malloc(head, new_elem H5FL_TRACK_INFO_INT);
ret_value = H5FL_arr_malloc(head, new_elem);
else {
H5FL_arr_list_t *temp; /* Temp. ptr to the new free list node allocated */
@@ -1600,15 +1379,14 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PA
assert((int)new_elem <= head->maxelem);
/* Get the pointer to the info header in front of the block to free */
temp =
(H5FL_arr_list_t *)((void *)((unsigned char *)obj - (sizeof(H5FL_arr_list_t) + H5FL_TRACK_SIZE)));
temp = (H5FL_arr_list_t *)((void *)((unsigned char *)obj - sizeof(H5FL_arr_list_t)));
/* Check if the size is really changing */
if (temp->nelem != new_elem) {
size_t blk_size; /* Size of block */
/* Get the new array of objects */
ret_value = H5FL_arr_malloc(head, new_elem H5FL_TRACK_INFO_INT);
ret_value = H5FL_arr_malloc(head, new_elem);
/* Copy the appropriate amount of elements */
blk_size = head->list_arr[MIN(temp->nelem, new_elem)].size;
@@ -1617,35 +1395,8 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PA
/* Free the old block */
H5FL_arr_free(head, obj);
} /* end if */
else {
#ifdef H5FL_TRACK
unsigned char *block_ptr = ((unsigned char *)obj) - sizeof(H5FL_track_t);
H5FL_track_t trk;
H5MM_memcpy(&trk, block_ptr, sizeof(H5FL_track_t));
/* Release previous tracking information */
H5CS_close_stack(trk.stack);
/* The 'func' & 'file' strings are statically allocated (by the compiler)
* and are not allocated, so there's no need to free them.
*/
trk.file = NULL;
trk.func = NULL;
/* Store new tracking information */
trk.stack = H5CS_copy_stack();
assert(trk.stack);
/* The 'call_func' & 'call_file' strings are statically allocated (by the compiler)
* there's no need to duplicate them.
*/
trk.file = call_file;
trk.func = call_func;
trk.line = call_line;
H5MM_memcpy(block_ptr, &trk, sizeof(H5FL_track_t));
#endif
else
ret_value = obj;
}
} /* end else */
FUNC_LEAVE_NOAPI(ret_value)
@@ -1851,7 +1602,7 @@ H5FL_seq_free(H5FL_seq_head_t *head, void *obj)
*-------------------------------------------------------------------------
*/
void *
H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS)
H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem)
{
void *ret_value = NULL; /* Pointer to the block to return */
@@ -1862,7 +1613,7 @@ H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS)
assert(elem);
/* Use block routine */
ret_value = H5FL_blk_malloc(&(head->queue), head->size * elem H5FL_TRACK_INFO_INT);
ret_value = H5FL_blk_malloc(&(head->queue), head->size * elem);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_seq_malloc() */
@@ -1878,7 +1629,7 @@ H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS)
*-------------------------------------------------------------------------
*/
void *
H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS)
H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem)
{
void *ret_value = NULL; /* Pointer to the block to return */
@@ -1889,7 +1640,7 @@ H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS)
assert(elem);
/* Use block routine */
ret_value = H5FL_blk_calloc(&(head->queue), head->size * elem H5FL_TRACK_INFO_INT);
ret_value = H5FL_blk_calloc(&(head->queue), head->size * elem);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_seq_calloc() */
@@ -1905,7 +1656,7 @@ H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS)
*-------------------------------------------------------------------------
*/
void *
H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS)
H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem)
{
void *ret_value = NULL; /* Pointer to the block to return */
@@ -1916,7 +1667,7 @@ H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PA
assert(new_elem);
/* Use block routine */
ret_value = H5FL_blk_realloc(&(head->queue), obj, head->size * new_elem H5FL_TRACK_INFO_INT);
ret_value = H5FL_blk_realloc(&(head->queue), obj, head->size * new_elem);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_seq_realloc() */
@@ -1968,11 +1719,6 @@ H5FL_fac_init(size_t size)
if (factory->size < sizeof(H5FL_fac_node_t))
factory->size = sizeof(H5FL_fac_node_t);
/* Make certain there's room for tracking information, if any */
#ifdef H5FL_TRACK
factory->size += sizeof(H5FL_track_t);
#endif /* H5FL_TRACK */
/* Indicate that the free list is initialized */
factory->init = true;
@@ -2011,32 +1757,6 @@ H5FL_fac_free(H5FL_fac_head_t *head, void *obj)
assert(head);
assert(obj);
#ifdef H5FL_TRACK
{
H5FL_track_t *trk = obj = ((unsigned char *)obj) - sizeof(H5FL_track_t);
/* Free tracking information about the allocation location */
H5CS_close_stack(trk->stack);
/* The 'func' & 'file' strings are statically allocated (by the compiler)
* and are not allocated, so there's no need to free them.
*/
trk->file = NULL;
trk->func = NULL;
/* Remove from "outstanding allocations" list */
if (trk == H5FL_out_head_g) {
H5FL_out_head_g = H5FL_out_head_g->next;
if (H5FL_out_head_g)
H5FL_out_head_g->prev = NULL;
} /* end if */
else {
trk->prev->next = trk->next;
if (trk->next)
trk->next->prev = trk->prev;
} /* end else */
}
#endif /* H5FL_TRACK */
#ifdef H5FL_DEBUG
memset(obj, 255, head->size);
#endif /* H5FL_DEBUG */
@@ -2082,7 +1802,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS)
H5FL_fac_malloc(H5FL_fac_head_t *head)
{
void *ret_value = NULL; /* Pointer to the block to return */
@@ -2116,28 +1836,6 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS)
head->allocated++;
} /* end else */
#ifdef H5FL_TRACK
/* Copy allocation location information */
((H5FL_track_t *)ret_value)->stack = H5CS_copy_stack();
assert(((H5FL_track_t *)ret_value)->stack);
/* The 'call_func' & 'call_file' strings are statically allocated (by the compiler)
* there's no need to duplicate them.
*/
((H5FL_track_t *)ret_value)->file = call_file;
((H5FL_track_t *)ret_value)->func = call_func;
((H5FL_track_t *)ret_value)->line = call_line;
/* Add to "outstanding allocations" list */
((H5FL_track_t *)ret_value)->prev = NULL;
((H5FL_track_t *)ret_value)->next = H5FL_out_head_g;
if (H5FL_out_head_g)
H5FL_out_head_g->prev = (H5FL_track_t *)ret_value;
H5FL_out_head_g = (H5FL_track_t *)ret_value;
/* Adjust for allocation tracking information */
ret_value = ((unsigned char *)ret_value) + sizeof(H5FL_track_t);
#endif /* H5FL_TRACK */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_fac_malloc() */
@@ -2153,7 +1851,7 @@ done:
*-------------------------------------------------------------------------
*/
void *
H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS)
H5FL_fac_calloc(H5FL_fac_head_t *head)
{
void *ret_value = NULL; /* Pointer to the block to return */
@@ -2164,12 +1862,11 @@ H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS)
assert(head);
/* Allocate the block */
if (NULL == (ret_value = H5FL_fac_malloc(head H5FL_TRACK_INFO_INT)))
if (NULL == (ret_value = H5FL_fac_malloc(head)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Clear to zeros */
/* (Accommodate tracking information, if present) */
memset(ret_value, 0, head->size - H5FL_TRACK_SIZE);
memset(ret_value, 0, head->size);
done:
FUNC_LEAVE_NOAPI(ret_value)
+26 -75
View File
@@ -35,52 +35,6 @@
#define H5_NO_FAC_FREE_LISTS
#endif /* H5_NO_FREE_LISTS */
/* Macro to track location where block was allocated from */
/* Uncomment next line to turn on tracking, but don't leave it on after
* debugging is done because of the extra overhead it imposes.
*/
/* NOTE: This hasn't been extended to all the free-list allocation routines
* yet. -QAK
*/
/* #define H5FL_TRACK */
#ifdef H5FL_TRACK
#ifndef H5_HAVE_CODESTACK
#error "Free list tracking requires code stack to be enabled"
#endif
/* Macro for inclusion in the free list allocation calls */
#define H5FL_TRACK_INFO , __FILE__, __func__, __LINE__
/* Macro for inclusion in internal free list allocation calls */
#define H5FL_TRACK_INFO_INT , call_file, call_func, call_line
/* Macro for inclusion in the free list allocation parameters */
#define H5FL_TRACK_PARAMS , const char *call_file, const char *call_func, int call_line
/* Forward declarations for structure fields */
struct H5CS_t;
/* Tracking information for each block */
typedef struct H5FL_track_t {
struct H5CS_t *stack; /* Function stack */
char *file; /* Name of file containing calling function */
char *func; /* Name of calling function */
int line; /* Line # within calling function */
struct H5FL_track_t *next; /* Pointer to next tracking block */
struct H5FL_track_t *prev; /* Pointer to previous tracking block */
} H5FL_track_t;
/* Macro for size of tracking information */
#define H5FL_TRACK_SIZE sizeof(H5FL_track_t)
#else /* H5FL_TRACK */
#define H5FL_TRACK_INFO
#define H5FL_TRACK_INFO_INT
#define H5FL_TRACK_PARAMS
#define H5FL_TRACK_SIZE 0
#endif /* H5FL_TRACK */
/*
* Private datatypes.
*/
@@ -118,10 +72,10 @@ typedef struct H5FL_reg_head_t {
#define H5FL_DEFINE_STATIC(t) static H5FL_DEFINE_COMMON(t)
/* Allocate an object of type 't' */
#define H5FL_MALLOC(t) (t *)H5FL_reg_malloc(&(H5FL_REG_NAME(t))H5FL_TRACK_INFO)
#define H5FL_MALLOC(t) (t *)H5FL_reg_malloc(&(H5FL_REG_NAME(t)))
/* Allocate an object of type 't' and clear it to all zeros */
#define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t))H5FL_TRACK_INFO)
#define H5FL_CALLOC(t) (t *)H5FL_reg_calloc(&(H5FL_REG_NAME(t)))
/* Free an object of type 't' */
#define H5FL_FREE(t, obj) (t *)H5FL_reg_free(&(H5FL_REG_NAME(t)), obj)
@@ -189,17 +143,16 @@ typedef struct H5FL_blk_head_t {
#define H5FL_BLK_DEFINE_STATIC(t) static H5FL_BLK_DEFINE_COMMON(t)
/* Allocate a block of type 't' */
#define H5FL_BLK_MALLOC(t, size) (uint8_t *)H5FL_blk_malloc(&(H5FL_BLK_NAME(t)), size H5FL_TRACK_INFO)
#define H5FL_BLK_MALLOC(t, size) (uint8_t *)H5FL_blk_malloc(&(H5FL_BLK_NAME(t)), (size))
/* Allocate a block of type 't' and clear it to zeros */
#define H5FL_BLK_CALLOC(t, size) (uint8_t *)H5FL_blk_calloc(&(H5FL_BLK_NAME(t)), size H5FL_TRACK_INFO)
#define H5FL_BLK_CALLOC(t, size) (uint8_t *)H5FL_blk_calloc(&(H5FL_BLK_NAME(t)), (size))
/* Free a block of type 't' */
#define H5FL_BLK_FREE(t, blk) (uint8_t *)H5FL_blk_free(&(H5FL_BLK_NAME(t)), blk)
/* Re-allocate a block of type 't' */
#define H5FL_BLK_REALLOC(t, blk, new_size) \
(uint8_t *)H5FL_blk_realloc(&(H5FL_BLK_NAME(t)), blk, new_size H5FL_TRACK_INFO)
#define H5FL_BLK_REALLOC(t, blk, new_size) (uint8_t *)H5FL_blk_realloc(&(H5FL_BLK_NAME(t)), (blk), (new_size))
/* Check if there is a free block available to reuse */
#define H5FL_BLK_AVAIL(t, size) H5FL_blk_free_block_avail(&(H5FL_BLK_NAME(t)), size)
@@ -272,17 +225,16 @@ typedef struct H5FL_arr_head_t {
#define H5FL_BARR_DEFINE_STATIC(b, t, m) static H5FL_ARR_DEFINE_COMMON(sizeof(b), t, m)
/* Allocate an array of type 't' */
#define H5FL_ARR_MALLOC(t, elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)), elem H5FL_TRACK_INFO)
#define H5FL_ARR_MALLOC(t, elem) H5FL_arr_malloc(&(H5FL_ARR_NAME(t)), (elem))
/* Allocate an array of type 't' and clear it to all zeros */
#define H5FL_ARR_CALLOC(t, elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)), elem H5FL_TRACK_INFO)
#define H5FL_ARR_CALLOC(t, elem) H5FL_arr_calloc(&(H5FL_ARR_NAME(t)), (elem))
/* Free an array of type 't' */
#define H5FL_ARR_FREE(t, obj) (t *)H5FL_arr_free(&(H5FL_ARR_NAME(t)), obj)
/* Re-allocate an array of type 't' */
#define H5FL_ARR_REALLOC(t, obj, new_elem) \
H5FL_arr_realloc(&(H5FL_ARR_NAME(t)), obj, new_elem H5FL_TRACK_INFO)
#define H5FL_ARR_REALLOC(t, obj, new_elem) H5FL_arr_realloc(&(H5FL_ARR_NAME(t)), obj, (new_elem))
#else /* H5_NO_ARR_FREE_LISTS */
/* Common macro for H5FL_ARR_DEFINE & H5FL_ARR_DEFINE_STATIC (and H5FL_BARR variants) */
@@ -327,17 +279,16 @@ typedef struct H5FL_seq_head_t {
#define H5FL_SEQ_DEFINE_STATIC(t) static H5FL_SEQ_DEFINE_COMMON(t)
/* Allocate a sequence of type 't' */
#define H5FL_SEQ_MALLOC(t, elem) (t *)H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)), elem H5FL_TRACK_INFO)
#define H5FL_SEQ_MALLOC(t, elem) (t *)H5FL_seq_malloc(&(H5FL_SEQ_NAME(t)), (elem))
/* Allocate a sequence of type 't' and clear it to all zeros */
#define H5FL_SEQ_CALLOC(t, elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)), elem H5FL_TRACK_INFO)
#define H5FL_SEQ_CALLOC(t, elem) (t *)H5FL_seq_calloc(&(H5FL_SEQ_NAME(t)), (elem))
/* Free a sequence of type 't' */
#define H5FL_SEQ_FREE(t, obj) (t *)H5FL_seq_free(&(H5FL_SEQ_NAME(t)), obj)
/* Re-allocate a sequence of type 't' */
#define H5FL_SEQ_REALLOC(t, obj, new_elem) \
(t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)), obj, new_elem H5FL_TRACK_INFO)
#define H5FL_SEQ_REALLOC(t, obj, new_elem) (t *)H5FL_seq_realloc(&(H5FL_SEQ_NAME(t)), obj, (new_elem))
#else /* H5_NO_SEQ_FREE_LISTS */
/* Common macro for H5FL_SEQ_DEFINE & H5FL_SEQ_DEFINE_STATIC */
@@ -375,10 +326,10 @@ typedef struct H5FL_fac_head_t {
*/
#ifndef H5_NO_FAC_FREE_LISTS
/* Allocate a block from a factory */
#define H5FL_FAC_MALLOC(f) H5FL_fac_malloc(f H5FL_TRACK_INFO)
#define H5FL_FAC_MALLOC(f) H5FL_fac_malloc(f)
/* Allocate a block from a factory and clear it to all zeros */
#define H5FL_FAC_CALLOC(f) H5FL_fac_calloc(f H5FL_TRACK_INFO)
#define H5FL_FAC_CALLOC(f) H5FL_fac_calloc(f)
/* Return a block to a factory */
#define H5FL_FAC_FREE(f, obj) H5FL_fac_free(f, obj)
@@ -393,33 +344,33 @@ typedef struct H5FL_fac_head_t {
* Library prototypes.
*/
/* Block free lists */
H5_DLL void *H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size) H5_ATTR_MALLOC;
H5_DLL void *H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size) H5_ATTR_MALLOC;
H5_DLL void *H5FL_blk_free(H5FL_blk_head_t *head, void *block);
H5_DLL void *H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size H5FL_TRACK_PARAMS);
H5_DLL void *H5FL_blk_realloc(H5FL_blk_head_t *head, void *block, size_t new_size);
H5_DLL htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size);
/* Regular free lists */
H5_DLL void *H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_reg_malloc(H5FL_reg_head_t *head) H5_ATTR_MALLOC;
H5_DLL void *H5FL_reg_calloc(H5FL_reg_head_t *head) H5_ATTR_MALLOC;
H5_DLL void *H5FL_reg_free(H5FL_reg_head_t *head, void *obj);
/* Array free lists */
H5_DLL void *H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) H5_ATTR_MALLOC;
H5_DLL void *H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) H5_ATTR_MALLOC;
H5_DLL void *H5FL_arr_free(H5FL_arr_head_t *head, void *obj);
H5_DLL void *H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS);
H5_DLL void *H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem);
/* Sequence free lists */
H5_DLL void *H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem) H5_ATTR_MALLOC;
H5_DLL void *H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem) H5_ATTR_MALLOC;
H5_DLL void *H5FL_seq_free(H5FL_seq_head_t *head, void *obj);
H5_DLL void *H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS);
H5_DLL void *H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem);
/* Factory free lists */
H5_DLL H5FL_fac_head_t *H5FL_fac_init(size_t size);
H5_DLL void *H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) H5_ATTR_MALLOC;
H5_DLL void *H5FL_fac_malloc(H5FL_fac_head_t *head) H5_ATTR_MALLOC;
H5_DLL void *H5FL_fac_calloc(H5FL_fac_head_t *head) H5_ATTR_MALLOC;
H5_DLL void *H5FL_fac_free(H5FL_fac_head_t *head, void *obj);
H5_DLL herr_t H5FL_fac_term(H5FL_fac_head_t *head);
-1
View File
@@ -109,7 +109,6 @@ const char H5build_settings[]=
" Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@\n"
" API tracing: @TRACE_API@\n"
" Using memory checker: @USINGMEMCHECKER@\n"
" Function stack tracing: @CODESTACK@\n"
" Use file locking: @DESIRED_FILE_LOCKING@\n"
" Strict file format checks: @STRICT_FORMAT_CHECKS@\n"
" Optimization instrumentation: @INSTRUMENT_LIBRARY@\n"
-1
View File
@@ -108,7 +108,6 @@ const char H5build_settings[]=
" Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@\n"
" API tracing: @HDF5_ENABLE_TRACE@\n"
" Using memory checker: @HDF5_ENABLE_USING_MEMCHECKER@\n"
" Function stack tracing: @HDF5_ENABLE_CODESTACK@\n"
" Use file locking: @HDF5_FILE_LOCKING_SETTING@\n"
" Strict file format checks: @HDF5_STRICT_FORMAT_CHECKS@\n"
" Optimization instrumentation: @HDF5_Enable_Instrument@\n"
-66
View File
@@ -1197,18 +1197,6 @@ extern bool H5_libterm_g; /* Is the library being shutdown? */
#endif /* H5_HAVE_THREADSAFE */
#ifdef H5_HAVE_CODESTACK
/* Include required function stack header */
#include "H5CSprivate.h"
#define H5_PUSH_FUNC H5CS_push(__func__);
#define H5_POP_FUNC H5CS_pop();
#else /* H5_HAVE_CODESTACK */
#define H5_PUSH_FUNC /* void */
#define H5_POP_FUNC /* void */
#endif /* H5_HAVE_CODESTACK */
/* Forward declaration of H5CXpush() / H5CXpop() */
/* (Including H5CXprivate.h creates bad circular dependencies - QAK, 3/18/2018) */
H5_DLL herr_t H5CX_push(void);
@@ -1261,9 +1249,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
}
#define FUNC_ENTER_API_PUSH(err) \
/* Push the name of this function on the function stack */ \
H5_PUSH_FUNC \
\
/* Push the API context */ \
if (H5_UNLIKELY(H5CX_push() < 0)) \
HGOTO_ERROR(H5E_FUNC, H5E_CANTSET, err, "can't set API context"); \
@@ -1309,7 +1294,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
{ \
{ \
FUNC_ENTER_API_COMMON \
H5_PUSH_FUNC \
{
/*
@@ -1366,14 +1350,12 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
#define FUNC_ENTER_NOAPI(err) \
{ \
FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \
H5_PUSH_FUNC \
{
/* Use this macro for all non-API functions, which propagate errors, but don't issue them */
#define FUNC_ENTER_NOAPI_NOERR \
{ \
FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \
H5_PUSH_FUNC \
{
/*
@@ -1387,7 +1369,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
#define FUNC_ENTER_NOAPI_NOINIT \
{ \
FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \
H5_PUSH_FUNC \
{
/*
@@ -1400,32 +1381,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
* - functions that propagate, but don't issue errors
*/
#define FUNC_ENTER_NOAPI_NOINIT_NOERR \
{ \
FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \
H5_PUSH_FUNC \
{
/*
* Use this macro for non-API functions which fall into these categories:
* - functions which shouldn't push their name on the function stack
* (so far, just the H5CS routines themselves)
*
*/
#define FUNC_ENTER_NOAPI_NOFS \
{ \
FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \
{
/*
* Use this macro for non-API functions which fall into these categories:
* - functions which shouldn't push their name on the function stack
* (so far, just the H5CS routines themselves)
*
* This macro is used for functions which fit the above categories _and_
* also don't use the 'FUNC' variable (i.e. don't push errors on the error stack)
*
*/
#define FUNC_ENTER_NOAPI_NOERR_NOFS \
{ \
FUNC_ENTER_COMMON_NOERR(!H5_IS_API(__func__)); \
{
@@ -1450,7 +1405,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
\
FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \
H5AC_tag(tag, &prev_tag); \
H5_PUSH_FUNC \
{
#define FUNC_ENTER_NOAPI_NOINIT_TAG(tag) \
@@ -1459,21 +1413,18 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
\
FUNC_ENTER_COMMON(!H5_IS_API(__func__)); \
H5AC_tag(tag, &prev_tag); \
H5_PUSH_FUNC \
{
/* Use this macro for all "normal" package-level functions */
#define FUNC_ENTER_PACKAGE \
{ \
FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \
H5_PUSH_FUNC \
{
/* Use this macro for package-level functions which propagate errors, but don't issue them */
#define FUNC_ENTER_PACKAGE_NOERR \
{ \
FUNC_ENTER_COMMON_NOERR(H5_IS_PKG(__func__)); \
H5_PUSH_FUNC \
{
/* Use the following macro as replacement for the FUNC_ENTER_PACKAGE
@@ -1484,7 +1435,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
\
FUNC_ENTER_COMMON(H5_IS_PKG(__func__)); \
H5AC_tag(tag, &prev_tag); \
H5_PUSH_FUNC \
{
/* Use this macro for staticly-scoped functions which propagate errors, but don't issue them */
@@ -1522,7 +1472,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
(void)H5CX_pop(true); \
api_ctx_pushed = false; \
} \
H5_POP_FUNC \
if (H5_UNLIKELY(err_occurred)) \
(void)H5E_dump_api_stack(); \
FUNC_LEAVE_API_THREADSAFE \
@@ -1534,7 +1483,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
#define FUNC_LEAVE_API_NOINIT(ret_value) \
; \
} /*end scope from end of FUNC_ENTER*/ \
H5_POP_FUNC \
if (H5_UNLIKELY(err_occurred)) \
(void)H5E_dump_api_stack(); \
FUNC_LEAVE_API_THREADSAFE \
@@ -1583,28 +1531,15 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
#define FUNC_LEAVE_NOAPI(ret_value) \
; \
} /*end scope from end of FUNC_ENTER*/ \
H5_POP_FUNC \
return (ret_value); \
} /*end scope from beginning of FUNC_ENTER*/
#define FUNC_LEAVE_NOAPI_VOID \
; \
} /*end scope from end of FUNC_ENTER*/ \
H5_POP_FUNC \
return; \
} /*end scope from beginning of FUNC_ENTER*/
/*
* Use this macro for non-API functions which fall into these categories:
* - functions which didn't push their name on the function stack
* (so far, just the H5CS routines themselves)
*/
#define FUNC_LEAVE_NOAPI_NOFS(ret_value) \
; \
} /*end scope from end of FUNC_ENTER*/ \
return (ret_value); \
} /*end scope from beginning of FUNC_ENTER*/
/* Use these macros to match the FUNC_ENTER_NOAPI_NAMECHECK_ONLY macro */
#define FUNC_LEAVE_NOAPI_NAMECHECK_ONLY(ret_value) \
return (ret_value); \
@@ -1618,7 +1553,6 @@ H5_DLL herr_t H5CX_pop(bool update_dxpl_props);
; \
} /*end scope from end of FUNC_ENTER*/ \
H5AC_tag(prev_tag, NULL); \
H5_POP_FUNC \
return (ret_value); \
} /*end scope from beginning of FUNC_ENTER*/
-1
View File
@@ -38,7 +38,6 @@ libhdf5_la_SOURCES= H5.c H5build_settings.c H5checksum.c H5dbg.c H5system.c \
H5C.c H5Cdbg.c H5Centry.c H5Cepoch.c H5Cimage.c H5Cint.c \
H5Clog.c H5Clog_json.c H5Clog_trace.c \
H5Cprefetched.c H5Cquery.c H5Ctag.c H5Ctest.c \
H5CS.c \
H5CX.c \
H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c \
H5Ddbg.c H5Ddeprec.c H5Dearray.c H5Defl.c H5Dfarray.c H5Dfill.c \
-1
View File
@@ -90,7 +90,6 @@ Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@
Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@
API tracing: @TRACE_API@
Using memory checker: @USINGMEMCHECKER@
Function stack tracing: @CODESTACK@
Use file locking: @DESIRED_FILE_LOCKING@
Strict file format checks: @STRICT_FORMAT_CHECKS@
Optimization instrumentation: @INSTRUMENT_LIBRARY@