-
Notifications
You must be signed in to change notification settings - Fork 274
Memory analyzer to take memory snapshots [blocks: #2649, #4438] #4261
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
Conversation
src/util/c_types_util.h
Outdated
|
||
/// \file | ||
/// This file contains functions, that should support test for underlying | ||
/// c types, in cases where this is required for anlysis purpose. |
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.
analysis
src/util/c_types_util.h
Outdated
return type.id() == ID_c_bool; | ||
} | ||
|
||
/// This function checks, whether the type is has been some kind of integer |
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 has been -> has been
src/util/c_types_util.h
Outdated
/// \param c_enum the enum type memeber_name is supposed to be part of. | ||
/// \return value a constant, that could be assigned as value for an expression | ||
/// with type c_enum. | ||
constant_exprt convert_memeber_name_to_enum_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.
member
src/util/c_types_util.h
Outdated
/// This function creates a constant representing the | ||
/// bitvector encoded integer value of a string in the enum. | ||
/// \param member_name is a string that should be in the enum. | ||
/// \param c_enum the enum type memeber_name is supposed to be part of. |
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.
\p member_name
src/util/c_types_util.h
Outdated
{ | ||
if(id2string(enum_value.get_identifier()) == member_name) | ||
{ | ||
mp_integer int_value = string2integer(id2string(enum_value.get_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.
Could this the call the safe version returning optionalt
?
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 should just be numeric_cast<mp_integer>(enum_value.get_value())
I think
This is just trying to convert constants between different types - I think we might have a function for that already, but I'm not sure
src/util/c_types_util.h
Outdated
/// bitvector encoded integer value of a string in the enum. | ||
/// \param member_name is a string that should be in the enum. | ||
/// \param c_enum the enum type memeber_name is supposed to be part of. | ||
/// \return value a constant, that could be assigned as value for an expression |
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 sounds strange.
<< " --breakpoint <breakpoint> analyze from breakpoint\n" | ||
<< " --symbols <symbol-list> list of symbols to analyze\n" | ||
<< " --symtab-snapshot output snapshot as symbol table\n" | ||
<< " --output-file <file> write snapshot to file\n" |
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 add a --json-ui
here, since it's somewhat useful for goto-harness
?
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.
Currently we have the option --symtab-snapshot
which outputs the memory snapshot in json format.
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.
$ ../../../build/bin/memory-analyzer --symtab-snapshot --breakpoint checkpoint --symbols array main_exe
Symbols:
Symbol......: __CPROVER_size_t
Pretty name.: __CPROVER_size_t
Module......: main
Base name...: __CPROVER_size_t
Mode........: C
Type........: __CPROVER_size_t
Value.......:
Flags.......: thread_local file_local type macro
Location....: file <built-in-additions> line 1
Symbol......: array
Pretty name.: array
Module......: main
Base name...: array
Mode........: C
Type........: signed int [3l]
Value.......: { 1, 4, 3 }
Flags.......: lvalue static_lifetime
Location....: file main.c line 5
Am I using it wrong?
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.
Oh, you're right. --json-ui
is indeed needed and missing from the help section.
32a410e
to
9be9e7f
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: c19aa7b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/111901196
This code takes a static symbol, zero initalizes the typet of the symbol and then fills it up with values if possible. Following the declared structure in the typet, the analyzer queries the gdb api for values of the attributes of typet. It the symbol is a primtive type, the analyzer directly queries for the value of the symbol.
These test have been used as driving example for the memory analyzer. They test basic functionality and handling of cycles in structs.
This adds an updated chain.sh file, and disables the existing regression tests. They currently fail due to two issues: goto code to c conversion currently ignores array sizes (i.e., even int arrays of known sizes are output as int[]), and void pointers are not handled (i.e., analyze_symbol() may try to zero initialize an object of type void, yielding an invariant violation).
This update the gdb api to return more information about pointers (via the method get_memory() which returns an object of type pointer_valuet describing the pointer and pointed-to data). Unit tests for the new functionality are included.
…pr.h A previous commit introduced e.g. function is_pointer() to check type.id() == ID_pointer. These have become obsolete as these expressions are now used directly.
This updates the symbol analyzer which is used by the memory analyzer. The class is refactored and updated to use the new gdb api.
We were doing this in multiple places, this should make it a bit easier to keep set properties consistent among different places. Ideally we could eventually move away from mentioning targets from modules here on the top level (and instead have each module call cprover_default_properties) but this isn't done in this commit. Because memory analyzer depends on GDB being present and further uses platform specific functionality at the moment it had some ifdef functionality to disable itself. This made the code a bit more complicated than it needed to be, and also lead to the code effectively building defunct executables. This removes these ifdefs and instead excludes memory-analyzer (and related tests) from the build unless requested (via WITH_MEMORY_ANALYZER environment variable or CMake option depending on whether it is a Make or CMake build respectively). Also force building memory-analyzer on Linux and test it there by default (unless explicitly unset). Behaviour on other platforms should be preserved.
and update the chain script accordingly.
mostly the description and expected output.
mostly white spaces and cprover_default_properties.
Add memory_addresst and documentation.
Better names and small code refactoring.
and add documentation.
Remove ui_message_handler dependence, fix header, etc.
to the new interface.
to CPROVER manual.
c19aa7b
to
35abeee
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 35abeee).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/112065798
Uh oh!
There was an error while loading. Please reload this page.