57 char *tprefix,
char *tsep) {
68 else if (ttctx == 1) {
70 ttdetail,sep,kvsep) < 0)
71 fprintf(stream,
"%s[tid=%"PRIiTID"",tprefix,tid);
73 fprintf(stream,
"%s[%s",tprefix,buf);
78 fprintf(stream,
"%sbacktrace=[error!]",sep);
80 fprintf(stream,
"%sbacktrace=[empty]",sep);
82 fprintf(stream,
"%sbacktrace=[%s]",sep,buf);
86 else if (ttctx == 2) {
91 fprintf(stream,
"%s",tsep);
94 ttdetail,sep,kvsep) < 0)
95 fprintf(stream,
"%s[tid=%"PRIiTID"",tprefix,tthread->
tid);
97 fprintf(stream,
"%s[%s",tprefix,buf);
104 fprintf(stream,
"%sbacktrace=[error!]",sep);
106 fprintf(stream,
"%sbacktrace=[empty]",sep);
108 fprintf(stream,
"%sbacktrace=[%s]",sep,buf);
117 else if (ttctx == 3) {
119 ttdetail,sep,kvsep) < 0)
120 fprintf(stream,
"%s[tid=%"PRIiTID"",tprefix,tid);
122 fprintf(stream,
"%s[%s",tprefix,buf);
132 if (tthread->
tid == tid)
135 fprintf(stream,
"%s",tsep);
138 ttdetail,sep,kvsep) < 0)
139 fprintf(stream,
"%s[tid=%"PRIiTID"",tprefix,tthread->
tid);
141 fprintf(stream,
"%s[%s",tprefix,buf);
148 fprintf(stream,
"%sbacktrace=[error!]",sep);
150 fprintf(stream,
"%sbacktrace=[empty]",sep);
152 fprintf(stream,
"%sbacktrace=[%s]",sep,buf);
160 struct probe *trigger,
struct probe *base) {
165 "RESULT:: (i:%d) np (30) NullPageUsageMmap"
166 " \"NULL Page Usage (mmap)!\""
167 " (mmap_violations=%d,",
172 "RESULT:: (i:%d) np (31) NullPageUsageMprotect"
173 " \"NULL Page Usage (mprotect)!\""
174 " (mprotect_violations=%d,",
179 "RESULT:: (i:%d) np (32) NullPageUsagePageFault"
180 " \"NULL Page Usage (Page Fault)!\""
181 " (mmap_violations=%d,",
185 vwarn(
"trigger was not valid!? BUG!?\n");
191 1,
";",
":",
"thread=",
",");
192 fputs(
") ::RESULT\n",stdout);
202 int main(
int argc,
char **argv) {
213 memset(&
npc,0,
sizeof(
npc));
221 verror(
"could not parse target arguments!\n");
227 verror(
"could not instantiate target!\n");
233 fprintf(stderr,
"could not open %s!\n",targetstr);
240 verror(
"could not instantiate the null page usage meta-probe; aborting!\n");
252 fprintf(stdout,
"Starting Null Page Usage monitoring!\n");
264 verror(
"could not resume target\n");
274 fprintf(stdout,
"target %s exiting, printing final results...\n",
279 fprintf(stdout,
"target %s exiting, removing probes safely...\n",
287 verror(
"could not resume target!\n");
297 fprintf(stdout,
"target %s exited, printing final results...\n",
306 fprintf(stdout,
"target %s exited, cleaning up.\n",targetstr);
318 " -- bad status (%d), printing final results...\n",
330 " -- bad status (%d), exiting\n",
int target_thread_snprintf(struct target *target, tid_t tid, char *buf, int bufsiz, int detail, char *sep, char *kvsep)
result_t np_handler(struct probe *probe, tid_t tid, void *data, struct probe *trigger, struct probe *base)
unsigned int pgfault_violations
int target_unwind_snprintf(char *buf, int buflen, struct target *target, tid_t tid, target_unwind_style_t fstyle, char *frame_sep, char *ksep)
struct target_spec * tspec
static uint64_t unsigned int i
void print_thread_context(FILE *stream, struct target *target, tid_t tid, int ttctx, int ttdetail, int bt, char *sep, char *kvsep, char *tprefix, char *tsep)
int target_resume(struct target *target)
void np_check_print_final_results(struct probe *probe)
#define NP_IS_MPROTECT(trigger, nps)
int target_pause(struct target *target)
#define NP_IS_MMAP(trigger, nps)
int main(int argc, char **argv)
#define verror(format,...)
int target_install_default_sighandlers(void(*sighandler)(int signo, siginfo_t *siginfo, void *x))
#define vwarn(format,...)
int target_snprintf(struct target *target, char *buf, int bufsiz)
#define array_list_foreach(alist, lpc, placeholder)
void target_default_cleanup()
unsigned int mmap_violations
int probe_free(struct probe *probe, int force)
void * probe_priv(struct probe *probe)
unsigned int mprotect_violations
void sigh_cleanup_probes(int signo, siginfo_t *siginfo, void *x)
REGVAL target_read_creg(struct target *target, tid_t tid, common_reg_t reg)
struct np_config * config
#define NP_IS_PGFAULT(trigger, nps)
struct array_list * target_list_available_tids(struct target *target)
struct probe * probe_np(struct target *target, struct np_config *npc, probe_handler_t pre_handler, probe_handler_t post_handler, void *handler_data)
int target_open(struct target *target)
target_status_t target_monitor(struct target *target)
unsigned int total_violations
struct target_spec * target_argp_driver_parse_one(struct argp *driver_parser, void *driver_state, int argc, char **argv, target_type_t target_types, int filter_quoted)
struct target * target_instantiate(struct target_spec *spec, struct evloop *evloop)
struct target_thread * target_lookup_thread(struct target *target, tid_t tid)