Community
Participate
Working Groups
When we call memory service "Memory get" , it will stop other contexts firstly, this can make sure the operation of memory read is atomic. But if memory service is called frequently, it will disturb the normal operation of other contexts and the performance is low. So we hope that there is a way to control stop or not stop. This provides the flexibility. --- a/agent/tcf/framework/context.h +++ b/agent/tcf/framework/context.h @@ -418,6 +418,7 @@ typedef struct MemoryAccessMode { int bypass_addr_check; int bypass_cache_sync; int verify; + int not_need_stop; } MemoryAccessMode; --- a/agent/tcf/services/memoryservice.c +++ b/agent/tcf/services/memoryservice.c @@ -356,6 +356,7 @@ static MemoryCommandArgs * read_command_args(char * token, Channel * c, int cmd) if (mode & 0x02) buf.mode.verify = 1; if (mode & 0x04) buf.mode.bypass_addr_check = 1; if (mode & 0x08) buf.mode.bypass_cache_sync = 1; + if (mode & 0x10) buf.mode.not_need_stop = 1; switch (cmd) { case CMD_SET: json_read_binary_start(&buf.state, &c->inp); @@ -514,6 +515,7 @@ static void memory_get_cache_client(void * parm) { ContextAddress addr = args->addr; unsigned long size = args->size; unsigned long pos = 0; + unsigned long nostop = args->mode.not_need_stop; int err = 0; MemoryErrorInfo err_info; JsonWriteBinaryState state; @@ -524,13 +526,16 @@ static void memory_get_cache_client(void * parm) { if (ctx == NULL) err = ERR_INV_CONTEXT; else if (ctx->exited) err = ERR_ALREADY_EXITED; - if (size > 0 && err == 0) { - Context * mem = context_get_group(ctx, CONTEXT_GROUP_PROCESS); - if ((mem->mem_access & MEM_ACCESS_RD_STOP) != 0) { - check_all_stopped(ctx); - } - if ((mem->mem_access & MEM_ACCESS_RD_RUNNING) == 0) { - if (!is_all_stopped(ctx)) err = set_errno(ERR_IS_RUNNING, "Cannot read memory if not stopped"); + if(nostop != 1) + { + if (size > 0 && err == 0) { + Context * mem = context_get_group(ctx, CONTEXT_GROUP_PROCESS); + if ((mem->mem_access & MEM_ACCESS_RD_STOP) != 0) { + check_all_stopped(ctx); + } + if ((mem->mem_access & MEM_ACCESS_RD_RUNNING) == 0) { + if (!is_all_stopped(ctx)) err = set_errno(ERR_IS_RUNNING, "Cannot read memory if not stopped"); + } } }
Can you take a look at this ?
I have added the flag. You need to make sure your context implementation sets MEM_ACCESS_RD_RUNNING.
I think I can't set MEM_ACCESS_RD_RUNNING for context. If dont_stop flag is zero, check_all_stopped will be called, but is_all_stopped will not be called. Can you modify it this way? It suits my needs better. It's also simpler. + if(!args->mode.dont_stop) + { if ((mem->mem_access & MEM_ACCESS_RD_STOP) != 0) { check_all_stopped(ctx); } if ((mem->mem_access & MEM_ACCESS_RD_RUNNING) == 0) { if (!is_all_stopped(ctx)) err = set_errno(ERR_IS_RUNNING, "Cannot read memory if not stopped"); } + }