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
64199a31
Commit
64199a31
authored
Sep 04, 2014
by
Gaurav Kukreja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor bug fixes at a lot of places
Signed-off-by:
Gaurav Kukreja
<
gaurav@gauravk.in
>
parent
d1dbeff0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
15 deletions
+49
-15
armEmulate.py
instrument/armEmulate.py
+1
-1
cGrammar.py
instrument/cGrammar.py
+11
-1
cacheSimInstrument.py
instrument/cacheSimInstrument.py
+11
-11
load_store_info.py
instrument/load_store_info.py
+4
-2
match_cfg.py
instrument/match_cfg.py
+22
-0
No files found.
instrument/armEmulate.py
View file @
64199a31
...
@@ -12,7 +12,7 @@ class Register:
...
@@ -12,7 +12,7 @@ class Register:
self
.
isValid
=
False
self
.
isValid
=
False
def
setValue
(
self
,
value
):
def
setValue
(
self
,
value
):
self
.
v
alid
=
True
self
.
isV
alid
=
True
self
.
value
=
value
self
.
value
=
value
# List of names of General Purpose Registers
# List of names of General Purpose Registers
...
...
instrument/cGrammar.py
View file @
64199a31
...
@@ -414,6 +414,16 @@ def ignore_statement(line):
...
@@ -414,6 +414,16 @@ def ignore_statement(line):
logging
.
debug
(
"Goto Statement. :
%
s"
%
line
)
logging
.
debug
(
"Goto Statement. :
%
s"
%
line
)
return
True
return
True
m
=
re_functionCallStatement
.
match
(
line
)
if
m
is
not
None
:
logging
.
debug
(
"Function Call. :
%
s"
%
line
)
return
True
m
=
re_returnStatement
.
match
(
line
)
if
m
is
not
None
:
logging
.
debug
(
"Function Call. :
%
s"
%
line
)
return
True
if
line
.
isspace
():
if
line
.
isspace
():
return
True
return
True
...
@@ -454,7 +464,7 @@ def parse_statement(line):
...
@@ -454,7 +464,7 @@ def parse_statement(line):
list_annotations
=
[]
list_annotations
=
[]
r
=
statement
.
parseString
(
line
)
r
=
statement
.
parseString
(
line
)
print
r
#
print r
return
list_annotations
return
list_annotations
...
...
instrument/cacheSimInstrument.py
View file @
64199a31
...
@@ -47,18 +47,18 @@ def instrumentCache(listISCFileNames, listObjdumpFileNames, listBinaryFileNames)
...
@@ -47,18 +47,18 @@ def instrumentCache(listISCFileNames, listObjdumpFileNames, listBinaryFileNames)
for
lineNumISC
in
range
(
blockISC
.
startLine
,
blockISC
.
endLine
+
1
):
for
lineNumISC
in
range
(
blockISC
.
startLine
,
blockISC
.
endLine
+
1
):
lineISC
=
lc
.
getline
(
funcISC
.
fileName
,
lineNumISC
)
lineISC
=
lc
.
getline
(
funcISC
.
fileName
,
lineNumISC
)
print
"
%
s:
%
d:
%
s"
%
(
funcISC
.
fileName
,
lineNumISC
,
lineISC
),
print
"
%
s:
%
d:
%
s"
%
(
funcISC
.
fileName
,
lineNumISC
,
lineISC
),
# lineAnnotations = parse_statement(lineISC)
lineAnnotations
=
parse_statement
(
lineISC
)
# if lineAnnotations == None:
if
lineAnnotations
==
None
:
# continue
continue
# for annotation in lineAnnotations:
for
annotation
in
lineAnnotations
:
# for lsInfo in blockLSInfo:
# if lsInfo.var != None and annotation[0] == lsInfo.var.name:
# print "Annotation :" + annotation[1]
listTerms
=
re_term
.
findall
(
lineISC
)
for
term
in
listTerms
:
for
lsInfo
in
blockLSInfo
:
for
lsInfo
in
blockLSInfo
:
if
lsInfo
.
var
!=
None
and
lsInfo
.
var
.
name
==
term
:
if
lsInfo
.
var
!=
None
and
annotation
[
0
]
==
lsInfo
.
var
.
name
:
print
"term
%
s found!"
%
term
print
"Annotation :"
+
annotation
[
1
]
# listTerms = re_term.findall(lineISC)
# for term in listTerms:
# for lsInfo in blockLSInfo:
# if lsInfo.var != None and lsInfo.var.name == term:
# print "term %s found!" % term
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
instrument/load_store_info.py
View file @
64199a31
import
linecache
as
lc
import
linecache
as
lc
from
collections
import
deque
from
collections
import
deque
import
copy
from
arm_isa_regex
import
*
from
arm_isa_regex
import
*
from
armEmulate
import
*
from
armEmulate
import
*
...
@@ -169,6 +170,7 @@ def identifyLoadStore(listISCFunctions,
...
@@ -169,6 +170,7 @@ def identifyLoadStore(listISCFunctions,
while
queuePendingFunction
:
while
queuePendingFunction
:
func
=
queuePendingFunction
.
popleft
()
func
=
queuePendingFunction
.
popleft
()
logging
.
debug
(
""
)
logging
.
debug
(
""
)
logging
.
debug
(
"Starting Emulation of Func
%
s"
%
func
.
name
)
logging
.
debug
(
"Starting Emulation of Func
%
s"
%
func
.
name
)
funcObj
=
find
(
lambda
fn
:
fn
.
functionName
==
func
.
name
,
listObjdumpFunctions
)
funcObj
=
find
(
lambda
fn
:
fn
.
functionName
==
func
.
name
,
listObjdumpFunctions
)
...
@@ -211,13 +213,13 @@ def identifyLoadStore(listISCFunctions,
...
@@ -211,13 +213,13 @@ def identifyLoadStore(listISCFunctions,
if
funcInQueue
is
not
None
:
if
funcInQueue
is
not
None
:
continue
continue
else
:
else
:
initRegState
=
armEmu
.
reg
initRegState
=
copy
.
deepcopy
(
armEmu
.
reg
)
logging
.
debug
(
"Adding func
%
s to queue!"
%
branchToFunction
)
logging
.
debug
(
"Adding func
%
s to queue!"
%
branchToFunction
)
queuePendingFunction
.
append
(
FunctionInitState
(
branchToFunction
,
queuePendingFunction
.
append
(
FunctionInitState
(
branchToFunction
,
initRegState
))
initRegState
))
continue
continue
else
:
else
:
logging
.
error
(
"labelFunction in branch instruction could not be matched!
"
)
logging
.
debug
(
"Branch function does not have a label! (branch to same function)
"
)
continue
continue
'''
'''
...
...
instrument/match_cfg.py
View file @
64199a31
...
@@ -18,6 +18,7 @@ from draw_cfg import draw_cfg
...
@@ -18,6 +18,7 @@ from draw_cfg import draw_cfg
COND_EXEC_BLOCKLEN_THRESH
=
6
COND_EXEC_BLOCKLEN_THRESH
=
6
app
=
None
app
=
None
outputPath
=
None
# listISCFileNames = []
# listISCFileNames = []
# listObjdumpFileNames = []
# listObjdumpFileNames = []
...
@@ -192,6 +193,9 @@ def mapping(cfgISC, blockIndISC, cfgObj, blockIndObj, mergedLevelsISC):
...
@@ -192,6 +193,9 @@ def mapping(cfgISC, blockIndISC, cfgObj, blockIndObj, mergedLevelsISC):
# succBlockISC.mapsTo.append(blockIndObj)
# succBlockISC.mapsTo.append(blockIndObj)
succBlockISC
.
mapISCTo
(
blockIndObj
)
succBlockISC
.
mapISCTo
(
blockIndObj
)
blockObj
.
mapsTo
.
append
(
listSuccBlocksISC
[
0
])
blockObj
.
mapsTo
.
append
(
listSuccBlocksISC
[
0
])
### ...
blockObj
.
mapsTo
.
append
(
blockIndISC
)
### ^^^
return
0
return
0
else
:
else
:
# Mapping not found!
# Mapping not found!
...
@@ -357,6 +361,10 @@ def mapping(cfgISC, blockIndISC, cfgObj, blockIndObj, mergedLevelsISC):
...
@@ -357,6 +361,10 @@ def mapping(cfgISC, blockIndISC, cfgObj, blockIndObj, mergedLevelsISC):
# cfgISC.listBlocks[succ2BlockIndISC].mapsTo.append(blockIndObj)
# cfgISC.listBlocks[succ2BlockIndISC].mapsTo.append(blockIndObj)
cfgISC
.
listBlocks
[
succ2BlockIndISC
]
.
mapISCTo
(
blockIndObj
)
cfgISC
.
listBlocks
[
succ2BlockIndISC
]
.
mapISCTo
(
blockIndObj
)
blockObj
.
mapsTo
.
append
(
blockIndISC
)
blockObj
.
mapsTo
.
append
(
blockIndISC
)
### ...
blockObj
.
mapsTo
.
append
(
succ1BlockIndISC
)
blockObj
.
mapsTo
.
append
(
succ2BlockIndISC
)
### ^^^
mappingStackISC
.
pop
()
mappingStackISC
.
pop
()
mappingStackISC
.
pop
()
mappingStackISC
.
pop
()
return
0
return
0
...
@@ -385,6 +393,11 @@ def mapping(cfgISC, blockIndISC, cfgObj, blockIndObj, mergedLevelsISC):
...
@@ -385,6 +393,11 @@ def mapping(cfgISC, blockIndISC, cfgObj, blockIndObj, mergedLevelsISC):
cfgISC
.
listBlocks
[
succ2BlockIndISC
]
.
mapISCTo
(
blockIndObj
)
cfgISC
.
listBlocks
[
succ2BlockIndISC
]
.
mapISCTo
(
blockIndObj
)
cfgISC
.
listBlocks
[
succSucc1BlockIndISC
]
.
mapISCTo
(
blockIndObj
)
cfgISC
.
listBlocks
[
succSucc1BlockIndISC
]
.
mapISCTo
(
blockIndObj
)
blockObj
.
mapsTo
.
append
(
blockIndISC
)
blockObj
.
mapsTo
.
append
(
blockIndISC
)
### ...
blockObj
.
mapsTo
.
append
(
succ1BlockIndISC
)
blockObj
.
mapsTo
.
append
(
succ2BlockIndISC
)
blockObj
.
mapsTo
.
append
(
succSucc1BlockIndISC
)
### ^^^
mappingStackISC
.
pop
()
mappingStackISC
.
pop
()
mappingStackISC
.
pop
()
mappingStackISC
.
pop
()
mappingStackISC
.
pop
()
mappingStackISC
.
pop
()
...
@@ -569,10 +582,19 @@ def match_cfg(listISCFileNames, listObjdumpFileNames, listBinaryFileNames):
...
@@ -569,10 +582,19 @@ def match_cfg(listISCFileNames, listObjdumpFileNames, listBinaryFileNames):
printDebugMapCFG
(
listISCFunctions
,
listObjdumpFunctions
,
gdbMapping
)
printDebugMapCFG
(
listISCFunctions
,
listObjdumpFunctions
,
gdbMapping
)
# for funcISC in listISCFunctions:
# funcObj = find(lambda fn: fn.functionName == funcISC.functionName, listObjdumpFunctions)
# # display_cfgs(app, funcISC.cfg, funcObj.cfg, "%s" % funcISC.functionName)
# psISCFileName = draw_cfg(funcISC, outputPath)
# psObjFileName = draw_cfg(funcObj, outputPath)
# call(args = ["evince", psISCFileName, psObjFileName])
return
listISCFunctions
,
listObjdumpFunctions
return
listISCFunctions
,
listObjdumpFunctions
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
global
outputPath
app
=
QtGui
.
QApplication
(
sys
.
argv
)
app
=
QtGui
.
QApplication
(
sys
.
argv
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
...
...
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