Skip to content

Commit 95fbc85

Browse files
authored
Merge pull request #5432 from natasha-jeppu/byte-extract-update-pr
CBMC additional profiling info: byte extract, update metrics
2 parents 7b5ba16 + bf3a0f5 commit 95fbc85

File tree

12 files changed

+370
-2
lines changed

12 files changed

+370
-2
lines changed

regression/cbmc/byte-op-metric/main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
typedef unsigned char BYTE;
2+
3+
int main()
4+
{
5+
unsigned int value;
6+
BYTE *bp = (BYTE *)(&value);
7+
8+
bp[0] = bp[2];
9+
assert(1);
10+
return 0;
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CORE
2+
main.c
3+
--show-byte-ops
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^Byte Extracts:$
7+
^.*main\.c line 8 function main$
8+
^.* byte\_extract\_little\_endian\(.*\)$
9+
^Number of byte extracts: 1$
10+
^Byte Updates:$
11+
^.*main\.c line 8 function main$
12+
^.* byte\_update\_little\_endian\(.*\)$
13+
^Number of byte updates: 1$
14+
--
15+
--
16+
To test --show-byte-ops option that displays byte extract and update metrics.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--show-byte-ops --json-ui
4+
activate-multi-line-match
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
"byteOpsStats": \{\n\s*"byteExtractStats": \{\n\s*"byteExtractList": \[\n\s*\{\n\s*"sourceLocation": \{(\n.*)*\},\n\s*"ssaExpr": \{(\n.*)*\},\n\s*"ssaExprString": ".* .* byte\_extract\_little\_endian\(.*\)"\n\s*\}\n\s*\],\n\s*"numOfExtracts": 1\n\s*\},\n\s*"byteUpdateStats": \{\n\s*"byteUpdateList": \[\n\s*\{\n\s*"sourceLocation": \{(\n.*)*\},\n\s*"ssaExpr": \{(\n.*)*\},\n\s*"ssaExprString": ".* .* byte\_update\_little\_endian\(.*\)"\n\s*\}\n\s*\],\n\s*"numOfUpdates": 1\n\s*\}
8+
--
9+
--
10+
To test json output for --show-byte-ops option that displays byte extract and update metrics.

src/cbmc/cbmc_parse_options.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
198198
if(cmdline.isset("program-only"))
199199
options.set_option("program-only", true);
200200

201+
if(cmdline.isset("show-byte-ops"))
202+
options.set_option("show-byte-ops", true);
203+
201204
if(cmdline.isset("show-vcc"))
202205
options.set_option("show-vcc", true);
203206

@@ -640,7 +643,8 @@ int cbmc_parse_optionst::doit()
640643

641644
if(
642645
options.get_bool_option("program-only") ||
643-
options.get_bool_option("show-vcc"))
646+
options.get_bool_option("show-vcc") ||
647+
options.get_bool_option("show-byte-ops"))
644648
{
645649
if(options.get_bool_option("paths"))
646650
{

src/goto-checker/bmc_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ void run_property_decider(
173173
// clang-format off
174174
#define OPT_BMC \
175175
"(program-only)" \
176+
"(show-byte-ops)" \
176177
"(show-loops)" \
177178
"(show-vcc)" \
178179
"(show-goto-symex-steps)" \
@@ -203,6 +204,7 @@ void run_property_decider(
203204
" --show-goto-symex-steps show which steps symex travels, includes " \
204205
" diagnostic information\n" \
205206
" --program-only only show program expression\n" \
207+
" --show-byte-ops show all byte extracts and updates\n" \
206208
" --show-loops show the loops in the program\n" \
207209
" --depth nr limit search depth\n" \
208210
" --max-field-sensitivity-array-size M\n" \

src/goto-checker/multi_path_symex_only_checker.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ operator()(propertiest &properties)
5959
show_program(ns, equation);
6060
}
6161

62+
if(options.get_bool_option("show-byte-ops"))
63+
{
64+
show_byte_ops(options, ui_message_handler, ns, equation);
65+
}
66+
6267
resultt result(resultt::progresst::DONE);
6368
update_properties(properties, result.updated_properties);
6469
return result;

src/goto-checker/single_path_symex_only_checker.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ void single_path_symex_only_checkert::equation_output(
127127
if(options.get_bool_option("program-only"))
128128
show_program(ns, equation);
129129

130+
if(options.get_bool_option("show-byte-ops"))
131+
show_byte_ops(options, ui_message_handler, ns, equation);
132+
130133
if(options.get_bool_option("validate-ssa-equation"))
131134
{
132135
symex.validate(validation_modet::INVARIANT);

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options)
8383
if(cmdline.isset("program-only"))
8484
options.set_option("program-only", true);
8585

86+
if(cmdline.isset("show-byte-ops"))
87+
options.set_option("show-byte-ops", true);
88+
8689
if(cmdline.isset("show-vcc"))
8790
options.set_option("show-vcc", true);
8891

0 commit comments

Comments
 (0)