summaryrefslogtreecommitdiffstats
path: root/bin/trace
diff options
context:
space:
mode:
Diffstat (limited to 'bin/trace')
-rwxr-xr-xbin/trace157
1 files changed, 102 insertions, 55 deletions
diff --git a/bin/trace b/bin/trace
index 8b3f68e..7ca84e6 100755
--- a/bin/trace
+++ b/bin/trace
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
##
# Copyright by The HDF Group.
# Copyright by the Board of Trustees of the University of Illinois.
@@ -12,6 +12,7 @@
# help@hdfgroup.org.
##
require 5.003;
+use warnings;
$Source = "";
##############################################################################
@@ -30,28 +31,29 @@ $Source = "";
"hbool_t" => "b",
"double" => "d",
"H5D_alloc_time_t" => "Da",
- "H5FD_mpio_collective_opt_t" => "Dc",
+ "H5FD_mpio_collective_opt_t" => "Dc",
"H5D_fill_time_t" => "Df",
"H5D_fill_value_t" => "DF",
- "H5FD_mpio_chunk_opt_t" => "Dh",
+ "H5FD_mpio_chunk_opt_t" => "Dh",
"H5D_mpio_actual_io_mode_t" => "Di",
"H5D_layout_t" => "Dl",
"H5D_mpio_no_collective_cause_t" => "Dn",
"H5D_mpio_actual_chunk_opt_mode_t" => "Do",
"H5D_space_status_t" => "Ds",
"H5FD_mpio_xfer_t" => "Dt",
+ "H5FD_splitter_vfd_config_t" => "Dr",
"herr_t" => "e",
"H5E_direction_t" => "Ed",
"H5E_error_t" => "Ee",
- "H5E_type_t" => "Et",
- "H5F_close_degree_t" => "Fd",
+ "H5E_type_t" => "Et",
+ "H5F_close_degree_t" => "Fd",
"H5F_scope_t" => "Fs",
- "H5F_libver_t" => "Fv",
+ "H5F_libver_t" => "Fv",
"H5G_obj_t" => "Go",
"H5G_stat_t" => "Gs",
- "hsize_t" => "h",
+ "hsize_t" => "h",
"hssize_t" => "Hs",
- "H5E_major_t" => "i",
+ "H5E_major_t" => "i",
"H5E_minor_t" => "i",
"H5_iter_order_t" => "Io",
"H5_index_t" => "Ii",
@@ -61,16 +63,17 @@ $Source = "";
"unsigned" => "Iu",
"unsigned int" => "Iu",
"uint32_t" => "Iu",
+ "uint64_t" => "UL",
"H5I_type_t" => "It",
- "H5G_link_t" => "Ll", #Same as H5L_type_t now
- "H5L_type_t" => "Ll",
+ "H5G_link_t" => "Ll", #Same as H5L_type_t now
+ "H5L_type_t" => "Ll",
"MPI_Comm" => "Mc",
"MPI_Info" => "Mi",
"H5FD_mem_t" => "Mt",
"off_t" => "o",
"H5O_type_t" => "Ot",
"H5P_class_t" => "p",
- "hobj_ref_t" => "r",
+ "hobj_ref_t" => "r",
"H5R_type_t" => "Rt",
"char" => "s",
"unsigned char" => "s",
@@ -92,9 +95,9 @@ $Source = "";
"void" => "x",
"FILE" => "x",
"H5A_operator_t" => "x",
- "H5A_operator1_t" => "x",
- "H5A_operator2_t" => "x",
- "H5A_info_t" => "x",
+ "H5A_operator1_t" => "x",
+ "H5A_operator2_t" => "x",
+ "H5A_info_t" => "x",
"H5AC_cache_config_t" => "x",
"H5D_gather_func_t" => "x",
"H5D_operator_t" => "x",
@@ -105,21 +108,24 @@ $Source = "";
"H5E_walk_t" => "x",
"H5E_walk1_t" => "x",
"H5E_walk2_t" => "x",
- "H5F_info_t" => "x",
+ "H5F_info_t" => "x",
"H5FD_t" => "x",
"H5FD_class_t" => "x",
"H5FD_stream_fapl_t" => "x",
+ "H5FD_ros3_fapl_t" => "x",
+ "H5FD_hdfs_fapl_t" => "x",
"H5FD_file_image_callbacks_t" => "x",
+ "H5FD_mirror_fapl_t" => "x",
"H5G_iterate_t" => "x",
- "H5G_info_t" => "x",
- "H5I_free_t" => "x",
- "H5I_search_func_t" => "x",
- "H5L_class_t" => "x",
+ "H5G_info_t" => "x",
+ "H5I_free_t" => "x",
+ "H5I_search_func_t" => "x",
+ "H5L_class_t" => "x",
"H5L_elink_traverse_t" => "x",
"H5L_iterate_t" => "x",
"H5MM_allocate_t" => "x",
"H5MM_free_t" => "x",
- "H5O_info_t" => "x",
+ "H5O_info_t" => "x",
"H5O_iterate_t" => "x",
"H5O_mcdt_search_cb_t" => "x",
"H5P_cls_create_func_t" => "x",
@@ -147,9 +153,19 @@ $Source = "";
"ssize_t" => "Zs",
);
+
+##############################################################################
+# Maximum length of H5TRACE macro line
+# If the ColumnLimit in .clang-format is changed, this value will need to be updated
+#
+my $max_trace_macro_line_len = 110;
+
+
##############################################################################
# Print an error message.
#
+my $found_errors = 0;
+
sub errmesg ($$@) {
my ($file, $func, @mesg) = @_;
my ($mesg) = join "", @mesg;
@@ -159,6 +175,8 @@ sub errmesg ($$@) {
$lineno = tr/\n/\n/;
}
+ $found_errors = 1;
+
print "$file: in function \`$func\':\n";
print "$file:$lineno: $mesg\n";
}
@@ -175,6 +193,11 @@ sub argstring ($$$) {
# certain type qualifiers, and indirection.
$atype =~ s/^\bconst\b//;
$atype =~ s/\bH5_ATTR_UNUSED\b//g;
+ $atype =~ s/\bH5_ATTR_DEPRECATED_USED\b//g;
+ $atype =~ s/\bH5_ATTR_NDEBUG_UNUSED\b//g;
+ $atype =~ s/\bH5_ATTR_DEBUG_API_USED\b//g;
+ $atype =~ s/\bH5_ATTR_PARALLEL_UNUSED\b//g;
+ $atype =~ s/\bH5_ATTR_PARALLEL_USED\b//g;
$atype =~ s/\s+/ /g;
$ptr = length $1 if $atype =~ s/(\*+)//;
$atype =~ s/^\s+//;
@@ -215,7 +238,7 @@ sub rewrite_func ($$$$$) {
# Parse arguments
if ($args eq "void") {
- $trace = "H5TRACE0(\"$rettype\",\"\");\n";
+ $trace = "H5TRACE0(\"$rettype\", \"\");\n";
} else {
# Split arguments. First convert `/*in,out*/' to get rid of the
# comma, then split the arguments on commas.
@@ -229,48 +252,64 @@ sub rewrite_func ($$$$$) {
next;
}
unless ($arg=~/^(([a-z_A-Z]\w*\s+)+\**)
- ([a-z_A-Z]\w*)(\[.*?\])?
- (\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) {
- errmesg $file, $name, "unable to parse \`$arg\'";
- goto error;
+ ([a-z_A-Z]\w*)(\[.*?\])?
+ (\s*\/\*\s*(in|out|in_out)\s*\*\/)?\s*$/x) {
+ errmesg $file, $name, "unable to parse \`$arg\'";
+ goto error;
} else {
- my ($atype, $aname, $array, $adir) = ($1, $3, $4, $6);
- $names{$aname} = $argno++;
- $adir ||= "in";
- $atype =~ s/\s+$//;
- push @arg_name, $aname;
+ my ($atype, $aname, $array, $adir) = ($1, $3, $4, $6);
+ $names{$aname} = $argno++;
+ $adir ||= "in";
+ $atype =~ s/\s+$//;
+ push @arg_name, $aname;
- if ($adir eq "out") {
- push @arg_str, "x";
- } else {
- if (defined $array) {
- $atype .= "*";
- if ($array =~ /^\[\/\*([a-z_A-Z]\w*)\*\/\]$/) {
- my $asize = $1;
- if (exists $names{$asize}) {
- $atype .= '[a' . $names{$asize} . ']';
- } else {
- warn "bad array size: $asize";
- $atype .= "*";
- }
- }
- }
- push @arg_str, argstring $file, $name, $atype;
- }
+ if ($adir eq "out") {
+ push @arg_str, "x";
+ } else {
+ if (defined $array) {
+ $atype .= "*";
+ if ($array =~ /^\[\/\*([a-z_A-Z]\w*)\*\/\]$/) {
+ my $asize = $1;
+ if (exists $names{$asize}) {
+ $atype .= '[a' . $names{$asize} . ']';
+ } else {
+ warn "bad array size: $asize";
+ $atype .= "*";
+ }
+ }
+ }
+ push @arg_str, argstring $file, $name, $atype;
+ }
}
}
+
+ # Compose the trace macro
$trace = "H5TRACE" . scalar(@arg_str) . "(\"$rettype\", \"";
$trace .= join("", @arg_str) . "\"";
- my $len = 4 + length $trace;
+ my $len = 4 + length $trace; # Add 4, for indenting the line
for (@arg_name) {
- if ($len + length >= 77) {
- $trace .= ",\n $_";
- $len = 13 + length;
+ # Wrap lines that will be longer than the limit, after ');' is added
+ if ($len + length >= ($max_trace_macro_line_len - 2)) {
+ # Wrap line, with indention
+ $trace .= ",\n ";
+ $len = 13; # Set to 13, for indention
+
+ # Indent an extra space to account for extra digit in 'H5TRACE' macro
+ if (scalar(@arg_str) >= 10) {
+ $trace .= " ";
+ $len++;
+ }
} else {
- $trace .= ", $_";
- $len += 1 + length;
+ $trace .= ", ";
+ $len += 2; # Add 2, for ', '
}
+
+ # Append argument
+ $trace .= "$_";
+ $len += length; # Add length of appended argument name
}
+
+ # Append final ');' for macro
$trace .= ");\n";
}
goto error if grep {/!/} @arg_str;
@@ -280,7 +319,7 @@ sub rewrite_func ($$$$$) {
# Ignored due to NO TRACE comment.
} elsif ($body =~ s/((\n[ \t]*)H5TRACE\d+\s*\(.*?\);)\n/"$2$trace"/es) {
# Replaced an H5TRACE macro.
- } elsif ($body=~s/((\n[ \t]*)FUNC_ENTER\w*\s*(\(.*?\))?;??)\n/"$1$2$trace"/es) {
+ } elsif ($body=~s/((\n[ \t]*)FUNC_ENTER\w*[ \t]*(\(.*?\))?;??)\n/"$1$2$trace"/es) {
# Added an H5TRACE macro after a FUNC_ENTER macro.
} else {
errmesg $file, $name, "unable to insert tracing information";
@@ -328,5 +367,13 @@ for $file (@ARGV) {
}
}
-printf "Finished processing HDF5 API calls\n"
+if ($found_errors eq 1) {
+ printf "\n";
+ printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
+ printf "*** ERRORS FOUND *** ERRORS FOUND *** ERRORS FOUND ****\n";
+ printf "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
+ exit 1;
+} else {
+ printf "Finished processing HDF5 API calls\n";
+}