Skip to content

Commit

Permalink
Log incompleteness messages to semantics and symbolic interpreter
Browse files Browse the repository at this point in the history
Not used in concrete interpreter.

The incompleteness messages could be removed from semantics but this would require
ignoring the logging buffer in all equalities between states.
  • Loading branch information
benozol committed Feb 19, 2020
1 parent 760c533 commit 9190cea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 9 additions & 4 deletions src/concrete/semantics.mlw
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ module Buffers

val function split_on_default_ifs string : list string

let constant loop_limit_message = "[INCOMPLETE] Loop limit"
let constant stack_limit_message = "[INCOMPLETE] Stack limit"

scope Stdout

use bool.Bool
Expand Down Expand Up @@ -106,10 +109,10 @@ module Buffers
let function to_stdin out =
reverse (all_lines out)

let output str out =
let function output str out =
{ out with line = String.concat out.line str }

let newline out =
let function newline out =
{ line = ""; lines = Cons out.line out.lines }

(* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03 *)
Expand Down Expand Up @@ -653,7 +656,8 @@ module Semantics
eval_list_expr stk (inp, ctx, sta) es (sta1, Ok args) ->
ctx.func_env[id] = Some ins ->
inp.config.stack_size = Finite stk ->
eval_instruction stk (inp, ctx, sta) (ICallFunction id es) (sta1, ctx, BIncomplete)
let sta1' = { sta1 with log = Stdout.(newline (output stack_limit_message sta1.log)) } in
eval_instruction stk (inp, ctx, sta) (ICallFunction id es) (sta1', ctx, BIncomplete)

| eval_call_function: forall stk inp ctx ctx2 sta sta1 sta2 id es args ins bhv.
eval_list_expr stk (inp, ctx, sta) es (sta1, Ok args) ->
Expand Down Expand Up @@ -704,7 +708,8 @@ module Semantics
| eval_while_loop_limit: forall stk ctr b inp ctx sta ins1 ins2.
0 <= ctr ->
inp.config.loop_limit = Finite ctr ->
eval_while stk ctr b (inp, ctx, sta) ins1 ins2 (sta, ctx, BIncomplete) ctr b
let sta' = { sta with log = Stdout.(newline (output loop_limit_message sta.log)) } in
eval_while stk ctr b (inp, ctx, sta) ins1 ins2 (sta', ctx, BIncomplete) ctr b

(** Condition not normal *)
| eval_while_abort_condition: forall stk ctr b inp ctx ctx1 sta sta1 ins1 ins2 bhv1.
Expand Down
7 changes: 4 additions & 3 deletions src/symbolic/symbolicInterpreter.mlw
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ module Interpreter
if stk = get_finite inp.config.stack_size then (* Stack overflow *)
let aux arg =
let sta', _ = arg in
(* let sta' = { sta' with log = Stdout.(newline (output "INCOMPLETE: STACK_OVERFLOW" sta'.log)) } in *)
let sta' = { sta' with log = Stdout.(newline (output stack_limit_message sta'.log)) } in
{state=sta'; context=ctx; data=()}
in
Rs.({empty with failure = Cn.map aux arg_res})
Expand All @@ -695,7 +695,8 @@ module Interpreter
eval_list_expr stk (inp, ctx, sta) le (sta1, Ok args) ->
ctx.func_env[id] = Some ins ->
inp.config.stack_size = Finite stk ->
Rs.mem {state=sta1; context=ctx; data=()} BIncomplete result
let sta1' = { sta1 with log = Stdout.(newline (output stack_limit_message sta1.log)) } in
Rs.mem {state=sta1'; context=ctx; data=()} BIncomplete result
}
else (* Execute function *)
let res2 =
Expand Down Expand Up @@ -1003,7 +1004,7 @@ module Interpreter
}
= let loop_limit = get_finite inp.config.loop_limit in
if ctr = loop_limit then
(* let sta = { sta with log = Stdout.(newline (output "INCOMPLETE: LOOP_LIMIT" sta.log)) } in *)
let sta = { sta with log = Stdout.(newline (output loop_limit_message sta.log)) } in
Rs.({empty with failure=Cn.singleton {state=sta; context=ctx; data=(ctr, b)}})
else
let res1_normal, res1_abort =
Expand Down

0 comments on commit 9190cea

Please sign in to comment.