From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25938 invoked by alias); 1 Oct 2010 20:25:48 -0000 Received: (qmail 25909 invoked by uid 22791); 1 Oct 2010 20:25:45 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,TW_DB,TW_FN,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; Fri, 01 Oct 2010 20:25:38 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o91KPaUj005718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Oct 2010 16:25:36 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o91KPawS023791; Fri, 1 Oct 2010 16:25:36 -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 o91KPZ4l013790; Fri, 1 Oct 2010 16:25:35 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id C377A378508; Fri, 1 Oct 2010 14:25:34 -0600 (MDT) From: Tom Tromey To: gdb-patches@sourceware.org Subject: FYI: make psymtabs more const-correct Date: Fri, 01 Oct 2010 20:25: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: 2010-10/txt/msg00014.txt.bz2 I'm checking this in. This patch makes a couple more fields in psymtabs const-qualified, and fixes a couple function arguments as well. The rest of the patch is just the fallout from this. Built and regtested on x86-64 (compile farm). Tom 2010-10-01 Tom Tromey * symfile.h (allocate_symtab): Update. * symfile.c (allocate_symtab): Make 'filename' const. * psymtab.c (add_psymbol_to_bcache): Make 'name' const. (add_psymbol_to_list): Likewise. * psympriv.h (struct partial_symtab) : Now const. (add_psymbol_to_list): Update. * mdebugread.c (new_symtab): Make 'name' const. (psymtab_to_symtab_1): Make 'filename' const. * elfread.c (elfstab_offset_sections): Update. * dwarf2read.c (dwarf_decode_lines): Make 'comp_dir' const. (dwarf2_start_subfile): Make 'dirname' and 'comp_dir' const. (psymtab_include_file_name): Update. * dbxread.c (find_stab_function_addr): Make 'filename' const. * buildsym.h (start_subfile): Update. * buildsym.c (start_subfile): Make arguments const. Index: buildsym.c =================================================================== RCS file: /cvs/src/src/gdb/buildsym.c,v retrieving revision 1.80 diff -u -r1.80 buildsym.c --- buildsym.c 13 May 2010 22:44:02 -0000 1.80 +++ buildsym.c 1 Oct 2010 20:01:39 -0000 @@ -523,7 +523,7 @@ the directory in which the file was compiled (or NULL if not known). */ void -start_subfile (char *name, char *dirname) +start_subfile (const char *name, const char *dirname) { struct subfile *subfile; Index: buildsym.h =================================================================== RCS file: /cvs/src/src/gdb/buildsym.h,v retrieving revision 1.24 diff -u -r1.24 buildsym.h --- buildsym.h 1 Jan 2010 07:31:30 -0000 1.24 +++ buildsym.h 1 Oct 2010 20:01:39 -0000 @@ -253,7 +253,7 @@ extern void really_free_pendings (void *dummy); -extern void start_subfile (char *name, char *dirname); +extern void start_subfile (const char *name, const char *dirname); extern void patch_subfile_names (struct subfile *subfile, char *name); Index: dbxread.c =================================================================== RCS file: /cvs/src/src/gdb/dbxread.c,v retrieving revision 1.117 diff -u -r1.117 dbxread.c --- dbxread.c 30 Sep 2010 19:14:30 -0000 1.117 +++ dbxread.c 1 Oct 2010 20:01:39 -0000 @@ -1125,7 +1125,7 @@ } static CORE_ADDR -find_stab_function_addr (char *namestring, char *filename, +find_stab_function_addr (char *namestring, const char *filename, struct objfile *objfile) { struct minimal_symbol *msym; Index: dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.463 diff -u -r1.463 dwarf2read.c --- dwarf2read.c 29 Sep 2010 16:41:24 -0000 1.463 +++ dwarf2read.c 1 Oct 2010 20:01:40 -0000 @@ -1007,10 +1007,10 @@ (unsigned int offset, bfd *abfd, struct dwarf2_cu *cu)); -static void dwarf_decode_lines (struct line_header *, char *, bfd *, +static void dwarf_decode_lines (struct line_header *, const char *, bfd *, struct dwarf2_cu *, struct partial_symtab *); -static void dwarf2_start_subfile (char *, char *, char *); +static void dwarf2_start_subfile (char *, const char *, const char *); static struct symbol *new_symbol (struct die_info *, struct type *, struct dwarf2_cu *); @@ -9994,7 +9994,8 @@ char *include_name = fe.name; char *include_name_to_compare = include_name; char *dir_name = NULL; - char *pst_filename; + const char *pst_filename; + char *copied_name = NULL; int file_is_pst; if (fe.dir_index) @@ -10039,16 +10040,17 @@ pst_filename = pst->filename; if (!IS_ABSOLUTE_PATH (pst_filename) && pst->dirname != NULL) { - pst_filename = concat (pst->dirname, SLASH_STRING, - pst_filename, (char *)NULL); + copied_name = concat (pst->dirname, SLASH_STRING, + pst_filename, (char *)NULL); + pst_filename = copied_name; } file_is_pst = strcmp (include_name_to_compare, pst_filename) == 0; if (include_name_to_compare != include_name) xfree (include_name_to_compare); - if (pst_filename != pst->filename) - xfree (pst_filename); + if (copied_name != NULL) + xfree (copied_name); if (file_is_pst) return NULL; @@ -10078,7 +10080,7 @@ A good testcase for this is mb-inline.exp. */ static void -dwarf_decode_lines (struct line_header *lh, char *comp_dir, bfd *abfd, +dwarf_decode_lines (struct line_header *lh, const char *comp_dir, bfd *abfd, struct dwarf2_cu *cu, struct partial_symtab *pst) { gdb_byte *line_ptr, *extended_end; @@ -10421,7 +10423,7 @@ subfile's name. */ static void -dwarf2_start_subfile (char *filename, char *dirname, char *comp_dir) +dwarf2_start_subfile (char *filename, const char *dirname, const char *comp_dir) { char *fullname; Index: elfread.c =================================================================== RCS file: /cvs/src/src/gdb/elfread.c,v retrieving revision 1.98 diff -u -r1.98 elfread.c --- elfread.c 30 Sep 2010 19:14:30 -0000 1.98 +++ elfread.c 1 Oct 2010 20:01:40 -0000 @@ -979,7 +979,7 @@ void elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst) { - char *filename = pst->filename; + const char *filename = pst->filename; struct dbx_symfile_info *dbx = objfile->deprecated_sym_stab_info; struct stab_section_info *maybe = dbx->stab_section_info; struct stab_section_info *questionable = 0; Index: mdebugread.c =================================================================== RCS file: /cvs/src/src/gdb/mdebugread.c,v retrieving revision 1.114 diff -u -r1.114 mdebugread.c --- mdebugread.c 9 Aug 2010 19:42:48 -0000 1.114 +++ mdebugread.c 1 Oct 2010 20:01:41 -0000 @@ -232,7 +232,7 @@ static struct block *new_block (enum block_type); -static struct symtab *new_symtab (char *, int, struct objfile *); +static struct symtab *new_symtab (const char *, int, struct objfile *); static struct linetable *new_linetable (int); @@ -248,7 +248,7 @@ static struct partial_symtab *new_psymtab (char *, struct objfile *); -static void psymtab_to_symtab_1 (struct partial_symtab *, char *); +static void psymtab_to_symtab_1 (struct partial_symtab *, const char *); static void add_block (struct block *, struct symtab *); @@ -3888,7 +3888,7 @@ The flow of control and even the memory allocation differs. FIXME. */ static void -psymtab_to_symtab_1 (struct partial_symtab *pst, char *filename) +psymtab_to_symtab_1 (struct partial_symtab *pst, const char *filename) { bfd_size_type external_sym_size; bfd_size_type external_pdr_size; @@ -4671,7 +4671,7 @@ linenumbers MAXLINES we'll put in it */ static struct symtab * -new_symtab (char *name, int maxlines, struct objfile *objfile) +new_symtab (const char *name, int maxlines, struct objfile *objfile) { struct symtab *s = allocate_symtab (name, objfile); Index: psympriv.h =================================================================== RCS file: /cvs/src/src/gdb/psympriv.h,v retrieving revision 1.3 diff -u -r1.3 psympriv.h --- psympriv.h 14 Sep 2010 22:50:30 -0000 1.3 +++ psympriv.h 1 Oct 2010 20:01:41 -0000 @@ -73,7 +73,7 @@ /* Name of the source file which this partial_symtab defines */ - char *filename; + const char *filename; /* Full path of the source file. NULL if not known. */ @@ -81,7 +81,7 @@ /* Directory in which it was compiled, or NULL if we don't know. */ - char *dirname; + const char *dirname; /* Information about the object file from which symbols should be read. */ @@ -156,7 +156,7 @@ /* Add any kind of symbol to a psymbol_allocation_list. */ extern const -struct partial_symbol *add_psymbol_to_list (char *, int, int, domain_enum, +struct partial_symbol *add_psymbol_to_list (const char *, int, int, domain_enum, enum address_class, struct psymbol_allocation_list *, long, CORE_ADDR, Index: psymtab.c =================================================================== RCS file: /cvs/src/src/gdb/psymtab.c,v retrieving revision 1.15 diff -u -r1.15 psymtab.c --- psymtab.c 14 Sep 2010 22:50:30 -0000 1.15 +++ psymtab.c 1 Oct 2010 20:01:41 -0000 @@ -1368,7 +1368,7 @@ different domain (or address) is possible and correct. */ static const struct partial_symbol * -add_psymbol_to_bcache (char *name, int namelength, int copy_name, +add_psymbol_to_bcache (const char *name, int namelength, int copy_name, domain_enum domain, enum address_class class, long val, /* Value as a long */ @@ -1465,7 +1465,7 @@ cache. */ const struct partial_symbol * -add_psymbol_to_list (char *name, int namelength, int copy_name, +add_psymbol_to_list (const char *name, int namelength, int copy_name, domain_enum domain, enum address_class class, struct psymbol_allocation_list *list, Index: symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.296 diff -u -r1.296 symfile.c --- symfile.c 30 Sep 2010 19:14:30 -0000 1.296 +++ symfile.c 1 Oct 2010 20:01:41 -0000 @@ -2724,7 +2724,7 @@ */ struct symtab * -allocate_symtab (char *filename, struct objfile *objfile) +allocate_symtab (const char *filename, struct objfile *objfile) { struct symtab *symtab; Index: symfile.h =================================================================== RCS file: /cvs/src/src/gdb/symfile.h,v retrieving revision 1.74 diff -u -r1.74 symfile.h --- symfile.h 30 Sep 2010 19:14:30 -0000 1.74 +++ symfile.h 1 Oct 2010 20:01:41 -0000 @@ -374,7 +374,7 @@ extern bfd_byte *default_symfile_relocate (struct objfile *objfile, asection *sectp, bfd_byte *buf); -extern struct symtab *allocate_symtab (char *, struct objfile *); +extern struct symtab *allocate_symtab (const char *, struct objfile *); extern void add_symtab_fns (const struct sym_fns *);