Skip to content

Commit

Permalink
Removes alternative function enter/leave macro scheme (#678)
Browse files Browse the repository at this point in the history
* Committing clang-format changes

* Converted BEGIN_FUNC, etc. macros to FUNC_ENTER

* Rips out the BEGIN_FUNC, etc. macros

* Removes 'end if', etc. comments from H5HL package

* Committing clang-format changes

* Fixes an H5EA iterate issue

* Fixes an issue in the H5FA iterator code

* Further cleanup in bin/trace after macro removal

* Iterator changes in H5EA and H5FA

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and lrknox committed Jul 15, 2021
1 parent db8298b commit edddb11
Show file tree
Hide file tree
Showing 33 changed files with 2,691 additions and 2,253 deletions.
37 changes: 26 additions & 11 deletions bin/trace
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,19 @@ sub argstring ($$$) {
# Given information about an API function, rewrite that function with
# updated tracing information.
#
my $file_api = 0;
my $file_args = 0;
my $total_api = 0;
my $total_args = 0;
sub rewrite_func ($$$$$) {
my ($file, $type, $name, $args, $body) = @_;
my ($arg,$trace);
my (@arg_name, @arg_str);
my ($arg, $trace, $argtrace);
my (@arg_name, @arg_str, @arg_type);
local $_;

# Keep copy of original arguments
my $orig_args = $args;

# Parse return value
my $rettype = argstring $file, $name, $type;
goto error if $rettype =~ /!/;
Expand Down Expand Up @@ -341,7 +348,7 @@ sub rewrite_func ($$$$$) {


error:
return "\n$type\n$name($args)\n$body";
return "\n$type\n$name($orig_args)\n$body";
}

##############################################################################
Expand All @@ -360,21 +367,26 @@ for $file (@ARGV) {

# Make modifications
my $original = $Source;
my $napi = $Source =~ s/\n([A-Za-z]\w*(\s+[A-Za-z]\w*)*\s*\**)\n #type
(H5[A-Z]{0,2}[^_A-Z0-9]\w*) #name
\s*\((.*?)\)\s* #args
(\{.*?\n\}[^\n]*) #body
/rewrite_func($file,$1,$3,$4,$5)/segx;
$total_api += $napi;

# Make modifications
$Source =~ s/\n([A-Za-z]\w*(\s+[A-Za-z]\w*)*\s*\**)\n #type
(H5[A-Z]{0,2}_?[a-zA-Z0-9_]\w*) #name
\s*\((.*?)\)\s* #args
(\{.*?\n\}[^\n]*) #body
/rewrite_func($file,$1,$3,$4,$5)/segx;

# If the source changed then print out the new version
if ($original ne $Source) {
printf "%s: instrumented %d API function%s\n",
$file, $napi, 1==$napi?"":"s";
printf "%s: instrumented %d API function%s and %d argument list%s\n",
$file, $file_api, (1 == $file_api ? "" : "s"),
$file_args, (1 == $file_args ? "" : "s");
rename $file, "$file~" or die "unable to make backup";
open SOURCE, ">$file" or die "unable to modify source";
print SOURCE $Source;
close SOURCE;

$total_api += $file_api;
$total_args += $file_args;
}
}
}
Expand All @@ -387,5 +399,8 @@ if ($found_errors eq 1) {
exit 1;
} else {
printf "Finished processing HDF5 API calls\n";
printf "\tinstrumented %d API function%s and %d argument list%s\n",
$total_api, (1 == $total_api ? "" : "s"),
$total_args, (1 == $total_args ? "" : "s");
}

4 changes: 0 additions & 4 deletions src/H5.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE;
/* Library Private Variables */
/*****************************/

/* HDF5 API Entered variable */
/* (move to H5.c when new FUNC_ENTER macros in actual use -QAK) */
hbool_t H5_api_entered_g = FALSE;

/* statically initialize block for pthread_once call used in initializing */
/* the first global mutex */
#ifdef H5_HAVE_THREADSAFE
Expand Down
Loading

0 comments on commit edddb11

Please sign in to comment.