Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
H
hostCompiledSimulation
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gaurav Kukreja
hostCompiledSimulation
Commits
ec2dc851
Commit
ec2dc851
authored
Sep 07, 2014
by
Gaurav Kukreja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing minor bug
Signed-off-by:
Gaurav Kukreja
<
gaurav@gauravk.in
>
parent
4ddd677c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
16 deletions
+40
-16
cacheSimInstrument.py
instrument/cacheSimInstrument.py
+40
-16
No files found.
instrument/cacheSimInstrument.py
View file @
ec2dc851
...
@@ -47,6 +47,9 @@ def addAnnotationToDict(dict, lineNum, annot):
...
@@ -47,6 +47,9 @@ def addAnnotationToDict(dict, lineNum, annot):
if
lineNum
not
in
dict
:
if
lineNum
not
in
dict
:
dict
[
lineNum
]
=
[
annot
]
dict
[
lineNum
]
=
[
annot
]
else
:
else
:
for
a
in
dict
[
lineNum
]:
if
a
.
annotation
==
annot
.
annotation
and
a
.
fileName
==
annot
.
fileName
:
return
dict
[
lineNum
]
.
append
(
annot
)
dict
[
lineNum
]
.
append
(
annot
)
def
annotateVarFuncDecl
(
listISCFileNames
,
listGlobalVariables
,
listLocalVariables
):
def
annotateVarFuncDecl
(
listISCFileNames
,
listGlobalVariables
,
listLocalVariables
):
...
@@ -191,7 +194,7 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
...
@@ -191,7 +194,7 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
for
funcISC
in
listISCFunctions
:
for
funcISC
in
listISCFunctions
:
lineNumISC
=
funcISC
.
startLine
lineNumISC
=
funcISC
.
startLine
currFuncListParams
=
[]
currFuncListParams
ToAnnot
=
[]
while
True
:
while
True
:
lineNumISC
=
lineNumISC
-
1
lineNumISC
=
lineNumISC
-
1
lineISC
=
lc
.
getline
(
funcISC
.
fileName
,
lineNumISC
)
lineISC
=
lc
.
getline
(
funcISC
.
fileName
,
lineNumISC
)
...
@@ -205,8 +208,12 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
...
@@ -205,8 +208,12 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
for
param
in
listParams
:
for
param
in
listParams
:
m1
=
re_VarSpec
.
match
(
param
)
m1
=
re_VarSpec
.
match
(
param
)
assert
(
m1
is
not
None
)
assert
(
m1
is
not
None
)
paramName
=
m1
.
group
(
"varName"
)
varType
=
m1
.
group
(
"varType"
)
currFuncListParams
.
append
(
paramName
)
varName
=
m1
.
group
(
"varName"
)
varLen
=
m1
.
group
(
"varLen"
)
m2
=
re
.
match
(
"(?:
\
s*
\
w*)*
\
*+
\
s*"
,
varType
)
if
m2
is
not
None
or
varLen
is
not
""
:
currFuncListParamsToAnnot
.
append
(
varName
)
break
break
funcObj
=
find
(
lambda
fn
:
fn
.
functionName
==
funcISC
.
functionName
,
listObjdumpFunctions
)
funcObj
=
find
(
lambda
fn
:
fn
.
functionName
==
funcISC
.
functionName
,
listObjdumpFunctions
)
...
@@ -222,8 +229,9 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
...
@@ -222,8 +229,9 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
lineAnnotations
=
parse_statement
(
lineISC
)
lineAnnotations
=
parse_statement
(
lineISC
)
if
lineAnnotations
==
None
:
if
lineAnnotations
==
None
:
continue
continue
for
annotation
in
lineAnnotations
:
while
lineAnnotations
:
if
annotation
[
0
]
in
currFuncListParams
:
annotation
=
lineAnnotations
.
pop
()
if
annotation
[
0
]
in
currFuncListParamsToAnnot
:
annot_str
=
annotation
[
1
]
annot_str
=
annotation
[
1
]
annot
=
Annotation
(
annot_str
,
funcISC
.
fileName
,
lineNumISC
,
False
)
annot
=
Annotation
(
annot_str
,
funcISC
.
fileName
,
lineNumISC
,
False
)
annot
.
debug
()
annot
.
debug
()
...
@@ -232,7 +240,9 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
...
@@ -232,7 +240,9 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
annot
)
annot
)
else
:
else
:
for
lsInfo
in
blockLSInfo
:
lenBlockLSInfo
=
len
(
blockLSInfo
)
for
i
in
range
(
lenBlockLSInfo
):
lsInfo
=
blockLSInfo
.
pop
(
0
)
if
lsInfo
.
var
!=
None
and
annotation
[
0
]
==
lsInfo
.
var
.
name
:
if
lsInfo
.
var
!=
None
and
annotation
[
0
]
==
lsInfo
.
var
.
name
:
annot_str
=
annotation
[
1
]
annot_str
=
annotation
[
1
]
annot
=
Annotation
(
annot_str
,
funcISC
.
fileName
,
lineNumISC
,
False
)
annot
=
Annotation
(
annot_str
,
funcISC
.
fileName
,
lineNumISC
,
False
)
...
@@ -240,23 +250,32 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
...
@@ -240,23 +250,32 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
addAnnotationToDict
(
dictAnnotLoadStore
,
addAnnotationToDict
(
dictAnnotLoadStore
,
lineNumISC
,
lineNumISC
,
annot
)
annot
)
break
else
:
blockLSInfo
.
append
(
lsInfo
)
print
"******* LS Info could not be mapped in block
%
s"
%
blockObj
.
name
for
lsInfo
in
blockLSInfo
:
lsInfo
.
debug
()
print
"*******"
debugDictAnnot
(
dictAnnotLoadStore
)
debugDictAnnot
(
dictAnnotLoadStore
)
return
dictAnnotLoadStore
return
dictAnnotLoadStore
def
generateOutputFileName
(
inFileName
):
def
generateOutputFileName
(
outputPath
,
inFileName
):
re_fileName
=
re
.
compile
(
"(?P<path>/?(?:
\
w*/)*)(?P<fileName>
\
w*)
\
.(?P<fileExt>
\
w*)"
)
re_fileName
=
re
.
compile
(
"(?P<path>/?(?:
\
w*/)*)(?P<fileName>
\
w*)
\
.(?P<fileExt>
\
w*)"
)
m
=
re_fileName
.
match
(
inFileName
)
m
=
re_fileName
.
match
(
inFileName
)
assert
(
m
is
not
None
)
assert
(
m
is
not
None
)
f
ilePath
=
m
.
group
(
"path"
)
inF
ilePath
=
m
.
group
(
"path"
)
inFileNameWOExt
=
m
.
group
(
"fileName"
)
inFileNameWOExt
=
m
.
group
(
"fileName"
)
inFileExt
=
m
.
group
(
"fileExt"
)
inFileExt
=
m
.
group
(
"fileExt"
)
return
filePath
+
inFileNameWOExt
+
"_ins."
+
inFileExt
if
outputPath
is
None
:
outputPath
=
inFilePath
return
outputPath
+
inFileNameWOExt
+
"_ins."
+
inFileExt
def
annotateCache
(
dictAnnotVarFuncDecl
,
dictAnnotLoadStore
,
listISCFileNames
):
def
generateAnnotatedSourceFiles
(
dictAnnotVarFuncDecl
,
dictAnnotLoadStore
,
listISCFileNames
,
outputPath
):
for
inFileName
in
listISCFileNames
:
for
inFileName
in
listISCFileNames
:
outFileName
=
generateOutputFileName
(
inFileName
)
outFileName
=
generateOutputFileName
(
outputPath
,
inFileName
)
inFile
=
open
(
inFileName
,
"r"
)
inFile
=
open
(
inFileName
,
"r"
)
outFile
=
open
(
outFileName
,
"w"
)
outFile
=
open
(
outFileName
,
"w"
)
lineNum
=
0
lineNum
=
0
...
@@ -309,7 +328,7 @@ def annotateCache(dictAnnotVarFuncDecl, dictAnnotLoadStore, listISCFileNames):
...
@@ -309,7 +328,7 @@ def annotateCache(dictAnnotVarFuncDecl, dictAnnotLoadStore, listISCFileNames):
print
(
"Output to file :
%
s"
%
outFileName
)
print
(
"Output to file :
%
s"
%
outFileName
)
def
instrumentCache
(
listISCFileNames
,
listObjdumpFileNames
,
listBinaryFileNames
):
def
instrumentCache
(
listISCFileNames
,
listObjdumpFileNames
,
listBinaryFileNames
,
outputPath
):
(
listISCFunctions
,
listObjdumpFunctions
)
=
match_cfg
(
listISCFileNames
,
(
listISCFunctions
,
listObjdumpFunctions
)
=
match_cfg
(
listISCFileNames
,
listObjdumpFileNames
,
listObjdumpFileNames
,
...
@@ -324,13 +343,13 @@ def instrumentCache(listISCFileNames, listObjdumpFileNames, listBinaryFileNames)
...
@@ -324,13 +343,13 @@ def instrumentCache(listISCFileNames, listObjdumpFileNames, listBinaryFileNames)
listGlobalVariables
,
listGlobalVariables
,
listLocalVariables
)
listLocalVariables
)
debugListLSInfo
(
listLSInfo
)
#
debugListLSInfo(listLSInfo)
dictAnnotVarFuncDecl
=
annotateVarFuncDecl
(
listISCFileNames
,
listGlobalVariables
,
listLocalVariables
)
dictAnnotVarFuncDecl
=
annotateVarFuncDecl
(
listISCFileNames
,
listGlobalVariables
,
listLocalVariables
)
dictAnnotLoadStore
=
annotateLoadStore
(
listISCFunctions
,
listObjdumpFunctions
,
listLSInfo
)
dictAnnotLoadStore
=
annotateLoadStore
(
listISCFunctions
,
listObjdumpFunctions
,
listLSInfo
)
annotateCache
(
dictAnnotVarFuncDecl
,
dictAnnotLoadStore
,
listISCFileNames
)
generateAnnotatedSourceFiles
(
dictAnnotVarFuncDecl
,
dictAnnotLoadStore
,
listISCFileNames
,
outputPath
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
@@ -348,6 +367,10 @@ if __name__ == "__main__":
...
@@ -348,6 +367,10 @@ if __name__ == "__main__":
type
=
"string"
,
dest
=
"listBinaryFileNames"
,
type
=
"string"
,
dest
=
"listBinaryFileNames"
,
help
=
"Binary Filename. For multiple files, use -b <filename> multiple times."
,
help
=
"Binary Filename. For multiple files, use -b <filename> multiple times."
,
metavar
=
"FILE"
)
metavar
=
"FILE"
)
optparser
.
add_option
(
"-p"
,
"--outpath"
,
action
=
"store"
,
type
=
"string"
,
dest
=
"outputPath"
,
help
=
"Output Path to store the annotated source files."
,
metavar
=
"PATH"
)
(
options
,
args
)
=
optparser
.
parse_args
()
(
options
,
args
)
=
optparser
.
parse_args
()
...
@@ -357,5 +380,6 @@ if __name__ == "__main__":
...
@@ -357,5 +380,6 @@ if __name__ == "__main__":
listISCFileNames
=
options
.
listISCFileNames
listISCFileNames
=
options
.
listISCFileNames
listObjdumpFileNames
=
options
.
listObjdumpFileNames
listObjdumpFileNames
=
options
.
listObjdumpFileNames
listBinaryFileNames
=
options
.
listBinaryFileNames
listBinaryFileNames
=
options
.
listBinaryFileNames
outputPath
=
options
.
outputPath
instrumentCache
(
listISCFileNames
,
listObjdumpFileNames
,
listBinaryFileNames
)
instrumentCache
(
listISCFileNames
,
listObjdumpFileNames
,
listBinaryFileNames
,
outputPath
)
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment