diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2020-11-25 05:58:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 05:58:16 (GMT) |
commit | b7bfe68968330c3ac39f4d4179498caec1e0ae24 (patch) | |
tree | 83784a6cfd580f3d70f44195b2e0b0b7e150560b /src/H5Idbg.c | |
parent | ea17afe305d40de1ae8682c62978edf42763469b (diff) | |
download | hdf5-b7bfe68968330c3ac39f4d4179498caec1e0ae24.zip hdf5-b7bfe68968330c3ac39f4d4179498caec1e0ae24.tar.gz hdf5-b7bfe68968330c3ac39f4d4179498caec1e0ae24.tar.bz2 |
Cherry pick of Minor/id code cleanup (#114) (#124)
* Revert "Switch ID code to use a hash table instead of a skip list (#52)"
This reverts commit a50d211755cb272b2e468144e7d892a4c90813c4.
* H5I_id_type_t and H5I_class_t are no longer managed via free lists
* Fixed commenting issues
* Naming and commenting cleanup in H5I.c
* H5I cleanup
* Header cleanup
* Commenting
* More uniform naming
* Renames H5I_id_type_t and related in H5I.c
* Adds gcc pragmas to ignore H5I const casting
* Split H5I code into multiple files
* Rename id_type to simply type in H5I code
* Minor typo in H5Itest.c
Diffstat (limited to 'src/H5Idbg.c')
-rw-r--r-- | src/H5Idbg.c | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/src/H5Idbg.c b/src/H5Idbg.c new file mode 100644 index 0000000..3d6d401 --- /dev/null +++ b/src/H5Idbg.c @@ -0,0 +1,191 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * H5Idbg.c - Debugging routines for handling IDs + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Imodule.h" /* This source code file is part of the H5I module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ +#include "H5RSprivate.h" /* Reference-counted strings */ +#include "H5SLprivate.h" /* Skip Lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5I__id_dump_cb + * + * Purpose: Dump the contents of an ID to stderr for debugging. + * + * Return: H5_ITER_CONT (always) + * + *------------------------------------------------------------------------- + */ +static int +H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) +{ + H5I_id_info_t *info = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ + H5G_name_t * path = NULL; /* Path to file object */ + const void * object = NULL; /* Pointer to VOL connector object */ + + FUNC_ENTER_STATIC_NOERR + + HDfprintf(stderr, " id = %" PRIdHID "\n", info->id); + HDfprintf(stderr, " count = %u\n", info->count); + HDfprintf(stderr, " obj = 0x%8p\n", info->object); + + /* Get the group location, so we get get the name */ + switch (type) { + case H5I_GROUP: { + const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->object; + + object = H5VL_object_data(vol_obj); + if (H5_VOL_NATIVE == vol_obj->connector->cls->value) + path = H5G_nameof((const H5G_t *)object); + break; + } + + case H5I_DATASET: { + const H5VL_object_t *vol_obj = (const H5VL_object_t *)info->object; + + object = H5VL_object_data(vol_obj); + if (H5_VOL_NATIVE == vol_obj->connector->cls->value) + path = H5D_nameof((const H5D_t *)object); + break; + } + + case H5I_DATATYPE: { + const H5T_t *dt = (const H5T_t *)info->object; + + H5_GCC_DIAG_OFF("cast-qual") + object = (void *)H5T_get_actual_type((H5T_t *)dt); /* Casting away const OK - QAK */ + H5_GCC_DIAG_ON("cast-qual") + + path = H5T_nameof((const H5T_t *)object); + break; + } + + /* TODO: Maps will have to be added when they are supported in the + * native VOL connector. + */ + case H5I_MAP: + + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_DATASPACE: + case H5I_ATTR: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_SPACE_SEL_ITER: + case H5I_NTYPES: + default: + break; /* Other types of IDs are not stored in files */ + } + + if (path) { + if (path->user_path_r) + HDfprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); + if (path->full_path_r) + HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); + } + + FUNC_LEAVE_NOAPI(H5_ITER_CONT) +} /* end H5I__id_dump_cb() */ + +/*------------------------------------------------------------------------- + * Function: H5I_dump_ids_for_type + * + * Purpose: Dump the contents of a type to stderr for debugging. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_dump_ids_for_type(H5I_type_t type) +{ + H5I_type_info_t *type_info = NULL; + + FUNC_ENTER_NOAPI_NOERR + + HDfprintf(stderr, "Dumping ID type %d\n", (int)type); + type_info = H5I_type_info_array_g[type]; + + if (type_info) { + + /* Header */ + HDfprintf(stderr, " init_count = %u\n", type_info->init_count); + HDfprintf(stderr, " reserved = %u\n", type_info->cls->reserved); + HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_info->id_count); + HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_info->nextid); + + /* List */ + if (type_info->id_count > 0) { + HDfprintf(stderr, " List:\n"); + H5SL_iterate(type_info->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() */ |