39 #define NP_ARGP_TTCTX 30000
40 #define NP_ARGP_TTDETAIL 30001
43 {
"np-mode",
'N',
"[mprotect[,mmap[,pgfault]]]",0,
"Set the mode for the NULL page usage detector. mprotect is probably the cheapest option, because it is called less frequently than mmap, and must always be called to change protections for an mmap'd page (?). The pgfault style will be most expensive. To achieve certain, good coverage, choose all three!",0 },
44 {
"ttctx",
NP_ARGP_TTCTX,
"none|self|hier|all (default self)",0,
"Which threads to display when an event happens.",0 },
45 {
"ttdetail",
NP_ARGP_TTDETAIL,
"-2|-1|0|1|2 (default 0)",0,
"How much info to print for each thread that is printed.",0 },
59 return ARGP_ERR_UNKNOWN;
61 return ARGP_ERR_UNKNOWN;
66 case ARGP_KEY_NO_ARGS:
67 case ARGP_KEY_SUCCESS:
73 if (strcmp(arg,
"none") == 0)
75 else if (strcmp(arg,
"self") == 0)
77 else if (strcmp(arg,
"hier") == 0)
79 else if (strcmp(arg,
"all") == 0)
82 verror(
"invalid ttctx %s!\n",arg);
96 if (strncmp(
"mmap",argptr,strlen(
"mmap")) == 0)
98 else if (strncmp(
"mprotect",argptr,strlen(
"mprotect")) == 0)
100 else if (strncmp(
"pgfault",argptr,strlen(
"pgfault")) == 0)
103 verror(
"bad nullpage flag spec!\n");
106 }
while ((argptr = index(argptr,
',')) != NULL && *++argptr !=
'\0');
109 return ARGP_ERR_UNKNOWN;
158 #define NP_PROT_READ 0x1
159 #define NP_PROT_WRITE 0x2
160 #define NP_PROT_EXEC 0x4
162 #define NP_MAP_FIXED 0x10
165 struct probe *trigger,
struct probe *base) {
170 struct value *va,*vf;
179 vwarn(
"could not load sys_mmap.addr!");
185 vwarn(
"could not load sys_mmap.vm_flags!");
193 vdebug(3,
LA_USER,1,
"NULLPAGE: tid %d tried to mmap at 0x0!\n",tid);
214 struct probe *trigger,
struct probe *base) {
219 struct value *va,*vp;
228 vwarn(
"could not load sys_mprotect.start!");
234 vwarn(
"could not load sys_mprotect.prot!");
243 vdebug(3,
LA_USER,1,
"NULLPAGE: tid %d tried to mprotect(0x0,%d)!\n",
265 struct probe *trigger,
struct probe *base) {
280 vwarn(
"could not load do_page_fault.error_code!");
311 vdebug(3,
LA_USER,1,
"NULLPAGE: tid %d tried to access(0x0) (0x%x!\n",
312 tid,(
int)error_code);
319 tid,addr,(
unsigned long)error_code);
343 snprintf(namebuf,64,
"nullpage(target %d)",target->
id);
366 verror(
"could not register function entry/exit probe on %s;"
371 verror(
"could not register nullpage meta probe %s atop probe %s!\n",
388 verror(
"could not register function entry/exit probe on %s;"
393 verror(
"could not register nullpage meta probe %s atop probe %s!\n",
410 verror(
"could not register function entry/exit probe on %s;"
415 verror(
"could not register nullpage master probe %s atop probe %s!\n",
result_t pre_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
struct probe * mmap_probe
void * target_argp_driver_state(struct argp_state *state)
struct argp_option np_argp_opts[]
unsigned int pgfault_violations
result_t np_mmap_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
struct bsymbol * target_lookup_sym(struct target *target, const char *name, const char *delim, char *srcfile, symbol_type_flag_t ftype)
result_t np_mprotect_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
struct target_location_ctxt * target_location_ctxt_create_from_bsymbol(struct target *target, tid_t tid, struct bsymbol *bsymbol)
int probe_fini_np(struct probe *probe)
result_t probe_do_sink_post_handlers(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
char * bsymbol_get_name(struct bsymbol *bsymbol)
struct probe * pgfault_probe
#define verror(format,...)
result_t probe_do_sink_pre_handlers(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
const char *(* gettype)(struct probe *probe)
result_t(* probe_handler_t)(struct probe *probe, tid_t tid, void *handler_data, struct probe *trigger, struct probe *base)
#define vwarn(format,...)
REGVAL target_read_reg(struct target *target, tid_t tid, REG reg)
struct probe * probe_np(struct target *target, struct np_config *npc, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
struct probe * probe_register_source(struct probe *sink, struct probe *src)
REFCNT bsymbol_release(struct bsymbol *bsymbol)
unsigned int mmap_violations
int probe_free(struct probe *probe, int force)
struct dt_argp_state opts
error_t np_argp_parse_opt(int key, char *arg, struct argp_state *state)
void value_free(struct value *value)
result_t np_pgfault_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
unsigned int mprotect_violations
struct probe * probe_create(struct target *target, tid_t tid, struct probe_ops *pops, const char *name, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data, int autofree, int tracked)
struct np_config * config
#define vdebug(devel, areas, flags, format,...)
ADDR v_addr(struct value *v)
void * calloc(size_t nmemb, size_t size)
result_t post_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
struct probe * mprotect_probe
unsigned int total_violations
struct value * target_load_symbol_member(struct target *target, struct target_location_ctxt *tlctxt, struct bsymbol *bsymbol, const char *member, const char *delim, load_flags_t flags)
void * probe_summarize_np(struct probe *probe)
void target_location_ctxt_free(struct target_location_ctxt *tlctxt)
const char * probe_gettype_np(struct probe *probe)
char * probe_name(struct probe *probe)
struct probe * probe_register_symbol(struct probe *probe, struct bsymbol *bsymbol, probepoint_style_t style, probepoint_whence_t whence, probepoint_watchsize_t watchsize)
unum_t v_unum(struct value *v)
void target_driver_argp_init_children(struct argp_state *state)