diff options
author | Eugene Tarassov | 2015-05-06 01:26:06 +0000 |
---|---|---|
committer | Eugene Tarassov | 2015-05-06 01:26:06 +0000 |
commit | bb862097061927db035e7928c51678dadea2f666 (patch) | |
tree | 04198c16669bccb40fd2cd45f57582535b946ce8 | |
parent | a11ae4d89c7899ba975b9f924f340515c21ce28a (diff) | |
download | org.eclipse.tcf.agent-bb862097061927db035e7928c51678dadea2f666.tar.gz org.eclipse.tcf.agent-bb862097061927db035e7928c51678dadea2f666.tar.xz org.eclipse.tcf.agent-bb862097061927db035e7928c51678dadea2f666.zip |
TCF Agent: A bit of code cleanup
-rw-r--r-- | agent/tcf/services/breakpoints.c | 8 | ||||
-rw-r--r-- | agent/tcf/services/symbols.c | 2 | ||||
-rw-r--r-- | agent/tcf/services/symbols.h | 4 | ||||
-rw-r--r-- | agent/tcf/services/symbols_elf.c | 40 |
4 files changed, 26 insertions, 28 deletions
diff --git a/agent/tcf/services/breakpoints.c b/agent/tcf/services/breakpoints.c index ed13c22e..fac27145 100644 --- a/agent/tcf/services/breakpoints.c +++ b/agent/tcf/services/breakpoints.c @@ -1422,12 +1422,12 @@ static void plant_at_address_expression(Context * ctx, ContextAddress ip, Breakp int error = 0; Value v; SymbolProperties props; - + if (evaluate_expression(ctx, STACK_NO_FRAME, ip, bp->location, 1, &v) < 0) error = errno; if (!error && value_to_address(&v, &addr) < 0) error = errno; if (v.sym != NULL) { /* We want to add the LocalEntryOffset */ - get_symbol_props(v.sym, &props); + get_symbol_props(v.sym, &props); /* If the symbol is not a PPC64 function, offset should be 0, so it is safe to add */ addr += props.local_entry_offset; } @@ -1464,9 +1464,9 @@ static void plant_at_address_expression(Context * ctx, ContextAddress ip, Breakp unsigned n = 0; while (v.sym_list[n] != NULL) { Symbol * sym = v.sym_list[n++]; - if (get_symbol_address(sym, &addr) == 0) { + if (get_symbol_address(sym, &addr) == 0) { /* We want to add the LocalEntryOffset */ - get_symbol_props(sym, &props); + get_symbol_props(sym, &props); /* If the symbol is not a PPC64 function, offset should be 0, so it is safe to add */ addr += props.local_entry_offset; #if ENABLE_SkipPrologueWhenPlanting diff --git a/agent/tcf/services/symbols.c b/agent/tcf/services/symbols.c index edbf834f..e0c68b38 100644 --- a/agent/tcf/services/symbols.c +++ b/agent/tcf/services/symbols.c @@ -309,7 +309,7 @@ static void command_get_context_cache_client(void * x) { json_write_ulong(&c->out, props.local_entry_offset); write_stream(&c->out, ','); } - + if (value != NULL) { json_write_string(&c->out, "Value"); write_stream(&c->out, ':'); diff --git a/agent/tcf/services/symbols.h b/agent/tcf/services/symbols.h index 33a39972..429054e8 100644 --- a/agent/tcf/services/symbols.h +++ b/agent/tcf/services/symbols.h @@ -91,8 +91,8 @@ typedef uint32_t SYM_FLAGS; typedef struct SymbolProperties { int binary_scale; /* The exponent of the base two scale factor to be applied to an instance of the type */ int decimal_scale; /* The exponent of the base ten scale factor to be applied to an instance of the type */ - unsigned bit_stride; - unsigned int local_entry_offset; /* Only PPC64 v2 supports it */ + unsigned bit_stride; + unsigned local_entry_offset; /* Only PPC64 v2 supports it */ } SymbolProperties; /* Symbol properties update policies */ diff --git a/agent/tcf/services/symbols_elf.c b/agent/tcf/services/symbols_elf.c index c014961d..3b78b1e3 100644 --- a/agent/tcf/services/symbols_elf.c +++ b/agent/tcf/services/symbols_elf.c @@ -4147,11 +4147,11 @@ int get_symbol_flags(const Symbol * sym, SYM_FLAGS * flags) { } int get_symbol_props(const Symbol * sym, SymbolProperties * props) { -#define STO_PPC64_LOCAL_BIT 5 -#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT) +#define STO_PPC64_LOCAL_BIT 5 +#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT) #define IS_PPC64_V2(elfsym) ((elfsym->file->machine == EM_PPC64) && (elfsym->file->flags & 0x3) == 2) - - ELF_SymbolInfo elf_sym_info; + + ELF_SymbolInfo elf_sym_info; ObjectInfo * obj = sym->obj; assert(sym->magic == SYMBOL_MAGIC); memset(props, 0, sizeof(SymbolProperties)); @@ -4167,25 +4167,23 @@ int get_symbol_props(const Symbol * sym, SymbolProperties * props) { if (get_num_prop(obj, AT_stride_size, &n)) props->bit_stride = (unsigned)n; } } - + /* PowerPC64 ABIv2 computes local offset from st_other */ if (sym->tbl != NULL) { - /* Only do that on PPC64 v2 */ - if (!IS_PPC64_V2(sym->tbl)) - return 0; - unpack_elf_symbol_info(sym->tbl, sym->index, &elf_sym_info); - } else { - Symbol *elf_symbol; - /* From Dwarf object to Elf symbol */ - map_to_sym_table(sym->obj, &elf_symbol); - if (elf_symbol == NULL) - return 0; - if (!IS_PPC64_V2(elf_symbol->tbl)) - return 0; - unpack_elf_symbol_info(elf_symbol->tbl, elf_symbol->index, &elf_sym_info); - } - /* We can compute the offset now */ - props->local_entry_offset = (((1 << (((elf_sym_info.other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2); + /* Only do that on PPC64 v2 */ + if (!IS_PPC64_V2(sym->tbl)) return 0; + unpack_elf_symbol_info(sym->tbl, sym->index, &elf_sym_info); + } + else { + Symbol * elf_symbol = NULL; + /* From Dwarf object to Elf symbol */ + map_to_sym_table(sym->obj, &elf_symbol); + if (elf_symbol == NULL) return 0; + if (!IS_PPC64_V2(elf_symbol->tbl)) return 0; + unpack_elf_symbol_info(elf_symbol->tbl, elf_symbol->index, &elf_sym_info); + } + /* We can compute the offset now */ + props->local_entry_offset = (((1 << (((elf_sym_info.other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2); return 0; } |