1997-08-05 00:19:57 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Copyright (C) 1997 National Center for Supercomputing Applications.
|
1997-08-05 00:19:57 +08:00
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Created: debug.c
|
|
|
|
|
* Jul 18 1997
|
|
|
|
|
* Robb Matzke <matzke@llnl.gov>
|
1997-08-05 00:19:57 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Purpose: Debugs an existing HDF5 file at a low level.
|
1997-08-05 00:19:57 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Modifications:
|
1997-08-05 00:19:57 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
1997-08-16 00:51:34 +08:00
|
|
|
|
#include <H5private.h>
|
1998-03-18 06:46:27 +08:00
|
|
|
|
#include <H5Iprivate.h>
|
1997-08-16 00:51:34 +08:00
|
|
|
|
#include <H5Bprivate.h>
|
1998-02-26 03:13:49 +08:00
|
|
|
|
#include <H5Pprivate.h>
|
1997-08-16 00:51:34 +08:00
|
|
|
|
#include <H5Fprivate.h>
|
|
|
|
|
#include <H5Gprivate.h>
|
1998-03-31 03:24:08 +08:00
|
|
|
|
#include <H5HGprivate.h>
|
|
|
|
|
#include <H5HLprivate.h>
|
1997-08-16 00:51:34 +08:00
|
|
|
|
#include <H5Oprivate.h>
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
#define INDENT 3
|
|
|
|
|
#define VCOL 50
|
1998-04-18 05:29:43 +08:00
|
|
|
|
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Function: main
|
1997-08-05 00:19:57 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Usage: debug FILENAME [OFFSET]
|
1997-08-05 00:19:57 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Return: Success: exit (0)
|
1997-08-05 00:19:57 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Failure: exit (non-zero)
|
1997-08-05 00:19:57 +08:00
|
|
|
|
*
|
1998-01-17 06:23:43 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
|
|
|
|
* matzke@llnl.gov
|
|
|
|
|
* Jul 18 1997
|
1997-08-05 00:19:57 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
int
|
1998-01-17 06:23:43 +08:00
|
|
|
|
main(int argc, char *argv[])
|
1997-08-05 00:19:57 +08:00
|
|
|
|
{
|
1998-11-19 02:40:09 +08:00
|
|
|
|
hid_t fid, plist=H5P_DEFAULT;
|
|
|
|
|
H5F_t *f;
|
|
|
|
|
haddr_t addr;
|
|
|
|
|
uint8_t sig[16];
|
|
|
|
|
intn i, ndims;
|
|
|
|
|
herr_t status = SUCCEED;
|
|
|
|
|
haddr_t extra;
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/*
|
|
|
|
|
* Open the file and get the file descriptor.
|
|
|
|
|
*/
|
1998-04-09 05:43:02 +08:00
|
|
|
|
if (strchr (argv[1], '%')) {
|
|
|
|
|
plist = H5Pcreate (H5P_FILE_ACCESS);
|
[svn-r339] Changes since 19980408
----------------------
./src/H5Osdspace.c
./html/H5.format.html
In the past we were allowed to have >2GB files on a 32-bit
machine as long as no dataset within the file was larger than
4GB (or whatever sizeof(size_t) is). That's been fixed now.
All dataset size calculations are done with `hsize_t' which is
normally defined as `unsigned long long'.
./src/H5F.c
./src/H5Ffamily.c
./src/H5Fprivate.h
./src/H5P.c
./src/H5Ppublic.h
The file family member size can now be set/queried. The
default is still 64MB, but it can be set to 1GB by saying:
H5Pset_family (plist, 30, H5P_DEFAULT);
When opening an existing file family the specified
bits-per-member is ignored and the first member of the family
determines the bits-per-member, which can be retrieved with
H5Pget_family().
./acconfig.h
./configure.in
./src/H5config.h
./src/H5public.h
Added `--disable-hsizet' so that those with old GCC compilers
(<2.8.1) can still compile the code.
./src/H5.c
./src/H5private.h
Added HDfprintf() which works just like fprintf() except you
can give `H' as a size modifier for the integer conversions
and supply an `hsize_t' or `hssize_t' argument without casting
it. For instance:
hsize_t npoints = H5Sget_npoints(space);
HDfprintf(stdout,"Dataset has %Hd (%#018Hx) points\n",
npoints, npoints);
You can now give `%a' as a format to print an address, but all
formating flags are ignored and it causes the return value of
HDfprintf() to not include the characters in the address (but
who uses the return value anyway :-). Example:
H5G_t *grp;
HDfprintf(stdout, "Group object header at %a\n",
&(grp->ent.header));
Added HDstrtoll() which works exactly like [HD]strtol() except
the result is an int64.
./src/debug.c
Large addresses can now be entered from the command-line. Use
either decimal, octal (leading `0') or hexadecimal (leading
`0x') when giving the address.
./src/h5ls.c
The printf format for dataset dimensions was changed to `%Hu'
to support large datasets.
./test/big.c [NEW]
A test for big datasets on 32-bit machines. This test is not
run by default. Don't try to run it on an nfs-mounted file
system or other file system that doesn't support holes because
it creates two 32GB datasets of all zero.
1998-04-10 04:22:11 +08:00
|
|
|
|
H5Pset_family (plist, 0, H5P_DEFAULT);
|
1998-04-09 05:43:02 +08:00
|
|
|
|
}
|
|
|
|
|
if ((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, plist)) < 0) {
|
1998-01-17 06:23:43 +08:00
|
|
|
|
fprintf(stderr, "cannot open file\n");
|
|
|
|
|
HDexit(1);
|
|
|
|
|
}
|
1998-03-18 06:46:27 +08:00
|
|
|
|
if (NULL == (f = H5I_object(fid))) {
|
1998-01-17 06:23:43 +08:00
|
|
|
|
fprintf(stderr, "cannot obtain H5F_t pointer\n");
|
|
|
|
|
HDexit(2);
|
|
|
|
|
}
|
1998-04-09 05:43:02 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/*
|
|
|
|
|
* Parse command arguments.
|
|
|
|
|
*/
|
|
|
|
|
H5F_addr_reset(&addr);
|
|
|
|
|
H5F_addr_reset(&extra);
|
|
|
|
|
if (argc > 2) {
|
|
|
|
|
printf("New address: %s\n", argv[2]);
|
[svn-r339] Changes since 19980408
----------------------
./src/H5Osdspace.c
./html/H5.format.html
In the past we were allowed to have >2GB files on a 32-bit
machine as long as no dataset within the file was larger than
4GB (or whatever sizeof(size_t) is). That's been fixed now.
All dataset size calculations are done with `hsize_t' which is
normally defined as `unsigned long long'.
./src/H5F.c
./src/H5Ffamily.c
./src/H5Fprivate.h
./src/H5P.c
./src/H5Ppublic.h
The file family member size can now be set/queried. The
default is still 64MB, but it can be set to 1GB by saying:
H5Pset_family (plist, 30, H5P_DEFAULT);
When opening an existing file family the specified
bits-per-member is ignored and the first member of the family
determines the bits-per-member, which can be retrieved with
H5Pget_family().
./acconfig.h
./configure.in
./src/H5config.h
./src/H5public.h
Added `--disable-hsizet' so that those with old GCC compilers
(<2.8.1) can still compile the code.
./src/H5.c
./src/H5private.h
Added HDfprintf() which works just like fprintf() except you
can give `H' as a size modifier for the integer conversions
and supply an `hsize_t' or `hssize_t' argument without casting
it. For instance:
hsize_t npoints = H5Sget_npoints(space);
HDfprintf(stdout,"Dataset has %Hd (%#018Hx) points\n",
npoints, npoints);
You can now give `%a' as a format to print an address, but all
formating flags are ignored and it causes the return value of
HDfprintf() to not include the characters in the address (but
who uses the return value anyway :-). Example:
H5G_t *grp;
HDfprintf(stdout, "Group object header at %a\n",
&(grp->ent.header));
Added HDstrtoll() which works exactly like [HD]strtol() except
the result is an int64.
./src/debug.c
Large addresses can now be entered from the command-line. Use
either decimal, octal (leading `0') or hexadecimal (leading
`0x') when giving the address.
./src/h5ls.c
The printf format for dataset dimensions was changed to `%Hu'
to support large datasets.
./test/big.c [NEW]
A test for big datasets on 32-bit machines. This test is not
run by default. Don't try to run it on an nfs-mounted file
system or other file system that doesn't support holes because
it creates two 32GB datasets of all zero.
1998-04-10 04:22:11 +08:00
|
|
|
|
addr.offset = HDstrtoll(argv[2], NULL, 0);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
}
|
|
|
|
|
if (argc > 3) {
|
[svn-r339] Changes since 19980408
----------------------
./src/H5Osdspace.c
./html/H5.format.html
In the past we were allowed to have >2GB files on a 32-bit
machine as long as no dataset within the file was larger than
4GB (or whatever sizeof(size_t) is). That's been fixed now.
All dataset size calculations are done with `hsize_t' which is
normally defined as `unsigned long long'.
./src/H5F.c
./src/H5Ffamily.c
./src/H5Fprivate.h
./src/H5P.c
./src/H5Ppublic.h
The file family member size can now be set/queried. The
default is still 64MB, but it can be set to 1GB by saying:
H5Pset_family (plist, 30, H5P_DEFAULT);
When opening an existing file family the specified
bits-per-member is ignored and the first member of the family
determines the bits-per-member, which can be retrieved with
H5Pget_family().
./acconfig.h
./configure.in
./src/H5config.h
./src/H5public.h
Added `--disable-hsizet' so that those with old GCC compilers
(<2.8.1) can still compile the code.
./src/H5.c
./src/H5private.h
Added HDfprintf() which works just like fprintf() except you
can give `H' as a size modifier for the integer conversions
and supply an `hsize_t' or `hssize_t' argument without casting
it. For instance:
hsize_t npoints = H5Sget_npoints(space);
HDfprintf(stdout,"Dataset has %Hd (%#018Hx) points\n",
npoints, npoints);
You can now give `%a' as a format to print an address, but all
formating flags are ignored and it causes the return value of
HDfprintf() to not include the characters in the address (but
who uses the return value anyway :-). Example:
H5G_t *grp;
HDfprintf(stdout, "Group object header at %a\n",
&(grp->ent.header));
Added HDstrtoll() which works exactly like [HD]strtol() except
the result is an int64.
./src/debug.c
Large addresses can now be entered from the command-line. Use
either decimal, octal (leading `0') or hexadecimal (leading
`0x') when giving the address.
./src/h5ls.c
The printf format for dataset dimensions was changed to `%Hu'
to support large datasets.
./test/big.c [NEW]
A test for big datasets on 32-bit machines. This test is not
run by default. Don't try to run it on an nfs-mounted file
system or other file system that doesn't support holes because
it creates two 32GB datasets of all zero.
1998-04-10 04:22:11 +08:00
|
|
|
|
extra.offset = HDstrtoll(argv[3], NULL, 0);
|
1998-01-17 06:23:43 +08:00
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Read the signature at the specified file position.
|
|
|
|
|
*/
|
|
|
|
|
printf("Reading signature at address ");
|
|
|
|
|
H5F_addr_print(stdout, &addr);
|
|
|
|
|
printf(" (rel)\n");
|
1999-04-26 22:43:53 +08:00
|
|
|
|
if (H5F_block_read(f, &addr, (hsize_t)sizeof(sig), &H5F_xfer_dflt,
|
|
|
|
|
sig)<0) {
|
1998-01-17 06:23:43 +08:00
|
|
|
|
fprintf(stderr, "cannot read signature\n");
|
|
|
|
|
HDexit(3);
|
|
|
|
|
}
|
|
|
|
|
if (!HDmemcmp(sig, H5F_SIGNATURE, H5F_SIGNATURE_LEN)) {
|
|
|
|
|
/*
|
|
|
|
|
* Debug the boot block.
|
|
|
|
|
*/
|
|
|
|
|
status = H5F_debug(f, &addr, stdout, 0, VCOL);
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
1998-03-31 03:24:08 +08:00
|
|
|
|
} else if (!HDmemcmp(sig, H5HL_MAGIC, H5HL_SIZEOF_MAGIC)) {
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/*
|
1998-03-31 03:24:08 +08:00
|
|
|
|
* Debug a local heap.
|
1998-01-17 06:23:43 +08:00
|
|
|
|
*/
|
1998-03-31 03:24:08 +08:00
|
|
|
|
status = H5HL_debug(f, &addr, stdout, 0, VCOL);
|
|
|
|
|
|
|
|
|
|
} else if (!HDmemcmp (sig, H5HG_MAGIC, H5HG_SIZEOF_MAGIC)) {
|
|
|
|
|
/*
|
|
|
|
|
* Debug a global heap collection.
|
|
|
|
|
*/
|
|
|
|
|
status = H5HG_debug (f, &addr, stdout, 0, VCOL);
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
} else if (!HDmemcmp(sig, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC)) {
|
|
|
|
|
/*
|
|
|
|
|
* Debug a symbol table node.
|
|
|
|
|
*/
|
|
|
|
|
status = H5G_node_debug(f, &addr, stdout, 0, VCOL, &extra);
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
} else if (!HDmemcmp(sig, H5B_MAGIC, H5B_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.
|
|
|
|
|
*/
|
1998-04-18 05:29:43 +08:00
|
|
|
|
H5B_subid_t subtype = (H5B_subid_t)sig[H5B_SIZEOF_MAGIC];
|
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
switch (subtype) {
|
|
|
|
|
case H5B_SNODE_ID:
|
|
|
|
|
status = H5G_node_debug(f, &addr, stdout, 0, VCOL, &extra);
|
|
|
|
|
break;
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
1998-04-18 05:29:43 +08:00
|
|
|
|
case H5B_ISTORE_ID:
|
|
|
|
|
ndims = (int)extra.offset;
|
|
|
|
|
status = H5F_istore_debug (f, &addr, stdout, 0, VCOL, ndims);
|
|
|
|
|
break;
|
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
default:
|
1998-11-19 02:40:09 +08:00
|
|
|
|
fprintf(stderr, "Unknown B-tree subtype %u\n",
|
|
|
|
|
(unsigned)(subtype));
|
1998-01-17 06:23:43 +08:00
|
|
|
|
HDexit(4);
|
|
|
|
|
}
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
1998-02-10 03:37:40 +08:00
|
|
|
|
} else if (sig[0] == H5O_VERSION) {
|
1998-01-17 06:23:43 +08:00
|
|
|
|
/*
|
|
|
|
|
* This could be an object header. Since they don't have a signature
|
|
|
|
|
* it's a somewhat "ify" detection.
|
|
|
|
|
*/
|
|
|
|
|
status = H5O_debug(f, &addr, stdout, 0, VCOL);
|
1997-08-08 03:23:00 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
|
* Got some other unrecognized signature.
|
|
|
|
|
*/
|
|
|
|
|
printf("%-*s ", VCOL, "Signature:");
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
|
if (sig[i] > ' ' && sig[i] <= '~' && '\\' != sig[i]) {
|
|
|
|
|
HDputchar(sig[i]);
|
|
|
|
|
} else if ('\\' == sig[i]) {
|
|
|
|
|
HDputchar('\\');
|
|
|
|
|
HDputchar('\\');
|
|
|
|
|
} else {
|
|
|
|
|
printf("\\%03o", sig[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
HDputchar('\n');
|
1997-08-05 00:19:57 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
fprintf(stderr, "unknown signature\n");
|
|
|
|
|
HDexit(4);
|
|
|
|
|
}
|
1997-08-08 03:23:00 +08:00
|
|
|
|
|
1998-01-17 06:23:43 +08:00
|
|
|
|
if (status < 0) {
|
|
|
|
|
fprintf(stderr, "An error occurred\n");
|
|
|
|
|
HDexit(5);
|
|
|
|
|
}
|
|
|
|
|
H5Fclose(fid);
|
1998-02-10 03:37:40 +08:00
|
|
|
|
return 0;
|
1997-08-05 00:19:57 +08:00
|
|
|
|
}
|