From a77a08b02fb31e87f451a39640e4376e49878097 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 14 Feb 2018 16:14:48 -0600 Subject: HDFFV-10384 Add optional arg to enable-error-stack --- tools/lib/h5tools.c | 22 +++++++++++++---- tools/lib/h5tools.h | 2 +- tools/src/h5copy/h5copy.c | 4 ++-- tools/src/h5diff/h5diff_common.c | 2 +- tools/src/h5diff/h5diff_main.c | 2 +- tools/src/h5dump/h5dump.c | 49 ++++++++++++++++++++------------------ tools/src/h5repack/h5repack_main.c | 4 ++-- 7 files changed, 50 insertions(+), 35 deletions(-) diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 89cb524..11888bc 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -43,7 +43,7 @@ unsigned packed_bits_num; /* number of packed bits to display */ unsigned packed_data_offset; /* offset of packed bits to display */ unsigned packed_data_length; /* length of packed bits to display */ unsigned long long packed_data_mask; /* mask in which packed bits to display */ -int enable_error_stack= FALSE; /* re-enable error stack */ +int enable_error_stack = 0; /* re-enable error stack; disable=0 enable=1 */ /* sort parameters */ H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */ @@ -548,9 +548,15 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, if ((my_fapl = h5tools_get_fapl(fapl, driver, &drivernum)) < 0) goto done; - H5E_BEGIN_TRY { + /* allow error stack display if enable-error-stack has optional arg number */ + if (enable_error_stack > 1) { fid = H5Fopen(fname, flags, my_fapl); - } H5E_END_TRY; + } + else { + H5E_BEGIN_TRY { + fid = H5Fopen(fname, flags, my_fapl); + } H5E_END_TRY; + } if (fid == FAIL) goto done; @@ -563,9 +569,15 @@ h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, if((my_fapl = h5tools_get_fapl(fapl, drivernames[drivernum], NULL)) < 0) goto done; - H5E_BEGIN_TRY { + /* allow error stack display if enable-error-stack has optional arg number */ + if (enable_error_stack > 1) { fid = H5Fopen(fname, flags, my_fapl); - } H5E_END_TRY; + } + else { + H5E_BEGIN_TRY { + fid = H5Fopen(fname, flags, my_fapl); + } H5E_END_TRY; + } if (fid != FAIL) break; diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 6383df5..c360230 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -573,7 +573,7 @@ H5TOOLS_DLLVAR H5_index_t sort_by; /*sort_by [creation_order | name] * H5TOOLS_DLLVAR H5_iter_order_t sort_order; /*sort_order [ascending | descending] */ /* things to display or which are set via command line parameters */ -H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack */ +H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack; disable=0 enable=1 */ /* Strings for output */ #define H5_TOOLS_GROUP "GROUP" diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c index 1d15d12..1800810 100644 --- a/tools/src/h5copy/h5copy.c +++ b/tools/src/h5copy/h5copy.c @@ -293,7 +293,7 @@ main (int argc, const char *argv[]) break; case 'E': - enable_error_stack = TRUE; + enable_error_stack = 1; break; default: @@ -330,7 +330,7 @@ main (int argc, const char *argv[]) leave(EXIT_FAILURE); } - if (enable_error_stack) { + if (enable_error_stack > 0) { H5Eset_auto2(H5E_DEFAULT, func, edata); H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); } diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index ce5df78..8f09c81 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -178,7 +178,7 @@ void parse_command_line(int argc, break; case 'S': - enable_error_stack = TRUE; + enable_error_stack = 1; break; case 'E': diff --git a/tools/src/h5diff/h5diff_main.c b/tools/src/h5diff/h5diff_main.c index ad488a4..c5a0cbf 100644 --- a/tools/src/h5diff/h5diff_main.c +++ b/tools/src/h5diff/h5diff_main.c @@ -100,7 +100,7 @@ int main(int argc, const char *argv[]) */ parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); - if (enable_error_stack) { + if (enable_error_stack > 0) { H5Eset_auto2(H5E_DEFAULT, func, edata); H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); } diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index b90d60f..62f0ed0 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -67,7 +67,7 @@ struct handler_t { */ /* The following initialization makes use of C language cancatenating */ /* "xxx" "yyy" into "xxxyyy". */ -static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RECM:O*N:vG:"; +static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RE*CM:O*N:vG:"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, { "hel", no_arg, 'h' }, @@ -181,7 +181,7 @@ static struct long_options l_opts[] = { { "sort_order", require_arg, 'z' }, { "format", require_arg, 'm' }, { "region", no_arg, 'R' }, - { "enable-error-stack", no_arg, 'E' }, + { "enable-error-stack", optional_arg, 'E' }, { "packed-bits", require_arg, 'M' }, { "no-compact-subset", no_arg, 'C' }, { "ddl", optional_arg, 'O' }, @@ -191,7 +191,7 @@ static struct long_options l_opts[] = { { NULL, 0, '\0' } }; - + /*------------------------------------------------------------------------- * Function: leave * @@ -214,7 +214,7 @@ leave(int ret) HDexit(ret); } - + /*------------------------------------------------------------------------- * Function: usage * @@ -366,7 +366,7 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, "\n"); } - + /*------------------------------------------------------------------------- * Function: table_list_add * @@ -419,7 +419,7 @@ table_list_add(hid_t oid, unsigned long file_no) return((ssize_t) idx); } /* end table_list_add() */ - + /*------------------------------------------------------------------------- * Function: table_list_visited * @@ -449,7 +449,7 @@ table_list_visited(unsigned long file_no) return(-1); } /* end table_list_visited() */ - + /*------------------------------------------------------------------------- * Function: table_list_free * @@ -817,7 +817,7 @@ parse_mask_list(const char *h_list) } } - + /*------------------------------------------------------------------------- * Function: free_handler * @@ -865,7 +865,7 @@ free_handler(struct handler_t *hand, int len) } } - + /*------------------------------------------------------------------------- * Function: parse_command_line * @@ -920,9 +920,8 @@ parse_start: case 'n': display_fi = TRUE; last_was_dset = FALSE; - if ( opt_arg != NULL) { + if (opt_arg != NULL) h5trav_set_verbose(HDatoi(opt_arg)); - } break; case 'p': display_dcpl = TRUE; @@ -939,8 +938,9 @@ parse_start: last_was_dset = FALSE; break; case 'A': - if ( opt_arg != NULL) { - if(0 == HDatoi(opt_arg)) include_attrs = FALSE; + if (opt_arg != NULL) { + if(0 == HDatoi(opt_arg)) + include_attrs = FALSE; } else { display_data = FALSE; @@ -1059,7 +1059,7 @@ parse_start: break; case 'o': - if ( bin_output ) { + if (bin_output) { if (h5tools_set_data_output_file(opt_arg, 1) < 0) { usage(h5tools_getprogname()); goto error; @@ -1086,8 +1086,8 @@ parse_start: break; case 'b': - if ( opt_arg != NULL) { - if ( ( bin_form = set_binary_form(opt_arg)) < 0) { + if (opt_arg != NULL) { + if ((bin_form = set_binary_form(opt_arg)) < 0) { /* failed to set binary form */ usage(h5tools_getprogname()); goto error; @@ -1106,7 +1106,7 @@ parse_start: break; case 'q': - if ( ( sort_by = set_sort_by(opt_arg)) < 0) { + if ((sort_by = set_sort_by(opt_arg)) < 0) { /* failed to set "sort by" form */ usage(h5tools_getprogname()); goto error; @@ -1114,7 +1114,7 @@ parse_start: break; case 'z': - if ( ( sort_order = set_sort_order(opt_arg)) < 0) { + if ((sort_order = set_sort_order(opt_arg)) < 0) { /* failed to set "sort order" form */ usage(h5tools_getprogname()); goto error; @@ -1268,7 +1268,10 @@ end_collect: /** end subsetting parameters **/ case 'E': - enable_error_stack = TRUE; + if (opt_arg != NULL) + enable_error_stack = HDatoi(opt_arg); + else + enable_error_stack = 1; break; case 'C': disable_compact_subset = TRUE; @@ -1306,7 +1309,7 @@ error: return hand; } - + /*------------------------------------------------------------------------- * Function: main * @@ -1388,7 +1391,7 @@ main(int argc, const char *argv[]) goto done; } - if (enable_error_stack) { + if (enable_error_stack > 0) { H5Eset_auto2(H5E_DEFAULT, func, edata); H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); } @@ -1764,7 +1767,7 @@ h5_fileaccess(void) return fapl; } - + /*------------------------------------------------------------------------- * Function: init_prefix * @@ -1785,7 +1788,7 @@ init_prefix(char **prfx, size_t prfx_len) error_msg("unable to allocate prefix buffer\n"); } - + /*------------------------------------------------------------------------- * Function: add_prefix * diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 0fa268e..226f58e 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -667,7 +667,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'E': - enable_error_stack = TRUE; + enable_error_stack = 1; break; default: @@ -760,7 +760,7 @@ int main(int argc, const char **argv) } } - if (enable_error_stack) { + if (enable_error_stack > 0) { H5Eset_auto2(H5E_DEFAULT, func, edata); H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); } -- cgit v0.12 From ebb3bb0cfc08f3674606d78ec8c18cb7132650cd Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 15 Feb 2018 16:58:51 -0600 Subject: HDFFV-10384 Add opt arg to help --- release_docs/RELEASE.txt | 12 ++++++++++++ tools/src/h5dump/h5dump.c | 4 ++-- tools/testfiles/h5dump-help.txt | 4 ++-- tools/testfiles/pbits/tnofilename-with-packed-bits.ddl | 4 ++-- tools/testfiles/pbits/tpbitsIncomplete.ddl | 4 ++-- tools/testfiles/pbits/tpbitsLengthExceeded.ddl | 4 ++-- tools/testfiles/pbits/tpbitsLengthPositive.ddl | 4 ++-- tools/testfiles/pbits/tpbitsMaxExceeded.ddl | 4 ++-- tools/testfiles/pbits/tpbitsOffsetExceeded.ddl | 4 ++-- tools/testfiles/pbits/tpbitsOffsetNegative.ddl | 4 ++-- 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index c13b247..e7186c5 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -312,6 +312,18 @@ Bug Fixes since HDF5-1.10.1 release ----- - h5dump + the tools library will hide the error stack during file open. + + While this is preferable almost always, there are reasons to enable + display of the error stack when a tool will not open a file. Adding an + optional argument to the --enable-error-stack will provide this use case. + As an optional argument it will not affect the operation of the + --enable-error-stack. h5dump is the only tool to implement this change. + + (ADB - 2018/02/15, HDFFV-10384) + + - h5dump + h5dump would output an indented blank line in the filters section. h5dump overused the h5tools_simple_prefix function, which is a diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index 62f0ed0..25e4858 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -273,8 +273,8 @@ usage(const char *prog) PRINTVALSTREAM(rawoutstream, " -m T, --format=T Set the floating point output format\n"); PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n"); PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n"); - PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); - PRINTVALSTREAM(rawoutstream, " occur.\n"); + PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they occur.\n"); + PRINTVALSTREAM(rawoutstream, " Optional value 2 also prints file open errors.\n"); PRINTVALSTREAM(rawoutstream, " --no-compact-subset Disable compact form of subsetting and allow the use\n"); PRINTVALSTREAM(rawoutstream, " of \"[\" in dataset names.\n"); PRINTVALSTREAM(rawoutstream, " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n"); diff --git a/tools/testfiles/h5dump-help.txt b/tools/testfiles/h5dump-help.txt index fe22a1b..19de76f 100644 --- a/tools/testfiles/h5dump-help.txt +++ b/tools/testfiles/h5dump-help.txt @@ -44,8 +44,8 @@ usage: h5dump [OPTIONS] files -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. --no-compact-subset Disable compact form of subsetting and allow the use of "[" in dataset names. -w N, --width=N Set the number of columns of output. A value of 0 (zero) diff --git a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl index 767cbbf..0a3beb0 100644 --- a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl +++ b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl @@ -44,8 +44,8 @@ usage: h5dump [OPTIONS] files -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. --no-compact-subset Disable compact form of subsetting and allow the use of "[" in dataset names. -w N, --width=N Set the number of columns of output. A value of 0 (zero) diff --git a/tools/testfiles/pbits/tpbitsIncomplete.ddl b/tools/testfiles/pbits/tpbitsIncomplete.ddl index d791b41..b353065 100644 --- a/tools/testfiles/pbits/tpbitsIncomplete.ddl +++ b/tools/testfiles/pbits/tpbitsIncomplete.ddl @@ -44,8 +44,8 @@ usage: h5dump [OPTIONS] files -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. --no-compact-subset Disable compact form of subsetting and allow the use of "[" in dataset names. -w N, --width=N Set the number of columns of output. A value of 0 (zero) diff --git a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl index 5235aa7..ffe0da9 100644 --- a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl @@ -44,8 +44,8 @@ usage: h5dump [OPTIONS] files -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. --no-compact-subset Disable compact form of subsetting and allow the use of "[" in dataset names. -w N, --width=N Set the number of columns of output. A value of 0 (zero) diff --git a/tools/testfiles/pbits/tpbitsLengthPositive.ddl b/tools/testfiles/pbits/tpbitsLengthPositive.ddl index 697bff8..4502143 100644 --- a/tools/testfiles/pbits/tpbitsLengthPositive.ddl +++ b/tools/testfiles/pbits/tpbitsLengthPositive.ddl @@ -44,8 +44,8 @@ usage: h5dump [OPTIONS] files -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. --no-compact-subset Disable compact form of subsetting and allow the use of "[" in dataset names. -w N, --width=N Set the number of columns of output. A value of 0 (zero) diff --git a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl index 900c0b5..011f6c9 100644 --- a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl @@ -44,8 +44,8 @@ usage: h5dump [OPTIONS] files -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. --no-compact-subset Disable compact form of subsetting and allow the use of "[" in dataset names. -w N, --width=N Set the number of columns of output. A value of 0 (zero) diff --git a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl index 65123d0..857fe62 100644 --- a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl @@ -44,8 +44,8 @@ usage: h5dump [OPTIONS] files -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. --no-compact-subset Disable compact form of subsetting and allow the use of "[" in dataset names. -w N, --width=N Set the number of columns of output. A value of 0 (zero) diff --git a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl index d352e34..9ac1160 100644 --- a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl @@ -44,8 +44,8 @@ usage: h5dump [OPTIONS] files -m T, --format=T Set the floating point output format -q Q, --sort_by=Q Sort groups and attributes by index Q -z Z, --sort_order=Z Sort groups and attributes by order Z - --enable-error-stack Prints messages from the HDF5 error stack as they - occur. + --enable-error-stack Prints messages from the HDF5 error stack as they occur. + Optional value 2 also prints file open errors. --no-compact-subset Disable compact form of subsetting and allow the use of "[" in dataset names. -w N, --width=N Set the number of columns of output. A value of 0 (zero) -- cgit v0.12 From 30166fed18a9b0754d56b3454176e3a5111a1e21 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 19 Feb 2018 08:32:15 -0600 Subject: Fix indentation --- tools/src/h5repack/h5repack_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 226f58e..8f0178f 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -667,8 +667,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'E': - enable_error_stack = 1; - break; + enable_error_stack = 1; + break; default: break; -- cgit v0.12