From b553ceaa71c7ecf41444c83ca801863da0db73f0 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sat, 26 Sep 2015 12:34:05 -0500 Subject: [svn-r27883] Revert of r27881 The number of elements in a struct between the trunk and revise_chunks differed, which confused Subversion. Interestingly, only some of the compilers flagged this as an error. Tested on: local linux --- src/H5Abtree2.c | 20 ++++++++---- src/H5B2dbg.c | 79 +++++++++++++++++++++++++++++++++++------------ src/H5B2private.h | 6 ++-- src/H5B2test.c | 53 +++++++++++++++++++++++++++++--- src/H5Fdbg.c | 2 -- src/H5Gbtree2.c | 22 +++++++++---- src/H5HF.c | 66 ++------------------------------------- src/H5HFbtree2.c | 84 ++++++++++++++++++++++++++++++++++++++++++-------- src/H5HFdbg.c | 74 -------------------------------------------- src/H5HFhuge.c | 87 ---------------------------------------------------- src/H5HFman.c | 35 --------------------- src/H5HFpkg.h | 6 +--- src/H5HFprivate.h | 4 --- src/H5Odbg.c | 21 +++---------- src/H5Olink.c | 4 +-- src/H5SM.c | 62 +++++++++++++------------------------ src/H5SMbtree2.c | 51 +++++++++++++++++++++++++++--- src/H5SMprivate.h | 2 +- tools/misc/h5debug.c | 14 ++++----- 19 files changed, 300 insertions(+), 392 deletions(-) diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 5e29d3f..b85bee3 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -85,7 +85,8 @@ static herr_t H5A__dense_btree2_corder_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5A__dense_btree2_corder_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5A__dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5A__dense_btree2_name_store(void *native, const void *udata); @@ -94,7 +95,8 @@ static herr_t H5A__dense_btree2_name_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5A__dense_btree2_name_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5A__dense_btree2_name_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); /* Fractal heap function callbacks */ static herr_t H5A__dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data); @@ -114,7 +116,9 @@ const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */ H5A__dense_btree2_name_compare, /* Record comparison callback */ H5A__dense_btree2_name_encode, /* Record encoding callback */ H5A__dense_btree2_name_decode, /* Record decoding callback */ - H5A__dense_btree2_name_debug /* Record debugging callback */ + H5A__dense_btree2_name_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /* v2 B-tree class for indexing 'creation order' field of attributes */ @@ -128,7 +132,9 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ H5A__dense_btree2_corder_compare, /* Record comparison callback */ H5A__dense_btree2_corder_encode, /* Record encoding callback */ H5A__dense_btree2_corder_decode, /* Record decoding callback */ - H5A__dense_btree2_corder_debug /* Record debugging callback */ + H5A__dense_btree2_corder_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; @@ -375,7 +381,8 @@ H5A__dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_U *------------------------------------------------------------------------- */ static herr_t -H5A__dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord) +H5A__dense_btree2_name_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *_nrecord, const void H5_ATTR_UNUSED *_udata) { const H5A_dense_bt2_name_rec_t *nrecord = (const H5A_dense_bt2_name_rec_t *)_nrecord; @@ -532,7 +539,8 @@ H5A__dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR *------------------------------------------------------------------------- */ static herr_t -H5A__dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord) +H5A__dense_btree2_corder_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *_nrecord, const void H5_ATTR_UNUSED *_udata) { const H5A_dense_bt2_corder_rec_t *nrecord = (const H5A_dense_bt2_corder_rec_t *)_nrecord; diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 85351e1..20c0a5f 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -91,6 +91,7 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, const H5B2_class_t *type, haddr_t obj_addr) { H5B2_hdr_t *hdr = NULL; /* B-tree header info */ + void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ @@ -108,13 +109,22 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); + HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || + (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); + + /* Check for debugging context callback available */ + if(type->crt_dbg_ctx) { + /* Create debugging context */ + if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") + } /* end if */ /* * Load the B-tree header. */ cache_udata.f = f; cache_udata.addr = addr; - cache_udata.ctx_udata = f; + cache_udata.ctx_udata = dbg_ctx; cache_udata.parent = NULL; if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") @@ -130,12 +140,12 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, */ HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", - (unsigned)hdr->node_size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + hdr->node_size); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Dirty flag:", hdr->cache_info.is_dirty ? "True" : "False"); @@ -168,6 +178,8 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, } /* end for */ done: + if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) @@ -197,6 +209,7 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_internal_t *internal = NULL; /* B-tree internal node */ + void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ @@ -213,16 +226,25 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); + HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || + (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); HDassert(H5F_addr_defined(hdr_addr)); HDassert(H5F_addr_defined(obj_addr)); HDassert(nrec > 0); + /* Check for debugging context callback available */ + if(type->crt_dbg_ctx) { + /* Create debugging context */ + if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") + } /* end if */ + /* * Load the B-tree header. */ cache_udata.f = f; cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = f; + cache_udata.ctx_udata = dbg_ctx; cache_udata.parent = NULL; if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") @@ -239,19 +261,22 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree internal node") /* Print opening message */ - HDfprintf(stream, "%*sv2 B-tree Internal Node...\n", indent, ""); + if(internal->depth == 1) + HDfprintf(stream, "%*sv2 B-tree Internal 'Leaf' Node...\n", indent, ""); + else + HDfprintf(stream, "%*sv2 B-tree Internal 'Branch' Node...\n", indent, ""); /* * Print the values. */ HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", - (unsigned)hdr->node_size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + hdr->node_size); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Dirty flag:", internal->cache_info.is_dirty ? "True" : "False"); @@ -274,8 +299,8 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_INT_NREC(internal, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), - H5B2_INT_NREC(internal, hdr, u)); + (void)(type->debug)(stream, f, dxpl_id, indent + 6, MAX (0, fwidth-6), + H5B2_INT_NREC(internal, hdr, u), dbg_ctx); } /* end for */ /* Print final node pointer */ @@ -287,6 +312,8 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, internal->node_ptrs[u].addr); done: + if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) @@ -319,6 +346,7 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ + void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value = SUCCEED; /* Return value */ @@ -334,16 +362,25 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); + HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || + (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); HDassert(H5F_addr_defined(hdr_addr)); HDassert(H5F_addr_defined(obj_addr)); HDassert(nrec > 0); + /* Check for debugging context callback available */ + if(type->crt_dbg_ctx) { + /* Create debugging context */ + if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") + } /* end if */ + /* * Load the B-tree header. */ cache_udata.f = f; cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = f; + cache_udata.ctx_udata = dbg_ctx; cache_udata.parent = NULL; if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree header") @@ -366,12 +403,12 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent */ HDfprintf(stream, "%*s%-*s %s (%u)\n", indent, "", fwidth, "Tree type ID:", hdr->cls->name, (unsigned)hdr->cls->id); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of node:", - (unsigned)hdr->node_size); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, + hdr->node_size); + HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Size of raw (disk) record:", - (unsigned)hdr->rrec_size); + hdr->rrec_size); HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Dirty flag:", leaf->cache_info.is_dirty ? "True" : "False"); @@ -386,11 +423,13 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_LEAF_NREC(leaf, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), - H5B2_LEAF_NREC(leaf, hdr, u)); + (void)(type->debug)(stream, f, dxpl_id, indent + 6, MAX (0, fwidth-6), + H5B2_LEAF_NREC(leaf, hdr, u), dbg_ctx); } /* end for */ done: + if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr) { hdr->f = NULL; if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5B2private.h b/src/H5B2private.h index 7cc64c0..472e4a4 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -95,8 +95,10 @@ struct H5B2_class_t { herr_t (*compare)(const void *rec1, const void *rec2); /* Compare two native records */ herr_t (*encode)(uint8_t *raw, const void *record, void *ctx); /* Encode record from native form to disk storage form */ herr_t (*decode)(const uint8_t *raw, void *record, void *ctx); /* Decode record from disk storage form to native form */ - herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */ - const void *record); + herr_t (*debug)(FILE *stream, const H5F_t *f, hid_t dxpl_id, /* Print a record for debugging */ + int indent, int fwidth, const void *record, const void *ctx); + 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 */ }; /* v2 B-tree creation parameters */ diff --git a/src/H5B2test.c b/src/H5B2test.c index 148cfb4..5890fb8 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -67,7 +67,9 @@ static herr_t H5B2__test_store(void *nrecord, const void *udata); static herr_t H5B2__test_compare(const void *rec1, const void *rec2); static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *ctx); static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *ctx); -static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5B2__test_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); +static void *H5B2__test_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); /*********************/ @@ -84,7 +86,9 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ H5B2__test_compare, /* Record comparison callback */ H5B2__test_encode, /* Record encoding callback */ H5B2__test_decode, /* Record decoding callback */ - H5B2__test_debug /* Record debugging callback */ + H5B2__test_debug, /* Record debugging callback */ + H5B2__test_crt_dbg_context, /* Create debugging context */ + H5B2__test_dst_context /* Destroy debugging context */ }}; @@ -291,11 +295,13 @@ H5B2__test_decode(const uint8_t *raw, void *nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record) +H5B2__test_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *record, + const void H5_ATTR_UNUSED *_udata) { FUNC_ENTER_STATIC_NOERR - HDassert(record); + HDassert (record); HDfprintf(stream, "%*s%-*s %Hu\n", indent, "", fwidth, "Record:", *(const hsize_t *)record); @@ -305,6 +311,45 @@ H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record) /*------------------------------------------------------------------------- + * Function: H5B2__test_crt_dbg_context + * + * Purpose: Create context for debugging callback + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, December 1, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5B2__test_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) +{ + H5B2_test_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(f); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2__test_crt_dbg_context() */ + + +/*------------------------------------------------------------------------- * Function: H5B2_get_root_addr_test * * Purpose: Retrieve the root node's address diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index 93da900..40d24e5 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -104,8 +104,6 @@ H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth) "Symbol table leaf node 1/2 rank:", f->shared->sblock->sym_leaf_k); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Symbol table internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_SNODE_ID]); - HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Indexed storage internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_CHUNK_ID]); HDfprintf(stream, "%*s%-*s 0x%02x\n", indent, "", fwidth, "File status flags:", (unsigned)(f->shared->sblock->status_flags)); HDfprintf(stream, "%*s%-*s %a (rel)\n", indent, "", fwidth, diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index 31db886..06af245 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -83,7 +83,8 @@ static herr_t H5G_dense_btree2_corder_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5G_dense_btree2_corder_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5G_dense_btree2_corder_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); /* v2 B-tree driver callbacks for 'name' index */ static herr_t H5G_dense_btree2_name_store(void *native, const void *udata); @@ -92,7 +93,8 @@ static herr_t H5G_dense_btree2_name_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5G_dense_btree2_name_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5G_dense_btree2_name_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); /* Fractal heap function callbacks */ static herr_t H5G_dense_fh_name_cmp(const void *obj, size_t obj_len, void *op_data); @@ -112,7 +114,9 @@ const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */ H5G_dense_btree2_name_compare, /* Record comparison callback */ H5G_dense_btree2_name_encode, /* Record encoding callback */ H5G_dense_btree2_name_decode, /* Record decoding callback */ - H5G_dense_btree2_name_debug /* Record debugging callback */ + H5G_dense_btree2_name_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /* v2 B-tree class for indexing 'creation order' field of links */ @@ -126,7 +130,9 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ H5G_dense_btree2_corder_compare, /* Record comparison callback */ H5G_dense_btree2_corder_encode, /* Record encoding callback */ H5G_dense_btree2_corder_decode, /* Record decoding callback */ - H5G_dense_btree2_corder_debug /* Record debugging callback */ + H5G_dense_btree2_corder_debug, /* Record debugging callback */ + NULL, /* Create debugging context */ + NULL /* Destroy debugging context */ }}; /*****************************/ @@ -356,7 +362,9 @@ H5G_dense_btree2_name_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_UN *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_name_debug(FILE *stream, int indent, int fwidth, const void *_nrecord) +H5G_dense_btree2_name_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5G_dense_bt2_name_rec_t *nrecord = (const H5G_dense_bt2_name_rec_t *)_nrecord; unsigned u; /* Local index variable */ @@ -520,7 +528,9 @@ H5G_dense_btree2_corder_decode(const uint8_t *raw, void *_nrecord, void H5_ATTR_ *------------------------------------------------------------------------- */ static herr_t -H5G_dense_btree2_corder_debug(FILE *stream, int indent, int fwidth, const void *_nrecord) +H5G_dense_btree2_corder_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5G_dense_bt2_corder_rec_t *nrecord = (const H5G_dense_bt2_corder_rec_t *)_nrecord; unsigned u; /* Local index variable */ diff --git a/src/H5HF.c b/src/H5HF.c index 74c9b7f..b2d7a34 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -451,8 +451,8 @@ H5HF_get_obj_len(H5HF_t *fh, hid_t dxpl_id, const void *_id, size_t *obj_len_p) HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'tiny' object's length") } /* end if */ else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") + HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); + HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") } /* end else */ done: @@ -461,68 +461,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF_get_obj_off - * - * Purpose: Get the offset of an entry in a fractal heap - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Aug 20 2015 - * - *------------------------------------------------------------------------- - */ -herr_t -H5HF_get_obj_off(H5HF_t *fh, hid_t dxpl_id, const void *_id, hsize_t *obj_off_p) -{ - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* - * Check arguments. - */ - HDassert(fh); - HDassert(id); - HDassert(obj_off_p); - - /* Get the ID flags */ - id_flags = *id; - - /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) - HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") - - /* Set the shared heap header's file context for this operation */ - fh->hdr->f = fh->f; - - /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { - H5HF__man_get_obj_off(fh->hdr, id, obj_off_p); - } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { - /* Huge objects are located directly in the file */ - if(H5HF__huge_get_obj_off(fh->hdr, dxpl_id, id, obj_off_p) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't get 'huge' object's offset") - } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { - /* Tiny objects are not stored in the heap */ - *obj_off_p = (hsize_t)0; - } /* end if */ - else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") - } /* end else */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_get_obj_off() */ - - -/*------------------------------------------------------------------------- * Function: H5HF_read * * Purpose: Read an object from a fractal heap into a buffer diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index cb1ec77..0229ebe 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -70,6 +70,7 @@ typedef struct H5HF_huge_bt2_ctx_t { static void *H5HF_huge_bt2_crt_context(void *udata); static herr_t H5HF_huge_bt2_dst_context(void *ctx); +static void *H5HF_huge_bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); static herr_t H5HF_huge_bt2_indir_store(void *native, const void *udata); static herr_t H5HF_huge_bt2_indir_compare(const void *rec1, const void *rec2); @@ -77,7 +78,8 @@ static herr_t H5HF_huge_bt2_indir_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5HF_huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5HF_huge_bt2_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); static herr_t H5HF_huge_bt2_filt_indir_store(void *native, const void *udata); static herr_t H5HF_huge_bt2_filt_indir_compare(const void *rec1, const void *rec2); @@ -85,7 +87,8 @@ static herr_t H5HF_huge_bt2_filt_indir_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5HF_huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5HF_huge_bt2_filt_indir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); static herr_t H5HF_huge_bt2_dir_store(void *native, const void *udata); static herr_t H5HF_huge_bt2_dir_compare(const void *rec1, const void *rec2); @@ -93,7 +96,8 @@ static herr_t H5HF_huge_bt2_dir_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5HF_huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5HF_huge_bt2_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); static herr_t H5HF_huge_bt2_filt_dir_store(void *native, const void *udata); static herr_t H5HF_huge_bt2_filt_dir_compare(const void *rec1, const void *rec2); @@ -101,7 +105,8 @@ static herr_t H5HF_huge_bt2_filt_dir_encode(uint8_t *raw, const void *native, void *ctx); static herr_t H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *native, void *ctx); -static herr_t H5HF_huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, const void *record); +static herr_t H5HF_huge_bt2_filt_dir_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); /*********************/ /* Package Variables */ @@ -117,7 +122,9 @@ const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]={{ /* B-tree class information */ H5HF_huge_bt2_indir_compare, /* Record comparison callback */ H5HF_huge_bt2_indir_encode, /* Record encoding callback */ H5HF_huge_bt2_indir_decode, /* Record decoding callback */ - H5HF_huge_bt2_indir_debug /* Record debugging callback */ + H5HF_huge_bt2_indir_debug, /* Record debugging callback */ + H5HF_huge_bt2_crt_dbg_context, /* Create debugging context */ + H5HF_huge_bt2_dst_context /* Destroy debugging context */ }}; /* v2 B-tree class for indirectly accessed, filtered 'huge' objects */ @@ -131,7 +138,9 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ H5HF_huge_bt2_filt_indir_compare, /* Record comparison callback */ H5HF_huge_bt2_filt_indir_encode, /* Record encoding callback */ H5HF_huge_bt2_filt_indir_decode, /* Record decoding callback */ - H5HF_huge_bt2_filt_indir_debug /* Record debugging callback */ + H5HF_huge_bt2_filt_indir_debug, /* Record debugging callback */ + H5HF_huge_bt2_crt_dbg_context, /* Create debugging context */ + H5HF_huge_bt2_dst_context /* Destroy debugging context */ }}; /* v2 B-tree class for directly accessed 'huge' objects */ @@ -145,7 +154,9 @@ const H5B2_class_t H5HF_HUGE_BT2_DIR[1]={{ /* B-tree class information */ H5HF_huge_bt2_dir_compare, /* Record comparison callback */ H5HF_huge_bt2_dir_encode, /* Record encoding callback */ H5HF_huge_bt2_dir_decode, /* Record decoding callback */ - H5HF_huge_bt2_dir_debug /* Record debugging callback */ + H5HF_huge_bt2_dir_debug, /* Record debugging callback */ + H5HF_huge_bt2_crt_dbg_context, /* Create debugging context */ + H5HF_huge_bt2_dst_context /* Destroy debugging context */ }}; /* v2 B-tree class for directly accessed, filtered 'huge' objects */ @@ -159,7 +170,9 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ H5HF_huge_bt2_filt_dir_compare, /* Record comparison callback */ H5HF_huge_bt2_filt_dir_encode, /* Record encoding callback */ H5HF_huge_bt2_filt_dir_decode, /* Record decoding callback */ - H5HF_huge_bt2_filt_dir_debug /* Record debugging callback */ + H5HF_huge_bt2_filt_dir_debug, /* Record debugging callback */ + H5HF_huge_bt2_crt_dbg_context, /* Create debugging context */ + H5HF_huge_bt2_dst_context /* Destroy debugging context */ }}; /*****************************/ @@ -252,6 +265,46 @@ H5HF_huge_bt2_dst_context(void *_ctx) /*------------------------------------------------------------------------- + * Function: H5HF_huge_bt2_crt_dbg_context + * + * Purpose: Create context for debugging callback + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, December 1, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5HF_huge_bt2_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) +{ + H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity check */ + HDassert(f); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); + ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5HF_huge_bt2_crt_dbg_context() */ + + +/*------------------------------------------------------------------------- * Function: H5HF_huge_bt2_indir_found * * Purpose: Retrieve record for indirectly accessed 'huge' object, when @@ -452,7 +505,9 @@ H5HF_huge_bt2_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_bt2_indir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord) +H5HF_huge_bt2_indir_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_indir_rec_t *nrecord = (const H5HF_huge_bt2_indir_rec_t *)_nrecord; @@ -672,7 +727,9 @@ H5HF_huge_bt2_filt_indir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_bt2_filt_indir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord) +H5HF_huge_bt2_filt_indir_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_filt_indir_rec_t *nrecord = (const H5HF_huge_bt2_filt_indir_rec_t *)_nrecord; @@ -863,7 +920,9 @@ H5HF_huge_bt2_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_bt2_dir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord) +H5HF_huge_bt2_dir_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *_nrecord, + const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_dir_rec_t *nrecord = (const H5HF_huge_bt2_dir_rec_t *)_nrecord; @@ -1090,7 +1149,8 @@ H5HF_huge_bt2_filt_dir_decode(const uint8_t *raw, void *_nrecord, void *_ctx) *------------------------------------------------------------------------- */ static herr_t -H5HF_huge_bt2_filt_dir_debug(FILE *stream, int indent, int fwidth, const void *_nrecord) +H5HF_huge_bt2_filt_dir_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *_nrecord, const void H5_ATTR_UNUSED *_udata) { const H5HF_huge_bt2_filt_dir_rec_t *nrecord = (const H5HF_huge_bt2_filt_dir_rec_t *)_nrecord; diff --git a/src/H5HFdbg.c b/src/H5HFdbg.c index 736b98d..5183b67 100644 --- a/src/H5HFdbg.c +++ b/src/H5HFdbg.c @@ -100,80 +100,6 @@ static herr_t H5HF_dtable_debug(const H5HF_dtable_t *dtable, FILE *stream, /*------------------------------------------------------------------------- - * Function: H5HF_id_print - * - * Purpose: Prints a fractal heap ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Aug 20 2015 - * - *------------------------------------------------------------------------- - */ -herr_t -H5HF_id_print(H5HF_t *fh, hid_t dxpl_id, const void *_id, FILE *stream, int indent, int fwidth) -{ - const uint8_t *id = (const uint8_t *)_id; /* Object ID */ - uint8_t id_flags; /* Heap ID flag bits */ - hsize_t obj_off; /* Offset of object */ - size_t obj_len; /* Length of object */ - char id_type; /* Character for the type of heap ID */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* - * Check arguments. - */ - HDassert(fh); - HDassert(id); - HDassert(stream); - HDassert(indent >= 0); - HDassert(fwidth >= 0); - - /* Get the ID flags */ - id_flags = *id; - - /* Check for correct heap ID version */ - if((id_flags & H5HF_ID_VERS_MASK) != H5HF_ID_VERS_CURR) - HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "incorrect heap ID version") - - /* Check type of object in heap */ - if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_MAN) { - id_type = 'M'; - } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_HUGE) { - id_type = 'H'; - } /* end if */ - else if((id_flags & H5HF_ID_TYPE_MASK) == H5HF_ID_TYPE_TINY) { - id_type = 'T'; - } /* end if */ - else { -HDfprintf(stderr, "%s: Heap ID type not supported yet!\n", FUNC); -HGOTO_ERROR(H5E_HEAP, H5E_UNSUPPORTED, FAIL, "heap ID type not supported yet") - } /* end else */ - - /* Get the length of the heap object */ - if(H5HF_get_obj_len(fh, dxpl_id, id, &obj_len) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve heap ID length") - - /* Get the offset of the heap object */ - if(H5HF_get_obj_off(fh, dxpl_id, id, &obj_off) < 0) - HGOTO_ERROR(H5E_HEAP, H5E_CANTGET, FAIL, "can't retrieve heap ID length") - - /* Display the heap ID */ - HDfprintf(stream, "%*s%-*s (%c, %Hu, %Zu)\n", indent, "", fwidth, - "Heap ID info: (type, offset, length)", - id_type, obj_off, obj_len); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF_id_print() */ - - -/*------------------------------------------------------------------------- * Function: H5HF_dtable_debug * * Purpose: Prints debugging info about a doubling table diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index a51cb29..7c3b5f9 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -588,93 +588,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5HF__huge_get_obj_off - * - * Purpose: Get the offset of a 'huge' object in a fractal heap - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Aug 8 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, - hsize_t *obj_off_p) -{ - haddr_t obj_addr; /* Object's address in the file */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* - * Check arguments. - */ - HDassert(hdr); - HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); - HDassert(id); - HDassert(obj_off_p); - - /* Skip over the flag byte */ - id++; - - /* Check if 'huge' object ID encodes address & length directly */ - if(hdr->huge_ids_direct) { - /* Retrieve the object's address (common) */ - H5F_addr_decode(hdr->f, &id, &obj_addr); - } /* end if */ - else { - /* Sanity check */ - HDassert(H5F_addr_defined(hdr->huge_bt2_addr)); - - /* Check if v2 B-tree is open yet */ - if(NULL == hdr->huge_bt2) { - /* Open existing v2 B-tree */ - if(NULL == (hdr->huge_bt2 = H5B2_open(hdr->f, dxpl_id, hdr->huge_bt2_addr, hdr->f, NULL))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTOPENOBJ, FAIL, "unable to open v2 B-tree for tracking 'huge' heap objects") - } /* end if */ - - if(hdr->filter_len > 0) { - H5HF_huge_bt2_filt_indir_rec_t found_rec; /* Record found from tracking object */ - H5HF_huge_bt2_filt_indir_rec_t search_rec; /* Record for searching for object */ - - /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) - - /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_filt_indir_found, &found_rec) != TRUE) - HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") - - /* Retrieve the object's address & length */ - obj_addr = found_rec.addr; - } /* end if */ - else { - H5HF_huge_bt2_indir_rec_t found_rec; /* Record found from tracking object */ - H5HF_huge_bt2_indir_rec_t search_rec; /* Record for searching for object */ - - /* Get ID for looking up 'huge' object in v2 B-tree */ - UINT64DECODE_VAR(id, search_rec.id, hdr->huge_id_size) - - /* Look up object in v2 B-tree */ - if(H5B2_find(hdr->huge_bt2, dxpl_id, &search_rec, H5HF_huge_bt2_indir_found, &found_rec) != TRUE) - HGOTO_ERROR(H5E_HEAP, H5E_NOTFOUND, FAIL, "can't find object in B-tree") - - /* Retrieve the object's address & length */ - obj_addr = found_rec.addr; - } /* end else */ - } /* end else */ - - /* Set the value to return */ - *obj_off_p = (hsize_t)obj_addr; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5HF__huge_get_obj_off() */ - - -/*------------------------------------------------------------------------- * Function: H5HF_huge_op_real * * Purpose: Internal routine to perform an operation on a 'huge' object diff --git a/src/H5HFman.c b/src/H5HFman.c index cfbcd87..5f95a91 100644 --- a/src/H5HFman.c +++ b/src/H5HFman.c @@ -256,41 +256,6 @@ H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p) /*------------------------------------------------------------------------- - * Function: H5HF__man_get_obj_off - * - * Purpose: Get the offset of a managed heap object - * - * Return: SUCCEED (Can't fail) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Aug 20 2015 - * - *------------------------------------------------------------------------- - */ -void -H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, hsize_t *obj_off_p) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* - * Check arguments. - */ - HDassert(hdr); - HDassert(id); - HDassert(obj_off_p); - - /* Skip over the flag byte */ - id++; - - /* Skip over object offset */ - UINT64DECODE_VAR(id, *obj_off_p, hdr->heap_off_size); - - FUNC_LEAVE_NOAPI_VOID -} /* end H5HF__man_get_obj_off() */ - - -/*------------------------------------------------------------------------- * Function: H5HF_man_op_real * * Purpose: Internal routine to perform an operation on a managed heap diff --git a/src/H5HFpkg.h b/src/H5HFpkg.h index 78edfe6..cb5488b 100644 --- a/src/H5HFpkg.h +++ b/src/H5HFpkg.h @@ -717,8 +717,6 @@ H5_DLL herr_t H5HF_man_insert(H5HF_hdr_t *fh, hid_t dxpl_id, size_t obj_size, const void *obj, void *id); H5_DLL herr_t H5HF_man_get_obj_len(H5HF_hdr_t *hdr, const uint8_t *id, size_t *obj_len_p); -H5_DLL void H5HF__man_get_obj_off(const H5HF_hdr_t *hdr, const uint8_t *id, - hsize_t *obj_off_p); H5_DLL herr_t H5HF_man_read(H5HF_hdr_t *fh, hid_t dxpl_id, const uint8_t *id, void *obj); H5_DLL herr_t H5HF_man_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, @@ -733,8 +731,6 @@ H5_DLL herr_t H5HF_huge_insert(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t obj_size, void *obj, void *id); H5_DLL herr_t H5HF_huge_get_obj_len(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, size_t *obj_len_p); -H5_DLL herr_t H5HF__huge_get_obj_off(H5HF_hdr_t *hdr, hid_t dxpl_id, - const uint8_t *id, hsize_t *obj_off_p); H5_DLL herr_t H5HF_huge_read(H5HF_hdr_t *fh, hid_t dxpl_id, const uint8_t *id, void *obj); H5_DLL herr_t H5HF_huge_write(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *id, @@ -767,7 +763,7 @@ H5_DLL herr_t H5HF_tiny_remove(H5HF_hdr_t *fh, const uint8_t *id); /* Debugging routines for dumping file structures */ H5_DLL void H5HF_hdr_print(const H5HF_hdr_t *hdr, hid_t dxpl_id, - hbool_t dump_internal, FILE *stream, int indent, int fwidth); + hbool_t dump_internal, FILE *stream, int indent, int fwidth); H5_DLL herr_t H5HF_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth); H5_DLL herr_t H5HF_dblock_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, diff --git a/src/H5HFprivate.h b/src/H5HFprivate.h index c052143..a32f21f 100644 --- a/src/H5HFprivate.h +++ b/src/H5HFprivate.h @@ -116,8 +116,6 @@ H5_DLL herr_t H5HF_insert(H5HF_t *fh, hid_t dxpl_id, size_t size, const void *obj, void *id/*out*/); H5_DLL herr_t H5HF_get_obj_len(H5HF_t *fh, hid_t dxpl_id, const void *id, size_t *obj_len_p/*out*/); -H5_DLL herr_t H5HF_get_obj_off(H5HF_t *fh, hid_t dxpl_id, const void *_id, - hsize_t *obj_off_p/*out*/); H5_DLL herr_t H5HF_read(H5HF_t *fh, hid_t dxpl_id, const void *id, void *obj/*out*/); H5_DLL herr_t H5HF_write(H5HF_t *fh, hid_t dxpl_id, void *id, hbool_t *id_changed, @@ -135,8 +133,6 @@ H5_DLL herr_t H5HF_stat_info(const H5HF_t *fh, H5HF_stat_t *stats); H5_DLL herr_t H5HF_size(const H5HF_t *fh, hid_t dxpl_id, hsize_t *heap_size/*out*/); /* Debugging routines */ -H5_DLL herr_t H5HF_id_print(H5HF_t *fh, hid_t dxpl_id, - const void *id, FILE *stream, int indent, int fwidth); #ifdef H5HF_DEBUGGING H5_DLL herr_t H5HF_sects_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int fwidth); diff --git a/src/H5Odbg.c b/src/H5Odbg.c index bd789c5..0388cd5 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -454,15 +454,12 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i if(oh->mesg[i].flags) { hbool_t flag_printed = FALSE; - /* Sanity check that all flags in format are covered below */ - HDcompile_assert(H5O_MSG_FLAG_BITS == (H5O_MSG_FLAG_CONSTANT|H5O_MSG_FLAG_SHARED|H5O_MSG_FLAG_DONTSHARE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE|H5O_MSG_FLAG_MARK_IF_UNKNOWN|H5O_MSG_FLAG_WAS_UNKNOWN|H5O_MSG_FLAG_SHAREABLE|H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS)); - - if(oh->mesg[i].flags & H5O_MSG_FLAG_CONSTANT) { - HDfprintf(stream, "%sC", (flag_printed ? ", " : "<")); + if(oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) { + HDfprintf(stream, "mesg[i].flags & H5O_MSG_FLAG_SHARED) { - HDfprintf(stream, "%sS", (flag_printed ? ", " : "<")); + if(oh->mesg[i].flags & H5O_MSG_FLAG_CONSTANT) { + HDfprintf(stream, "%sC", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ if(oh->mesg[i].flags & H5O_MSG_FLAG_DONTSHARE) { @@ -470,7 +467,7 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i flag_printed = TRUE; } /* end if */ if(oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_AND_OPEN_FOR_WRITE) { - HDfprintf(stream, "%sFIUW", (flag_printed ? ", " : "<")); + HDfprintf(stream, "%sFIU", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ if(oh->mesg[i].flags & H5O_MSG_FLAG_MARK_IF_UNKNOWN) { @@ -482,14 +479,6 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i HDfprintf(stream, "%sWU", (flag_printed ? ", " : "<")); flag_printed = TRUE; } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_SHAREABLE) { - HDfprintf(stream, "%sSA", (flag_printed ? ", " : "<")); - flag_printed = TRUE; - } /* end if */ - if(oh->mesg[i].flags & H5O_MSG_FLAG_FAIL_IF_UNKNOWN_ALWAYS) { - HDfprintf(stream, "%sFIUA", (flag_printed ? ", " : "<")); - flag_printed = TRUE; - } /* end if */ if(!flag_printed) HDfprintf(stream, "-"); HDfprintf(stream, ">\n"); diff --git a/src/H5Olink.c b/src/H5Olink.c index 7e70196..53191ca 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -834,7 +834,7 @@ H5O_link_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Link Name Character Set:", (lnk->cset == H5T_CSET_ASCII ? "ASCII" : (lnk->cset == H5T_CSET_UTF8 ? "UTF-8" : "Unknown"))); - HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Link Name:", lnk->name); /* Display link-specific information */ @@ -845,7 +845,7 @@ H5O_link_debug(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void break; case H5L_TYPE_SOFT: - HDfprintf(stream, "%*s%-*s '%s'\n", indent, "", fwidth, + HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "Link Value:", lnk->u.soft.name); break; diff --git a/src/H5SM.c b/src/H5SM.c index e2a02af..730f4b1 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -2580,15 +2580,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5SM_list_debug(H5F_t *f, hid_t dxpl_id, haddr_t list_addr, FILE *stream, - int indent, int fwidth, haddr_t table_addr) +H5SM_list_debug(H5F_t *f, hid_t dxpl_id, haddr_t list_addr, + FILE *stream, int indent, int fwidth, + unsigned table_vers, size_t num_messages) { - H5SM_master_table_t *table = NULL; /* SOHM master table */ + H5SM_list_t *list = NULL; /* SOHM index list for message type (if in list form) */ - H5SM_list_cache_ud_t lst_cache_udata; /* List user-data for metadata cache callback */ - H5SM_table_cache_ud_t tbl_cache_udata; /* Table user-data for metadata cache callback */ - H5HF_t *fh = NULL; /* Fractal heap for SOHM messages */ - unsigned index_num; /* Index of list, within master table */ + H5SM_index_header_t header; /* A "false" header used to read the list */ + H5SM_list_cache_ud_t cache_udata; /* User-data for metadata cache callback */ unsigned x; /* Counter variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2600,51 +2599,36 @@ H5SM_list_debug(H5F_t *f, hid_t dxpl_id, haddr_t list_addr, FILE *stream, HDassert(indent >= 0); HDassert(fwidth >= 0); - /* Set up user data for callback */ - tbl_cache_udata.f = f; - - /* Look up the master SOHM table */ - if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, table_addr, &tbl_cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table") + /* Check arguments. Version must be 0, the only version implemented so far */ + if(table_vers > H5SM_LIST_VERSION) + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "unknown shared message list version") + if(num_messages == 0 || num_messages > H5O_SHMESG_MAX_LIST_SIZE) + HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES") - /* Determine which index the list is part of */ - index_num = table->num_indexes; - for(x = 0; x < table->num_indexes; x++) { - if(H5F_addr_eq(table->indexes[x].index_addr, list_addr)) { - index_num = x; - break; - } /* end if */ - } /* end for */ - if(x == table->num_indexes) - HGOTO_ERROR(H5E_SOHM, H5E_BADVALUE, FAIL, "list address doesn't match address for any indices in table") + /* Create a temporary header using the arguments. The cache needs this to load the list. */ + HDmemset(&header, 0, sizeof(H5SM_index_header_t)); + header.list_max = header.num_messages = num_messages; + header.index_type = H5SM_LIST; + header.index_addr = list_addr; /* Set up user data for metadata cache callback */ - lst_cache_udata.f = f; - lst_cache_udata.header = &(table->indexes[index_num]); + cache_udata.f = f; + cache_udata.header = &header; /* Get the list from the cache */ - if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, list_addr, &lst_cache_udata, H5AC__READ_ONLY_FLAG))) + if(NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, list_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_SOHM, H5E_CANTPROTECT, FAIL, "unable to load SOHM index") - /* Open the heap, if one exists */ - if(H5F_addr_defined(table->indexes[index_num].heap_addr)) - if(NULL == (fh = H5HF_open(f, dxpl_id, table->indexes[index_num].heap_addr))) - HGOTO_ERROR(H5E_SOHM, H5E_CANTOPENOBJ, FAIL, "unable to open SOHM heap") - HDfprintf(stream, "%*sShared Message List Index...\n", indent, ""); - for(x = 0; x < table->indexes[index_num].num_messages; ++x) { + for(x = 0; x < num_messages; ++x) { HDfprintf(stream, "%*sShared Object Header Message %d...\n", indent, "", x); HDfprintf(stream, "%*s%-*s %08lu\n", indent + 3, "", fwidth, "Hash value:", (unsigned long)list->messages[x].hash); if(list->messages[x].location == H5SM_IN_HEAP) { - HDassert(fh); - HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth, "Location:", "in heap"); - HDfprintf(stream, "%*s%-*s 0x%Zx\n", indent + 3, "", fwidth, + HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, "Heap ID:", list->messages[x].u.heap_loc.fheap_id); -H5HF_id_print(fh, dxpl_id, - &(list->messages[x].u.heap_loc.fheap_id), stream, indent + 6, (fwidth - 3)); HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth, "Reference count:", list->messages[x].u.heap_loc.ref_count); } /* end if */ @@ -2664,12 +2648,8 @@ H5HF_id_print(fh, dxpl_id, } /* end for */ done: - if(fh && H5HF_close(fh, dxpl_id) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close SOHM heap") if(list && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_LIST, list_addr, list, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index") - if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM master table") FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) } /* end H5SM_list_debug() */ diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index 7706cbd..e18e9fb 100644 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -48,8 +48,9 @@ static void *H5SM_bt2_crt_context(void *udata); static herr_t H5SM_bt2_dst_context(void *ctx); static herr_t H5SM_bt2_store(void *native, const void *udata); -static herr_t H5SM_bt2_debug(FILE *stream, int indent, int fwidth, - const void *record); +static herr_t H5SM_bt2_debug(FILE *stream, const H5F_t *f, hid_t dxpl_id, + int indent, int fwidth, const void *record, const void *_udata); +static void *H5SM_bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); /*****************************/ @@ -66,7 +67,9 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ H5SM_message_compare, /* Record comparison callback */ H5SM_message_encode, /* Record encoding callback */ H5SM_message_decode, /* Record decoding callback */ - H5SM_bt2_debug /* Record debugging callback */ + H5SM_bt2_debug, /* Record debugging callback */ + H5SM_bt2_crt_dbg_context, /* Create debugging context */ + H5SM_bt2_dst_context /* Destroy debugging context */ }}; @@ -192,7 +195,8 @@ H5SM_bt2_store(void *native, const void *udata) *------------------------------------------------------------------------- */ static herr_t -H5SM_bt2_debug(FILE *stream, int indent, int fwidth, const void *record) +H5SM_bt2_debug(FILE *stream, const H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + int indent, int fwidth, const void *record, const void H5_ATTR_UNUSED *_udata) { const H5SM_sohm_t *sohm = (const H5SM_sohm_t *)record; @@ -214,6 +218,45 @@ H5SM_bt2_debug(FILE *stream, int indent, int fwidth, const void *record) /*------------------------------------------------------------------------- + * Function: H5SM_bt2_crt_dbg_context + * + * Purpose: Create context for debugging callback + * + * Return: Success: non-NULL + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, December 1, 2009 + * + *------------------------------------------------------------------------- + */ +static void * +H5SM_bt2_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) +{ + H5SM_bt2_ctx_t *ctx; /* Callback context structure */ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity check */ + HDassert(f); + + /* Allocate callback context */ + if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") + + /* Determine the size of addresses & lengths in the file */ + ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); + + /* Set return value */ + ret_value = ctx; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5SM_bt2_crt_dbg_context() */ + + +/*------------------------------------------------------------------------- * Function: H5SM_bt2_convert_to_list_op * * Purpose: An H5B2_remove_t callback function to convert a SOHM diff --git a/src/H5SMprivate.h b/src/H5SMprivate.h index 57afacf..d072434 100644 --- a/src/H5SMprivate.h +++ b/src/H5SMprivate.h @@ -74,7 +74,7 @@ H5_DLL herr_t H5SM_table_debug(H5F_t *f, hid_t dxpl_id, haddr_t table_addr, FILE *stream, int indent, int fwidth, unsigned table_vers, unsigned num_indexes); H5_DLL herr_t H5SM_list_debug(H5F_t *f, hid_t dxpl_id, haddr_t list_addr, - FILE *stream, int indent, int fwidth, haddr_t table_addr); + FILE *stream, int indent, int fwidth, unsigned list_vers, size_t num_messages); #endif /*_H5SMprivate_H*/ diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c index e751bb3..ffaa5a5 100644 --- a/tools/misc/h5debug.c +++ b/tools/misc/h5debug.c @@ -379,11 +379,11 @@ main(int argc, char *argv[]) /* Build array of chunk dimensions */ ndims = (unsigned)extra; - dim[0] = (uint32_t)extra2; + dim[0] = extra2; if(ndims > 1) - dim[1] = (uint32_t)extra3; + dim[1] = extra3; if(ndims > 2) - dim[2] = (uint32_t)extra4; + dim[2] = extra4; /* Check for dimension error */ if(ndims > 3) { @@ -550,14 +550,14 @@ main(int argc, char *argv[]) */ /* Check for enough valid parameters */ - if(extra == 0) { - HDfprintf(stderr, "ERROR: Need shared message header address in order to shared message list\n"); + if(extra2 == 0) { + HDfprintf(stderr, "ERROR: Need list format version and number of messages in order to shared message list\n"); HDfprintf(stderr, "Shared message list usage:\n"); - HDfprintf(stderr, "\th5debug \n"); + HDfprintf(stderr, "\th5debug \n"); HDexit(4); } /* end if */ - status = H5SM_list_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, (haddr_t)extra); + status = H5SM_list_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, (unsigned) extra, (size_t) extra2); } else if(!HDmemcmp(sig, H5EA_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* -- cgit v0.12