DynamoRIO API
dr_defines.h File Reference

Basic defines and type definitions. More...

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

Data Structures

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

Macros

#define MAXIMUM_PATH   260
 
#define INVALID_FILE   INVALID_HANDLE_VALUE
 
#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   "0x" PFMT
 
#define PIFX   "0x" PIFMT
 
#define PIDFMT   SZFMT
 
#define TIDFMT   SZFMT
 
#define NUM_SIMD_SLOTS   32
 
#define PRE_SIMD_PADDING   0
 
#define DR_NOTE_FIRST_RESERVED   0xfffffffffffffff0ULL
 

Typedefs

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 struct _dr_mcontext_t dr_mcontext_t
 
typedef struct _dr_stats_t dr_stats_t
 

Enumerations

enum  dr_mcontext_flags_t {
  DR_MC_INTEGER = 0x01,
  DR_MC_CONTROL = 0x02,
  DR_MC_MULTIMEDIA = 0x04,
  DR_MC_ALL = (DR_MC_INTEGER | DR_MC_CONTROL | DR_MC_MULTIMEDIA)
}
 
enum  dr_where_am_i_t {
  DR_WHERE_APP = 0,
  DR_WHERE_INTERP,
  DR_WHERE_DISPATCH,
  DR_WHERE_MONITOR,
  DR_WHERE_SYSCALL_HANDLER,
  DR_WHERE_SIGNAL_HANDLER,
  DR_WHERE_TRAMPOLINE,
  DR_WHERE_CONTEXT_SWITCH,
  DR_WHERE_IBL,
  DR_WHERE_FCACHE,
  DR_WHERE_CLEAN_CALLEE,
  DR_WHERE_UNKNOWN,
  DR_WHERE_LAST
}
 

Functions

union ALIGN_VAR (16) _dr_simd_t
 

Variables

file_t our_stdout
 
file_t our_stderr
 
file_t our_stdin
 

Detailed Description

Basic defines and type definitions.

Macro Definition Documentation

◆ DR_NOTE_FIRST_RESERVED

#define DR_NOTE_FIRST_RESERVED   0xfffffffffffffff0ULL

Upper note values are reserved for core DR.

◆ INVALID_FILE [1/2]

#define INVALID_FILE   INVALID_HANDLE_VALUE

The sentinel value for an invalid file_t.

◆ INVALID_FILE [2/2]

#define INVALID_FILE   -1

The sentinel value for an invalid file_t.

◆ MAXIMUM_PATH

#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.

◆ NUM_SIMD_SLOTS

#define NUM_SIMD_SLOTS   32

Number of 128-bit SIMD Vn slots in dr_mcontext_t \

◆ PFX

#define PFX   "0x" PFMT

printf format code for pointers

◆ PIDFMT

#define PIDFMT   SZFMT

printf format code for process_id_t

◆ PIFX

#define PIFX   "0x" PIFMT

printf format code for pointer-sized integers

◆ PRE_SIMD_PADDING

#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.

◆ TIDFMT

#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_mcontext_t

typedef struct _dr_mcontext_t dr_mcontext_t

Machine context structure.

◆ dr_stats_t

◆ 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.

Enumeration Type Documentation

◆ dr_mcontext_flags_t

Values for the flags field of dr_mcontext_t

Enumerator
DR_MC_INTEGER 

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.

DR_MC_CONTROL 

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.

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

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.

DR_MC_ALL 

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().

Enumerator
DR_WHERE_APP 

Control is in native application code.

DR_WHERE_INTERP 

Control is in basic block building.

DR_WHERE_DISPATCH 

Control is in dispatch.

DR_WHERE_MONITOR 

Control is in trace building.

DR_WHERE_SYSCALL_HANDLER 

Control is in system call handling.

DR_WHERE_SIGNAL_HANDLER 

Control is in signal handling.

DR_WHERE_TRAMPOLINE 

Control is in trampoline hooks.

DR_WHERE_CONTEXT_SWITCH 

Control is in context switching.

DR_WHERE_IBL 

Control is in inlined indirect branch lookup.

DR_WHERE_FCACHE 

Control is in the code cache.

DR_WHERE_CLEAN_CALLEE 

Control is in a clean call.

DR_WHERE_UNKNOWN 

Control is in an unknown location.

DR_WHERE_LAST 

Equals the count of DR_WHERE_xxx locations.

Function Documentation

◆ ALIGN_VAR()

union ALIGN_VAR ( 16  )

128-bit ARM SIMD Vn register. 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.

< Bottom 8 bits of Vn == Bn.

< Bottom 16 bits of Vn == Hn.

< Bottom 32 bits of Vn == Sn.

< Bottom 64 bits of Vn == Dn as d[1]:d[0].

< 128-bit Qn as q[3]:q[2]:q[1]:q[0].

< The full 128-bit register.

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.