Skip to content

Commit

Permalink
Fix bin/trace script w/ out params (HDFGroup#4074)
Browse files Browse the repository at this point in the history
The bin/trace script adds TRACE macros to public API calls in the main
C library. This script had a parsing bug that caused functions that
were annotated with /*out*/, etc. to be labeled as void pointers
instead of typed pointers.

This is mainly a developer feature and not visible to consumers
of the public API.

The bin/trace script now annotates public API calls properly.

Fixes GH HDFGroup#3733
  • Loading branch information
derobins authored and lrknox committed Mar 21, 2024
1 parent 87bb0c5 commit 59a62b7
Show file tree
Hide file tree
Showing 58 changed files with 366 additions and 323 deletions.
23 changes: 16 additions & 7 deletions bin/trace
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ $Source = "";
"H5A_operator1_t" => "Ao",
"H5A_operator2_t" => "AO",
"hbool_t" => "b",
"bool" => "b",
"H5AC_cache_config_t" => "Cc",
"H5AC_cache_image_config_t" => "CC",
"double" => "d",
Expand Down Expand Up @@ -74,6 +75,7 @@ $Source = "";
"H5F_file_space_type_t" => "Ft",
"H5F_libver_t" => "Fv",
"H5G_iterate_t" => "Gi",
"H5G_info_t" => "GI",
"H5G_obj_t" => "Go",
"H5G_stat_t" => "Gs",
"hsize_t" => "h",
Expand Down Expand Up @@ -199,7 +201,7 @@ $Source = "";
"H5FD_t" => "#",
"H5FD_hdfs_fapl_t" => "#",
"H5FD_mirror_fapl_t" => "#",
"H5FD_onion_fapl_t" => "#",
"H5FD_onion_fapl_t" => "#",
"H5FD_ros3_fapl_t" => "#",
"H5FD_splitter_vfd_config_t" => "#",
"H5L_class_t" => "#",
Expand Down Expand Up @@ -305,10 +307,18 @@ sub rewrite_func ($$$$$) {
$trace = "H5TRACE0(\"$rettype\", \"\");\n";
$argtrace = "H5ARG_TRACE0(\"\")";
} else {
# Split arguments. First convert `/*in,out*/' to get rid of the
# comma and remove lines beginning with a '#', then split the arguments
# on commas.
$args =~ s/(\/\*\s*in),\s*(out\s*\*\/)/$1_$2/g; # Get rid of comma in 'in,out'
# Split arguments
#
# First remove:
# * /*in*/, /*out*/, /*in_out*/, and /*in,out*/ comments
# * preprocessor lines that start with #
# * H5FL_TRACKING_PARAMS macros (free list code only)
#
# then split the function arguments on commas
$args =~ s/\/\*\s*in\s*\*\///g; # Get rid of /*in*/
$args =~ s/\/\*\s*out\s*\*\///g; # Get rid of /*out*/
$args =~ s/\/\*\s*in,\s*out\s*\*\///g; # Get rid of /*in,out*/
$args =~ s/\/\*\s*in_out\s*\*\///g; # Get rid of /*in_out*/
$args =~ s/H5FL_TRACK_PARAMS//g; # Remove free list macro
$args =~ s/\n#.*?\n/\n/g; # Remove lines beginning with '#'
my @args = split /,[\s\n]*/, $args;
Expand All @@ -320,8 +330,7 @@ sub rewrite_func ($$$$$) {
next;
}
unless ($arg=~/^((\s*[a-z_A-Z](\w|\*)*\s+)+(\s*\*\s*|\s*const\s*|\s*volatile\s*)*)
([a-z_A-Z]\w*)(\[.*?\])?
(\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) {
([a-z_A-Z]\w*)(\[.*?\])?\s*$/x) {
errmesg $file, $name, "unable to parse \`$arg\'";
goto error;
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/H5.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ H5get_free_list_sizes(size_t *reg_size /*out*/, size_t *arr_size /*out*/, size_t
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE4("e", "xxxx", reg_size, arr_size, blk_size, fac_size);
H5TRACE4("e", "*z*z*z*z", reg_size, arr_size, blk_size, fac_size);

/* Call the free list function to actually get the sizes */
if (H5FL_get_free_list_sizes(reg_size, arr_size, blk_size, fac_size) < 0)
Expand Down Expand Up @@ -814,7 +814,7 @@ H5get_libversion(unsigned *majnum /*out*/, unsigned *minnum /*out*/, unsigned *r
herr_t ret_value = SUCCEED;

FUNC_ENTER_API(FAIL)
H5TRACE3("e", "xxx", majnum, minnum, relnum);
H5TRACE3("e", "*Iu*Iu*Iu", majnum, minnum, relnum);

/* Set the version information */
if (majnum)
Expand Down Expand Up @@ -1216,7 +1216,7 @@ H5is_library_threadsafe(bool *is_ts /*out*/)
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API_NOINIT
H5TRACE1("e", "x", is_ts);
H5TRACE1("e", "*b", is_ts);

if (is_ts) {
#ifdef H5_HAVE_THREADSAFE
Expand Down Expand Up @@ -1251,7 +1251,7 @@ H5is_library_terminating(bool *is_terminating /*out*/)
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API_NOINIT
H5TRACE1("e", "x", is_terminating);
H5TRACE1("e", "*b", is_terminating);

assert(is_terminating);

Expand Down
16 changes: 8 additions & 8 deletions src/H5A.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ H5Aread(hid_t attr_id, hid_t dtype_id, void *buf /*out*/)
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE3("e", "iix", attr_id, dtype_id, buf);
H5TRACE3("e", "ii*x", attr_id, dtype_id, buf);

/* Synchronously read the data */
if (H5A__read_api_common(attr_id, dtype_id, buf, NULL, NULL) < 0)
Expand Down Expand Up @@ -1064,7 +1064,7 @@ H5Aread_async(const char *app_file, const char *app_func, unsigned app_line, hid
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE7("e", "*s*sIuiixi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id);
H5TRACE7("e", "*s*sIuii*xi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id);

/* Set up request token pointer for asynchronous operation */
if (H5ES_NONE != es_id)
Expand All @@ -1078,7 +1078,7 @@ H5Aread_async(const char *app_file, const char *app_func, unsigned app_line, hid
if (NULL != token)
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE7(__func__, "*s*sIuiixi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id)) < 0)
H5ARG_TRACE7(__func__, "*s*sIuii*xi", app_file, app_func, app_line, attr_id, dtype_id, buf, es_id)) < 0)
/* clang-format on */
HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "can't insert token into event set");

Expand Down Expand Up @@ -1257,7 +1257,7 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf /*out*/)
ssize_t ret_value = -1; /* Return value */

FUNC_ENTER_API((-1))
H5TRACE3("Zs", "izx", attr_id, buf_size, buf);
H5TRACE3("Zs", "iz*s", attr_id, buf_size, buf);

/* check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
Expand Down Expand Up @@ -1308,7 +1308,7 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i
ssize_t ret_value; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE8("Zs", "i*sIiIohxzi", loc_id, obj_name, idx_type, order, n, name, size, lapl_id);
H5TRACE8("Zs", "i*sIiIoh*szi", loc_id, obj_name, idx_type, order, n, name, size, lapl_id);

/* Check args */
if (H5I_ATTR == H5I_get_type(loc_id))
Expand Down Expand Up @@ -1416,7 +1416,7 @@ H5Aget_info(hid_t attr_id, H5A_info_t *ainfo /*out*/)
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", attr_id, ainfo);
H5TRACE2("e", "i*Ai", attr_id, ainfo);

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR)))
Expand Down Expand Up @@ -1458,7 +1458,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE5("e", "i*s*sxi", loc_id, obj_name, attr_name, ainfo, lapl_id);
H5TRACE5("e", "i*s*s*Aii", loc_id, obj_name, attr_name, ainfo, lapl_id);

/* Check args */
if (H5I_ATTR == H5I_get_type(loc_id))
Expand Down Expand Up @@ -1515,7 +1515,7 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE7("e", "i*sIiIohxi", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id);
H5TRACE7("e", "i*sIiIoh*Aii", loc_id, obj_name, idx_type, order, n, ainfo, lapl_id);

/* Check args */
if (H5I_ATTR == H5I_get_type(loc_id))
Expand Down
32 changes: 16 additions & 16 deletions src/H5D.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation /*out*/)
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", dset_id, allocation);
H5TRACE2("e", "i*Ds", dset_id, allocation);

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
Expand Down Expand Up @@ -1053,7 +1053,7 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_i
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf);
H5TRACE6("e", "iiiii*x", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf);

/* Read the data */
if (H5D__read_api_common(1, &dset_id, &mem_type_id, &mem_space_id, &file_space_id, dxpl_id, &buf, NULL,
Expand Down Expand Up @@ -1083,7 +1083,7 @@ H5Dread_async(const char *app_file, const char *app_func, unsigned app_line, hid
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE10("e", "*s*sIuiiiiixi", app_file, app_func, app_line, dset_id, mem_type_id, mem_space_id,
H5TRACE10("e", "*s*sIuiiiii*xi", app_file, app_func, app_line, dset_id, mem_type_id, mem_space_id,
file_space_id, dxpl_id, buf, es_id);

/* Set up request token pointer for asynchronous operation */
Expand All @@ -1099,7 +1099,7 @@ H5Dread_async(const char *app_file, const char *app_func, unsigned app_line, hid
if (NULL != token)
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE10(__func__, "*s*sIuiiiiixi", app_file, app_func, app_line, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, es_id)) < 0)
H5ARG_TRACE10(__func__, "*s*sIuiiiii*xi", app_file, app_func, app_line, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, es_id)) < 0)
/* clang-format on */
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert token into event set");

Expand All @@ -1124,7 +1124,7 @@ H5Dread_multi(size_t count, hid_t dset_id[], hid_t mem_type_id[], hid_t mem_spac
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE7("e", "z*i*i*i*iix", count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf);
H5TRACE7("e", "z*i*i*i*ii**x", count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf);

if (count == 0)
HGOTO_DONE(SUCCEED);
Expand Down Expand Up @@ -1159,7 +1159,7 @@ H5Dread_multi_async(const char *app_file, const char *app_func, unsigned app_lin
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE11("e", "*s*sIuz*i*i*i*iixi", app_file, app_func, app_line, count, dset_id, mem_type_id,
H5TRACE11("e", "*s*sIuz*i*i*i*ii**xi", app_file, app_func, app_line, count, dset_id, mem_type_id,
mem_space_id, file_space_id, dxpl_id, buf, es_id);

/* Set up request token pointer for asynchronous operation */
Expand All @@ -1175,7 +1175,7 @@ H5Dread_multi_async(const char *app_file, const char *app_func, unsigned app_lin
if (NULL != token)
/* clang-format off */
if (H5ES_insert(es_id, vol_obj->connector, token,
H5ARG_TRACE11(__func__, "*s*sIuz*i*i*i*iixi", app_file, app_func, app_line, count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, es_id)) < 0)
H5ARG_TRACE11(__func__, "*s*sIuz*i*i*i*ii**xi", app_file, app_func, app_line, count, dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, es_id)) < 0)
/* clang-format on */
HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "can't insert token into event set");

Expand All @@ -1201,7 +1201,7 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE5("e", "ii*h*Iux", dset_id, dxpl_id, offset, filters, buf);
H5TRACE5("e", "ii*h*Iu*x", dset_id, dxpl_id, offset, filters, buf);

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
Expand Down Expand Up @@ -1581,7 +1581,7 @@ H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE5("e", "DS*xiix", op, op_data, type_id, dst_space_id, dst_buf);
H5TRACE5("e", "DS*xii*x", op, op_data, type_id, dst_space_id, dst_buf);

/* Check args */
if (op == NULL)
Expand Down Expand Up @@ -1674,7 +1674,7 @@ H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE7("e", "i*xizxDg*x", src_space_id, src_buf, type_id, dst_buf_size, dst_buf, op, op_data);
H5TRACE7("e", "i*xiz*xDg*x", src_space_id, src_buf, type_id, dst_buf_size, dst_buf, op, op_data);

/* Check args */
if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE)))
Expand Down Expand Up @@ -1906,7 +1906,7 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *s
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE4("e", "iiix", dataset_id, type_id, space_id, size);
H5TRACE4("e", "iii*h", dataset_id, type_id, space_id, size);

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(dataset_id)))
Expand Down Expand Up @@ -2201,7 +2201,7 @@ H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type /*out*/)
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE2("e", "ix", dset_id, idx_type);
H5TRACE2("e", "i*Dk", dset_id, idx_type);

/* Check args */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
Expand Down Expand Up @@ -2243,7 +2243,7 @@ H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_n
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_API(FAIL)
H5TRACE3("e", "i*hx", dset_id, offset, chunk_nbytes);
H5TRACE3("e", "i*h*h", dset_id, offset, chunk_nbytes);

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
Expand Down Expand Up @@ -2294,7 +2294,7 @@ H5Dget_num_chunks(hid_t dset_id, hid_t fspace_id, hsize_t *nchunks /*out*/)
herr_t ret_value = SUCCEED;

FUNC_ENTER_API(FAIL)
H5TRACE3("e", "iix", dset_id, fspace_id, nchunks);
H5TRACE3("e", "ii*h", dset_id, fspace_id, nchunks);

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
Expand Down Expand Up @@ -2346,7 +2346,7 @@ H5Dget_chunk_info(hid_t dset_id, hid_t fspace_id, hsize_t chk_index, hsize_t *of
herr_t ret_value = SUCCEED;

FUNC_ENTER_API(FAIL)
H5TRACE7("e", "iihxxxx", dset_id, fspace_id, chk_index, offset, filter_mask, addr, size);
H5TRACE7("e", "iih*h*Iu*a*h", dset_id, fspace_id, chk_index, offset, filter_mask, addr, size);

/* Check arguments */
if (NULL == offset && NULL == filter_mask && NULL == addr && NULL == size)
Expand Down Expand Up @@ -2415,7 +2415,7 @@ H5Dget_chunk_info_by_coord(hid_t dset_id, const hsize_t *offset, unsigned *filte
herr_t ret_value = SUCCEED;

FUNC_ENTER_API(FAIL)
H5TRACE5("e", "i*hxxx", dset_id, offset, filter_mask, addr, size);
H5TRACE5("e", "i*h*Iu*a*h", dset_id, offset, filter_mask, addr, size);

/* Check arguments */
if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET)))
Expand Down
6 changes: 3 additions & 3 deletions src/H5E.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ H5Eget_class_name(hid_t class_id, char *name /*out*/, size_t size)
ssize_t ret_value = -1; /* Return value */

FUNC_ENTER_API((-1))
H5TRACE3("Zs", "ixz", class_id, name, size);
H5TRACE3("Zs", "i*sz", class_id, name, size);

/* Get the error class */
if (NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS)))
Expand Down Expand Up @@ -774,7 +774,7 @@ H5Eget_msg(hid_t msg_id, H5E_type_t *type /*out*/, char *msg_str /*out*/, size_t
ssize_t ret_value = -1; /* Return value */

FUNC_ENTER_API_NOCLEAR((-1))
H5TRACE4("Zs", "ixxz", msg_id, type, msg_str, size);
H5TRACE4("Zs", "i*Et*sz", msg_id, type, msg_str, size);

/* Get the message object */
if (NULL == (msg = (H5E_msg_t *)H5I_object_verify(msg_id, H5I_ERROR_MSG)))
Expand Down Expand Up @@ -1446,7 +1446,7 @@ H5Eget_auto2(hid_t estack_id, H5E_auto2_t *func /*out*/, void **client_data /*ou

/* Don't clear the error stack! :-) */
FUNC_ENTER_API_NOCLEAR(FAIL)
H5TRACE3("e", "ixx", estack_id, func, client_data);
H5TRACE3("e", "i*EA**x", estack_id, func, client_data);

if (estack_id == H5E_DEFAULT) {
if (NULL == (estack = H5E__get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in
Expand Down
Loading

0 comments on commit 59a62b7

Please sign in to comment.