Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
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
?
Snippets
Groups
Projects
Show more breadcrumbs
Samuel Karlsson
cortex-m-rtfm-klee
Commits
78daae2e
Commit
78daae2e
authored
Mar 4, 2018
by
Per
Browse files
Options
Downloads
Plain Diff
Merge branch 'klee' of gitlab.henriktjader.com:KLEE/cortex-m-rtfm-klee into klee
parents
f1806843
edc46b48
No related branches found
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
+59
-27
59 additions, 27 deletions
klee_stm_gdb.py
with
59 additions
and
27 deletions
klee_stm_gdb.py
+
59
−
27
View file @
78daae2e
#!/usr/bin/env python
import
gdb
import
os
import
sys
...
...
@@ -12,6 +13,8 @@ version_no = 3
debug
=
False
autobuild
=
True
debug_file
=
"
resource
"
klee_out_folder
=
'
target/x86_64-unknown-linux-gnu/debug/examples/
'
stm_out_folder
=
'
target/thumbv7em-none-eabihf/release/examples/
'
...
...
@@ -19,7 +22,6 @@ file_list = []
file_index_current
=
0
object_index_current
=
0
example_name
=
"
resource
"
tasks
=
[]
task_to_test
=
0
...
...
@@ -34,9 +36,6 @@ init_done = 0
"""
Max number of events guard
"""
object_index_max
=
100
database_name
=
"
klee_profiling
"
path
=
"
output
"
"""
Define the original working directory
"""
original_pwd
=
os
.
getcwd
()
...
...
@@ -114,7 +113,8 @@ class MainBP(gdb.Breakpoint):
def
stop
(
self
):
global
init_done
if
self
.
location
==
"
init
"
:
print
(
"
Breakpoint location: %s
"
%
self
.
location
)
if
self
.
location
==
"
main
"
:
if
not
init_done
:
# gdb.prompt_hook = prompt
...
...
@@ -152,7 +152,7 @@ def stop_event(evt):
except
gdb
.
error
:
"""
If there is no ceiling, it means we have returned to in
it
If there is no ceiling, it means we have returned to
ma
in
since every claim have ceiling
"""
# gdb.events.stop.disconnect(stop_event)
...
...
@@ -222,7 +222,7 @@ def prompt(current):
def
posted_event_init
():
"""
Called at the very beginning of execution
when the breakpoint at in
it
() is hit
when the breakpoint at
ma
in() is hit
Loads each defined task
...
...
@@ -339,6 +339,7 @@ def ktest_setdata(file_index):
if
debug
:
print
(
'
object %4d: name: %r
'
%
(
i
,
name
))
print
(
'
object %4d: size: %r
'
%
(
i
,
len
(
data
)))
print
(
str
)
# if opts.writeInts and len(data) == 4:
obj_data
=
struct
.
unpack
(
'
i
'
,
str
)[
0
]
if
debug
:
...
...
@@ -347,7 +348,7 @@ def ktest_setdata(file_index):
# gdb.execute('whatis %r' % name.decode('UTF-8'))
# gdb.execute('whatis %r' % obj_data)
gdb
.
execute
(
'
set variable %s = %r
'
%
(
name
.
decode
(
'
UTF-8
'
),
obj_data
))
(
example_name
+
"
::
"
+
name
.
decode
(
'
UTF-8
'
),
obj_data
))
# gdb.write('Variable %s is:' % name.decode('UTF-8'))
# gdb.execute('print %s' % name.decode('UTF-8'))
# else:
...
...
@@ -366,7 +367,7 @@ def ktest_iterate():
curdir
=
os
.
getcwd
()
if
debug
:
print
(
curdir
)
"""
We have already entered the output folder
"""
rustoutputfolder
=
curdir
+
"
/
"
+
klee_out_folder
try
:
os
.
chdir
(
rustoutputfolder
)
...
...
@@ -401,6 +402,9 @@ def ktest_iterate():
print
(
"
Running klee...
"
)
klee_run
()
"""
Ran KLEE, need to update the dirlist
"""
dirlist
=
next
(
os
.
walk
(
"
.
"
))[
1
]
dirlist
.
sort
()
try
:
directory
=
dirlist
[
-
1
]
except
IOError
:
...
...
@@ -513,40 +517,68 @@ def gdb_cyccnt_write(num):
gdb
.
execute
(
'
mon mww 0xe0001004 %r
'
%
num
)
"""
Check if the MCU code is compiled
"""
"""
Used for making GDB scriptable
"""
gdb
.
execute
(
"
set confirm off
"
)
gdb
.
execute
(
"
set pagination off
"
)
gdb
.
execute
(
"
set verbose off
"
)
gdb
.
execute
(
"
set height 0
"
)
"""
Setup GDB for remote debugging
"""
gdb
.
execute
(
"
target remote :3333
"
)
gdb
.
execute
(
"
monitor arm semihosting enable
"
)
"""
Check if the user passed a file to use as the source.
If a file is given, use this as the example_name
"""
if
gdb
.
progspaces
()[
0
].
filename
:
"""
A filename was given on the gdb command line
"""
example_name
=
gdb
.
progspaces
()[
0
].
filename
.
split
(
'
/
'
)[
-
1
]
print
(
"
The resource used for debugging: %s
"
%
example_name
)
try
:
if
os
.
listdir
(
stm_out_folder
)
==
[]:
"""
There are no files, compile
"""
os
.
path
.
exists
(
gdb
.
progspaces
()[
0
].
filename
)
except
IOError
:
"""
Compiles the given example
"""
xargo_run
(
"
stm
"
)
gdb
.
execute
(
"
file %s
"
%
(
stm_out_folder
+
example_name
))
gdb
.
execute
(
"
load
"
)
xargo_run
(
"
klee
"
)
else
:
example_name
=
debug_file
print
(
"
Defaulting to example
'
%s
'
for debugging.
"
%
example_name
)
try
:
if
example_name
not
in
os
.
listdir
(
stm_out_folder
):
"""
Compiles the default example
"""
xargo_run
(
"
stm
"
)
xargo_run
(
"
klee
"
)
except
IOError
:
"""
Compiles the default example
"""
xargo_run
(
"
stm
"
)
xargo_run
(
"
klee
"
)
"""
Tell GDB to load the file
"""
gdb
.
execute
(
"
file %s
"
%
(
stm_out_folder
+
example_name
))
gdb
.
execute
(
"
load
"
)
gdb
.
execute
(
"
load %s
"
%
(
stm_out_folder
+
example_name
))
# gdb.execute("step")
"""
Run KLEE on the generated files
"""
# print(klee_run())
"""
Break at main to set variable values
"""
# AddBreakpoint("main")
MainBP
(
"
in
it
"
)
MainBP
(
"
ma
in
"
)
"""
Tell gdb-dashboard to hide
"""
# gdb.execute("dashboard -enabled off")
# gdb.execute("dashboard -output /dev/null")
"""
Also break at the
main
-loop
"""
"""
Also break at the
idle
-loop
"""
MainBP
(
"
idle
"
)
# MainBP("terminate_execution")
"""
Used for making it scriptable
"""
gdb
.
execute
(
"
set confirm off
"
)
gdb
.
execute
(
"
set pagination off
"
)
gdb
.
execute
(
"
set verbose off
"
)
gdb
.
execute
(
"
set height 0
"
)
"""
Save all ktest files into an array
"""
file_list
=
ktest_iterate
()
# print(file_list)
...
...
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