From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25486 invoked by alias); 4 Apr 2011 15:19:56 -0000 Received: (qmail 25470 invoked by uid 22791); 4 Apr 2011 15:19:54 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,T_RP_MATCHES_RCVD 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; Mon, 04 Apr 2011 15:19:18 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p34FJHmJ022016 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 4 Apr 2011 11:19:17 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p34FJHrd007742; Mon, 4 Apr 2011 11:19:17 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p34FJGv6025624; Mon, 4 Apr 2011 11:19:17 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 992AD37848E; Mon, 4 Apr 2011 09:18:57 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: remove free_symtab Date: Mon, 04 Apr 2011 15:19:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2011-04/txt/msg00055.txt.bz2 I'm checking this in on the trunk. After the preceding patches, it is obvious that `free_symtab' is dead: it had no callers in the tree, but now it is clear that it isn't needed even in theory. So, this patch removes it. Currently, nothing frees the `line_charpos' and `fullname' fields of symtabs in a dying objfile. This patch clears up this memory leak by freeing these from free_objfile. Built and regtested on x86-64 (compile farm). Tom 2011-04-04 Tom Tromey * symtab.h (free_symtab): Remove. (forget_cached_source_info_for_objfile): Declare. * symmisc.c (free_symtab): Remove. * source.c (forget_cached_source_info_for_objfile): New function. (forget_cached_source_info): Use it. * objfiles.c (free_objfile): Simplify check before calling clear_current_source_symtab_and_line. Call forget_cached_source_info_for_objfile. Index: objfiles.c =================================================================== RCS file: /cvs/src/src/gdb/objfiles.c,v retrieving revision 1.128 diff -u -r1.128 objfiles.c --- objfiles.c 4 Apr 2011 14:37:16 -0000 1.128 +++ objfiles.c 4 Apr 2011 15:17:54 -0000 @@ -632,15 +632,13 @@ { struct symtab_and_line cursal = get_current_source_symtab_and_line (); - struct symtab *s; - ALL_OBJFILE_SYMTABS (objfile, s) - { - if (s == cursal.symtab) - clear_current_source_symtab_and_line (); - } + if (cursal.symtab && cursal.symtab->objfile == objfile) + clear_current_source_symtab_and_line (); } + forget_cached_source_info_for_objfile (objfile); + /* The last thing we do is free the objfile struct itself. */ xfree (objfile->name); Index: source.c =================================================================== RCS file: /cvs/src/src/gdb/source.c,v retrieving revision 1.122 diff -u -r1.122 source.c --- source.c 4 Apr 2011 14:18:11 -0000 1.122 +++ source.c 4 Apr 2011 15:17:55 -0000 @@ -335,6 +335,32 @@ show_directories_1 (NULL, from_tty); } +/* Forget line positions and file names for the symtabs in a + particular objfile. */ + +void +forget_cached_source_info_for_objfile (struct objfile *objfile) +{ + struct symtab *s; + + ALL_OBJFILE_SYMTABS (objfile, s) + { + if (s->line_charpos != NULL) + { + xfree (s->line_charpos); + s->line_charpos = NULL; + } + if (s->fullname != NULL) + { + xfree (s->fullname); + s->fullname = NULL; + } + + if (objfile->sf) + objfile->sf->qf->forget_cached_source_info (objfile); + } +} + /* Forget what we learned about line positions in source files, and which directories contain them; must check again now since files may be found in a different directory now. */ @@ -349,22 +375,7 @@ ALL_PSPACES (pspace) ALL_PSPACE_OBJFILES (pspace, objfile) { - for (s = objfile->symtabs; s != NULL; s = s->next) - { - if (s->line_charpos != NULL) - { - xfree (s->line_charpos); - s->line_charpos = NULL; - } - if (s->fullname != NULL) - { - xfree (s->fullname); - s->fullname = NULL; - } - } - - if (objfile->sf) - objfile->sf->qf->forget_cached_source_info (objfile); + forget_cached_source_info_for_objfile (objfile); } last_source_visited = NULL; Index: symmisc.c =================================================================== RCS file: /cvs/src/src/gdb/symmisc.c,v retrieving revision 1.79 diff -u -r1.79 symmisc.c --- symmisc.c 4 Apr 2011 15:11:19 -0000 1.79 +++ symmisc.c 4 Apr 2011 15:17:55 -0000 @@ -79,18 +79,6 @@ static int print_symbol (void *); -/* Free all the storage associated with the struct symtab <- S. */ - -void -free_symtab (struct symtab *s) -{ - /* Free source-related stuff. */ - if (s->line_charpos != NULL) - xfree (s->line_charpos); - if (s->fullname != NULL) - xfree (s->fullname); - xfree (s); -} void print_symbol_bcache_statistics (void) Index: symtab.h =================================================================== RCS file: /cvs/src/src/gdb/symtab.h,v retrieving revision 1.176 diff -u -r1.176 symtab.h --- symtab.h 4 Apr 2011 15:11:19 -0000 1.176 +++ symtab.h 4 Apr 2011 15:17:55 -0000 @@ -1165,8 +1165,6 @@ void maintenance_print_statistics (char *, int); -extern void free_symtab (struct symtab *); - /* Symbol-reading stuff in symfile.c and solib.c. */ extern void clear_solib (void); @@ -1177,6 +1175,7 @@ extern void print_source_lines (struct symtab *, int, int, int); +extern void forget_cached_source_info_for_objfile (struct objfile *); extern void forget_cached_source_info (void); extern void select_source_symtab (struct symtab *);