From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17526 invoked by alias); 22 May 2003 17:53:40 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 17490 invoked from network); 22 May 2003 17:53:39 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.131) by sources.redhat.com with SMTP; 22 May 2003 17:53:39 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id AC4CB2B2F; Thu, 22 May 2003 13:53:30 -0400 (EDT) Message-ID: <3ECD0E9A.9020908@redhat.com> Date: Thu, 22 May 2003 17:53:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kevin Buettner Cc: gdb-patches@sources.redhat.com Subject: Re: [RFA] Limited DW_OP_piece support References: <1030522170039.ZM30271@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-05/txt/msg00429.txt.bz2 > The patch below adds limited DW_OP_piece support to dwarf2expr.c. I > will post a patch to rs6000-tdep.c which illustrates what a > ``dwarf2_compose_register_pieces'' method should look like. I think GDB needs to just learn about location lists :-/ Andrew > Index: dwarf2expr.c > =================================================================== > RCS file: /cvs/src/src/gdb/dwarf2expr.c,v > retrieving revision 1.7 > diff -u -p -r1.7 dwarf2expr.c > --- dwarf2expr.c 14 May 2003 22:45:41 -0000 1.7 > +++ dwarf2expr.c 22 May 2003 16:39:14 -0000 > @@ -456,6 +456,98 @@ execute_stack_op (struct dwarf_expr_cont > ctx->in_reg = 0; > } > break; > + > + case DW_OP_piece: > + > + if (!gdbarch_dwarf2_compose_register_pieces_p (current_gdbarch)) > + error ("DWARF-2 expression error: DW_OP_piece not supported for " > + "this architecture."); > + else > + { > + /* If the pieces consist of 2 or more registers in the > + proper order, then gdb "will do the right thing" by > + simply using the first register -- assuming, of course > + that the corresponding type information is correct. > + Otherwise, complain. > + > + For the case that we handle, there should already be > + a register pushed on the stack. Our strategy will > + be to push the DW_OP_piece size information and then > + push the next register and it's size information, etc. > + Once that is done, an architecture specific method will > + be called to determine which register should be used > + to access the entire object described by the pieces. > + > + When we've finished the stack should look like this: > + > + reg num 1 Bottom of stack (index == 0) > + size num 1 > + . > + . > + reg num N > + size num N Top of stack (index == 2*N-1) */ > + > + CORE_ADDR regnum; > + > + /* First check to make sure there's only one thing on the > + stack and that's it's a register. */ > + if (ctx->stack_len != 1 || !ctx->in_reg) > + error ("DWARF-2 expression error: DW_OP_piece expression " > + "is too complicated."); > + > + while (1) > + { > + long nextregnum; > + > + /* Fetch the number of bytes for this piece. */ > + op_ptr = read_uleb128 (op_ptr, op_end, &uoffset); > + dwarf_expr_push (ctx, uoffset); > + > + /* Break out if we're done. */ > + if (op_ptr >= op_end) > + break; > + > + /* We expect to see a register next. */ > + op = *op_ptr++; > + if (DW_OP_reg0 <= op && op <= DW_OP_reg31) > + { > + reg = op - DW_OP_reg0; > + dwarf_expr_push (ctx, reg); > + } > + else if (op == DW_OP_regx) > + { > + op_ptr = read_uleb128 (op_ptr, op_end, ®); > + dwarf_expr_push (ctx, reg); > + } > + else > + error ("DWARF-2 expression error: DW_OP_piece expression " > + "is too complicated."); > + > + /* Make sure that we haven't read too far and that > + a DW_OP_piece operator comes next. */ > + > + if (op_ptr >= op_end || (*op_ptr!= DW_OP_piece)) > + error ("DWARF-2 expression error: DW_OP_piece expression " > + "is too complicated."); > + > + /* Skip over DW_OP_piece operator. */ > + op_ptr++; > + } > + > + result = gdbarch_dwarf2_compose_register_pieces ( > + current_gdbarch, ctx->stack_len / 2, &ctx->stack[0]); > + > + if (result < 0) > + error ("DWARF-2 expression error: DW_OP_piece expression " > + "is too complicated."); > + > + /* Note: ctx->in_reg is already set. We want result to be the > + only thing on the stack -- it will be pushed below. > + Make the stack empty so that this will occur. */ > + ctx->stack_len = 0; > + } > + break; > + > case DW_OP_dup: > result = dwarf_expr_fetch (ctx, 0); > break; > Index: gdbarch.sh > =================================================================== > RCS file: /cvs/src/src/gdb/gdbarch.sh,v > retrieving revision 1.237 > diff -u -p -r1.237 gdbarch.sh > --- gdbarch.sh 17 May 2003 05:59:58 -0000 1.237 > +++ gdbarch.sh 22 May 2003 16:39:16 -0000 > @@ -471,6 +471,7 @@ f:2:DWARF_REG_TO_REGNUM:int:dwarf_reg_to > # to map one to one onto the sdb register numbers. > f:2:SDB_REG_TO_REGNUM:int:sdb_reg_to_regnum:int sdb_regnr:sdb_regnr:::no_op_reg_to_regnum::0 > f:2:DWARF2_REG_TO_REGNUM:int:dwarf2_reg_to_regnum:int dwarf2_regnr:dwarf2_regnr:::no_op_reg_to_regnum::0 > +M:2:DWARF2_COMPOSE_REGISTER_PIECES:long:dwarf2_compose_register_pieces:int count, CORE_ADDR *piece_info:count, piece_info > f:2:REGISTER_NAME:const char *:register_name:int regnr:regnr:::legacy_register_name::0 > v::DEPRECATED_REGISTER_SIZE:int:deprecated_register_size > v::DEPRECATED_REGISTER_BYTES:int:deprecated_register_bytes > >