From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32719 invoked by alias); 12 Jan 2010 11:22:07 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 32702 invoked by uid 22791); 12 Jan 2010 11:22:06 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Message-ID: <4B4C5B55.6060303@redhat.com> Date: Tue, 12 Jan 2010 11:22:00 -0000 From: Phil Muldoon User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0 MIME-Version: 1.0 To: Project Archer CC: themastermind1@gmail.com Subject: Re: [patch] fixing leaking struct value* in py-value.c References: In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2010-q1/txt/msg00009.txt.bz2 On 12/10/2009 11:15 PM, Aman Gupta wrote: > The gdb process will leak a large amount of memory (>512mb RSS) while > executing the python loop. Some (but not all) of this memory is > returned after the loop completes and free_all_values() is called for > the next command. The following patch against archer-tromey-python > keeps the memory usage constant during the loop. On my tests, the consumption noted is far in excess of that, so good find. > > diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c > index 14efd79..f305b01 100644 > --- a/gdb/python/py-value.c > +++ b/gdb/python/py-value.c > @@ -143,7 +143,7 @@ valpy_new (PyTypeObject *subtype, PyObject *args, > PyObject *keywords) Your mailer appears to be wrapping patches. So this means the patch command will complain of a malformed patch. In this case it was easily fixed in an editor, but a heads up in any case. > #define GDB_PY_HANDLE_EXCEPTION(Exception) \ > + GDB_PY_HANDLE_EXCEPTION_AND_CLEANUP(Exception, NULL) > + > +#define GDB_PY_HANDLE_EXCEPTION_AND_CLEANUP(Exception, mark) \ > do { \ > - if (Exception.reason < 0) \ > + if (Exception.reason < 0) { \ > + if (mark) \ > + value_free_to_mark (mark); \ > return PyErr_Format (Exception.reason == RETURN_QUIT \ > ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \ > "%s", Exception.message); \ > + } \ > } while (0) When I try to compile against archer-tromey-python with: ../archer/configure && make CFLAGS="-O0 -g3" I get a compile error: cc1: warnings being treated as errors ../../archer/gdb/python/py-symbol.c: In function ‘gdbpy_lookup_symbol’: ../../archer/gdb/python/py-symbol.c:200: error: implicit declaration of function ‘value_free_to_mark’ make[2]: *** [py-symbol.o] Error 1 This is because GDB_PY_HANDLE_EXCEPTION is used in many sources files, and value_free_to_mark is defined in value.{h|c}. And as you've taken over the definition of GDB_PY_HANDLE_EXCEPTION the substitution has some side-effects. So this needs to be fixed first. Did you spot or note any regressions from a full test run by comparing the gdb.sum files before and after the patch? A note indicating the platform/architecture of testing, and any regressions spotted would be great, thanks. Also, this patch needs a ChangeLog. Cheers, Phil