1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group.                                               *
3  * Copyright by the Board of Trustees of the University of Illinois.         *
4  * All rights reserved.                                                      *
5  *                                                                           *
6  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
7  * terms governing use, modification, and redistribution, is contained in    *
8  * the COPYING file, which can be found at the root of the source code       *
9  * distribution tree, or in https://www.hdfgroup.org/licenses.               *
10  * If you do not have access to either file, you may request a copy from     *
11  * help@hdfgroup.org.                                                        *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /* Programmer:  Quincey Koziol
15  *              Wednesday, July 9, 2003
16  *
17  * Purpose:	File object debugging functions.
18  */
19 
20 #include "H5Fmodule.h" /* This source code file is part of the H5F module */
21 #define H5G_FRIEND     /*suppress error about including H5Gpkg   */
22 
23 #include "H5private.h"  /* Generic Functions			*/
24 #include "H5Eprivate.h" /* Error handling		        */
25 #include "H5Fpkg.h"     /* File access				*/
26 #include "H5Gpkg.h"     /* Groups		  		*/
27 #include "H5Iprivate.h" /* ID Functions		                */
28 #include "H5Pprivate.h" /* Property lists			*/
29 
30 /*-------------------------------------------------------------------------
31  * Function:	H5F_debug
32  *
33  * Purpose:	Prints a file header to the specified stream.  Each line
34  *		is indented and the field name occupies the specified width
35  *		number of characters.
36  *
37  * Return:	Non-negative on success/Negative on failure
38  *
39  * Programmer:	Robb Matzke
40  *		Aug  1 1997
41  *
42  *-------------------------------------------------------------------------
43  */
44 herr_t
H5F_debug(H5F_t * f,FILE * stream,int indent,int fwidth)45 H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth)
46 {
47     H5P_genplist_t *plist;               /* File creation property list */
48     hsize_t         userblock_size;      /* Userblock size */
49     herr_t          ret_value = SUCCEED; /* Return value */
50 
51     FUNC_ENTER_NOAPI(FAIL)
52 
53     /* check args */
54     HDassert(f);
55     HDassert(stream);
56     HDassert(indent >= 0);
57     HDassert(fwidth >= 0);
58 
59     /* Get property list */
60     if (NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
61         HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
62 
63     /* Retrieve file creation properties */
64     if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size) < 0)
65         HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get userblock size")
66 
67     /* debug */
68     HDfprintf(stream, "%*sFile Super Block...\n", indent, "");
69 
70     HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth, "File name (as opened):", H5F_OPEN_NAME(f));
71     HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
72               "File name (after resolving symlinks):", H5F_ACTUAL_NAME(f));
73     HDfprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, "File access flags", f->shared->flags);
74     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "File open reference count:", f->shared->nrefs);
75     HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (abs)\n", indent, "", fwidth,
76               "Address of super block:", f->shared->sblock->base_addr);
77     HDfprintf(stream, "%*s%-*s %" PRIuHSIZE " bytes\n", indent, "", fwidth,
78               "Size of userblock:", userblock_size);
79 
80     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
81               "Superblock version number:", f->shared->sblock->super_vers);
82 
83     /* Hard-wired versions */
84     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
85               "Free list version number:", (unsigned)HDF5_FREESPACE_VERSION);
86     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
87               "Root group symbol table entry version number:", (unsigned)HDF5_OBJECTDIR_VERSION);
88     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
89               "Shared header version number:", (unsigned)HDF5_SHAREDHEADER_VERSION);
90 
91     HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
92               "Size of file offsets (haddr_t type):", (unsigned)f->shared->sizeof_addr);
93     HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
94               "Size of file lengths (hsize_t type):", (unsigned)f->shared->sizeof_size);
95     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
96               "Symbol table leaf node 1/2 rank:", f->shared->sblock->sym_leaf_k);
97     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
98               "Symbol table internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_SNODE_ID]);
99     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
100               "Indexed storage internal node 1/2 rank:", f->shared->sblock->btree_k[H5B_CHUNK_ID]);
101     HDfprintf(stream, "%*s%-*s 0x%02x\n", indent, "", fwidth,
102               "File status flags:", (unsigned)(f->shared->sblock->status_flags));
103     HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (rel)\n", indent, "", fwidth,
104               "Superblock extension address:", f->shared->sblock->ext_addr);
105     HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (rel)\n", indent, "", fwidth,
106               "Shared object header message table address:", f->shared->sohm_addr);
107     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
108               "Shared object header message version number:", (unsigned)f->shared->sohm_vers);
109     HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
110               "Number of shared object header message indexes:", (unsigned)f->shared->sohm_nindexes);
111 
112     HDfprintf(stream, "%*s%-*s %" PRIuHADDR " (rel)\n", indent, "", fwidth,
113               "Address of driver information block:", f->shared->sblock->driver_addr);
114 
115     HDfprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
116               "Root group symbol table entry:", f->shared->root_grp ? "" : "(none)");
117     if (f->shared->root_grp) {
118         if (f->shared->sblock->root_ent) /* Use real root group symbol table entry */
119             H5G__ent_debug(f->shared->sblock->root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL);
120         else {
121             H5O_loc_t * root_oloc; /* Root object location */
122             H5G_entry_t root_ent;  /* Constructed root symbol table entry */
123 
124             /* Reset the root group entry */
125             H5G__ent_reset(&root_ent);
126 
127             /* Build up a simulated root group symbol table entry */
128             root_oloc = H5G_oloc(f->shared->root_grp);
129             HDassert(root_oloc);
130             root_ent.type   = H5G_NOTHING_CACHED;
131             root_ent.header = root_oloc->addr;
132 
133             /* Display root group symbol table entry info */
134             H5G__ent_debug(&root_ent, stream, indent + 3, MAX(0, fwidth - 3), NULL);
135         } /* end else */
136     }     /* end if */
137 
138 done:
139     FUNC_LEAVE_NOAPI(ret_value)
140 } /* end H5F_debug() */
141