From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14468 invoked by alias); 22 May 2003 17:00:47 -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 14432 invoked from network); 22 May 2003 17:00:46 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 22 May 2003 17:00:46 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h4MH0jH07702 for ; Thu, 22 May 2003 13:00:45 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h4MH0jI15716 for ; Thu, 22 May 2003 13:00:45 -0400 Received: from localhost.localdomain (vpn50-3.rdu.redhat.com [172.16.50.3]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h4MH0jo30907 for ; Thu, 22 May 2003 13:00:45 -0400 Received: (from kev@localhost) by localhost.localdomain (8.11.6/8.11.6) id h4MH0dQ30272 for gdb-patches@sources.redhat.com; Thu, 22 May 2003 10:00:39 -0700 Date: Thu, 22 May 2003 17:00:00 -0000 From: Kevin Buettner Message-Id: <1030522170039.ZM30271@localhost.localdomain> To: gdb-patches@sources.redhat.com Subject: [RFA] Limited DW_OP_piece support MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-05/txt/msg00425.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. Okay? 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