Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2008-11-06 20:47:24 +0000
committereutarass2008-11-06 20:47:24 +0000
commit96565c9d546c917001b89d345c676c37bf652c05 (patch)
treeb196e6b68a16b82fa5d45bb9cb298a9a61044827
parent7245bb099bbf157ffbce63fd15d7d4213561fe8f (diff)
downloadorg.eclipse.tcf.agent-96565c9d546c917001b89d345c676c37bf652c05.tar.gz
org.eclipse.tcf.agent-96565c9d546c917001b89d345c676c37bf652c05.tar.xz
org.eclipse.tcf.agent-96565c9d546c917001b89d345c676c37bf652c05.zip
1. TCF Agent Symbols service: new function get_symbol_pointer() returns symbol that represents result type of '&' operation in an expression.
2. Expressions service and Expressions view now support '&' operation in expressions.
-rw-r--r--TCF Agent - Linux i686.launch24
-rw-r--r--expressions.c19
-rw-r--r--symbols.h3
-rw-r--r--symbols_elf.c92
-rw-r--r--symbols_win32.c86
5 files changed, 192 insertions, 32 deletions
diff --git a/TCF Agent - Linux i686.launch b/TCF Agent - Linux i686.launch
index c131118d..ce8f8991 100644
--- a/TCF Agent - Linux i686.launch
+++ b/TCF Agent - Linux i686.launch
@@ -1,12 +1,12 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.tm.tcf.debug.LaunchConfigurationType">
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/>
-<stringAttribute key="org.eclipse.tm.tcf.debug.LocalProgramFile" value="Linux/i686/Debug/agent"/>
-<stringAttribute key="org.eclipse.tm.tcf.debug.PeerID" value="TCP:172.25.38.204:1534"/>
-<stringAttribute key="org.eclipse.tm.tcf.debug.ProgramArguments" value="-xxx"/>
-<stringAttribute key="org.eclipse.tm.tcf.debug.ProgramFile" value="/tmp/agent"/>
-<stringAttribute key="org.eclipse.tm.tcf.debug.ProjectName" value="org.eclipse.tm.tcf.agent"/>
-<booleanAttribute key="org.eclipse.tm.tcf.debug.UseTerminal" value="true"/>
-<stringAttribute key="org.eclipse.tm.tcf.debug.WorkingDirectory" value="/tmp"/>
-</launchConfiguration>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.tm.tcf.debug.LaunchConfigurationType">
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_ENCODING" value="UTF-8"/>
+<stringAttribute key="org.eclipse.tm.tcf.debug.LocalProgramFile" value="Linux/i686/Debug/agent"/>
+<stringAttribute key="org.eclipse.tm.tcf.debug.PeerID" value="TCP:147.11.46.31:1534"/>
+<stringAttribute key="org.eclipse.tm.tcf.debug.ProgramArguments" value="-t"/>
+<stringAttribute key="org.eclipse.tm.tcf.debug.ProgramFile" value="/tmp/agent"/>
+<stringAttribute key="org.eclipse.tm.tcf.debug.ProjectName" value="org.eclipse.tm.tcf.agent"/>
+<booleanAttribute key="org.eclipse.tm.tcf.debug.UseTerminal" value="true"/>
+<stringAttribute key="org.eclipse.tm.tcf.debug.WorkingDirectory" value="/tmp"/>
+</launchConfiguration>
diff --git a/expressions.c b/expressions.c
index 31f1bb05..6626ecbf 100644
--- a/expressions.c
+++ b/expressions.c
@@ -853,6 +853,23 @@ static void op_index(Value * v) {
#endif
}
+static void op_addr(Value * v) {
+ if (!v->remote) error(ERR_INV_EXPRESSION, "Invalid '&': value has no address");
+ v->size = sizeof(ContextAddress);
+ v->value = alloc_str(text_val.size);
+ v->remote = 0;
+ *(ContextAddress *)v->value = v->address;
+ v->address = 0;
+ v->type_class = TYPE_CLASS_POINTER;
+#if SERVICE_Symbols
+ if (get_symbol_pointer(&v->type, &v->type)) {
+ error(errno, "Cannot get pointer type");
+ }
+#else
+ memset(&v->type, 0, sizeof(v->type));
+#endif
+}
+
static void postfix_expression(Value * v) {
primary_expression(v);
while (1) {
@@ -889,7 +906,7 @@ static void unary_expression(Value * v) {
case '&':
next_sy();
unary_expression(v);
- error(ERR_INV_EXPRESSION, "TODO");
+ op_addr(v);
break;
case '+':
next_sy();
diff --git a/symbols.h b/symbols.h
index 4daacd84..fc0233ff 100644
--- a/symbols.h
+++ b/symbols.h
@@ -122,6 +122,9 @@ extern int get_symbol_value(const Symbol * sym, void ** value, size_t * size);
/* Get address (variables) */
extern int get_symbol_address(const Symbol * sym, int frame, ContextAddress * address);
+/* Get a type that represents a pointer to given base type */
+extern int get_symbol_pointer(const Symbol * sym, Symbol * ptr);
+
/*************************************************************************************************/
diff --git a/symbols_elf.c b/symbols_elf.c
index 7a9b5171..7b51ba0d 100644
--- a/symbols_elf.c
+++ b/symbols_elf.c
@@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2007, 2008 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
+ * 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.
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
+ * and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
- *
+ *
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
@@ -47,6 +47,7 @@ typedef struct SymLocation {
SymbolSection * tbl;
unsigned index;
unsigned dimension;
+ unsigned pointer;
} SymLocation;
static void object2symbol(Context * ctx, ObjectInfo * obj, Symbol * sym) {
@@ -200,7 +201,7 @@ int find_symbol(Context * ctx, int frame, char * name, Symbol * sym) {
int found = 0;
#if defined(_WRS_KERNEL)
-
+
char * ptr;
SYM_TYPE type;
@@ -213,7 +214,7 @@ int find_symbol(Context * ctx, int frame, char * name, Symbol * sym) {
memset(sym, 0, sizeof(Symbol));
sym->ctx = ctx;
((SymLocation *)sym->location)->addr = ptr;
-
+
if (SYM_IS_TEXT(type)) {
sym->sym_class = SYM_CLASS_FUNCTION;
}
@@ -222,19 +223,19 @@ int find_symbol(Context * ctx, int frame, char * name, Symbol * sym) {
}
found = 1;
}
-
+
#endif
if (error == 0 && !found) {
ContextAddress ip = 0;
-
+
if (frame != STACK_NO_FRAME) {
if (get_frame_info(ctx, frame, &ip, NULL, NULL) < 0) error = errno;
}
-
+
if (error == 0) {
ELF_File * file = elf_list_first(ctx, ip, ip == 0 ? ~(ContextAddress)0 : ip + 1);
- if (file == NULL) error = errno;
+ if (file == NULL) error = errno;
while (error == 0 && file != NULL) {
Trap trap;
if (set_trap(&trap)) {
@@ -293,7 +294,7 @@ static void enumerate_local_vars(Context * ctx, ObjectInfo * obj, ContextAddress
int enumerate_symbols(Context * ctx, int frame, EnumerateSymbolsCallBack * call_back, void * args) {
int error = 0;
ContextAddress ip = 0;
-
+
if (frame != STACK_NO_FRAME) {
if (get_frame_info(ctx, frame, &ip, NULL, NULL) < 0) error = errno;
}
@@ -345,10 +346,10 @@ char * symbol2id(const Symbol * sym) {
if (file == NULL) return "SYM";
if (loc->obj != NULL) obj_index = loc->obj->mID;
if (loc->tbl != NULL) tbl_index = loc->tbl->mIndex + 1;
- snprintf(id, sizeof(id), "SYM%X.%lX.%lX.%X.%llX.%X.%X.%X.%s",
+ snprintf(id, sizeof(id), "SYM%X.%lX.%lX.%X.%llX.%X.%X.%X.%X.%s",
sym->sym_class, (unsigned long)file->dev, (unsigned long)file->ino,
(unsigned)file->mtime & 0xffff, obj_index, tbl_index,
- loc->index, loc->dimension, container_id(sym->ctx));
+ loc->index, loc->dimension, loc->pointer, container_id(sym->ctx));
return id;
}
@@ -412,6 +413,8 @@ int id2symbol(char * id, Symbol * sym) {
if (*p == '.') p++;
loc->dimension = read_hex(&p);
if (*p == '.') p++;
+ loc->pointer = read_hex(&p);
+ if (*p == '.') p++;
sym->ctx = id2ctx(p);
if (sym->ctx == NULL) {
errno = ERR_INV_CONTEXT;
@@ -541,6 +544,10 @@ static ObjectInfo * get_object_type(ObjectInfo * obj) {
}
int get_symbol_type(const Symbol * sym, Symbol * type) {
+ if (((SymLocation *)sym->location)->pointer) {
+ *type = *sym;
+ return 0;
+ }
if (unpack(sym) < 0) return -1;
obj = get_object_type(obj);
if (obj != NULL) object2symbol(sym->ctx, obj, type);
@@ -549,6 +556,10 @@ int get_symbol_type(const Symbol * sym, Symbol * type) {
}
int get_symbol_type_class(const Symbol * sym, int * type_class) {
+ if (((SymLocation *)sym->location)->pointer) {
+ *type_class = TYPE_CLASS_POINTER;
+ return 0;
+ }
if (unpack(sym) < 0) return -1;
while (obj != NULL) {
switch (obj->mTag) {
@@ -621,6 +632,10 @@ int get_symbol_type_class(const Symbol * sym, int * type_class) {
}
int get_symbol_name(const Symbol * sym, char ** name) {
+ if (((SymLocation *)sym->location)->pointer) {
+ *name = NULL;
+ return 0;
+ }
if (unpack(sym) < 0) return -1;
if (obj != NULL) {
*name = obj->mName == NULL ? NULL : loc_strdup(obj->mName);
@@ -638,6 +653,10 @@ int get_symbol_name(const Symbol * sym, char ** name) {
}
int get_symbol_size(const Symbol * sym, size_t * size) {
+ if (((SymLocation *)sym->location)->pointer) {
+ *size = sizeof(void *);
+ return 0;
+ }
if (unpack(sym) < 0) return -1;
if (obj != NULL) {
if (sym->sym_class == SYM_CLASS_REFERENCE && obj->mSize == 0 && obj->mType != NULL) obj = obj->mType;
@@ -692,6 +711,11 @@ int get_symbol_size(const Symbol * sym, size_t * size) {
}
int get_symbol_base_type(const Symbol * sym, Symbol * base_type) {
+ if (((SymLocation *)sym->location)->pointer) {
+ *base_type = *sym;
+ ((SymLocation *)base_type->location)->pointer--;
+ return 0;
+ }
if (unpack(sym) < 0) return -1;
if (obj != NULL) {
obj = get_object_type(obj);
@@ -720,6 +744,10 @@ int get_symbol_base_type(const Symbol * sym, Symbol * base_type) {
}
int get_symbol_index_type(const Symbol * sym, Symbol * index_type) {
+ if (((SymLocation *)sym->location)->pointer) {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
if (unpack(sym) < 0) return -1;
if (obj != NULL) {
obj = get_object_type(obj);
@@ -741,6 +769,10 @@ int get_symbol_index_type(const Symbol * sym, Symbol * index_type) {
}
int get_symbol_length(const Symbol * sym, unsigned long * length) {
+ if (((SymLocation *)sym->location)->pointer) {
+ *length = 1;
+ return 0;
+ }
if (unpack(sym) < 0) return -1;
if (obj != NULL) {
obj = get_object_type(obj);
@@ -762,6 +794,11 @@ int get_symbol_length(const Symbol * sym, unsigned long * length) {
}
int get_symbol_children(const Symbol * sym, Symbol ** children, int * count) {
+ if (((SymLocation *)sym->location)->pointer) {
+ *children = NULL;
+ *count = 0;
+ return 0;
+ }
int n = 0;
if (unpack(sym) < 0) return -1;
*children = NULL;
@@ -785,6 +822,10 @@ int get_symbol_children(const Symbol * sym, Symbol ** children, int * count) {
}
int get_symbol_offset(const Symbol * sym, unsigned long * offset) {
+ if (((SymLocation *)sym->location)->pointer) {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
if (unpack(sym) < 0) return -1;
if (obj != NULL && obj->mTag == TAG_member) {
U8_T addr = 0;
@@ -797,6 +838,10 @@ int get_symbol_offset(const Symbol * sym, unsigned long * offset) {
}
int get_symbol_value(const Symbol * sym, void ** value, size_t * size) {
+ if (((SymLocation *)sym->location)->pointer) {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
if (unpack(sym) < 0) return -1;
if (obj != NULL && obj->mConstValueAddr != NULL) {
*size = obj->mConstValueSize;
@@ -809,6 +854,10 @@ int get_symbol_value(const Symbol * sym, void ** value, size_t * size) {
}
int get_symbol_address(const Symbol * sym, int frame, ContextAddress * address) {
+ if (((SymLocation *)sym->location)->pointer) {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
if (unpack(sym) < 0) return -1;
if (obj != NULL && obj->mTag != TAG_member) {
U8_T addr = 0;
@@ -839,5 +888,22 @@ int get_symbol_address(const Symbol * sym, int frame, ContextAddress * address)
return -1;
}
+int get_symbol_pointer(const Symbol * sym, Symbol * ptr) {
+ *ptr = *sym;
+ if (!((SymLocation *)ptr->location)->pointer) {
+ if (unpack(ptr) < 0) return -1;
+ obj = get_object_type(obj);
+ if (obj != NULL) {
+ object2symbol(ptr->ctx, obj, ptr);
+ }
+ else {
+ memset(ptr, 0, sizeof(Symbol));
+ ptr->sym_class = SYM_CLASS_TYPE;
+ }
+ }
+ assert(ptr->sym_class == SYM_CLASS_TYPE);
+ ((SymLocation *)ptr->location)->pointer++;
+ return 0;
+}
#endif
diff --git a/symbols_win32.c b/symbols_win32.c
index 26cb9271..1df98c71 100644
--- a/symbols_win32.c
+++ b/symbols_win32.c
@@ -45,6 +45,7 @@
typedef struct SymLocation {
ULONG64 module;
ULONG index;
+ unsigned pointer;
} SymLocation;
static char * tmp_buf = NULL;
@@ -145,15 +146,15 @@ static int get_type_tag(Symbol * type, DWORD * tag) {
char * symbol2id(const Symbol * sym) {
static char buf[256];
const SymLocation * loc = (const SymLocation *)sym->location;
- snprintf(buf, sizeof(buf), "SYM%llX.%lX.%s",
- loc->module, loc->index, container_id(sym->ctx));
+ snprintf(buf, sizeof(buf), "SYM%llX.%lX.%X.%s",
+ loc->module, loc->index, loc->pointer, container_id(sym->ctx));
return buf;
}
int id2symbol(char * id, Symbol * sym) {
ULONG64 module = 0;
ULONG index = 0;
- DWORD dword = 0;
+ unsigned pointer = 0;
SymLocation * loc = (SymLocation *)sym->location;
char * p;
@@ -182,16 +183,33 @@ int id2symbol(char * id, Symbol * sym) {
errno = ERR_INV_CONTEXT;
return -1;
}
+ while (1) {
+ if (*p >= '0' && *p <= '9') pointer = (pointer << 4) | (*p - '0');
+ else if (*p >= 'A' && *p <= 'F') pointer = (pointer << 4) | (*p - 'A' + 10);
+ else break;
+ p++;
+ }
+ if (*p++ != '.') {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
memset(sym, 0, sizeof(Symbol));
sym->ctx = id2ctx(p);
loc->module = module;
loc->index = index;
+ loc->pointer = pointer;
if (sym->ctx == NULL) {
errno = ERR_INV_CONTEXT;
return -1;
}
- if (get_type_info(sym, TI_GET_SYMTAG, &dword) < 0) return -1;
- tag2symclass(sym, dword);
+ if (loc->pointer) {
+ sym->sym_class = SYM_CLASS_TYPE;
+ }
+ else {
+ DWORD dword = 0;
+ if (get_type_info(sym, TI_GET_SYMTAG, &dword) < 0) return -1;
+ tag2symclass(sym, dword);
+ }
return 0;
}
@@ -201,6 +219,10 @@ int get_symbol_type_class(const Symbol * sym, int * type_class) {
DWORD tag = 0;
DWORD base = 0;
+ if (((SymLocation *)sym->location)->pointer) {
+ *type_class = TYPE_CLASS_POINTER;
+ return 0;
+ }
if (get_type_tag(&type, &tag)) return -1;
switch (tag) {
@@ -263,6 +285,10 @@ int get_symbol_name(const Symbol * sym, char ** name) {
WCHAR * ptr = NULL;
char * res = NULL;
+ if (((SymLocation *)sym->location)->pointer) {
+ *name = NULL;
+ return 0;
+ }
if (get_type_info(sym, TI_GET_SYMNAME, &ptr) < 0) return -1;
if (ptr != NULL) {
int len = 0;
@@ -296,6 +322,10 @@ int get_symbol_size(const Symbol * sym, size_t * size) {
Symbol type = *sym;
DWORD tag = 0;
+ if (((SymLocation *)sym->location)->pointer) {
+ *size = sizeof(void *);
+ return 0;
+ }
if (get_type_tag(&type, &tag)) return -1;
if (get_type_info(&type, TI_GET_LENGTH, &res) < 0) return -1;
@@ -308,7 +338,10 @@ int get_symbol_type(const Symbol * sym, Symbol * type) {
DWORD index = 0;
*type = *sym;
- if (get_type_tag(type, &tag)) return -1;
+ if (!((SymLocation *)type->location)->pointer) {
+ if (get_type_tag(type, &tag)) return -1;
+ }
+ assert(type->sym_class == SYM_CLASS_TYPE);
return 0;
}
@@ -317,6 +350,10 @@ int get_symbol_base_type(const Symbol * sym, Symbol * type) {
DWORD index = 0;
*type = *sym;
+ if (((SymLocation *)type->location)->pointer) {
+ ((SymLocation *)type->location)->pointer--;
+ return 0;
+ }
if (get_type_tag(type, &tag)) return -1;
if (get_type_info(type, TI_GET_TYPE, &index) < 0) return -1;
((SymLocation *)type->location)->index = index;
@@ -328,6 +365,10 @@ int get_symbol_index_type(const Symbol * sym, Symbol * type) {
DWORD tag = 0;
DWORD index = 0;
+ if (((SymLocation *)sym->location)->pointer) {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
*type = *sym;
if (get_type_tag(type, &tag)) return -1;
if (get_type_info(type, TI_GET_ARRAYINDEXTYPEID, &index) < 0) return -1;
@@ -341,6 +382,10 @@ int get_symbol_length(const Symbol * sym, unsigned long * length) {
Symbol type = *sym;
DWORD tag = 0;
+ if (((SymLocation *)sym->location)->pointer) {
+ *length = 1;
+ return 0;
+ }
if (get_type_tag(&type, &tag)) return -1;
if (get_type_info(&type, TI_GET_COUNT, &res) < 0) return -1;
@@ -358,6 +403,11 @@ int get_symbol_children(const Symbol * sym, Symbol ** children, int * count) {
Symbol type = *sym;
DWORD tag = 0;
+ if (((SymLocation *)sym->location)->pointer) {
+ *children = NULL;
+ *count = 0;
+ return 0;
+ }
if (get_type_tag(&type, &tag)) return -1;
if (get_type_info(&type, TI_GET_CHILDRENCOUNT, &cnt) < 0) return -1;
if (params == NULL) params = loc_alloc(sizeof(TI_FINDCHILDREN_PARAMS) + (FINDCHILDREN_BUF_SIZE - 1) * sizeof(ULONG));
@@ -386,6 +436,10 @@ int get_symbol_children(const Symbol * sym, Symbol ** children, int * count) {
int get_symbol_offset(const Symbol * sym, unsigned long * offset) {
DWORD dword = 0;
+ if (((SymLocation *)sym->location)->pointer) {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
if (get_type_info(sym, TI_GET_OFFSET, &dword) < 0) return -1;
*offset = dword;
return 0;
@@ -397,6 +451,10 @@ int get_symbol_value(const Symbol * sym, void ** value, size_t * size) {
void * data_addr = &data.bVal;
size_t data_size = 0;
+ if (((SymLocation *)sym->location)->pointer) {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
assert(data_addr == &data.lVal);
if (get_type_info(sym, TI_GET_VALUE, &data) < 0) return -1;
@@ -442,6 +500,10 @@ int get_symbol_value(const Symbol * sym, void ** value, size_t * size) {
int get_symbol_address(const Symbol * sym, int frame, ContextAddress * addr) {
SYMBOL_INFO * info = NULL;
+ if (((SymLocation *)sym->location)->pointer) {
+ errno = ERR_INV_CONTEXT;
+ return -1;
+ }
if (get_sym_info(sym, ((SymLocation *)sym->location)->index, &info) < 0) return -1;
*addr = (ContextAddress)info->Address;
@@ -454,6 +516,18 @@ int get_symbol_address(const Symbol * sym, int frame, ContextAddress * addr) {
return 0;
}
+int get_symbol_pointer(const Symbol * sym, Symbol * ptr) {
+ DWORD tag = 0;
+
+ *ptr = *sym;
+ if (!((SymLocation *)ptr->location)->pointer) {
+ if (get_type_tag(ptr, &tag)) return -1;
+ }
+ assert(ptr->sym_class == SYM_CLASS_TYPE);
+ ((SymLocation *)ptr->location)->pointer++;
+ return 0;
+}
+
int find_symbol(Context * ctx, int frame, char * name, Symbol * sym) {
ULONG64 buffer[(sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR) + sizeof(ULONG64) - 1) / sizeof(ULONG64)];
SYMBOL_INFO * info = (SYMBOL_INFO *)buffer;

Back to the top