[svn-r13159] Added h5debug support for shared message structures.

Tests run on juniper, kagiso, smirom.  h5debug run manually on sample files on
Windows, juniper, and kagiso.
This commit is contained in:
James Laird 2007-01-19 13:51:03 -05:00
parent ff572efab7
commit 632773727c
8 changed files with 215 additions and 7 deletions

View File

@ -130,7 +130,8 @@ H5B2_hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
(shared->type->id == H5B2_FHEAP_HUGE_FILT_INDIR_ID ? "H5B2_FHEAP_HUGE_FILT_INDIR_ID" :
(shared->type->id == H5B2_FHEAP_HUGE_DIR_ID ? "H5B2_FHEAP_HUGE_DIR_ID" :
(shared->type->id == H5B2_FHEAP_HUGE_FILT_DIR_ID ? "H5B2_FHEAP_HUGE_FILT_DIR_ID" :
"Unknown!"))))));
(shared->type->id == H5B2_SOHM_INDEX_ID ? "H5B2_SOHM_INDEX_ID" :
"Unknown!")))))));
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Size of node:",
shared->node_size);
@ -251,7 +252,8 @@ H5B2_int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
(shared->type->id == H5B2_FHEAP_HUGE_FILT_INDIR_ID ? "H5B2_FHEAP_HUGE_FILT_INDIR_ID" :
(shared->type->id == H5B2_FHEAP_HUGE_DIR_ID ? "H5B2_FHEAP_HUGE_DIR_ID" :
(shared->type->id == H5B2_FHEAP_HUGE_FILT_DIR_ID ? "H5B2_FHEAP_HUGE_FILT_DIR_ID" :
"Unknown!"))))));
(shared->type->id == H5B2_SOHM_INDEX_ID ? "H5B2_SOHM_INDEX_ID" :
"Unknown!")))))));
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Size of node:",
shared->node_size);
@ -372,7 +374,8 @@ H5B2_leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
(shared->type->id == H5B2_FHEAP_HUGE_FILT_INDIR_ID ? "H5B2_FHEAP_HUGE_FILT_INDIR_ID" :
(shared->type->id == H5B2_FHEAP_HUGE_DIR_ID ? "H5B2_FHEAP_HUGE_DIR_ID" :
(shared->type->id == H5B2_FHEAP_HUGE_FILT_DIR_ID ? "H5B2_FHEAP_HUGE_FILT_DIR_ID" :
"Unknown!"))))));
(shared->type->id == H5B2_SOHM_INDEX_ID ? "H5B2_SOHM_INDEX_ID" :
"Unknown!")))))));
HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth,
"Size of node:",
shared->node_size);

View File

@ -748,7 +748,7 @@ H5O_shared_debug (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
if(mesg->flags & H5O_COMMITTED_FLAG)
{
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Sharing method",
"Sharing method:",
"Obj Hdr");
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"Object address:",
@ -757,7 +757,7 @@ H5O_shared_debug (H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const void *_mesg,
else
{
HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Sharing method",
"Sharing method:",
"SOHM Heap");
HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth,
"Heap ID:",

View File

@ -1629,3 +1629,155 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5SM_get_refcount() */
/*-------------------------------------------------------------------------
* Function: H5SM_table_debug
*
* Purpose: Print debugging information for the master table.
*
* If table_vers and num_indexes are not UFAIL, they are used
* instead of the values in the superblock.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: James Laird
* Thursday, January 18, 2007
*
*-------------------------------------------------------------------------
*/
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)
{
H5SM_master_table_t *table = NULL; /* SOHM master table */
unsigned x; /* Counter variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5SM_table_debug, FAIL)
HDassert(f);
HDassert(table_addr != HADDR_UNDEF);
HDassert(stream);
HDassert(indent >= 0);
HDassert(fwidth >= 0);
/* If table_vers and num_indexes are UFAIL, replace them with values from
* userblock
*/
if(table_vers == UFAIL)
table_vers = f->shared->sohm_vers;
else if(table_vers = f->shared->sohm_vers)
HDfprintf(stream, "*** SOHM TABLE VERSION DOESN'T MATCH VERSION IN SUPERBLOCK!\n");
if(num_indexes == UFAIL)
num_indexes = f->shared->sohm_nindexes;
else if(num_indexes = f->shared->sohm_nindexes)
HDfprintf(stream, "*** NUMBER OF SOHM INDEXES DOESN'T MATCH VALUE IN SUPERBLOCK!\n");
/* Check arguments. Version must be 0, the only version implemented so far */
if(table_vers > HDF5_SHAREDHEADER_VERSION)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown shared message table version")
if(num_indexes == 0 || num_indexes > H5O_SHMESG_MAX_NINDEXES)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES")
/* Look up the master SOHM table */
if(NULL == (table = (H5SM_master_table_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_TABLE, table_addr, NULL, NULL, H5AC_READ)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM master table")
HDfprintf(stream, "%*sShared Message Master Table...\n", indent, "");
for(x=0; x<num_indexes; ++x) {
HDfprintf(stream, "%*sIndex %d...\n", indent, "", x);
HDfprintf(stream, "%*s%-*s %s\n", indent + 3, "", fwidth,
"SOHM Index Type:",
(table->indexes[x].index_type == H5SM_LIST ? "List" :
(table->indexes[x].index_type == H5SM_BTREE ? "B-Tree" : "Unknown")));
HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", fwidth,
"Address of index:", table->indexes[x].index_addr);
HDfprintf(stream, "%*s%-*s %a\n", indent + 3, "", fwidth,
"Address of index's heap:", table->indexes[x].heap_addr);
HDfprintf(stream, "%*s%-*s 0x%08x\n", indent + 3, "", fwidth,
"Message type flags:", table->indexes[x].mesg_types);
HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth,
"Minimum size of messages:", table->indexes[x].min_mesg_size);
HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth,
"Number of messages:", table->indexes[x].num_messages);
HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth,
"Maximum list size:", table->indexes[x].list_max);
HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth,
"Minimum B-tree size:", table->indexes[x].btree_min);
}
done:
if(table && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_TABLE, table_addr, table, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_CACHE, H5E_CANTRELEASE, FAIL, "unable to close SOHM master table")
FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
* Function: H5SM_list_debug
*
* Purpose: Print debugging information for a SOHM list.
*
* Relies on the list version and number of messages passed in.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: James Laird
* Thursday, January 18, 2007
*
*-------------------------------------------------------------------------
*/
herr_t
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_list_t *list = NULL; /* SOHM index list for message type (if in list form) */
H5SM_index_header_t header; /* A "false" header used to read the list */
unsigned x; /* Counter variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5SM_list_debug, FAIL)
HDassert(f);
HDassert(num_messages != HADDR_UNDEF);
HDassert(stream);
HDassert(indent >= 0);
HDassert(fwidth >= 0);
/* Check arguments. Version must be 0, the only version implemented so far */
if(table_vers > H5SM_LIST_VERSION)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unknown shared message list version")
if(num_messages == 0 || num_messages > H5O_SHMESG_MAX_LIST_SIZE)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "number of indexes must be between 1 and H5O_SHMESG_MAX_NINDEXES")
/* 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;
/* Get the list from the cache */
if (NULL == (list = (H5SM_list_t *)H5AC_protect(f, dxpl_id, H5AC_SOHM_LIST, list_addr, NULL, &header, H5AC_READ)))
HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "unable to load SOHM index")
HDfprintf(stream, "%*sShared Message List Index...\n", indent, "");
for(x=0; x<num_messages; ++x) {
HDfprintf(stream, "%*sShared Object Header Message %d...\n", indent, "", x);
HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth,
"Heap ID:", list->messages[x].fheap_id);
HDfprintf(stream, "%*s%-*s %Zu\n", indent + 3, "", fwidth, /* JAMES: better flag for this? */
"Hash value:", list->messages[x].hash);
HDfprintf(stream, "%*s%-*s %u\n", indent + 3, "", fwidth,
"Reference count:", list->messages[x].ref_count);
}
done:
if(list && H5AC_unprotect(f, dxpl_id, H5AC_SOHM_LIST, list_addr, list, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "unable to close SOHM index")
FUNC_LEAVE_NOAPI(ret_value)
}

View File

@ -264,7 +264,7 @@ H5SM_btree_debug(FILE *stream, const H5F_t UNUSED *f, hid_t UNUSED dxpl_id,
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5SM_btree_debug)
HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx}\n", indent, "", fwidth, "Record:",
HDfprintf(stream, "%*s%-*s {%a, %lo, %Hx}\n", indent, "", fwidth, "Shared Message:",
sohm->fheap_id, sohm->hash, sohm->ref_count);
FUNC_LEAVE_NOAPI(SUCCEED)

View File

@ -32,7 +32,6 @@
/****************/
/* Local Macros */
/****************/
#define H5SM_LIST_VERSION 0 /* Verion of Shared Object Header Message List Indexes */
/******************/
/* Local Typedefs */
@ -118,6 +117,11 @@ H5SM_flush_table(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5SM_ma
uint32_t computed_chksum; /* Computed metadata checksum value */
int x; /* Counter variable */
/* Verify that we're writing version 0 of the table; this is the only
* version defined so far.
*/
HDassert(f->shared->sohm_vers == HDF5_SHAREDHEADER_VERSION);
/* Encode the master table and all of the index headers as one big blob */
size = H5SM_TABLE_SIZE(f) + (H5SM_INDEX_HEADER_SIZE(f) * table->num_indexes);
@ -200,6 +204,11 @@ H5SM_load_table(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *udata1
FUNC_ENTER_NOAPI(H5SM_load_table, NULL)
/* Verify that we're reading version 0 of the table; this is the only
* version defined so far.
*/
HDassert(f->shared->sohm_vers == HDF5_SHAREDHEADER_VERSION);
/* Allocate space for the master table in memory */
if(NULL == (table = H5MM_calloc(sizeof(H5SM_master_table_t))))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")

View File

@ -60,6 +60,8 @@
#define H5SM_B2_SPLIT_PERCENT 100
#define H5SM_B2_MERGE_PERCENT 40
#define H5SM_LIST_VERSION 0 /* Verion of Shared Object Header Message List Indexes */
/****************************/
/* Package Typedefs */
/****************************/

View File

@ -45,5 +45,11 @@ H5_DLL herr_t H5SM_reconstitute(H5O_shared_t *sh_mesg, H5O_fheap_id_t heap_id);
H5_DLL herr_t H5SM_get_refcount(H5F_t *f, hid_t dxpl_id, unsigned type_id,
const H5O_shared_t *sh_mesg, hsize_t *ref_count);
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,
unsigned list_vers, size_t num_messages);
#endif /*_H5SMprivate_H*/

View File

@ -30,6 +30,7 @@
#define H5FS_PACKAGE /*suppress error about including H5FSpkg */
#define H5HF_PACKAGE /*suppress error about including H5HFpkg */
#define H5O_PACKAGE /*suppress error about including H5Opkg */
#define H5SM_PACKAGE /*suppress error about including H5SMpkg */
#include "H5private.h" /* Generic Functions */
#include "H5Bprivate.h" /* B-trees */
@ -45,6 +46,7 @@
#include "H5Iprivate.h" /* IDs */
#include "H5Opkg.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
#include "H5SMpkg.h" /* Implicitly shared messages */
/* File drivers */
#include "H5FDfamily.h"
@ -232,6 +234,10 @@ main(int argc, char *argv[])
status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_FILT_DIR);
break;
case H5B2_SOHM_INDEX_ID:
status = H5B2_hdr_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5SM_INDEX);
break;
default:
fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
HDexit(4);
@ -275,6 +281,10 @@ main(int argc, char *argv[])
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_SOHM_INDEX_ID:
status = H5B2_int_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5SM_INDEX, extra, (unsigned)extra2, (unsigned)extra3);
break;
default:
fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
HDexit(4);
@ -317,6 +327,10 @@ main(int argc, char *argv[])
status = H5B2_leaf_debug(f, H5P_DATASET_XFER_DEFAULT, addr, stdout, 0, VCOL, H5HF_BT2_FILT_DIR, 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;
default:
fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
HDexit(4);
@ -380,6 +394,28 @@ 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_TABLE_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_LIST_SIZEOF_MAGIC)) {
/*
* Debug shared message list index.
*/
/* Check for enough valid parameters */
if(extra2 == 0) {
fprintf(stderr, "ERROR: Need list format version and number of messages in order to shared message list\n");
fprintf(stderr, "Shared message list usage:\n");
fprintf(stderr, "\th5debug <filename> <shared message list address> <list format version> <number of mesages in list>\n");
HDexit(4);
} /* end if */
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)) {
/*
* Debug v2 object header (which have signatures).