Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEugene Tarassov2011-12-02 22:08:58 -0500
committerEugene Tarassov2011-12-02 22:08:58 -0500
commit495dd83ce0aadbe78aa62d076adb1d11e50cfcff (patch)
treec4585f956f0ca55284a89f26fc0cbf580e47f223 /tests
parentf42b051a2d5fe26988d15e1d2eaaa01f9f27d62c (diff)
downloadorg.eclipse.tcf.agent-495dd83ce0aadbe78aa62d076adb1d11e50cfcff.tar.gz
org.eclipse.tcf.agent-495dd83ce0aadbe78aa62d076adb1d11e50cfcff.tar.xz
org.eclipse.tcf.agent-495dd83ce0aadbe78aa62d076adb1d11e50cfcff.zip
TCF Agent: tested and fixed handling of "debuginfo" files in Linux. Added support for GNU extensions of DWARF.
Diffstat (limited to 'tests')
-rw-r--r--tests/mem-leaks/agent.vcproj16
-rw-r--r--tests/mem-leaks/tcf/services/memtrace.c16
-rw-r--r--tests/test-dwarf/dwarf-test.vcproj30
-rw-r--r--tests/test-dwarf/tcf/backend/backend.c52
4 files changed, 64 insertions, 50 deletions
diff --git a/tests/mem-leaks/agent.vcproj b/tests/mem-leaks/agent.vcproj
index 73c0546b..3127f612 100644
--- a/tests/mem-leaks/agent.vcproj
+++ b/tests/mem-leaks/agent.vcproj
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories=".;..\..\agent;..\..\agent\tcf\system\Windows;..\..\agent\tcf\machine\i386"
+ AdditionalIncludeDirectories=".;..\..\agent;..\..\agent\system\Windows;..\..\agent\machine\i386"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -116,7 +116,7 @@
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
- AdditionalIncludeDirectories=".;..\..\agent;..\..\agent\tcf\system\Windows;..\..\agent\tcf\machine\i386"
+ AdditionalIncludeDirectories=".;..\..\agent;..\..\agent\system\Windows;..\..\agent\machine\i386"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
@@ -612,27 +612,27 @@
Name="Windows"
>
<File
- RelativePath="..\..\agent\tcf\system\Windows\context-win32.c"
+ RelativePath="..\..\agent\system\Windows\tcf\context-win32.c"
>
</File>
<File
- RelativePath="..\..\agent\tcf\system\Windows\context-win32.h"
+ RelativePath="..\..\agent\system\Windows\tcf\context-win32.h"
>
</File>
<File
- RelativePath="..\..\agent\tcf\system\Windows\pthreads-win32.c"
+ RelativePath="..\..\agent\system\Windows\tcf\pthreads-win32.c"
>
</File>
<File
- RelativePath="..\..\agent\tcf\system\Windows\regset.h"
+ RelativePath="..\..\agent\system\Windows\tcf\regset.h"
>
</File>
<File
- RelativePath="..\..\agent\tcf\system\Windows\windbgcache.c"
+ RelativePath="..\..\agent\system\Windows\tcf\windbgcache.c"
>
</File>
<File
- RelativePath="..\..\agent\tcf\system\Windows\windbgcache.h"
+ RelativePath="..\..\agent\system\Windows\tcf\windbgcache.h"
>
</File>
</Filter>
diff --git a/tests/mem-leaks/tcf/services/memtrace.c b/tests/mem-leaks/tcf/services/memtrace.c
index 80a0f659..a4322b85 100644
--- a/tests/mem-leaks/tcf/services/memtrace.c
+++ b/tests/mem-leaks/tcf/services/memtrace.c
@@ -30,7 +30,7 @@
#include <tcf/services/linenumbers.h>
#include <tcf/services/memtrace.h>
#if defined(WIN32)
-# include <tcf/system/Windows/context-win32.h>
+# include <system/Windows/tcf/context-win32.h>
#endif
#define USE_DEBUG_REGS 0
@@ -43,7 +43,7 @@
#define FUNC_DESTROY 6
typedef struct EventPoint {
- char * name;
+ const char * name;
int heap_type;
int func_type;
} EventPoint;
@@ -127,8 +127,10 @@ static LINK mem_hash[MEM_HASH_SIZE];
static RegisterDefinition * reg_def_eax = NULL;
static RegisterDefinition * reg_def_esp = NULL;
static RegisterDefinition * reg_def_eip = NULL;
+#if defined(__x86_64__)
static RegisterDefinition * reg_def_rdi = NULL;
static RegisterDefinition * reg_def_rsi = NULL;
+#endif
#define link_mem2trace(x) ((StackTrace *)((char *)(x) - offsetof(StackTrace, link_all)))
#define link_mem2ret(x) ((ReturnPoint *)((char *)(x) - offsetof(ReturnPoint, link_mem)))
@@ -516,12 +518,14 @@ static int sort_func(const void * x, const void * y) {
static int print_text_pos_cnt = 0;
+#if SERVICE_LineNumbers
static void print_text_pos(CodeArea * area, void * args) {
if (print_text_pos_cnt == 0) {
printf(" %s %d\n", area->file, area->start_line);
}
print_text_pos_cnt++;
}
+#endif
#if !USE_DEBUG_REGS
static void rp_callback(Context * ctx, void * args) {
@@ -537,8 +541,10 @@ static void event_point(Context * ctx, void * args) {
StackFrame * info = NULL;
uint64_t esp = 0;
uint64_t eip = 0;
+#if defined(__x86_64__)
uint64_t rdi = 0;
uint64_t rsi = 0;
+#endif
ContextAddress buf[4];
MemorySpace * m = NULL;
static StackTrace trace;
@@ -691,11 +697,13 @@ static void event_point(Context * ctx, void * args) {
for (i = 0; i < 8 && i < cnt; i++) {
int j;
StackTrace * t = buf[i];
- printf(" curr %lld, total %lld, calls %d\n",
- (long long)t->size_current, (long long)t->size_total, t->call_cnt);
+ printf(" curr %" PRId64 ", total %" PRId64 ", calls %d\n",
+ (int64_t)t->size_current, (int64_t)t->size_total, t->call_cnt);
for (j = 0; j < t->frame_cnt; j++) {
print_text_pos_cnt = 0;
+#if SERVICE_LineNumbers
address_to_line(ctx, t->frames[j], t->frames[j] + 1, print_text_pos, NULL);
+#endif
if (print_text_pos_cnt == 0) {
printf(" 0x%" PRIX64 "\n", (uint64_t)t->frames[j]);
}
diff --git a/tests/test-dwarf/dwarf-test.vcproj b/tests/test-dwarf/dwarf-test.vcproj
index c4217bb1..aaddecaa 100644
--- a/tests/test-dwarf/dwarf-test.vcproj
+++ b/tests/test-dwarf/dwarf-test.vcproj
@@ -230,6 +230,10 @@
>
</File>
<File
+ RelativePath=".\tcf\framework\cpudefs-ext.h"
+ >
+ </File>
+ <File
RelativePath="..\..\agent\tcf\framework\cpudefs.c"
>
</File>
@@ -490,6 +494,14 @@
>
</File>
<File
+ RelativePath="..\..\agent\tcf\services\elf-loader.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\agent\tcf\services\elf-loader.h"
+ >
+ </File>
+ <File
RelativePath="..\..\agent\tcf\services\expressions.c"
>
</File>
@@ -647,22 +659,6 @@
</File>
</Filter>
<Filter
- Name="machine"
- >
- <File
- RelativePath=".\tcf\machine\cpudefs-ext.h"
- >
- </File>
- <Filter
- Name="i386"
- >
- <File
- RelativePath="..\..\agent\tcf\machine\i386\elf-mdep.h"
- >
- </File>
- </Filter>
- </Filter>
- <Filter
Name="backend"
>
<File
@@ -678,7 +674,7 @@
Name="system"
>
<File
- RelativePath="..\..\agent\tcf\system\Windows\pthreads-win32.c"
+ RelativePath="..\..\agent\system\Windows\tcf\pthreads-win32.c"
>
</File>
</Filter>
diff --git a/tests/test-dwarf/tcf/backend/backend.c b/tests/test-dwarf/tcf/backend/backend.c
index 6c914a93..6094a3fc 100644
--- a/tests/test-dwarf/tcf/backend/backend.c
+++ b/tests/test-dwarf/tcf/backend/backend.c
@@ -208,12 +208,14 @@ static void loc_var_func(void * args, Symbol * sym) {
error("get_symbol_name");
}
if (get_symbol_address(sym, &addr) < 0) {
- int err = errno;
if ((get_symbol_register(sym, &ctx, &frame, &reg) < 0 || reg == NULL) &&
(get_symbol_value(sym, &value, &value_size, &value_big_endian) < 0 || value == NULL)) {
+ int err = errno;
+ if (strncmp(errno_to_str(err), "Object location or value info not available", 43) == 0) return;
if (strncmp(errno_to_str(err), "No object location info found", 29) == 0) return;
if (strncmp(errno_to_str(err), "Object is not available", 23) == 0) return;
if (strncmp(errno_to_str(err), "Object has no RT address", 24) == 0) return;
+ if (strncmp(errno_to_str(err), "Division by zero in DWARF", 25) == 0) return;
errno = err;
error("get_symbol_address");
}
@@ -226,7 +228,7 @@ static void loc_var_func(void * args, Symbol * sym) {
}
if (get_symbol_size(sym, &size) < 0) {
int ok = 0;
- if (name == NULL && type != NULL) {
+ if (type != NULL) {
char * type_name;
unsigned type_flags;
if (get_symbol_name(type, &type_name) < 0) {
@@ -235,7 +237,7 @@ static void loc_var_func(void * args, Symbol * sym) {
if (get_symbol_flags(type, &type_flags) < 0) {
error("get_symbol_flags");
}
- if (type_name != NULL && strcmp(type_name, "exception") == 0 && (type_flags & SYM_FLAG_CLASS_TYPE)) {
+ if (name == NULL && type_name != NULL && strcmp(type_name, "exception") == 0 && (type_flags & SYM_FLAG_CLASS_TYPE)) {
/* GCC does not tell size of std::exception class */
ok = 1;
}
@@ -314,6 +316,8 @@ static void next_pc(void) {
mem_region_pos++;
pc = 0;
print_time(time_start, test_cnt);
+ post_event_with_delay(test, NULL, 1000000);
+ test_posted = 1;
return;
}
@@ -326,6 +330,8 @@ static void next_pc(void) {
mem_region_pos++;
pc = 0;
print_time(time_start, test_cnt);
+ post_event_with_delay(test, NULL, 1000000);
+ test_posted = 1;
return;
}
}
@@ -415,7 +421,7 @@ static void next_pc(void) {
time_start = time_now;
loaded = 0;
}
- else if (test_cnt >= 100000) {
+ else if (test_cnt >= 1000) {
print_time(time_start, test_cnt);
clock_gettime(CLOCK_REALTIME, &time_start);
test_posted = 1;
@@ -442,7 +448,7 @@ static void next_file(void) {
clock_gettime(CLOCK_REALTIME, &time_start);
- f = elf_open(elf_file_name);;
+ f = elf_open(elf_file_name);
if (f == NULL) {
printf("Cannot open ELF: %s\n", errno_to_str(errno));
exit(1);
@@ -520,7 +526,7 @@ static void next_file(void) {
RegisterDefinition * r = reg_defs + j;
r->big_endian = f->big_endian;
r->dwarf_id = (int16_t)(j == 0 ? -1 : j - 1);
- r->eh_frame_id = -1;
+ r->eh_frame_id = r->dwarf_id;
r->name = reg_names[j];
snprintf(reg_names[j], sizeof(reg_names[j]), "R%d", j);
r->offset = reg_size;
@@ -547,15 +553,7 @@ static void test(void * args) {
}
}
-static void on_elf_file_closed(ELF_File * f) {
- if (!test_posted) {
- test_posted = 1;
- post_event(test, NULL);
- }
-}
-
-void init_contexts_sys_dep(void) {
- const char * dir_name = "files";
+static void add_dir(const char * dir_name) {
DIR * dir = opendir(dir_name);
if (dir == NULL) {
printf("Cannot open '%s' directory\n", dir_name);
@@ -567,17 +565,29 @@ void init_contexts_sys_dep(void) {
char path[FILE_PATH_SIZE];
struct stat st;
if (e == NULL) break;
+ if (strcmp(e->d_name, ".") == 0) continue;
+ if (strcmp(e->d_name, "..") == 0) continue;
+ if (strcmp(e->d_name + strlen(e->d_name) - 6, ".debug") == 0) continue;
snprintf(path, sizeof(path), "%s/%s", dir_name, e->d_name);
- if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) {
- if (files_cnt >= files_max) {
- files_max += 8;
- files = (char **)loc_realloc(files, files_max * sizeof(char *));
+ if (stat(path, &st) == 0) {
+ if (S_ISDIR(st.st_mode)) {
+ add_dir(path);
+ }
+ else {
+ if (files_cnt >= files_max) {
+ files_max += 8;
+ files = (char **)loc_realloc(files, files_max * sizeof(char *));
+ }
+ files[files_cnt++] = loc_strdup(path);
}
- files[files_cnt++] = loc_strdup(path);
}
}
closedir(dir);
- elf_add_close_listener(on_elf_file_closed);
+}
+
+void init_contexts_sys_dep(void) {
+ const char * dir_name = "files";
+ add_dir(dir_name);
test_posted = 1;
post_event(test, NULL);
}

Back to the top