From: Andrew Cagney <ac131313@redhat.com>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] Limited DW_OP_piece support
Date: Thu, 22 May 2003 17:53:00 -0000 [thread overview]
Message-ID: <3ECD0E9A.9020908@redhat.com> (raw)
In-Reply-To: <1030522170039.ZM30271@localhost.localdomain>
> 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
>
>
next prev parent reply other threads:[~2003-05-22 17:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-22 17:00 Kevin Buettner
2003-05-22 17:53 ` Andrew Cagney [this message]
2003-05-22 18:30 ` Kevin Buettner
2003-05-22 18:42 ` Andrew Cagney
2003-05-22 18:19 ` Daniel Jacobowitz
2003-05-22 21:21 ` Kevin Buettner
2003-05-22 21:29 ` Daniel Jacobowitz
2003-05-22 21:42 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3ECD0E9A.9020908@redhat.com \
--to=ac131313@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=kevinb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox