dr_defines.h File Reference

Basic defines and type definitions. More...

#include <windows.h>
#include <winbase.h>
#include <stdarg.h>
#include <sys/types.h>
#include "dr_mcxtx.h"

Data Structures

struct  opnd_t
struct  instr_t
union  _dr_xmm_t
union  _dr_ymm_t
union  _dr_zmm_t
union  _dr_svep_t
struct  _dr_mcontext_t
struct  dr_time_t
struct  _dr_stats_t


#define MAXIMUM_PATH   260
#define STDOUT   (dr_get_stdout_file())
#define STDERR   (dr_get_stderr_file())
#define STDIN   (dr_get_stdin_file())
#define INVALID_FILE   -1
#define STDOUT   our_stdout
#define STDERR   our_stderr
#define STDIN   our_stdin
#define PFX   "%p"
#define PIFX   "0x" PIFMT
#define PIDFMT   SZFMT
#define TIDFMT   SZFMT
#define MCXT_NUM_SVEP_SLOTS   16
#define MCXT_NUM_FFR_SLOTS   1
#define PRE_SIMD_PADDING   0
#define DR_NOTE_FIRST_RESERVED   0xffffffffffff0000ULL


typedef size_t app_rva_t
typedef uint client_id_t
typedef union _dr_xmm_t dr_xmm_t
typedef union _dr_ymm_t dr_ymm_t
typedef union _dr_zmm_t dr_zmm_t
typedef uint64 dr_opmask_t
typedef union _dr_svep_t dr_svep_t
typedef dr_svep_t dr_ffr_t
typedef struct _dr_mcontext_t dr_mcontext_t
typedef struct _instrlist_t instrlist_t
typedef struct _module_data_t module_data_t
typedef struct _dr_stats_t dr_stats_t


enum  dr_mcontext_flags_t {
  DR_MC_INTEGER = 0x01,
  DR_MC_CONTROL = 0x02,
enum  {
enum  dr_error_code_t {
enum  dr_where_am_i_t {
enum  dr_cleancall_save_t {


union ALIGN_VAR (16) _dr_simd_t


file_t our_stdout
file_t our_stderr
file_t our_stdin

Detailed Description

Basic defines and type definitions.

Macro Definition Documentation


#define DR_NOTE_FIRST_RESERVED   0xffffffffffff0000ULL

Upper note values are reserved for core DR.



The sentinel value for an invalid file_t.


#define INVALID_FILE   -1

The sentinel value for an invalid file_t.


#define MAXIMUM_PATH   260

Maximum file path length define meant to replace platform-specific defines such as MAX_PATH and PATH_MAX. Currently, internal stack size limits prevent this from being much larger on UNIX.


#define MCXT_NUM_FFR_SLOTS   1

Number of first-fault register slots in dr_mcontext_t.



Number of 16-64-bit OpMask Kn slots in dr_mcontext_t, \ if architecture supports. \



Total number of SIMD register slots in dr_mcontext_t.



Number of 512-bit SIMD Vn/Zn slots in dr_mcontext_t. \


#define MCXT_NUM_SVEP_SLOTS   16

Number of SIMD Pn slots in dr_mcontext_t.


#define PFX   "%p"

printf format code for pointers


#define PIDFMT   SZFMT

printf format code for process_id_t


#define PIFX   "0x" PIFMT

printf format code for pointer-sized integers


#define PRE_SIMD_PADDING   0

Bytes of padding before xmm/ymm dr_mcontext_t slots. \

◆ STDERR [1/2]

#define STDERR   (dr_get_stderr_file())

The file_t value for standard error.

◆ STDERR [2/2]

#define STDERR   our_stderr

The file_t value for standard error.

◆ STDIN [1/2]

#define STDIN   (dr_get_stdin_file())

The file_t value for standard input.

The file_t value for standard error.

◆ STDIN [2/2]

#define STDIN   our_stdin

The file_t value for standard input.

The file_t value for standard error.

◆ STDOUT [1/2]

#define STDOUT   (dr_get_stdout_file())

The file_t value for standard output.

◆ STDOUT [2/2]

#define STDOUT   our_stdout

The file_t value for standard output.


#define TIDFMT   SZFMT

printf format code for thread_id_t

Typedef Documentation

◆ app_rva_t

typedef size_t app_rva_t

Application offset from module base. PE32+ modules are limited to 2GB, but not ELF x64 med/large code model.

◆ client_id_t

typedef uint client_id_t

ID used to uniquely identify a client. This value is set at client registration and passed to the client in dr_client_main().

◆ dr_ffr_t

64-bit Arm Scalable Vector Extension (SVE) First Fault Register (FFR). FFR is a special purpose predicate register used by some SVE instructions.

◆ dr_mcontext_t

typedef struct _dr_mcontext_t dr_mcontext_t

Machine context structure.

◆ dr_opmask_t

typedef uint64 dr_opmask_t

AVX-512 OpMask (k-)register.

◆ dr_stats_t

◆ dr_svep_t

typedef union _dr_svep_t dr_svep_t

64-bit Arm Scalable Vector Extension (SVE) predicate register Pn. SVE Pn registers are used to hold mask values that control the operation of some SVE instructions. Pn registers have one bit for every byte of a Zn register to the size of a Pn register is always 1/8 the size of a Zn register. DynamoRIO currently supports up to 512-bit Zn registers and 64-bit Pn registers.

◆ dr_xmm_t

typedef union _dr_xmm_t dr_xmm_t

128-bit XMM register.

◆ dr_ymm_t

typedef union _dr_ymm_t dr_ymm_t

256-bit YMM register.

◆ dr_zmm_t

typedef union _dr_zmm_t dr_zmm_t

512-bit ZMM register.

◆ instrlist_t

typedef struct _instrlist_t instrlist_t

The opaque type used to represent linear lists of instr_t instructions.

◆ module_data_t

typedef struct _module_data_t module_data_t

Alias for the _module_data_t structure holding library information.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Identifies an annotation point. This label will be replaced by a clean call to the registered annotation handler.


Identifies the end of a clean call.


Identifies a point at which clients should restore all registers to their application values, as required for DR's internal block mangling.


Used for internal translation from an instruction list. These apply not only to client-inserted clean calls but all inserted calls whether inserted by clients or DR and whether fully clean or not. This is thus distinct from DR_NOTE_CLEAN_CALL_END.


Placed at the top of a basic block, this identifies the entry to an "rseq" (Linux restartable sequence) region. The first two label data fields (see instr_get_label_data_area()) are filled in with this rseq region's end PC and its abort handler PC, in that order.

◆ dr_cleancall_save_t

Flags to request non-default preservation of state in a clean call as well as other call options. This is used with dr_insert_clean_call_ex(), dr_insert_clean_call_ex_varg(), and dr_register_clean_call_insertion_event().


Save legacy floating-point state (x86-specific; not saved by default). The last floating-point instruction address (FIP) in the saved state is left in an untranslated state (i.e., it may point into the code cache). This flag is orthogonal to the saving of SIMD registers and related flags below.


Skip saving the flags and skip clearing the flags (including DF) for client execution. Note that this can cause problems if dr_redirect_execution() is called from a clean call, as an uninitialized flags value can cause subtle errors.


Skip saving any XMM or YMM registers (saved by default).


Skip saving any XMM or YMM registers that are never used as parameters.


Skip saving any XMM or YMM registers that are never used as return values.


Requests that an indirect call be used to ensure reachability, both for reaching the callee and for any out-of-line helper routine calls. Only honored for 64-bit mode, where r11 will be used for the indirection.


Requests that out-of-line state save and restore routines be used even when a subset of the state does not need to be preserved for this callee. Also disables inlining. This helps guarantee that the inserted code remains small.


Indicates that the callee will access the application context (either as passed parameters or by calling dr_get_mcontext()). This flag is passed to callbacks registered with dr_register_clean_call_insertion_event() requesting that register reservation code in clients and libraries restore application values to all registers. Without this flag, register values observed by the callee may be values written by instrumentation rather than application values. If the intent is to have a mixture of application and tool values in registers, manual restoration is required rather than passing this automation flag.


Indicates that the callee will modify the application context (by calling dr_set_mcontext()). This flag is passed to callbacks registered with dr_register_clean_call_insertion_event() requesting that register reservation code in clients and libraries update spilled application register values. Without this flag, changes made by dr_set_mcontext() may be undone by later restores of spilled values.


Indicates that the clean call may be skipped by inserted tool control flow. This affects how register spilling and restoring occurs when combined with the DR_CLEANCALL_READS_APP_CONTEXT flag. Tool values may be clobbered when this flag is used. If control flow and clean call context access is used with registers holding tool values across the clean call, manual restoration may be required rather than passing any of these automated flags.

Combining this flag with DR_CLEANCALL_WRITES_APP_CONTEXT is not supported. Manual updates are required for such a combination.

◆ dr_error_code_t

Error codes of DR API routines.


Invalid parameter passed to the API routine.


Insufficient size of passed buffer.


String encoding is unknown.


Feature of API routine not yet implemented.

◆ dr_mcontext_flags_t

Values for the flags field of dr_mcontext_t


On x86, selects the xdi, xsi, xbp, xbx, xdx, xcx, xax, and r8-r15 fields (i.e., all of the general-purpose registers excluding xsp, xip, and xflags). On ARM, selects r0-r12 and r14. On AArch64, selects r0-r30.


On x86, selects the xsp, xflags, and xip fields. On ARM, selects the sp, pc, and cpsr fields. On AArch64, selects the sp, pc, and nzcv fields. On RISC-V, selects the sp, pc and fcsr fields.

: The xip/pc field is only honored as an input for dr_redirect_execution(), and as an output for system call events.

Selects the simd fields. This flag is ignored unless dr_mcontext_xmm_fields_valid() returns true. If dr_mcontext_xmm_fields_valid() returns false, the application values of the multimedia registers remain in the registers themselves.


Selects all fields

◆ dr_where_am_i_t

Identifies where a thread's control is at any one point. Used with client PC sampling using dr_set_itimer().


Control is in native application code.


Control is in basic block building.


Control is in d_r_dispatch.


Control is in trace building.


Control is in system call handling.


Control is in signal handling.


Control is in trampoline hooks.


Control is in context switching.


Control is in inlined indirect branch lookup.


Control is in the code cache.


Control is in a clean call.


Control is in an unknown location.


Equals the count of DR_WHERE_xxx locations.

Function Documentation


union ALIGN_VAR ( 16  )

512-bit ARM Scalable Vector Extension (SVE) vector registers Zn. Low 128 bits of Zn overlap with existing ARM Advanced SIMD (NEON) Vn registers. The SVE specification defines the following valid vector lengths: 128 256 384 512 640 768 896 1024 1152 1280 1408 1536 1664 1792 1920 2048 We currently support 512-bit maximum due to DR's stack size limitation, (machine context stored in the stack). In AArch64, align to 16 bytes for better performance. In AArch32, we're not using any uint64 fields here to avoid alignment padding in sensitive structs. We could alternatively use pragma pack.

< Byte (8 bit, Bn) scalar element of Vn, Zn, or Pn.

< Halfword (16 bit, Hn) scalar element of Vn, Zn and Pn.

< Singleword (32 bit, Sn) scalar element of Vn, Zn and Pn.

< Doubleword (64 bit, Dn) scalar element of Vn, Zn and Pn.

< The full 128 bit Vn register, Qn as q[3]:q[2]:q[1]:q[0].

< The full 512 bit Zn register as Singleword (32-bit) elements.

< The full 512 bit Zn register as Doubleword (64-bit) elements.

Variable Documentation

◆ our_stderr

file_t our_stderr

Allow use of stderr after the application closes it.

◆ our_stdin

file_t our_stdin

Allow use of stdin after the application closes it.

◆ our_stdout

file_t our_stdout

Allow use of stdout after the application closes it.