Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEugene Tarassov2012-01-30 20:47:40 -0500
committerEugene Tarassov2012-01-30 20:47:40 -0500
commit3fc3677b1a32efb2856ae17ce082f11ac08232dd (patch)
treeed988238dadda37d4483c0a2b48f69ce42362ce5 /tests
parentaa78355205befe7dabe9368ba2fd2eb03e45a554 (diff)
downloadorg.eclipse.tcf.agent-3fc3677b1a32efb2856ae17ce082f11ac08232dd.tar.gz
org.eclipse.tcf.agent-3fc3677b1a32efb2856ae17ce082f11ac08232dd.tar.xz
org.eclipse.tcf.agent-3fc3677b1a32efb2856ae17ce082f11ac08232dd.zip
TCF Agent: improved DWARF reader:
1. new symbols flags: private, protected, public, enum, struct; 2. more of delayed loading of DWARF; 3. get_symbol_type() now allows to get original type of typedef and modified types; 4. more DWARF tests;
Diffstat (limited to 'tests')
-rw-r--r--tests/test-dwarf/tcf/backend/backend.c114
1 files changed, 113 insertions, 1 deletions
diff --git a/tests/test-dwarf/tcf/backend/backend.c b/tests/test-dwarf/tcf/backend/backend.c
index d8a20adc..3d8da1da 100644
--- a/tests/test-dwarf/tcf/backend/backend.c
+++ b/tests/test-dwarf/tcf/backend/backend.c
@@ -313,6 +313,12 @@ static void print_time(struct timespec time_start, int cnt) {
fflush(stdout);
}
+static int symcmp(Symbol * x, Symbol * y) {
+ char id[256];
+ strcpy(id, symbol2id(x));
+ return strcmp(id, symbol2id(y));
+}
+
static void test(void * args);
static void loc_var_func(void * args, Symbol * sym) {
@@ -406,34 +412,117 @@ static void loc_var_func(void * args, Symbol * sym) {
}
}
if (type != NULL) {
+ int type_sym_class = 0;
+ Symbol * org_type = NULL;
Symbol * container = NULL;
+ if (get_symbol_class(type, &type_sym_class) < 0) {
+ error("get_symbol_class");
+ }
+ if (type_sym_class != SYM_CLASS_TYPE) {
+ errno = ERR_OTHER;
+ error("Invalid symbol class of a type");
+ }
if (get_symbol_type_class(sym, &type_class) < 0) {
error("get_symbol_type_class");
}
if (get_symbol_flags(type, &flags) < 0) {
error("get_symbol_flags");
}
+ if (flags & SYM_FLAG_TYPEDEF) {
+ char * type_name = NULL;
+ if (get_symbol_object(type) == NULL) {
+ errno = ERR_OTHER;
+ error("Invalid DWARF object of typedef");
+ }
+ if (get_symbol_type(type, &org_type) < 0) {
+ error("get_symbol_type");
+ }
+ if (symcmp(type, org_type) == 0) {
+ errno = ERR_OTHER;
+ error("Invalid original type of typedef");
+ }
+ if (get_symbol_name(type, &type_name) < 0) {
+ error("get_symbol_name");
+ }
+ if (type_name == NULL) {
+ errno = ERR_OTHER;
+ error("typedef must have a name");
+ }
+ if ((flags & SYM_FLAG_CONST_TYPE) || (flags & SYM_FLAG_VOLATILE_TYPE)) {
+ errno = ERR_OTHER;
+ error("Invalid flags of typedef");
+ }
+ }
+ else if ((flags & SYM_FLAG_CONST_TYPE) || (flags & SYM_FLAG_VOLATILE_TYPE)) {
+ if (get_symbol_type(type, &org_type) < 0) {
+ error("get_symbol_type");
+ }
+ if (symcmp(type, org_type) == 0) {
+ errno = ERR_OTHER;
+ error("Invalid original type of modified type");
+ }
+ }
if (get_symbol_index_type(type, &index_type) < 0) {
if (type_class == TYPE_CLASS_ARRAY) {
error("get_symbol_index_type");
}
}
+ else if (org_type != NULL) {
+ Symbol * org_index_type = NULL;
+ if (get_symbol_index_type(org_type, &org_index_type) < 0) {
+ error("get_symbol_index_type");
+ }
+ if (symcmp(index_type, org_index_type) != 0) {
+ errno = ERR_OTHER;
+ error("Invalid inedx type of typedef");
+ }
+ }
if (get_symbol_base_type(type, &base_type) < 0) {
if (type_class == TYPE_CLASS_ARRAY || type_class == TYPE_CLASS_FUNCTION ||
type_class == TYPE_CLASS_POINTER || type_class == TYPE_CLASS_MEMBER_PTR) {
error("get_symbol_base_type");
}
}
+ else if (org_type != NULL) {
+ Symbol * org_base_type = NULL;
+ if (get_symbol_base_type(org_type, &org_base_type) < 0) {
+ error("get_symbol_base_type");
+ }
+ if (symcmp(base_type, org_base_type) != 0) {
+ errno = ERR_OTHER;
+ error("Invalid base type of typedef");
+ }
+ }
if (get_symbol_container(type, &container) < 0) {
if (type_class == TYPE_CLASS_MEMBER_PTR) {
error("get_symbol_container");
}
}
+ else if (org_type != NULL) {
+ Symbol * org_container = NULL;
+ if (get_symbol_container(org_type, &org_container) < 0) {
+ error("get_symbol_container");
+ }
+ if (symcmp(container, org_container) != 0) {
+ errno = ERR_OTHER;
+ error("Invalid container of typedef");
+ }
+ }
if (get_symbol_length(type, &length) < 0) {
if (type_class == TYPE_CLASS_ARRAY) {
error("get_symbol_length");
}
}
+ else if (org_type != NULL) {
+ ContextAddress org_length = 0;
+ if (get_symbol_length(org_type, &org_length) < 0) {
+ error("get_symbol_length");
+ }
+ if (length != org_length) {
+ errno = ERR_OTHER;
+ error("Invalid length of typedef");
+ }
+ }
if (type_class == TYPE_CLASS_ARRAY) {
if (get_symbol_lower_bound(type, &lower_bound) < 0) {
error("get_symbol_lower_bound");
@@ -443,16 +532,39 @@ static void loc_var_func(void * args, Symbol * sym) {
int i;
int count = 0;
Symbol ** children = NULL;
+ Symbol * enum_type = type;
+ for (i = 0;; i++) {
+ SYM_FLAGS enum_flags = 0;
+ if (get_symbol_flags(enum_type, &enum_flags) < 0) {
+ error("get_symbol_flags");
+ }
+ if ((enum_flags & SYM_FLAG_ENUM_TYPE) != 0) break;
+ if (get_symbol_type(enum_type, &enum_type) < 0) {
+ error("get_symbol_type");
+ }
+ if (i >= 1000) {
+ errno = ERR_OTHER;
+ error("Invalid original type for enumeration type class");
+ }
+ }
if (get_symbol_children(type, &children, &count) < 0) {
error("get_symbol_children");
}
for (i = 0; i < count; i++) {
+ Symbol * child_type = NULL;
void * value = NULL;
size_t value_size = 0;
int big_endian = 0;
if (get_symbol_value(children[i], &value, &value_size, &big_endian) < 0) {
error("get_symbol_value");
}
+ if (get_symbol_type(children[i], &child_type) < 0) {
+ error("get_symbol_type");
+ }
+ if (symcmp(enum_type, child_type) != 0) {
+ errno = ERR_OTHER;
+ error("Invalid type of enum element");
+ }
}
}
else if (type_class == TYPE_CLASS_COMPOSITE) {
@@ -862,7 +974,7 @@ static void add_dir(const char * dir_name) {
}
void init_contexts_sys_dep(void) {
- const char * dir_name = "files";
+ const char * dir_name = ".";
add_dir(dir_name);
test_posted = 1;
post_event(test, NULL);

Back to the top