-
Notifications
You must be signed in to change notification settings - Fork 260
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
Gather shadow memory fields #7535
Gather shadow memory fields #7535
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #7535 +/- ##
========================================
Coverage 78.50% 78.50%
========================================
Files 1670 1671 +1
Lines 191795 191837 +42
========================================
+ Hits 150567 150610 +43
+ Misses 41228 41227 -1
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 in Codecov by Sentry. |
b6f4ffa
to
3286ae3
Compare
7606203
to
4266acf
Compare
4266acf
to
f474505
Compare
f474505
to
5986dcd
Compare
if(!can_cast_type<bitvector_typet>(expr.type())) | ||
{ | ||
throw unsupported_operation_exceptiont( | ||
"A shadow memory field must be of a bitvector type."); | ||
} | ||
if(to_bitvector_type(expr.type()).get_width() > 8) | ||
{ | ||
throw unsupported_operation_exceptiont( | ||
"A shadow memory field must not be larger than 8 bits."); | ||
} |
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.
Could we please catch this in the front-end and just have a DATA_INVARIANT
here?
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 would be doable, but it would mean splitting up the logic over multiple modules, i.e. there will be shadow memory-specific logic in the front end - I tried to avoid that by postponing these checks, but I can of course change this if preferred.
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.
I think it would be more user-friendly to catch problems early. If the front-end can tell the user that something will necessarily fail then IMHO it should do so.
} | ||
|
||
// record the field's initial value (and type) | ||
fields[field_name] = expr; |
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.
Probably a matter of style, but I'd prefer this method to return a pair (field_name, expr) and have the caller put this in place (the caller might choose insert or firmly replace).
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.
Looks good to me
444b48c
to
1921cff
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.
Approving, but I'd still strictly prefer to have some degree of sanity checking in the front-end.
|
||
messaget log(message_handler); | ||
log.debug() << "Shadow memory: declare " << (is_global ? "global " : "local ") | ||
<< "field " << id2string(field_name) << " of 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.
Nit pick: no need for id2string
here.
else if(string_expr.id() == ID_string_constant) | ||
{ | ||
return string_expr.get(ID_value); | ||
} |
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.
Nit pick: is there a reason for using braces (just!) here?
One of the utility functions that we are going to need in the shadow memory instrumentation implementation. We put these utility functions into a separate in order not to bloat the shadow_memory.cpp file.
Gathers the available shadow memory field definitions (__CPROVER_field_decl calls) from the goto model and stores them in a shadow_memory_field_definitionst.
Check that right/wrong shadow memory declarations are accepted/rejected.
1921cff
to
addef03
Compare
Implements shadow_memoryt::gather field declarations.
Next steps: