summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib/h5tools_str.c')
-rw-r--r--tools/lib/h5tools_str.c267
1 files changed, 187 insertions, 80 deletions
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index c5759d8..23b7a0e 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -289,19 +289,27 @@ char *
h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx)
{
+ H5TOOLS_ERR_INIT(int, SUCCEED)
size_t i = 0;
hsize_t curr_pos = elmtno;
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims);
h5tools_str_reset(str);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ndims=%d", ndims);
if(ndims > 0) {
/*
* Calculate the number of elements represented by a unit change in a
* certain index position.
*/
for(i = 0; i < (size_t) ndims; i++) {
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "curr_pos=%ld - ctx->acc[%d]=%ld", curr_pos, i, ctx->acc[i]);
ctx->pos[i] = curr_pos / ctx->acc[i];
curr_pos -= ctx->acc[i] * ctx->pos[i];
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "curr_pos=%ld - ctx->pos[%d]=%ld - ctx->acc[%d]=%ld", curr_pos, i, ctx->pos[i], i, ctx->acc[i]);
}
HDassert(curr_pos == 0);
@@ -316,7 +324,11 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
}
}
else /* Scalar */
- h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t) 0);
+ h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t)elmtno);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "str=%s", str->s);
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
/* Add prefix and suffix to the index */
return h5tools_str_fmt(str, (size_t)0, OPT(info->idx_fmt, "%s: "));
@@ -672,6 +684,7 @@ char *
h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
hid_t type, void *vp, h5tools_context_t *ctx)
{
+ H5TOOLS_ERR_INIT(char*, NULL);
size_t nsize, offset, size=0, nelmts, start;
H5T_sign_t nsign;
char *name = NULL;
@@ -683,6 +696,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
H5T_str_t pad;
H5T_class_t type_class;
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
/* Build default formats for long long types */
if(!fmt_llong[0]) {
HDsnprintf(fmt_llong, sizeof(fmt_llong), "%%%sd", H5_PRINTF_LL_WIDTH);
@@ -711,6 +726,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
return NULL;
switch (type_class) {
case H5T_FLOAT:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_FLOAT");
if(sizeof(float) == nsize) {
/* if (H5Tequal(type, H5T_NATIVE_FLOAT)) */
float tempfloat;
@@ -742,6 +758,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
char quote = '\0';
char *s;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_STRING");
quote = '\0';
if(H5Tis_variable_str(type)) {
/* cp_vp is the pointer into the struct where a `char*' is stored. So we have
@@ -814,6 +831,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
break;
case H5T_INTEGER:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_INTEGER");
if(sizeof(char) == nsize) {
if(info->ascii)
h5tools_print_char(str, info, (char) (*ucp_vp));
@@ -951,6 +969,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
break;
case H5T_COMPOUND:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_COMPOUND");
if(ctx->cmpd_listv) { /* there is <list_of_fields> */
unsigned save_indent_level; /* The indentation level */
size_t curr_field; /* Current field to display */
@@ -1052,6 +1071,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
{
char enum_name[1024];
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_ENUM");
if(H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0)
h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name)));
else {
@@ -1066,61 +1086,119 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
break;
case H5T_REFERENCE:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE");
if(h5tools_str_is_zero(vp, nsize))
h5tools_str_append(str, "NULL");
else {
- if(nsize == H5R_DSET_REG_REF_BUF_SIZE) {
- /* if (H5Tequal(type, H5T_STD_REF_DSETREG)) */
- h5tools_str_sprint_region(str, info, container, vp);
+ if (H5Tequal(type, H5T_STD_REF)) {
+ char *obj_name = NULL;
+ H5O_type_t obj_type; /* Object type */
+ H5R_type_t ref_type; /* Reference type */
+ const H5R_ref_t *ref_vp = (const H5R_ref_t *)vp;
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE:H5T_STD_REF");
+ ref_type = H5Rget_type(ref_vp);
+ H5Rget_obj_type3(ref_vp, H5P_DEFAULT, &obj_type);
+ switch (ref_type) {
+ case H5R_OBJECT1:
+ {
+ /* Object references -- show the type and OID of the referenced object. */
+ H5O_info_t oi;
+
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_OBJECT1");
+ if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ H5Oget_info2(obj, &oi, H5O_INFO_BASIC);
+ if(H5Oclose(obj) < 0)
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g,
+ "H5Oclose H5R_OBJECT1 failed");
+ }
+ else
+ H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g,
+ "H5Ropen_object H5R_OBJECT1 failed");
+
+ /* Print object type and close object */
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_DATATYPE);
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ h5tools_str_append(str, "%u-", (unsigned) oi.type);
+ break;
+ } /* end switch */
+ H5Oclose(obj);
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+
+ /* Print OID */
+ if(info->obj_hidefileno)
+ h5tools_str_append(str, info->obj_format, oi.addr);
+ else
+ h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
+ }
+ break;
+ case H5R_DATASET_REGION1:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_DATASET_REGION1");
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+ break;
+ case H5R_OBJECT2:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_OBJECT2");
+ switch (obj_type) {
+ case H5O_TYPE_GROUP:
+ h5tools_str_append(str, H5_TOOLS_GROUP);
+ break;
+
+ case H5O_TYPE_DATASET:
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ break;
+
+ case H5O_TYPE_NAMED_DATATYPE:
+ h5tools_str_append(str, H5_TOOLS_DATATYPE);
+ break;
+
+ case H5O_TYPE_MAP:
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ default:
+ break;
+ } /* end switch */
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+ break;
+ case H5R_DATASET_REGION2:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_DATASET_REGION2");
+ h5tools_str_append(str, H5_TOOLS_DATASET);
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+ break;
+ case H5R_ATTR:
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "ref_type is H5R_ATTR");
+ h5tools_str_append(str, H5_TOOLS_ATTRIBUTE);
+ h5tools_str_sprint_reference(str, info, container, ref_vp);
+ break;
+ case H5R_BADTYPE:
+ case H5R_MAXTYPE:
+ default:
+ break;
+ } /* end switch */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE:H5T_STD_REF end");
}
- else if (nsize == H5R_OBJ_REF_BUF_SIZE) {
- /* if (H5Tequal(type, H5T_STD_REF_OBJ)) */
- /*
- * Object references -- show the type and OID of the referenced
- * object.
- */
- H5O_info_t oi;
- const char *path;
-
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, vp);
- H5Oget_info2(obj, &oi, H5O_INFO_BASIC);
-
- /* Print object type and close object */
- switch(oi.type) {
- case H5O_TYPE_GROUP:
- h5tools_str_append(str, H5_TOOLS_GROUP);
- break;
-
- case H5O_TYPE_DATASET:
- h5tools_str_append(str, H5_TOOLS_DATASET);
- break;
-
- case H5O_TYPE_NAMED_DATATYPE:
- h5tools_str_append(str, H5_TOOLS_DATATYPE);
- break;
-
- case H5O_TYPE_MAP:
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- default:
- h5tools_str_append(str, "%u-", (unsigned) oi.type);
- break;
- } /* end switch */
- H5Oclose(obj);
-
- /* Print OID */
- if(info->obj_hidefileno)
- h5tools_str_append(str, info->obj_format, oi.addr);
- else
- h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
-
- /* Print name */
- path = lookup_ref_path(*(haddr_t *) vp);
- if(path) {
- h5tools_str_append(str, " ");
- h5tools_str_append(str, path);
- h5tools_str_append(str, " ");
- } /* end if */
+ else if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
+ /* if(nsize == H5R_DSET_REG_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE:H5T_STD_REF_DSETREG");
+ }
+ else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
+ /* if (nsize == H5R_OBJ_REF_BUF_SIZE) */
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_REFERENCE:H5T_STD_REF_OBJ");
} /* end else if (H5Tequal(type, H5T_STD_REF_OBJ)) */
}
break;
@@ -1131,6 +1209,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
hsize_t i, dims[H5S_MAX_RANK], temp_nelmts;
static int is_next_arry_elmt = 0;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_ARRAY");
/* Get the array's base datatype for each element */
memb = H5Tget_super(type);
size = H5Tget_size(memb);
@@ -1192,6 +1271,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
{
unsigned int i;
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5T_VLEN");
/* Get the VL sequences's base datatype for each element */
memb = H5Tget_super(type);
size = H5Tget_size(memb);
@@ -1238,6 +1318,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
case H5T_BITFIELD:
case H5T_OPAQUE:
{
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "OTHER");
/* All other types get printed as hexadecimal */
size_t i;
if(1 == nsize)
@@ -1255,49 +1336,75 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
break;
} /* end switch */
}
- return h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
+CATCH
+ ret_value = h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
+
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit with %s", ret_value);
+ H5TOOLS_POP_STACK();
+ return ret_value;
}
/*-------------------------------------------------------------------------
- * Function: h5tools_str_sprint_region
+ * Function: h5tools_str_sprint_reference
*
- * Purpose: Dataset region reference -- show the type and data of the referenced object.
+ * Purpose: Object reference -- show the name of the referenced object.
*
* Return: Nothing
*-------------------------------------------------------------------------
*/
void
-h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info,
- hid_t container, void *vp)
+h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info,
+ hid_t container, H5R_ref_t *ref_vp)
{
- hid_t obj = -1;
- hid_t region = -1;
- char ref_name[1024];
- H5S_sel_type region_type;
-
- obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, vp);
- if(obj >= 0) {
- region = H5Rget_region(container, H5R_DATASET_REGION, vp);
- if(region >= 0) {
- H5Rget_name(obj, H5R_DATASET_REGION, vp, (char*) ref_name, 1024);
-
- h5tools_str_append(str, info->dset_format, ref_name);
+ H5TOOLS_ERR_INIT(int, SUCCEED);
+ ssize_t buf_size, status;
+
+ H5TOOLS_PUSH_STACK();
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "enter");
+
+ h5tools_str_append(str, " ");
+ buf_size = H5Rget_file_name(ref_vp, NULL, 0);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *file_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ status = H5Rget_file_name(ref_vp, file_name, buf_size + 1);
+ file_name[buf_size] = '\0';
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "name=%s", file_name);
+
+ h5tools_str_append(str, "%s", file_name);
+ HDfree(file_name);
+ }
- h5tools_str_append(str, "{");
+ buf_size = H5Rget_obj_name(ref_vp, H5P_DEFAULT, NULL, 0);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *obj_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ status = H5Rget_obj_name(ref_vp, H5P_DEFAULT, obj_name, buf_size + 1);
+ obj_name[buf_size] = '\0';
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "name=%s", obj_name);
- region_type = H5Sget_select_type(region);
- if(region_type==H5S_SEL_POINTS)
- h5tools_str_dump_space_points(str, region, info);
- else
- h5tools_str_dump_space_blocks(str, region, info);
+ h5tools_str_append(str, "%s", obj_name);
+ HDfree(obj_name);
+ }
- h5tools_str_append(str, "}");
+ if (H5Rget_type(ref_vp) == H5R_ATTR) {
+ buf_size = H5Rget_attr_name(ref_vp, NULL, 0);
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "buf_size=%ld", buf_size);
+ if (buf_size) {
+ char *attr_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
+ status = H5Rget_attr_name(ref_vp, attr_name, buf_size + 1);
+ attr_name[buf_size] = '\0';
+ H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "name=%s", attr_name);
+
+ h5tools_str_append(str, "/%s", attr_name);
+ HDfree(attr_name);
+ }
+ }
- H5Sclose(region);
- } /* end if (region >= 0) */
- H5Dclose(obj);
- } /* end if (obj >= 0) */
+CATCH
+ H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit");
+ H5TOOLS_POP_STACK();
}
/*-------------------------------------------------------------------------