summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2010-08-25 16:17:38 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2010-08-25 16:17:38 (GMT)
commitabb9cc9cd8834024a7a46cf3438585aad1af09f5 (patch)
treef56c37498104f703db07337a3fa4975553b8cae6 /src
parent8b07a4a214c0fc8c5d6e3a859f32ee5127cdf473 (diff)
downloadhdf5-abb9cc9cd8834024a7a46cf3438585aad1af09f5.zip
hdf5-abb9cc9cd8834024a7a46cf3438585aad1af09f5.tar.gz
hdf5-abb9cc9cd8834024a7a46cf3438585aad1af09f5.tar.bz2
[svn-r19296] 1) Modifications to h5debug and related coding so that it will handle Fixed Array/Extensible Array meta data.
2) Moved Extensible/Fixed array type to be right after MAGIC # and version so that h5debug can determine the array class type.
Diffstat (limited to 'src')
-rw-r--r--src/H5Dearray.c125
-rw-r--r--src/H5EAcache.c61
-rw-r--r--src/H5EAdbg.c91
-rw-r--r--src/H5EApkg.h19
-rw-r--r--src/H5EAprivate.h3
-rw-r--r--src/H5EAtest.c77
-rw-r--r--src/H5FAcache.c20
-rw-r--r--src/H5FApkg.h11
8 files changed, 326 insertions, 81 deletions
diff --git a/src/H5Dearray.c b/src/H5Dearray.c
index 553887e..7a0277c 100644
--- a/src/H5Dearray.c
+++ b/src/H5Dearray.c
@@ -89,12 +89,11 @@ typedef struct H5D_earray_filt_elmt_t {
static void *H5D_earray_crt_context(void *udata);
static herr_t H5D_earray_dst_context(void *ctx);
static herr_t H5D_earray_fill(void *nat_blk, size_t nelmts);
-static herr_t H5D_earray_encode(void *raw, const void *elmt, size_t nelmts,
- void *ctx);
-static herr_t H5D_earray_decode(const void *raw, void *elmt, size_t nelmts,
- void *ctx);
-static herr_t H5D_earray_debug(FILE *stream, int indent, int fwidth,
- hsize_t idx, const void *elmt);
+static herr_t H5D_earray_encode(void *raw, const void *elmt, size_t nelmts, void *ctx);
+static herr_t H5D_earray_decode(const void *raw, void *elmt, size_t nelmts, void *ctx);
+static herr_t H5D_earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt);
+static void *H5D_earray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr);
+static herr_t H5D_earray_dst_dbg_context(void *dbg_ctx);
/* Extensible array class callbacks for chunks w/filters */
/* (some shared with callbacks for chunks w/o filters) */
@@ -176,29 +175,37 @@ const H5D_chunk_ops_t H5D_COPS_EARRAY[1] = {{
/* Extensible array class callbacks for dataset chunks w/o filters */
const H5EA_class_t H5EA_CLS_CHUNK[1]={{
H5EA_CLS_CHUNK_ID, /* Type of extensible array */
+ "Chunk w/o filters", /* Name of extensible array class */
sizeof(haddr_t), /* Size of native element */
H5D_earray_crt_context, /* Create context */
H5D_earray_dst_context, /* Destroy context */
H5D_earray_fill, /* Fill block of missing elements callback */
H5D_earray_encode, /* Element encoding callback */
H5D_earray_decode, /* Element decoding callback */
- H5D_earray_debug /* Element debugging callback */
+ H5D_earray_debug, /* Element debugging callback */
+ H5D_earray_crt_dbg_context, /* Create debugging context */
+ H5D_earray_dst_dbg_context /* Destroy debugging context */
}};
/* Extensible array class callbacks for dataset chunks w/filters */
const H5EA_class_t H5EA_CLS_FILT_CHUNK[1]={{
H5EA_CLS_FILT_CHUNK_ID, /* Type of extensible array */
+ "Chunk w/filters", /* Name of extensible array class */
sizeof(H5D_earray_filt_elmt_t), /* Size of native element */
H5D_earray_crt_context, /* Create context */
H5D_earray_dst_context, /* Destroy context */
H5D_earray_filt_fill, /* Fill block of missing elements callback */
H5D_earray_filt_encode, /* Element encoding callback */
H5D_earray_filt_decode, /* Element decoding callback */
- H5D_earray_filt_debug /* Element debugging callback */
+ H5D_earray_filt_debug, /* Element debugging callback */
+ H5D_earray_crt_dbg_context, /* Create debugging context */
+ H5D_earray_dst_dbg_context /* Destroy debugging context */
}};
/* Declare a free list to manage the H5D_earray_ctx_t struct */
+/* Declare a free list to manage the H5D_earray_ctx_ud_t struct */
H5FL_DEFINE_STATIC(H5D_earray_ctx_t);
+H5FL_DEFINE_STATIC(H5D_earray_ctx_ud_t);
@@ -434,6 +441,108 @@ H5D_earray_debug(FILE *stream, int indent, int fwidth, hsize_t idx,
/*-------------------------------------------------------------------------
+ * Function: H5D_earray_crt_dbg_context
+ *
+ * Purpose: Create context for debugging callback
+ * (get the layout message in the specified object header)
+ *
+ * Return: Success: non-NULL
+ * Failure: NULL
+ *
+ * Programmer: Vailin Choi; July 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+static void *
+H5D_earray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr)
+{
+ H5D_earray_ctx_ud_t *dbg_ctx = NULL; /* Context for fixed array callback */
+ H5O_loc_t obj_loc; /* Pointer to an object's location */
+ hbool_t obj_opened = FALSE; /* Flag to indicate that the object header was opened */
+ H5O_layout_t layout; /* Layout message */
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5D_earray_crt_dbg_context)
+
+ HDassert(f);
+ HDassert(H5F_addr_defined(obj_addr));
+
+ /* Allocate context for debugging callback */
+ if(NULL == (dbg_ctx = H5FL_MALLOC(H5D_earray_ctx_ud_t)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, NULL, "can't allocate extensible array client callback context")
+
+ /* Set up the object header location info */
+ H5O_loc_reset(&obj_loc);
+ obj_loc.file = f;
+ obj_loc.addr = obj_addr;
+
+ /* Open the object header where the layout message resides */
+ if(H5O_open(&obj_loc) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "can't open object header")
+ obj_opened = TRUE;
+
+ /* Read the layout message */
+ if(NULL == H5O_msg_read(&obj_loc, H5O_LAYOUT_ID, &layout, dxpl_id))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info")
+
+ /* close the object header */
+ if(H5O_close(&obj_loc) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header")
+
+ /* Create user data */
+ dbg_ctx->f = f;
+ dbg_ctx->chunk_size = layout.u.chunk.size;
+
+ /* Set return value */
+ ret_value = dbg_ctx;
+
+done:
+ /* Cleanup on error */
+ if(ret_value == NULL) {
+ /* Release context structure */
+ if(dbg_ctx)
+ dbg_ctx = H5FL_FREE(H5D_earray_ctx_ud_t, dbg_ctx);
+
+ /* Close object header */
+ if(obj_opened) {
+ if(H5O_close(&obj_loc) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header")
+ } /* end if */
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_earray_crt_dbg_context() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_earray_dst_dbg_context
+ *
+ * Purpose: Destroy context for debugging callback
+ * (free the layout message from the specified object header)
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Vailin Choi; July 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5D_earray_dst_dbg_context(void *_dbg_ctx)
+{
+ H5D_earray_ctx_ud_t *dbg_ctx = (H5D_earray_ctx_ud_t *)_dbg_ctx; /* Context for extensible array callback */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_earray_dst_dbg_context)
+
+ HDassert(dbg_ctx);
+
+ /* Release context structure */
+ dbg_ctx = H5FL_FREE(H5D_earray_ctx_ud_t, dbg_ctx);
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5D_earray_dst_dbg_context() */
+
+/*-------------------------------------------------------------------------
* Function: H5D_earray_filt_fill
*
* Purpose: Fill "missing elements" in block of elements
diff --git a/src/H5EAcache.c b/src/H5EAcache.c
index b64e884..cc712ab9 100644
--- a/src/H5EAcache.c
+++ b/src/H5EAcache.c
@@ -560,6 +560,10 @@ END_FUNC(STATIC) /* end H5EA__cache_hdr_dest() */
* koziol@hdfgroup.org
* Sep 9 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Moved Fixed array type to be right after MAGIC # and version.
+
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(STATIC, ERR,
@@ -617,15 +621,15 @@ H5EA__cache_iblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
if(*p++ != H5EA_IBLOCK_VERSION)
H5E_THROW(H5E_VERSION, "wrong extensible array index block version")
+ /* Extensible array type */
+ if(*p++ != (uint8_t)hdr->cparam.cls->id)
+ H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
+
/* Address of header for array that owns this block (just for file integrity checks) */
H5F_addr_decode(f, &p, &arr_addr);
if(H5F_addr_ne(arr_addr, hdr->addr))
H5E_THROW(H5E_BADVALUE, "wrong extensible array header address")
- /* Extensible array type */
- if(*p++ != (uint8_t)hdr->cparam.cls->id)
- H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
-
/* Internal information */
/* Decode elements in index block */
@@ -700,6 +704,9 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_load() */
* koziol@hdfgroup.org
* Sep 9 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Moved Fixed array type to be right after MAGIC # and version.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(STATIC, ERR,
@@ -744,12 +751,12 @@ H5EA__cache_iblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Version # */
*p++ = H5EA_IBLOCK_VERSION;
- /* Address of array header for array which owns this block */
- H5F_addr_encode(f, &p, iblock->hdr->addr);
-
/* Extensible array type */
*p++ = iblock->hdr->cparam.cls->id;
+ /* Address of array header for array which owns this block */
+ H5F_addr_encode(f, &p, iblock->hdr->addr);
+
/* Internal information */
/* Encode elements in index block */
@@ -978,6 +985,9 @@ END_FUNC(STATIC) /* end H5EA__cache_iblock_dest() */
* koziol@hdfgroup.org
* Sep 30 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Moved Fixed array type to be right after MAGIC # and version.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(STATIC, ERR,
@@ -1036,6 +1046,10 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
if(*p++ != H5EA_SBLOCK_VERSION)
H5E_THROW(H5E_VERSION, "wrong extensible array super block version")
+ /* Extensible array type */
+ if(*p++ != (uint8_t)udata->hdr->cparam.cls->id)
+ H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
+
/* Address of header for array that owns this block (just for file integrity checks) */
H5F_addr_decode(f, &p, &arr_addr);
if(H5F_addr_ne(arr_addr, udata->hdr->addr))
@@ -1044,10 +1058,6 @@ H5EA__cache_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
/* Offset of block within the array's address space */
UINT64DECODE_VAR(p, sblock->block_off, udata->hdr->arr_off_size);
- /* Extensible array type */
- if(*p++ != (uint8_t)udata->hdr->cparam.cls->id)
- H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
-
/* Internal information */
/* Check for 'page init' bitmasks for this super block */
@@ -1109,6 +1119,9 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_load() */
* koziol@hdfgroup.org
* Sep 30 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Moved Fixed array type to be right after MAGIC # and version.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(STATIC, ERR,
@@ -1154,15 +1167,15 @@ H5EA__cache_sblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Version # */
*p++ = H5EA_SBLOCK_VERSION;
+ /* Extensible array type */
+ *p++ = sblock->hdr->cparam.cls->id;
+
/* Address of array header for array which owns this block */
H5F_addr_encode(f, &p, sblock->hdr->addr);
/* Offset of block in array */
UINT64ENCODE_VAR(p, sblock->block_off, sblock->hdr->arr_off_size);
- /* Extensible array type */
- *p++ = sblock->hdr->cparam.cls->id;
-
/* Internal information */
/* Check for 'page init' bitmasks for this super block */
@@ -1377,6 +1390,9 @@ END_FUNC(STATIC) /* end H5EA__cache_sblock_dest() */
* koziol@hdfgroup.org
* Sep 16 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Moved Fixed array type to be right after MAGIC # and version.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(STATIC, ERR,
@@ -1437,6 +1453,10 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
if(*p++ != H5EA_DBLOCK_VERSION)
H5E_THROW(H5E_VERSION, "wrong extensible array data block version")
+ /* Extensible array type */
+ if(*p++ != (uint8_t)udata->hdr->cparam.cls->id)
+ H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
+
/* Address of header for array that owns this block (just for file integrity checks) */
H5F_addr_decode(f, &p, &arr_addr);
if(H5F_addr_ne(arr_addr, udata->hdr->addr))
@@ -1445,10 +1465,6 @@ H5EA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
/* Offset of block within the array's address space */
UINT64DECODE_VAR(p, dblock->block_off, udata->hdr->arr_off_size);
- /* Extensible array type */
- if(*p++ != (uint8_t)udata->hdr->cparam.cls->id)
- H5E_THROW(H5E_BADTYPE, "incorrect extensible array class")
-
/* Internal information */
/* Only decode elements if the data block is not paged */
@@ -1506,6 +1522,9 @@ END_FUNC(STATIC) /* end H5EA__cache_dblock_load() */
* koziol@hdfgroup.org
* Sep 18 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Moved Fixed array type to be right after MAGIC # and version.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(STATIC, ERR,
@@ -1553,15 +1572,15 @@ H5EA__cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Version # */
*p++ = H5EA_DBLOCK_VERSION;
+ /* Extensible array type */
+ *p++ = dblock->hdr->cparam.cls->id;
+
/* Address of array header for array which owns this block */
H5F_addr_encode(f, &p, dblock->hdr->addr);
/* Offset of block in array */
UINT64ENCODE_VAR(p, dblock->block_off, dblock->hdr->arr_off_size);
- /* Extensible array type */
- *p++ = dblock->hdr->cparam.cls->id;
-
/* Internal information */
/* Only encode elements if the data block is not paged */
diff --git a/src/H5EAdbg.c b/src/H5EAdbg.c
index 1851bd8..32b0307 100644
--- a/src/H5EAdbg.c
+++ b/src/H5EAdbg.c
@@ -91,26 +91,38 @@
* koziol@hdfgroup.org
* Sep 11 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Create debugging context so that header can be loaded properly.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(PKG, ERR,
herr_t, SUCCEED, FAIL,
H5EA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
- int fwidth, const H5EA_class_t *cls))
+ int fwidth, const H5EA_class_t *cls, haddr_t obj_addr))
/* Local variables */
- H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */
+ H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */
+ void *dbg_ctx = NULL; /* Extensible array debugging context */
/* Check arguments */
HDassert(f);
HDassert(H5F_addr_defined(addr));
+ HDassert(H5F_addr_defined(obj_addr));
HDassert(stream);
HDassert(indent >= 0);
HDassert(fwidth >= 0);
HDassert(cls);
+ /* Check for debugging context callback available */
+ if(cls->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, dxpl_id, obj_addr)))
+ H5E_THROW(H5E_CANTGET, "unable to create fixed array debugging context")
+ } /* end if */
+
/* Load the extensible array header */
- if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, addr, NULL, H5AC_READ)))
+ if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, addr, dbg_ctx, H5AC_READ)))
H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header")
/* Print opening message */
@@ -118,9 +130,7 @@ H5EA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Array class ID:",
- (hdr->cparam.cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
- "Unknown!"));
+ "Array class ID:", hdr->cparam.cls->name);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Header size:",
hdr->size);
@@ -162,6 +172,9 @@ H5EA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
hdr->idx_blk_addr);
CATCH
+ if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0)
+ H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context")
+
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_EARRAY_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array header")
@@ -179,16 +192,20 @@ END_FUNC(PKG) /* end H5EA__hdr_debug() */
* koziol@hdfgroup.org
* Sep 11 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Create debugging context so that header can be loaded properly.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(PKG, ERR,
herr_t, SUCCEED, FAIL,
H5EA__iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE *stream, int indent,
- int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr))
+ int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr, haddr_t obj_addr))
/* Local variables */
H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */
H5EA_iblock_t *iblock = NULL; /* Extensible array index block */
+ void *dbg_ctx = NULL; /* Extensible array context */
/* Check arguments */
HDassert(f);
@@ -198,9 +215,17 @@ H5EA__iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE *stream, i
HDassert(fwidth >= 0);
HDassert(cls);
HDassert(H5F_addr_defined(hdr_addr));
+ HDassert(H5F_addr_defined(obj_addr));
+
+ /* Check for debugging context callback available */
+ if(cls->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, dxpl_id, obj_addr)))
+ H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context")
+ } /* end if */
/* Load the extensible array header */
- if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, NULL, H5AC_READ)))
+ if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, dbg_ctx, H5AC_READ)))
H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header")
/* Sanity check */
@@ -215,9 +240,7 @@ H5EA__iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE *stream, i
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Array class ID:",
- (hdr->cparam.cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
- "Unknown!"));
+ "Array class ID:", hdr->cparam.cls->name);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Index Block size:",
iblock->size);
@@ -276,6 +299,8 @@ H5EA__iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, FILE *stream, i
} /* end if */
CATCH
+ if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0)
+ H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context")
if(iblock && H5EA__iblock_unprotect(iblock, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array index block")
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
@@ -295,16 +320,20 @@ END_FUNC(PKG) /* end H5EA__iblock_debug() */
* koziol@hdfgroup.org
* Sep 30 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Create debugging context so that header can be loaded properly.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(PKG, ERR,
herr_t, SUCCEED, FAIL,
H5EA__sblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
- int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr, unsigned sblk_idx))
+ int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr))
/* Local variables */
H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */
H5EA_sblock_t *sblock = NULL; /* Extensible array super block */
+ void *dbg_ctx = NULL; /* Extensible array context */
/* Check arguments */
HDassert(f);
@@ -314,9 +343,17 @@ H5EA__sblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
HDassert(fwidth >= 0);
HDassert(cls);
HDassert(H5F_addr_defined(hdr_addr));
+ HDassert(H5F_addr_defined(obj_addr));
+
+ /* Check for debugging context callback available */
+ if(cls->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, dxpl_id, obj_addr)))
+ H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context")
+ } /* end if */
/* Load the extensible array header */
- if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, NULL, H5AC_READ)))
+ if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, dbg_ctx, H5AC_READ)))
H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header")
/* Protect super block */
@@ -329,9 +366,7 @@ H5EA__sblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Array class ID:",
- (hdr->cparam.cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
- "Unknown!"));
+ "Array class ID:", hdr->cparam.cls->name);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Super Block size:",
sblock->size);
@@ -359,6 +394,8 @@ H5EA__sblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
} /* end if */
CATCH
+ if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0)
+ H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context")
if(sblock && H5EA__sblock_unprotect(sblock, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array super block")
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
@@ -378,16 +415,20 @@ END_FUNC(PKG) /* end H5EA__sblock_debug() */
* koziol@hdfgroup.org
* Sep 22 2008
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Create debugging context so that header can be loaded properly.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(PKG, ERR,
herr_t, SUCCEED, FAIL,
H5EA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
- int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr, size_t dblk_nelmts))
+ int fwidth, const H5EA_class_t *cls, haddr_t hdr_addr, size_t dblk_nelmts, haddr_t obj_addr))
/* Local variables */
H5EA_hdr_t *hdr = NULL; /* Shared extensible array header */
H5EA_dblock_t *dblock = NULL; /* Extensible array data block */
+ void *dbg_ctx = NULL; /* Extensible array context */
size_t u; /* Local index variable */
/* Check arguments */
@@ -398,10 +439,18 @@ H5EA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
HDassert(fwidth >= 0);
HDassert(cls);
HDassert(H5F_addr_defined(hdr_addr));
+ HDassert(H5F_addr_defined(obj_addr));
HDassert(dblk_nelmts > 0);
+ /* Check for debugging context callback available */
+ if(cls->crt_dbg_ctx) {
+ /* Create debugging context */
+ if(NULL == (dbg_ctx = cls->crt_dbg_ctx(f, dxpl_id, obj_addr)))
+ H5E_THROW(H5E_CANTGET, "unable to create extensible array debugging context")
+ } /* end if */
+
/* Load the extensible array header */
- if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, NULL, H5AC_READ)))
+ if(NULL == (hdr = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, dbg_ctx, H5AC_READ)))
H5E_THROW(H5E_CANTPROTECT, "unable to load extensible array header")
/* Protect data block */
@@ -414,9 +463,7 @@ H5EA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
/* Print the values */
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Array class ID:",
- (hdr->cparam.cls->id == H5EA_CLS_TEST_ID ? "H5EA_CLS_TEST_ID" :
- "Unknown!"));
+ "Array class ID:", hdr->cparam.cls->name);
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Data Block size:",
dblock->size);
@@ -433,6 +480,8 @@ H5EA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int inde
} /* end for */
CATCH
+ if(dbg_ctx && cls->dst_dbg_ctx(dbg_ctx) < 0)
+ H5E_THROW(H5E_CANTRELEASE, "unable to release extensible array debugging context")
if(dblock && H5EA__dblock_unprotect(dblock, dxpl_id, H5AC__NO_FLAGS_SET) < 0)
H5E_THROW(H5E_CANTUNPROTECT, "unable to release extensible array data block")
if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_EARRAY_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0)
diff --git a/src/H5EApkg.h b/src/H5EApkg.h
index e95d27f..0bbca28 100644
--- a/src/H5EApkg.h
+++ b/src/H5EApkg.h
@@ -61,6 +61,7 @@
#define H5EA_METADATA_PREFIX_SIZE(c) ( \
H5_SIZEOF_MAGIC /* Signature */ \
+ 1 /* Version */ \
+ + 1 /* Array type */ \
+ ((c) ? H5EA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \
)
@@ -70,7 +71,6 @@
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* General array information */ \
- + 1 /* Array type */ \
+ 1 /* Element Size */ \
+ 1 /* Max. # of elements bits */ \
+ 1 /* # of elements to store in index block */ \
@@ -96,7 +96,6 @@
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* Sanity-checking fields */ \
- + 1 /* Array type */ \
+ (i)->hdr->sizeof_addr /* File address of array owning the block */ \
\
/* Extensible Array Index Block specific fields */ \
@@ -111,7 +110,6 @@
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* Sanity-checking fields */ \
- + 1 /* Array type */ \
+ (s)->hdr->sizeof_addr /* File address of array owning the block */ \
+ (s)->hdr->arr_off_size /* Offset of the block in the array */ \
\
@@ -126,7 +124,6 @@
H5EA_METADATA_PREFIX_SIZE(TRUE) \
\
/* Sanity-checking fields */ \
- + 1 /* Array type */ \
+ (d)->hdr->sizeof_addr /* File address of array owning the block */ \
+ (d)->hdr->arr_off_size /* Offset of the block in the array */ \
)
@@ -352,6 +349,12 @@ H5_DLLVAR const H5AC_class_t H5AC_EARRAY_DBLOCK[1];
/* H5EA data block page inherits cache-like properties from H5AC */
H5_DLLVAR const H5AC_class_t H5AC_EARRAY_DBLK_PAGE[1];
+/* The Extensible Array class for dataset chunks w/o filters*/
+H5_DLLVAR const H5EA_class_t H5EA_CLS_CHUNK[1];
+
+/* The Extensible Array class for dataset chunks w/ filters*/
+H5_DLLVAR const H5EA_class_t H5EA_CLS_FILT_CHUNK[1];
+
/* Internal extensible array testing class */
#ifdef H5EA_TESTING
H5_DLLVAR const H5EA_class_t H5EA_CLS_TEST[1];
@@ -436,16 +439,16 @@ H5_DLL herr_t H5EA__dblk_page_dest(H5EA_dblk_page_t *dblk_page);
/* Debugging routines for dumping file structures */
H5_DLL herr_t H5EA__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
- FILE *stream, int indent, int fwidth, const H5EA_class_t *cls);
+ FILE *stream, int indent, int fwidth, const H5EA_class_t *cls, haddr_t obj_addr);
H5_DLL herr_t H5EA__iblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
FILE *stream, int indent, int fwidth, const H5EA_class_t *cls,
- haddr_t hdr_addr);
+ haddr_t hdr_addr, haddr_t obj_addr);
H5_DLL herr_t H5EA__sblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
FILE *stream, int indent, int fwidth, const H5EA_class_t *cls,
- haddr_t hdr_addr, unsigned sblk_idx);
+ haddr_t hdr_addr, unsigned sblk_idx, haddr_t obj_addr);
H5_DLL herr_t H5EA__dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr,
FILE *stream, int indent, int fwidth, const H5EA_class_t *cls,
- haddr_t hdr_addr, size_t dblk_nelmts);
+ haddr_t hdr_addr, size_t dblk_nelmts, haddr_t obj_addr);
/* Testing routines */
#ifdef H5EA_TESTING
diff --git a/src/H5EAprivate.h b/src/H5EAprivate.h
index 06bdd55..feb58b7 100644
--- a/src/H5EAprivate.h
+++ b/src/H5EAprivate.h
@@ -64,6 +64,7 @@ typedef enum H5EA_cls_id_t {
*/
typedef struct H5EA_class_t {
H5EA_cls_id_t id; /* ID of Extensible Array class, as found in file */
+ const char *name; /* Name of class (for debugging) */
size_t nat_elmt_size; /* Size of native (memory) element */
/* Extensible array client callback methods */
@@ -73,6 +74,8 @@ typedef struct H5EA_class_t {
herr_t (*encode)(void *raw, const void *elmt, size_t nelmts, void *ctx); /* Encode elements from native form to disk storage form */
herr_t (*decode)(const void *raw, void *elmt, size_t nelmts, void *ctx); /* Decode elements from disk storage form to native form */
herr_t (*debug)(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt); /* Print an element for debugging */
+ void *(*crt_dbg_ctx)(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr); /* Create debugging context */
+ herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */
} H5EA_class_t;
/* Extensible array creation parameters */
diff --git a/src/H5EAtest.c b/src/H5EAtest.c
index 87f9195..e24fc65 100644
--- a/src/H5EAtest.c
+++ b/src/H5EAtest.c
@@ -75,13 +75,12 @@ typedef struct H5EA__test_ctx_t {
static void *H5EA__test_crt_context(void *udata);
static herr_t H5EA__test_dst_context(void *ctx);
static herr_t H5EA__test_fill(void *nat_blk, size_t nelmts);
-static herr_t H5EA__test_encode(void *raw, const void *elmt, size_t nelmts,
- void *ctx);
-static herr_t H5EA__test_decode(const void *raw, void *elmt, size_t nelmts,
- void *ctx);
-static herr_t H5EA__test_debug(FILE *stream, int indent, int fwidth,
- hsize_t idx, const void *elmt);
+static herr_t H5EA__test_encode(void *raw, const void *elmt, size_t nelmts, void *ctx);
+static herr_t H5EA__test_decode(const void *raw, void *elmt, size_t nelmts, void *ctx);
+static herr_t H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx, const void *elmt);
+static void *H5EA__test_crt_dbg_context(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t UNUSED obj_addr);
+static herr_t H5EA__test_dst_dbg_context(void *_ctx);
/*********************/
/* Package Variables */
@@ -90,13 +89,16 @@ static herr_t H5EA__test_debug(FILE *stream, int indent, int fwidth,
/* Extensible array testing class information */
const H5EA_class_t H5EA_CLS_TEST[1]={{
H5EA_CLS_TEST_ID, /* Type of Extensible array */
+ "Testing", /* Name of Extensible Array class */
sizeof(uint64_t), /* Size of native element */
H5EA__test_crt_context, /* Create context */
H5EA__test_dst_context, /* Destroy context */
H5EA__test_fill, /* Fill block of missing elements callback */
H5EA__test_encode, /* Element encoding callback */
H5EA__test_decode, /* Element decoding callback */
- H5EA__test_debug /* Element debugging callback */
+ H5EA__test_debug, /* Element debugging callback */
+ H5EA__test_crt_dbg_context, /* Create debugging context */
+ H5EA__test_dst_dbg_context /* Destroy debugging context */
}};
@@ -111,6 +113,8 @@ const H5EA_class_t H5EA_CLS_TEST[1]={{
/* Declare a free list to manage the H5EA__test_ctx_t struct */
H5FL_DEFINE_STATIC(H5EA__test_ctx_t);
+/* Declare a free list to manage the H5EA__ctx_cb_t struct */
+H5FL_DEFINE_STATIC(H5EA__ctx_cb_t);
@@ -338,6 +342,65 @@ H5EA__test_debug(FILE *stream, int indent, int fwidth, hsize_t idx,
END_FUNC(STATIC) /* end H5EA__test_debug() */
+/*-------------------------------------------------------------------------
+ * Function: H5EA__test_crt_dbg_context
+ *
+ * Purpose: Create context for debugging callback
+ *
+ * Return: Success: non-NULL
+ * Failure: NULL
+ *
+ * Programmer: Vailin Choi; August 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+BEGIN_FUNC(STATIC, ERR,
+void *, NULL, NULL,
+H5EA__test_crt_dbg_context(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, haddr_t UNUSED obj_addr))
+
+ /* Local variables */
+ H5EA__ctx_cb_t *ctx; /* Context for callbacks */
+
+ /* Allocate new context structure */
+ if(NULL == (ctx = H5FL_MALLOC(H5EA__ctx_cb_t)))
+ H5E_THROW(H5E_CANTALLOC, "can't allocate extensible array client callback context")
+
+ /* Set return value */
+ ret_value = ctx;
+
+CATCH
+
+END_FUNC(STATIC) /* end H5EA__test_crt_dbg_context() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5EA__test_dst_dbg_context
+ *
+ * Purpose: Destroy context for callbacks
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Vailin Choi; August 2010
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t H5EA__test_dst_dbg_context(void *_ctx);
+
+BEGIN_FUNC(STATIC, NOERR,
+herr_t, SUCCEED, -,
+H5EA__test_dst_dbg_context(void *_ctx))
+
+ /* Local variables */
+ H5EA__ctx_cb_t *ctx = (H5EA__ctx_cb_t *)_ctx; /* Callback context to destroy */
+
+ HDassert(_ctx);
+
+ /* Release context structure */
+ ctx = H5FL_FREE(H5EA__ctx_cb_t, ctx);
+
+END_FUNC(STATIC) /* end H5EA__test_dst_dbg_context() */
+
/*-------------------------------------------------------------------------
* Function: H5EA_get_cparam_test
diff --git a/src/H5FAcache.c b/src/H5FAcache.c
index 96510b5..7e72a08 100644
--- a/src/H5FAcache.c
+++ b/src/H5FAcache.c
@@ -496,6 +496,9 @@ END_FUNC(STATIC) /* end H5FA__cache_hdr_dest() */
* Programmer: Vailin Choi
* Thursday, April 30, 2009
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Moved Fixed array type to be right after MAGIC # and version.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(STATIC, ERR,
@@ -556,15 +559,15 @@ H5FA__cache_dblock_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_udata))
if(*p++ != H5FA_DBLOCK_VERSION)
H5E_THROW(H5E_VERSION, "wrong fixed array data block version")
+ /* Fixed array type */
+ if(*p++ != (uint8_t)udata->hdr->cparam.cls->id)
+ H5E_THROW(H5E_BADTYPE, "incorrect fixed array class")
+
/* Address of header for array that owns this block (just for file integrity checks) */
H5F_addr_decode(f, &p, &arr_addr);
if(H5F_addr_ne(arr_addr, udata->hdr->addr))
H5E_THROW(H5E_BADVALUE, "wrong fixed array header address")
- /* Fixed array type */
- if(*p++ != (uint8_t)udata->hdr->cparam.cls->id)
- H5E_THROW(H5E_BADTYPE, "incorrect fixed array class")
-
/* Page initialization flags */
if(dblock->npages > 0) {
HDmemcpy(dblock->dblk_page_init, p, dblock->dblk_page_init_size);
@@ -625,6 +628,9 @@ END_FUNC(STATIC) /* end H5FA__cache_dblock_load() */
* Programmer: Vailin Choi
* Thursday, April 30, 2009
*
+ * Modifications:
+ * Vailin Choi; July 2010
+ * Moved Fixed array type to be right after MAGIC # and version.
*-------------------------------------------------------------------------
*/
BEGIN_FUNC(STATIC, ERR,
@@ -672,12 +678,12 @@ H5FA__cache_dblock_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr,
/* Version # */
*p++ = H5FA_DBLOCK_VERSION;
- /* Address of array header for array which owns this block */
- H5F_addr_encode(f, &p, dblock->hdr->addr);
-
/* Fixed array type */
*p++ = dblock->hdr->cparam.cls->id;
+ /* Address of array header for array which owns this block */
+ H5F_addr_encode(f, &p, dblock->hdr->addr);
+
/* Page init flags */
if(dblock->npages > 0) {
/* Store the 'page init' bitmasks */
diff --git a/src/H5FApkg.h b/src/H5FApkg.h
index f6d995b..3df1cda 100644
--- a/src/H5FApkg.h
+++ b/src/H5FApkg.h
@@ -65,6 +65,7 @@
#define H5FA_METADATA_PREFIX_SIZE(c) ( \
H5_SIZEOF_MAGIC /* Signature */ \
+ 1 /* Version */ \
+ + 1 /* Array type */ \
+ ((c) ? H5FA_SIZEOF_CHKSUM : 0) /* Metadata checksum */ \
)
@@ -72,15 +73,11 @@
#define H5FA_HEADER_SIZE(h) ( \
/* General metadata fields */ \
H5FA_METADATA_PREFIX_SIZE(TRUE) \
- \
/* General array information */ \
- + 1 /* Array type */ \
+ 1 /* Element Size */ \
+ 1 /* Log2(Max. # of elements in data block page) - i.e. # of bits needed to store max. # of elements in data block page */ \
- \
/* Fixed Array statistics fields */ \
+ (h)->sizeof_size /* # of elements in the fixed array */ \
- \
/* Fixed Array Header specific fields */ \
+ (h)->sizeof_addr /* File address of Fixed Array data block */ \
)
@@ -89,11 +86,8 @@
#define H5FA_DBLOCK_PREFIX_SIZE(d) ( \
/* General metadata fields */ \
H5FA_METADATA_PREFIX_SIZE(TRUE) \
- \
/* Sanity-checking fields */ \
- + (d)->hdr->sizeof_addr /* File address of Fixed Array header owning the data block */ \
- + 1 /* Array type */ \
- \
+ + (d)->hdr->sizeof_addr /* File address of Fixed Array header owning the data block */ \
/* Fixed Array Data Block specific fields */ \
+ (d)->dblk_page_init_size /* Fixed array data block 'page init' bitmasks (can be 0 if no pages) */ \
)
@@ -102,7 +96,6 @@
#define H5FA_DBLOCK_SIZE(d) ( \
/* Data block prefix size */ \
H5FA_DBLOCK_PREFIX_SIZE(d) \
- \
/* Fixed Array Elements|Pages of Elements*/ \
+ ((d)->hdr->cparam.nelmts * (size_t)(d)->hdr->cparam.raw_elmt_size) \
+ ((d)->npages * H5FA_SIZEOF_CHKSUM) /* Checksum */ \