- improved debugging

- abort error handler now terminates all processes in MPI_COMM_WORLD
- some formating issues fixed
- some minor (cosmetic) changes
This commit is contained in:
2011-02-18 10:33:44 +00:00
parent 05772223f5
commit 7e93a7ab2f
64 changed files with 3475 additions and 3293 deletions
-2
View File
@@ -107,14 +107,12 @@ H5GetErrorHandler (
h5_err_t
H5ReportErrorhandler (
const h5_file_t * const f,
const char *fmt,
va_list ap
);
h5_err_t
H5AbortErrorhandler (
const h5_file_t * const f,
const char *fmt,
va_list ap
);
+119 -6
View File
@@ -3,14 +3,127 @@
#define UNUSED_ARGUMENT(x) (void)x
#define TRY( func ) \
if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) \
return H5_ERR; \
#define H5_DEBUG_USER (1<<2)
#define H5_DEBUG_API (1<<3)
#define H5_DEBUG_CORE_API (1<<4)
#define H5_DEBUG_PRIV_API (1<<5)
#define H5_DEBUG_PRIV_FUNC (1<<6)
#define H5_DEBUG_HDF5 (1<<7)
#define H5_DEBUG_MALLOC (1<<8)
#define H5_DEBUG_CLIB (1<<9)
#define H5_DEBUG_ALL (-1)
#define TRY2( func ) \
if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) \
goto done; \
extern char* h5_rfmts[];
#define __FUNC_ENTER(type) \
h5_call_stack_push (__func__,e_##type); \
type ret_value = (type)H5_ERR;
#define __FUNC_ARGS0(mask) \
if (h5_debug_level & mask ) { \
h5_debug ("(void)"); \
}
#define __FUNC_ARGS1(fmt, a1, mask) \
if (h5_debug_level & mask ) { \
h5_debug ("(" fmt ")", a1); \
}
#define __FUNC_ARGS2(fmt, a1, a2, mask) \
if (h5_debug_level & mask ) { \
h5_debug ("(" fmt ")", a1, a2); \
}
#define __FUNC_ARGS3(fmt, a1, a2, a3, mask) \
if (h5_debug_level & mask ) { \
h5_debug ("(" fmt ")", a1, a2, a3); \
}
#define __FUNC_ARGS4(fmt, a1, a2, a3, a4, mask) \
if (h5_debug_level & mask ) { \
h5_debug ("(" fmt ")", a1, a2, a3, a4); \
}
#define __FUNC_ARGS5(fmt, a1, a2, a3, a4, a5, mask) \
if (h5_debug_level & mask ) { \
h5_debug ("(" fmt ")", a1, a2, a3, a4, a5); \
}
#define __FUNC_ENTER0(type, mask) \
__FUNC_ENTER(type); \
__FUNC_ARGS0(mask);
#define __FUNC_ENTER1(type, fmt, a1, mask) \
__FUNC_ENTER(type); \
__FUNC_ARGS1(fmt, a1, mask);
#define __FUNC_ENTER2(type, fmt, a1, a2, mask) \
__FUNC_ENTER(type); \
__FUNC_ARGS2(fmt, a1, a2, mask);
#define __FUNC_ENTER3(type, fmt, a1, a2, a3, mask) \
__FUNC_ENTER(type); \
__FUNC_ARGS3(fmt, a1, a2, a3, mask);
#define __FUNC_ENTER4(type, fmt, a1, a2, a3, a4, mask) \
__FUNC_ENTER(type); \
__FUNC_ARGS4(fmt, a1, a2, a3, a4, mask);
#define __FUNC_ENTER5(type, fmt, a1, a2, a3, a4, a5, mask) \
__FUNC_ENTER(type); \
__FUNC_ARGS5(fmt, a1, a2, a3, a4, a5, mask);
#define __FUNC_LEAVE(expr) { \
ret_value = expr; \
goto done; \
}
#define __FUNC_RETURN(expr, mask) \
ret_value = expr; \
goto done; \
done: \
if (h5_debug_level & mask ) { \
char fmt[256]; \
snprintf (fmt, sizeof(fmt), "return: %s", \
h5_rfmts[h5_call_stack_get_type()]); \
h5_debug (fmt, ret_value); \
} \
h5_call_stack_pop(); \
return ret_value;
#define H5_API_ENTER(type) \
if (!h5_initialized) { \
h5_initialize(); \
} \
__FUNC_ENTER(type);
#define H5_API_ENTER1(type, fmt, a1) \
H5_API_ENTER(type); \
__FUNC_ARGS1(fmt, a1, H5_DEBUG_API)
#define H5_API_ENTER2(type, fmt, a1, a2) \
H5_API_ENTER(type); \
__FUNC_ARGS2(fmt, a1,a2, H5_DEBUG_API)
#define H5_API_ENTER3(type, fmt, a1, a2, a3) \
H5_API_ENTER(type); \
__FUNC_ARGS3(fmt, a1,a2,a3, H5_DEBUG_API)
#define H5_API_LEAVE(expr) __FUNC_LEAVE(expr)
#define H5_API_RETURN(expr) __FUNC_RETURN(expr, H5_DEBUG_API);
#define TRY( func ) \
if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) { \
ret_value = H5_ERR; \
goto done; \
}
#define TRY2( func ) \
if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) { \
ret_value = (void*) H5_ERR; \
goto done; \
}
#include "h5_types.h"
#include "h5_errno.h"
+125 -64
View File
@@ -1,44 +1,77 @@
#ifndef __H5_ERRORHANDLING_H
#define __H5_ERRORHANDLING_H
extern h5_int32_t h5priv_debug_level;
enum h5_rtypes {
e_int = 0,
e_ssize_t,
e_char_p,
e_void_p,
e_h5_err_t,
e_h5_int64_t,
e_h5_id_t,
e_h5_ssize_t,
e_h5_errorhandler_t,
e_h5_file_p,
e_h5t_lvl_idx_t,
e_h5t_iterator_p,
e_h5_loc_id_t,
e_h5_loc_idx_t,
e_hid_t,
e_H5O_type_t,
e_herr_t
};
struct call_stack_entry {
char* name;
enum h5_rtypes type;
};
struct call_stack {
int level;
struct call_stack_entry entry[1024];
};
extern h5_int32_t h5_debug_level;
extern int h5_initialized;
extern struct call_stack h5_call_stack;
extern h5_err_t h5_errno;
void
h5_initialize (
void
);
#define CHECK_FILEHANDLE( f ) \
if ( h5_check_filehandle ( f ) != H5_SUCCESS ) \
return h5_get_errno( f );
return h5_get_errno();
#define CHECK_WRITABLE_MODE( f ) \
if ( f->mode==H5_O_RDONLY ) \
return h5_error ( \
f, \
H5_ERR_INVAL, \
"Attempting to write to read-only file" );
#define CHECK_READONLY_MODE( f ) \
if ( ! f->mode==H5_O_RDONLY ) \
return h5_error ( \
f, \
H5_ERR_INVAL, \
"Operation is not allowed on writable files." );
#define CHECK_TIMEGROUP( f ) \
if ( f->step_gid <= 0 ) \
return h5_error ( \
f, \
H5_ERR_INVAL, \
"Time step is invalid! Have you set the time step?");
#define h5_error_not_implemented( f, file, func, lino ) \
#define h5_error_not_implemented( file, func, lino ) \
h5_error( \
f, \
H5_ERR_NOT_IMPLEMENTED, \
"%s: Function \"%s\", line %d not yet implemented!", \
file, func, lino );
#define h5_error_internal( f, file, func, lino ) \
#define h5_error_internal( file, func, lino ) \
h5_error( \
f, \
H5_ERR_INTERNAL, \
"%s: Internal error: %s line %d!", \
file, func, lino )
@@ -66,25 +99,85 @@ h5_get_errorhandler (
h5_err_t
h5_get_errno (
const h5_file_t * const f
void
);
void
h5_set_errno (
h5_file_t * const f,
const h5_err_t h5_errno
);
static inline void
h5_call_stack_init (
const char* fname,
enum h5_rtypes type
) {
h5_call_stack.level = 0;
h5_call_stack.entry[0].name = (char *)fname;
h5_call_stack.entry[0].type = type;
}
static inline void
h5_call_stack_push (
const char* fname,
enum h5_rtypes type
) {
h5_call_stack.entry[h5_call_stack.level].name = (char *)fname;
h5_call_stack.entry[h5_call_stack.level].type = type;
h5_call_stack.level++;
}
static inline const char*
h5_call_stack_pop (
void
) {
return h5_call_stack.entry[--h5_call_stack.level].name;
}
static inline const char*
h5_call_stack_get_name (
void
) {
return h5_call_stack.entry[h5_call_stack.level-1].name;
}
static inline const char*
h5_get_funcname (
void
) {
return h5_call_stack.entry[0].name;
}
static inline enum h5_rtypes
h5_call_stack_get_type (
void
) {
return h5_call_stack.entry[h5_call_stack.level-1].type;
}
static inline int
h5_call_stack_get_level (
void
) {
return h5_call_stack.level;
}
static inline const char*
h5_call_stack_reset (
void
) {
h5_call_stack.level = 0;
return h5_call_stack.entry[0].name;
}
h5_err_t
h5_report_errorhandler (
const h5_file_t * const f,
const char *fmt,
va_list ap
);
h5_err_t
h5_abort_errorhandler (
const h5_file_t * const f,
const char *fmt,
va_list ap
);
@@ -98,27 +191,19 @@ h5priv_vprintf (
va_list ap
);
const char *
h5_get_funcname (
const h5_file_t * const f
);
h5_err_t
h5_error (
h5_file_t * const f,
const h5_err_t error_no,
const char *fmt,
...
)
#ifdef __GNUC__
__attribute__ ((format (printf, 3, 4)))
__attribute__ ((format (printf, 2, 3)))
#endif
;
void
h5_verror (
const h5_file_t* const f,
const char* fmt,
va_list ap
);
@@ -129,28 +214,27 @@ h5_verror (
Print a warning message to \c stderr.
*/
static inline void
static inline h5_err_t
h5_warn (
const h5_file_t * const f,
const char *fmt,
...
)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
__attribute__ ((format (printf, 1, 2)))
#endif
;
static inline void
static inline h5_err_t
h5_warn (
const h5_file_t* const f,
const char* fmt,
...
) {
if (h5priv_debug_level >= 2) {
if (h5_debug_level >= 2) {
va_list ap;
va_start (ap, fmt);
h5priv_vprintf (stderr, "W", h5_get_funcname(f), fmt, ap);
h5priv_vprintf (stderr, "W", h5_get_funcname(), fmt, ap);
va_end (ap);
}
return H5_NOK;
}
/*!
@@ -160,24 +244,22 @@ h5_warn (
*/
static inline void
h5_info (
const h5_file_t * const f,
const char *fmt,
...
)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
__attribute__ ((format (printf, 1, 2)))
#endif
;
static inline void
h5_info (
const h5_file_t* const f,
const char* fmt,
...
) {
if (h5priv_debug_level >= 3) {
if (h5_debug_level >= 3) {
va_list ap;
va_start (ap, fmt);
h5priv_vprintf (stdout, "I", h5_get_funcname(f), fmt, ap);
h5priv_vprintf (stdout, "I", h5_get_funcname(), fmt, ap);
va_end (ap);
}
}
@@ -187,53 +269,32 @@ h5_info (
Print a debug message to \c stdout.
*/
#if defined(HAVE__VA_ARGS__)
#define h5_debug(f, ...) \
if (h5priv_debug_level >= 4) { \
h5priv_vprintf (stdout, "D", h5_get_funcname(f), __VA_ARGS__); \
}
#else
static inline void
h5_debug (
const h5_file_t * const f,
const char *fmt,
...
)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
__attribute__ ((format (printf, 1, 2)))
#endif
;
static inline void
h5_debug (
const h5_file_t * const f,
const char *fmt,
...
) {
if (h5priv_debug_level >= 4) {
if (h5_debug_level >= 4) {
char prefix[256];
snprintf (prefix, sizeof(prefix), "(%d) %s",
h5_call_stack_get_level(),
h5_call_stack_get_name());
va_list ap;
va_start (ap, fmt);
h5priv_vprintf (stdout, "D", h5_get_funcname(f), fmt, ap);
h5priv_vprintf (stdout, "D", prefix, fmt, ap);
va_end (ap);
}
}
#endif
void
h5_set_funcname (
h5_file_t * const f,
const char * const fname
);
#define H5_API_ENTER { \
h5_set_funcname( f, __func__ ); \
h5_debug (f, "%s", " "); \
} \
#define H5_API_RETURN(retval) \
\
goto done; \
done: \
return retval; \
#endif
-5
View File
@@ -3,20 +3,17 @@
ssize_t
h5_get_num_hdf5_groups (
h5_file_t* const f,
const hid_t loc_id
);
ssize_t
h5_get_num_hdf5_groups_matching_prefix (
h5_file_t* const f,
const hid_t loc_id,
char* prefix
);
h5_err_t
h5_get_hdf5_groupname_by_idx (
h5_file_t* const f,
hid_t loc_id,
hsize_t idx,
char *name,
@@ -25,13 +22,11 @@ h5_get_hdf5_groupname_by_idx (
ssize_t
h5_get_num_hdf5_datasets (
h5_file_t* const f,
const hid_t loc_id
);
h5_err_t
h5_get_hdf5_datasetname_by_idx (
h5_file_t* const f,
hid_t loc_id,
hsize_t idx,
char *name,
+1 -2
View File
@@ -5,8 +5,7 @@ h5_file_t *
h5_open_file (
const char *filename,
h5_int32_t flags,
MPI_Comm comm,
const char *funcname
MPI_Comm comm
);
h5_int64_t
-3
View File
@@ -3,21 +3,18 @@
void*
h5_alloc (
h5_file_t* const f,
void* ptr,
const size_t size
);
void*
h5_calloc (
h5_file_t* const f,
const size_t count,
const size_t size
);
h5_err_t
h5_free (
h5_file_t* const f,
void* ptr
);
#endif
+5 -3
View File
@@ -51,6 +51,8 @@ typedef uint64_t h5_size_t; /* size in number of elements */
typedef int64_t h5_ssize_t; /* size in number of elements */
typedef int64_t h5_err_t;
typedef char* char_p;
typedef void* void_p;
typedef double h5_float64_t;
typedef float h5_float32_t;
@@ -62,15 +64,15 @@ typedef h5_float64_t h5_coord3d_t[3];
struct h5_file;
typedef struct h5_file h5_file_t;
typedef h5_file_t* h5_file_p;
typedef h5_err_t (*h5_errorhandler_t)(
const h5_file_t * const,
const char*,
va_list ap );
#ifndef PARALLEL_IO
typedef unsigned long MPI_Comm;
typedef unsigned long MPI_Datatype;
typedef int MPI_Comm;
typedef int MPI_Datatype;
#endif
typedef struct h5_loc_idlist {
+4 -4
View File
@@ -1,24 +1,24 @@
#ifndef __H5T_INQUIRY_H
#define __H5T_INQUIRY_H
h5_size_t
h5_ssize_t
h5t_get_num_meshes (
h5_file_t * const f,
const enum h5_oid type
);
h5_size_t
h5_ssize_t
h5t_get_num_leaf_levels (
h5_file_t * const f
);
h5_size_t
h5_ssize_t
h5t_get_num_elems (
h5_file_t * const f,
const h5_id_t cnode
);
h5_size_t
h5_ssize_t
h5t_get_num_vertices (
h5_file_t * const f,
const h5_id_t cnode
+1
View File
@@ -45,6 +45,7 @@ typedef union h5t_iterator {
h5t_generic_iterator_t generic;
} h5t_iterator_t;
typedef h5t_iterator_t* h5t_iterator_p;
h5_err_t
h5t_init_leaf_iterator (