-
Notifications
You must be signed in to change notification settings - Fork 274
Shadow memory interface and integration hooks [blocks 7535] #7523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shadow memory interface and integration hooks [blocks 7535] #7523
Conversation
3d9116b
to
fb7024c
Compare
daea9f4
to
161c60c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few initial thoughts.
Codecov ReportBase: 78.39% // Head: 78.49% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #7523 +/- ##
===========================================
+ Coverage 78.39% 78.49% +0.09%
===========================================
Files 1663 1667 +4
Lines 191354 191431 +77
===========================================
+ Hits 150013 150255 +242
+ Misses 41341 41176 -165
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
My standard concern: symex is already beyond the breaking point in terms of complexity. It should really be re-implemented from scratch. Furthermore, a downside of tying this into symex is that you'll never be able to use any other analyzers. No way this can be done as a program instrumentation? |
The integration has only a few touchpoints with symex, which are already all fully implemented in this PR:
That's it.
Having tried to implement that on various levels (C, goto, symex), I can say that the symex-level implementation is by far the most correct, simplest and elegant, and orders of magnitude faster. The crucial ingredient for the implementation is to replace the base objects (i.e. the original memory chunks by their shadows) in a given pointer-dereference operation. This is totally trivial in symex, but can't be reasonably emulated on goto or C level. |
161c60c
to
2f5bf1e
Compare
These will hold the shadow memory field definitions declared by the user in the C source files via shadow memory API calls.
This data structure tracks the shadow memory information during symbolic execution.
This tracks the shadow memory information required to resolve get_field and set_field shadow memory accesses.
The interface provided by the shadow memory instrumentation for integration with the symbolic execution.
2f5bf1e
to
9f7f2e5
Compare
@@ -98,16 +109,22 @@ class goto_symext | |||
/// having the state around afterwards. | |||
/// \param get_goto_function: The delegate to retrieve function bodies (see | |||
/// \ref get_goto_functiont) | |||
/// \return A symbol table holding the symbols added during symbolic | |||
/// execution. | |||
/// \param fields The shadow memory field declarations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change (unintentionally?) discards the \return
comment.
src/goto-symex/shadow_memory.cpp
Outdated
id2string(state.source.function_id), | ||
SHADOW_MEMORY_PREFIX + from_expr(expr) + "__" + id2string(field_name), | ||
state.source.pc->source_location(), | ||
ID_C, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always the right mode?
src/goto-symex/symex_assign.cpp
Outdated
if(rhs.id() == ID_address_of) | ||
{ | ||
const address_of_exprt &address_of = to_address_of_expr(rhs); | ||
if(address_of.object().id() == ID_index) | ||
{ | ||
const index_exprt &index = to_index_expr(address_of.object()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might consider using expr_try_dynamic_cast
to make this code more concise?
src/goto-symex/symex_assign.cpp
Outdated
const index_exprt &index = to_index_expr(address_of.object()); | ||
if( | ||
index.array().id() == ID_string_constant && | ||
index.index() == from_integer(0, c_index_type())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does any other type not work here? Could you instead use index.index().is_zero()
?
The actual implementation will be added incrementally in future PRs.
Gathers the __CPROVER_field_decl* calls from the goto model. In the next step we'll pass them to goto_symex.
Initializees the shadow_memory member of the goto_symex_state that tracks the shadow memory information during symbolic execution.
Triggers allocation of global-scope shadow memory.
This will allow us to call the shadow memory instrumentation API.
This triggers the allocation of local-scope shadow memory.
This triggers the allocation of local-scope\ shadow memory.
We need to call the shadow memory instrumentation API from there.
9f7f2e5
to
9fed50f
Compare
or static variables.
Symbolically executes the respective shadow memory access calls. These produce assignments by calling symex_assign.
9fed50f
to
67ce46b
Compare
This adds the shadow memory integration interface and integrates it into goto-symex.
The implementation is left empty and will be filled in incrementally in follow-up PRs.
No functional change to CBMC at this point.