From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31167 invoked by alias); 21 May 2007 15:50:20 -0000 Received: (qmail 31102 invoked by uid 22791); 21 May 2007 15:50:11 -0000 X-Spam-Check-By: sourceware.org Received: from return.false.org (HELO return.false.org) (66.207.162.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 21 May 2007 15:50:05 +0000 Received: from return.false.org (localhost [127.0.0.1]) by return.false.org (Postfix) with ESMTP id 3C57D4B267 for ; Mon, 21 May 2007 10:50:03 -0500 (CDT) Received: from caradoc.them.org (dsl093-172-095.pit1.dsl.speakeasy.net [66.93.172.95]) by return.false.org (Postfix) with ESMTP id A90EE4B262 for ; Mon, 21 May 2007 10:50:02 -0500 (CDT) Received: from drow by caradoc.them.org with local (Exim 4.67) (envelope-from ) id 1HqA8z-0004Nn-MS for gdb-patches@sourceware.org; Mon, 21 May 2007 11:49:57 -0400 Date: Mon, 21 May 2007 15:50:00 -0000 From: Daniel Jacobowitz To: gdb-patches@sourceware.org Subject: Re: [rfc] Record register names for OP_REGISTER Message-ID: <20070521154956.GA16833@caradoc.them.org> Mail-Followup-To: gdb-patches@sourceware.org References: <20070521132616.GB1392@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070521132616.GB1392@caradoc.them.org> User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-05/txt/msg00345.txt.bz2 Whoops, posted the wrong copy of the patch. Sorry. -- Daniel Jacobowitz CodeSourcery 2007-05-21 Daniel Jacobowitz * expression.h (enum exp_opcode): Document a register name for OP_REGISTER. * parse.c (write_dollar_variable): Write the register name for OP_REGISTER. (operator_length_standard): Expect the register name following OP_REGISTER. * ada-lang.c (resolve_subexp): Likewise. * ax-gdb.c (gen_expr): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * expprint.c (print_subexp_standard, dump_subexp_body_standard): Likewise. * tracepoint.c (encode_actions): Likewise. --- ada-lang.c | 5 ++++- ax-gdb.c | 10 ++++++++-- eval.c | 13 +++++++++---- expprint.c | 11 ++++------- expression.h | 5 ++--- parse.c | 6 ++++-- tracepoint.c | 19 ++++++++++++++----- 7 files changed, 45 insertions(+), 24 deletions(-) Index: gdb/ada-lang.c =================================================================== --- gdb.orig/ada-lang.c 2007-05-21 09:00:03.000000000 -0400 +++ gdb/ada-lang.c 2007-05-21 09:05:33.000000000 -0400 @@ -2710,7 +2710,6 @@ resolve_subexp (struct expression **expp case OP_TYPE: case OP_BOOL: case OP_LAST: - case OP_REGISTER: case OP_INTERNALVAR: *pos += 3; break; @@ -2720,6 +2719,10 @@ resolve_subexp (struct expression **expp nargs = 1; break; + case OP_REGISTER: + *pos += 4 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1); + break; + case STRUCTOP_STRUCT: *pos += 4 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1); nargs = 1; Index: gdb/ax-gdb.c =================================================================== --- gdb.orig/ax-gdb.c 2007-05-21 09:00:03.000000000 -0400 +++ gdb/ax-gdb.c 2007-05-21 09:23:18.000000000 -0400 @@ -1597,8 +1597,14 @@ gen_expr (union exp_element **pc, struct 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); value->kind = axs_lvalue_register; value->u.reg = reg; value->type = register_type (current_gdbarch, reg); Index: gdb/eval.c =================================================================== --- gdb.orig/eval.c 2007-05-21 09:00:03.000000000 -0400 +++ gdb/eval.c 2007-05-21 09:21:31.000000000 -0400 @@ -500,16 +500,21 @@ evaluate_subexp_standard (struct type *e case OP_REGISTER: { - int regno = longest_to_int (exp->elts[pc + 1].longconst); + const char *name = &exp->elts[pc + 2].string; + int regno; struct value *val; - (*pos) += 2; + + (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1); + regno = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (), + name, strlen (name)); + if (regno == -1) + error (_("Register $%s not available."), name); if (noside == EVAL_AVOID_SIDE_EFFECTS) val = value_zero (register_type (current_gdbarch, regno), not_lval); else val = value_of_register (regno, get_selected_frame (NULL)); if (val == NULL) - error (_("Value of register %s not available."), - frame_map_regnum_to_name (get_selected_frame (NULL), regno)); + error (_("Value of register %s not available."), name); else return val; } Index: gdb/expprint.c =================================================================== --- gdb.orig/expprint.c 2007-05-21 09:00:03.000000000 -0400 +++ gdb/expprint.c 2007-05-21 09:24:11.000000000 -0400 @@ -130,10 +130,8 @@ print_subexp_standard (struct expression case OP_REGISTER: { - int regnum = longest_to_int (exp->elts[pc + 1].longconst); - const char *name = user_reg_map_regnum_to_name (current_gdbarch, - regnum); - (*pos) += 2; + const char *name = &exp->elts[pc + 2].string; + (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1); fprintf_filtered (stream, "$%s", name); return; } @@ -965,9 +963,8 @@ dump_subexp_body_standard (struct expres elt += 2; break; case OP_REGISTER: - fprintf_filtered (stream, "Register %ld", - (long) exp->elts[elt].longconst); - elt += 2; + fprintf_filtered (stream, "Register $%s", &exp->elts[elt + 1].string); + elt += 3 + BYTES_TO_EXP_ELEM (exp->elts[elt].longconst + 1); break; case OP_INTERNALVAR: fprintf_filtered (stream, "Internal var @"); Index: gdb/expression.h =================================================================== --- gdb.orig/expression.h 2007-05-21 09:00:03.000000000 -0400 +++ gdb/expression.h 2007-05-21 09:05:33.000000000 -0400 @@ -166,9 +166,8 @@ enum exp_opcode With another OP_LAST at the end, this makes three exp_elements. */ OP_LAST, - /* OP_REGISTER is followed by an integer in the next exp_element. - This is the number of a register to fetch (as an int). - With another OP_REGISTER at the end, this makes three exp_elements. */ + /* OP_REGISTER is followed by a string in the next exp_element. + This is the name of a register to fetch. */ OP_REGISTER, /* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element. Index: gdb/parse.c =================================================================== --- gdb.orig/parse.c 2007-05-21 09:00:03.000000000 -0400 +++ gdb/parse.c 2007-05-21 09:05:33.000000000 -0400 @@ -549,7 +549,9 @@ handle_last: return; handle_register: write_exp_elt_opcode (OP_REGISTER); - write_exp_elt_longcst (i); + str.length--; + str.ptr++; + write_exp_string (str); write_exp_elt_opcode (OP_REGISTER); return; } @@ -899,7 +901,6 @@ operator_length_standard (struct express case OP_TYPE: case OP_BOOL: case OP_LAST: - case OP_REGISTER: case OP_INTERNALVAR: oplen = 3; break; @@ -954,6 +955,7 @@ operator_length_standard (struct express case STRUCTOP_PTR: args = 1; /* fall through */ + case OP_REGISTER: case OP_M2_STRING: case OP_STRING: case OP_OBJC_NSSTRING: /* Objective C Foundation Class NSString constant */ Index: gdb/tracepoint.c =================================================================== --- gdb.orig/tracepoint.c 2007-05-21 09:00:03.000000000 -0400 +++ gdb/tracepoint.c 2007-05-21 09:21:15.000000000 -0400 @@ -1601,11 +1601,20 @@ encode_actions (struct tracepoint *t, ch switch (exp->elts[0].opcode) { case OP_REGISTER: - i = exp->elts[1].longconst; - if (info_verbose) - printf_filtered ("OP_REGISTER: "); - add_register (collect, i); - break; + { + const char *name = &exp->elts[2].string; + + i = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (), + name, strlen (name)); + if (i == -1) + internal_error (__FILE__, __LINE__, + _("Register $%s not available"), + name); + if (info_verbose) + printf_filtered ("OP_REGISTER: "); + add_register (collect, i); + break; + } case UNOP_MEMVAL: /* safe because we know it's a simple expression */