diff options
author | Eugene Tarassov | 2012-05-23 06:08:33 +0000 |
---|---|---|
committer | Eugene Tarassov | 2012-05-23 06:08:33 +0000 |
commit | 4832d712eb1acaa658f0ba2cb39a30c9d28bbef8 (patch) | |
tree | e583637d2e01c5c5ee7219b0353e7a2d2e42f6dd | |
parent | 015e50fd40770fabc0f8a51042d18906af30ae97 (diff) | |
download | org.eclipse.tcf.agent-4832d712eb1acaa658f0ba2cb39a30c9d28bbef8.tar.gz org.eclipse.tcf.agent-4832d712eb1acaa658f0ba2cb39a30c9d28bbef8.tar.xz org.eclipse.tcf.agent-4832d712eb1acaa658f0ba2cb39a30c9d28bbef8.zip |
TCF Agent: allow to use compilation unit name in qualified names in expressions, e.g. "test.c"::foo
-rw-r--r-- | agent/tcf/services/dwarfcache.c | 29 | ||||
-rw-r--r-- | agent/tcf/services/expressions.c | 24 |
2 files changed, 35 insertions, 18 deletions
diff --git a/agent/tcf/services/dwarfcache.c b/agent/tcf/services/dwarfcache.c index 11bbe544..b71f325a 100644 --- a/agent/tcf/services/dwarfcache.c +++ b/agent/tcf/services/dwarfcache.c @@ -932,6 +932,20 @@ static void load_pub_names(ELF_Section * debug_info, ELF_Section * pub_names) { dio_ExitSection(); } +static void add_pub_name(PubNamesTable * tbl, ObjectInfo * obj) { + PubNamesInfo * info = NULL; + unsigned h = calc_symbol_name_hash(obj->mName) % tbl->mHashSize; + if (tbl->mCnt >= tbl->mMax) { + tbl->mMax = tbl->mMax * 3 / 2; + tbl->mNext = (PubNamesInfo *)loc_realloc(tbl->mNext, sizeof(PubNamesInfo) * tbl->mMax); + } + info = tbl->mNext + tbl->mCnt; + info->mObject = obj; + info->mNext = tbl->mHash[h]; + tbl->mHash[h] = tbl->mCnt++; + obj->mFlags |= DOIF_pub_mark; +} + static void create_pub_names(ELF_Section * debug_info) { ObjectInfo * unit = sCache->mCompUnits; PubNamesTable * tbl = &sCache->mPubNames; @@ -939,20 +953,13 @@ static void create_pub_names(ELF_Section * debug_info) { ObjectInfo * obj = get_dwarf_children(unit); while (obj != NULL) { if ((obj->mFlags & DOIF_pub_mark) == 0 && obj->mDefinition == NULL && obj->mName != NULL) { - PubNamesInfo * info = NULL; - unsigned h = calc_symbol_name_hash(obj->mName) % tbl->mHashSize; - if (tbl->mCnt >= tbl->mMax) { - tbl->mMax = tbl->mMax * 3 / 2; - tbl->mNext = (PubNamesInfo *)loc_realloc(tbl->mNext, sizeof(PubNamesInfo) * tbl->mMax); - } - info = tbl->mNext + tbl->mCnt; - info->mObject = obj; - info->mNext = tbl->mHash[h]; - tbl->mHash[h] = tbl->mCnt++; - obj->mFlags |= DOIF_pub_mark; + add_pub_name(tbl, obj); } obj = obj->mSibling; } + if ((unit->mFlags & DOIF_pub_mark) == 0 && unit->mName != NULL) { + add_pub_name(tbl, unit); + } unit = unit->mSibling; } } diff --git a/agent/tcf/services/expressions.c b/agent/tcf/services/expressions.c index fd4d16a8..63811145 100644 --- a/agent/tcf/services/expressions.c +++ b/agent/tcf/services/expressions.c @@ -17,7 +17,7 @@ * Expression evaluation service. * * Extensions to regular C/C++ syntax: - * 1. Special characters in identifiers: $"X" + * 1. Special characters in identifiers: $"X", or just "X" if followed by :: * where X is object name that can contain any characters. * 2. Symbol IDs in expressions: ${X} * where X is symbol ID as returned by symbols service. @@ -1300,6 +1300,11 @@ static int to_boolean(int mode, Value * v) { static void expression(int mode, Value * v); +static void qualified_name_expression(int mode, Value * scope, Value * v) { + if (qualified_name(mode, scope, 0, v) != SYM_CLASS_TYPE) return; + error(ERR_INV_EXPRESSION, "Illegal usage of a type in expression"); +} + static void primary_expression(int mode, Value * v) { if (text_sy == '(') { next_sy(); @@ -1308,20 +1313,25 @@ static void primary_expression(int mode, Value * v) { next_sy(); } else if (text_sy == SY_VAL) { - if (mode != MODE_SKIP) *v = text_val; - else memset(v, 0, sizeof(Value)); + *v = text_val; next_sy(); + if (v->type_class == TYPE_CLASS_ARRAY && text_sy == SY_SCOPE) { + Value x; + char * name = (char *)v->value; + if (identifier(mode, NULL, name, 0, &x) < 0) + error(ERR_INV_EXPRESSION, "Undefined identifier '%s'", name); + next_sy(); + qualified_name_expression(mode, &x, v); + } } else if (text_sy == SY_SCOPE) { Value x; next_sy(); memset(&x, 0, sizeof(x)); - if (qualified_name(mode, &x, 0, v) == SYM_CLASS_TYPE) - error(ERR_INV_EXPRESSION, "Illegal usage of a type in expression"); + qualified_name_expression(mode, &x, v); } else if (text_sy == SY_NAME || text_sy == SY_ID) { - if (qualified_name(mode, NULL, 0, v) == SYM_CLASS_TYPE) - error(ERR_INV_EXPRESSION, "Illegal usage of a type in expression"); + qualified_name_expression(mode, NULL, v); } else { error(ERR_INV_EXPRESSION, "Syntax error"); |