From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22248 invoked by alias); 23 Jun 2006 13:09:57 -0000 Received: (qmail 22187 invoked by uid 22791); 23 Jun 2006 13:09:56 -0000 X-Spam-Check-By: sourceware.org Received: from lon-del-03.spheriq.net (HELO lon-del-03.spheriq.net) (195.46.50.99) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 23 Jun 2006 13:09:52 +0000 Received: from lon-out-01.spheriq.net ([195.46.50.129]) by lon-del-03.spheriq.net with ESMTP id k5ND9m3u029414 for ; Fri, 23 Jun 2006 13:09:48 GMT Received: from lon-cus-01.spheriq.net (lon-cus-01.spheriq.net [195.46.50.37]) by lon-out-01.spheriq.net with ESMTP id k5ND9leJ027058 for ; Fri, 23 Jun 2006 13:09:47 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by lon-cus-01.spheriq.net with ESMTP id k5ND9jvh015168 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Fri, 23 Jun 2006 13:09:46 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6AEEFDBFD for ; Fri, 23 Jun 2006 12:00:55 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2E7AE47460 for ; Fri, 23 Jun 2006 12:00:55 +0000 (GMT) Received: from [164.129.15.13] (bri1043.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CHT28174 (AUTH stubbsa); Fri, 23 Jun 2006 13:00:54 +0100 (BST) Message-ID: <449BD7F5.5090604@st.com> Date: Fri, 23 Jun 2006 13:09:00 -0000 From: Andrew STUBBS User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: GDB Patches Subject: [PATCH] Initialise data to appease valgrind Content-Type: multipart/mixed; boundary="------------000901090404050306060409" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00360.txt.bz2 This is a multi-part message in MIME format. --------------000901090404050306060409 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 799 When 'set debug expression 1' is used the debug code prints the full contents of the expression 'elts' as a hex/ASCII dump. Unfortunately this is a union so parts of it are potentially uninitialised. This is not normally a problem (although displaying random data doesn't sound like a good idea to me - especially for autotester etc.), but when run under valgrind it causes a lot of output which hides the real problems. The attached patch initialises the union before using it to ensure that the whole thing is initialised. I suppose that it is not necessary to initialise it in all the cases I have covered - the data fills the union anyway, but it is safer this way and I imagine the compiler will do the right thing in any case. Tested with no regressions. Andrew Stubbs :ADDPATCH parse.c: --------------000901090404050306060409 Content-Type: text/plain; name="debug-expression.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="debug-expression.patch" Content-length: 1693 2006-06-23 Andrew Stubbs * parse.c (write_exp_elt_opcode, write_exp_elt_sym, write_exp_elt_block write_exp_elt_longcst, write_exp_elt_dblcst, write_exp_elt_type, write_exp_elt_intern): Zero initialize tmp. Index: src/gdb/parse.c =================================================================== --- src.orig/gdb/parse.c 2006-06-23 11:21:56.000000000 +0100 +++ src/gdb/parse.c 2006-06-23 11:29:35.000000000 +0100 @@ -191,6 +191,7 @@ void write_exp_elt_opcode (enum exp_opcode expelt) { union exp_element tmp; + memset (&tmp, 0, sizeof (union exp_element)); tmp.opcode = expelt; @@ -201,6 +202,7 @@ void write_exp_elt_sym (struct symbol *expelt) { union exp_element tmp; + memset (&tmp, 0, sizeof (union exp_element)); tmp.symbol = expelt; @@ -211,6 +213,7 @@ void write_exp_elt_block (struct block *b) { union exp_element tmp; + memset (&tmp, 0, sizeof (union exp_element)); tmp.block = b; write_exp_elt (tmp); } @@ -219,6 +222,7 @@ void write_exp_elt_longcst (LONGEST expelt) { union exp_element tmp; + memset (&tmp, 0, sizeof (union exp_element)); tmp.longconst = expelt; @@ -229,6 +233,7 @@ void write_exp_elt_dblcst (DOUBLEST expelt) { union exp_element tmp; + memset (&tmp, 0, sizeof (union exp_element)); tmp.doubleconst = expelt; @@ -239,6 +244,7 @@ void write_exp_elt_type (struct type *expelt) { union exp_element tmp; + memset (&tmp, 0, sizeof (union exp_element)); tmp.type = expelt; @@ -249,6 +255,7 @@ void write_exp_elt_intern (struct internalvar *expelt) { union exp_element tmp; + memset (&tmp, 0, sizeof (union exp_element)); tmp.internalvar = expelt; --------------000901090404050306060409--