public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Disallow non-scalars as rvalues in agent expressions
@ 2010-03-18  5:00 Stan Shebs
  2010-03-18  7:11 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Stan Shebs @ 2010-03-18  5:00 UTC (permalink / raw)
  To: gdb-patches

[-- 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:

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Disallow non-scalars as rvalues in agent expressions
  2010-03-18  5:00 [PATCH] Disallow non-scalars as rvalues in agent expressions Stan Shebs
@ 2010-03-18  7:11 ` Eli Zaretskii
  2010-03-18 16:02   ` Stan Shebs
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2010-03-18  7:11 UTC (permalink / raw)
  To: Stan Shebs; +Cc: gdb-patches

> Date: Wed, 17 Mar 2010 22:00:21 -0700
> From: Stan Shebs <stan@codesourcery.com>
> 
> +     error ("Value not scalar: cannot be an rvalue.");

Shouldn't the error message be in _() ?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Disallow non-scalars as rvalues in agent expressions
  2010-03-18  7:11 ` Eli Zaretskii
@ 2010-03-18 16:02   ` Stan Shebs
  0 siblings, 0 replies; 3+ messages in thread
From: Stan Shebs @ 2010-03-18 16:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Stan Shebs, gdb-patches

Eli Zaretskii wrote:
>> Date: Wed, 17 Mar 2010 22:00:21 -0700
>> From: Stan Shebs <stan@codesourcery.com>
>>
>> +     error ("Value not scalar: cannot be an rvalue.");
>>     
>
> Shouldn't the error message be in _() ?
>   
Gack! Thanks, just checked in the fix.

Stan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-18 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-18  5:00 [PATCH] Disallow non-scalars as rvalues in agent expressions Stan Shebs
2010-03-18  7:11 ` Eli Zaretskii
2010-03-18 16:02   ` Stan Shebs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).