From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3198 invoked by alias); 18 Mar 2010 05:00:35 -0000 Received: (qmail 3165 invoked by uid 22791); 18 Mar 2010 05:00:32 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Mar 2010 05:00:28 +0000 Received: (qmail 17246 invoked from network); 18 Mar 2010 05:00:27 -0000 Received: from unknown (HELO macbook-2.local) (stan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 18 Mar 2010 05:00:27 -0000 Message-ID: <4BA1B365.1070608@codesourcery.com> Date: Thu, 18 Mar 2010 05:00:00 -0000 From: Stan Shebs User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [PATCH] Disallow non-scalars as rvalues in agent expressions Content-Type: multipart/mixed; boundary="------------030202020209040507000600" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00645.txt.bz2 This is a multi-part message in MIME format. --------------030202020209040507000600 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 759 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 * ax-gdb.c (require_rvalue): Disallow non-scalars. --------------030202020209040507000600 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="nonscalar-patch-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="nonscalar-patch-1" Content-length: 908 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: --------------030202020209040507000600--