dr_emit_flags_t handle_bb(void* ctx, void* tag, instrlist_t* bb, bool for_trace, bool translating) { bool new_frag; bool instrument; #ifdef TRACE_DEBUG dr_fprintf(STDERR, "debug: handle_bb(tag=%p, for_trace=%u, translating=%u)\n", tag, for_trace, translating); #endif check_ctx(ctx, "handle_bb"); new_frag = true; instrument = true; if(for_trace) { // Traces are instrumented separately, we only need to increment counter. new_frag = false; instrument = false; } if(translating) { // Reuse existing fragment when translating. new_frag = false; } handle_frag(ctx, tag, bb, new_frag, instrument, 0); return DR_EMIT_DEFAULT; }
void handle_thread_exit(void* ctx) { thread_id_t thread_id; struct trace_buffer_t* tb; check_ctx(ctx, "handle_thread_exit"); thread_id = dr_get_thread_id(ctx); dr_fprintf(STDERR, "info: cleaning up thread 0x%" PRIx64 "..\n", (uint64_t)thread_id); tb = dr_get_tls_field(ctx); tb_delete(tb); dr_set_tls_field(ctx, NULL); }
void handle_thread_init(void* ctx) { thread_id_t thread_id; struct trace_buffer_t* tb; check_ctx(ctx, "handle_thread_init"); thread_id = dr_get_thread_id(ctx); dr_fprintf(STDERR, "info: initializing thread 0x%" PRIx64 "..\n", (uint64_t)thread_id); tb = tb_create(thread_id); dr_set_tls_field(ctx, tb); tb_tlv(tb, TYPE_TRACE); }
dr_emit_flags_t handle_trace(void* ctx, void* tag, instrlist_t* trace, bool translating) { #ifdef TRACE_DEBUG dr_fprintf(STDERR, "debug: handle_trace(tag=%p, translating=%u)\n", tag, translating); #endif check_ctx(ctx, "handle_trace"); handle_frag(ctx, tag, trace, !translating, true, FRAG_ID_MSB); return DR_EMIT_DEFAULT; }
static enum clnt_stat nfs3_call(int proc, void *arg, xdrproc_t xdr_proc, nfs_ctx *ctx, user_cb u_cb, void * priv, int64_t callflag) { int sockp = RPC_ANYSOCK; int flag = 1; struct callback_info cbi; struct rpc_proc_info rpc; if(!check_ctx(ctx)) return RPC_SYSTEMERROR; if(ctx->nfs_cl == NULL) { if(ctx->nfs_connflags & NFSC_CFL_NONBLOCKING) ctx->nfs_cl = clnttcp_nb_create(ctx->nfs_srv, NFS_PROGRAM, NFS_V3, &sockp, ctx->nfs_wsize, ctx->nfs_rsize); else ctx->nfs_cl = clnttcp_b_create(ctx->nfs_srv, NFS_PROGRAM, NFS_V3, &sockp, ctx->nfs_wsize, ctx->nfs_rsize); if(ctx->nfs_connflags & NFSC_CFL_DISABLE_NAGLE) setsockopt(sockp, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag)); } if(ctx->nfs_cl == NULL) return RPC_SYSTEMERROR; cbi.callback = u_cb; cbi.cb_private = priv; rpc.proc = proc; rpc.inproc = xdr_proc; rpc.inargs = (caddr_t)arg; return clnttcp_nb_call(ctx->nfs_cl, rpc, cbi, callflag); }