5 releases

0.1.4 Jul 3, 2023
0.1.3 Jun 17, 2023
0.1.2 Jun 11, 2023
0.1.1 Jun 9, 2023
0.1.0 Jun 8, 2023

#394 in Operating systems

Download history 48/week @ 2024-07-22 41/week @ 2024-07-29 32/week @ 2024-08-05 25/week @ 2024-08-12 58/week @ 2024-08-19 57/week @ 2024-08-26 24/week @ 2024-09-02 31/week @ 2024-09-09 29/week @ 2024-09-16 45/week @ 2024-09-23 24/week @ 2024-09-30 33/week @ 2024-10-07 35/week @ 2024-10-14 17/week @ 2024-10-21 25/week @ 2024-10-28 18/week @ 2024-11-04

99 downloads per month
Used in constant_time_eq

MIT/Apache

21KB
396 lines

Counts the instructions executed within a single function.

When developing constant-time code, it can be helpful to validate that several executions of a given function have the same number of instructions, and that the same instructions were used.

The approach used by this crate is to single-step the function using the operating system debug API, optionally recording the address of each instruction. This is currently implemented only for Linux; for other operating systems, it will fail with an error.

Using the debug API to single-step the function has several drawbacks:

  • It can be very slow, especially when not compiled in release mode;
  • It cannot be used while another debugger is attached to the process;
  • Its use might be restricted by several system hardening mechanisms.

On the other hand, using the debug API has the advantage of tracing the real code executed by the CPU, as generated by the compiler, instead of symbolic execution of the source code, or emulation on another architecture.

License

Licensed under either of

at your option.

Dependencies

~1.5–9.5MB
~112K SLoC