diff options
author | eutarass | 2011-06-24 16:37:20 +0000 |
---|---|---|
committer | eutarass | 2011-06-24 16:37:20 +0000 |
commit | 8286eef85097b5bcc1ff194fbabb16a0cea3c1de (patch) | |
tree | f522bfcafea783deaff1aba3d27d90a62277aa91 | |
parent | 981b137e8a24e4e67d8ba91222dd7a3cb0e6642b (diff) | |
download | org.eclipse.tcf.agent-8286eef85097b5bcc1ff194fbabb16a0cea3c1de.tar.gz org.eclipse.tcf.agent-8286eef85097b5bcc1ff194fbabb16a0cea3c1de.tar.xz org.eclipse.tcf.agent-8286eef85097b5bcc1ff194fbabb16a0cea3c1de.zip |
TCF Agent: changes to allow building the agent with -DENABLE_ELF=1 -DENABLE_DebugContext=0
-rw-r--r-- | framework/context.c | 48 | ||||
-rw-r--r-- | framework/context.h | 25 | ||||
-rw-r--r-- | services/dwarfcache.c | 4 | ||||
-rw-r--r-- | services/dwarfcache.h | 6 | ||||
-rw-r--r-- | services/dwarfexpr.c | 4 | ||||
-rw-r--r-- | services/dwarfexpr.h | 4 | ||||
-rw-r--r-- | services/dwarfframe.c | 4 | ||||
-rw-r--r-- | services/dwarfframe.h | 4 | ||||
-rw-r--r-- | services/memorymap.c | 29 | ||||
-rw-r--r-- | services/tcf_elf.c | 8 | ||||
-rw-r--r-- | services/tcf_elf.h | 6 |
11 files changed, 81 insertions, 61 deletions
diff --git a/framework/context.c b/framework/context.c index 97899b04..c9318424 100644 --- a/framework/context.c +++ b/framework/context.c @@ -32,6 +32,9 @@ static Listener * listeners = NULL; static unsigned listener_cnt = 0; static unsigned listener_max = 0; +static size_t extension_size = 0; +static int context_created = 0; + LINK context_root = { NULL, NULL }; const char * REASON_USER_REQUEST = "Suspended"; @@ -94,11 +97,6 @@ void add_context_event_listener(ContextEventListener * listener, void * client_d listener_cnt++; } -#if ENABLE_DebugContext - -static size_t extension_size = 0; -static int context_created = 0; - size_t context_extension(size_t size) { size_t offs = 0; assert(!context_created); @@ -117,6 +115,27 @@ Context * create_context(const char * id) { return ctx; } +void context_clear_memory_map(MemoryMap * map) { + unsigned i; + for (i = 0; i < map->region_cnt; i++) { + MemoryRegion * r = map->regions + i; + loc_free(r->file_name); + loc_free(r->sect_name); + loc_free(r->id); + while (r->attrs != NULL) { + MemoryRegionAttribute * x = r->attrs; + r->attrs = x->next; + loc_free(x->name); + loc_free(x->value); + loc_free(x); + } + } + memset(map->regions, 0, sizeof(MemoryRegion) * map->region_max); + map->region_cnt = 0; +} + +#if ENABLE_DebugContext + void context_lock(Context * ctx) { assert(ctx->ref_count > 0); ctx->ref_count++; @@ -159,25 +178,6 @@ const char * context_state_name(Context * ctx) { return "running"; } -void context_clear_memory_map(MemoryMap * map) { - unsigned i; - for (i = 0; i < map->region_cnt; i++) { - MemoryRegion * r = map->regions + i; - loc_free(r->file_name); - loc_free(r->sect_name); - loc_free(r->id); - while (r->attrs != NULL) { - MemoryRegionAttribute * x = r->attrs; - r->attrs = x->next; - loc_free(x->name); - loc_free(x->value); - loc_free(x); - } - } - memset(map->regions, 0, sizeof(MemoryRegion) * map->region_max); - map->region_cnt = 0; -} - void send_context_created_event(Context * ctx) { unsigned i; assert(ctx->ref_count > 0); diff --git a/framework/context.h b/framework/context.h index 45ae0bcc..5940d926 100644 --- a/framework/context.h +++ b/framework/context.h @@ -185,8 +185,6 @@ extern pid_t id2pid(const char * id, pid_t * parent); */ extern Context * id2ctx(const char * id); -#if ENABLE_DebugContext - /* * Register an extension of struct Context. * Return offset of extension data area. @@ -196,6 +194,18 @@ extern Context * id2ctx(const char * id); extern size_t context_extension(size_t size); /* + * Create a Context object. + */ +extern Context * create_context(const char * id); + +/* + * Clear a memory map - dispose all entries. + */ +extern void context_clear_memory_map(MemoryMap * map); + +#if ENABLE_DebugContext + +/* * Get human redable name of current state of a context. */ extern const char * context_state_name(Context * ctx); @@ -305,11 +315,6 @@ extern int context_single_step(Context * ctx); extern int context_get_memory_map(Context * ctx, MemoryMap * map); /* - * Clear a memory map - dispose all entries. - */ -extern void context_clear_memory_map(MemoryMap * map); - -/* * Write context memory. * Implementation calls check_breakpoints_on_memory_write() before writing to context memory, * which can change contents of the buffer. @@ -465,12 +470,6 @@ extern void send_context_stopped_event(Context * ctx); extern void send_context_started_event(Context * ctx); extern void send_context_exited_event(Context * ctx); -/* - * Create a Context object. - * It is not supposed to be called by clients. - */ -extern Context * create_context(const char * id); - extern void ini_contexts(void); extern void init_contexts_sys_dep(void); diff --git a/services/dwarfcache.c b/services/dwarfcache.c index c75391f1..0f3d27d0 100644 --- a/services/dwarfcache.c +++ b/services/dwarfcache.c @@ -21,7 +21,7 @@ #include <config.h> -#if ENABLE_ELF +#if ENABLE_ELF && ENABLE_DebugContext #include <assert.h> #include <framework/exceptions.h> @@ -1078,4 +1078,4 @@ UnitAddressRange * find_comp_unit_addr_range(DWARFCache * cache, ContextAddress return NULL; } -#endif /* ENABLE_ELF */ +#endif /* ENABLE_ELF && ENABLE_DebugContext */ diff --git a/services/dwarfcache.h b/services/dwarfcache.h index a5980fed..e608481b 100644 --- a/services/dwarfcache.h +++ b/services/dwarfcache.h @@ -26,7 +26,7 @@ #include <config.h> -#if ENABLE_ELF +#if ENABLE_ELF && ENABLE_DebugContext #include <services/tcf_elf.h> #include <services/dwarfio.h> @@ -55,8 +55,6 @@ struct FileInfo { unsigned mNameHash; }; -#define SYM_HASH_SIZE (32 * MEM_USAGE_FACTOR - 1) - #define TAG_fund_type 0x2000 struct ObjectInfo { @@ -223,6 +221,6 @@ extern void read_and_evaluate_dwarf_object_property(Context * ctx, int frame, U8 /* Convert PropertyValue to a number */ extern U8_T get_numeric_property_value(PropertyValue * Value); -#endif /* ENABLE_ELF */ +#endif /* ENABLE_ELF && ENABLE_DebugContext */ #endif /* D_dwarfcache */ diff --git a/services/dwarfexpr.c b/services/dwarfexpr.c index 0474656a..26b94eb0 100644 --- a/services/dwarfexpr.c +++ b/services/dwarfexpr.c @@ -19,7 +19,7 @@ #include <config.h> -#if ENABLE_ELF +#if ENABLE_ELF && ENABLE_DebugContext #include <assert.h> #include <stdio.h> @@ -584,4 +584,4 @@ void dwarf_evaluate_expression(U8_T BaseAddress, PropertyValue * Value) { if (Value->mAttr != AT_frame_base) sExprStackLen = 0; } -#endif /* ENABLE_ELF */ +#endif /* ENABLE_ELF && ENABLE_DebugContext */ diff --git a/services/dwarfexpr.h b/services/dwarfexpr.h index dc257cb2..c38f3a00 100644 --- a/services/dwarfexpr.h +++ b/services/dwarfexpr.h @@ -23,12 +23,12 @@ #include <config.h> -#if ENABLE_ELF +#if ENABLE_ELF && ENABLE_DebugContext #include <services/dwarfcache.h> extern void dwarf_evaluate_expression(U8_T base, PropertyValue * value); -#endif /* ENABLE_ELF */ +#endif /* ENABLE_ELF && ENABLE_DebugContext */ #endif /* D_dwarfexpr */ diff --git a/services/dwarfframe.c b/services/dwarfframe.c index 9988d4e9..dc610904 100644 --- a/services/dwarfframe.c +++ b/services/dwarfframe.c @@ -21,7 +21,7 @@ #include <config.h> -#if ENABLE_ELF +#if ENABLE_ELF && ENABLE_DebugContext #include <assert.h> #include <stdio.h> @@ -1000,4 +1000,4 @@ void get_dwarf_stack_frame_info(Context * ctx, ELF_File * file, ELF_Section * se } } -#endif /* ENABLE_ELF */ +#endif /* ENABLE_ELF && ENABLE_DebugContext */ diff --git a/services/dwarfframe.h b/services/dwarfframe.h index 225ca575..c4107f2a 100644 --- a/services/dwarfframe.h +++ b/services/dwarfframe.h @@ -24,7 +24,7 @@ #include <config.h> -#if ENABLE_ELF +#if ENABLE_ELF && ENABLE_DebugContext #include <framework/context.h> #include <services/dwarfcache.h> @@ -51,6 +51,6 @@ extern StackTracingCommandSequence * dwarf_stack_trace_fp; extern int dwarf_stack_trace_regs_cnt; extern StackTracingCommandSequence ** dwarf_stack_trace_regs; -#endif /* ENABLE_ELF */ +#endif /* ENABLE_ELF && ENABLE_DebugContext */ #endif /* D_dwarfframe */ diff --git a/services/memorymap.c b/services/memorymap.c index f987b99d..a9ebf796 100644 --- a/services/memorymap.c +++ b/services/memorymap.c @@ -124,6 +124,13 @@ static unsigned find_maps(LINK * maps, const char * id) { return cnt; } +static Context * get_mem_context(Context * ctx) { +#if ENABLE_DebugContext + ctx = context_get_group(ctx, CONTEXT_GROUP_PROCESS); +#endif + return ctx; +} + static void update_context_client_map(Context * ctx) { ContextExtensionMM * ext = EXT(ctx); unsigned r_cnt = 0; @@ -132,7 +139,7 @@ static void update_context_client_map(Context * ctx) { LINK * l; LINK maps; - assert(ctx == context_get_group(ctx, CONTEXT_GROUP_PROCESS)); + assert(ctx == get_mem_context(ctx)); list_init(&maps); r_cnt += find_maps(&maps, ctx->id); if (ctx->name != NULL) { @@ -189,7 +196,7 @@ static void update_all_context_client_maps(void) { for (l = context_root.next; l != &context_root; l = l->next) { Context * ctx = ctxl2ctxp(l); if (ctx->exited) continue; - if (ctx != context_get_group(ctx, CONTEXT_GROUP_PROCESS)) continue; + if (ctx != get_mem_context(ctx)) continue; update_context_client_map(ctx); } } @@ -200,7 +207,7 @@ static void event_memory_map_changed(Context * ctx, void * args) { if (ctx->exited) return; if (!ext->valid) return; - if (ctx != context_get_group(ctx, CONTEXT_GROUP_PROCESS)) return; + if (ctx != get_mem_context(ctx)) return; context_clear_memory_map(&ext->target_map); ext->valid = 0; @@ -218,7 +225,7 @@ static void event_memory_map_changed(Context * ctx, void * args) { static void event_context_changed(Context * ctx, void * args) { if (ctx->exited) return; - if (ctx != context_get_group(ctx, CONTEXT_GROUP_PROCESS)) return; + if (ctx != get_mem_context(ctx)) return; update_context_client_map(ctx); } @@ -241,7 +248,8 @@ static void event_context_disposed(Context * ctx, void * args) { int memory_map_get(Context * ctx, MemoryMap ** client_map, MemoryMap ** target_map) { ContextExtensionMM * ext = EXT(ctx); - assert(ctx == context_get_group(ctx, CONTEXT_GROUP_PROCESS)); + assert(ctx == get_mem_context(ctx)); +#if ENABLE_DebugContext if (!ext->valid) { context_clear_memory_map(&ext->target_map); release_error_report(ext->error); @@ -254,6 +262,7 @@ int memory_map_get(Context * ctx, MemoryMap ** client_map, MemoryMap ** target_m ext->valid = 1; } } +#endif if (ext->error != NULL) { set_error_report_errno(ext->error); return -1; @@ -266,7 +275,7 @@ int memory_map_get(Context * ctx, MemoryMap ** client_map, MemoryMap ** target_m void memory_map_event_module_loaded(Context * ctx) { unsigned i; assert(ctx->ref_count > 0); - assert(ctx == context_get_group(ctx, CONTEXT_GROUP_PROCESS)); + assert(ctx == get_mem_context(ctx)); event_memory_map_changed(ctx, NULL); for (i = 0; i < listener_cnt; i++) { Listener * l = listeners + i; @@ -278,7 +287,7 @@ void memory_map_event_module_loaded(Context * ctx) { void memory_map_event_code_section_ummapped(Context * ctx, ContextAddress addr, ContextAddress size) { unsigned i; assert(ctx->ref_count > 0); - assert(ctx == context_get_group(ctx, CONTEXT_GROUP_PROCESS)); + assert(ctx == get_mem_context(ctx)); event_memory_map_changed(ctx, NULL); for (i = 0; i < listener_cnt; i++) { Listener * l = listeners + i; @@ -290,7 +299,7 @@ void memory_map_event_code_section_ummapped(Context * ctx, ContextAddress addr, void memory_map_event_module_unloaded(Context * ctx) { unsigned i; assert(ctx->ref_count > 0); - assert(ctx == context_get_group(ctx, CONTEXT_GROUP_PROCESS)); + assert(ctx == get_mem_context(ctx)); event_memory_map_changed(ctx, NULL); for (i = 0; i < listener_cnt; i++) { Listener * l = listeners + i; @@ -302,7 +311,7 @@ void memory_map_event_module_unloaded(Context * ctx) { void memory_map_event_mapping_chnaged(Context * ctx) { unsigned i; assert(ctx->ref_count > 0); - assert(ctx == context_get_group(ctx, CONTEXT_GROUP_PROCESS)); + assert(ctx == get_mem_context(ctx)); event_memory_map_changed(ctx, NULL); for (i = 0; i < listener_cnt; i++) { Listener * l = listeners + i; @@ -389,7 +398,7 @@ static void command_get(char * token, Channel * c) { ctx = id2ctx(id); if (ctx == NULL) err = ERR_INV_CONTEXT; - else ctx = context_get_group(ctx, CONTEXT_GROUP_PROCESS); + else ctx = get_mem_context(ctx); if (!err && memory_map_get(ctx, &client_map, &target_map) < 0) err = errno; diff --git a/services/tcf_elf.c b/services/tcf_elf.c index dc6b582d..5d75c827 100644 --- a/services/tcf_elf.c +++ b/services/tcf_elf.c @@ -760,7 +760,9 @@ static int get_map(Context * ctx, ContextAddress addr0, ContextAddress addr1, Me MemoryMap * target_map = NULL; map->region_cnt = 0; +#if ENABLE_DebugContext ctx = context_get_group(ctx, CONTEXT_GROUP_PROCESS); +#endif if (memory_map_get(ctx, &client_map, &target_map) < 0) return -1; search_regions(client_map, addr0, addr1, map); search_regions(target_map, addr0, addr1, map); @@ -839,6 +841,7 @@ void elf_list_done(Context * ctx) { elf_list.region_cnt = 0; } +#if ENABLE_DebugContext UnitAddressRange * elf_find_unit(Context * ctx, ContextAddress addr_min, ContextAddress addr_max, ContextAddress * range_rt_addr) { unsigned i, j; UnitAddressRange * range = NULL; @@ -918,6 +921,7 @@ UnitAddressRange * elf_find_unit(Context * ctx, ContextAddress addr_min, Context #endif return range; } +#endif ContextAddress elf_map_to_run_time_address(Context * ctx, ELF_File * file, ELF_Section * sec, ContextAddress addr) { unsigned i; @@ -1037,6 +1041,8 @@ ContextAddress elf_map_to_link_time_address(Context * ctx, ContextAddress addr, return 0; } +#if ENABLE_DebugContext + static int get_dynamic_tag(Context * ctx, ELF_File * file, int tag, ContextAddress * addr) { unsigned i, j; @@ -1189,6 +1195,8 @@ ContextAddress elf_get_debug_structure_address(Context * ctx, ELF_File ** file_p return addr; } +#endif + /************************ ELF symbol tables *****************************************/ unsigned calc_symbol_name_hash(const char * s) { diff --git a/services/tcf_elf.h b/services/tcf_elf.h index 22ef5405..212611d7 100644 --- a/services/tcf_elf.h +++ b/services/tcf_elf.h @@ -466,6 +466,8 @@ struct ELF_PHeader { U4_T align; }; +#define SYM_HASH_SIZE (32 * MEM_USAGE_FACTOR - 1) + /* * Swap bytes in a buffer. * The function is used when ELF file endianness mismatch agent endianness. @@ -531,6 +533,8 @@ extern ContextAddress elf_map_to_run_time_address(Context * ctx, ELF_File * file */ extern ContextAddress elf_map_to_link_time_address(Context * ctx, ContextAddress addr, ELF_File ** file, ELF_Section ** sec); +#if ENABLE_DebugContext + /* * Read a word from context memory. Word size and endianess are determened by ELF file. */ @@ -549,6 +553,8 @@ extern ContextAddress elf_get_debug_structure_address(Context * ctx, ELF_File ** */ extern struct UnitAddressRange * elf_find_unit(Context * ctx, ContextAddress addr_min, ContextAddress addr_max, ContextAddress * range_rt_addr); +#endif + /* Return symbol name hash. The hash is used to build sym_names_hash table. */ extern unsigned calc_symbol_name_hash(const char * s); |