From 23fd6a27c8d8914b419f8822c7e6b7d625b12da8 Mon Sep 17 00:00:00 2001 From: Devin Matthews Date: Wed, 13 Jul 2022 15:28:05 -0500 Subject: [PATCH 1/2] Add `#line` directives to flattened `blis.h`. This enables better debugging since errors will show up based on the un-flattened filename and line number. --- build/flatten-headers.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build/flatten-headers.py b/build/flatten-headers.py index 563725a7e9..3863d196e3 100755 --- a/build/flatten-headers.py +++ b/build/flatten-headers.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# BLIS +# BLIS # An object-based framework for developing high-performance BLAS-like # libraries. # @@ -216,7 +216,9 @@ def flatten_header( inputfile, header_dirpaths, cursp ): ifile = open( inputfile, "r" ) # Iterate over the lines in the file. + lineno = 0 while True: + lineno += 1 # Read a line in the file. line = ifile.readline() @@ -268,12 +270,14 @@ def flatten_header( inputfile, header_dirpaths, cursp ): # Mark the beginning of the header being inserted. ostring += "%s%s%c" % ( beginstr, header, '\n' ) + ostring += "#line %d \"%s\"%c\n" % ( 1, header_path, '\n' ) # Recurse on the header, accumulating the string. ostring += flatten_header( header_path, header_dirpaths, cursp + " " ) # Mark the end of the header being inserted. ostring += "%s%s%c" % ( endstr, header, '\n' ) + ostring += "#line %d \"%s\"%c\n" % ( lineno+1, inputfile, '\n' ) echov2( "%sheader file '%s' fully processed." \ % ( cursp, header_path ) ) @@ -300,7 +304,7 @@ def flatten_header( inputfile, header_dirpaths, cursp ): # endif # endwhile - + # Close the input file. ifile.close() @@ -330,7 +334,7 @@ def find_header_dirs( dirpath ): #endfor return header_dirpaths - + # ------------------------------------------------------------------------------ From e44c123b38e53f204a67804faad6dc6cbfbf893a Mon Sep 17 00:00:00 2001 From: "Field G. Van Zee" Date: Mon, 25 Jul 2022 17:44:05 -0500 Subject: [PATCH 2/2] Comment updates. --- build/flatten-headers.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build/flatten-headers.py b/build/flatten-headers.py index 3863d196e3..40fc2a4507 100755 --- a/build/flatten-headers.py +++ b/build/flatten-headers.py @@ -215,9 +215,17 @@ def flatten_header( inputfile, header_dirpaths, cursp ): # Open the input file to process. ifile = open( inputfile, "r" ) - # Iterate over the lines in the file. + # A counter to track the line number being parsed within the current file. + # This counter, when selectively encoded into the flattened header via #line + # directives, facilitates easier debugging. (When the compiler finds an + # issue, it will be able to refer to the line number within the constituent + # header file rather than the flattened one.) lineno = 0 + + # Iterate over the lines in the file. while True: + + # Increment the line number. lineno += 1 # Read a line in the file. @@ -335,7 +343,6 @@ def find_header_dirs( dirpath ): return header_dirpaths - # ------------------------------------------------------------------------------ # Global variables.