summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools_error.h
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2019-11-07 15:48:56 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2019-11-07 15:49:11 (GMT)
commit6b927a773c83bedc111dcd2ad38805f974660b15 (patch)
tree5f836ff5409d5265161b058e75f4d806c8afff1d /tools/lib/h5tools_error.h
parent2dd5bbfe167e3e9b6b6ee657a882e24072de4aeb (diff)
downloadhdf5-6b927a773c83bedc111dcd2ad38805f974660b15.zip
hdf5-6b927a773c83bedc111dcd2ad38805f974660b15.tar.gz
hdf5-6b927a773c83bedc111dcd2ad38805f974660b15.tar.bz2
HDFFV-10876 Update h5dump and h5ls for new ref api.
Diffstat (limited to 'tools/lib/h5tools_error.h')
-rw-r--r--tools/lib/h5tools_error.h92
1 files changed, 70 insertions, 22 deletions
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index 2cdaf74..2c5e6c9 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -18,12 +18,15 @@
#define H5TOOLS_ERROR_H_
#include "H5Epublic.h"
+#include "H5Eprivate.h" /* Error handling */
/* tools-HDF5 Error variables */
H5TOOLS_DLLVAR hid_t H5tools_ERR_STACK_g;
H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g;
H5TOOLS_DLLVAR hid_t H5E_tools_g;
H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
+H5TOOLS_DLLVAR hid_t H5E_tools_min_info_id_g;
+H5TOOLS_DLLVAR hid_t H5E_tools_min_dbg_id_g;
/* Use FUNC to safely handle variations of C99 __func__ keyword handling */
#ifdef H5_HAVE_C99_FUNC
@@ -39,41 +42,84 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
*/
#define H5TOOLS_INIT_ERROR() { \
H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str); \
- H5E_tools_g= H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library"); \
+ H5E_tools_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MAJOR, "Failure in tools library"); \
H5E_tools_min_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "error in function"); \
+ H5E_tools_min_info_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function info"); \
+ H5E_tools_min_dbg_id_g = H5Ecreate_msg(H5tools_ERR_CLS_g, H5E_MINOR, "function debug"); \
}
/*
* H5TOOLS_CLOSE_ERROR macro, used to initialize error reporting.
*/
#define H5TOOLS_CLOSE_ERROR() { \
+ H5Eclose_msg(H5E_tools_min_dbg_id_g); \
+ H5Eclose_msg(H5E_tools_min_info_id_g); \
H5Eclose_msg(H5E_tools_min_id_g); \
H5Eclose_msg(H5E_tools_g); \
H5Eunregister_class(H5tools_ERR_CLS_g); \
}
/*
- * HERR_INIT macro, used to facilitate error reporting. Declaration and assignments of error variables.
+ * H5TOOLS_ERR_INIT macro, used to facilitate error reporting. Declaration and assignments of error variables.
* Use at the beginning of a function using error handling macros.
*/
-#define HERR_INIT(ret_typ, ret_init) \
- hbool_t past_catch = FALSE; \
+#define H5TOOLS_ERR_INIT(ret_typ, ret_init) \
+ hid_t pstack_id = H5I_INVALID_HID; \
+ hid_t estack_id = H5tools_ERR_STACK_g; \
+ hbool_t past_catch = FALSE; \
ret_typ ret_value = ret_init;
+/*
+ * H5TOOLS_PUSH_STACK macro, used to create a new error stack.
+ */
+#define H5TOOLS_PUSH_STACK() { \
+ pstack_id = estack_id; \
+ estack_id = H5Ecreate_stack(); \
+}
/*
- * H5TOOLS_INFO macro, used to facilitate error reporting . The arguments are the major
- * error number, the minor error number, and a description of the error.
+ * H5TOOLS_POP_STACK macro, used to release a new error stack.
+ */
+#define H5TOOLS_POP_STACK() { \
+ if (H5I_INVALID_HID != pstack_id) { \
+ H5Eclose_stack(estack_id); \
+ estack_id = pstack_id; \
+ pstack_id = H5I_INVALID_HID; \
+ } \
+}
+
+/*
+ * H5TOOLS_DEBUG macro, used to facilitate error reporting. The arguments are the minor error number, and a description of the error.
+ */
+#ifdef H5_TOOLS_DEBUG
+#define H5TOOLS_DEBUG(min_id, ...) { \
+ H5Epush2(estack_id, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
+}
+#define H5TOOLS_ENDDEBUG(min_id, ...) { \
+ H5Epush2(estack_id, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
+ H5Eprint2(estack_id, stderr); \
+}
+#else
+#define H5TOOLS_DEBUG(min_id, ...) { \
+ ; \
+}
+#define H5TOOLS_ENDDEBUG(min_id, ...) { \
+ ; \
+}
+#endif
+
+/*
+ * H5TOOLS_INFO macro, used to facilitate error reporting . The arguments are the minor error number, and a description of the error.
*/
#define H5TOOLS_INFO(min_id, ...) { \
H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
}
/*
- * HERROR macro, used to facilitate error reporting . The arguments are the major
+ * H5TOOLS_ERROR macro, used to facilitate error reporting . The arguments are the major
* error number, the minor error number, and a description of the error.
*/
-#define HERROR(maj_id, min_id, ...) { \
+#define H5TOOLS_ERROR(maj_id, min_id, ...) { \
H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, maj_id, min_id, __VA_ARGS__); \
ret_value = FAIL; \
}
@@ -82,7 +128,7 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
/* Macro for "catching" flow of control when an error occurs. Note that the
* H5_LEAVE macro won't jump back here once it's past this point.
*/
-#define CATCH catch_except:; past_catch = TRUE;
+/* #define CATCH catch_except:; past_catch = TRUE; defined in H5Eprivate.h */
/*
* H5_LEAVE macro, used to facilitate control flow between a
@@ -91,32 +137,34 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
* The return value is assigned to a variable `ret_value' and control branches
* to the `catch_except' label, if we're not already past it.
*/
-#define H5_LEAVE(v) { \
- ret_value = v; \
- if(!past_catch) \
- goto catch_except; \
-}
+/*
+ * #define H5_LEAVE(v) { \
+ * ret_value = v; \
+ * if(!past_catch) \
+ * goto catch_except; \
+ * }
+ * defined in H5Eprivate.h */
/*
- * H5E_THROW macro, used to facilitate error reporting within a function body.
+ * H5TOOLS_THROW macro, used to facilitate error reporting within a function body.
* The arguments are the minor error number, and an error string.
* The return value is assigned to a variable `ret_value' and control branches
* to the `catch_except' label, if we're not already past it.
*/
-#define H5E_THROW(fail_value, min_id, ...) { \
+#define H5TOOLS_THROW(fail_value, min_id, ...) { \
H5Epush2(H5tools_ERR_STACK_g, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \
- H5_LEAVE(fail_value) \
+ H5_LEAVE(fail_value) \
}
/*
- * HGOTO_ERROR macro, used to facilitate error reporting within a function body. The arguments are
+ * H5TOOLS_GOTO_ERROR macro, used to facilitate error reporting within a function body. The arguments are
* the major error number, the minor error number, the return value, and an
* error string. The return value is assigned to a variable `ret_value' and
* control branches to the `done' label.
*/
-#define HGOTO_ERROR(fail_value, min_id, ...) { \
- HERROR(H5E_tools_g, min_id, __VA_ARGS__); \
- HGOTO_DONE(fail_value) \
+#define H5TOOLS_GOTO_ERROR(fail_value, min_id, ...) { \
+ H5TOOLS_ERROR(H5E_tools_g, min_id, __VA_ARGS__); \
+ HGOTO_DONE(fail_value) \
}
/*
@@ -124,7 +172,7 @@ H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
* The argument is the return value which is assigned to the `ret_value'
* variable. Control branches to the `done' label.
*/
-#define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;}
+/* #define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} defined in H5Eprivate.h */
#endif /* H5TOOLS_ERROR_H_ */