Skip to content

Commit

Permalink
Add a -trace-register-updates option
Browse files Browse the repository at this point in the history
The idea is for this to play a similar debugging role to
-trace-registers, but it's less verbose (more comparable to
-trace-insns and -trace-loads) because it only prints messages when a
register is written to, and skips temporaries and condition code flags.
  • Loading branch information
smcc committed Aug 4, 2018
1 parent 3119bb4 commit 6e2b309
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions execution/exec_options.ml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ let opt_check_read_operands = ref false
let opt_check_write_operands = ref false
let opt_fix_write_operands = ref false
let opt_trace_registers = ref false
let opt_trace_register_updates = ref false
let opt_trace_segments = ref false
let opt_trace_taint = ref false
let opt_trace_unexpected = ref false
Expand Down
1 change: 1 addition & 0 deletions execution/exec_options.mli
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ val opt_check_read_operands : bool ref
val opt_check_write_operands : bool ref
val opt_fix_write_operands : bool ref
val opt_trace_registers : bool ref
val opt_trace_register_updates : bool ref
val opt_trace_segments : bool ref
val opt_trace_taint : bool ref
val opt_trace_unexpected : bool ref
Expand Down
2 changes: 2 additions & 0 deletions execution/exec_set_options.ml
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ let cmdline_opts =
" Print symbolic memory regions");
("-trace-registers", Arg.Set(opt_trace_registers),
" Print register contents");
("-trace-register-updates", Arg.Set(opt_trace_register_updates),
" Print when registers are assigned to");
("-trace-setup", Arg.Set(opt_trace_setup),
" Print progress of program loading");
("-trace-stmts", Arg.Set(opt_trace_stmts),
Expand Down
14 changes: 13 additions & 1 deletion execution/fragment_machine.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2350,8 +2350,20 @@ struct
jump (self#eval_label_exp l2)
| V.Move(V.Temp((n,s,t) as v), e) ->
let rhs = self#eval_int_exp_simplify e in
let trace_eval () =
Printf.printf " %s <- %s\n" s (D.to_string_32 rhs)
in
if !opt_trace_eval then
Printf.printf " %s <- %s\n" s (D.to_string_32 rhs);
trace_eval ()
else if !opt_trace_register_updates then
if String.sub s 0 1 = "T" then
() (* skip updates to temps *)
else if String.length s = 4 &&
String.sub s 0 2 = "R_" &&
String.sub s 3 1 = "F" then
() (* skip updates to flags *)
else
trace_eval ();
self#set_int_var v rhs;
loop rest
| V.Move(V.Mem(memv, idx_e, ty), rhs_e) ->
Expand Down

0 comments on commit 6e2b309

Please sign in to comment.