From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26918 invoked by alias); 14 Jun 2011 16:49:40 -0000 Received: (qmail 26902 invoked by uid 22791); 14 Jun 2011 16:49:38 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,TW_DB,TW_YM,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; Tue, 14 Jun 2011 16:49:20 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5EGnJX7026259 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 14 Jun 2011 12:49:19 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5EGnJ2x005692; Tue, 14 Jun 2011 12:49:19 -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 p5EGnIaQ019722; Tue, 14 Jun 2011 12:49:18 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 2B7CB378233; Tue, 14 Jun 2011 10:49:17 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: make current_objfile local to symbol readers Date: Tue, 14 Jun 2011 16:49:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) 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-06/txt/msg00191.txt.bz2 I'm checking this in on the trunk. The global 'current_objfile' is used by some symbol readers, but only in a local way. This patch removes makes this global be local to the readers which use it. I think this is clearer and also prevents new (bad) uses of this global in the future. Built and regtested on the buildbot. Tom 2011-06-14 Tom Tromey * symtab.h (current_objfile): Don't declare. * objfiles.h (current_objfile): Don't declare. * objfiles.c (current_objfile): Remove. * mdebugread.c (current_objfile): New file-scope global. * dbxread.c (current_objfile): New file-scope global. * coffread.c (current_objfile): New file-scope global. Index: coffread.c =================================================================== RCS file: /cvs/src/src/gdb/coffread.c,v retrieving revision 1.122 diff -u -r1.122 coffread.c --- coffread.c 26 May 2011 07:47:10 -0000 1.122 +++ coffread.c 14 Jun 2011 16:46:16 -0000 @@ -49,6 +49,10 @@ extern void _initialize_coffread (void); +/* The objfile we are currently reading. */ + +static struct objfile *current_objfile; + struct coff_symfile_info { file_ptr min_lineno_offset; /* Where in file lowest line#s are. */ Index: dbxread.c =================================================================== RCS file: /cvs/src/src/gdb/dbxread.c,v retrieving revision 1.127 diff -u -r1.127 dbxread.c --- dbxread.c 23 Mar 2011 18:23:54 -0000 1.127 +++ dbxread.c 14 Jun 2011 16:46:17 -0000 @@ -1,6 +1,6 @@ /* Read dbx symbol tables and convert to internal format, for GDB. Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, - 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010. + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010, 2011. Free Software Foundation, Inc. This file is part of GDB. @@ -105,6 +105,10 @@ #define FILE_STRING_OFFSET(p) (SYMLOC(p)->file_string_offset) +/* The objfile we are currently reading. */ + +static struct objfile *current_objfile; + /* Remember what we deduced to be the source language of this psymtab. */ static enum language psymtab_language = language_unknown; Index: mdebugread.c =================================================================== RCS file: /cvs/src/src/gdb/mdebugread.c,v retrieving revision 1.123 diff -u -r1.123 mdebugread.c --- mdebugread.c 4 Apr 2011 15:11:19 -0000 1.123 +++ mdebugread.c 14 Jun 2011 16:46:17 -0000 @@ -78,6 +78,11 @@ case the symbol's ELF section could not be represented in ECOFF. */ #define ECOFF_IN_ELF(bfd) (bfd_get_flavour (bfd) == bfd_target_elf_flavour \ && bfd_get_section_by_name (bfd, ".mdebug") != NULL) + +/* The objfile we are currently reading. */ + +static struct objfile *current_objfile; + /* We put a pointer to this structure in the read_symtab_private field Index: objfiles.c =================================================================== RCS file: /cvs/src/src/gdb/objfiles.c,v retrieving revision 1.131 diff -u -r1.131 objfiles.c --- objfiles.c 25 Apr 2011 19:38:15 -0000 1.131 +++ objfiles.c 14 Jun 2011 16:46:17 -0000 @@ -64,7 +64,6 @@ /* Externally visible variables that are owned by this module. See declarations in objfile.h for more info. */ -struct objfile *current_objfile; /* For symbol file being read in */ struct objfile *rt_common_objfile; /* For runtime common symbols */ struct objfile_pspace_info Index: objfiles.h =================================================================== RCS file: /cvs/src/src/gdb/objfiles.h,v retrieving revision 1.84 diff -u -r1.84 objfiles.h --- objfiles.h 1 Jun 2011 14:46:23 -0000 1.84 +++ objfiles.h 14 Jun 2011 16:46:24 -0000 @@ -439,21 +439,6 @@ extern struct objfile *rt_common_objfile; -/* When we need to allocate a new type, we need to know which objfile_obstack - to allocate the type on, since there is one for each objfile. The places - where types are allocated are deeply buried in function call hierarchies - which know nothing about objfiles, so rather than trying to pass a - particular objfile down to them, we just do an end run around them and - set current_objfile to be whatever objfile we expect to be using at the - time types are being allocated. For instance, when we start reading - symbols for a particular objfile, we set current_objfile to point to that - objfile, and when we are done, we set it back to NULL, to ensure that we - never put a type someplace other than where we are expecting to put it. - FIXME: Maybe we should review the entire type handling system and - see if there is a better way to avoid this problem. */ - -extern struct objfile *current_objfile; - /* Declarations for functions defined in objfiles.c */ extern struct objfile *allocate_objfile (bfd *, int); Index: symtab.h =================================================================== RCS file: /cvs/src/src/gdb/symtab.h,v retrieving revision 1.182 diff -u -r1.182 symtab.h --- symtab.h 6 May 2011 15:06:48 -0000 1.182 +++ symtab.h 14 Jun 2011 16:46:25 -0000 @@ -847,10 +847,6 @@ /* External variables and functions for the objects described above. */ -/* See the comment in symfile.c about how current_objfile is used. */ - -extern struct objfile *current_objfile; - /* True if we are nested inside psymtab_to_symtab. */ extern int currently_reading_symtab;