From 1b2c820b4bdb0a176cba20ccdb87b07f7ab5eede Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 5 Oct 2018 21:47:51 -0700 Subject: The H5I debug ID dump function is now always available instead of hidden behind an H5_DEBUG_OUTPUT ifdef. --- src/H5I.c | 41 +++++++++++++++-------------------------- src/H5Iprivate.h | 3 +++ 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/H5I.c b/src/H5I.c index 293a0ea..61b2783 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -26,28 +26,22 @@ */ #include "H5Imodule.h" /* This source code file is part of the H5I module */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ #include "H5private.h" /* Generic Functions */ #include "H5ACprivate.h" /* Metadata cache */ #include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ +#include "H5Gprivate.h" /* Groups */ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5SLprivate.h" /* Skip Lists */ +#include "H5Tpkg.h" /* Datatypes */ -/* Define this to compile in support for dumping ID information */ -/* #define H5I_DEBUG_OUTPUT */ -#ifndef H5I_DEBUG_OUTPUT -#include "H5Gprivate.h" /* Groups */ -#else /* H5I_DEBUG_OUTPUT */ -#define H5G_FRIEND /* Suppress error about including H5Gpkg */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Tprivate.h" /* Datatypes */ -#endif /* H5I_DEBUG_OUTPUT */ /* Local Macros */ @@ -129,10 +123,7 @@ static int H5I__get_type_ref(H5I_type_t type); static int H5I__search_cb(void *obj, hid_t id, void *_udata); static H5I_id_info_t *H5I__find_id(hid_t id); static hid_t H5I__get_file_id(hid_t obj_id, H5I_type_t id_type); -#ifdef H5I_DEBUG_OUTPUT -static int H5I__debug_cb(void *_item, void *_key, void *_udata); -static herr_t H5I__debug(H5I_type_t type); -#endif /* H5I_DEBUG_OUTPUT */ +static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); /*------------------------------------------------------------------------- @@ -2110,10 +2101,9 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__get_file_id() */ -#ifdef H5I_DEBUG_OUTPUT /*------------------------------------------------------------------------- - * Function: H5I__debug_cb + * Function: H5I__id_dump_cb * * Purpose: Dump the contents of an ID to stderr for debugging. * @@ -2122,7 +2112,7 @@ done: *------------------------------------------------------------------------- */ static int -H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) +H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ @@ -2176,11 +2166,11 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) } FUNC_LEAVE_NOAPI(H5_ITER_CONT) -} /* end H5I__debug_cb() */ +} /* end H5I__id_dump_cb() */ /*------------------------------------------------------------------------- - * Function: H5I__debug + * Function: H5I_dump_ids_for_type * * Purpose: Dump the contents of a type to stderr for debugging. * @@ -2188,12 +2178,12 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) * *------------------------------------------------------------------------- */ -static herr_t -H5I__debug(H5I_type_t type) +herr_t +H5I_dump_ids_for_type(H5I_type_t type) { - H5I_id_type_t *type_ptr; + H5I_id_type_t *type_ptr = NULL; - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_NOAPI_NOERR HDfprintf(stderr, "Dumping ID type %d\n", (int)type); type_ptr = H5I_id_type_list_g[type]; @@ -2206,9 +2196,8 @@ H5I__debug(H5I_type_t type) /* List */ HDfprintf(stderr, " List:\n"); - H5SL_iterate(type_ptr->ids, H5I__debug_cb, &type); + H5SL_iterate(type_ptr->ids, H5I__id_dump_cb, &type); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5I__debug() */ -#endif /* H5I_DEBUG_OUTPUT */ +} /* end H5I_dump_ids_for_type() */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index a10147d..6a0fc01 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -81,5 +81,8 @@ H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_always_close(hid_t id); H5_DLL int H5I_dec_type_ref(H5I_type_t type); +/* Debugging functions */ +H5_DLL herr_t H5I_dump_ids_for_type(H5I_type_t type); + #endif /* _H5Iprivate_H */ -- cgit v0.12 From 75b84b09bd249b36a063fd51ecd3383801b0118b Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 5 Oct 2018 22:16:51 -0700 Subject: Updated the H5I debug dump to not segfault when types are not initialized or contain zero IDs in the skip list. --- src/H5I.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/H5I.c b/src/H5I.c index 61b2783..34874c7 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -2188,15 +2188,22 @@ H5I_dump_ids_for_type(H5I_type_t type) HDfprintf(stderr, "Dumping ID type %d\n", (int)type); type_ptr = H5I_id_type_list_g[type]; - /* Header */ - HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); - HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); - HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count); - HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); - - /* List */ - HDfprintf(stderr, " List:\n"); - H5SL_iterate(type_ptr->ids, H5I__id_dump_cb, &type); + if(type_ptr) { + + /* Header */ + HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); + HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); + HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count); + HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); + + /* List */ + if(type_ptr->id_count > 0) { + HDfprintf(stderr, " List:\n"); + H5SL_iterate(type_ptr->ids, H5I__id_dump_cb, &type); + } + } + else + HDfprintf(stderr, "Global type info/tracking pointer for that type is NULL\n"); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5I_dump_ids_for_type() */ -- cgit v0.12