Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2013-04-05 12:29:54 -0400
committerEugene Tarassov2013-04-05 12:29:54 -0400
commit296831ee6868660d13786919c9ecb5f00d99166e (patch)
tree6c2bd3956ded622c3d3fab089db5b0d84127f92d
parentea0577e88a4dd1c77e9761a9c0574fe7dfa6aab6 (diff)
downloadorg.eclipse.tcf.agent-296831ee6868660d13786919c9ecb5f00d99166e.tar.gz
org.eclipse.tcf.agent-296831ee6868660d13786919c9ecb5f00d99166e.tar.xz
org.eclipse.tcf.agent-296831ee6868660d13786919c9ecb5f00d99166e.zip
Bug 404788 - Symbols proxy service : symbol cache is not flushed on path mapping changes
-rw-r--r--agent/tcf/services/linenumbers_proxy.c45
-rw-r--r--agent/tcf/services/memorymap.c53
-rw-r--r--agent/tcf/services/symbols_proxy.c71
3 files changed, 128 insertions, 41 deletions
diff --git a/agent/tcf/services/linenumbers_proxy.c b/agent/tcf/services/linenumbers_proxy.c
index 7689af2d..1a8a0ede 100644
--- a/agent/tcf/services/linenumbers_proxy.c
+++ b/agent/tcf/services/linenumbers_proxy.c
@@ -32,6 +32,7 @@
#include <tcf/framework/events.h>
#include <tcf/framework/myalloc.h>
#include <tcf/framework/exceptions.h>
+#include <tcf/services/memorymap.h>
#include <tcf/services/linenumbers.h>
#define HASH_SIZE (16 * MEM_USAGE_FACTOR - 1)
@@ -115,7 +116,8 @@ static LineNumbersCache * get_line_numbers_cache(void) {
LINK * l = NULL;
LineNumbersCache * cache = NULL;
Channel * c = cache_channel();
- if (c == NULL) str_exception(ERR_OTHER, "get_line_numbers_cache(): illegal cache access");
+ if (c == NULL) str_exception(ERR_OTHER, "Line numbers cache: illegal cache access");
+ if (is_channel_closed(c)) exception(ERR_CHANNEL_CLOSED);
for (l = root.next; l != &root; l = l->next) {
LineNumbersCache * x = root2cache(l);
if (x->channel == c) {
@@ -239,8 +241,7 @@ int line_to_address(Context * ctx, char * file, int line, int column,
}
if (entry == NULL) {
- Channel * c = cache_channel();
- if (c == NULL || is_channel_closed(c)) exception(ERR_UNSUPPORTED);
+ Channel * c = cache->channel;
entry = (LineNumbersCacheEntry *)loc_alloc_zero(sizeof(LineNumbersCacheEntry));
list_add_first(&entry->link_cache, cache->link_entries + h);
entry->magic = LINE_NUMBERS_CACHE_MAGIC;
@@ -305,8 +306,7 @@ int address_to_line(Context * ctx, ContextAddress addr0, ContextAddress addr1, L
}
if (entry == NULL) {
- Channel * c = cache_channel();
- if (c == NULL || is_channel_closed(c)) exception(ERR_UNSUPPORTED);
+ Channel * c = cache->channel;
entry = (LineNumbersCacheEntry *)loc_alloc_zero(sizeof(LineNumbersCacheEntry));
list_add_first(&entry->link_cache, cache->link_entries + h);
entry->magic = LINE_NUMBERS_CACHE_MAGIC;
@@ -370,6 +370,12 @@ static void event_context_changed(Context * ctx, void * x) {
flush_cache(context_get_group(ctx, CONTEXT_GROUP_SYMBOLS));
}
+#if SERVICE_MemoryMap
+static void event_code_unmapped(Context * ctx, ContextAddress addr, ContextAddress size, void * x) {
+ event_context_changed(ctx, x);
+}
+#endif
+
static void channel_close_listener(Channel * c) {
LINK * l = root.next;
while (l != &root) {
@@ -380,14 +386,27 @@ static void channel_close_listener(Channel * c) {
}
void ini_line_numbers_lib(void) {
- static ContextEventListener listener = {
- event_context_created,
- event_context_exited,
- NULL,
- NULL,
- event_context_changed
- };
- add_context_event_listener(&listener, NULL);
+ {
+ static ContextEventListener listener = {
+ event_context_created,
+ event_context_exited,
+ NULL,
+ NULL,
+ event_context_changed
+ };
+ add_context_event_listener(&listener, NULL);
+ }
+#if SERVICE_MemoryMap
+ {
+ static MemoryMapEventListener listener = {
+ event_context_changed,
+ event_code_unmapped,
+ event_context_changed,
+ event_context_changed,
+ };
+ add_memory_map_event_listener(&listener, NULL);
+ }
+#endif
add_channel_close_listener(channel_close_listener);
}
diff --git a/agent/tcf/services/memorymap.c b/agent/tcf/services/memorymap.c
index 5a6707ef..d0792889 100644
--- a/agent/tcf/services/memorymap.c
+++ b/agent/tcf/services/memorymap.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Wind River Systems, Inc. and others.
+ * Copyright (c) 2009, 2013 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
@@ -30,6 +30,7 @@
#include <tcf/framework/events.h>
#include <tcf/framework/exceptions.h>
#include <tcf/services/contextquery.h>
+#include <tcf/services/pathmap.h>
#include <tcf/services/memorymap.h>
typedef struct Listener {
@@ -521,6 +522,28 @@ static void command_set(char * token, Channel * c) {
write_stream(&c->out, MARKER_EOM);
}
+#if SERVICE_PathMap
+/* Memory map file names are translated using Path Map service,
+ * so any change in the path maps translates to memory map
+ * change in all memory spaces */
+static void event_path_map_changed(Channel * c, void * args) {
+ LINK * l = context_root.next;
+ while (l != &context_root) {
+ int notify = 0;
+ Context * ctx = ctxl2ctxp(l);
+ ContextExtensionMM * ext = EXT(ctx);
+ l = l->next;
+ if (ctx->exited) continue;
+ if (ctx != get_mem_context(ctx)) continue;
+#if ENABLE_DebugContext
+ if (ext->valid && !ext->error && ext->target_map.region_cnt > 0) notify = 1;
+#endif
+ if (ext->client_map.region_cnt > 0) notify = 1;
+ if (notify) memory_map_event_mapping_changed(ctx);
+ }
+}
+#endif
+
static void channel_close_listener(Channel * c) {
int notify = 0;
LINK * l = client_map_list.next;
@@ -539,17 +562,27 @@ static void channel_close_listener(Channel * c) {
}
void ini_memory_map_service(Protocol * proto, TCFBroadcastGroup * bcg) {
- static ContextEventListener listener = {
- event_context_changed,
- NULL,
- NULL,
- NULL,
- event_context_changed,
- event_context_disposed
- };
+ {
+ static ContextEventListener listener = {
+ event_context_changed,
+ NULL,
+ NULL,
+ NULL,
+ event_context_changed,
+ event_context_disposed
+ };
+ add_context_event_listener(&listener, NULL);
+ }
+#if SERVICE_PathMap
+ {
+ static PathMapEventListener listener = {
+ event_path_map_changed,
+ };
+ add_path_map_event_listener(&listener, NULL);
+ }
+#endif
broadcast_group = bcg;
add_channel_close_listener(channel_close_listener);
- add_context_event_listener(&listener, NULL);
add_command_handler(proto, MEMORY_MAP, "get", command_get);
add_command_handler(proto, MEMORY_MAP, "set", command_set);
context_extension_offset = context_extension(sizeof(ContextExtensionMM));
diff --git a/agent/tcf/services/symbols_proxy.c b/agent/tcf/services/symbols_proxy.c
index b213cba7..e7b036d4 100644
--- a/agent/tcf/services/symbols_proxy.c
+++ b/agent/tcf/services/symbols_proxy.c
@@ -32,6 +32,7 @@
#include <tcf/framework/myalloc.h>
#include <tcf/framework/exceptions.h>
#include <tcf/services/stacktrace.h>
+#include <tcf/services/memorymap.h>
#include <tcf/services/symbols.h>
#include <tcf/services/vm.h>
#if ENABLE_RCBP_TEST
@@ -226,7 +227,8 @@ static SymbolsCache * get_symbols_cache(void) {
LINK * l = NULL;
SymbolsCache * syms = NULL;
Channel * c = cache_channel();
- if (c == NULL) str_exception(ERR_OTHER, "get_symbols_cache(): illegal cache access");
+ if (c == NULL) str_exception(ERR_OTHER, "Symbols cache: illegal cache access");
+ if (is_channel_closed(c)) exception(ERR_CHANNEL_CLOSED);
for (l = root.next; l != &root; l = l->next) {
SymbolsCache * x = root2syms(l);
if (x->channel == c) {
@@ -1678,10 +1680,19 @@ const char * get_symbol_file_name(Context * ctx, MemoryRegion * module) {
/*************************************************************************************************/
+static int check_policy(Context * ctx, int mode, Context * sym_grp, Context * sym_ctx, int policy) {
+ if ((mode & (1 << policy)) && sym_ctx == ctx) return 1;
+ if (mode & (1 << UPDATE_ON_MEMORY_MAP_CHANGES)) {
+ if (context_get_group(sym_ctx, CONTEXT_GROUP_SYMBOLS) == sym_grp) return 1;
+ }
+ return 0;
+}
+
static void flush_syms(Context * ctx, int mode) {
LINK * l;
LINK * m;
int i;
+ Context * sym_grp = context_get_group(ctx, CONTEXT_GROUP_SYMBOLS);
for (m = root.next; m != &root; m = m->next) {
SymbolsCache * syms = root2syms(m);
@@ -1696,7 +1707,7 @@ static void flush_syms(Context * ctx, int mode) {
else if (c->update_owner == NULL || c->update_owner->exited) {
free_sym_info_cache(c);
}
- else if ((mode & (1 << c->update_policy)) && ctx == c->update_owner) {
+ else if (check_policy(ctx, mode, sym_grp, c->update_owner, c->update_policy)) {
if (mode == (1 << UPDATE_ON_EXE_STATE_CHANGES)) {
c->degraded = 1;
}
@@ -1709,7 +1720,7 @@ static void flush_syms(Context * ctx, int mode) {
while (l != syms->link_find_by_name + i) {
FindSymCache * c = syms2find(l);
l = l->next;
- if ((mode & (1 << c->update_policy)) && c->ctx == ctx) {
+ if (check_policy(ctx, mode, sym_grp, c->ctx, c->update_policy)) {
free_find_sym_cache(c);
}
}
@@ -1717,7 +1728,7 @@ static void flush_syms(Context * ctx, int mode) {
while (l != syms->link_find_in_scope + i) {
FindSymCache * c = syms2find(l);
l = l->next;
- if ((mode & (1 << c->update_policy)) && c->ctx == ctx) {
+ if (check_policy(ctx, mode, sym_grp, c->ctx, c->update_policy)) {
free_find_sym_cache(c);
}
}
@@ -1725,29 +1736,34 @@ static void flush_syms(Context * ctx, int mode) {
while (l != syms->link_list + i) {
FindSymCache * c = syms2find(l);
l = l->next;
- if ((mode & (1 << c->update_policy)) && c->ctx == ctx) {
+ if (check_policy(ctx, mode, sym_grp, c->ctx, c->update_policy)) {
free_find_sym_cache(c);
}
}
if (mode & (1 << UPDATE_ON_MEMORY_MAP_CHANGES)) {
- Context * prs = context_get_group(ctx, CONTEXT_GROUP_SYMBOLS);
l = syms->link_frame[i].next;
while (l != syms->link_frame + i) {
StackFrameCache * c = syms2frame(l);
l = l->next;
- if (context_get_group(c->ctx, CONTEXT_GROUP_SYMBOLS) == prs) free_stack_frame_cache(c);
+ if (check_policy(ctx, mode, sym_grp, c->ctx, UPDATE_ON_MEMORY_MAP_CHANGES)) {
+ free_stack_frame_cache(c);
+ }
}
l = syms->link_address[i].next;
while (l != syms->link_address + i) {
AddressInfoCache * c = syms2address(l);
l = l->next;
- if (context_get_group(c->ctx, CONTEXT_GROUP_SYMBOLS) == prs) free_address_info_cache(c);
+ if (check_policy(ctx, mode, sym_grp, c->ctx, UPDATE_ON_MEMORY_MAP_CHANGES)) {
+ free_address_info_cache(c);
+ }
}
l = syms->link_location[i].next;
while (l != syms->link_location + i) {
LocationInfoCache * c = syms2location(l);
l = l->next;
- if (context_get_group(c->ctx, CONTEXT_GROUP_SYMBOLS) == prs) free_location_info_cache(c);
+ if (check_policy(ctx, mode, sym_grp, c->ctx, UPDATE_ON_MEMORY_MAP_CHANGES)) {
+ free_location_info_cache(c);
+ }
}
}
}
@@ -1771,9 +1787,15 @@ static void event_context_started(Context * ctx, void * x) {
}
static void event_context_changed(Context * ctx, void * x) {
- flush_syms(ctx, (1 << UPDATE_ON_MEMORY_MAP_CHANGES) | (1 << UPDATE_ON_EXE_STATE_CHANGES));
+ flush_syms(ctx, ~0);
}
+#if SERVICE_MemoryMap
+static void event_code_unmapped(Context * ctx, ContextAddress addr, ContextAddress size, void * x) {
+ flush_syms(ctx, ~0);
+}
+#endif
+
static void channel_close_listener(Channel * c) {
LINK * l = root.next;
while (l != &root) {
@@ -1784,14 +1806,27 @@ static void channel_close_listener(Channel * c) {
}
void ini_symbols_lib(void) {
- static ContextEventListener listener = {
- event_context_created,
- event_context_exited,
- event_context_stopped,
- event_context_started,
- event_context_changed
- };
- add_context_event_listener(&listener, NULL);
+ {
+ static ContextEventListener listener = {
+ event_context_created,
+ event_context_exited,
+ event_context_stopped,
+ event_context_started,
+ event_context_changed
+ };
+ add_context_event_listener(&listener, NULL);
+ }
+#if SERVICE_MemoryMap
+ {
+ static MemoryMapEventListener listener = {
+ event_context_changed,
+ event_code_unmapped,
+ event_context_changed,
+ event_context_changed,
+ };
+ add_memory_map_event_listener(&listener, NULL);
+ }
+#endif
add_channel_close_listener(channel_close_listener);
}

Back to the top