X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fax-gdb.c;h=09bf42cd7fbd284d6ecc98dd7b96260c143f1574;hb=7317d334006e42d356031e370e12c234f7401272;hp=1b0097ff95786f374eacd24dd3bc4cb7ecdf13f2;hpb=36e9969cac95317f057b47509cf63271bccd98b0;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 1b0097ff95..09bf42cd7f 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1,13 +1,13 @@ /* GDB-specific functions for operating on agent expressions. - Copyright 1998, 1999, 2000, 2001, 2003 Free Software Foundation, - Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2003, 2007, 2008 + Free Software Foundation, Inc. This file is part of GDB. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,9 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + along with this program. If not, see . */ #include "defs.h" #include "symtab.h" @@ -321,7 +319,7 @@ gen_traced_pop (struct agent_expr *ax, struct axs_value *value) case axs_lvalue_memory: { - int length = TYPE_LENGTH (value->type); + int length = TYPE_LENGTH (check_typedef (value->type)); /* There's no point in trying to use a trace_quick bytecode here, since "trace_quick SIZE pop" is three bytes, whereas @@ -461,7 +459,8 @@ gen_frame_args_address (struct agent_expr *ax) int frame_reg; LONGEST frame_offset; - TARGET_VIRTUAL_FRAME_POINTER (ax->scope, &frame_reg, &frame_offset); + gdbarch_virtual_frame_pointer (current_gdbarch, + ax->scope, &frame_reg, &frame_offset); ax_reg (ax, frame_reg); gen_offset (ax, frame_offset); } @@ -475,7 +474,8 @@ gen_frame_locals_address (struct agent_expr *ax) int frame_reg; LONGEST frame_offset; - TARGET_VIRTUAL_FRAME_POINTER (ax->scope, &frame_reg, &frame_offset); + gdbarch_virtual_frame_pointer (current_gdbarch, + ax->scope, &frame_reg, &frame_offset); ax_reg (ax, frame_reg); gen_offset (ax, frame_offset); } @@ -564,19 +564,11 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var) break; case LOC_LOCAL: /* var lives in locals area of frame */ - case LOC_LOCAL_ARG: gen_frame_locals_address (ax); gen_sym_offset (ax, var); value->kind = axs_lvalue_memory; break; - case LOC_BASEREG: /* relative to some base register */ - case LOC_BASEREG_ARG: - ax_reg (ax, SYMBOL_BASEREG (var)); - gen_sym_offset (ax, var); - value->kind = axs_lvalue_memory; - break; - case LOC_TYPEDEF: error (_("Cannot compute value of typedef `%s'."), SYMBOL_PRINT_NAME (var)); @@ -588,7 +580,6 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var) break; case LOC_REGISTER: - case LOC_REGPARM: /* Don't generate any code at all; in the process of treating this as an lvalue or rvalue, the caller will generate the right code. */ @@ -597,9 +588,9 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var) break; /* A lot like LOC_REF_ARG, but the pointer lives directly in a - register, not on the stack. Simpler than LOC_REGISTER and - LOC_REGPARM, because it's just like any other case where the - thing has a real address. */ + register, not on the stack. Simpler than LOC_REGISTER + because it's just like any other case where the thing + has a real address. */ case LOC_REGPARM_ADDR: ax_reg (ax, SYMBOL_VALUE (var)); value->kind = axs_lvalue_memory; @@ -619,7 +610,6 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var) break; case LOC_COMPUTED: - case LOC_COMPUTED_ARG: /* FIXME: cagney/2004-01-26: It should be possible to unconditionally call the SYMBOL_OPS method when available. Unfortunately DWARF 2 stores the frame-base (instead of the @@ -650,7 +640,7 @@ gen_int_literal (struct agent_expr *ax, struct axs_value *value, LONGEST k, { ax_const_l (ax, k); value->kind = axs_rvalue; - value->type = type; + value->type = check_typedef (type); } @@ -854,7 +844,7 @@ gen_usual_arithmetic (struct agent_expr *ax, struct axs_value *value1, ax_simple (ax, aop_swap); } - value1->type = value2->type = target; + value1->type = value2->type = check_typedef (target); } } @@ -905,9 +895,8 @@ gen_cast (struct agent_expr *ax, struct axs_value *value, struct type *type) /* We don't have to worry about the size of the value, because all our integral values are fully sign-extended, and when casting pointers we can do anything we like. Is there any - way for us to actually know what GCC actually does with a - cast like this? */ - value->type = type; + way for us to know what GCC actually does with a cast like + this? */ break; case TYPE_CODE_INT: @@ -1170,12 +1159,15 @@ find_field (struct type *type, char *name) { char *this_name = TYPE_FIELD_NAME (type, i); - if (this_name && strcmp (name, this_name) == 0) - return i; + if (this_name) + { + if (strcmp (name, this_name) == 0) + return i; - if (this_name[0] == '\0') - internal_error (__FILE__, __LINE__, - _("find_field: anonymous unions not supported")); + if (this_name[0] == '\0') + internal_error (__FILE__, __LINE__, + _("find_field: anonymous unions not supported")); + } } error (_("Couldn't find member named `%s' in struct/union `%s'"), @@ -1317,7 +1309,7 @@ gen_bitfield_ref (struct agent_expr *ax, struct axs_value *value, the sign/zero extension will wipe them out. - If we're in the interior of the word, then there is no garbage on either end, because the ref operators zero-extend. */ - if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) gen_left_shift (ax, end - (offset + op_size)); else gen_left_shift (ax, offset - start); @@ -1597,8 +1589,18 @@ gen_expr (union exp_element **pc, struct agent_expr *ax, case OP_REGISTER: { - int reg = (int) (*pc)[1].longconst; - (*pc) += 3; + const char *name = &(*pc)[2].string; + int reg; + (*pc) += 4 + BYTES_TO_EXP_ELEM ((*pc)[1].longconst + 1); + reg = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (), + name, strlen (name)); + if (reg == -1) + internal_error (__FILE__, __LINE__, + _("Register $%s not available"), name); + if (reg >= gdbarch_num_regs (current_gdbarch)) + error (_("'%s' is a pseudo-register; " + "GDB cannot yet trace pseudoregister contents."), + name); value->kind = axs_lvalue_register; value->u.reg = reg; value->type = register_type (current_gdbarch, reg); @@ -1728,56 +1730,6 @@ gen_expr (union exp_element **pc, struct agent_expr *ax, /* Generating bytecode from GDB expressions: driver */ -/* Given a GDB expression EXPR, produce a string of agent bytecode - which computes its value. Return the agent expression, and set - *VALUE to describe its type, and whether it's an lvalue or rvalue. */ -struct agent_expr * -expr_to_agent (struct expression *expr, struct axs_value *value) -{ - struct cleanup *old_chain = 0; - struct agent_expr *ax = new_agent_expr (0); - union exp_element *pc; - - old_chain = make_cleanup_free_agent_expr (ax); - - pc = expr->elts; - trace_kludge = 0; - gen_expr (&pc, ax, value); - - /* We have successfully built the agent expr, so cancel the cleanup - request. If we add more cleanups that we always want done, this - will have to get more complicated. */ - discard_cleanups (old_chain); - return ax; -} - - -#if 0 /* not used */ -/* Given a GDB expression EXPR denoting an lvalue in memory, produce a - string of agent bytecode which will leave its address and size on - the top of stack. Return the agent expression. - - Not sure this function is useful at all. */ -struct agent_expr * -expr_to_address_and_size (struct expression *expr) -{ - struct axs_value value; - struct agent_expr *ax = expr_to_agent (expr, &value); - - /* Complain if the result is not a memory lvalue. */ - if (value.kind != axs_lvalue_memory) - { - free_agent_expr (ax); - error (_("Expression does not denote an object in memory.")); - } - - /* Push the object's size on the stack. */ - ax_const_l (ax, TYPE_LENGTH (value.type)); - - return ax; -} -#endif - /* Given a GDB expression EXPR, return bytecode to trace its value. The result will use the `trace' and `trace_quick' bytecodes to record the value of all memory touched by the expression. The