Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2011-06-13 18:09:55 +0000
committereutarass2011-06-13 18:09:55 +0000
commit617316e90aeec41d94aa85a086372a3c53be2bce (patch)
tree5c105e466c6536443e15171053930d88f0c92bbc
parent240fd28096b205ce5c8a1ac7a773e8729dd1d80f (diff)
downloadorg.eclipse.tcf.agent-617316e90aeec41d94aa85a086372a3c53be2bce.tar.gz
org.eclipse.tcf.agent-617316e90aeec41d94aa85a086372a3c53be2bce.tar.xz
org.eclipse.tcf.agent-617316e90aeec41d94aa85a086372a3c53be2bce.zip
Changes in Memory Map service implementation and UI:
1. Added new notification callback: void (*mapping_changed)(Context * ctx, void * client_data). 2. Manual memory map entries are now associated with full context name (including parent names) to avoid ambiguity. 3. TCF launch configuration now includes "Symbol Files" tab to allow editing of manual map entries as part of the launch configuration. 4. "Debug context" field of the memory map UI changed to combo box to allow a user to see/edit all maps associated with a launch.
-rw-r--r--server/services/context-proxy.c16
-rw-r--r--services/breakpoints.c3
-rw-r--r--services/memorymap.c120
-rw-r--r--services/memorymap.h2
-rw-r--r--system/GNU/Linux/context-linux.c4
-rw-r--r--system/Windows/context-win32.c1
6 files changed, 95 insertions, 51 deletions
diff --git a/server/services/context-proxy.c b/server/services/context-proxy.c
index bd446c3f..99e14066 100644
--- a/server/services/context-proxy.c
+++ b/server/services/context-proxy.c
@@ -33,6 +33,7 @@
#include <framework/json.h>
#include <framework/cache.h>
#include <services/pathmap.h>
+#include <services/memorymap.h>
#include <services/stacktrace.h>
#include <services/context-proxy.h>
@@ -406,7 +407,6 @@ static void read_context_changed_item(InputStream * inp, void * args) {
c->can_resume = buf.can_resume;
c->can_count = buf.can_count;
c->can_terminate = buf.can_terminate;
- crear_memory_map_data(c);
send_context_changed_event(c->ctx);
}
else if (p->rc_done) {
@@ -609,7 +609,7 @@ static void event_memory_map_changed(Channel * c, void * args) {
if (ctx != NULL) {
assert(*EXT(ctx->ctx) == ctx);
crear_memory_map_data(ctx);
- send_context_changed_event(ctx->ctx);
+ memory_map_event_mapping_chnaged(ctx->ctx);
}
else if (p->rc_done) {
trace(LOG_ALWAYS, "Invalid ID in 'memory map changed' event: %s", id);
@@ -628,6 +628,8 @@ static void command_path_map_set(char * token, Channel * c, void * args) {
if (read_stream(p->fwd_inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);
}
+static void validate_peer_cache_children(Channel * c, void * args, int error);
+
void create_context_proxy(Channel * host, Channel * target, int forward_pm) {
int i;
LINK * l;
@@ -654,6 +656,11 @@ void create_context_proxy(Channel * host, Channel * target, int forward_pm) {
add_event_handler2(target, RUN_CONTROL, "containerResumed", event_container_resumed, p);
add_event_handler2(target, MEMORY_MAP, "changed", event_memory_map_changed, p);
if (forward_pm) add_command_handler2(host->protocol, PATH_MAP, "set", command_path_map_set, p);
+ /* Retirve initila set of run control contexts */
+ protocol_send_command(p->target, "RunControl", "getChildren", validate_peer_cache_children, p);
+ write_stringz(&p->target->out, "null");
+ write_stream(&p->target->out, MARKER_EOM);
+ p->rc_pending_cnt++;
}
static void validate_peer_cache_context(Channel * c, void * args, int error);
@@ -838,10 +845,6 @@ Context * id2ctx(const char * id) {
set_error_report_errno(p->rc_error);
}
else if (!p->rc_done) {
- protocol_send_command(p->target, "RunControl", "getChildren", validate_peer_cache_children, p);
- write_stringz(&p->target->out, "null");
- write_stream(&p->target->out, MARKER_EOM);
- p->rc_pending_cnt++;
cache_wait(&p->rc_cache);
}
else {
@@ -858,7 +861,6 @@ int context_has_state(Context * ctx) {
}
Context * context_get_group(Context * ctx, int group) {
- /* TODO: context proxy: context_get_group() */
switch (group) {
case CONTEXT_GROUP_INTERCEPT:
return ctx;
diff --git a/services/breakpoints.c b/services/breakpoints.c
index 6ccd69bb..9d808de4 100644
--- a/services/breakpoints.c
+++ b/services/breakpoints.c
@@ -2315,7 +2315,8 @@ void ini_breakpoints_service(Protocol * proto, TCFBroadcastGroup * bcg) {
static MemoryMapEventListener listener = {
event_context_changed,
event_code_unmapped,
- event_context_changed
+ event_context_changed,
+ event_context_changed,
};
add_memory_map_event_listener(&listener, NULL);
}
diff --git a/services/memorymap.c b/services/memorymap.c
index e9746510..f987b99d 100644
--- a/services/memorymap.c
+++ b/services/memorymap.c
@@ -97,33 +97,49 @@ static int str_equ(char * x, char * y) {
return strcmp(x, y) == 0;
}
-static int update_context_client_map(Context * ctx) {
+static size_t get_context_full_name(Context * ctx, char * buf, size_t buf_size) {
+ size_t pos = 0;
+ if (ctx != NULL) {
+ char * name = ctx->name;
+ pos = get_context_full_name(ctx->parent, buf, buf_size);
+ if (pos < buf_size) buf[pos++] = '/';
+ if (name != NULL) {
+ while (pos < buf_size && *name) buf[pos++] = *name++;
+ }
+ }
+ return pos;
+}
+
+static unsigned find_maps(LINK * maps, const char * id) {
+ LINK * l;
+ unsigned cnt = 0;
+ unsigned h = map_id_hash(id);
+ for (l = client_map_hash[h].next; l != &client_map_hash[h]; l = l->next) {
+ ClientMap * m = hash2map(l);
+ if (list_is_empty(&m->link_ctx) && strcmp(m->id, id) == 0) {
+ list_add_last(&m->link_ctx, maps);
+ cnt += m->map.region_cnt;
+ }
+ }
+ return cnt;
+}
+
+static void update_context_client_map(Context * ctx) {
ContextExtensionMM * ext = EXT(ctx);
unsigned r_cnt = 0;
int equ = 0;
- unsigned h, i;
+ unsigned i;
LINK * l;
LINK maps;
assert(ctx == context_get_group(ctx, CONTEXT_GROUP_PROCESS));
list_init(&maps);
- h = map_id_hash(ctx->id);
- for (l = client_map_hash[h].next; l != &client_map_hash[h]; l = l->next) {
- ClientMap * m = hash2map(l);
- if (strcmp(m->id, ctx->id) == 0) {
- list_add_last(&m->link_ctx, &maps);
- r_cnt += m->map.region_cnt;
- }
- }
+ r_cnt += find_maps(&maps, ctx->id);
if (ctx->name != NULL) {
- h = map_id_hash(ctx->name);
- for (l = client_map_hash[h].next; l != &client_map_hash[h]; l = l->next) {
- ClientMap * m = hash2map(l);
- if (strcmp(m->id, ctx->name) == 0) {
- list_add_last(&m->link_ctx, &maps);
- r_cnt += m->map.region_cnt;
- }
- }
+ char buf[1024];
+ r_cnt += find_maps(&maps, ctx->name);
+ buf[get_context_full_name(ctx, buf, sizeof(buf) - 1)] = 0;
+ r_cnt += find_maps(&maps, buf);
}
equ = ext->client_map.region_cnt == r_cnt;
if (equ) {
@@ -143,27 +159,29 @@ static int update_context_client_map(Context * ctx) {
str_equ(y->sect_name, x->sect_name);
}
}
+ assert(!equ || k == r_cnt);
}
- if (equ) return 0;
-
- context_clear_memory_map(&ext->client_map);
- for (l = maps.next; l != &maps; l = l->next) {
- ClientMap * m = ctx2map(l);
- for (i = 0; i < m->map.region_cnt; i++) {
- MemoryRegion * x = m->map.regions + i;
- MemoryRegion * y = add_region(&ext->client_map);
- y->addr = x->addr;
- y->size = x->size;
- y->file_offs = x->file_offs;
- y->bss = x->bss;
- y->flags = x->flags;
- if (x->file_name) y->file_name = loc_strdup(x->file_name);
- if (x->sect_name) y->sect_name = loc_strdup(x->sect_name);
- if (x->id) y->id = loc_strdup(x->id);
+ if (!equ) {
+ context_clear_memory_map(&ext->client_map);
+ for (l = maps.next; l != &maps; l = l->next) {
+ ClientMap * m = ctx2map(l);
+ for (i = 0; i < m->map.region_cnt; i++) {
+ MemoryRegion * x = m->map.regions + i;
+ MemoryRegion * y = add_region(&ext->client_map);
+ y->addr = x->addr;
+ y->size = x->size;
+ y->file_offs = x->file_offs;
+ y->bss = x->bss;
+ y->flags = x->flags;
+ if (x->file_name) y->file_name = loc_strdup(x->file_name);
+ if (x->sect_name) y->sect_name = loc_strdup(x->sect_name);
+ if (x->id) y->id = loc_strdup(x->id);
+ }
}
+ assert(ext->client_map.region_cnt == r_cnt);
}
-
- return 1;
+ while (!list_is_empty(&maps)) list_remove(maps.next);
+ if (!equ) memory_map_event_mapping_chnaged(ctx);
}
static void update_all_context_client_maps(void) {
@@ -172,7 +190,7 @@ static void update_all_context_client_maps(void) {
Context * ctx = ctxl2ctxp(l);
if (ctx->exited) continue;
if (ctx != context_get_group(ctx, CONTEXT_GROUP_PROCESS)) continue;
- if (update_context_client_map(ctx)) send_context_changed_event(ctx);
+ update_context_client_map(ctx);
}
}
@@ -180,13 +198,13 @@ static void event_memory_map_changed(Context * ctx, void * args) {
OutputStream * out;
ContextExtensionMM * ext = EXT(ctx);
+ if (ctx->exited) return;
+ if (!ext->valid) return;
if (ctx != context_get_group(ctx, CONTEXT_GROUP_PROCESS)) return;
- update_context_client_map(ctx);
+
context_clear_memory_map(&ext->target_map);
- if (!ext->valid) return;
ext->valid = 0;
- if (ctx->exited) return;
out = &broadcast_group->out;
write_stringz(out, "E");
@@ -198,6 +216,12 @@ static void event_memory_map_changed(Context * ctx, void * args) {
write_stream(out, MARKER_EOM);
}
+static void event_context_changed(Context * ctx, void * args) {
+ if (ctx->exited) return;
+ if (ctx != context_get_group(ctx, CONTEXT_GROUP_PROCESS)) return;
+ update_context_client_map(ctx);
+}
+
static void event_context_disposed(Context * ctx, void * args) {
MemoryMap * map;
ContextExtensionMM * ext = EXT(ctx);
@@ -275,6 +299,18 @@ void memory_map_event_module_unloaded(Context * ctx) {
}
}
+void memory_map_event_mapping_chnaged(Context * ctx) {
+ unsigned i;
+ assert(ctx->ref_count > 0);
+ assert(ctx == context_get_group(ctx, CONTEXT_GROUP_PROCESS));
+ event_memory_map_changed(ctx, NULL);
+ for (i = 0; i < listener_cnt; i++) {
+ Listener * l = listeners + i;
+ if (l->listener->mapping_changed == NULL) continue;
+ l->listener->mapping_changed(ctx, l->args);
+ }
+}
+
void add_memory_map_event_listener(MemoryMapEventListener * listener, void * client_data) {
Listener * l = NULL;
if (listener_cnt >= listener_max) {
@@ -481,11 +517,11 @@ static void channel_close_listener(Channel * c) {
void ini_memory_map_service(Protocol * proto, TCFBroadcastGroup * bcg) {
int i;
static ContextEventListener listener = {
- event_memory_map_changed,
+ event_context_changed,
NULL,
NULL,
NULL,
- event_memory_map_changed,
+ event_context_changed,
event_context_disposed
};
broadcast_group = bcg;
diff --git a/services/memorymap.h b/services/memorymap.h
index b23d0a88..9b73a932 100644
--- a/services/memorymap.h
+++ b/services/memorymap.h
@@ -38,6 +38,7 @@ extern int memory_map_get(Context * ctx, MemoryMap ** client_map, MemoryMap ** t
extern void memory_map_event_module_loaded(Context * ctx);
extern void memory_map_event_code_section_ummapped(Context * ctx, ContextAddress addr, ContextAddress size);
extern void memory_map_event_module_unloaded(Context * ctx);
+extern void memory_map_event_mapping_chnaged(Context * ctx);
/*
* Memory map listener.
@@ -46,6 +47,7 @@ typedef struct MemoryMapEventListener {
void (*module_loaded)(Context * ctx, void * client_data);
void (*code_section_ummapped)(Context * ctx, ContextAddress addr, ContextAddress size, void * client_data);
void (*module_unloaded)(Context * ctx, void * client_data);
+ void (*mapping_changed)(Context * ctx, void * client_data);
} MemoryMapEventListener;
/*
diff --git a/system/GNU/Linux/context-linux.c b/system/GNU/Linux/context-linux.c
index 49e257f0..986a0172 100644
--- a/system/GNU/Linux/context-linux.c
+++ b/system/GNU/Linux/context-linux.c
@@ -860,6 +860,7 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
break;
case PTRACE_EVENT_EXEC:
send_context_changed_event(ctx);
+ memory_map_event_mapping_chnaged(ctx->mem);
break;
case PTRACE_EVENT_EXIT:
ctx->exiting = 1;
@@ -948,7 +949,7 @@ static void event_pid_stopped(pid_t pid, int signal, int event, int syscall) {
#endif
case __NR_mremap:
case __NR_remap_file_pages:
- send_context_changed_event(ctx);
+ memory_map_event_mapping_chnaged(ctx->mem);
break;
}
ext->syscall_enter = 0;
@@ -1074,6 +1075,7 @@ static void eventpoint_at_loader(Context * ctx, void * args) {
static void eventpoint_at_main(Context * ctx, void * args) {
send_context_changed_event(ctx->mem);
+ memory_map_event_mapping_chnaged(ctx->mem);
suspend_debug_context(ctx);
}
diff --git a/system/Windows/context-win32.c b/system/Windows/context-win32.c
index f33cc179..4c26faf8 100644
--- a/system/Windows/context-win32.c
+++ b/system/Windows/context-win32.c
@@ -311,6 +311,7 @@ static DWORD event_win32_context_stopped(Context * ctx) {
if (!debug_state->ok_to_use_hw_bp) {
debug_state->ok_to_use_hw_bp = 1;
send_context_changed_event(ctx->mem);
+ memory_map_event_mapping_chnaged(ctx->mem);
}
#endif
}

Back to the top