static void check_cls_write_from_cache(void) { CHECK(drmgr_get_cls_field(dr_get_current_drcontext(), cls_idx) == (void *) MAGIC_NUMBER_FROM_CACHE, "cls write from cache incorrect"); /* now restore */ drmgr_set_cls_field(dr_get_current_drcontext(), cls_idx, (void *)(ptr_int_t)cb_depth); checked_cls_write_from_cache = true; }
static void event_thread_context_init(void *drcontext, bool new_depth) { /* create an instance of our data structure for this thread context */ per_thread_t *data; #ifdef SHOW_RESULTS dr_fprintf(STDERR, "new thread context id="TIDFMT"%s\n", dr_get_thread_id(drcontext), new_depth ? " new depth" : ""); #endif if (new_depth) { data = (per_thread_t *) dr_thread_alloc(drcontext, sizeof(per_thread_t)); drmgr_set_cls_field(drcontext, tcls_idx, data); } else data = (per_thread_t *) drmgr_get_cls_field(drcontext, tcls_idx); memset(data, 0, sizeof(*data)); }
static void event_thread_context_init(void *drcontext, bool new_depth) { if (dr_get_thread_id(drcontext) != main_thread) { cb_depth++; #if VERBOSE /* # cbs differs on xp vs win7 so not part of output */ dr_fprintf(STDERR, "non-main thread entering callback depth=%d\n", cb_depth); #endif CHECK(new_depth || drmgr_get_cls_field(drcontext, cls_idx) == (void *)(ptr_int_t)cb_depth, "not re-using prior callback value"); drmgr_set_cls_field(drcontext, cls_idx, (void *)(ptr_int_t)cb_depth); CHECK(drmgr_get_tls_field(drcontext, tls_idx) == (void *)(ptr_int_t)dr_get_thread_id(drcontext), "tls not preserved"); } }
static void event_thread_context_init(void *drcontext, bool new_depth) { /* create an instance of our data structure for this thread context */ per_thread_t *data; if (new_depth) { data = (per_thread_t *) dr_thread_alloc(drcontext, sizeof(per_thread_t)); drmgr_set_cls_field(drcontext, cls_idx, data); } else data = (per_thread_t *) drmgr_get_cls_field(drcontext, cls_idx); memset(data, 0, sizeof(*data)); /* test self-nudge to make up for lack of nudge_test on windows (waiting * for runall support (i#120) */ if (!sent_self) { sent_self = true; if (!dr_nudge_client(client_id, NUDGE_ARG_SELF)) dr_fprintf(STDERR, "self nudge failed"); } }