This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[6/17] create minsyms.h
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 14 Dec 2011 14:14:57 -0700
- Subject: [6/17] create minsyms.h
A trivial rearrangement. I may just put this one in as well.
This makes a minsyms.h and moves things there, for clarity.
It also moves the misplaced terminate_minimal_symbol_table into
minsyms.c.
Tom
>From 4e3aa0e73e51cf7ce12d010e254f0b1cbe2ed310 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Mon, 5 Dec 2011 11:20:34 -0700
Subject: [PATCH 06/18] create minsyms.h
* symfile.c (symfile_bfd_open): Don't copy name.
(load_command): Open the new BFD before freeing the old.
* symfile-mem.c (symbol_file_add_from_memory): Don't copy name.
Call gdb_bfd_stash_filename.
* spu-linux-nat.c (spu_bfd_open): Don't copy name.
* solib-spu.c (spu_bfd_fopen): Don't copy name. Call
gdb_bfd_stash_filename.
* solib-darwin.c (darwin_solib_get_all_image_info_addr_at_init):
Free found_pathname.
* rs6000-nat.c (add_vmap): Don't copy filename.
* remote.c (remote_bfd_open): Call gdb_bfd_stash_filename.
* machoread.c (macho_add_oso_symfile): Call
gdb_bfd_stash_filename.
(macho_symfile_read_all_oso): Arrange to free archive_name.
(macho_check_dsym): Don't copy filename. Call
gdb_bfd_stash_filename.
* jit.c (bfd_open_from_target_memory): Don't copy the filename.
* gdb_bfd.c (gdb_bfd_stash_filename): New function.
* gdb_bfd.h (gdb_bfd_stash_filename): Declare.
* gcore.c (create_gcore_bfd): Call gdb_bfd_stash_filename.
* exec.c (exec_close): Don't free the BFD's filename.
(exec_file_attach): Don't copy the filename.
* corelow.c (core_close): Don't free the BFD's filename.
(core_open): Call gdb_bfd_stash_filename.
* corefile.c (reopen_exec_file): Remove #if 0 code.
---
gdb/minsyms.c | 21 +++++++++++
gdb/minsyms.h | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
gdb/objfiles.c | 23 ------------
gdb/symtab.h | 78 +--------------------------------------
4 files changed, 133 insertions(+), 99 deletions(-)
create mode 100644 gdb/minsyms.h
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index f90f036..22d76e5 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1291,6 +1291,27 @@ install_minimal_symbols (struct objfile *objfile)
}
}
+/* See minsyms.h. */
+
+void
+terminate_minimal_symbol_table (struct objfile *objfile)
+{
+ if (! objfile->msymbols)
+ objfile->msymbols = ((struct minimal_symbol *)
+ obstack_alloc (&objfile->objfile_obstack,
+ sizeof (objfile->msymbols[0])));
+
+ {
+ struct minimal_symbol *m
+ = &objfile->msymbols[objfile->minimal_symbol_count];
+
+ memset (m, 0, sizeof (*m));
+ /* Don't rely on these enumeration values being 0's. */
+ MSYMBOL_TYPE (m) = mst_unknown;
+ SYMBOL_SET_LANGUAGE (m, language_unknown);
+ }
+}
+
/* Sort all the minimal symbols in OBJFILE. */
void
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
new file mode 100644
index 0000000..a60bd81
--- /dev/null
+++ b/gdb/minsyms.h
@@ -0,0 +1,110 @@
+/* Minimal symbol table definitions for GDB.
+
+ Copyright (C) 2011 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef MINSYMS_H
+#define MINSYMS_H
+
+/* Functions for dealing with the minimal symbol table, really a misc
+ address<->symbol mapping for things we don't have debug symbols for. */
+
+void prim_record_minimal_symbol (const char *, CORE_ADDR,
+ enum minimal_symbol_type,
+ struct objfile *);
+
+struct minimal_symbol *prim_record_minimal_symbol_full
+ (const char *,
+ int, int, CORE_ADDR,
+ enum minimal_symbol_type,
+ int section,
+ asection *bfd_section,
+ struct objfile *);
+
+struct minimal_symbol *prim_record_minimal_symbol_and_info
+ (const char *,
+ CORE_ADDR,
+ enum minimal_symbol_type,
+ int section,
+ asection *bfd_section,
+ struct objfile *);
+
+unsigned int msymbol_hash_iw (const char *);
+
+unsigned int msymbol_hash (const char *);
+
+/* Compute the next hash value from previous HASH and the character C. This
+ is only a GDB in-memory computed value with no external files compatibility
+ requirements. */
+
+#define SYMBOL_HASH_NEXT(hash, c) \
+ ((hash) * 67 + tolower ((unsigned char) (c)) - 113)
+
+struct objfile *msymbol_objfile (struct minimal_symbol *sym);
+
+void add_minsym_to_hash_table (struct minimal_symbol *sym,
+ struct minimal_symbol **table);
+
+struct minimal_symbol *lookup_minimal_symbol (const char *,
+ const char *,
+ struct objfile *);
+
+struct minimal_symbol *lookup_minimal_symbol_text (const char *,
+ struct objfile *);
+
+struct minimal_symbol *lookup_minimal_symbol_solib_trampoline
+ (const char *,
+ struct objfile *);
+
+struct minimal_symbol *lookup_minimal_symbol_by_pc_name
+(CORE_ADDR, const char *, struct objfile *);
+
+struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR);
+
+struct minimal_symbol *lookup_minimal_symbol_and_objfile (const char *,
+ struct objfile **);
+
+struct minimal_symbol *lookup_minimal_symbol_by_pc_section
+ (CORE_ADDR,
+ struct obj_section *);
+
+struct minimal_symbol *lookup_solib_trampoline_symbol_by_pc (CORE_ADDR);
+
+void init_minimal_symbol_collection (void);
+
+struct cleanup *make_cleanup_discard_minimal_symbols (void);
+
+void install_minimal_symbols (struct objfile *);
+
+/* Sort all the minimal symbols in OBJFILE. */
+
+void msymbols_sort (struct objfile *objfile);
+
+/* Create the terminating entry of OBJFILE's minimal symbol table.
+ If OBJFILE->msymbols is zero, allocate a single entry from
+ OBJFILE->objfile_obstack; otherwise, just initialize
+ OBJFILE->msymbols[OBJFILE->minimal_symbol_count]. */
+
+void terminate_minimal_symbol_table (struct objfile *objfile);
+
+void iterate_over_minimal_symbols (struct objfile *objf,
+ const char *name,
+ void (*callback) (struct minimal_symbol *,
+ void *),
+ void *user_data);
+
+#endif /* MINSYMS_H */
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 8afadc3..8f73600 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -351,29 +351,6 @@ entry_point_address (void)
return retval;
}
-/* Create the terminating entry of OBJFILE's minimal symbol table.
- If OBJFILE->msymbols is zero, allocate a single entry from
- OBJFILE->objfile_obstack; otherwise, just initialize
- OBJFILE->msymbols[OBJFILE->minimal_symbol_count]. */
-void
-terminate_minimal_symbol_table (struct objfile *objfile)
-{
- if (! objfile->msymbols)
- objfile->msymbols = ((struct minimal_symbol *)
- obstack_alloc (&objfile->objfile_obstack,
- sizeof (objfile->msymbols[0])));
-
- {
- struct minimal_symbol *m
- = &objfile->msymbols[objfile->minimal_symbol_count];
-
- memset (m, 0, sizeof (*m));
- /* Don't rely on these enumeration values being 0's. */
- MSYMBOL_TYPE (m) = mst_unknown;
- SYMBOL_SET_LANGUAGE (m, language_unknown);
- }
-}
-
/* Iterator on PARENT and every separate debug objfile of PARENT.
The usage pattern is:
for (objfile = parent;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 643c0e7..bbc7f2b 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -373,6 +373,8 @@ struct minimal_symbol
#define MSYMBOL_SIZE(msymbol) (msymbol)->size
#define MSYMBOL_TYPE(msymbol) (msymbol)->type
+#include "minsyms.h"
+
/* Represent one symbol name; a variable, constant, function or typedef. */
@@ -1008,62 +1010,6 @@ extern struct type *basic_lookup_transparent_type (const char *);
#define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled."
#endif
-/* Functions for dealing with the minimal symbol table, really a misc
- address<->symbol mapping for things we don't have debug symbols for. */
-
-extern void prim_record_minimal_symbol (const char *, CORE_ADDR,
- enum minimal_symbol_type,
- struct objfile *);
-
-extern struct minimal_symbol *prim_record_minimal_symbol_full
- (const char *, int, int, CORE_ADDR,
- enum minimal_symbol_type,
- int section, asection * bfd_section, struct objfile *);
-
-extern struct minimal_symbol *prim_record_minimal_symbol_and_info
- (const char *, CORE_ADDR,
- enum minimal_symbol_type,
- int section, asection * bfd_section, struct objfile *);
-
-extern unsigned int msymbol_hash_iw (const char *);
-
-extern unsigned int msymbol_hash (const char *);
-
-/* Compute the next hash value from previous HASH and the character C. This
- is only a GDB in-memory computed value with no external files compatibility
- requirements. */
-
-#define SYMBOL_HASH_NEXT(hash, c) \
- ((hash) * 67 + tolower ((unsigned char) (c)) - 113)
-
-extern struct objfile * msymbol_objfile (struct minimal_symbol *sym);
-
-extern void
-add_minsym_to_hash_table (struct minimal_symbol *sym,
- struct minimal_symbol **table);
-
-extern struct minimal_symbol *lookup_minimal_symbol (const char *,
- const char *,
- struct objfile *);
-
-extern struct minimal_symbol *lookup_minimal_symbol_text (const char *,
- struct objfile *);
-
-struct minimal_symbol *lookup_minimal_symbol_solib_trampoline (const char *,
- struct objfile
- *);
-
-extern struct minimal_symbol *lookup_minimal_symbol_by_pc_name
- (CORE_ADDR, const char *, struct objfile *);
-
-extern struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR);
-
-extern void iterate_over_minimal_symbols (struct objfile *objf,
- const char *name,
- void (*callback) (struct minimal_symbol *,
- void *),
- void *user_data);
-
extern int in_gnu_ifunc_stub (CORE_ADDR pc);
/* Functions for resolving STT_GNU_IFUNC symbols which are implemented only
@@ -1093,28 +1039,8 @@ struct gnu_ifunc_fns
extern const struct gnu_ifunc_fns *gnu_ifunc_fns_p;
-extern struct minimal_symbol *
- lookup_minimal_symbol_and_objfile (const char *,
- struct objfile **);
-
-extern struct minimal_symbol
- *lookup_minimal_symbol_by_pc_section (CORE_ADDR, struct obj_section *);
-
-extern struct minimal_symbol
- *lookup_solib_trampoline_symbol_by_pc (CORE_ADDR);
-
extern CORE_ADDR find_solib_trampoline_target (struct frame_info *, CORE_ADDR);
-extern void init_minimal_symbol_collection (void);
-
-extern struct cleanup *make_cleanup_discard_minimal_symbols (void);
-
-extern void install_minimal_symbols (struct objfile *);
-
-/* Sort all the minimal symbols in OBJFILE. */
-
-extern void msymbols_sort (struct objfile *objfile);
-
struct symtab_and_line
{
/* The program space of this sal. */
--
1.7.6.4