From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5601 invoked by alias); 22 Mar 2010 19:42:14 -0000 Received: (qmail 5588 invoked by uid 22791); 22 Mar 2010 19:42:14 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from lo.gmane.org (HELO lo.gmane.org) (80.91.229.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 22 Mar 2010 19:42:09 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1NtnVm-0001di-Od for gdb-patches@sources.redhat.com; Mon, 22 Mar 2010 20:42:06 +0100 Received: from enigma.qnx.com ([209.226.137.106]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Mar 2010 20:42:06 +0100 Received: from aristovski by enigma.qnx.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 22 Mar 2010 20:42:06 +0100 To: gdb-patches@sources.redhat.com From: Aleksandar Ristovski Subject: [patch] varobj.c c_describe_child Date: Mon, 22 Mar 2010 19:42:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060906070903090502050108" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.8) Gecko/20100227 Lightning/1.0b1 Thunderbird/3.0.3 X-IsSubscribed: yes 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/msg00774.txt.bz2 This is a multi-part message in MIME format. --------------060906070903090502050108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 950 Hello, When printing children of a variable created with a pointer type, gdb generates a copy of value of target type for each child. This quickly exhausts memory in certain cases. In my case, customer has a struct with 1600+ fields and of size approx 900K. Listing children of such struct via a variable created with a pointer to it, crashes gdb (gdb version 6.8) due to running out of memory. The patch fixes this by removing intermediate value and freeing it. Note that with latest gdb from HEAD it doesn't crash, I believe due to recent changes in lazy allocating the values, but it still seems wrong to keep all these intermediate values generated by 'adjust_value_for_child_access' in 'all_values' list. Thanks, -- Aleksandar Ristovski QNX Software Systems ChangeLog: 2010-03-22 Aleksandar Ristovski * varobj.c (c_describe_child): Do not keep temporary parent value while fetching child's value. --------------060906070903090502050108 Content-Type: text/plain; name="varobj-removetempvalue-20100322-ChangeLog.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="varobj-removetempvalue-20100322-ChangeLog.patch" Content-length: 155 2010-03-22 Aleksandar Ristovski * varobj.c (c_describe_child): Do not keep temporary parent value while fetching child's value. --------------060906070903090502050108 Content-Type: text/plain; name="varobj-removetempvalue-20100322.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="varobj-removetempvalue-20100322.patch" Content-length: 933 Index: gdb/varobj.c =================================================================== RCS file: /cvs/src/src/gdb/varobj.c,v retrieving revision 1.156 diff -u -p -r1.156 varobj.c --- gdb/varobj.c 3 Mar 2010 18:32:44 -0000 1.156 +++ gdb/varobj.c 22 Mar 2010 19:15:34 -0000 @@ -2821,6 +2821,12 @@ c_describe_child (struct varobj *parent, parent_expression = varobj_get_path_expr (parent); } adjust_value_for_child_access (&value, &type, &was_ptr); + if (value != parent->value) + { + /* If value was created merely to later create child, + * do not keep it in value history. */ + release_value (value); + } switch (TYPE_CODE (type)) { @@ -2902,6 +2908,9 @@ c_describe_child (struct varobj *parent, *cfull_expression = xstrdup ("???"); /* Don't set value and type, we don't know then. */ } + + if (value != parent->value) + value_free (value); } static char * --------------060906070903090502050108--