-
Notifications
You must be signed in to change notification settings - Fork 23
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
Abstract proof trace writer at event level #1136
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
037634a
removing unused flag
theo25 250335a
new abstract writer at the event level
theo25 1226f16
removing old proof_trace_writer
theo25 1ce3f01
fix bug in writing values of type i1
theo25 650b571
clearer naming of write methods
theo25 1af3d5a
Merge branch 'develop' into abstract-event-writer
theo25 36885d5
support for new pattern_matching_failure event
theo25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#ifndef RUNTIME_PROOF_TRACE_WRITER_H | ||
#define RUNTIME_PROOF_TRACE_WRITER_H | ||
|
||
#include <kllvm/binary/ProofTraceParser.h> | ||
#include <runtime/header.h> | ||
|
||
#include <cstdio> | ||
|
||
class proof_trace_writer { | ||
public: | ||
virtual ~proof_trace_writer() = default; | ||
|
||
virtual void proof_trace_header(uint32_t version) = 0; | ||
virtual void hook_event_pre( | ||
char const *name, char const *pattern, char const *location_stack) | ||
= 0; | ||
virtual void | ||
hook_event_post(void *hook_result, uint64_t block_header, bool indirect) | ||
= 0; | ||
virtual void argument(void *arg, uint64_t block_header, bool indirect) = 0; | ||
virtual void rewrite_event_pre(uint64_t ordinal, uint64_t arity) = 0; | ||
virtual void | ||
variable(char const *name, void *var, uint64_t block_header, bool indirect) | ||
= 0; | ||
virtual void | ||
rewrite_event_post(void *config, uint64_t block_header, bool indirect) | ||
= 0; | ||
virtual void function_event_pre(char const *name, char const *location_stack) | ||
= 0; | ||
virtual void function_event_post() = 0; | ||
virtual void side_condition_event_pre(uint64_t ordinal, uint64_t arity) = 0; | ||
virtual void | ||
side_condition_event_post(uint64_t ordinal, bool side_cond_result) | ||
Robertorosmaninho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
= 0; | ||
virtual void configuration(block *config) = 0; | ||
virtual void end_of_trace() = 0; | ||
}; | ||
|
||
class proof_trace_file_writer : public proof_trace_writer { | ||
private: | ||
FILE *file_; | ||
|
||
void write(void const *ptr, size_t len) { fwrite(ptr, len, 1, file_); } | ||
|
||
void write_string(char const *str, size_t len) { fwrite(str, 1, len, file_); } | ||
|
||
// Note: This method will not write a 0 at the end of string. | ||
// The passed string should be 0 terminated. | ||
void write_string(char const *str) { fputs(str, file_); } | ||
|
||
// Note: this method will write a 0 at the end of the string. | ||
// The passed string should be 0 terminated. | ||
void write_null_terminated_string(char const *str) { | ||
write_string(str); | ||
char n = 0; | ||
write(&n, 1); | ||
} | ||
Robertorosmaninho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
void write_bool(bool b) { write(&b, sizeof(bool)); } | ||
void write_uint32(uint32_t i) { write(&i, sizeof(uint32_t)); } | ||
void write_uint64(uint64_t i) { write(&i, sizeof(uint64_t)); } | ||
|
||
public: | ||
proof_trace_file_writer(FILE *file) | ||
: file_(file) { } | ||
|
||
void proof_trace_header(uint32_t version) override { | ||
write_string("HINT"); | ||
write_uint32(version); | ||
} | ||
|
||
void hook_event_pre( | ||
char const *name, char const *pattern, | ||
char const *location_stack) override { | ||
write_uint64(kllvm::hook_event_sentinel); | ||
write_null_terminated_string(name); | ||
write_null_terminated_string(pattern); | ||
write_null_terminated_string(location_stack); | ||
} | ||
|
||
void hook_event_post( | ||
void *hook_result, uint64_t block_header, bool indirect) override { | ||
write_uint64(kllvm::hook_result_sentinel); | ||
serialize_term_to_proof_trace(file_, hook_result, block_header, indirect); | ||
} | ||
|
||
void argument(void *arg, uint64_t block_header, bool indirect) override { | ||
serialize_term_to_proof_trace(file_, arg, block_header, indirect); | ||
} | ||
|
||
void rewrite_event_pre(uint64_t ordinal, uint64_t arity) override { | ||
write_uint64(kllvm::rule_event_sentinel); | ||
write_uint64(ordinal); | ||
write_uint64(arity); | ||
} | ||
|
||
void variable( | ||
char const *name, void *var, uint64_t block_header, | ||
bool indirect) override { | ||
write_null_terminated_string(name); | ||
serialize_term_to_proof_trace(file_, var, block_header, indirect); | ||
} | ||
|
||
void rewrite_event_post( | ||
void *config, uint64_t block_header, bool indirect) override { | ||
write_uint64(kllvm::config_sentinel); | ||
serialize_term_to_proof_trace(file_, config, block_header, indirect); | ||
} | ||
|
||
void | ||
function_event_pre(char const *name, char const *location_stack) override { | ||
write_uint64(kllvm::function_event_sentinel); | ||
write_null_terminated_string(name); | ||
write_null_terminated_string(location_stack); | ||
} | ||
|
||
void function_event_post() override { | ||
write_uint64(kllvm::function_end_sentinel); | ||
} | ||
|
||
void side_condition_event_pre(uint64_t ordinal, uint64_t arity) override { | ||
write_uint64(kllvm::side_condition_event_sentinel); | ||
write_uint64(ordinal); | ||
write_uint64(arity); | ||
} | ||
|
||
void | ||
side_condition_event_post(uint64_t ordinal, bool side_cond_result) override { | ||
write_uint64(kllvm::side_condition_end_sentinel); | ||
write_uint64(ordinal); | ||
write_bool(side_cond_result); | ||
} | ||
|
||
void configuration(block *config) override { | ||
write_uint64(kllvm::config_sentinel); | ||
serialize_configuration_to_proof_trace(file_, config, 0); | ||
} | ||
|
||
void end_of_trace() override { } | ||
}; | ||
|
||
#endif // RUNTIME_PROOF_TRACE_WRITER_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 understand that this will be deleted by DCE, but is it really impossible to prevent this writing from being in MergeBlock? Can you elaborate a bit more on this?
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.
So there is an issue with the way github presents the diff for this PR. If you notice this is not my code, it has been just deleted from a different place in the file and moved here verbatim. As such I have no comment on what should be done with it and whatever it is that we may decide, it shouldn't be part of this PR anyway.
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.
That's pretty awkward indeed.