Skip to content

Commit 7e41c8a

Browse files
committed
Some debugging statements.
1 parent 2982743 commit 7e41c8a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

driver/utils.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
# Internal logger
3838
_logger = logging.getLogger(__name__)
3939

40+
# Flag for debugging
41+
DEBUG = False
42+
43+
4044
# This class applies filters to GCC argument lists. It has a few
4145
# default arguments that it records, but does not modify the argument
4246
# list at all. It can be subclassed to change this behavior.
@@ -143,6 +147,9 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
143147
if not matched:
144148
self.keepArgument(currentItem)
145149

150+
if DEBUG:
151+
self.dump()
152+
146153
def _shiftArgs(self, nargs):
147154
ret = []
148155
while nargs > 0:
@@ -198,6 +205,37 @@ def getOutputFilename(self):
198205
else:
199206
return 'a.out'
200207

208+
# iam: returns a pair [objectFilename, bitcodeFilename] i.e .o and .bc.
209+
# the hidden flag determines whether the objectFile is hidden like the
210+
# bitcodeFile is (starts with a '.'), use the DEBUG flag to get a sense
211+
# of what is being written out.
212+
def getArtifactNames(self, srcFile, hidden=False):
213+
(srcpath, srcbase) = os.path.split(srcFile)
214+
(srcroot, srcext) = os.path.splitext(srcbase)
215+
if hidden:
216+
objbase = '.{0}.o'.format(srcroot)
217+
else:
218+
objbase = '{0}.o'.format(srcroot)
219+
bcbase = '.{0}.o.bc'.format(srcroot)
220+
path = ''
221+
if self.outputFilename is not None:
222+
path = os.path.dirname(self.outputFilename)
223+
return [os.path.join(path, objbase), os.path.join(path, bcbase)]
224+
225+
#iam: for printing our partitioning of the args
226+
def dump(self):
227+
print "compileArgs: ", self.compileArgs
228+
print "inputFiles: ", self.inputFiles
229+
print "linkArgs: ", self.linkArgs
230+
print "objectFiles: ", self.objectFiles
231+
print "outputFilename: ", self.outputFilename
232+
for srcFile in self.inputFiles:
233+
print "srcFile: ", srcFile
234+
(objFile, bcFile) = self.getArtifactNames(srcFile)
235+
print "{0} ===> ({1}, {2})".format(srcFile, objFile, bcFile)
236+
237+
238+
201239
# Same as above, but change the name of the output filename when
202240
# building the bitcode file so that we don't clobber the object file.
203241
class ClangBitcodeArgumentListFilter(ArgumentListFilter):

0 commit comments

Comments
 (0)