Skip to main content
Homepage
Explore
Search or go to…
/
Register
Sign in
Explore
Primary navigation
Project
C
cortex-m-rtfm-klee
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
Samuel Karlsson
cortex-m-rtfm-klee
Commits
40669c94
Commit
40669c94
authored
Feb 25, 2018
by
Henrik Tjäder
Browse files
Options
Downloads
Patches
Plain Diff
Now step through each test
parent
f8f6df08
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
klee_stm_gdb.py
+70
-53
70 additions, 53 deletions
klee_stm_gdb.py
with
70 additions
and
53 deletions
klee_stm_gdb.py
+
70
−
53
View file @
40669c94
...
@@ -11,6 +11,8 @@ import subprocess
...
@@ -11,6 +11,8 @@ import subprocess
version_no
=
3
version_no
=
3
debug
=
False
file_list
=
[]
file_list
=
[]
file_index_current
=
0
file_index_current
=
0
object_index_current
=
0
object_index_current
=
0
...
@@ -126,13 +128,11 @@ def do_continue():
...
@@ -126,13 +128,11 @@ def do_continue():
class
MainBP
(
gdb
.
Breakpoint
):
class
MainBP
(
gdb
.
Breakpoint
):
def
stop
(
self
):
def
stop
(
self
):
# print("##### breakpoint")
global
file_index_current
global
file_index_current
global
outputdata
global
outputdata
global
init_done
global
init_done
if
self
.
location
==
"
init
"
:
if
self
.
location
==
"
init
"
:
# print("##### breakpoint init")
if
not
init_done
:
if
not
init_done
:
# gdb.prompt_hook = prompt
# gdb.prompt_hook = prompt
...
@@ -141,23 +141,6 @@ class MainBP(gdb.Breakpoint):
...
@@ -141,23 +141,6 @@ class MainBP(gdb.Breakpoint):
else
:
else
:
gdb
.
post_event
(
gather_data
)
gdb
.
post_event
(
gather_data
)
elif
self
.
location
==
"
idle
"
:
# print("##### breakpoint idle")
"""
Idle loop is reached, now jump to the task specified
in the
"
task
"
value in the ktest files.
If the task value is greater than the number of tasks,
then run all of the tasks.
"""
# gdb.write("Breakpoint in finish_execution\n")
# gdb.write("Stopped before the main loop\n")
"""
Save the execution time and
reload back to the main function.
"""
gdb
.
prompt_hook
=
prompt
# gdb.post_event(posted_event_finish_execution)
"""
Needed to actually stop after the breakpoint
"""
Needed to actually stop after the breakpoint
True: Return prompt
True: Return prompt
False: Continue?
False: Continue?
...
@@ -173,44 +156,52 @@ def stop_event(evt):
...
@@ -173,44 +156,52 @@ def stop_event(evt):
global
outputdata
global
outputdata
global
task_name
global
task_name
global
file_index_current
global
file_list
tmp1
=
task_name
cyccnt
=
gdb_cyccnt_read
()
tmp2
=
gdb_cyccnt_read
()
"""
"""
Get the current ceiling level, cast it to an integer
Get the current ceiling level, cast it to an integer
"""
"""
try
:
try
:
tmp3
=
int
(
gdb
.
parse_and_eval
(
"
ceiling
"
).
cast
(
gdb
.
lookup_type
(
'
u8
'
)))
ceiling
=
int
(
gdb
.
parse_and_eval
(
"
ceiling
"
).
cast
(
gdb
.
lookup_type
(
'
u8
'
)))
except
gdb
.
error
:
except
gdb
.
error
:
print
(
"
Returned from call to %s
"
%
task_name
)
#
print("Returned from call to %s" % task_name)
"""
"""
If there is no ceiling, it means we have returned to init
If there is no ceiling, it means we have returned to init
since every claim have ceiling
since every claim have ceiling
"""
"""
gdb
.
events
.
stop
.
disconnect
(
stop_event
)
#
gdb.events.stop.disconnect(stop_event)
outputdata
.
append
([
t
mp1
,
tmp2
,
0
,
"
Finish
"
])
outputdata
.
append
([
t
ask_name
,
cyccnt
,
0
,
"
Finish
"
])
print
(
"
Claims:
"
)
print
(
"
Claims:
"
)
for
x
in
outputdata
:
for
x
in
outputdata
:
print
(
"
%s
\n
"
%
x
)
print
(
"
%s
"
%
x
)
if
file_index_current
<
len
(
file_list
)
-
1
:
gather_data
()
else
:
gdb
.
execute
(
"
quit
"
)
gdb
.
execute
(
"
quit
"
)
print
(
"
CYCCNT: %s
\n
Ceiling: %s
"
%
(
tmp2
,
tmp3
))
return
print
(
"
CYCCNT: %s
\n
Ceiling: %s
"
%
(
cyccnt
,
outputdata
[
-
1
][
2
]))
"""
"""
If outputdata is empty, we start
If outputdata is empty, we start
If the same ceiling as previously: exit
If the same ceiling as previously: exit
"""
"""
if
len
(
outputdata
):
if
len
(
outputdata
):
if
outputdata
[
-
1
][
2
]
>=
tmp3
:
if
outputdata
[
-
1
][
2
]
>=
ceiling
:
action
=
"
Exit
"
action
=
"
Exit
"
else
:
else
:
action
=
"
Enter
"
action
=
"
Enter
"
else
:
else
:
action
=
"
Enter
"
action
=
"
Enter
"
outputdata
.
append
([
t
mp1
,
tmp2
,
tmp3
,
action
])
outputdata
.
append
([
t
ask_name
,
cyccnt
,
ceiling
,
action
])
"""
"""
Prepare a prompt for do_continue()
Prepare a prompt for do_continue()
...
@@ -254,7 +245,7 @@ def posted_event_init():
...
@@ -254,7 +245,7 @@ def posted_event_init():
global
file_index_current
global
file_index_current
"""
Load the variable data
"""
"""
Load the variable data
"""
#
ktest_setdata(file_index_current)
ktest_setdata
(
file_index_current
)
"""
"""
Prepare the cycle counter
Prepare the cycle counter
...
@@ -264,6 +255,11 @@ def posted_event_init():
...
@@ -264,6 +255,11 @@ def posted_event_init():
print
(
"
Tasks:
"
,
tasks
)
print
(
"
Tasks:
"
,
tasks
)
# print("Name of task to test:", tasks[task_to_test])
# print("Name of task to test:", tasks[task_to_test])
if
task_to_test
>
len
(
tasks
):
print
(
"
Nothing to call...
"
)
do_continue
()
return
if
not
task_to_test
==
-
1
:
if
not
task_to_test
==
-
1
:
gdb
.
write
(
'
Task to call: %s
\n
'
%
(
gdb
.
write
(
'
Task to call: %s
\n
'
%
(
tasks
[
task_to_test
]
+
"
()
"
))
tasks
[
task_to_test
]
+
"
()
"
))
...
@@ -271,7 +267,7 @@ def posted_event_init():
...
@@ -271,7 +267,7 @@ def posted_event_init():
# gdb.prompt_hook = prompt
# gdb.prompt_hook = prompt
gdb
.
execute
(
'
call %s
'
%
"
stub_
"
+
gdb
.
execute
(
'
call %s
'
%
"
stub_
"
+
tasks
[
task_to_test
]
+
"
()
"
)
tasks
[
task_to_test
]
+
"
()
"
)
print
(
"
Called stub
"
)
#
print("Called stub")
task_to_test
=
-
1
task_to_test
=
-
1
do_continue
()
do_continue
()
...
@@ -282,7 +278,17 @@ def posted_event_init():
...
@@ -282,7 +278,17 @@ def posted_event_init():
def
gather_data
():
def
gather_data
():
global
outputdata
global
outputdata
global
file_index_current
global
file_list
global
init_done
if
file_index_current
<
len
(
file_list
):
init_done
=
0
file_index_current
+=
1
print
(
"
Current file: %s
"
%
file_list
[
file_index_current
])
gdb
.
post_event
(
posted_event_init
)
else
:
print
(
"
Finished everything
"
)
print
(
"
Finished everything
"
)
print
(
outputdata
)
print
(
outputdata
)
...
@@ -384,7 +390,10 @@ def ktest_setdata(file_index):
...
@@ -384,7 +390,10 @@ def ktest_setdata(file_index):
"""
"""
global
file_list
global
file_list
global
task_to_test
global
task_to_test
global
debug
b
=
KTest
.
fromfile
(
file_list
[
file_index
])
b
=
KTest
.
fromfile
(
file_list
[
file_index
])
if
debug
:
# print('ktest filename : %r' % filename)
# print('ktest filename : %r' % filename)
gdb
.
write
(
'
ktest file: %r
\n
'
%
file_list
[
file_index
])
gdb
.
write
(
'
ktest file: %r
\n
'
%
file_list
[
file_index
])
# print('args : %r' % b.args)
# print('args : %r' % b.args)
...
@@ -394,20 +403,24 @@ def ktest_setdata(file_index):
...
@@ -394,20 +403,24 @@ def ktest_setdata(file_index):
"""
If Name is
"
task
"
, skip it
"""
"""
If Name is
"
task
"
, skip it
"""
if
name
.
decode
(
'
UTF-8
'
)
==
"
task
"
:
if
name
.
decode
(
'
UTF-8
'
)
==
"
task
"
:
if
debug
:
print
(
'
object %4d: name: %r
'
%
(
i
,
name
))
print
(
'
object %4d: name: %r
'
%
(
i
,
name
))
print
(
'
object %4d: size: %r
'
%
(
i
,
len
(
data
)))
print
(
'
object %4d: size: %r
'
%
(
i
,
len
(
data
)))
# print(struct.unpack('i', str).repr())
# print(struct.unpack('i', str).repr())
# task_to_test = struct.unpack('i', str)[0]
# task_to_test = struct.unpack('i', str)[0]
# print("str: ", str)
# print("str: ", str)
# print("str: ", str[0])
# print("str: ", str[0])
# task_to_test = struct.unpack('i', str)[0]
task_to_test
=
struct
.
unpack
(
'
i
'
,
str
)[
0
]
task_to_test
=
int
(
str
[
0
])
# task_to_test = int(str[0])
if
debug
:
print
(
"
Task to test:
"
,
task_to_test
)
print
(
"
Task to test:
"
,
task_to_test
)
else
:
else
:
if
debug
:
print
(
'
object %4d: name: %r
'
%
(
i
,
name
))
print
(
'
object %4d: name: %r
'
%
(
i
,
name
))
print
(
'
object %4d: size: %r
'
%
(
i
,
len
(
data
)))
print
(
'
object %4d: size: %r
'
%
(
i
,
len
(
data
)))
# if opts.writeInts and len(data) == 4:
# if opts.writeInts and len(data) == 4:
obj_data
=
struct
.
unpack
(
'
i
'
,
str
)[
0
]
obj_data
=
struct
.
unpack
(
'
i
'
,
str
)[
0
]
if
debug
:
print
(
'
object %4d: data: %r
'
%
print
(
'
object %4d: data: %r
'
%
(
i
,
obj_data
))
(
i
,
obj_data
))
# gdb.execute('whatis %r' % name.decode('UTF-8'))
# gdb.execute('whatis %r' % name.decode('UTF-8'))
...
@@ -418,6 +431,7 @@ def ktest_setdata(file_index):
...
@@ -418,6 +431,7 @@ def ktest_setdata(file_index):
# gdb.execute('print %s' % name.decode('UTF-8'))
# gdb.execute('print %s' % name.decode('UTF-8'))
# else:
# else:
# print('object %4d: data: %r' % (i, str))
# print('object %4d: data: %r' % (i, str))
if
debug
:
print
(
"
Done with setdata
"
)
print
(
"
Done with setdata
"
)
...
@@ -426,9 +440,10 @@ def ktest_iterate():
...
@@ -426,9 +440,10 @@ def ktest_iterate():
last one.
last one.
"""
"""
curdir
=
os
.
getcwd
()
curdir
=
os
.
getcwd
()
if
debug
:
print
(
curdir
)
print
(
curdir
)
"""
We have already entered the output folder
"""
"""
We have already entered the output folder
"""
rustoutputfolder
=
"
../target/x86_64-unknown-linux-gnu/
release
/examples/
"
rustoutputfolder
=
"
../target/x86_64-unknown-linux-gnu/
debug
/examples/
"
try
:
try
:
os
.
chdir
(
rustoutputfolder
)
os
.
chdir
(
rustoutputfolder
)
except
IOError
:
except
IOError
:
...
@@ -439,6 +454,7 @@ def ktest_iterate():
...
@@ -439,6 +454,7 @@ def ktest_iterate():
dirlist
=
next
(
os
.
walk
(
"
.
"
))[
1
]
dirlist
=
next
(
os
.
walk
(
"
.
"
))[
1
]
dirlist
.
sort
()
dirlist
.
sort
()
if
debug
:
print
(
dirlist
)
print
(
dirlist
)
try
:
try
:
directory
=
dirlist
[
-
1
]
directory
=
dirlist
[
-
1
]
...
@@ -466,6 +482,7 @@ def tasklist_get():
...
@@ -466,6 +482,7 @@ def tasklist_get():
"""
Parse the automatically generated tasklist
"""
Parse the automatically generated tasklist
"""
"""
if
debug
:
print
(
os
.
getcwd
())
print
(
os
.
getcwd
())
with
open
(
'
../klee/tasks.txt
'
)
as
fin
:
with
open
(
'
../klee/tasks.txt
'
)
as
fin
:
for
line
in
fin
:
for
line
in
fin
:
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment