Skip to content

Commit

Permalink
implements eval-cond via jumping
Browse files Browse the repository at this point in the history
The `eval-cond` signal is less powerfull that its the same named
`eval-cond` observation (as it is not fired from the Lisp code),
so we should either deprecate it or even remove it (to prevent
confusion between singal and observation that have same meaning but
different semantics).

With that said, the semantics of `eval-cond` is the same as it was
befor 2.1.0 (i.e., starting from 1.5 to 2.0 inclusive), it has changed
only in 2.1.0 and now we are rolling back it again.

The future of this signal is unclear. Possible we will be able to
enable it in the 2.1.0 semantics by enabling two modes of execution
of the Primus code - analysis and modelling, but this requires a lot
of effort and many not work at the end, so it might be that we will
remove this signal at all from Primus Lisp interface in 2.2.0.
  • Loading branch information
ivg committed Jun 22, 2020
1 parent 5cecd09 commit 4308304
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/bap_primus/bap_primus_lisp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type bindings = {
type state = {
program : Lisp.Program.t;
typeenv : Lisp.Program.Type.env;
signals : subscription String.Map.t;
signals : subscription list String.Map.t;
width : int;
env : bindings;
cur : Id.t;
Expand Down Expand Up @@ -785,7 +785,7 @@ module Make(Machine : Machine) = struct
proj x >>= Self.eval_signal name) >>= fun sub ->
Machine.Local.update state ~f:(fun s -> {
s with program = Lisp.Program.add s.program signal r;
signals = Map.add_exn s.signals name sub;
signals = Map.add_multi s.signals name sub;
})


Expand Down Expand Up @@ -822,7 +822,7 @@ module Make(Machine : Machine) = struct
let useless_subscriptions =
Map.fold s.signals ~init:[] ~f:(fun ~key:name ~data:sub subs ->
if Set.mem known_methods name then subs
else sub::subs) in
else List.rev_append sub @@ subs) in
Machine.List.iter useless_subscriptions ~f:Machine.Observation.cancel


Expand Down
5 changes: 3 additions & 2 deletions plugins/primus_lisp/primus_lisp_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ module Signals(Machine : Primus.Machine.S) = struct
{|(written V X) is emitted when X is written to V|};
signal pc_change word one Type.(one int)
{|(pc-change PC) is emitted when PC is updated|};
signal eval_cond value one Type.(one bool)
{|(eval-cond V) is emitted after evaluating a conditional to V|};
signal jumping (value,value) pair Type.(tuple [bool; int])
{|(jumping C D) is emitted before jump to D occurs under the
condition C|};
Expand Down Expand Up @@ -133,6 +131,9 @@ module Signals(Machine : Primus.Machine.S) = struct
The machine is in the resticted mode in the body of the
methods."
~params:Type.unit;
Lisp.signal jumping (fun (cnd,_) -> value cnd >>| List.return)
~doc:{|(eval-cond V) is emitted after evaluating a conditional to V|}
~params:Type.(one bool);
]
end

Expand Down

0 comments on commit 4308304

Please sign in to comment.