summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-09-22 17:33:58 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-09-22 17:33:58 (GMT)
commit926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8 (patch)
treead06b825bd0d4dc30c88ab14dda1abe0c87f4ed5 /tools
parent531822d443296bfe74a76aed6c121ec8421508a5 (diff)
downloadhdf5-926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8.zip
hdf5-926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8.tar.gz
hdf5-926cfe52cc14c735e53709e8b8dc3bfc4d0f8dd8.tar.bz2
[svn-r15677] Description:
Bring r15676 back from trunk: Centralize all macros for declaring "magic numbers"/signatures for objects in the file into src/H5Fprivate.h, so it's easier to know what values have already been defined, etc. Tested on: Mac OS X/32 10.5.5 (amazon) Too minor to require h5committest
Diffstat (limited to 'tools')
-rw-r--r--tools/misc/h5debug.c269
1 files changed, 100 insertions, 169 deletions
diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c
index fa6d1ec..0f0e593 100644
--- a/tools/misc/h5debug.c
+++ b/tools/misc/h5debug.c
@@ -29,7 +29,6 @@
#define H5B2_PACKAGE /*suppress error about including H5B2pkg */
#define H5B2_TESTING /*suppress warning about H5B2 testing funcs*/
#define H5F_PACKAGE /*suppress error about including H5Fpkg */
-#define H5FS_PACKAGE /*suppress error about including H5FSpkg */
#define H5G_PACKAGE /*suppress error about including H5Gpkg */
#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
#define H5O_PACKAGE /*suppress error about including H5Opkg */
@@ -37,19 +36,16 @@
#include "H5private.h" /* Generic Functions */
#include "H5Apkg.h" /* Attributes */
-#include "H5Bprivate.h" /* B-trees */
#include "H5B2pkg.h" /* v2 B-trees */
#include "H5Dprivate.h" /* Datasets */
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
-#include "H5FSpkg.h" /* File free space */
+#include "H5FSprivate.h" /* Free space manager */
#include "H5Gpkg.h" /* Groups */
#include "H5HFpkg.h" /* Fractal heaps */
#include "H5HGprivate.h" /* Global Heaps */
-#include "H5HLprivate.h" /* Local Heaps */
#include "H5Iprivate.h" /* IDs */
#include "H5Opkg.h" /* Object headers */
-#include "H5Pprivate.h" /* Property lists */
#include "H5SMpkg.h" /* Implicitly shared messages */
/* File drivers */
@@ -60,6 +56,77 @@
/*-------------------------------------------------------------------------
+ * Function: get_H5B2_class
+ *
+ * Purpose: Determine the v2 B-tree class from the buffer read in.
+ * B-trees are debugged through the B-tree subclass. The subclass
+ * identifier is two bytes after the B-tree signature.
+ *
+ * Return: Non-NULL on success/NULL on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Sep 11 2008
+ *
+ *-------------------------------------------------------------------------
+ */
+static const H5B2_class_t *
+get_H5B2_class(const uint8_t *sig)
+{
+ H5B2_subid_t subtype = (H5B2_subid_t)sig[H5_SIZEOF_MAGIC + 1];
+ const H5B2_class_t *cls;
+
+ switch(subtype) {
+ case H5B2_TEST_ID:
+ cls = H5B2_TEST;
+ break;
+
+ case H5B2_FHEAP_HUGE_INDIR_ID:
+ cls = H5HF_BT2_INDIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
+ cls = H5HF_BT2_FILT_INDIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_DIR_ID:
+ cls = H5HF_BT2_DIR;
+ break;
+
+ case H5B2_FHEAP_HUGE_FILT_DIR_ID:
+ cls = H5HF_BT2_FILT_DIR;
+ break;
+
+ case H5B2_GRP_DENSE_NAME_ID:
+ cls = H5G_BT2_NAME;
+ break;
+
+ case H5B2_GRP_DENSE_CORDER_ID:
+ cls = H5G_BT2_CORDER;
+ break;
+
+ case H5B2_SOHM_INDEX_ID:
+ cls = H5SM_INDEX;
+ break;
+
+ case H5B2_ATTR_DENSE_NAME_ID:
+ cls = H5A_BT2_NAME;
+ break;
+
+ case H5B2_ATTR_DENSE_CORDER_ID:
+ cls = H5A_BT2_CORDER;
+ break;
+
+ default:
+ fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
+ HDexit(4);
+ } /* end switch */
+
+ return(cls);
+} /* end get_H5B2_class() */
+
+
+/*-------------------------------------------------------------------------
* Function: main
*
* Usage: debug FILENAME [OFFSET]
@@ -143,19 +210,19 @@ main(int argc, char *argv[])
*/
status = H5F_debug(f, stdout, 0, VCOL);
- } else if(!HDmemcmp(sig, H5HL_MAGIC, (size_t)H5HL_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a local heap.
*/
status = H5HL_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
- } else if(!HDmemcmp (sig, H5HG_MAGIC, (size_t)H5HG_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp (sig, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a global heap collection.
*/
status = H5HG_debug (f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
- } else if(!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5G_NODE_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a symbol table node.
*/
@@ -169,13 +236,13 @@ main(int argc, char *argv[])
status = H5G_node_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra);
- } else if(!HDmemcmp(sig, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5B_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a B-tree. B-trees are debugged through the B-tree
* subclass. The subclass identifier is the byte immediately
* after the B-tree signature.
*/
- H5B_subid_t subtype = (H5B_subid_t)sig[H5B_SIZEOF_MAGIC];
+ H5B_subid_t subtype = (H5B_subid_t)sig[H5_SIZEOF_MAGIC];
unsigned ndims;
switch(subtype) {
@@ -208,67 +275,20 @@ main(int argc, char *argv[])
HDexit(4);
}
- } else if(!HDmemcmp(sig, H5B2_HDR_MAGIC, (size_t)H5B2_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5B2_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a v2 B-tree. B-trees are debugged through the B-tree
- * subclass. The subclass identifier is two bytes after the
- * B-tree signature.
+ * Debug a v2 B-tree header.
*/
- H5B2_subid_t subtype = (H5B2_subid_t)sig[H5B2_SIZEOF_MAGIC+1];
-
- switch(subtype) {
- case H5B2_TEST_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST);
- break;
-
- case H5B2_FHEAP_HUGE_INDIR_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_INDIR);
- break;
-
- case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_FILT_INDIR);
- break;
-
- case H5B2_FHEAP_HUGE_DIR_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_DIR);
- break;
-
- case H5B2_FHEAP_HUGE_FILT_DIR_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_FILT_DIR);
- break;
-
- case H5B2_GRP_DENSE_NAME_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5G_BT2_NAME);
- break;
-
- case H5B2_GRP_DENSE_CORDER_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5G_BT2_CORDER);
- break;
-
- case H5B2_SOHM_INDEX_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5SM_INDEX);
- break;
-
- case H5B2_ATTR_DENSE_NAME_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5A_BT2_NAME);
- break;
-
- case H5B2_ATTR_DENSE_CORDER_ID:
- status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5A_BT2_CORDER);
- break;
-
- default:
- fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
- } /* end switch */
+ const H5B2_class_t *cls = get_H5B2_class(sig);
+ HDassert(cls);
+ status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls);
- } else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5B2_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5B2_INT_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a v2 B-tree. B-trees are debugged through the B-tree
- * subclass. The subclass identifier is the byte after the
- * B-tree signature.
+ * Debug a v2 B-tree internal node.
*/
- H5B2_subid_t subtype = (H5B2_subid_t)sig[H5B2_SIZEOF_MAGIC + 1];
+ const H5B2_class_t *cls = get_H5B2_class(sig);
+ HDassert(cls);
/* Check for enough valid parameters */
if(extra == 0 || extra2 == 0 || extra3 == 0) {
@@ -279,59 +299,14 @@ main(int argc, char *argv[])
HDexit(4);
} /* end if */
- switch(subtype) {
- case H5B2_TEST_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_FHEAP_HUGE_INDIR_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_INDIR, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_FILT_INDIR, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_FHEAP_HUGE_DIR_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_DIR, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_FHEAP_HUGE_FILT_DIR_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_FILT_DIR, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_GRP_DENSE_NAME_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5G_BT2_NAME, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_GRP_DENSE_CORDER_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5G_BT2_CORDER, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_SOHM_INDEX_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5SM_INDEX, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_ATTR_DENSE_NAME_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5A_BT2_NAME, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- case H5B2_ATTR_DENSE_CORDER_ID:
- status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5A_BT2_CORDER, extra, (unsigned)extra2, (unsigned)extra3);
- break;
-
- default:
- fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
- } /* end switch */
+ status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2, (unsigned)extra3);
- } else if(!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5B2_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5B2_LEAF_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
- * Debug a v2 B-tree. B-trees are debugged through the B-tree
- * subclass. The subclass identifier is the byte after the
- * B-tree signature.
+ * Debug a v2 B-tree leaf node.
*/
- H5B2_subid_t subtype = (H5B2_subid_t)sig[H5B2_SIZEOF_MAGIC + 1];
+ const H5B2_class_t *cls = get_H5B2_class(sig);
+ HDassert(cls);
/* Check for enough valid parameters */
if(extra == 0 || extra2 == 0) {
@@ -341,59 +316,15 @@ main(int argc, char *argv[])
HDexit(4);
} /* end if */
- switch(subtype) {
- case H5B2_TEST_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5B2_TEST, extra, (unsigned)extra2);
- break;
-
- case H5B2_FHEAP_HUGE_INDIR_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_INDIR, extra, (unsigned)extra2);
- break;
-
- case H5B2_FHEAP_HUGE_FILT_INDIR_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_FILT_INDIR, extra, (unsigned)extra2);
- break;
-
- case H5B2_FHEAP_HUGE_DIR_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_DIR, extra, (unsigned)extra2);
- break;
-
- case H5B2_FHEAP_HUGE_FILT_DIR_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_FILT_DIR, extra, (unsigned)extra2);
- break;
-
- case H5B2_GRP_DENSE_NAME_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5G_BT2_NAME, extra, (unsigned)extra2);
- break;
-
- case H5B2_GRP_DENSE_CORDER_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5G_BT2_CORDER, extra, (unsigned)extra2);
- break;
-
- case H5B2_SOHM_INDEX_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5SM_INDEX, extra, (unsigned)extra2);
- break;
-
- case H5B2_ATTR_DENSE_NAME_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5A_BT2_NAME, extra, (unsigned)extra2);
- break;
-
- case H5B2_ATTR_DENSE_CORDER_ID:
- status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5A_BT2_CORDER, extra, (unsigned)extra2);
- break;
-
- default:
- fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
- HDexit(4);
- } /* end switch */
+ status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, cls, extra, (unsigned)extra2);
- } else if(!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5HF_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a fractal heap header.
*/
status = H5HF_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
- } else if(!HDmemcmp(sig, H5HF_DBLOCK_MAGIC, (size_t)H5HF_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5HF_DBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a fractal heap direct block.
*/
@@ -408,7 +339,7 @@ main(int argc, char *argv[])
status = H5HF_dblock_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra, (size_t)extra2);
- } else if(!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5HF_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5HF_IBLOCK_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a fractal heap indirect block.
*/
@@ -423,14 +354,14 @@ main(int argc, char *argv[])
status = H5HF_iblock_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra, (unsigned)extra2);
- } else if(!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5FS_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5FS_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug a free space header.
*/
status = H5FS_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL);
- } else if(!HDmemcmp(sig, H5FS_SINFO_MAGIC, (size_t)H5FS_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5FS_SINFO_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug free space serialized sections.
*/
@@ -445,14 +376,14 @@ main(int argc, char *argv[])
status = H5FS_sects_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, extra, extra2);
- } else if(!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5SM_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5SM_TABLE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug shared message master table.
*/
status = H5SM_table_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, (unsigned) UFAIL, (unsigned) UFAIL);
- } else if(!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5SM_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5SM_LIST_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug shared message list index.
*/
@@ -467,7 +398,7 @@ main(int argc, char *argv[])
status = H5SM_list_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, (unsigned) extra, (size_t) extra2);
- } else if(!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5O_SIZEOF_MAGIC)) {
+ } else if(!HDmemcmp(sig, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
/*
* Debug v2 object header (which have signatures).
*/