From 93188425e70f3d1a1c256e8d6fc7d1fe230670d6 Mon Sep 17 00:00:00 2001 From: Eugene Tarassov Date: Fri, 30 Dec 2011 09:55:13 -0800 Subject: TCF Agent: implemented remote execution of DWRF expressions; more C++ support in DWARF reader. --- agent/tcf/services/symbols_win32.c | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'agent/tcf/services/symbols_win32.c') diff --git a/agent/tcf/services/symbols_win32.c b/agent/tcf/services/symbols_win32.c index 3b2c8d7a..0e5a4791 100644 --- a/agent/tcf/services/symbols_win32.c +++ b/agent/tcf/services/symbols_win32.c @@ -121,6 +121,7 @@ static size_t context_extension_offset = 0; static char * tmp_buf = NULL; static int tmp_buf_size = 0; +static LocationInfo * location_info = NULL; #define SYMBOL_MAGIC 0x34875234 @@ -590,6 +591,11 @@ int get_symbol_index_type(const Symbol * sym, Symbol ** type) { return 0; } +int get_symbol_containing_type(const Symbol * sym, Symbol ** containing_type) { + errno = ERR_UNSUPPORTED; + return -1; +} + int get_symbol_length(const Symbol * sym, ContextAddress * length) { DWORD res = 0; Symbol type = *sym; @@ -1136,6 +1142,61 @@ ContextAddress is_plt_section(Context * ctx, ContextAddress addr) { return 0; } +static LocationExpressionCommand * add_location_command(int op) { + LocationExpressionCommand * cmd = NULL; + if (location_info->cmds_cnt >= location_info->cmds_max) { + location_info->cmds_max += 4; + location_info->cmds = (LocationExpressionCommand *)tmp_realloc(location_info->cmds, + sizeof(LocationExpressionCommand) * location_info->cmds_max); + } + cmd = location_info->cmds + location_info->cmds_cnt++; + memset(cmd, 0, sizeof(LocationExpressionCommand)); + cmd->cmd = op; + return cmd; +} + +int get_location_info(const Symbol * sym, LocationInfo ** loc) { + DWORD dword = 0; + SYMBOL_INFO * info = NULL; + + assert(sym->magic == SYMBOL_MAGIC); + *loc = location_info = (LocationInfo *)tmp_alloc_zero(sizeof(LocationInfo)); + + if (sym->address != 0) { + add_location_command(SFT_CMD_NUMBER)->args.num = sym->address; + return 0; + } + + if (sym->base || sym->info) { + errno = ERR_INV_CONTEXT; + return -1; + } + + if (get_type_info(sym, TI_GET_OFFSET, &dword) == 0) { + add_location_command(SFT_CMD_ARG)->args.arg_no = 0; + add_location_command(SFT_CMD_NUMBER)->args.num = dword; + add_location_command(SFT_CMD_ADD); + return 0; + } + + if (get_sym_info(sym, sym->index, &info) < 0) return -1; + + if (is_register(info)) { + set_errno(ERR_INV_CONTEXT, "Register variable"); + return -1; + } + + if (is_frame_relative(info)) { + add_location_command(SFT_CMD_FP); + add_location_command(SFT_CMD_NUMBER)->args.num = info->Address - sizeof(ContextAddress) * 2; + add_location_command(SFT_CMD_ADD); + return 0; + } + + add_location_command(SFT_CMD_NUMBER)->args.num = info->Address; + return 0; +} + int get_stack_tracing_info(Context * ctx, ContextAddress addr, StackTracingInfo ** info) { *info = NULL; return 0; -- cgit v1.2.3