当前位置: 首页>>代码示例>>C++>>正文


C++ dr_mutex_lock函数代码示例

本文整理汇总了C++中dr_mutex_lock函数的典型用法代码示例。如果您正苦于以下问题:C++ dr_mutex_lock函数的具体用法?C++ dr_mutex_lock怎么用?C++ dr_mutex_lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dr_mutex_lock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: event_basic_block

static dr_emit_flags_t
event_basic_block(void *drcontext, void *tag, instrlist_t *bb, bool for_trace, bool translating)
{
    instr_t *instr;
    trace_head_entry_t *e = NULL;
    if (translating)
        return DR_EMIT_DEFAULT;
    for (instr = instrlist_first(bb); instr != NULL; instr = instr_get_next(instr)) {
        /* blocks containing calls are trace heads */
        if (instr_is_call(instr)) {
            dr_mark_trace_head(drcontext, tag);
            dr_mutex_lock(htable_mutex);
            e = add_trace_head_entry(NULL, tag);
            e->is_trace_head = true;
            dr_mutex_unlock(htable_mutex);
#ifdef VERBOSE
            dr_log(drcontext, LOG_ALL, 3,
                   "inline: marking bb "PFX" as trace head\n", tag);
#endif
            /* doesn't matter what's in rest of bb */
            return DR_EMIT_DEFAULT;
        } else if (instr_is_return(instr)) {
            dr_mutex_lock(htable_mutex);
            e = add_trace_head_entry(NULL, tag);
            e->has_ret = true;
            dr_mutex_unlock(htable_mutex);
        }
    }
    return DR_EMIT_DEFAULT;
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:30,代码来源:custom_traces.dll.c

示例2: init_context

/* Annotation handler to initialize a client context (associated with an app thread) */
static void
init_context(uint id, const char *label, uint initial_mode)
{
    context_t *context;
    dr_mutex_lock(context_lock);

    PRINTF("Initialize context %d '%s' in mode %d", id, label, initial_mode);

    context = get_context(id);
    if (context == NULL) {
        uint label_length = (uint) (sizeof(char) * strlen(label)) + 1;
        context = dr_global_alloc(sizeof(context_t));
        context->id = id;
        context->label = dr_global_alloc(label_length);
        context->mode = initial_mode;
        context->mode_history = dr_global_alloc(MAX_MODE_HISTORY * sizeof(uint));
        context->mode_history[0] = initial_mode;
        context->mode_history_index = 1;
        memcpy(context->label, label, label_length);
        context->next = NULL;

        if (context_list->head == NULL) {
            context_list->head = context_list->tail = context;
        } else {
            context_list->tail->next = context;
            context_list->tail = context;
        }
    }

    dr_mutex_unlock(context_lock);
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:32,代码来源:annotation-concurrency.dll.c

示例3: inc_count_second

static void
inc_count_second(int second)
{
    dr_mutex_lock(mutex);
    counts[second]++;
    dr_mutex_unlock(mutex);
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:7,代码来源:events.dll.c

示例4: hashtable_remove

bool
hashtable_remove(hashtable_t *table, void *key)
{
    bool res = false;
    hash_entry_t *e, *prev_e;
    uint hindex = hash_key(table, key);
    if (table->synch)
        dr_mutex_lock(table->lock);
    for (e = table->table[hindex], prev_e = NULL; e != NULL; prev_e = e, e = e->next) {
        if (keys_equal(table, e->key, key)) {
            if (prev_e == NULL)
                table->table[hindex] = e->next;
            else
                prev_e->next = e->next;
            if (table->str_dup)
                hash_free(e->key, strlen((const char *)e->key) + 1);
            if (table->free_payload_func != NULL)
                (table->free_payload_func)(e->payload);
            hash_free(e, sizeof(*e));
            res = true;
            table->entries--;
            break;
        }
    }
    if (table->synch)
        dr_mutex_unlock(table->lock);
    return res;
}
开发者ID:kumarak,项目名称:Granary-Drk,代码行数:28,代码来源:hashtable_client.c

示例5: event_fragment_deleted

/* to keep the size of our hashtable down */
static void
event_fragment_deleted(void *drcontext, void *tag)
{
    dr_mutex_lock(htable_mutex);
    remove_trace_head_entry(NULL, tag);
    dr_mutex_unlock(htable_mutex);
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:8,代码来源:custom_traces.dll.c

示例6: instrace_thread_exit

void
instrace_thread_exit(void *drcontext)
{
    per_thread_t *data;
	int i;

	if (client_arg->instrace_mode == INS_TRACE){
		ins_trace(drcontext);
	}

    data = drmgr_get_tls_field(drcontext, tls_index);
    dr_mutex_lock(mutex);
    num_refs += data->num_refs;
    dr_mutex_unlock(mutex);

    dr_close_file(data->outfile);
	if (log_mode){
		dr_close_file(data->logfile);
	}

	dr_thread_free(drcontext, data->buf_base, INSTR_BUF_SIZE);
	dr_thread_free(drcontext, data->output_array, OUTPUT_BUF_SIZE);

	DEBUG_PRINT("%s - thread id : %d, cloned instructions freeing now - %d\n",ins_pass_name, dr_get_thread_id(drcontext),data->static_ptr);

	for(i=0 ; i<data->static_ptr; i++){
		instr_destroy(dr_get_current_drcontext(),data->static_array[i]);
	}

	dr_thread_free(drcontext, data->static_array, sizeof(instr_t *)*client_arg->static_info_size);
    dr_thread_free(drcontext, data, sizeof(per_thread_t));

	DEBUG_PRINT("%s - exiting thread done %d\n", ins_pass_name, dr_get_thread_id(drcontext));

}
开发者ID:CharithYMendis,项目名称:Helium,代码行数:35,代码来源:instrace.c

示例7: hashtable_delete

void
hashtable_delete(hashtable_t *table)
{
    uint i;
    if (table->synch)
        dr_mutex_lock(table->lock);
    for (i = 0; i < HASHTABLE_SIZE(table->table_bits); i++) {
        hash_entry_t *e = table->table[i];
        while (e != NULL) {
            hash_entry_t *nexte = e->next;
            if (table->str_dup)
                hash_free(e->key, strlen((const char *)e->key) + 1);
            if (table->free_payload_func != NULL)
                (table->free_payload_func)(e->payload);
            hash_free(e, sizeof(*e));
            e = nexte;
        }
    }
    hash_free(table->table, (size_t)HASHTABLE_SIZE(table->table_bits) *
              sizeof(hash_entry_t*));
    table->table = NULL;
    table->entries = 0;
    if (table->synch)
        dr_mutex_unlock(table->lock);
    dr_mutex_destroy(table->lock);
}
开发者ID:kumarak,项目名称:Granary-Drk,代码行数:26,代码来源:hashtable_client.c

示例8: add_hit

void add_hit(void *pc, size_t size, void *target, int read, void *drcontext,
	     ctx_t *ctx)
{
  malloc_t	*block = search_on_tree(active_blocks, target);
  access_t	*access;

  // if the access is not on a malloc block we do nothing
  // we have to check if the target is not the and of the block
  // (because last offset is out of the user
  // data and use only for malloc's internal purposes)
  if (!block || target == block->end)
    return;

  dr_mutex_lock(lock);

  if (read)
    access = get_access(target - block->start, &(block->read), block);
  else
    access = get_access(target - block->start, &(block->write), block);

  access->total_hits++;
  incr_orig(access, size, pc, drcontext, block, ctx);

  dr_mutex_unlock(lock);  
}
开发者ID:awesome-security,项目名称:dynStruct,代码行数:25,代码来源:rw.c

示例9: drvector_delete

bool
drvector_delete(drvector_t *vec)
{
    uint i;
    if (vec == NULL)
        return false;

    if (vec->synch)
        dr_mutex_lock(vec->lock);

    /* Since we lazily initialize the array, vec->array could be NULL if we
     * called drvector_init with capacity 0 and never inserted an element into
     * the vec. We check vec->array here and below before access.
     * */
    if (vec->free_data_func != NULL && vec->array != NULL) {
        for (i = 0; i < vec->entries; i++) {
            (vec->free_data_func)(vec->array[i]);
        }
    }

    if (vec->array != NULL) {
        dr_global_free(vec->array, vec->capacity * sizeof(void *));
        vec->array = NULL;
        vec->entries = 0;
    }

    if (vec->synch)
        dr_mutex_unlock(vec->lock);
    dr_mutex_destroy(vec->lock);
    return true;
}
开发者ID:djmott,项目名称:dynamorio,代码行数:31,代码来源:drvector.c

示例10: hashtable_add

bool
hashtable_add(hashtable_t *table, void *key, void *payload)
{
    uint hindex = hash_key(table, key);
    hash_entry_t *e;
    /* if payload is null can't tell from lookup miss */
    ASSERT(payload != NULL, "hashtable_add internal error");
    if (table->synch)
        dr_mutex_lock(table->lock);
    for (e = table->table[hindex]; e != NULL; e = e->next) {
        if (keys_equal(table, e->key, key)) {
            /* we have a use where payload != existing entry so we don't assert on that */
            if (table->synch)
                dr_mutex_unlock(table->lock);
            return false;
        }
    }
    e = (hash_entry_t *) hash_alloc(sizeof(*e));
    if (table->str_dup) {
        const char *s = (const char *) key;
        e->key = hash_alloc(strlen(s)+1);
        strncpy((char *)e->key, s, strlen(s)+1);
    } else
        e->key = key;
    e->payload = payload;
    e->next = table->table[hindex];
    table->table[hindex] = e;
    table->entries++;
    hashtable_check_for_resize(table);
    if (table->synch)
        dr_mutex_unlock(table->lock);
    return true;
}
开发者ID:kumarak,项目名称:Granary-Drk,代码行数:33,代码来源:hashtable_client.c

示例11: ordered_lock

static inline void
ordered_lock(ipc_channel_t *channel, uint tid)
{
    dr_mutex_lock(channel->queue_lock);

    ticket_queue_t *q = &channel->ticket_queue;
    if (q->locked)
    {
        ticket_node_t *node = dr_global_alloc(sizeof(ticket_node_t));
        if (node == NULL)
            DR_ABORT_MSG("Failed to allocate ticket node\n");
        node->next = NULL;
        node->dr_event = dr_event_create();
        node->waiting = true;
        node->thread_id = tid;

        DR_ASSERT(q->tail->next == NULL);
        q->tail = q->tail->next = node;

        SGL_DEBUG("Sleeping Thread :%d\n", tid);
        dr_mutex_unlock(channel->queue_lock);

        /* MDL20170425 TODO(soonish)
         * how likely is it that we'll miss a wakeup here? */
        while (node->waiting)
            dr_event_wait(node->dr_event);

        dr_mutex_lock(channel->queue_lock);

        q->head->next = node->next;
        if (q->tail == node)
            q->tail = q->head;

        dr_event_destroy(node->dr_event);
        dr_global_free(node, sizeof(ticket_node_t));

        SGL_DEBUG("Awakened Thread :%d\n", tid);
    }
    else
    {
        q->locked = true;
    }

    dr_mutex_unlock(channel->queue_lock);
}
开发者ID:mdlui,项目名称:dynamorio,代码行数:45,代码来源:drsigil_ipc.c

示例12: hashtable_clear

void
hashtable_clear(hashtable_t *table)
{
    if (table->synch)
        dr_mutex_lock(table->lock);
    hashtable_clear_internal(table);
    if (table->synch)
        dr_mutex_unlock(table->lock);
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:9,代码来源:hashtable.c

示例13: inc_count_first

static void
inc_count_first(int first, int second)
{
    dr_mutex_lock(mutex);
    if (counts[second] == 0)
        dr_fprintf(STDERR, "%s is called before %s\n", name[first], name[second]);
    counts[first]++;
    dr_mutex_unlock(mutex);
}
开发者ID:AVGirl,项目名称:dynamorio,代码行数:9,代码来源:events.dll.c

示例14: delete_fragment

static void
delete_fragment(void *drcontext, app_pc tag)
{
    dr_mutex_lock(mutex);
    deletions++;
    dr_mutex_unlock(mutex);

    dr_delete_fragment(drcontext, tag);
}
开发者ID:Arunpreet,项目名称:dynamorio,代码行数:9,代码来源:fragdel.dll.c

示例15: clean_call_mem_information

void clean_call_mem_information(instr_t * instr, app_pc mem_val, uint write){

	void * drcontext = dr_get_current_drcontext();
	module_data_t * data = dr_lookup_module(instr_get_app_pc(instr));
	uint offset;

	app_pc base_pc;
	size_t size;
	uint prot;
	file_t dump_file;
	char * dump_filename;
	
	DR_ASSERT(data != NULL);
	offset = instr_get_app_pc(instr) - data->start;

	dr_mutex_lock(mutex);

	//if (!md_lookup_bb_in_module(done_head, data->full_path, offset)){

		//md_add_bb_to_module(done_head, data->full_path, offset, MAX_BBS_PER_MODULE, false); 
		dr_query_memory(mem_val, &base_pc, &size, &prot);
		//DEBUG_PRINT("base pc - %x, size - %u, write - %u\n", base_pc, size, write);
		if (write){  /* postpone till the end of the function */
			if (!is_mem_region_present(write_regions, base_pc, size, write_region_size)){
				DEBUG_PRINT("write registered - offset - %x memval %x\n", offset, mem_val);
				add_to_mem_region(write_regions, base_pc, size, &write_region_size);
				DEBUG_PRINT("base pc %x, size %d\n", base_pc, size); 
			}
		}
		else{
			if (!is_mem_region_present(read_regions, base_pc, size, read_region_size)){
				add_to_mem_region(read_regions, base_pc, size, &read_region_size);
				//DEBUG_PRINT("size - %d\n", read_region_size);
				//DEBUG_PRINT("present - %d\n", is_mem_region_present(read_regions, base_pc, size, read_region_size));
				//dr_abort();
				DEBUG_PRINT("read registered - offset - %x memval %x\n", offset,  mem_val);
				DEBUG_PRINT("base pc %x, size %d\n", base_pc, size);
				dump_filename = get_mem_dump_filename(base_pc, size, write,0);
				dump_file = dr_open_file(dump_filename, DR_FILE_WRITE_OVERWRITE);
				DEBUG_PRINT("%s dumping file\n", dump_filename);
				do_mem_dump(dump_file, base_pc, size);
				DEBUG_PRINT("file dumped\n");
				dr_global_free(dump_filename, sizeof(char) * MAX_STRING_LENGTH);
				dr_close_file(dump_file);
			}
		}



	//}

	dr_mutex_unlock(mutex);
	dr_free_module_data(data);


}
开发者ID:CharithYMendis,项目名称:Helium,代码行数:56,代码来源:memdump.c


注:本文中的dr_mutex_lock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。