summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c14
-rw-r--r--src/H5ACprivate.h4
-rw-r--r--src/H5Distore.c2
-rw-r--r--src/H5F.c120
-rw-r--r--src/H5Fdbg.c149
-rw-r--r--src/H5Fistore.c2
-rw-r--r--src/H5Fpkg.h4
-rw-r--r--src/H5Fprivate.h3
-rw-r--r--src/H5HG.c149
-rw-r--r--src/H5HGdbg.c136
-rw-r--r--src/H5HGpkg.h92
-rw-r--r--src/H5HGprivate.h4
-rw-r--r--src/H5HL.c174
-rw-r--r--src/H5HLdbg.c174
-rw-r--r--src/H5HLpkg.h79
-rw-r--r--src/H5HLprivate.h2
16 files changed, 673 insertions, 435 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 41661af..b2de4f6 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -1788,11 +1788,12 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
}
+#ifdef H5AC_DEBUG
/*-------------------------------------------------------------------------
- * Function: H5AC_debug
+ * Function: H5AC_stats
*
- * Purpose: Prints debugging info about the cache.
+ * Purpose: Prints statistics about the cache.
*
* Return: Non-negative on success/Negative on failure
*
@@ -1804,19 +1805,16 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_debug(H5F_t UNUSED *f)
+H5AC_stats(H5F_t UNUSED *f)
{
-#ifdef H5AC_DEBUG
H5AC_subid_t i;
char s[32], ascii[32];
H5AC_t *cache = f->shared->cache;
double miss_rate;
-#endif /* H5AC_DEBUG */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI(H5AC_debug, FAIL);
+ FUNC_ENTER_NOAPI(H5AC_stats, FAIL);
-#ifdef H5AC_DEBUG
if (H5DEBUG(AC)) {
fprintf(H5DEBUG(AC), "H5AC: meta data cache statistics for file %s\n",
f->name);
@@ -1870,9 +1868,9 @@ H5AC_debug(H5F_t UNUSED *f)
(long)(cache->diagnostics[i].ninits)));
}
}
-#endif /* H5AC_DEBUG */
done:
FUNC_LEAVE_NOAPI(ret_value);
}
+#endif /* H5AC_DEBUG */
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index dbe4ec9..0ebdbca 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -146,7 +146,9 @@ H5_DLL herr_t H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, hadd
H5_DLL herr_t H5AC_rename(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type,
haddr_t old_addr, haddr_t new_addr);
H5_DLL herr_t H5AC_dest(H5F_t *f, hid_t dxpl_id);
-H5_DLL herr_t H5AC_debug(H5F_t *f);
+#ifdef H5AC_DEBUG
+H5_DLL herr_t H5AC_stats(H5F_t *f);
+#endif /* H5AC_DEBUG */
#endif /* !_H5ACprivate_H */
diff --git a/src/H5Distore.c b/src/H5Distore.c
index acb871d..c3bda60 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -2959,6 +2959,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
}
+#ifdef H5F_ISTORE_DEBUG
/*-------------------------------------------------------------------------
* Function: H5F_istore_stats
@@ -3023,6 +3024,7 @@ H5F_istore_stats (H5F_t *f, hbool_t headers)
done:
FUNC_LEAVE_NOAPI(ret_value);
}
+#endif /* H5F_ISTORE_DEBUG */
/*-------------------------------------------------------------------------
diff --git a/src/H5F.c b/src/H5F.c
index 23e30d3..6f37aa9 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -3045,8 +3045,12 @@ H5F_close(H5F_t *f)
/* Only flush at this point if the file will be closed */
if (closing) {
/* Dump debugging info */
- H5AC_debug(f);
+#ifdef H5AC_DEBUG
+ H5AC_stats(f);
+#endif /* H5AC_DEBUG */
+#ifdef H5F_ISTORE_DEBUG
H5F_istore_stats(f, FALSE);
+#endif /* H5F_ISTORE_DEBUG */
#ifdef H5_HAVE_FPHDF5
/*
@@ -4198,117 +4202,3 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
} /* H5F_sieve_overlap_clear() */
-
-/*-------------------------------------------------------------------------
- * Function: H5F_debug
- *
- * Purpose: Prints a file header to the specified stream. Each line
- * is indented and the field name occupies the specified width
- * number of characters.
- *
- * Errors:
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
- *
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * Raymond Lu, 2001-10-14
- * Changed to the new generic property list.
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5F_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE * stream, int indent,
- int fwidth)
-{
- hsize_t userblock_size;
- int super_vers, freespace_vers, obj_dir_vers, share_head_vers;
- H5P_genplist_t *plist; /* Property list */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5F_debug, FAIL);
-
- /* check args */
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
-
- /* Get property list */
- if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
-
- if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block size");
- if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, &super_vers)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version");
- if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version");
- if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version");
- if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers)<0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header format version");
-
- /* debug */
- HDfprintf(stream, "%*sFile Super Block...\n", indent, "");
-
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "File name:",
- f->name);
- HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth,
- "File access flags",
- (unsigned) (f->shared->flags));
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "File open reference count:",
- (unsigned) (f->shared->nrefs));
- HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth,
- "Address of super block:", f->shared->boot_addr);
- HDfprintf(stream, "%*s%-*s %lu bytes\n", indent, "", fwidth,
- "Size of user block:", (unsigned long) userblock_size);
-
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Super block version number:", (unsigned) super_vers);
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Free list version number:", (unsigned) freespace_vers);
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Root group symbol table entry version number:", (unsigned) obj_dir_vers);
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Shared header version number:", (unsigned) share_head_vers);
- HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
- "Size of file offsets (haddr_t type):", (unsigned) f->shared->sizeof_addr);
- HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
- "Size of file lengths (hsize_t type):", (unsigned) f->shared->sizeof_size);
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Symbol table leaf node 1/2 rank:", f->shared->sym_leaf_k);
- HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Symbol table internal node 1/2 rank:",
- (unsigned) (f->shared->btree_k[H5B_SNODE_ID]));
- HDfprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
- "File consistency flags:",
- (unsigned long) (f->shared->consist_flags));
- HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth,
- "Base address:", f->shared->base_addr);
- HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth,
- "Free list address:", f->shared->freespace_addr);
-
- HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth,
- "Address of driver information block:", f->shared->driver_addr);
-
- HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Root group symbol table entry:",
- f->shared->root_grp ? "" : "(none)");
- if (f->shared->root_grp) {
- H5G_ent_debug(f, dxpl_id, H5G_entof(f->shared->root_grp), stream,
- indent+3, MAX(0, fwidth-3), HADDR_UNDEF);
- }
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c
new file mode 100644
index 0000000..fec3a46
--- /dev/null
+++ b/src/H5Fdbg.c
@@ -0,0 +1,149 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Wednesday, July 9, 2003
+ *
+ * Purpose: File object debugging functions.
+ */
+
+#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+
+/* Pablo information */
+/* (Put before include files to avoid problems with inline functions) */
+#define PABLO_MASK H5Fdbg_mask
+
+#include "H5private.h" /* Generic Functions */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fpkg.h" /* File access */
+#include "H5Iprivate.h" /* ID Functions */
+#include "H5Pprivate.h" /* Property lists */
+
+/* Interface initialization */
+#define INTERFACE_INIT NULL
+static int interface_initialize_g = 0;
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5F_debug
+ *
+ * Purpose: Prints a file header to the specified stream. Each line
+ * is indented and the field name occupies the specified width
+ * number of characters.
+ *
+ * Errors:
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 1 1997
+ *
+ * Modifications:
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
+ *
+ * Raymond Lu, 2001-10-14
+ * Changed to the new generic property list.
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_debug(H5F_t *f, hid_t dxpl_id, FILE * stream, int indent, int fwidth)
+{
+ hsize_t userblock_size;
+ int super_vers, freespace_vers, obj_dir_vers, share_head_vers;
+ H5P_genplist_t *plist; /* Property list */
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5F_debug, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ /* Get property list */
+ if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+
+ if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block size");
+ if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, &super_vers)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version");
+ if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get super block version");
+ if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version");
+ if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header format version");
+
+ /* debug */
+ HDfprintf(stream, "%*sFile Super Block...\n", indent, "");
+
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "File name:",
+ f->name);
+ HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth,
+ "File access flags",
+ (unsigned) (f->shared->flags));
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "File open reference count:",
+ (unsigned) (f->shared->nrefs));
+ HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth,
+ "Address of super block:", f->shared->boot_addr);
+ HDfprintf(stream, "%*s%-*s %lu bytes\n", indent, "", fwidth,
+ "Size of user block:", (unsigned long) userblock_size);
+
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Super block version number:", (unsigned) super_vers);
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Free list version number:", (unsigned) freespace_vers);
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Root group symbol table entry version number:", (unsigned) obj_dir_vers);
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Shared header version number:", (unsigned) share_head_vers);
+ HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
+ "Size of file offsets (haddr_t type):", (unsigned) f->shared->sizeof_addr);
+ HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
+ "Size of file lengths (hsize_t type):", (unsigned) f->shared->sizeof_size);
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Symbol table leaf node 1/2 rank:", f->shared->sym_leaf_k);
+ HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Symbol table internal node 1/2 rank:",
+ (unsigned) (f->shared->btree_k[H5B_SNODE_ID]));
+ HDfprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
+ "File consistency flags:",
+ (unsigned long) (f->shared->consist_flags));
+ HDfprintf(stream, "%*s%-*s %a (abs)\n", indent, "", fwidth,
+ "Base address:", f->shared->base_addr);
+ HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth,
+ "Free list address:", f->shared->freespace_addr);
+
+ HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth,
+ "Address of driver information block:", f->shared->driver_addr);
+
+ HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Root group symbol table entry:",
+ f->shared->root_grp ? "" : "(none)");
+ if (f->shared->root_grp) {
+ H5G_ent_debug(f, dxpl_id, H5G_entof(f->shared->root_grp), stream,
+ indent+3, MAX(0, fwidth-3), HADDR_UNDEF);
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index acb871d..c3bda60 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -2959,6 +2959,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
}
+#ifdef H5F_ISTORE_DEBUG
/*-------------------------------------------------------------------------
* Function: H5F_istore_stats
@@ -3023,6 +3024,7 @@ H5F_istore_stats (H5F_t *f, hbool_t headers)
done:
FUNC_LEAVE_NOAPI(ret_value);
}
+#endif /* H5F_ISTORE_DEBUG */
/*-------------------------------------------------------------------------
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 2d92ad3..f0f120b 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -195,8 +195,6 @@ H5_DLLVAR hbool_t H5_mpiposix_1_metawrite_g;
H5_DLL void H5F_encode_length_unusual(const H5F_t *f, uint8_t **p, uint8_t *l);
#endif /* NOT_YET */
H5_DLL herr_t H5F_mountpoint(struct H5G_entry_t *find/*in,out*/);
-H5_DLL herr_t H5F_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream,
- int indent, int fwidth);
H5_DLL herr_t H5F_sieve_overlap_clear(H5F_t *f, haddr_t addr, hsize_t size);
/* Functions that operate on indexed storage */
@@ -213,7 +211,9 @@ H5_DLL ssize_t H5F_istore_writevv(H5F_t *f, hid_t dxpl_id,
size_t chunk_max_nseq, size_t *chunk_curr_seq, size_t chunk_len_arr[], hsize_t chunk_offset_arr[],
size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_offset_arr[],
const void *buf);
+#ifdef H5F_ISTORE_DEBUG
H5_DLL herr_t H5F_istore_stats (H5F_t *f, hbool_t headers);
+#endif /* H5F_ISTORE_DEBUG */
H5_DLL herr_t H5F_istore_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream,
int indent, int fwidth, int ndims);
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index fb5d8ca..945a35d 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -470,4 +470,7 @@ H5_DLL herr_t H5F_acs_close(hid_t fapl_id, void *close_data);
H5_DLL herr_t H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id,
void *close_data);
+/* Debugging functions */
+H5_DLL herr_t H5F_debug(H5F_t *f, hid_t dxpl_id, FILE * stream, int indent, int fwidth);
+
#endif
diff --git a/src/H5HG.c b/src/H5HG.c
index 7f6f59f..57a3320 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -37,19 +37,21 @@
*/
#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+#define H5HG_PACKAGE /*suppress error about including H5HGpkg */
+
+/* Pablo information */
+/* (Put before include files to avoid problems with inline functions) */
+#define PABLO_MASK H5HG_mask
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
#include "H5FLprivate.h" /* Free lists */
-#include "H5HGprivate.h" /* Global heaps */
+#include "H5HGpkg.h" /* Global heaps */
#include "H5MFprivate.h" /* File memory management */
#include "H5MMprivate.h" /* Memory management */
-/* Pablo information */
-#define PABLO_MASK H5HG_mask
-
/* Private macros */
/*
@@ -58,17 +60,6 @@
#define H5HG_VERSION 1
/*
- * Pad all global heap messages to a multiple of eight bytes so we can load
- * the entire collection into memory and operate on it there. Eight should
- * be sufficient for machines that have alignment constraints because our
- * largest data type is eight bytes.
- */
-#define H5HG_ALIGNMENT 8
-#define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/ \
- H5HG_ALIGNMENT))
-#define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X))
-
-/*
* All global heap collections are at least this big. This allows us to read
* most collections with a single read() since we don't have to read a few
* bytes of header to figure out the size. If the heap is larger than this
@@ -98,16 +89,6 @@
H5F_SIZEOF_SIZE(f)) /*collection size */
/*
- * The overhead associated with each object in the heap, always a multiple of
- * the alignment so that the stuff that follows the header is aligned.
- */
-#define H5HG_SIZEOF_OBJHDR(f) \
- H5HG_ALIGN(2 + /*object id number */ \
- 2 + /*reference count */ \
- 4 + /*reserved */ \
- H5F_SIZEOF_SIZE(f)) /*object data size */
-
-/*
* The initial guess for the number of messages in a collection. We assume
* that all objects in that collection are zero length, giving the maximum
* possible number of objects in the collection. The collection itself has
@@ -126,22 +107,6 @@
/* Private typedefs */
-typedef struct H5HG_obj_t {
- int nrefs; /*reference count */
- size_t size; /*total size of object */
- uint8_t *begin; /*ptr to object into heap->chunk*/
-} H5HG_obj_t;
-
-struct H5HG_heap_t {
- H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
- /* first field in structure */
- haddr_t addr; /*collection address */
- size_t size; /*total size of collection */
- uint8_t *chunk; /*the collection, incl. header */
- size_t nalloc; /*numb object slots allocated */
- H5HG_obj_t *obj; /*array of object descriptions */
-};
-
/* PRIVATE PROTOTYPES */
static H5HG_heap_t *H5HG_create(H5F_t *f, hid_t dxpl_id, size_t size);
#ifdef NOT_YET
@@ -159,7 +124,7 @@ static herr_t H5HG_clear(H5HG_heap_t *heap);
/*
* H5HG inherits cache-like properties from H5AC
*/
-static const H5AC_class_t H5AC_GHEAP[1] = {{
+const H5AC_class_t H5AC_GHEAP[1] = {{
H5AC_GHEAP_ID,
(H5AC_load_func_t)H5HG_load,
(H5AC_flush_func_t)H5HG_flush,
@@ -1045,103 +1010,3 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
}
-
-/*-------------------------------------------------------------------------
- * Function: H5HG_debug
- *
- * Purpose: Prints debugging information about a global heap collection.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Mar 27, 1998
- *
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *
- * Robb Matzke, LLNL, 2003-06-05
- * The size does not include the object header, just the data.
- *-------------------------------------------------------------------------
- */
-herr_t
-H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
- int fwidth)
-{
- unsigned u, nused, maxobj;
- unsigned j, k;
- H5HG_heap_t *h = NULL;
- char buf[64];
- uint8_t *p = NULL;
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5HG_debug, FAIL);
-
- /* check arguments */
- assert(f);
- assert(H5F_addr_defined (addr));
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
-
- if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection");
- fprintf(stream, "%*sGlobal Heap Collection...\n", indent, "");
- fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Dirty:",
- (int)(h->cache_info.dirty));
- fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Total collection size in file:",
- (unsigned long)(h->size));
-
- for (u=1, nused=0, maxobj=0; u<h->nalloc; u++) {
- if (h->obj[u].begin) {
- nused++;
- if (u>maxobj) maxobj = u;
- }
- }
- fprintf (stream, "%*s%-*s %u/%lu/", indent, "", fwidth,
- "Objects defined/allocated/max:",
- nused, (unsigned long)h->nalloc);
- fprintf (stream, nused ? "%u\n": "NA\n", maxobj);
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Free space:",
- (unsigned long)(h->obj[0].size));
-
- for (u=1; u<h->nalloc; u++) {
- if (h->obj[u].begin) {
- sprintf (buf, "Object %u", u);
- fprintf (stream, "%*s%s\n", indent, "", buf);
- fprintf (stream, "%*s%-*s %d\n", indent+3, "", MIN(fwidth-3, 0),
- "Reference count:",
- h->obj[u].nrefs);
- fprintf (stream, "%*s%-*s %lu/%lu\n", indent+3, "",
- MIN(fwidth-3, 0),
- "Size of object body:",
- (unsigned long)(h->obj[u].size),
- (unsigned long)H5HG_ALIGN(h->obj[u].size));
- p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR (f);
- for (j=0; j<h->obj[u].size; j+=16) {
- fprintf (stream, "%*s%04d: ", indent+6, "", j);
- for (k=0; k<16; k++) {
- if (8==k) fprintf (stream, " ");
- if (j+k<h->obj[u].size) {
- fprintf (stream, "%02x ", p[j+k]);
- } else {
- HDfputs(" ", stream);
- }
- }
- for (k=0; k<16 && j+k<h->obj[u].size; k++) {
- if (8==k) fprintf (stream, " ");
- HDfputc(p[j+k]>' ' && p[j+k]<='~' ? p[j+k] : '.', stream);
- }
- fprintf (stream, "\n");
- }
- }
- }
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c
new file mode 100644
index 0000000..128ba93
--- /dev/null
+++ b/src/H5HGdbg.c
@@ -0,0 +1,136 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Wednesday, July 9, 2003
+ *
+ * Purpose: Global Heap object debugging functions.
+ */
+#define H5HG_PACKAGE /*suppress error about including H5HGpkg */
+
+/* Pablo information */
+/* (Put before include files to avoid problems with inline functions) */
+#define PABLO_MASK H5HGdbg_mask
+
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HGpkg.h" /* Global heaps */
+#include "H5Iprivate.h" /* ID Functions */
+
+/* Interface initialization */
+#define INTERFACE_INIT NULL
+static int interface_initialize_g = 0;
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HG_debug
+ *
+ * Purpose: Prints debugging information about a global heap collection.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Mar 27, 1998
+ *
+ * Modifications:
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
+ *
+ * Robb Matzke, LLNL, 2003-06-05
+ * The size does not include the object header, just the data.
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
+ int fwidth)
+{
+ unsigned u, nused, maxobj;
+ unsigned j, k;
+ H5HG_heap_t *h = NULL;
+ char buf[64];
+ uint8_t *p = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5HG_debug, FAIL);
+
+ /* check arguments */
+ assert(f);
+ assert(H5F_addr_defined (addr));
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection");
+ fprintf(stream, "%*sGlobal Heap Collection...\n", indent, "");
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Dirty:",
+ (int)(h->cache_info.dirty));
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Total collection size in file:",
+ (unsigned long)(h->size));
+
+ for (u=1, nused=0, maxobj=0; u<h->nalloc; u++) {
+ if (h->obj[u].begin) {
+ nused++;
+ if (u>maxobj) maxobj = u;
+ }
+ }
+ fprintf (stream, "%*s%-*s %u/%lu/", indent, "", fwidth,
+ "Objects defined/allocated/max:",
+ nused, (unsigned long)h->nalloc);
+ fprintf (stream, nused ? "%u\n": "NA\n", maxobj);
+
+ fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Free space:",
+ (unsigned long)(h->obj[0].size));
+
+ for (u=1; u<h->nalloc; u++) {
+ if (h->obj[u].begin) {
+ sprintf (buf, "Object %u", u);
+ fprintf (stream, "%*s%s\n", indent, "", buf);
+ fprintf (stream, "%*s%-*s %d\n", indent+3, "", MIN(fwidth-3, 0),
+ "Reference count:",
+ h->obj[u].nrefs);
+ fprintf (stream, "%*s%-*s %lu/%lu\n", indent+3, "",
+ MIN(fwidth-3, 0),
+ "Size of object body:",
+ (unsigned long)(h->obj[u].size),
+ (unsigned long)H5HG_ALIGN(h->obj[u].size));
+ p = h->obj[u].begin + H5HG_SIZEOF_OBJHDR (f);
+ for (j=0; j<h->obj[u].size; j+=16) {
+ fprintf (stream, "%*s%04d: ", indent+6, "", j);
+ for (k=0; k<16; k++) {
+ if (8==k) fprintf (stream, " ");
+ if (j+k<h->obj[u].size) {
+ fprintf (stream, "%02x ", p[j+k]);
+ } else {
+ HDfputs(" ", stream);
+ }
+ }
+ for (k=0; k<16 && j+k<h->obj[u].size; k++) {
+ if (8==k) fprintf (stream, " ");
+ HDfputc(p[j+k]>' ' && p[j+k]<='~' ? p[j+k] : '.', stream);
+ }
+ fprintf (stream, "\n");
+ }
+ }
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h
new file mode 100644
index 0000000..ee029c4
--- /dev/null
+++ b/src/H5HGpkg.h
@@ -0,0 +1,92 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Wednesday, July 9, 2003
+ *
+ * Purpose: This file contains declarations which are visible
+ * only within the H5HG package. Source files outside the
+ * H5HG package should include H5HGprivate.h instead.
+ */
+#ifndef H5HG_PACKAGE
+#error "Do not include this file outside the H5HG package!"
+#endif
+
+#ifndef _H5HGpkg_H
+#define _H5HGpkg_H
+
+/* Get package's private header */
+#include "H5HGprivate.h"
+
+/* Other private headers needed by this file */
+
+/*****************************/
+/* Package Private Variables */
+/*****************************/
+
+/* The cache subclass */
+H5_DLLVAR const H5AC_class_t H5AC_GHEAP[1];
+
+/**************************/
+/* Package Private Macros */
+/**************************/
+
+/*
+ * Pad all global heap messages to a multiple of eight bytes so we can load
+ * the entire collection into memory and operate on it there. Eight should
+ * be sufficient for machines that have alignment constraints because our
+ * largest data type is eight bytes.
+ */
+#define H5HG_ALIGNMENT 8
+#define H5HG_ALIGN(X) (H5HG_ALIGNMENT*(((X)+H5HG_ALIGNMENT-1)/ \
+ H5HG_ALIGNMENT))
+#define H5HG_ISALIGNED(X) ((X)==H5HG_ALIGN(X))
+
+/*
+ * The overhead associated with each object in the heap, always a multiple of
+ * the alignment so that the stuff that follows the header is aligned.
+ */
+#define H5HG_SIZEOF_OBJHDR(f) \
+ H5HG_ALIGN(2 + /*object id number */ \
+ 2 + /*reference count */ \
+ 4 + /*reserved */ \
+ H5F_SIZEOF_SIZE(f)) /*object data size */
+
+/****************************/
+/* Package Private Typedefs */
+/****************************/
+
+typedef struct H5HG_obj_t {
+ int nrefs; /*reference count */
+ size_t size; /*total size of object */
+ uint8_t *begin; /*ptr to object into heap->chunk*/
+} H5HG_obj_t;
+
+struct H5HG_heap_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
+ haddr_t addr; /*collection address */
+ size_t size; /*total size of collection */
+ uint8_t *chunk; /*the collection, incl. header */
+ size_t nalloc; /*numb object slots allocated */
+ H5HG_obj_t *obj; /*array of object descriptions */
+};
+
+/******************************/
+/* Package Private Prototypes */
+/******************************/
+
+#endif
+
diff --git a/src/H5HGprivate.h b/src/H5HGprivate.h
index 4915c13..8e589e1 100644
--- a/src/H5HGprivate.h
+++ b/src/H5HGprivate.h
@@ -37,7 +37,7 @@ typedef struct H5HG_t {
unsigned idx; /*object ID within collection */
} H5HG_t;
-/* Typedef for heap in memory (defined in H5HG.c) */
+/* Typedef for heap in memory (defined in H5HGpkg.h) */
typedef struct H5HG_heap_t H5HG_heap_t;
H5_DLL herr_t H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj,
@@ -45,6 +45,8 @@ H5_DLL herr_t H5HG_insert(H5F_t *f, hid_t dxpl_id, size_t size, void *obj,
H5_DLL void *H5HG_read(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object);
H5_DLL int H5HG_link(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, int adjust);
H5_DLL herr_t H5HG_remove(H5F_t *f, hid_t dxpl_id, H5HG_t *hobj);
+
+/* Debugging functions */
H5_DLL herr_t H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
int fwidth);
diff --git a/src/H5HL.c b/src/H5HL.c
index 98e2323..4400e10 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -28,47 +28,26 @@
*
*-------------------------------------------------------------------------
*/
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+#define H5F_PACKAGE /* Suppress error about including H5Fpkg */
+#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */
+
+/* Pablo information */
+/* (Put before include files to avoid problems with inline functions) */
+#define PABLO_MASK H5HL_mask
#include "H5private.h" /* Generic Functions */
#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
#include "H5FLprivate.h" /* Free lists */
-#include "H5HLprivate.h" /* Local Heaps */
+#include "H5HLpkg.h" /* Local Heaps */
#include "H5MFprivate.h" /* File memory management */
-#include "H5MMprivate.h" /* Memory management */
-
-/* Pablo information */
-#define PABLO_MASK H5HL_mask
/* Private macros */
#define H5HL_FREE_NULL 1 /*end of free list on disk */
#define H5HL_MIN_HEAP 256 /* Minimum size to reduce heap buffer to */
-#define H5HL_SIZEOF_HDR(F) \
- H5HL_ALIGN(H5HL_SIZEOF_MAGIC + /*heap signature */ \
- 4 + /*reserved */ \
- H5F_SIZEOF_SIZE (F) + /*data size */ \
- H5F_SIZEOF_SIZE (F) + /*free list head */ \
- H5F_SIZEOF_ADDR (F)) /*data address */
/* Private typedefs */
-typedef struct H5HL_free_t {
- size_t offset; /*offset of free block */
- size_t size; /*size of free block */
- struct H5HL_free_t *prev; /*previous entry in free list */
- struct H5HL_free_t *next; /*next entry in free list */
-} H5HL_free_t;
-
-typedef struct H5HL_t {
- H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
- /* first field in structure */
- haddr_t addr; /*address of data */
- size_t disk_alloc; /*data bytes allocated on disk */
- size_t mem_alloc; /*data bytes allocated in mem */
- uint8_t *chunk; /*the chunk, including header */
- H5HL_free_t *freelist; /*the free list */
-} H5HL_t;
/* PRIVATE PROTOTYPES */
#ifdef NOT_YET
@@ -89,7 +68,7 @@ static herr_t H5HL_clear(H5HL_t *heap);
/*
* H5HL inherits cache-like properties from H5AC
*/
-static const H5AC_class_t H5AC_LHEAP[1] = {{
+const H5AC_class_t H5AC_LHEAP[1] = {{
H5AC_LHEAP_ID,
(H5AC_load_func_t)H5HL_load,
(H5AC_flush_func_t)H5HL_flush,
@@ -1158,140 +1137,3 @@ done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5HL_delete() */
-
-/*-------------------------------------------------------------------------
- * Function: H5HL_debug
- *
- * Purpose: Prints debugging information about a heap.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
- *
- * Modifications:
- * Robb Matzke, 1999-07-28
- * The ADDR argument is passed by value.
- *-------------------------------------------------------------------------
- */
-herr_t
-H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth)
-{
- H5HL_t *h = NULL;
- int i, j, overlap, free_block;
- uint8_t c;
- H5HL_free_t *freelist = NULL;
- uint8_t *marker = NULL;
- size_t amount_free = 0;
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(H5HL_debug, FAIL);
-
- /* check arguments */
- assert(f);
- assert(H5F_addr_defined(addr));
- assert(stream);
- assert(indent >= 0);
- assert(fwidth >= 0);
-
- if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
- fprintf(stream, "%*sLocal Heap...\n", indent, "");
- fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Dirty:",
- (int) (h->cache_info.dirty));
- fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Header size (in bytes):",
- (unsigned long) H5HL_SIZEOF_HDR(f));
- HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
- "Address of heap data:",
- h->addr);
- HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
- "Data bytes allocated on disk:",
- h->disk_alloc);
- HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
- "Data bytes allocated in core:",
- h->mem_alloc);
-
- /*
- * Traverse the free list and check that all free blocks fall within
- * the heap and that no two free blocks point to the same region of
- * the heap.
- */
- if (NULL==(marker = H5MM_calloc(h->mem_alloc)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- fprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
- for (free_block=0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) {
- char temp_str[32];
-
- sprintf(temp_str,"Block #%d:",free_block);
- HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent+3, "", MAX(0,fwidth-9),
- temp_str,
- freelist->offset, freelist->size);
- if (freelist->offset + freelist->size > h->mem_alloc) {
- fprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n");
- } else {
- for (i=overlap=0; i<(int)(freelist->size); i++) {
- if (marker[freelist->offset + i])
- overlap++;
- marker[freelist->offset + i] = 1;
- }
- if (overlap) {
- fprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS "
- "ONE!\n");
- } else {
- amount_free += freelist->size;
- }
- }
- }
-
- if (h->mem_alloc) {
- fprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth,
- "Percent of heap used:",
- (100.0 * (double)(h->mem_alloc - amount_free) / (double)h->mem_alloc));
- }
- /*
- * Print the data in a VMS-style octal dump.
- */
- fprintf(stream, "%*sData follows (`__' indicates free region)...\n",
- indent, "");
- for (i=0; i<(int)(h->disk_alloc); i+=16) {
- fprintf(stream, "%*s %8d: ", indent, "", i);
- for (j = 0; j < 16; j++) {
- if (i+j<(int)(h->disk_alloc)) {
- if (marker[i + j]) {
- fprintf(stream, "__ ");
- } else {
- c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j];
- fprintf(stream, "%02x ", c);
- }
- } else {
- fprintf(stream, " ");
- }
- if (7 == j)
- HDfputc(' ', stream);
- }
-
- for (j = 0; j < 16; j++) {
- if (i+j < (int)(h->disk_alloc)) {
- if (marker[i + j]) {
- HDfputc(' ', stream);
- } else {
- c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j];
- if (c > ' ' && c < '~')
- HDfputc(c, stream);
- else
- HDfputc('.', stream);
- }
- }
- }
-
- HDfputc('\n', stream);
- }
-
- H5MM_xfree(marker);
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c
new file mode 100644
index 0000000..2e0be37
--- /dev/null
+++ b/src/H5HLdbg.c
@@ -0,0 +1,174 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Wednesday, July 9, 2003
+ *
+ * Purpose: Local Heap object debugging functions.
+ */
+#define H5HL_PACKAGE /* Suppress error about including H5HLpkg */
+
+/* Pablo information */
+/* (Put before include files to avoid problems with inline functions) */
+#define PABLO_MASK H5HLdbg_mask
+
+#include "H5private.h" /* Generic Functions */
+#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5HLpkg.h" /* Local heaps */
+#include "H5Iprivate.h" /* ID Functions */
+#include "H5MMprivate.h" /* Memory management */
+
+/* Interface initialization */
+#define INTERFACE_INIT NULL
+static int interface_initialize_g = 0;
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5HL_debug
+ *
+ * Purpose: Prints debugging information about a heap.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 1 1997
+ *
+ * Modifications:
+ * Robb Matzke, 1999-07-28
+ * The ADDR argument is passed by value.
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int fwidth)
+{
+ H5HL_t *h = NULL;
+ int i, j, overlap, free_block;
+ uint8_t c;
+ H5HL_free_t *freelist = NULL;
+ uint8_t *marker = NULL;
+ size_t amount_free = 0;
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5HL_debug, FAIL);
+
+ /* check arguments */
+ assert(f);
+ assert(H5F_addr_defined(addr));
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
+ fprintf(stream, "%*sLocal Heap...\n", indent, "");
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Dirty:",
+ (int) (h->cache_info.dirty));
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Header size (in bytes):",
+ (unsigned long) H5HL_SIZEOF_HDR(f));
+ HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
+ "Address of heap data:",
+ h->addr);
+ HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
+ "Data bytes allocated on disk:",
+ h->disk_alloc);
+ HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
+ "Data bytes allocated in core:",
+ h->mem_alloc);
+
+ /*
+ * Traverse the free list and check that all free blocks fall within
+ * the heap and that no two free blocks point to the same region of
+ * the heap.
+ */
+ if (NULL==(marker = H5MM_calloc(h->mem_alloc)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ fprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
+ for (free_block=0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) {
+ char temp_str[32];
+
+ sprintf(temp_str,"Block #%d:",free_block);
+ HDfprintf(stream, "%*s%-*s %8Zu, %8Zu\n", indent+3, "", MAX(0,fwidth-9),
+ temp_str,
+ freelist->offset, freelist->size);
+ if (freelist->offset + freelist->size > h->mem_alloc) {
+ fprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n");
+ } else {
+ for (i=overlap=0; i<(int)(freelist->size); i++) {
+ if (marker[freelist->offset + i])
+ overlap++;
+ marker[freelist->offset + i] = 1;
+ }
+ if (overlap) {
+ fprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS "
+ "ONE!\n");
+ } else {
+ amount_free += freelist->size;
+ }
+ }
+ }
+
+ if (h->mem_alloc) {
+ fprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth,
+ "Percent of heap used:",
+ (100.0 * (double)(h->mem_alloc - amount_free) / (double)h->mem_alloc));
+ }
+ /*
+ * Print the data in a VMS-style octal dump.
+ */
+ fprintf(stream, "%*sData follows (`__' indicates free region)...\n",
+ indent, "");
+ for (i=0; i<(int)(h->disk_alloc); i+=16) {
+ fprintf(stream, "%*s %8d: ", indent, "", i);
+ for (j = 0; j < 16; j++) {
+ if (i+j<(int)(h->disk_alloc)) {
+ if (marker[i + j]) {
+ fprintf(stream, "__ ");
+ } else {
+ c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j];
+ fprintf(stream, "%02x ", c);
+ }
+ } else {
+ fprintf(stream, " ");
+ }
+ if (7 == j)
+ HDfputc(' ', stream);
+ }
+
+ for (j = 0; j < 16; j++) {
+ if (i+j < (int)(h->disk_alloc)) {
+ if (marker[i + j]) {
+ HDfputc(' ', stream);
+ } else {
+ c = h->chunk[H5HL_SIZEOF_HDR(f) + i + j];
+ if (c > ' ' && c < '~')
+ HDfputc(c, stream);
+ else
+ HDfputc('.', stream);
+ }
+ }
+ }
+
+ HDfputc('\n', stream);
+ }
+
+ H5MM_xfree(marker);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
diff --git a/src/H5HLpkg.h b/src/H5HLpkg.h
new file mode 100644
index 0000000..0b52c5f
--- /dev/null
+++ b/src/H5HLpkg.h
@@ -0,0 +1,79 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * 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 files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Programmer: Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Wednesday, July 9, 2003
+ *
+ * Purpose: This file contains declarations which are visible
+ * only within the H5HL package. Source files outside the
+ * H5HL package should include H5HLprivate.h instead.
+ */
+#ifndef H5HL_PACKAGE
+#error "Do not include this file outside the H5HL package!"
+#endif
+
+#ifndef _H5HLpkg_H
+#define _H5HLpkg_H
+
+/* Get package's private header */
+#include "H5HLprivate.h"
+
+/* Other private headers needed by this file */
+
+/*****************************/
+/* Package Private Variables */
+/*****************************/
+
+/* The cache subclass */
+H5_DLLVAR const H5AC_class_t H5AC_LHEAP[1];
+
+/**************************/
+/* Package Private Macros */
+/**************************/
+
+#define H5HL_SIZEOF_HDR(F) \
+ H5HL_ALIGN(H5HL_SIZEOF_MAGIC + /*heap signature */ \
+ 4 + /*reserved */ \
+ H5F_SIZEOF_SIZE (F) + /*data size */ \
+ H5F_SIZEOF_SIZE (F) + /*free list head */ \
+ H5F_SIZEOF_ADDR (F)) /*data address */
+
+/****************************/
+/* Package Private Typedefs */
+/****************************/
+
+typedef struct H5HL_free_t {
+ size_t offset; /*offset of free block */
+ size_t size; /*size of free block */
+ struct H5HL_free_t *prev; /*previous entry in free list */
+ struct H5HL_free_t *next; /*next entry in free list */
+} H5HL_free_t;
+
+typedef struct H5HL_t {
+ H5AC_info_t cache_info; /* Information for H5AC cache functions, _must_ be */
+ /* first field in structure */
+ haddr_t addr; /*address of data */
+ size_t disk_alloc; /*data bytes allocated on disk */
+ size_t mem_alloc; /*data bytes allocated in mem */
+ uint8_t *chunk; /*the chunk, including header */
+ H5HL_free_t *freelist; /*the free list */
+} H5HL_t;
+/******************************/
+/* Package Private Prototypes */
+/******************************/
+
+#endif
+
+
diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h
index aa2a2d4..9c2e64b 100644
--- a/src/H5HLprivate.h
+++ b/src/H5HLprivate.h
@@ -60,6 +60,8 @@ H5_DLL size_t H5HL_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size,
const void *buf);
H5_DLL herr_t H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size);
H5_DLL herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr);
+
+/* Debugging functions */
H5_DLL herr_t H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
int fwidth);
#endif