Skip to content
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

Merged
merged 4 commits into from
Mar 23, 2023

Conversation

peterschrammel
Copy link
Member

@peterschrammel peterschrammel commented Feb 11, 2023

Implements shadow_memoryt::gather field declarations.

Next steps:

  1. Fix up Extend expr_initializer to support byte-wise initialization #7392
  2. Use 1. for shadow memory initializations
  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • [n/a] The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • [n/a] My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • [n/a] White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Feb 11, 2023

Codecov Report

Patch coverage: 97.67% and no project coverage change.

Comparison is base (7e7864b) 78.50% compared to head (addef03) 78.50%.

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     
Impacted Files Coverage Δ
src/goto-symex/shadow_memory.h 100.00% <ø> (ø)
src/goto-symex/shadow_memory.cpp 73.33% <97.05%> (+36.29%) ⬆️
src/goto-symex/shadow_memory_util.cpp 100.00% <100.00%> (ø)

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@peterschrammel peterschrammel changed the title Gather shadow memory fields Gather shadow memory fields [depends: 7523] Feb 12, 2023
@peterschrammel peterschrammel changed the title Gather shadow memory fields [depends: 7523] Gather shadow memory fields [depends on 7523] Feb 12, 2023
@peterschrammel peterschrammel force-pushed the shadow-memory-basic2 branch 2 times, most recently from 7606203 to 4266acf Compare February 12, 2023 13:02
@peterschrammel peterschrammel self-assigned this Feb 13, 2023
@peterschrammel peterschrammel changed the title Gather shadow memory fields [depends on 7523] Gather shadow memory fields Feb 18, 2023
@peterschrammel peterschrammel marked this pull request as ready for review February 18, 2023 17:29
Comment on lines +168 to +176
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.");
}
Copy link
Collaborator

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?

Copy link
Member Author

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.

Copy link
Collaborator

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;
Copy link
Collaborator

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).

Copy link
Contributor

@esteffin esteffin left a 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

@esteffin esteffin force-pushed the shadow-memory-basic2 branch 2 times, most recently from 444b48c to 1921cff Compare March 6, 2023 17:29
Copy link
Collaborator

@tautschnig tautschnig left a 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 "
Copy link
Collaborator

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.

Comment on lines +26 to +29
else if(string_expr.id() == ID_string_constant)
{
return string_expr.get(ID_value);
}
Copy link
Collaborator

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?

@tautschnig tautschnig removed their assignment Mar 7, 2023
peterschrammel and others added 4 commits March 21, 2023 11:51
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.
@esteffin esteffin merged commit 9cdd34f into diffblue:develop Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants