Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/dev/kinst/amd64/kinst_isa.c
Show All 11 Lines | |||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <sys/dtrace.h> | #include <sys/dtrace.h> | ||||
#include <cddl/dev/dtrace/dtrace_cddl.h> | #include <cddl/dev/dtrace/dtrace_cddl.h> | ||||
#include <dis_tables.h> | #include <dis_tables.h> | ||||
#include "kinst.h" | #include "kinst.h" | ||||
#define KINST_PUSHL_RBP 0x55 | |||||
#define KINST_STI 0xfb | #define KINST_STI 0xfb | ||||
#define KINST_POPF 0x9d | #define KINST_POPF 0x9d | ||||
#define KINST_MODRM_MOD(b) (((b) & 0xc0) >> 6) | #define KINST_MODRM_MOD(b) (((b) & 0xc0) >> 6) | ||||
#define KINST_MODRM_REG(b) (((b) & 0x38) >> 3) | #define KINST_MODRM_REG(b) (((b) & 0x38) >> 3) | ||||
#define KINST_MODRM_RM(b) ((b) & 0x07) | #define KINST_MODRM_RM(b) ((b) & 0x07) | ||||
#define KINST_SIB_SCALE(s) (((s) & 0xc0) >> 6) | #define KINST_SIB_SCALE(s) (((s) & 0xc0) >> 6) | ||||
▲ Show 20 Lines • Show All 478 Lines • ▼ Show 20 Lines | kinst_make_probe(linker_file_t lf, int symindx, linker_symval_t *symval, | ||||
struct kinst_probe *kp; | struct kinst_probe *kp; | ||||
dtrace_kinst_probedesc_t *pd; | dtrace_kinst_probedesc_t *pd; | ||||
const char *func; | const char *func; | ||||
int error, instrsize, n, off; | int error, instrsize, n, off; | ||||
uint8_t *instr, *limit; | uint8_t *instr, *limit; | ||||
pd = opaque; | pd = opaque; | ||||
func = symval->name; | func = symval->name; | ||||
if (strcmp(func, pd->kpd_func) != 0 || strcmp(func, "trap_check") == 0) | |||||
if (kinst_excluded(func)) | |||||
return (0); | return (0); | ||||
if (strcmp(func, pd->kpd_func) != 0) | |||||
return (0); | |||||
instr = (uint8_t *)symval->value; | instr = (uint8_t *)symval->value; | ||||
limit = (uint8_t *)symval->value + symval->size; | limit = (uint8_t *)symval->value + symval->size; | ||||
if (instr >= limit) | if (instr >= limit) | ||||
return (0); | |||||
/* | |||||
* Ignore functions not beginning with the usual function prologue. | |||||
* These might correspond to exception handlers with which we should not | |||||
* meddle. This does however exclude functions which can be safely | |||||
* traced, such as cpu_switch(). | |||||
*/ | |||||
if (*instr != KINST_PUSHL_RBP) | |||||
return (0); | return (0); | ||||
n = 0; | n = 0; | ||||
while (instr < limit) { | while (instr < limit) { | ||||
instrsize = dtrace_instr_size(instr); | instrsize = dtrace_instr_size(instr); | ||||
off = (int)(instr - (uint8_t *)symval->value); | off = (int)(instr - (uint8_t *)symval->value); | ||||
if (pd->kpd_off != -1 && off != pd->kpd_off) { | if (pd->kpd_off != -1 && off != pd->kpd_off) { | ||||
instr += instrsize; | instr += instrsize; | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |