HPCToolkit
x86-process-ranges.cpp File Reference
#include <stdio.h>
#include <assert.h>
#include <string>
#include <include/hpctoolkit-config.h>
#include <xed-interface.h>
#include "code-ranges.h"
#include "function-entries.h"
#include "process-ranges.h"
#include <lib/isa-lean/x86/instruction-set.h>
Include dependency graph for x86-process-ranges.cpp:

Go to the source code of this file.

Macros

#define RELOCATE(u, offset)   (((char *) (u)) - (offset))
 
#define SAVE_REL_OFFSET(offset)
 
#define KILL_REL_OFFSET()
 

Functions

xed_iclass_enum_t xed_iclass (char *ins)
 
static void process_call (char *ins, long offset, xed_decoded_inst_t *xptr, void *start, void *end)
 
static bool is_push_bp (char *ins)
 
static bool is_sub_immed_sp (char *ins, char **next)
 
static bool is_2step_push_bp (char *ins)
 
static bool contains_bp_save (char *ins)
 
static bool is_push_bp_seq (char *ins)
 
static void process_branch (char *ins, long offset, xed_decoded_inst_t *xptr, char *vstart, char *vend)
 
static void after_unconditional (char *ins, long offset, xed_decoded_inst_t *xptr)
 
static bool invalid_routine_start (unsigned char *ins)
 
static void addsub (char *ins, xed_decoded_inst_t *xptr, xed_iclass_enum_t iclass, long ins_offset)
 
static void process_move (char *ins, xed_decoded_inst_t *xptr, long ins_offset)
 
static void process_push (char *ins, xed_decoded_inst_t *xptr, long ins_offset)
 
static void process_pop (char *ins, xed_decoded_inst_t *xptr, long ins_offset)
 
static void process_enter (char *ins, long ins_offset)
 
static void process_leave (char *ins, long ins_offset)
 
static bool bkwd_jump_into_protected_range (char *ins, long offset, xed_decoded_inst_t *xptr)
 
static bool validate_tail_call_from_jump (char *ins, long offset, xed_decoded_inst_t *xptr)
 
static bool nextins_looks_like_fn_start (char *ins, long offset, xed_decoded_inst_t *xptrin)
 
static bool lea_has_zero_offset (xed_decoded_inst_t *xptr)
 
void process_range_init ()
 
void process_range (const char *name, long offset, void *vstart, void *vend, DiscoverFnTy fn_discovery)
 
static int is_padding (int c)
 
static bool skip_padding (unsigned char **ins)
 
static void * get_branch_target (char *ins, xed_decoded_inst_t *xptr, xed_operand_values_t *vals)
 
static bool contains_bp_save_window (char *ins, size_t window)
 
static bool is_sub_immed_prologue (char *ins)
 
bool range_contains_control_flow (void *vstart, void *vend)
 
static char * xed_next (char *ins)
 
static bool is_mov_sp_2_bp (char *ins)
 
static bool ins_seq_is_std_frame (char *ins)
 
static bool ins_seq_has_reg_move_to_bp (char *ins)
 
static bool ins_seq_is_common_frameless_proc (char *ins)
 
static int mem_below_rsp_or_rbp (xed_decoded_inst_t *xptr, int oindex)
 
static bool inst_accesses_callers_mem (xed_decoded_inst_t *xptr)
 
static bool from_ax_reg (xed_decoded_inst_t *xptr)
 
static bool is_null (unsigned char *ins, int n)
 
static bool is_breakpoint (xed_decoded_inst_t *xptr)
 
void x86_dump_ins (void *ins)
 

Variables

static xed_state_t dbg_xed_machine_state
 
static xed_state_t xed_machine_state
 
static char * prologue_start = NULL
 
static char * set_rbp = NULL
 
static char * push_rbp = NULL
 
static char * push_other = NULL
 
static char * last_bad = NULL
 
static xed_reg_enum_t push_other_reg
 
static const size_t WINDOW = 16
 
static const size_t FRAMELESS_PROC_WINDOW = 8
 

Macro Definition Documentation

◆ KILL_REL_OFFSET

#define KILL_REL_OFFSET ( )

Definition at line 209 of file x86-process-ranges.cpp.

◆ RELOCATE

#define RELOCATE (   u,
  offset 
)    (((char *) (u)) - (offset))

Definition at line 157 of file x86-process-ranges.cpp.

◆ SAVE_REL_OFFSET

#define SAVE_REL_OFFSET (   offset)

Definition at line 208 of file x86-process-ranges.cpp.

Function Documentation

◆ addsub()

static void addsub ( char *  ins,
xed_decoded_inst_t *  xptr,
xed_iclass_enum_t  iclass,
long  ins_offset 
)
static

Definition at line 1351 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ after_unconditional()

static void after_unconditional ( char *  ins,
long  offset,
xed_decoded_inst_t *  xptr 
)
static

Definition at line 479 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bkwd_jump_into_protected_range()

static bool bkwd_jump_into_protected_range ( char *  ins,
long  offset,
xed_decoded_inst_t *  xptr 
)
static

Definition at line 774 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains_bp_save()

static bool contains_bp_save ( char *  ins)
static

Definition at line 640 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains_bp_save_window()

static bool contains_bp_save_window ( char *  ins,
size_t  window 
)
static

Definition at line 600 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ from_ax_reg()

static bool from_ax_reg ( xed_decoded_inst_t *  xptr)
static

Definition at line 1252 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ get_branch_target()

static void* get_branch_target ( char *  ins,
xed_decoded_inst_t *  xptr,
xed_operand_values_t *  vals 
)
static

Definition at line 517 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ ins_seq_has_reg_move_to_bp()

static bool ins_seq_has_reg_move_to_bp ( char *  ins)
static

Definition at line 1032 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ ins_seq_is_common_frameless_proc()

static bool ins_seq_is_common_frameless_proc ( char *  ins)
static

Definition at line 1079 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ins_seq_is_std_frame()

static bool ins_seq_is_std_frame ( char *  ins)
static

Definition at line 1024 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inst_accesses_callers_mem()

static bool inst_accesses_callers_mem ( xed_decoded_inst_t *  xptr)
static

Definition at line 1230 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invalid_routine_start()

static bool invalid_routine_start ( unsigned char *  ins)
static

Definition at line 1309 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_2step_push_bp()

static bool is_2step_push_bp ( char *  ins)
static

Definition at line 701 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_breakpoint()

static bool is_breakpoint ( xed_decoded_inst_t *  xptr)
static

Definition at line 1294 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ is_mov_sp_2_bp()

static bool is_mov_sp_2_bp ( char *  ins)
static

Definition at line 990 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ is_null()

static bool is_null ( unsigned char *  ins,
int  n 
)
static

Definition at line 1284 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ is_padding()

static int is_padding ( int  c)
static

Definition at line 430 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ is_push_bp()

static bool is_push_bp ( char *  ins)
static

Definition at line 547 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ is_push_bp_seq()

static bool is_push_bp_seq ( char *  ins)
static

Definition at line 711 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_sub_immed_prologue()

static bool is_sub_immed_prologue ( char *  ins)
static

Definition at line 691 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_sub_immed_sp()

static bool is_sub_immed_sp ( char *  ins,
char **  next 
)
static

Definition at line 650 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ lea_has_zero_offset()

static bool lea_has_zero_offset ( xed_decoded_inst_t *  xptr)
static

Definition at line 956 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ mem_below_rsp_or_rbp()

static int mem_below_rsp_or_rbp ( xed_decoded_inst_t *  xptr,
int  oindex 
)
static

Definition at line 1212 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ nextins_looks_like_fn_start()

static bool nextins_looks_like_fn_start ( char *  ins,
long  offset,
xed_decoded_inst_t *  xptrin 
)
static

Definition at line 1085 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_branch()

static void process_branch ( char *  ins,
long  offset,
xed_decoded_inst_t *  xptr,
char *  vstart,
char *  vend 
)
static

Definition at line 1160 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_call()

static void process_call ( char *  ins,
long  offset,
xed_decoded_inst_t *  xptr,
void *  start,
void *  end 
)
static

Definition at line 720 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_enter()

static void process_enter ( char *  ins,
long  ins_offset 
)
static

Definition at line 1490 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ process_leave()

static void process_leave ( char *  ins,
long  ins_offset 
)
static

Definition at line 1497 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_move()

static void process_move ( char *  ins,
xed_decoded_inst_t *  xptr,
long  ins_offset 
)
static

Definition at line 1400 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ process_pop()

static void process_pop ( char *  ins,
xed_decoded_inst_t *  xptr,
long  ins_offset 
)
static

Definition at line 1453 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_push()

static void process_push ( char *  ins,
xed_decoded_inst_t *  xptr,
long  ins_offset 
)
static

Definition at line 1426 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_range()

void process_range ( const char *  name,
long  offset,
void *  vstart,
void *  vend,
DiscoverFnTy  fn_discovery 
)

Definition at line 228 of file x86-process-ranges.cpp.

Here is the call graph for this function:

◆ process_range_init()

void process_range_init ( void  )

Definition at line 221 of file x86-process-ranges.cpp.

◆ range_contains_control_flow()

bool range_contains_control_flow ( void *  vstart,
void *  vend 
)

Definition at line 810 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

◆ skip_padding()

static bool skip_padding ( unsigned char **  ins)
static

Definition at line 436 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_tail_call_from_jump()

static bool validate_tail_call_from_jump ( char *  ins,
long  offset,
xed_decoded_inst_t *  xptr 
)
static

Definition at line 857 of file x86-process-ranges.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ x86_dump_ins()

void x86_dump_ins ( void *  ins)

Definition at line 1328 of file x86-process-ranges.cpp.

◆ xed_iclass()

xed_iclass_enum_t xed_iclass ( char *  ins)

Definition at line 82 of file x86-process-ranges.cpp.

Here is the call graph for this function:

◆ xed_next()

static char* xed_next ( char *  ins)
static

Definition at line 972 of file x86-process-ranges.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ dbg_xed_machine_state

xed_state_t dbg_xed_machine_state
static
Initial value:
=
{ XED_MACHINE_MODE_LONG_COMPAT_32,
XED_ADDRESS_WIDTH_32b }

Definition at line 72 of file x86-process-ranges.cpp.

◆ FRAMELESS_PROC_WINDOW

const size_t FRAMELESS_PROC_WINDOW = 8
static

Definition at line 1029 of file x86-process-ranges.cpp.

◆ last_bad

char* last_bad = NULL
static

Definition at line 177 of file x86-process-ranges.cpp.

◆ prologue_start

char* prologue_start = NULL
static

Definition at line 173 of file x86-process-ranges.cpp.

◆ push_other

char* push_other = NULL
static

Definition at line 176 of file x86-process-ranges.cpp.

◆ push_other_reg

xed_reg_enum_t push_other_reg
static

Definition at line 178 of file x86-process-ranges.cpp.

◆ push_rbp

char* push_rbp = NULL
static

Definition at line 175 of file x86-process-ranges.cpp.

◆ set_rbp

char* set_rbp = NULL
static

Definition at line 174 of file x86-process-ranges.cpp.

◆ WINDOW

const size_t WINDOW = 16
static

Definition at line 595 of file x86-process-ranges.cpp.

◆ xed_machine_state

xed_state_t xed_machine_state
static
Initial value:
=
{ XED_MACHINE_MODE_LONG_COMPAT_32,
XED_ADDRESS_WIDTH_32b }

Definition at line 164 of file x86-process-ranges.cpp.