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
Show 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):
if
lineNum
not
in
dict
:
dict
[
lineNum
]
=
[
annot
]
else
:
for
a
in
dict
[
lineNum
]:
if
a
.
annotation
==
annot
.
annotation
and
a
.
fileName
==
annot
.
fileName
:
return
dict
[
lineNum
]
.
append
(
annot
)
def
annotateVarFuncDecl
(
listISCFileNames
,
listGlobalVariables
,
listLocalVariables
):
...
...
@@ -191,7 +194,7 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
for
funcISC
in
listISCFunctions
:
lineNumISC
=
funcISC
.
startLine
currFuncListParams
=
[]
currFuncListParams
ToAnnot
=
[]
while
True
:
lineNumISC
=
lineNumISC
-
1
lineISC
=
lc
.
getline
(
funcISC
.
fileName
,
lineNumISC
)
...
...
@@ -205,8 +208,12 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
for
param
in
listParams
:
m1
=
re_VarSpec
.
match
(
param
)
assert
(
m1
is
not
None
)
paramName
=
m1
.
group
(
"varName"
)
currFuncListParams
.
append
(
paramName
)
varType
=
m1
.
group
(
"varType"
)
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
funcObj
=
find
(
lambda
fn
:
fn
.
functionName
==
funcISC
.
functionName
,
listObjdumpFunctions
)
...
...
@@ -222,8 +229,9 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
lineAnnotations
=
parse_statement
(
lineISC
)
if
lineAnnotations
==
None
:
continue
for
annotation
in
lineAnnotations
:
if
annotation
[
0
]
in
currFuncListParams
:
while
lineAnnotations
:
annotation
=
lineAnnotations
.
pop
()
if
annotation
[
0
]
in
currFuncListParamsToAnnot
:
annot_str
=
annotation
[
1
]
annot
=
Annotation
(
annot_str
,
funcISC
.
fileName
,
lineNumISC
,
False
)
annot
.
debug
()
...
...
@@ -232,7 +240,9 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
annot
)
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
:
annot_str
=
annotation
[
1
]
annot
=
Annotation
(
annot_str
,
funcISC
.
fileName
,
lineNumISC
,
False
)
...
...
@@ -240,23 +250,32 @@ def annotateLoadStore(listISCFunctions, listObjdumpFunctions, listLSInfo):
addAnnotationToDict
(
dictAnnotLoadStore
,
lineNumISC
,
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
)
return
dictAnnotLoadStore
def
generateOutputFileName
(
inFileName
):
def
generateOutputFileName
(
outputPath
,
inFileName
):
re_fileName
=
re
.
compile
(
"(?P<path>/?(?:
\
w*/)*)(?P<fileName>
\
w*)
\
.(?P<fileExt>
\
w*)"
)
m
=
re_fileName
.
match
(
inFileName
)
assert
(
m
is
not
None
)
f
ilePath
=
m
.
group
(
"path"
)
inF
ilePath
=
m
.
group
(
"path"
)
inFileNameWOExt
=
m
.
group
(
"fileName"
)
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
:
outFileName
=
generateOutputFileName
(
inFileName
)
outFileName
=
generateOutputFileName
(
outputPath
,
inFileName
)
inFile
=
open
(
inFileName
,
"r"
)
outFile
=
open
(
outFileName
,
"w"
)
lineNum
=
0
...
...
@@ -309,7 +328,7 @@ def annotateCache(dictAnnotVarFuncDecl, dictAnnotLoadStore, listISCFileNames):
print
(
"Output to file :
%
s"
%
outFileName
)
def
instrumentCache
(
listISCFileNames
,
listObjdumpFileNames
,
listBinaryFileNames
):
def
instrumentCache
(
listISCFileNames
,
listObjdumpFileNames
,
listBinaryFileNames
,
outputPath
):
(
listISCFunctions
,
listObjdumpFunctions
)
=
match_cfg
(
listISCFileNames
,
listObjdumpFileNames
,
...
...
@@ -324,13 +343,13 @@ def instrumentCache(listISCFileNames, listObjdumpFileNames, listBinaryFileNames)
listGlobalVariables
,
listLocalVariables
)
debugListLSInfo
(
listLSInfo
)
#
debugListLSInfo(listLSInfo)
dictAnnotVarFuncDecl
=
annotateVarFuncDecl
(
listISCFileNames
,
listGlobalVariables
,
listLocalVariables
)
dictAnnotLoadStore
=
annotateLoadStore
(
listISCFunctions
,
listObjdumpFunctions
,
listLSInfo
)
annotateCache
(
dictAnnotVarFuncDecl
,
dictAnnotLoadStore
,
listISCFileNames
)
generateAnnotatedSourceFiles
(
dictAnnotVarFuncDecl
,
dictAnnotLoadStore
,
listISCFileNames
,
outputPath
)
if
__name__
==
"__main__"
:
...
...
@@ -348,6 +367,10 @@ if __name__ == "__main__":
type
=
"string"
,
dest
=
"listBinaryFileNames"
,
help
=
"Binary Filename. For multiple files, use -b <filename> multiple times."
,
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
()
...
...
@@ -357,5 +380,6 @@ if __name__ == "__main__":
listISCFileNames
=
options
.
listISCFileNames
listObjdumpFileNames
=
options
.
listObjdumpFileNames
listBinaryFileNames
=
options
.
listBinaryFileNames
outputPath
=
options
.
outputPath
instrumentCache
(
listISCFileNames
,
listObjdumpFileNames
,
listBinaryFileNames
)
\ No newline at end of file
instrumentCache
(
listISCFileNames
,
listObjdumpFileNames
,
listBinaryFileNames
,
outputPath
)
\ 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