From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20797 invoked by alias); 29 Nov 2012 15:25:48 -0000 Received: (qmail 20777 invoked by uid 22791); 29 Nov 2012 15:25:46 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Nov 2012 15:25:39 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qATFPdSb028228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 29 Nov 2012 10:25:39 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qATFPbkI009782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 29 Nov 2012 10:25:38 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: really free pending_blocks, v2 Date: Thu, 29 Nov 2012 15:25:00 -0000 Message-ID: <87mwy077ny.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2012-11/txt/msg00866.txt.bz2 This is a refresh of the patch I erroneously sent to the main gdb list. This one uses a local obstack as suggested by John Gilmore. Built and regtested on x86-64 Fedora 16. Tom 2012-11-28 Tom Tromey * buildsym.c (struct pending_block): Move from buildsym.h. (pending_blocks): Likewise; now static. (pending_block_obstack): New global. (free_pending_blocks): Free blocks. (record_pending_block): Use pending_block_obstack. * buildsym.h (struct pending_block): Move definition to buildsym.c. (pending_blocks): Don't declare. diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 8f2e732..c3e8516 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -83,6 +83,25 @@ static struct obstack pending_addrmap_obstack; the end, then we just toss the addrmap. */ static int pending_addrmap_interesting; +/* An obstack used for allocating pending blocks. */ + +static struct obstack pending_block_obstack; + +/* List of blocks already made (lexical contexts already closed). + This is used at the end to make the blockvector. */ + +struct pending_block + { + struct pending_block *next; + struct block *block; + }; + +/* Pointer to the head of a linked list of symbol blocks which have + already been finalized (lexical contexts already closed) and which + are just waiting to be built into a blockvector when finalizing the + associated symtab. */ + +static struct pending_block *pending_blocks; static int compare_line_numbers (const void *ln1p, const void *ln2p); @@ -205,9 +224,11 @@ really_free_pendings (void *dummy) void free_pending_blocks (void) { - /* The links are made in the objfile_obstack, so we only need to - reset PENDING_BLOCKS. */ - pending_blocks = NULL; + if (pending_blocks != NULL) + { + obstack_free (&pending_block_obstack, NULL); + pending_blocks = NULL; + } } /* Take one of the lists of symbols and make a block from it. Keep @@ -418,8 +439,11 @@ record_pending_block (struct objfile *objfile, struct block *block, { struct pending_block *pblock; + if (pending_blocks == NULL) + obstack_init (&pending_block_obstack); + pblock = (struct pending_block *) - obstack_alloc (&objfile->objfile_obstack, sizeof (struct pending_block)); + obstack_alloc (&pending_block_obstack, sizeof (struct pending_block)); pblock->block = block; if (opblock) { diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 0db96bf..b7d4a76 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -37,6 +37,7 @@ struct addrmap; this technique. */ struct block; +struct pending_block; #ifndef EXTERN #define EXTERN extern @@ -177,21 +178,6 @@ EXTERN int context_stack_size; EXTERN int within_function; -/* List of blocks already made (lexical contexts already closed). - This is used at the end to make the blockvector. */ - -struct pending_block - { - struct pending_block *next; - struct block *block; - }; - -/* Pointer to the head of a linked list of symbol blocks which have - already been finalized (lexical contexts already closed) and which - are just waiting to be built into a blockvector when finalizing the - associated symtab. */ - -EXTERN struct pending_block *pending_blocks; struct subfile_stack