Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2014-04-29 22:02:01 -0400
committerEugene Tarassov2014-04-29 22:02:01 -0400
commit756da99053acd22cc8fd33f4d50e84051bdc7a1a (patch)
tree45559c35df33e900c5e2e0cb0ee92db48585c28b
parent908b6b7b77bbcaeb4226f2ad7a2fd4a667be41cd (diff)
downloadorg.eclipse.tcf.agent-756da99053acd22cc8fd33f4d50e84051bdc7a1a.tar.gz
org.eclipse.tcf.agent-756da99053acd22cc8fd33f4d50e84051bdc7a1a.tar.xz
org.eclipse.tcf.agent-756da99053acd22cc8fd33f4d50e84051bdc7a1a.zip
TCF Agent: symbols multiplexer and symbols proxy are now enabled by default. This allows to do symbols look up on both target and host sides at same time.
-rwxr-xr-xagent/agent.vcproj8
-rw-r--r--agent/tcf/config.h14
-rw-r--r--agent/tcf/main/test.c10
-rw-r--r--agent/tcf/services/diagnostics.c40
-rw-r--r--agent/tcf/services/dwarfreloc.c4
-rw-r--r--agent/tcf/services/elf-symbols.c4
-rw-r--r--agent/tcf/services/elf-symbols.h6
-rw-r--r--agent/tcf/services/expressions.c11
-rw-r--r--agent/tcf/services/linenumbers_elf.c4
-rw-r--r--agent/tcf/services/linenumbers_mux.c42
-rw-r--r--agent/tcf/services/linenumbers_mux.h9
-rw-r--r--agent/tcf/services/linenumbers_proxy.c7
-rw-r--r--agent/tcf/services/linenumbers_win32.c6
-rw-r--r--agent/tcf/services/runctrl.c7
-rw-r--r--agent/tcf/services/stacktrace.c7
-rw-r--r--agent/tcf/services/stacktrace.h26
-rw-r--r--agent/tcf/services/symbols_elf.c42
-rw-r--r--agent/tcf/services/symbols_mux.c201
-rw-r--r--agent/tcf/services/symbols_mux.h7
-rw-r--r--agent/tcf/services/symbols_proxy.c326
-rw-r--r--agent/tcf/services/symbols_win32.c34
21 files changed, 454 insertions, 361 deletions
diff --git a/agent/agent.vcproj b/agent/agent.vcproj
index 4b7ea7ac..5b0cf297 100755
--- a/agent/agent.vcproj
+++ b/agent/agent.vcproj
@@ -836,6 +836,10 @@
>
</File>
<File
+ RelativePath=".\tcf\services\linenumbers_mux.h"
+ >
+ </File>
+ <File
RelativePath=".\tcf\services\linenumbers_proxy.c"
>
</File>
@@ -948,6 +952,10 @@
>
</File>
<File
+ RelativePath=".\tcf\services\symbols_mux.h"
+ >
+ </File>
+ <File
RelativePath=".\tcf\services\symbols_proxy.c"
>
</File>
diff --git a/agent/tcf/config.h b/agent/tcf/config.h
index 384513c5..92b7d27e 100644
--- a/agent/tcf/config.h
+++ b/agent/tcf/config.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -173,23 +173,23 @@
#endif
#if !defined(ENABLE_SymbolsProxy)
-# define ENABLE_SymbolsProxy (ENABLE_DebugContext && TARGET_VXWORKS)
+# define ENABLE_SymbolsProxy (ENABLE_DebugContext && (TARGET_VXWORKS || TARGET_UNIX || TARGET_WINDOWS))
#endif
#if !defined(ENABLE_LineNumbersProxy)
-# define ENABLE_LineNumbersProxy (ENABLE_DebugContext && TARGET_VXWORKS)
+# define ENABLE_LineNumbersProxy (ENABLE_DebugContext && (TARGET_VXWORKS || TARGET_UNIX || TARGET_WINDOWS))
#endif
#if !defined(ENABLE_MemoryMap)
# define ENABLE_MemoryMap ((ENABLE_DebugContext && ENABLE_ContextProxy) || SERVICE_MemoryMap)
#endif
-#if ENABLE_SymbolsProxy || !ENABLE_DebugContext
+#if !ENABLE_DebugContext
# undef SERVICE_Symbols
# define SERVICE_Symbols 0
#endif
-#if ENABLE_LineNumbersProxy || !ENABLE_DebugContext
+#if !ENABLE_DebugContext
# undef SERVICE_LineNumbers
# define SERVICE_LineNumbers 0
#endif
@@ -211,11 +211,11 @@
#endif
#if !defined(ENABLE_SymbolsMux)
-#define ENABLE_SymbolsMux 0
+#define ENABLE_SymbolsMux (SERVICE_Symbols && (ENABLE_ELF || ENABLE_PE))
#endif
#if !defined(ENABLE_LineNumbersMux)
-#define ENABLE_LineNumbersMux 0
+#define ENABLE_LineNumbersMux (SERVICE_LineNumbers && (ENABLE_ELF || ENABLE_PE))
#endif
#if !defined(ENABLE_SSL)
diff --git a/agent/tcf/main/test.c b/agent/tcf/main/test.c
index abe41a58..e35259c4 100644
--- a/agent/tcf/main/test.c
+++ b/agent/tcf/main/test.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -271,10 +271,10 @@ int find_test_symbol(Context * ctx, const char * name, void ** addr, int * sym_c
}
else {
*sym_class = SYM_CLASS_FUNCTION;
- if (strcmp(name, "tcf_test_func0") == 0) *addr = (void *)&tcf_test_func0;
- else if (strcmp(name, "tcf_test_func1") == 0) *addr = (void *)&tcf_test_func1;
- else if (strcmp(name, "tcf_test_func2") == 0) *addr = (void *)&tcf_test_func2;
- else if (strcmp(name, "tcf_test_func3") == 0) *addr = (void *)&tcf_test_func3;
+ if (strcmp(name, "tcf_test_func0") == 0) *addr = (void *)tcf_test_func0;
+ else if (strcmp(name, "tcf_test_func1") == 0) *addr = (void *)tcf_test_func1;
+ else if (strcmp(name, "tcf_test_func2") == 0) *addr = (void *)tcf_test_func2;
+ else if (strcmp(name, "tcf_test_func3") == 0) *addr = (void *)tcf_test_func3;
}
if (*addr != NULL) return 0;
}
diff --git a/agent/tcf/services/diagnostics.c b/agent/tcf/services/diagnostics.c
index 2f265543..b0b3ef37 100644
--- a/agent/tcf/services/diagnostics.c
+++ b/agent/tcf/services/diagnostics.c
@@ -244,7 +244,7 @@ static void write_symbol(Channel * c, ContextAddress address) {
}
}
-#if ENABLE_Symbols
+#if ENABLE_DebugContext
typedef struct GetSymbolArgs {
char token[256];
@@ -258,17 +258,28 @@ static void get_symbol_cache_client(void * x) {
Context * ctx = args->ctx;
Symbol * sym = NULL;
ContextAddress addr = 0;
- int error = 0;
+ int error = ERR_SYM_NOT_FOUND;
- if (ctx->exited) {
- error = ERR_ALREADY_EXITED;
- }
- else if (find_symbol_by_name(ctx, STACK_NO_FRAME, 0, args->name, &sym) < 0) {
- error = errno;
+ if (ctx->exited) error = ERR_ALREADY_EXITED;
+
+#if ENABLE_Symbols
+ if (get_error_code(error) == ERR_SYM_NOT_FOUND) {
+ error = 0;
+ if (find_symbol_by_name(ctx, STACK_NO_FRAME, 0, args->name, &sym) < 0) error = errno;
+ if (!error && get_symbol_address(sym, &addr) < 0) error = errno;
}
- else if (get_symbol_address(sym, &addr) < 0) {
- error = errno;
+#endif
+
+#if ENABLE_RCBP_TEST
+ if (get_error_code(error) == ERR_SYM_NOT_FOUND) {
+ void * ptr = NULL;
+ int cls = 0;
+ error = 0;
+ if (find_test_symbol(ctx, args->name, &ptr, &cls) < 0) error = errno;
+ addr = (ContextAddress)ptr;
}
+#endif
+
cache_exit();
write_stringz(&c->out, "R");
@@ -281,7 +292,7 @@ static void get_symbol_cache_client(void * x) {
loc_free(args->name);
}
-#endif /* ENABLE_Symbols */
+#endif /* ENABLE_DebugContext */
static void command_get_symbol(char * token, Channel * c) {
char id[256];
@@ -305,7 +316,6 @@ static void command_get_symbol(char * token, Channel * c) {
error = ERR_ALREADY_EXITED;
}
else {
-#if ENABLE_Symbols
GetSymbolArgs args;
strlcpy(args.token, token, sizeof(args.token));
context_lock(ctx);
@@ -313,14 +323,6 @@ static void command_get_symbol(char * token, Channel * c) {
args.name = name;
cache_enter(get_symbol_cache_client, c, &args, sizeof(args));
return;
-#elif ENABLE_RCBP_TEST
- void * ptr = NULL;
- int cls = 0;
- error = (find_test_symbol(ctx, name, &ptr, &cls) < 0) ? errno : 0;
- addr = (ContextAddress)ptr;
-#else
- error = ERR_UNSUPPORTED;
-#endif
}
}
#else
diff --git a/agent/tcf/services/dwarfreloc.c b/agent/tcf/services/dwarfreloc.c
index 739b92bb..47af0673 100644
--- a/agent/tcf/services/dwarfreloc.c
+++ b/agent/tcf/services/dwarfreloc.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2010, 2014 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.
@@ -110,7 +110,7 @@ static void relocate(void * r) {
sym_value = info.value;
break;
case SHN_COMMON:
-#if SERVICE_Symbols && !ENABLE_SymbolsProxy
+#if SERVICE_Symbols && (!ENABLE_SymbolsProxy || ENABLE_SymbolsMux)
if (ctx != NULL) {
ContextAddress addr = 0;
if (elf_symbol_address(ctx, &info, &addr) < 0) exception(errno);
diff --git a/agent/tcf/services/elf-symbols.c b/agent/tcf/services/elf-symbols.c
index f989d658..c211518a 100644
--- a/agent/tcf/services/elf-symbols.c
+++ b/agent/tcf/services/elf-symbols.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2012, 2014 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.
@@ -19,7 +19,7 @@
#include <tcf/config.h>
-#if SERVICE_Symbols && !ENABLE_SymbolsProxy && ENABLE_ELF
+#if SERVICE_Symbols && (!ENABLE_SymbolsProxy || ENABLE_SymbolsMux) && ENABLE_ELF
#include <assert.h>
#include <tcf/framework/myalloc.h>
diff --git a/agent/tcf/services/elf-symbols.h b/agent/tcf/services/elf-symbols.h
index 348e8e84..989e09cb 100644
--- a/agent/tcf/services/elf-symbols.h
+++ b/agent/tcf/services/elf-symbols.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2012, 2014 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.
@@ -21,7 +21,7 @@
#include <tcf/config.h>
-#if SERVICE_Symbols && !ENABLE_SymbolsProxy && ENABLE_ELF
+#if SERVICE_Symbols && (!ENABLE_SymbolsProxy || ENABLE_SymbolsMux) && ENABLE_ELF
#include <tcf/framework/context.h>
#include <tcf/services/symbols.h>
@@ -63,7 +63,7 @@ extern int elf_tcf_symbol(Context * ctx, ELF_SymbolInfo * elf_sym, Symbol ** sym
*/
extern int elf_symbol_address(Context * ctx, ELF_SymbolInfo * info, ContextAddress * address);
-#endif /* SERVICE_Symbols && !ENABLE_SymbolsProxy && ENABLE_ELF */
+#endif /* SERVICE_Symbols && (!ENABLE_SymbolsProxy || ENABLE_SymbolsMux) && ENABLE_ELF */
#if ENABLE_ELF
diff --git a/agent/tcf/services/expressions.c b/agent/tcf/services/expressions.c
index a93944b2..82e11752 100644
--- a/agent/tcf/services/expressions.c
+++ b/agent/tcf/services/expressions.c
@@ -1088,7 +1088,8 @@ static int identifier(int mode, Value * scope, char * name, SYM_FLAGS flags, Val
return sym_class;
}
}
-#elif ENABLE_RCBP_TEST
+#endif
+#if ENABLE_RCBP_TEST
{
void * ptr = NULL;
int sym_class = 0;
@@ -2132,7 +2133,9 @@ static void funcccall_breakpoint(Context * ctx, void * args) {
for (i = 0; i < state->regs_cnt; i++) {
RegisterDefinition * r = state->regs[i];
if (context_write_reg(ctx, r, 0, r->size, state->regs_data + offs) < 0) exception(errno);
+#if SERVICE_Registers
send_event_register_changed(register2id(ctx, STACK_TOP_FRAME, r));
+#endif
offs += r->size;
}
state->regs_cnt = 0;
@@ -3551,7 +3554,7 @@ static void command_get_context(char * token, Channel * c) {
cache_enter(get_context_cache_client, c, &args, sizeof(args));
}
-#if ENABLE_Symbols
+#if ENABLE_Symbols && SERVICE_StackTrace
static int sym_cnt = 0;
static int sym_max = 0;
@@ -3573,7 +3576,7 @@ static void get_children_cache_client(void * x) {
int err = 0;
/* TODO: Expressions.getChildren - structures */
-#if ENABLE_Symbols
+#if ENABLE_Symbols && SERVICE_StackTrace
char parent_id[256];
{
Context * ctx;
@@ -3607,7 +3610,7 @@ static void get_children_cache_client(void * x) {
write_errno(&c->out, err);
write_stream(&c->out, '[');
-#if ENABLE_Symbols
+#if ENABLE_Symbols && SERVICE_StackTrace
{
int i;
for (i = 0; i < sym_cnt; i++) {
diff --git a/agent/tcf/services/linenumbers_elf.c b/agent/tcf/services/linenumbers_elf.c
index ffd2d696..c3c06161 100644
--- a/agent/tcf/services/linenumbers_elf.c
+++ b/agent/tcf/services/linenumbers_elf.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -22,7 +22,7 @@
#include <tcf/config.h>
-#if SERVICE_LineNumbers && !ENABLE_LineNumbersProxy && ENABLE_ELF
+#if SERVICE_LineNumbers && (!ENABLE_LineNumbersProxy || ENABLE_LineNumbersMux) && ENABLE_ELF
#include <errno.h>
#include <assert.h>
diff --git a/agent/tcf/services/linenumbers_mux.c b/agent/tcf/services/linenumbers_mux.c
index 229d79ce..2d245f09 100644
--- a/agent/tcf/services/linenumbers_mux.c
+++ b/agent/tcf/services/linenumbers_mux.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -14,15 +14,16 @@
*******************************************************************************/
/*
- * TCF service line Numbers - ELF version.
+ * Line Numbers Muliplexer - Provides a multiplexer to support several
+ * file format in the same TCF agent and in the same debug session.
*
- * The service associates locations in the source files with the corresponding
- * machine instruction addresses in the executable object.
+ * The multiplexer delegates actual search for line number info to info readers
+ * that are registed with add_line_numbers_reader().
*/
#include <tcf/config.h>
-#if SERVICE_LineNumbers && !ENABLE_LineNumbersProxy && ENABLE_LineNumbersMux
+#if SERVICE_LineNumbers && ENABLE_LineNumbersMux
#include <errno.h>
#include <assert.h>
@@ -35,18 +36,11 @@ static LineNumbersReader ** readers = NULL;
static unsigned reader_count = 0;
static unsigned max_reader_count = 0;
-#if ENABLE_ELF
-extern void elf_ini_line_numbers_lib(void);
-#endif
-#if defined(_WIN32) || defined(__CYGWIN__)
-extern void win32_ini_line_numbers_lib(void);
-#endif
-
int line_to_address(Context * ctx, char * file_name, int line, int column,
LineNumbersCallBack * client, void * args) {
unsigned i;
for (i = 0; i < reader_count; i++) {
- if (readers[i]->line_to_address(ctx, file_name, line, column, client, args) != 0) {
+ if (readers[i]->line_to_address(ctx, file_name, line, column, client, args) < 0) {
return -1;
}
}
@@ -54,10 +48,10 @@ int line_to_address(Context * ctx, char * file_name, int line, int column,
}
int address_to_line(Context * ctx, ContextAddress addr0, ContextAddress addr1,
- LineNumbersCallBack * client, void * args) {
+ LineNumbersCallBack * client, void * args) {
unsigned i;
for (i = 0; i < reader_count; i++) {
- if (readers[i]->address_to_line(ctx, addr0, addr1, client, args) != 0) {
+ if (readers[i]->address_to_line(ctx, addr0, addr1, client, args) < 0) {
return -1;
}
}
@@ -67,21 +61,31 @@ int address_to_line(Context * ctx, ContextAddress addr0, ContextAddress addr1,
int add_line_numbers_reader(LineNumbersReader * reader) {
if (reader_count >= max_reader_count) {
max_reader_count += 2;
- readers = (LineNumbersReader **)loc_realloc(readers, max_reader_count * sizeof(reader));
+ readers = (LineNumbersReader **)loc_realloc(readers, max_reader_count * sizeof(LineNumbersReader *));
}
- readers[reader_count] = reader;
reader->reader_index = reader_count;
- reader_count++;
+ readers[reader_count++] = reader;
return 0;
}
+extern void elf_reader_ini_line_numbers_lib(void);
+extern void win32_reader_ini_line_numbers_lib(void);
+extern void proxy_reader_ini_line_numbers_lib(void);
+
void ini_line_numbers_lib(void) {
+ /*
+ * We keep this to limit the impact of changes. In the ideal world, those
+ * initialization routines should be called from the agent initialization code.
+ */
#if ENABLE_ELF
elf_reader_ini_line_numbers_lib();
#endif
#if ENABLE_PE
win32_reader_ini_line_numbers_lib();
#endif
+#if ENABLE_LineNumbersProxy
+ proxy_reader_ini_line_numbers_lib();
+#endif
}
-#endif /* SERVICE_LineNumbers && !ENABLE_LineNumbersProxy && ENABLE_ELF */
+#endif /* ENABLE_LineNumbersMux && SERVICE_LineNumbers */
diff --git a/agent/tcf/services/linenumbers_mux.h b/agent/tcf/services/linenumbers_mux.h
index d36b21f5..a74c3118 100644
--- a/agent/tcf/services/linenumbers_mux.h
+++ b/agent/tcf/services/linenumbers_mux.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -36,6 +36,7 @@ typedef struct LineNumbersReader {
} LineNumbersReader;
#ifdef LINENUMBERS_READER_PREFIX
+
#define JOIN(a,b) JOIN1(a,b)
#define JOIN1(a,b) a##b
#define READER_NAME(name) JOIN(LINENUMBERS_READER_PREFIX,name)
@@ -49,10 +50,8 @@ extern int line_to_address(Context * ctx, char * file, int line, int column, Lin
extern int address_to_line(Context * ctx, ContextAddress addr0, ContextAddress addr1, LineNumbersCallBack * client, void * args);
extern void ini_line_numbers_lib(void);
-static LineNumbersReader line_numbers_reader = { line_to_address, address_to_line};
-#else /* SYM_READER_PREFIX */
-extern void elf_reader_ini_line_numbers_lib();
-extern void win32_reader_ini_line_numbers_lib();
+static LineNumbersReader line_numbers_reader = { line_to_address, address_to_line };
+
#endif /* SYM_READER_PREFIX */
extern int add_line_numbers_reader(LineNumbersReader * reader);
diff --git a/agent/tcf/services/linenumbers_proxy.c b/agent/tcf/services/linenumbers_proxy.c
index ab5c804a..48611a8a 100644
--- a/agent/tcf/services/linenumbers_proxy.c
+++ b/agent/tcf/services/linenumbers_proxy.c
@@ -34,6 +34,10 @@
#include <tcf/framework/exceptions.h>
#include <tcf/services/memorymap.h>
#include <tcf/services/linenumbers.h>
+#if ENABLE_LineNumbersMux
+#define LINENUMBERS_READER_PREFIX proxy_reader_
+#include <tcf/services/linenumbers_mux.h>
+#endif
#define HASH_SIZE (16 * MEM_USAGE_FACTOR - 1)
@@ -408,6 +412,9 @@ void ini_line_numbers_lib(void) {
}
#endif
add_channel_close_listener(channel_close_listener);
+#if ENABLE_LineNumbersMux
+ add_line_numbers_reader(&line_numbers_reader);
+#endif
}
#endif /* ENABLE_LineNumbersProxy */
diff --git a/agent/tcf/services/linenumbers_win32.c b/agent/tcf/services/linenumbers_win32.c
index d96c66df..1f6c76db 100644
--- a/agent/tcf/services/linenumbers_win32.c
+++ b/agent/tcf/services/linenumbers_win32.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -21,7 +21,7 @@
#include <tcf/config.h>
-#if SERVICE_LineNumbers && !ENABLE_LineNumbersProxy && ENABLE_PE
+#if SERVICE_LineNumbers && (!ENABLE_LineNumbersProxy || ENABLE_LineNumbersMux) && ENABLE_PE
#include <errno.h>
#include <assert.h>
@@ -247,4 +247,4 @@ void ini_line_numbers_lib(void) {
#endif
}
-#endif /* SERVICE_LineNumbers && !ENABLE_LineNumbersProxy && defined(_MSC_VER) && !ENABLE_ELF */
+#endif /* SERVICE_LineNumbers && (!ENABLE_LineNumbersProxy || ENABLE_LineNumbersMux) && ENABLE_PE */
diff --git a/agent/tcf/services/runctrl.c b/agent/tcf/services/runctrl.c
index 09ff5244..2b107f2b 100644
--- a/agent/tcf/services/runctrl.c
+++ b/agent/tcf/services/runctrl.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -1304,6 +1304,7 @@ int is_intercepted(Context * ctx) {
}
#if EN_STEP_LINE
+
static int is_same_line(CodeArea * x, CodeArea * y) {
if (x == NULL || y == NULL) return 0;
if (x->start_line != y->start_line) return 0;
@@ -1363,6 +1364,8 @@ static int is_hidden_function(Context * ctx, ContextAddress ip,
return 0;
}
+#if EN_STEP_OVER
+
#if ENABLE_Symbols
static void get_machine_code_area(CodeArea * area, void * args) {
*(CodeArea **)args = (CodeArea *)tmp_alloc(sizeof(CodeArea));
@@ -1388,6 +1391,8 @@ static int is_within_function_epilogue(Context * ctx, ContextAddress ip) {
#endif
return 0;
}
+
+#endif
#endif
#if EN_STEP_OVER
diff --git a/agent/tcf/services/stacktrace.c b/agent/tcf/services/stacktrace.c
index c473efe2..39e516b1 100644
--- a/agent/tcf/services/stacktrace.c
+++ b/agent/tcf/services/stacktrace.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -577,11 +577,6 @@ int get_frame_info(Context * ctx, int frame, StackFrame ** info) {
return 0;
}
-int is_top_frame(Context * ctx, int frame) {
- if (ctx == NULL || !context_has_state(ctx)) return 0;
- return frame == 0 || frame == STACK_TOP_FRAME;
-}
-
static void flush_stack_trace(Context * ctx, void * args) {
invalidate_stack_trace(EXT(ctx));
}
diff --git a/agent/tcf/services/stacktrace.h b/agent/tcf/services/stacktrace.h
index 22c93f59..a6b6dcbe 100644
--- a/agent/tcf/services/stacktrace.h
+++ b/agent/tcf/services/stacktrace.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -24,6 +24,17 @@
#include <tcf/framework/context.h>
#include <tcf/services/stacktrace-ext.h>
+
+/*
+ * Return 1 if 'frame' is the top frame of the context call stack.
+ */
+#define is_top_frame(ctx, frame) ((frame) == 0 || (frame) == STACK_TOP_FRAME)
+
+/*
+ * Get frame number for 'info'.
+ */
+#define get_info_frame(ctx, info) (info ? info->frame : STACK_NO_FRAME)
+
#if SERVICE_StackTrace || ENABLE_ContextProxy
/*
@@ -41,21 +52,11 @@ extern int get_prev_frame(Context * ctx, int frame);
extern int get_next_frame(Context * ctx, int frame);
/*
- * Return 1 if 'frame' is the top frame of the context.
- */
-extern int is_top_frame(Context * ctx, int frame);
-
-/*
* Get information about given stack frame.
*/
extern int get_frame_info(Context * ctx, int frame, StackFrame ** info);
/*
- * Get frame number for 'info'.
- */
-#define get_info_frame(ctx, info) (info ? info->frame : STACK_NO_FRAME)
-
-/*
* For given context and its registers in a stack frame,
* compute stack frame location and next frame register values.
* If frame info is not available, do nothing.
@@ -71,9 +72,8 @@ extern void ini_stack_trace_service(Protocol *, TCFBroadcastGroup *);
#else /* SERVICE_StackTrace */
+#define get_top_frame(ctx) 0
#define get_frame_info(ctx, frame, info) (errno = ERR_UNSUPPORTED, -1)
-#define get_info_frame(ctx, info) STACK_NO_FRAME
-#define is_top_frame(ctx, frame) (frame == STACK_TOP_FRAME)
#endif /* SERVICE_StackTrace */
#endif /* D_stacktrace */
diff --git a/agent/tcf/services/symbols_elf.c b/agent/tcf/services/symbols_elf.c
index 42a73bfc..ffae7223 100644
--- a/agent/tcf/services/symbols_elf.c
+++ b/agent/tcf/services/symbols_elf.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -23,7 +23,7 @@
#include <tcf/config.h>
-#if SERVICE_Symbols && !ENABLE_SymbolsProxy && ENABLE_ELF
+#if SERVICE_Symbols && (!ENABLE_SymbolsProxy || ENABLE_SymbolsMux) && ENABLE_ELF
#if defined(_WRS_KERNEL)
# include <symLib.h>
@@ -49,9 +49,6 @@
#include <tcf/services/symbols.h>
#include <tcf/services/elf-symbols.h>
#include <tcf/services/vm.h>
-#if ENABLE_RCBP_TEST
-# include <tcf/main/test.h>
-#endif
#if ENABLE_SymbolsMux
#define SYM_READER_PREFIX elf_reader_
#include <tcf/services/symbols_mux.h>
@@ -201,7 +198,7 @@ static int get_sym_context(Context * ctx, int frame, ContextAddress addr) {
if (frame == STACK_NO_FRAME) {
sym_ip = addr;
}
- else if (frame == STACK_TOP_FRAME) {
+ else if (is_top_frame(ctx, frame)) {
if (!ctx->stopped) {
errno = ERR_IS_RUNNING;
return -1;
@@ -1188,22 +1185,6 @@ int find_symbol_by_name(Context * ctx, int frame, ContextAddress ip, const char
}
}
-#if ENABLE_RCBP_TEST
- if (find_symbol_list == NULL) {
- int sym_class = 0;
- void * address = NULL;
- if (find_test_symbol(ctx, name, &address, &sym_class) >= 0) {
- Symbol * sym = alloc_symbol();
- sym->ctx = context_get_group(ctx, CONTEXT_GROUP_SYMBOLS);
- sym->frame = STACK_NO_FRAME;
- sym->address = (ContextAddress)address;
- sym->has_address = 1;
- sym->sym_class = sym_class;
- add_to_find_symbol_buf(sym);
- }
- }
-#endif
-
if (error == 0 && find_symbol_list == NULL) {
/* Search in pub names of all other files */
ELF_File * file = elf_list_first(sym_ctx, 0, ~(ContextAddress)0);
@@ -1467,7 +1448,6 @@ int find_symbol_by_addr(Context * ctx, int frame, ContextAddress addr, Symbol **
find_symbol_list = NULL;
if (!set_trap(&trap)) return -1;
- if (frame == STACK_TOP_FRAME && (frame = get_top_frame(ctx)) < 0) exception(errno);
if (get_sym_context(ctx, frame, addr) < 0) exception(errno);
find_unit(sym_ctx, addr, &loc);
if (addr == sym_ip) ip = loc;
@@ -2029,12 +2009,15 @@ int get_stack_tracing_info(Context * ctx, ContextAddress rt_addr, StackTracingIn
const char * get_symbol_file_name(Context * ctx, MemoryRegion * module) {
int error = 0;
- ELF_File * file = module ? elf_open_memory_region_file(module, &error) : NULL;
- file = get_dwarf_file(file);
+ ELF_File * file = NULL;
+ if (module == NULL) {
+ errno = 0;
+ return NULL;
+ }
+ file = get_dwarf_file(elf_open_memory_region_file(module, &error));
errno = error;
- if (file == NULL && module == NULL) return NULL;
- if (file == NULL) return module->file_name;
- return file->name;
+ if (file != NULL) return file->name;
+ return NULL;
}
#if ENABLE_MemoryMap
@@ -2065,8 +2048,7 @@ static int reader_is_valid(Context * ctx, ContextAddress addr) {
ELF_File * file = NULL;
ELF_Section * sec = NULL;
elf_map_to_link_time_address(ctx, addr, &file, &sec);
- if (file != NULL) return 1;
- return 0;
+ return file != NULL;
}
#endif
diff --git a/agent/tcf/services/symbols_mux.c b/agent/tcf/services/symbols_mux.c
index c67e015c..8a4b7ee0 100644
--- a/agent/tcf/services/symbols_mux.c
+++ b/agent/tcf/services/symbols_mux.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2012, 2014 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.
@@ -14,13 +14,17 @@
*******************************************************************************/
/*
- * Symbols Muliplexer - Provides a symbol multiplexer to support several
+ * Symbols Muliplexer - Provides a multiplexer to support several
* file format in the same TCF agent and in the same debug session.
+ *
+ * The multiplexer delegates actual search for symbols info to info readers
+ * that are registed with add_symbols_reader().
*/
#include <tcf/config.h>
-#if ENABLE_SymbolsMux && SERVICE_Symbols
+#if SERVICE_Symbols && ENABLE_SymbolsMux
+
#include <assert.h>
#include <stdio.h>
#include <tcf/services/symbols.h>
@@ -36,10 +40,11 @@ static unsigned max_reader_cnt = 0;
static Context * find_symbol_ctx = NULL;
static Symbol ** find_symbol_list = NULL;
-static int get_sym_addr(Context * ctx, int frame, ContextAddress addr,
- ContextAddress * sym_addr) {
- if (frame == STACK_NO_FRAME) *sym_addr = addr;
- else if (frame == STACK_TOP_FRAME) {
+static int get_sym_addr(Context * ctx, int frame, ContextAddress addr, ContextAddress * sym_addr) {
+ if (frame == STACK_NO_FRAME) {
+ *sym_addr = addr;
+ }
+ else if (is_top_frame(ctx, frame)) {
if (!ctx->stopped) {
errno = ERR_IS_RUNNING;
return -1;
@@ -56,7 +61,7 @@ static int get_sym_addr(Context * ctx, int frame, ContextAddress addr,
if (get_frame_info(ctx, frame, &info) < 0) return -1;
if (read_reg_value(info, get_PC_definition(ctx), &ip) < 0) return -1;
if (!info->is_top_frame && ip > 0) ip--;
- *sym_addr = (ContextAddress) ip;
+ *sym_addr = (ContextAddress)ip;
}
return 0;
}
@@ -70,7 +75,7 @@ static int get_symbol_reader(Context * ctx, int frame, ContextAddress addr, Symb
*sym_reader = readers[0];
return 0;
}
- if (get_sym_addr(ctx, frame, addr, &sym_addr) == -1) return -1;
+ if (get_sym_addr(ctx, frame, addr, &sym_addr) < 0) return -1;
for (i = 0; i < reader_cnt; i++) {
if (readers[i]->reader_is_valid(ctx, sym_addr)) {
*sym_reader = readers[i];
@@ -80,24 +85,28 @@ static int get_symbol_reader(Context * ctx, int frame, ContextAddress addr, Symb
return 0;
}
-int find_symbol_by_name(Context * ctx, int frame, ContextAddress ip, const char * name,
- Symbol ** res) {
+int find_symbol_by_name(Context * ctx, int frame, ContextAddress ip, const char * name, Symbol ** res) {
unsigned i;
find_symbol_ctx = NULL;
for (i = 0; i < reader_cnt; i++) find_symbol_list[i] = NULL;
for (i = 0; i < reader_cnt; i++) {
- Symbol * sym;
+ Symbol * sym = NULL;
if (readers[i]->find_symbol_by_name(ctx, frame, ip, name, &sym) == 0) {
- find_symbol_list[i] = sym;
assert(sym != NULL);
+ find_symbol_list[i] = sym;
if (find_symbol_ctx == NULL) {
+ if (readers[i]->find_next_symbol(&find_symbol_list[i]) < 0) {
+ find_symbol_list[i] = NULL;
+ }
find_symbol_ctx = ctx;
*res = sym;
}
}
- else if (errno != ERR_SYM_NOT_FOUND) return -1;
+ else if (get_error_code(errno) != ERR_SYM_NOT_FOUND) {
+ return -1;
+ }
}
if (find_symbol_ctx != NULL) return 0;
errno = ERR_SYM_NOT_FOUND;
@@ -107,23 +116,28 @@ int find_symbol_by_name(Context * ctx, int frame, ContextAddress ip, const char
int find_symbol_in_scope(Context * ctx, int frame, ContextAddress ip, Symbol * scope,
const char * name, Symbol ** res) {
unsigned i;
- SymbolReader * reader;
- for (i = 0; i < reader_cnt; i++) find_symbol_list[i] = NULL;
find_symbol_ctx = NULL;
+ for (i = 0; i < reader_cnt; i++) find_symbol_list[i] = NULL;
- if (get_symbol_reader(ctx, frame,ip,&reader) == -1) return -1;
- if (reader != NULL) {
+ for (i = 0; i < reader_cnt; i++) {
Symbol * sym = NULL;
- if (reader->find_symbol_in_scope(ctx, frame, ip, scope, name, &sym) == 0) {
- find_symbol_list[reader->reader_index] = sym;
- *res = sym;
- find_symbol_ctx = ctx;
- assert (sym != NULL);
- return 0;
+ if (readers[i]->find_symbol_in_scope(ctx, frame, ip, scope, name, &sym) == 0) {
+ assert(sym != NULL);
+ find_symbol_list[i] = sym;
+ if (find_symbol_ctx == NULL) {
+ if (readers[i]->find_next_symbol(&find_symbol_list[i]) < 0) {
+ find_symbol_list[i] = NULL;
+ }
+ find_symbol_ctx = ctx;
+ *res = sym;
+ }
+ }
+ else if (get_error_code(errno) != ERR_SYM_NOT_FOUND) {
+ return -1;
}
- else return -1;
}
+ if (find_symbol_ctx != NULL) return 0;
errno = ERR_SYM_NOT_FOUND;
return -1;
}
@@ -132,20 +146,18 @@ int find_symbol_by_addr(Context * ctx, int frame, ContextAddress addr, Symbol **
unsigned i;
SymbolReader * reader;
- for (i = 0; i < reader_cnt; i++) find_symbol_list[i] = NULL;
find_symbol_ctx = NULL;
+ for (i = 0; i < reader_cnt; i++) find_symbol_list[i] = NULL;
- if (get_symbol_reader(ctx, frame, addr, &reader) == -1) return -1;
+ if (get_symbol_reader(ctx, frame, addr, &reader) < 0) return -1;
if (reader != NULL) {
- Symbol * sym;
- if (reader->find_symbol_by_addr(ctx, frame, addr, &sym) == 0) {
- find_symbol_list[reader->reader_index] = sym;
- *res = sym;
- assert (sym != NULL);
- find_symbol_ctx = ctx;
- return 0;
+ i = reader->reader_index;
+ if (reader->find_symbol_by_addr(ctx, frame, addr, res) < 0) return -1;
+ if (readers[i]->find_next_symbol(&find_symbol_list[i]) < 0) {
+ find_symbol_list[i] = NULL;
}
- else return -1;
+ find_symbol_ctx = ctx;
+ return 0;
}
errno = ERR_SYM_NOT_FOUND;
return -1;
@@ -160,15 +172,11 @@ int find_next_symbol(Symbol ** sym) {
}
for (i = 0; i < reader_cnt; i++) {
if (find_symbol_list[i] != NULL) {
- if (find_symbol_list[i] != *sym) {
- *sym = find_symbol_list[i];
- return 0;
- }
- find_symbol_list[i] = NULL;
- if (readers[i]->find_next_symbol(sym) == 0) {
- find_symbol_list[i] = *sym;
- return 0;
+ *sym = find_symbol_list[i];
+ if (readers[i]->find_next_symbol(&find_symbol_list[i]) < 0) {
+ find_symbol_list[i] = NULL;
}
+ return 0;
}
}
errno = ERR_SYM_NOT_FOUND;
@@ -177,7 +185,7 @@ int find_next_symbol(Symbol ** sym) {
int enumerate_symbols(Context * ctx, int frame, EnumerateSymbolsCallBack * call_back, void * args) {
SymbolReader * reader = NULL;
- if (get_symbol_reader(ctx, frame, 0, &reader) == -1) return 0;
+ if (get_symbol_reader(ctx, frame, 0, &reader) < 0) return 0;
if (reader) return reader->enumerate_symbols(ctx, frame, call_back, args);
return 0;
}
@@ -212,146 +220,127 @@ int id2symbol(const char * id, Symbol ** res) {
ContextAddress is_plt_section(Context * ctx, ContextAddress addr) {
SymbolReader * reader = NULL;
- if (get_symbol_reader(ctx, STACK_NO_FRAME, addr, &reader) == -1) return 0;
+ if (get_symbol_reader(ctx, STACK_NO_FRAME, addr, &reader) < 0) return 0;
if (reader) return reader->is_plt_section(ctx, addr);
return 0;
}
-int get_stack_tracing_info(Context * ctx, ContextAddress rt_addr, StackTracingInfo ** info) {
+int get_stack_tracing_info(Context * ctx, ContextAddress addr, StackTracingInfo ** info) {
SymbolReader * reader = NULL;
*info = NULL;
- if (get_symbol_reader(ctx, STACK_NO_FRAME, rt_addr, &reader) == -1) return 0;
- if (reader) return reader->get_stack_tracing_info(ctx, rt_addr, info);
+ if (get_symbol_reader(ctx, STACK_NO_FRAME, addr, &reader) < 0) return 0;
+ if (reader) return reader->get_stack_tracing_info(ctx, addr, info);
return 0;
}
const char * get_symbol_file_name(Context * ctx, MemoryRegion * module) {
unsigned i;
- const char * name;
+ if (module == NULL) {
+ errno = 0;
+ return NULL;
+ }
for (i = 0; i < reader_cnt; i++) {
- name = readers[i]->get_symbol_file_name(ctx, module);
- if (name != NULL) {
- if (module == NULL) return name;
- if (name != module->file_name) return name;
- }
+ const char * name = readers[i]->get_symbol_file_name(ctx, module);
+ if (name != NULL) return name;
}
- if (module == NULL) return NULL;
- else return module->file_name;
+ errno = 0;
+ return NULL;
}
int get_symbol_class(const Symbol * sym, int * sym_class) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_class(sym, sym_class);
}
int get_symbol_type(const Symbol * sym, Symbol ** type) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_type(sym, type);
}
int get_symbol_type_class(const Symbol * sym, int * type_class) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_type_class(sym, type_class);
}
int get_symbol_update_policy(const Symbol * sym, char ** id, int * policy) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_update_policy(sym, id, policy);
}
int get_symbol_name(const Symbol * sym, char ** name) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_name(sym, name);
}
int get_symbol_size(const Symbol * sym, ContextAddress * size) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_size(sym, size);
}
int get_symbol_base_type(const Symbol * sym, Symbol ** base_type) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_base_type(sym, base_type);
}
int get_symbol_index_type(const Symbol * sym, Symbol ** index_type) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_index_type(sym, index_type);
}
int get_symbol_container(const Symbol * sym, Symbol ** container) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_container(sym, container);
}
int get_symbol_length(const Symbol * sym, ContextAddress * length) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_length(sym, length);
}
int get_symbol_lower_bound(const Symbol * sym, int64_t * value) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_lower_bound(sym, value);
-
}
int get_symbol_children(const Symbol * sym, Symbol *** children, int * count) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_children(sym, children, count);
}
int get_array_symbol(const Symbol * sym, ContextAddress length, Symbol ** ptr) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_array_symbol(sym, length, ptr);
}
int get_location_info(const Symbol * sym, LocationInfo ** res) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_location_info(sym, res);
}
int get_symbol_flags(const Symbol * sym, SYM_FLAGS * flags) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_flags(sym, flags);
}
int get_symbol_frame(const Symbol * sym, Context ** ctx, int * frame) {
- SymbolReader * reader = *(SymbolReader **) sym;
- assert(reader != NULL);
+ SymbolReader * reader = *(SymbolReader **)sym;
return reader->get_symbol_frame(sym, ctx, frame);
}
-int get_funccall_info(const Symbol * func, const Symbol ** args, unsigned args_cnt,
- FunctionCallInfo ** res) {
- SymbolReader * reader = *(SymbolReader **) func;
- assert(reader != NULL);
+int get_funccall_info(const Symbol * func, const Symbol ** args, unsigned args_cnt, FunctionCallInfo ** res) {
+ SymbolReader * reader = *(SymbolReader **)func;
return reader->get_funccall_info(func, args, args_cnt, res);
}
-int get_context_isa(Context * ctx, ContextAddress ip, const char ** isa,
+int get_context_isa(Context * ctx, ContextAddress addr, const char ** isa,
ContextAddress * range_addr, ContextAddress * range_size) {
SymbolReader * reader = NULL;
*isa = NULL;
- *range_addr = ip;
+ *range_addr = addr;
*range_size = 1;
- if (get_symbol_reader(ctx, STACK_NO_FRAME, ip, &reader) == -1) return 0;
- if (reader != NULL) return reader->get_context_isa(ctx, ip, isa, range_addr, range_size);
+ if (get_symbol_reader(ctx, STACK_NO_FRAME, addr, &reader) < 0) return 0;
+ if (reader != NULL) return reader->get_context_isa(ctx, addr, isa, range_addr, range_size);
return 0;
}
@@ -359,27 +348,33 @@ int add_symbols_reader(SymbolReader * reader) {
unsigned i;
if (reader_cnt >= max_reader_cnt) {
max_reader_cnt += 2;
- readers = (SymbolReader **)loc_realloc(readers, max_reader_cnt * sizeof(reader));
- find_symbol_list = (Symbol **) loc_realloc(find_symbol_list, max_reader_cnt * sizeof(Symbol *));
+ readers = (SymbolReader **)loc_realloc(readers, max_reader_cnt * sizeof(SymbolReader *));
+ find_symbol_list = (Symbol **)loc_realloc(find_symbol_list, max_reader_cnt * sizeof(Symbol *));
}
- readers[reader_cnt] = reader;
reader->reader_index = reader_cnt;
- reader_cnt++;
+ readers[reader_cnt++] = reader;
for (i = 0; i < reader_cnt; i++) find_symbol_list[i] = NULL;
find_symbol_ctx = NULL;
return 0;
}
+extern void elf_reader_ini_symbols_lib(void);
+extern void win32_reader_ini_symbols_lib(void);
+extern void proxy_reader_ini_symbols_lib(void);
+
void ini_symbols_lib(void) {
/*
* We keep this to limit the impact of changes. In the ideal world, those
* initialization routines should be called from the agent initialization code.
*/
+#if ENABLE_ELF
+ elf_reader_ini_symbols_lib();
+#endif
#if ENABLE_PE
win32_reader_ini_symbols_lib();
#endif
-#if ENABLE_ELF
- elf_reader_ini_symbols_lib();
+#if ENABLE_SymbolsProxy
+ proxy_reader_ini_symbols_lib();
#endif
}
#endif /* Enable_SymbolsMux && SERVICE_Symbols */
diff --git a/agent/tcf/services/symbols_mux.h b/agent/tcf/services/symbols_mux.h
index a93765e8..962be844 100644
--- a/agent/tcf/services/symbols_mux.h
+++ b/agent/tcf/services/symbols_mux.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -63,6 +63,7 @@ typedef struct SymbolReader {
}SymbolReader;
#ifdef SYM_READER_PREFIX
+
#define JOIN(a,b) JOIN1(a,b)
#define JOIN1(a,b) a##b
#define READER_NAME(name) JOIN(SYM_READER_PREFIX,name)
@@ -140,9 +141,7 @@ static SymbolReader symbol_reader = { find_symbol_by_name, find_symbol_in_scope,
get_symbol_flags, get_symbol_frame, get_array_symbol, is_plt_section, get_location_info,
get_funccall_info, get_stack_tracing_info, get_symbol_file_name,
get_context_isa, reader_is_valid};
-#else
-extern void win32_reader_ini_symbols_lib(void);
-extern void elf_reader_ini_symbols_lib(void);
+
#endif /* SYM_READER_PREFIX */
extern int add_symbols_reader(SymbolReader * reader);
diff --git a/agent/tcf/services/symbols_proxy.c b/agent/tcf/services/symbols_proxy.c
index f2c65a62..0cb65de1 100644
--- a/agent/tcf/services/symbols_proxy.c
+++ b/agent/tcf/services/symbols_proxy.c
@@ -33,8 +33,9 @@
#include <tcf/services/memorymap.h>
#include <tcf/services/symbols.h>
#include <tcf/services/vm.h>
-#if ENABLE_RCBP_TEST
-# include <tcf/main/test.h>
+#if ENABLE_SymbolsMux
+#define SYM_READER_PREFIX proxy_reader_
+#include <tcf/services/symbols_mux.h>
#endif
#define HASH_SIZE (4 * MEM_USAGE_FACTOR - 1)
@@ -58,6 +59,7 @@ typedef struct SymbolsCache {
LINK link_find_by_addr[HASH_SIZE];
LINK link_find_in_scope[HASH_SIZE];
LINK link_list[HASH_SIZE];
+ LINK link_file[HASH_SIZE];
LINK link_frame[HASH_SIZE];
LINK link_address[HASH_SIZE];
LINK link_location[HASH_SIZE];
@@ -164,6 +166,24 @@ typedef struct AddressInfoCache {
int disposed;
} AddressInfoCache;
+typedef struct FileInfoCache {
+ unsigned magic;
+ LINK link_syms;
+ LINK link_flush;
+ AbstractCache cache;
+ ReplyHandlerInfo * pending;
+ ErrorReport * error;
+ Context * ctx;
+ ContextAddress addr;
+
+ char * file_name;
+ ContextAddress range_addr;
+ ContextAddress range_size;
+ ErrorReport * file_error;
+
+ int disposed;
+} FileInfoCache;
+
typedef struct LocationInfoCache {
unsigned magic;
LINK link_syms;
@@ -185,6 +205,7 @@ typedef struct LocationInfoCache {
#define syms2find(A) ((FindSymCache *)((char *)(A) - offsetof(FindSymCache, link_syms)))
#define syms2frame(A)((StackFrameCache *)((char *)(A) - offsetof(StackFrameCache, link_syms)))
#define syms2address(A)((AddressInfoCache *)((char *)(A) - offsetof(AddressInfoCache, link_syms)))
+#define syms2file(A) ((FileInfoCache *)((char *)(A) - offsetof(FileInfoCache, link_syms)))
#define syms2location(A)((LocationInfoCache *)((char *)(A) - offsetof(LocationInfoCache, link_syms)))
#define sym2arr(A) ((ArraySymCache *)((char *)(A) - offsetof(ArraySymCache, link_sym)))
@@ -193,9 +214,13 @@ typedef struct LocationInfoCache {
#define flush2find(A) ((FindSymCache *)((char *)(A) - offsetof(FindSymCache, link_flush)))
#define flush2frame(A)((StackFrameCache *)((char *)(A) - offsetof(StackFrameCache, link_flush)))
#define flush2address(A)((AddressInfoCache *)((char *)(A) - offsetof(AddressInfoCache, link_flush)))
+#define flush2file(A) ((FileInfoCache *)((char *)(A) - offsetof(FileInfoCache, link_flush)))
#define flush2location(A)((LocationInfoCache *)((char *)(A) - offsetof(LocationInfoCache, link_flush)))
struct Symbol {
+#if ENABLE_SymbolsMux
+ SymbolReader * reader;
+#endif
unsigned magic;
SymInfoCache * cache;
};
@@ -218,6 +243,7 @@ static const char * SYMBOLS = "Symbols";
#define MAGIC_FIND 0x89058765
#define MAGIC_FRAME 0x10837608
#define MAGIC_ADDR 0x28658765
+#define MAGIC_FILE 0x87653487
#define MAGIC_LOC 0x09878751
static void flush_symbol(LINK * l);
@@ -255,6 +281,9 @@ static void symbols_cleanup_event(void * arg) {
static Symbol * alloc_symbol(void) {
Symbol * s = (Symbol *)tmp_alloc_zero(sizeof(Symbol));
+#if ENABLE_SymbolsMux
+ s->reader = &symbol_reader;
+#endif
s->magic = MAGIC_SYMBOL;
return s;
}
@@ -285,6 +314,10 @@ static unsigned hash_address(Context * ctx) {
return ((uintptr_t)ctx >> 4) % HASH_SIZE;
}
+static unsigned hash_file(Context * ctx) {
+ return ((uintptr_t)ctx >> 4) % HASH_SIZE;
+}
+
static SymbolsCache * get_symbols_cache(void) {
LINK * l = NULL;
SymbolsCache * syms = NULL;
@@ -313,6 +346,7 @@ static SymbolsCache * get_symbols_cache(void) {
list_init(syms->link_find_by_addr + i);
list_init(syms->link_find_in_scope + i);
list_init(syms->link_list + i);
+ list_init(syms->link_file + i);
list_init(syms->link_frame + i);
list_init(syms->link_address + i);
list_init(syms->link_location + i);
@@ -452,6 +486,25 @@ static void free_address_info_cache(AddressInfoCache * c) {
}
}
+static void free_file_info_cache(FileInfoCache * c) {
+ assert(c->magic == MAGIC_FILE);
+ assert(!c->disposed || c->pending == NULL);
+ if (!c->disposed) {
+ list_remove(&c->link_syms);
+ list_remove(&c->link_flush);
+ c->disposed = 1;
+ }
+ if (c->pending == NULL) {
+ c->magic = 0;
+ cache_dispose(&c->cache);
+ release_error_report(c->error);
+ release_error_report(c->file_error);
+ context_unlock(c->ctx);
+ loc_free(c->file_name);
+ loc_free(c);
+ }
+}
+
static void free_location_info_cache(LocationInfoCache * c) {
assert(c->magic == MAGIC_LOC);
assert(!c->disposed || c->pending == NULL);
@@ -522,6 +575,10 @@ static void flush_symbol(LINK * l) {
AddressInfoCache * c = flush2address(l);
if (c->cache.wait_list_cnt == 0) free_address_info_cache(c);
}
+ else if (magic == MAGIC_FILE) {
+ FileInfoCache * c = flush2file(l);
+ if (c->cache.wait_list_cnt == 0) free_file_info_cache(c);
+ }
else if (magic == MAGIC_LOC) {
LocationInfoCache * c = flush2location(l);
if (c->cache.wait_list_cnt == 0) free_location_info_cache(c);
@@ -534,6 +591,30 @@ static Channel * get_channel(SymbolsCache * syms) {
return syms->channel;
}
+static uint64_t get_symbol_ip(Context * ctx, int * frame, ContextAddress addr) {
+ uint64_t ip = 0;
+ if (*frame == STACK_NO_FRAME) {
+ ip = addr;
+ }
+ else if (is_top_frame(ctx, *frame)) {
+ if (!ctx->stopped) {
+ exception(ERR_IS_RUNNING);
+ }
+ if (ctx->exited) {
+ exception(ERR_ALREADY_EXITED);
+ }
+ *frame = get_top_frame(ctx);
+ ip = get_regs_PC(ctx);
+ }
+ else {
+ StackFrame * info = NULL;
+ if (get_frame_info(ctx, *frame, &info) < 0) exception(errno);
+ if (read_reg_value(info, get_PC_definition(ctx), &ip) < 0) exception(errno);
+ *frame = info->frame;
+ }
+ return ip;
+}
+
static void read_context_data(InputStream * inp, const char * name, void * args) {
char id[256];
SymInfoCache * s = (SymInfoCache *)args;
@@ -703,16 +784,7 @@ int find_symbol_by_name(Context * ctx, int frame, ContextAddress addr, const cha
if (!set_trap(&trap)) return -1;
- if (frame == STACK_NO_FRAME) {
- ip = addr;
- }
- else {
- StackFrame * info = NULL;
- if (frame == STACK_TOP_FRAME && (frame = get_top_frame(ctx)) < 0) exception(errno);;
- if (get_frame_info(ctx, frame, &info) < 0) exception(errno);
- if (read_reg_value(info, get_PC_definition(ctx), &ip) < 0) exception(errno);
- }
-
+ ip = get_symbol_ip(ctx, &frame, addr);
h = hash_find(ctx, name, ip);
syms = get_symbols_cache();
for (l = syms->link_find_by_name[h].next; l != syms->link_find_by_name + h; l = l->next) {
@@ -723,35 +795,6 @@ int find_symbol_by_name(Context * ctx, int frame, ContextAddress addr, const cha
}
}
-#if ENABLE_RCBP_TEST
- if (f == NULL && !syms->service_available) {
- void * address = NULL;
- int sym_class = 0;
- if (find_test_symbol(ctx, name, &address, &sym_class) >= 0) {
- char bf[256];
- if (f == NULL) {
- f = (FindSymCache *)loc_alloc_zero(sizeof(FindSymCache));
- list_add_first(&f->link_syms, syms->link_find_by_name + h);
- list_add_last(&f->link_flush, &flush_mm);
- context_lock(f->ctx = ctx);
- f->magic = MAGIC_FIND;
- f->name = loc_strdup(name);
- f->ip = ip;
- }
- else {
- release_error_report(f->error);
- f->error = NULL;
- loc_free(f->id_buf);
- f->id_cnt = 0;
- }
- f->update_policy = UPDATE_ON_MEMORY_MAP_CHANGES;
- snprintf(bf, sizeof(bf), "@T.%X.%"PRIX64".%s", sym_class,
- (uint64_t)(uintptr_t)address, context_get_group(ctx, CONTEXT_GROUP_SYMBOLS)->id);
- f->id_buf = string_to_symbol_list(bf, &f->id_cnt);
- }
- }
-#endif
-
if (f == NULL) {
Channel * c = get_channel(syms);
f = (FindSymCache *)loc_alloc_zero(sizeof(FindSymCache));
@@ -808,16 +851,7 @@ int find_symbol_by_addr(Context * ctx, int frame, ContextAddress addr, Symbol **
if (!set_trap(&trap)) return -1;
- if (frame == STACK_NO_FRAME) {
- ip = addr;
- }
- else {
- StackFrame * info = NULL;
- if (frame == STACK_TOP_FRAME && (frame = get_top_frame(ctx)) < 0) exception(errno);;
- if (get_frame_info(ctx, frame, &info) < 0) exception(errno);
- if (read_reg_value(info, get_PC_definition(ctx), &ip) < 0) exception(errno);
- }
-
+ ip = get_symbol_ip(ctx, &frame, addr);
h = hash_find(ctx, NULL, ip);
syms = get_symbols_cache();
for (l = syms->link_find_by_addr[h].next; l != syms->link_find_by_addr + h; l = l->next) {
@@ -886,16 +920,7 @@ int find_symbol_in_scope(Context * ctx, int frame, ContextAddress addr, Symbol *
if (!set_trap(&trap)) return -1;
- if (frame == STACK_NO_FRAME) {
- ip = addr;
- }
- else {
- StackFrame * info = NULL;
- if (frame == STACK_TOP_FRAME && (frame = get_top_frame(ctx)) < 0) exception(errno);;
- if (get_frame_info(ctx, frame, &info) < 0) exception(errno);
- if (read_reg_value(info, get_PC_definition(ctx), &ip) < 0) exception(errno);
- }
-
+ ip = get_symbol_ip(ctx, &frame, addr);
h = hash_find(ctx, name, ip);
syms = get_symbols_cache();
for (l = syms->link_find_in_scope[h].next; l != syms->link_find_in_scope + h; l = l->next) {
@@ -982,13 +1007,7 @@ int enumerate_symbols(Context * ctx, int frame, EnumerateSymbolsCallBack * func,
if (!set_trap(&trap)) return -1;
- if (frame != STACK_NO_FRAME) {
- StackFrame * info = NULL;
- if (frame == STACK_TOP_FRAME && (frame = get_top_frame(ctx)) < 0) exception(errno);;
- if (get_frame_info(ctx, frame, &info) < 0) exception(errno);
- if (read_reg_value(info, get_PC_definition(ctx), &ip) < 0) exception(errno);
- }
-
+ ip = get_symbol_ip(ctx, &frame, 0);
h = hash_list(ctx, ip);
syms = get_symbols_cache();
for (l = syms->link_list[h].next; l != syms->link_list + h; l = l->next) {
@@ -1049,8 +1068,11 @@ int id2symbol(const char * id, Symbol ** sym) {
LINK * l;
SymInfoCache * s = NULL;
unsigned h = hash_sym_id(id);
- SymbolsCache * syms = get_symbols_cache();
+ SymbolsCache * syms = NULL;
+ Trap trap;
+ if (!set_trap(&trap)) return -1;
+ syms = get_symbols_cache();
for (l = syms->link_sym[h].next; l != syms->link_sym + h; l = l->next) {
SymInfoCache * x = syms2sym(l);
if (strcmp(x->id, id) == 0) {
@@ -1067,29 +1089,16 @@ int id2symbol(const char * id, Symbol ** sym) {
list_add_first(&s->link_syms, syms->link_sym + h);
list_add_last(&s->link_flush, &flush_mm);
list_init(&s->array_syms);
-#if ENABLE_RCBP_TEST
- if (strncmp(id, "@T.", 3) == 0) {
- int sym_class = 0;
- uint64_t address = 0;
- char ctx_id[256];
- if (sscanf(id, "@T.%X.%"SCNx64".%255s", &sym_class, &address, ctx_id) == 3) {
- s->done_context = 1;
- s->sym_class = sym_class;
- s->update_owner = id2ctx(ctx_id);
- if (s->update_owner != NULL) context_lock(s->update_owner);
- }
- }
-#endif
- } else {
- if (!s->disposed) {
- /* Move used item at the end of the flush list */
- list_remove(&s->link_flush);
- if (s->update_policy == UPDATE_ON_EXE_STATE_CHANGES) list_add_last(&s->link_flush, &flush_rc)
- else list_add_last(&s->link_flush, &flush_mm);
- }
+ }
+ else if (!s->disposed) {
+ /* Move used item at the end of the flush list */
+ list_remove(&s->link_flush);
+ if (s->update_policy == UPDATE_ON_EXE_STATE_CHANGES) list_add_last(&s->link_flush, &flush_rc)
+ else list_add_last(&s->link_flush, &flush_mm);
}
*sym = alloc_symbol();
(*sym)->cache = s;
+ clear_trap(&trap);
return 0;
}
@@ -1641,22 +1650,6 @@ int get_location_info(const Symbol * sym, LocationInfo ** loc) {
context_lock(f->ctx = ctx);
f->magic = MAGIC_LOC;
f->ip = ip;
-#if ENABLE_RCBP_TEST
- if (strncmp(sym_cache->id, "@T.", 3) == 0) {
- int sym_class = 0;
- uint64_t address = 0;
- char ctx_id[256];
- if (sscanf(sym_cache->id, "@T.%X.%"SCNx64".%255s", &sym_class, &address, ctx_id) == 3) {
- location_cmds.cnt = 0;
- add_location_command(SFT_CMD_NUMBER)->args.num = address;
- f->info.value_cmds.cmds = (LocationExpressionCommand *)loc_alloc(location_cmds.cnt * sizeof(LocationExpressionCommand));
- memcpy(f->info.value_cmds.cmds, location_cmds.cmds, location_cmds.cnt * sizeof(LocationExpressionCommand));
- f->info.value_cmds.cnt = f->info.value_cmds.max = location_cmds.cnt;
- f->info.big_endian = big_endian_host();
- f->sym_id = loc_strdup(sym_cache->id);
- }
- }
-#endif
}
if (f->sym_id == NULL) {
Channel * c = get_channel(syms);
@@ -1824,10 +1817,110 @@ int get_funccall_info(const Symbol * func,
return -1;
}
-const char * get_symbol_file_name(Context * ctx, MemoryRegion * module) {
- /* TODO: get_symbol_file_name() in symbols proxy */
+static void read_file_info_props(InputStream * inp, const char * name, void * args) {
+ FileInfoCache * f = (FileInfoCache *)args;
+ if (strcmp(name, "Addr") == 0) {
+ f->range_addr = (ContextAddress)json_read_uint64(inp);
+ }
+ else if (strcmp(name, "Size") == 0) {
+ f->range_size = (ContextAddress)json_read_uint64(inp);
+ }
+ else if (strcmp(name, "FileName") == 0) {
+ loc_free(f->file_name);
+ f->file_name = json_read_alloc_string(inp);
+ }
+ else if (strcmp(name, "FileError") == 0 && f->file_error == NULL) {
+ release_error_report(f->file_error);
+ f->file_error = get_error_report(read_error_object(inp));
+ }
+ else {
+ json_skip_object(inp);
+ }
+}
+
+static void validate_file(Channel * c, void * args, int error) {
+ Trap trap;
+ FileInfoCache * f = (FileInfoCache *)args;
+ assert(f->magic == MAGIC_FILE);
+ assert(f->pending != NULL);
+ assert(f->error == NULL);
+ if (set_trap(&trap)) {
+ f->pending = NULL;
+ if (!error) {
+ error = read_errno(&c->inp);
+ json_read_struct(&c->inp, read_file_info_props, f);
+ json_test_char(&c->inp, MARKER_EOA);
+ json_test_char(&c->inp, MARKER_EOM);
+ }
+ clear_trap(&trap);
+ }
+ else {
+ error = trap.error;
+ }
+ if (get_error_code(error) != ERR_INV_COMMAND) f->error = get_error_report(error);
+ cache_notify_later(&f->cache);
+ if (f->disposed) free_file_info_cache(f);
+}
+
+static FileInfoCache * get_file_info_cache(Context * ctx, ContextAddress addr) {
+ Trap trap;
+ unsigned h;
+ LINK * l;
+ SymbolsCache * syms = NULL;
+ FileInfoCache * f = NULL;
+
+ if (!set_trap(&trap)) return NULL;
+
+ h = hash_file(ctx);
+ syms = get_symbols_cache();
+ for (l = syms->link_file[h].next; l != syms->link_file + h; l = l->next) {
+ FileInfoCache * c = syms2file(l);
+ if (c->ctx == ctx) {
+ if (c->pending != NULL) {
+ cache_wait(&c->cache);
+ }
+ else if (c->range_addr <= addr && c->range_addr + c->range_size > addr) {
+ f = c;
+ break;
+ }
+ }
+ }
+
+ assert(f == NULL || f->pending == NULL);
+
+ if (f == NULL && !syms->service_available) {
+ /* nothing */
+ }
+ else if (f == NULL) {
+ Channel * c = get_channel(syms);
+ f = (FileInfoCache *)loc_alloc_zero(sizeof(FileInfoCache));
+ list_add_first(&f->link_syms, syms->link_frame + h);
+ list_add_last(&f->link_flush, &flush_mm);
+ context_lock(f->ctx = ctx);
+ f->magic = MAGIC_FILE;
+ f->addr = addr;
+ f->pending = protocol_send_command(c, SYMBOLS, "getSymFileInfo", validate_file, f);
+ json_write_string(&c->out, f->ctx->id);
+ write_stream(&c->out, 0);
+ json_write_uint64(&c->out, addr);
+ write_stream(&c->out, 0);
+ write_stream(&c->out, MARKER_EOM);
+ cache_wait(&f->cache);
+ }
+ else if (f->error != NULL) {
+ exception(set_error_report_errno(f->error));
+ }
+
+ clear_trap(&trap);
errno = 0;
- return NULL;
+ return f;
+}
+
+const char * get_symbol_file_name(Context * ctx, MemoryRegion * module) {
+ FileInfoCache * f = get_file_info_cache(ctx, module->addr);
+ if (f == NULL) return NULL;
+ set_error_report_errno(f->file_error);
+ return f->file_name;
}
/*************************************************************************************************/
@@ -1881,6 +1974,13 @@ static void flush_one(Context * ctx, int mode, Context * sym_grp, LINK * l) {
}
return;
}
+ if (magic == MAGIC_FILE) {
+ FileInfoCache * c = flush2file(l);
+ if (check_policy(ctx, mode, sym_grp, c->ctx, UPDATE_ON_MEMORY_MAP_CHANGES)) {
+ free_file_info_cache(c);
+ }
+ return;
+ }
if (magic == MAGIC_LOC) {
LocationInfoCache * c = flush2location(l);
if (check_policy(ctx, mode, sym_grp, c->ctx, UPDATE_ON_MEMORY_MAP_CHANGES)) {
@@ -1936,6 +2036,13 @@ static void event_code_unmapped(Context * ctx, ContextAddress addr, ContextAddre
}
#endif
+#if ENABLE_SymbolsMux
+static int reader_is_valid(Context * ctx, ContextAddress addr) {
+ FileInfoCache * f = get_file_info_cache(ctx, addr);
+ return f != NULL && f->file_name != NULL;
+}
+#endif
+
static void channel_close_listener(Channel * c) {
LINK * l = root.next;
while (l != &root) {
@@ -1970,6 +2077,9 @@ void ini_symbols_lib(void) {
add_channel_close_listener(channel_close_listener);
list_init(&flush_rc);
list_init(&flush_mm);
+#if ENABLE_SymbolsMux
+ add_symbols_reader(&symbol_reader);
+#endif
}
#endif
diff --git a/agent/tcf/services/symbols_win32.c b/agent/tcf/services/symbols_win32.c
index b4f3929f..2f9b5641 100644
--- a/agent/tcf/services/symbols_win32.c
+++ b/agent/tcf/services/symbols_win32.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2014 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.
@@ -19,7 +19,7 @@
#include <tcf/config.h>
-#if SERVICE_Symbols && !ENABLE_SymbolsProxy && ENABLE_PE
+#if SERVICE_Symbols && (!ENABLE_SymbolsProxy || ENABLE_LineNumbersMux) && ENABLE_PE
#include <errno.h>
#include <assert.h>
@@ -36,9 +36,6 @@
#include <tcf/services/funccall.h>
#include <system/Windows/tcf/windbgcache.h>
#include <system/Windows/tcf/context-win32.h>
-#if ENABLE_RCBP_TEST
-# include <tcf/main/test.h>
-#endif
#if ENABLE_SymbolsMux
#define SYM_READER_PREFIX win32_reader_
#include <tcf/services/symbols_mux.h>
@@ -971,19 +968,6 @@ int find_symbol_by_name(Context * ctx, int frame, ContextAddress ip, const char
if (frame == STACK_TOP_FRAME && (frame = get_top_frame(ctx)) < 0) return -1;
if (find_pe_symbol_by_name(ctx, frame, ip, name, *sym) >= 0) found = 1;
else if (get_error_code(errno) != ERR_SYM_NOT_FOUND) return -1;
-#if ENABLE_RCBP_TEST
- if (!found) {
- int sym_class = 0;
- void * address = NULL;
- if (find_test_symbol(ctx, name, &address, &sym_class) >= 0) found = 1;
- else if (get_error_code(errno) != ERR_SYM_NOT_FOUND) return -1;
- if (found) {
- (*sym)->ctx = ctx->mem;
- (*sym)->sym_class = sym_class;
- (*sym)->address = (ContextAddress)address;
- }
- }
-#endif
if (!found) {
if (find_basic_type_symbol(ctx, name, *sym) >= 0) found = 1;
else if (get_error_code(errno) != ERR_SYM_NOT_FOUND) return -1;
@@ -1264,6 +1248,10 @@ int get_funccall_info(const Symbol * func,
const char * get_symbol_file_name(Context * ctx, MemoryRegion * module) {
IMAGEHLP_MODULE64 info;
HANDLE process = get_context_handle(context_get_group(ctx, CONTEXT_GROUP_PROCESS));
+ if (module == NULL) {
+ errno = 0;
+ return NULL;
+ }
memset(&info, 0, sizeof(info));
info.SizeOfStruct = sizeof(info);
if (!SymGetModuleInfo64(process, module->addr, &info)) {
@@ -1335,12 +1323,8 @@ static int reader_is_valid(Context * ctx, ContextAddress addr) {
HANDLE process = get_context_handle(context_get_group(ctx, CONTEXT_GROUP_PROCESS));
memset(&info, 0, sizeof(info));
info.SizeOfStruct = sizeof(info);
- if (!SymGetModuleInfo64(process, addr, &info)) {
- return 0;
- }
- errno = 0;
- if (info.LoadedImageName[0] == 0) return 0;
- return 1;
+ if (!SymGetModuleInfo64(process, addr, &info)) return 0;
+ return info.LoadedImageName[0] != 0;
}
#endif
@@ -1364,4 +1348,4 @@ void ini_symbols_lib(void) {
}
-#endif /* SERVICE_Symbols && defined(_MSC_VER) */
+#endif /* SERVICE_Symbols && (!ENABLE_SymbolsProxy || ENABLE_LineNumbersMux) && ENABLE_PE */

Back to the top