Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2012-04-10 20:49:11 +0000
committerEugene Tarassov2012-04-10 20:49:11 +0000
commit26ddfef40b507d13755919a53f4ae3884488e361 (patch)
treef72ff4bd1ce8c9d2ef71199fbf9615e427a3bb69 /agent/tcf/services/linenumbers_win32.c
parentfca934b9ccdf85b3085035857051c7888d5a3b1b (diff)
downloadorg.eclipse.tcf.agent-26ddfef40b507d13755919a53f4ae3884488e361.tar.gz
org.eclipse.tcf.agent-26ddfef40b507d13755919a53f4ae3884488e361.tar.xz
org.eclipse.tcf.agent-26ddfef40b507d13755919a53f4ae3884488e361.zip
TCF Agent: better handling of path mapping in line_to_address()
Diffstat (limited to 'agent/tcf/services/linenumbers_win32.c')
-rw-r--r--agent/tcf/services/linenumbers_win32.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/agent/tcf/services/linenumbers_win32.c b/agent/tcf/services/linenumbers_win32.c
index fac43d7d..637218b4 100644
--- a/agent/tcf/services/linenumbers_win32.c
+++ b/agent/tcf/services/linenumbers_win32.c
@@ -30,10 +30,42 @@
#include <tcf/framework/protocol.h>
#include <tcf/framework/context.h>
#include <tcf/framework/exceptions.h>
+#include <tcf/framework/cache.h>
+#include <tcf/services/pathmap.h>
#include <tcf/services/linenumbers.h>
#include <system/Windows/tcf/windbgcache.h>
#include <system/Windows/tcf/context-win32.h>
+static int compare_path(Channel * chnl, Context * ctx, const char * file, const char * name) {
+ int i, j;
+ char * full_name = NULL;
+
+ if (file == NULL) return 0;
+ if (name == NULL) return 0;
+
+ while (file[0] == '.') {
+ if (file[1] == '.' && file[2] == '/') file += 3;
+ else if (file[1] == '/') file += 2;
+ else break;
+ }
+ i = strlen(file);
+
+ full_name = canonic_path_map_file_name(name);
+ j = strlen(full_name);
+ if (i <= j && strcmp(file, full_name + j - i) == 0) return 1;
+#if SERVICE_PathMap
+ {
+ char * s = apply_path_map(chnl, ctx, full_name, PATH_MAP_TO_CLIENT);
+ if (s != full_name) {
+ full_name = canonic_path_map_file_name(s);
+ j = strlen(full_name);
+ if (i <= j && strcmp(file, full_name + j - i) == 0) return 1;
+ }
+ }
+#endif
+ return 0;
+}
+
int line_to_address(Context * ctx, char * file, int line, int column,
LineNumbersCallBack * callback, void * user_args) {
int err = 0;
@@ -44,12 +76,15 @@ int line_to_address(Context * ctx, char * file, int line, int column,
if (err == 0 && ctx->parent != NULL) ctx = ctx->parent;
if (err == 0) {
+ CodeArea area;
LONG offset = 0;
IMAGEHLP_LINE img_line;
- CodeArea area;
- memset(&img_line, 0, sizeof(img_line));
+ Channel * chnl = cache_channel();
+
memset(&area, 0, sizeof(area));
+ memset(&img_line, 0, sizeof(img_line));
img_line.SizeOfStruct = sizeof(IMAGEHLP_LINE);
+ file = canonic_path_map_file_name(file);
if (!SymGetLineFromName(get_context_handle(ctx), NULL, file, line, &offset, &img_line)) {
DWORD win_err = GetLastError();
@@ -60,10 +95,11 @@ int line_to_address(Context * ctx, char * file, int line, int column,
else {
IMAGEHLP_LINE img_next;
memcpy(&img_next, &img_line, sizeof(img_next));
+ img_next.SizeOfStruct = sizeof(IMAGEHLP_LINE);
if (!SymGetLineNext(get_context_handle(ctx), &img_next)) {
err = set_win32_errno(GetLastError());
}
- else {
+ else if (compare_path(chnl, ctx, file, img_line.FileName)) {
area.file = img_line.FileName;
area.start_line = img_line.LineNumber;
area.start_address = img_line.Address;

Back to the top