count_instructions

Crates.iocount_instructions
lib.rscount_instructions
version0.1.4
sourcesrc
created_at2023-06-08 23:19:09.165337
updated_at2023-07-03 23:32:41.572481
descriptionCounts the instructions executed within a single function
homepage
repositoryhttps://github.com/cesarb/count_instructions
max_upload_size
id885814
size35,746
Cesar Eduardo Barros (cesarb)

documentation

README

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.

Commit count: 16

cargo fmt