From: Stan Shebs <stan@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Disallow non-scalars as rvalues in agent expressions
Date: Thu, 18 Mar 2010 05:00:00 -0000 [thread overview]
Message-ID: <4BA1B365.1070608@codesourcery.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 759 bytes --]
Bad Stuff(tm) happens when you try to compile an agent expression that
wants to use a non-scalar object like a struct. (We're talking about
the struct itself, not a pointer to it.) Now, it actually works in GDB
to say "print (int)bigstruct" - the first 32 bits of the struct get made
into an integer, and the rest is discarded. While in theory the
bytecode compiler could do likewise, and perhaps someone will make that
happen someday (it's not as simple as taking address, struct might be
partly in registers), in the meantime we need to prevent non-scalar
types from triggering internal errors all over the place. Committed to
trunk.
Stan
2010-03-17 Stan Shebs <stan@codesourcery.com>
* ax-gdb.c (require_rvalue): Disallow non-scalars.
[-- Attachment #2: nonscalar-patch-1 --]
[-- Type: text/plain, Size: 908 bytes --]
Index: ax-gdb.c
===================================================================
RCS file: /cvs/src/src/gdb/ax-gdb.c,v
retrieving revision 1.69
diff -p -r1.69 ax-gdb.c
*** ax-gdb.c 17 Mar 2010 22:04:43 -0000 1.69
--- ax-gdb.c 18 Mar 2010 01:44:44 -0000
*************** gen_int_literal (struct agent_expr *ax,
*** 745,750 ****
--- 745,759 ----
static void
require_rvalue (struct agent_expr *ax, struct axs_value *value)
{
+ /* Only deal with scalars, structs and such may be too large
+ to fit in a stack entry. */
+ value->type = check_typedef (value->type);
+ if (TYPE_CODE (value->type) == TYPE_CODE_ARRAY
+ || TYPE_CODE (value->type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (value->type) == TYPE_CODE_UNION
+ || TYPE_CODE (value->type) == TYPE_CODE_FUNC)
+ error ("Value not scalar: cannot be an rvalue.");
+
switch (value->kind)
{
case axs_rvalue:
next reply other threads:[~2010-03-18 5:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-18 5:00 Stan Shebs [this message]
2010-03-18 7:11 ` Eli Zaretskii
2010-03-18 16:02 ` Stan Shebs
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=4BA1B365.1070608@codesourcery.com \
--to=stan@codesourcery.com \
--cc=gdb-patches@sourceware.org \
/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