From b56f0119896adefa8e55bebf0c151f8fcef5d33f Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Wed, 22 Jul 1998 08:51:51 -0500 Subject: [svn-r526] Changes since 19980721 ---------------------- ./tools/h5ls.c If the dataset is of type H5T_NATIVE_CHAR then we print the value as a string. This is temporary -- I plan to add better control of this later but needed something now for debugging. ./src/H5Fistore.c Squashed a bug in the chunk caching code that caused the wrong chunk to be returned. ./bin/trace ./src/H5.c Added support for printing values of array arguments when the size of the array is supplied by some previous argument. You must declare the argument as an array in order for the automatic tracing stuff to work. For instance, the third argument of H5Pset_chunk() is an array whose size is determined by the second argument `ndims'. Here's how you should declare it: herr_t H5Pset_chunk(hid_t plist_id, intn rank, hsize_t dims[/*rank*/]) The comment inside the `[]' is the name of some previous integer argument (int, unsigned, size_t, ssize_t, hsize_t, hssize_t). The trace output will look something like: H5Pset_chunk(plist=1234567, rank=2, dims=0x112233 {11, 22}) Changed tracing so that data types are printed out symbolically when possible. Changed tracing so data type initializations are not printed. This used to be confusing because lots of H5Tcopy() and H5Tregister...() calls showed up before the applications first explicit API call. ./src/H5Ipublic.h Changed the file atom group from zero to one so printing of atoms during tracing is more consistent -- they're all big numbers now. ./src/H5A.c ./src/H5E.c ./src/H5F.c ./src/H5G.c ./src/H5Sselect.c ./src/H5T.c ./src/H5TB.c ./src/H5Z.c Accidently modified these when working on the tracing, but nothing should have changed. ./src/H5P.c Changed the definition of H5Pset_chunk() for tracing. ./src/H5S.c ./src/H5Spublic.h Changed the definitions of H5Sset_extent_simple() and H5Screate_simple() for tracing. Changed the FUNC_ENTER() name for H5Screate_simple() so tracing shows the correct name. --- README | 2 +- bin/trace | 32 +++-- src/H5.c | 360 +++++++++++++++++++++++++++++++++++++++++++++++--------- src/H5Distore.c | 6 +- src/H5Fistore.c | 6 +- src/H5Ipublic.h | 7 +- src/H5P.c | 4 +- src/H5S.c | 13 +- src/H5Spublic.h | 3 +- src/H5T.c | 2 +- test/.distdep | 46 ++++---- tools/h5ls.c | 55 +++++++++ 12 files changed, 433 insertions(+), 103 deletions(-) diff --git a/README b/README index 183a6c8..00963af 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is hdf5-1.0.24 released on 1998-06-20 15:24 UTC +This is hdf5-1.0.24 released on 1998-06-21 19:01 UTC Please refer to the INSTALL file for installation instructions. ------------------------------------------------------------------------------ diff --git a/bin/trace b/bin/trace index c1a1acc..3ab902e 100755 --- a/bin/trace +++ b/bin/trace @@ -80,7 +80,7 @@ sub errmesg ($$@) { # sub argstring ($$$) { my ($file, $func, $atype) = @_; - my ($ptr, $tstr) = (0,"!"); + my ($ptr, $tstr, $array) = (0, "!", ""); my ($fq_atype); # Normalize the data type by removing redundant white space, @@ -91,8 +91,12 @@ sub argstring ($$$) { $ptr = length $1 if $atype =~ s/(\*+)//; $atype =~ s/^\s+//; $atype =~ s/\s+$//; + if ($atype =~ /(.*)\[(.*)\]$/) { + ($array, $atype) = ($2, $1); + } $fq_atype = $atype . ('*' x $ptr); + if ($ptr>0 && exists $TypeString{$fq_atype}) { $ptr = 0; $tstr = $TypeString{$fq_atype}; @@ -104,7 +108,7 @@ sub argstring ($$$) { } else { $tstr = $TypeString{$atype}; } - return ("*" x $ptr) . $tstr; + return ("*" x $ptr) . ($array?"[$array]":"") . $tstr; } ############################################################################## @@ -129,15 +133,18 @@ sub rewrite_func ($$$$$) { # comma, then split the arguments on commas. $args =~ s/(\/\*\s*in),\s*(out\s*\*\/)/$1_$2/g; my @args = split /,[\s\n]*/, $args; + my $argno = 0; + my %names; for $arg (@args) { unless ($arg=~/^(([a-z_A-Z]\w*\s+)+\**) - ([a-z_A-Z]\w*)(\[\])? + ([a-z_A-Z]\w*)(\[.*?\])? (\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) { errmesg $file, $name, "unable to parse \`$arg\'"; goto error; } else { my ($atype, $aname, $array, $adir) = ($1, $3, $4, $6); + $names{$aname} = $argno++; $adir ||= "in"; $atype =~ s/\s+$//; push @arg_name, $aname; @@ -145,7 +152,18 @@ sub rewrite_func ($$$$$) { if ($adir eq "out") { push @arg_str, "x"; } else { - $atype .= "*" if $array; + if (defined $array) { + $atype .= "*"; + if ($array =~ /^\[\/\*([a-z_A-Z]\w*)\*\/\]$/) { + my $asize = $1; + if (exists $names{$asize}) { + $atype .= '[a' . $names{$asize} . ']'; + } else { + warn "bad array size: $asize"; + $atype .= "*"; + } + } + } push @arg_str, argstring $file, $name, $atype; } } @@ -185,7 +203,7 @@ sub rewrite_func ($$$$$) { error: - return "\n$type\n$name ($args)$body"; + return "\n$type\n$name ($args)\n$body"; } ############################################################################## @@ -203,8 +221,8 @@ for $file (@ARGV) { my $original = $Source; my $napi = $Source =~ s/\n([A-Za-z]\w*(\s+[a-z]\w*)*)\s*\n #type (H5[A-Z]{1,2}[^_A-Z]\w*) #name - \s*\((.*?)\) #args - (.*?\n\}[^\n]*) #body + \s*\((.*?)\)\s* #args + (\{.*?\n\}[^\n]*) #body /rewrite_func($file,$1,$3,$4,$5)/segx; $total_api += $napi; diff --git a/src/H5.c b/src/H5.c index 3cb6aed..9f0b9a7 100644 --- a/src/H5.c +++ b/src/H5.c @@ -93,17 +93,6 @@ H5_init_library(void) { FUNC_ENTER_INIT(H5_init_library, NULL, FAIL); -#ifdef H5_DEBUG_API - { - /* Turn on tracing? */ - const char *s = getenv ("HDF5_TRACE"); - if (s && isdigit(*s)) { - int fd = HDstrtol (s, NULL, 0); - H5_trace_g = HDfdopen (fd, "w"); - } - } -#endif - /* Install atexit() library cleanup routine */ if (install_atexit_g == TRUE) if (HDatexit(&H5_term_library) != 0) @@ -118,6 +107,18 @@ H5_init_library(void) HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize type interface"); } + +#ifdef H5_DEBUG_API + { + /* Turn on tracing? */ + const char *s = getenv ("HDF5_TRACE"); + if (s && isdigit(*s)) { + int fd = HDstrtol (s, NULL, 0); + H5_trace_g = HDfdopen (fd, "w"); + } + } +#endif + FUNC_LEAVE(SUCCEED); } @@ -962,9 +963,11 @@ void H5_trace (hbool_t returning, const char *func, const char *type, ...) { va_list ap; - char buf[64]; + char buf[64], *rest; const char *argname; - intn argno=0, ptr, n; + intn argno=0, ptr, n, asize_idx; + hssize_t asize[16]; + hssize_t i; void *vp = NULL; FILE *out = H5_trace_g; @@ -977,10 +980,28 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) fprintf (out, "%s(", func); } - while (*type) { + /* Clear array sizes */ + for (i=0; i=0 && asize[asize_idx]>=0) { + hsize_t *p = (hsize_t*)vp; + fprintf(out, " {"); + for (i=0; i=0 && asize[asize_idx]>=0) { + hssize_t *p = (hssize_t*)vp; + fprintf(out, " {"); + for (i=0; i=0 && asize[asize_idx]>=0) { + int *p = (int*)vp; + fprintf(out, " {"); + for (i=0; i=0 && asize[asize_idx]>=0) { + int *p = (int*)vp; + fprintf(out, " {"); + for (i=0; i=0 && asize[asize_idx]>=0) { + size_t *p = (size_t*)vp; + fprintf(out, " {"); + for (i=0; i=0 && asize[asize_idx]>=0) { + ssize_t *p = (ssize_t*)vp; + fprintf(out, " {"); + for (i=0; i=0 && *idx_hintnused) { ent = rdcc->slot + *idx_hint; - if (layout->ndims==ent->layout->ndims) { + if (layout->ndims==ent->layout->ndims && + H5F_addr_eq(&(layout->addr), &(ent->layout->addr))) { for (i=0, found=*idx_hint; found>=0 && ilayout->ndims; i++) { if (offset[i]!=ent->offset[i]) found = -1; } @@ -1004,7 +1005,8 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout, /* Then look at all the entries */ for (i=0; found<0 && inused; i++) { ent = rdcc->slot + i; - if (layout->ndims==ent->layout->ndims) { + if (layout->ndims==ent->layout->ndims && + H5F_addr_eq(&(layout->addr), &(ent->layout->addr))) { for (j=0, found=i; found>=0 && jlayout->ndims; j++) { if (offset[j]!=ent->offset[j]) found = -1; } diff --git a/src/H5Fistore.c b/src/H5Fistore.c index 8c9d22e..262a58f 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -994,7 +994,8 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout, /* First use the hint */ if (idx_hint && *idx_hint>=0 && *idx_hintnused) { ent = rdcc->slot + *idx_hint; - if (layout->ndims==ent->layout->ndims) { + if (layout->ndims==ent->layout->ndims && + H5F_addr_eq(&(layout->addr), &(ent->layout->addr))) { for (i=0, found=*idx_hint; found>=0 && ilayout->ndims; i++) { if (offset[i]!=ent->offset[i]) found = -1; } @@ -1004,7 +1005,8 @@ H5F_istore_lock (H5F_t *f, const H5O_layout_t *layout, /* Then look at all the entries */ for (i=0; found<0 && inused; i++) { ent = rdcc->slot + i; - if (layout->ndims==ent->layout->ndims) { + if (layout->ndims==ent->layout->ndims && + H5F_addr_eq(&(layout->addr), &(ent->layout->addr))) { for (j=0, found=i; found>=0 && jlayout->ndims; j++) { if (offset[j]!=ent->offset[j]) found = -1; } diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 74b0bd8..e673734 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -20,10 +20,13 @@ /* Public headers needed by this file */ #include -/* Group values allowed */ +/* + * Group values allowed. Start with `1' instead of `0' because it makes the + * tracing output look better when hid_t values are large numbers. + */ typedef enum { BADGROUP = (-1),/*invalid Group */ - H5_FILE = 0, /*group ID for File objects */ + H5_FILE = 1, /*group ID for File objects */ H5_TEMPLATE_0, /*group ID for Template objects */ H5_TEMPLATE_1, /*group ID for Template objects */ H5_TEMPLATE_2, /*group ID for Template objects */ diff --git a/src/H5P.c b/src/H5P.c index 459e7d6..c40d7c3 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -1038,13 +1038,13 @@ H5Pget_layout (hid_t tid) *------------------------------------------------------------------------- */ herr_t -H5Pset_chunk (hid_t tid, int ndims, const hsize_t dim[]) +H5Pset_chunk (hid_t tid, int ndims, const hsize_t dim[/*ndims*/]) { int i; H5D_create_t *tmpl = NULL; FUNC_ENTER(H5Pset_chunk, FAIL); - H5TRACE3("e","iIs*h",tid,ndims,dim); + H5TRACE3("e","iIs*[a1]h",tid,ndims,dim); /* Check arguments */ if (H5P_DATASET_CREATE != H5P_get_class(tid) || diff --git a/src/H5S.c b/src/H5S.c index 215267b..4905aed 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -1029,14 +1029,14 @@ H5Sis_simple (hid_t sid) dimension in the array (the slowest) may be unlimited in size. --------------------------------------------------------------------------*/ herr_t -H5Sset_extent_simple (hid_t sid, int rank, const hsize_t *dims, - const hsize_t *max) +H5Sset_extent_simple (hid_t sid, int rank, const hsize_t dims[/*rank*/], + const hsize_t max[/*rank*/]) { H5S_t *space = NULL; /* dataspace to modify */ intn u; /* local counting variable */ FUNC_ENTER(H5Sset_extent_simple, FAIL); - H5TRACE4("e","iIs*h*h",sid,rank,dims,max); + H5TRACE4("e","iIs*[a1]h*[a1]h",sid,rank,dims,max); /* Check args */ if ((space = H5I_object(sid)) == NULL) { @@ -1382,14 +1382,15 @@ H5S_extend (H5S_t *space, const hsize_t *size) *------------------------------------------------------------------------- */ hid_t -H5Screate_simple (int rank, const hsize_t *dims, const hsize_t *maxdims) +H5Screate_simple (int rank, const hsize_t dims[/*rank*/], + const hsize_t maxdims[/*rank*/]) { hid_t ret_value = FAIL; H5S_t *space = NULL; int i; - FUNC_ENTER(H5Screate, FAIL); - H5TRACE3("i","Is*h*h",rank,dims,maxdims); + FUNC_ENTER(H5Screate_simple, FAIL); + H5TRACE3("i","Is*[a0]h*[a0]h",rank,dims,maxdims); /* Check arguments */ if (rank<0) { diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 022f108..68a5fd1 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -45,7 +45,8 @@ extern "C" { /* Functions in H5S.c */ hid_t H5Screate(H5S_class_t type); hid_t H5Screate_simple (int rank, const hsize_t dims[], const hsize_t maxdims[]); -herr_t H5Sset_extent_simple (hid_t sid, int rank, const hsize_t *dims, const hsize_t *max); +herr_t H5Sset_extent_simple (hid_t sid, int rank, const hsize_t dims[], + const hsize_t max[]); hid_t H5Scopy (hid_t space_id); herr_t H5Sclose (hid_t space_id); hsize_t H5Sextent_npoints (hid_t space_id); diff --git a/src/H5T.c b/src/H5T.c index 11eef4b..bf0f03b 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -615,7 +615,7 @@ H5T_init_interface(void) HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function"); } - + FUNC_LEAVE(ret_value); } diff --git a/test/.distdep b/test/.distdep index dad6bc8..7088b0b 100644 --- a/test/.distdep +++ b/test/.distdep @@ -396,20 +396,17 @@ testhdf5.o: \ ../src/H5private.h \ ../src/H5public.h \ ../src/H5config.h -tselect.o: \ - tselect.c \ - testhdf5.h \ - ../src/H5private.h \ +dsets.o: \ + dsets.c \ + ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ - ../src/H5Eprivate.h \ - ../src/H5Epublic.h \ ../src/H5Ipublic.h \ - ../src/hdf5.h \ ../src/H5Apublic.h \ ../src/H5ACpublic.h \ ../src/H5Bpublic.h \ ../src/H5Dpublic.h \ + ../src/H5Epublic.h \ ../src/H5Fpublic.h \ ../src/H5Gpublic.h \ ../src/H5HGpublic.h \ @@ -419,9 +416,10 @@ tselect.o: \ ../src/H5Opublic.h \ ../src/H5Ppublic.h \ ../src/H5Zpublic.h \ - ../src/H5Spublic.h -dsets.o: \ - dsets.c \ + ../src/H5Spublic.h \ + ../src/H5Tpublic.h +dtypes.o: \ + dtypes.c \ ../src/hdf5.h \ ../src/H5public.h \ ../src/H5config.h \ @@ -441,18 +439,27 @@ dsets.o: \ ../src/H5Ppublic.h \ ../src/H5Zpublic.h \ ../src/H5Spublic.h \ - ../src/H5Tpublic.h -dtypes.o: \ - dtypes.c \ - ../src/hdf5.h \ + ../src/H5Tpublic.h \ + ../src/H5Tpkg.h \ + ../src/H5HGprivate.h \ + ../src/H5Fprivate.h \ + ../src/H5private.h \ + ../src/H5Tprivate.h \ + ../src/H5Gprivate.h +tselect.o: \ + tselect.c \ + testhdf5.h \ + ../src/H5private.h \ ../src/H5public.h \ ../src/H5config.h \ + ../src/H5Eprivate.h \ + ../src/H5Epublic.h \ ../src/H5Ipublic.h \ + ../src/hdf5.h \ ../src/H5Apublic.h \ ../src/H5ACpublic.h \ ../src/H5Bpublic.h \ ../src/H5Dpublic.h \ - ../src/H5Epublic.h \ ../src/H5Fpublic.h \ ../src/H5Gpublic.h \ ../src/H5HGpublic.h \ @@ -462,11 +469,4 @@ dtypes.o: \ ../src/H5Opublic.h \ ../src/H5Ppublic.h \ ../src/H5Zpublic.h \ - ../src/H5Spublic.h \ - ../src/H5Tpublic.h \ - ../src/H5Tpkg.h \ - ../src/H5HGprivate.h \ - ../src/H5Fprivate.h \ - ../src/H5private.h \ - ../src/H5Tprivate.h \ - ../src/H5Gprivate.h + ../src/H5Spublic.h diff --git a/tools/h5ls.c b/tools/h5ls.c index 7a88ac4..18a1636 100644 --- a/tools/h5ls.c +++ b/tools/h5ls.c @@ -5,6 +5,7 @@ * Programmer: Robb Matzke * Monday, March 23, 1998 */ +#include #include #include #include @@ -56,6 +57,59 @@ usage: %s [OPTIONS] FILE [GROUP]\n\ /*------------------------------------------------------------------------- + * Function: dump_dataset_values + * + * Purpose: Prints all values of a dataset. + * + * Return: void + * + * Programmer: Robb Matzke + * Tuesday, July 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void +dump_dataset_values(hid_t dset) +{ + hid_t file_space, mem_space, type; + hsize_t start, file_nelmts, mem_nelmts; + hssize_t zero = 0; + unsigned char buf[1024]; + hsize_t i; + + file_space = H5Dget_space(dset); + type = H5Dget_type(dset); + + if (H5Tequal(type, H5T_NATIVE_CHAR)) { + printf("%*svalue = \"", 26, ""); + file_nelmts = H5Sextent_npoints(file_space); + mem_nelmts = sizeof(buf); + mem_space = H5Screate_simple(1, &mem_nelmts, NULL); + for (start=0; start=0) { printf ("Group\n"); -- cgit v0.12