|
DynamoRIO
|
DrPoints is a DynamoRIO client that computes Basic Block Vectors (BBV) for a program execution. These vectors represent the execution frequency of basic blocks within fixed-size instruction intervals, which are commonly used for phase analysis and as input for tools like SimPoint Toolkit.
Usage
To run DrPoints, use the -t drpoints option with drrun. For example:
The tool will generate a .bbv file in the current directory. You can customize the behavior using several options:
- -instr_interval <size>: Specifies the instruction interval size (default is 100,000,000 instructions). This value divides the program execution into instruction intervals of the specified size. Example:
-instr_interval50000000 - -out_bbv_file <path>: Specifies the output path for the
.bbv file. By default, the file is nameddrpoints.BINARY_NAME.PID.UNIQUE_ID.bbvand saved in the current directory. Example:-out_bbv_filemyapp.bbv - -no_out_bbv_file: Disables the generation of the output
.bbv file, but still runs the client. This is useful for testing or when only stdout output is desired. Default is false. - -print_to_stdout: Prints the BBVs to standard output in addition to the file. Default is false.
- -save_bbv_every <intervals>: Frequency (in number of instruction intervals) at which to write BBVs to the output and clear them from memory (default is 100). This is useful for long-running programs to avoid high memory consumption. A value of 0 keeps all BBVs in memory until the program exits. Example:
-save_bbv_every50
BBV Output Format
The output file follows the format expected by SimPoint Toolkit 3.2. Each line represents an instruction interval and starts with a "T" separator, followed by pairs of basic block IDs and their weighted frequencies:
- BB_id: A unique, 1-indexed identifier for each basic block.
- count: The number of times the basic block was executed in the interval multiplied by the number of instructions in that basic block.
Basic Block Definition
It is important to note that DynamoRIO's definition of a basic block differs from a traditional, static compiler definition. DynamoRIO constructs dynamic basic blocks as it encounters code during execution. A traditional compiler's basic block is a sequence of instructions with a single entry point and a single exit point. In contrast, DynamoRIO does not know all entry points ahead of time. This can lead to tail duplication if a later entry point is discovered that targets the middle of an existing basic block, or if straight-line code falls through into code already present in a block; in such cases, DynamoRIO will create a new basic block that duplicates the tail of the original block. Consequently, a single static basic block in the original binary might be represented by multiple dynamic basic blocks in DrPoints, and some instructions may appear in multiple dynamic blocks due to tail duplication.
Limitations
Currently, DrPoints has the following limitations:
- Multi-threading: The tool does not support multi-threaded applications. It will abort when it detects more than one thread.
- Architectures: Efficient inlined counter updates are currently implemented for x86_64 and AArch64. Other architectures default to a slower clean call implementation.