Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
klee_tutorial
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ruben Asplund
klee_tutorial
Commits
44a35f0d
Commit
44a35f0d
authored
4 years ago
by
Ruben Asplund
Browse files
Options
Downloads
Patches
Plain Diff
Exercise B and C
parent
f7a47b34
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
cargo_klee_examples/examples/cyccnt.rs
+13
-6
13 additions, 6 deletions
cargo_klee_examples/examples/cyccnt.rs
with
13 additions
and
6 deletions
cargo_klee_examples/examples/cyccnt.rs
+
13
−
6
View file @
44a35f0d
...
@@ -19,7 +19,7 @@ fn main() {
...
@@ -19,7 +19,7 @@ fn main() {
let
end
=
core
.DWT.cyccnt
.read
();
let
end
=
core
.DWT.cyccnt
.read
();
let
_time
=
end
-
start
;
//
let _time = end
.wrapping_sub(
start
)
;
}
}
// A) Running KLEE on embedded code:
// A) Running KLEE on embedded code:
...
@@ -166,7 +166,9 @@ fn main() {
...
@@ -166,7 +166,9 @@ fn main() {
//
//
// What do you get, and why?
// What do you get, and why?
//
//
// [There are no value of start or end because both are optimized out.]
// [There are no value of start or end because both are optimized out.
// The variables are used for substraction, the difference value is is thrown away.
// Then start and end is useless, therefore they are optimized out.]
//
//
// As you should have seen, this was not particularly informative, right?
// As you should have seen, this was not particularly informative, right?
//
//
...
@@ -197,15 +199,19 @@ fn main() {
...
@@ -197,15 +199,19 @@ fn main() {
//
//
// Value of `start`.
// Value of `start`.
//
//
// [
your answer here
]
// [
start = 0
]
//
//
// Value of `end`
// Value of `end`
//
//
// [
your answer here
]
// [
end = 0
]
//
//
// Why does these values cause an error debug/dev build but not in a release build?
// Why does these values cause an error debug/dev build but not in a release build?
//
//
// [your answer here]
// [This line is causing the problem: let _time = end - start;
// When taking substraction of values two values there is a high risk that it will overflow,
// therefore the error occurs in debug/dev build.
// In release build the substractions occurs and no overflow is found then errors will not occurs.
// It seems like the release build is not detecting potential problems, only problems that occurs.]
//
//
// C) Fix the problem!
// C) Fix the problem!
//
//
...
@@ -217,7 +223,8 @@ fn main() {
...
@@ -217,7 +223,8 @@ fn main() {
// There are numerous ways to solve the problem.
// There are numerous ways to solve the problem.
// Argue for your solution in your own words.
// Argue for your solution in your own words.
//
//
// [your answer here]
// [The substraction can overflow, to remove the error and make sure the substraction is almost always correct,
// we need to use wrapper_sub.]
//
//
// D) Learning outcomes and major takeaways.
// D) Learning outcomes and major takeaways.
//
//
...
...
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