X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fdwarf2expr.c;h=cf00929e2251f00ce6d4ba723ec5a644c4e9d709;hb=db488fc1b2aba317876c90eca1f4e5eb787c4238;hp=35e76f3cd40bb09ccdc51d40154f56f8d978ebb1;hpb=61fbb938d653fed62f0c7d893b5f8e842fa7a09f;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c index 35e76f3cd4..cf00929e22 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c @@ -39,8 +39,9 @@ new_dwarf_expr_context (void) { struct dwarf_expr_context *retval; retval = xcalloc (1, sizeof (struct dwarf_expr_context)); - retval->stack_len = 10; - retval->stack = xmalloc (10 * sizeof (CORE_ADDR)); + retval->stack_len = 0; + retval->stack_allocated = 10; + retval->stack = xmalloc (retval->stack_allocated * sizeof (CORE_ADDR)); return retval; } @@ -61,12 +62,10 @@ dwarf_expr_grow_stack (struct dwarf_expr_context *ctx, size_t need) { if (ctx->stack_len + need > ctx->stack_allocated) { - size_t templen = ctx->stack_len * 2; - while (templen < (ctx->stack_len + need)) - templen *= 2; + size_t newlen = ctx->stack_len + need + 10; ctx->stack = xrealloc (ctx->stack, - templen * sizeof (CORE_ADDR)); - ctx->stack_allocated = templen; + newlen * sizeof (CORE_ADDR)); + ctx->stack_allocated = newlen; } } @@ -179,7 +178,9 @@ dwarf2_read_address (unsigned char *buf, unsigned char *buf_end, int *bytes_read error ("dwarf2_read_address: Corrupted DWARF expression."); *bytes_read = TARGET_ADDR_BIT / TARGET_CHAR_BIT; - result = extract_address (buf, TARGET_ADDR_BIT / TARGET_CHAR_BIT); + /* NOTE: cagney/2003-05-22: This extract is assuming that a DWARF 2 + address is always unsigned. That may or may not be true. */ + result = extract_unsigned_integer (buf, TARGET_ADDR_BIT / TARGET_CHAR_BIT); return result; } @@ -228,6 +229,8 @@ static void execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr, unsigned char *op_end) { + ctx->in_reg = 0; + while (op_ptr < op_end) { enum dwarf_location_atom op = *op_ptr++; @@ -236,8 +239,6 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr, LONGEST offset; int bytes_read; - ctx->in_reg = 0; - switch (op) { case DW_OP_lit0: @@ -355,10 +356,9 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr, case DW_OP_reg29: case DW_OP_reg30: case DW_OP_reg31: - /* NOTE: in the presence of DW_OP_piece this check is incorrect. */ - if (op_ptr != op_end) + if (op_ptr != op_end && *op_ptr != DW_OP_piece) error ("DWARF-2 expression error: DW_OP_reg operations must be " - "used alone."); + "used either alone or in conjuction with DW_OP_piece."); result = op - DW_OP_reg0; ctx->in_reg = 1; @@ -367,9 +367,9 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr, case DW_OP_regx: op_ptr = read_uleb128 (op_ptr, op_end, ®); - if (op_ptr != op_end) + if (op_ptr != op_end && *op_ptr != DW_OP_piece) error ("DWARF-2 expression error: DW_OP_reg operations must be " - "used alone."); + "used either alone or in conjuction with DW_OP_piece."); result = reg; ctx->in_reg = 1; @@ -441,18 +441,6 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr, result = dwarf_expr_fetch (ctx, 0); if (ctx->in_reg) result = (ctx->read_reg) (ctx->baton, result); - else - { - char *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT); - int bytes_read; - - (ctx->read_mem) (ctx->baton, buf, result, - TARGET_ADDR_BIT / TARGET_CHAR_BIT); - result = dwarf2_read_address (buf, - buf + (TARGET_ADDR_BIT - / TARGET_CHAR_BIT), - &bytes_read); - } result = result + offset; ctx->stack_len = before_stack_len; ctx->in_reg = 0; @@ -641,6 +629,14 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr, break; case DW_OP_GNU_push_tls_address: + /* Variable is at a constant offset in the thread-local + storage block into the objfile for the current thread and + the dynamic linker module containing this expression. Here + we return returns the offset from that base. The top of the + stack has the offset from the beginning of the thread + control block at which the variable is located. Nothing + should follow this operator, so the top of stack would be + returned. */ result = dwarf_expr_fetch (ctx, 0); dwarf_expr_pop (ctx); result = (ctx->get_tls_address) (ctx->baton, result);