aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorK. Richard Pixley <rich@cygnus>1993-04-07 07:04:26 +0000
committerK. Richard Pixley <rich@cygnus>1993-04-07 07:04:26 +0000
commit73d0fc782010af6ad1784c9e3a8fc41997ec922b (patch)
treeb2b30811f85c276e9ef87d1bc3b87c67288e937a
parent07861607f5b7010e4b5f908361783aac2c096e1e (diff)
downloadgdb-73d0fc782010af6ad1784c9e3a8fc41997ec922b.zip
gdb-73d0fc782010af6ad1784c9e3a8fc41997ec922b.tar.gz
gdb-73d0fc782010af6ad1784c9e3a8fc41997ec922b.tar.bz2
Add section table to objfile struct. Use it for find_pc_section.
* objfiles.c (add_to_objfile_sections, build_objfile_section_table, find_pc_section): new functions. (allocate_objfile): build section table. * objfiles.h (struct obj_section): new structure. (struct objfile): add section table. (find_pc_section): new prototype. * solib.[ch] (find_pc_section_from_so_list): removed. * sparc-tdep.c: include objfiles.h for find_pc_section. include symfile.h for objfiles.h. (in_solib_trampoline): adjusted for new find_pc_section prototype. Removed BAD_RICH_HACK ifdefs. * symfile.c (syms_from_objfile): offset objfile sections. (find_pc_section): removed. Also removed BAD_RICH_HACK ifdefs. * symfile.h (find_pc_section): prototype removed. Also fixed comment typo NUL -> NULL. * target.[ch] (find_pc_section_from_targets): removed. * config/sparc/tm-sun4sol2.h (BAD_RICHH_HACK): removed.
-rw-r--r--gdb/ChangeLog21
-rw-r--r--gdb/config/sparc/tm-sun4sol2.h6
-rw-r--r--gdb/objfiles.c71
-rw-r--r--gdb/objfiles.h22
-rw-r--r--gdb/solib.h3
-rw-r--r--gdb/symfile.h23
6 files changed, 118 insertions, 28 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7cae9cc..2eec88f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,24 @@
+Tue Apr 6 22:30:58 1993 K. Richard Pixley (rich@cygnus.com)
+
+ Add section table to objfile struct. Use it for find_pc_section.
+ * objfiles.c (add_to_objfile_sections,
+ build_objfile_section_table, find_pc_section): new functions.
+ (allocate_objfile): build section table.
+ * objfiles.h (struct obj_section): new structure.
+ (struct objfile): add section table.
+ (find_pc_section): new prototype.
+ * solib.[ch] (find_pc_section_from_so_list): removed.
+ * sparc-tdep.c: include objfiles.h for find_pc_section. include
+ symfile.h for objfiles.h.
+ (in_solib_trampoline): adjusted for new find_pc_section
+ prototype. Removed BAD_RICH_HACK ifdefs.
+ * symfile.c (syms_from_objfile): offset objfile sections.
+ (find_pc_section): removed. Also removed BAD_RICH_HACK ifdefs.
+ * symfile.h (find_pc_section): prototype removed. Also fixed
+ comment typo NUL -> NULL.
+ * target.[ch] (find_pc_section_from_targets): removed.
+ * config/sparc/tm-sun4sol2.h (BAD_RICHH_HACK): removed.
+
Tue Apr 6 21:41:13 1993 Stu Grossman (grossman@cygnus.com)
* ser-go32.c: Format. (go32_open): Use proper return value.
diff --git a/gdb/config/sparc/tm-sun4sol2.h b/gdb/config/sparc/tm-sun4sol2.h
index 3208a9c..a95ef3b 100644
--- a/gdb/config/sparc/tm-sun4sol2.h
+++ b/gdb/config/sparc/tm-sun4sol2.h
@@ -23,12 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#undef IN_SOLIB_TRAMPOLINE
#define IN_SOLIB_TRAMPOLINE(pc, name) in_solib_trampoline((pc), (name))
-/* BAD_RICH_HACK is a bad hack. What needs to happen here is for
- sections to move out of the solib structures and into objfiles.
- I'm working on this. FIXME. 1apr93 rich@cygnus.com. */
-
-#define BAD_RICH_HACK
-
/* The values of N_SLINE, N_LBRAC, N_RBRAC symbols in .stab sections are
relative to the current function, rather than being absolute or
relative to the current N_SO. */
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 7fb53e7..541941a 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -60,6 +60,51 @@ struct objfile *symfile_objfile; /* Main symbol table loaded from */
int mapped_symbol_files; /* Try to use mapped symbol files */
+/* Locate all mappable sections of a BFD file.
+ objfile_p_char is a char * to get it through
+ bfd_map_over_sections; we cast it back to its proper type. */
+
+static void
+add_to_objfile_sections (abfd, asect, objfile_p_char)
+ bfd *abfd;
+ sec_ptr asect;
+ PTR objfile_p_char;
+{
+ struct objfile *objfile = (struct objfile *) objfile_p_char;
+ struct obj_section section;
+ flagword aflag;
+
+ aflag = bfd_get_section_flags (abfd, asect);
+ /* FIXME, we need to handle BSS segment here...it alloc's but doesn't load */
+ if (!(aflag & SEC_LOAD))
+ return;
+ if (0 == bfd_section_size (abfd, asect))
+ return;
+ section.offset = 0;
+ section.sec_ptr = asect;
+ section.addr = bfd_section_vma (abfd, asect);
+ section.endaddr = section.addr + bfd_section_size (abfd, asect);
+ obstack_grow (&objfile->psymbol_obstack, &section, sizeof(section));
+ objfile->sections_end = (struct obj_section *) (((int) objfile->sections_end) + 1);
+}
+
+/* Builds a section table for OBJFILE.
+ Returns 0 if OK, 1 on error. */
+
+static int
+build_objfile_section_table (objfile)
+ struct objfile *objfile;
+{
+ if (objfile->sections)
+ abort();
+
+ objfile->sections_end = 0;
+ bfd_map_over_sections (objfile->obfd, add_to_objfile_sections, (char *)objfile);
+ objfile->sections = obstack_finish (&objfile->psymbol_obstack);
+ objfile->sections_end = objfile->sections + (int) objfile->sections_end;
+ return(0);
+}
+
/* Given a pointer to an initialized bfd (ABFD) and a flag that indicates
whether or not an objfile is to be mapped (MAPPED), allocate a new objfile
struct, fill it in as best we can, link it into the list of all known
@@ -188,6 +233,14 @@ allocate_objfile (abfd, mapped)
objfile -> name = mstrsave (objfile -> md, bfd_get_filename (abfd));
objfile -> mtime = bfd_get_mtime (abfd);
+ /* Build section table. */
+
+ if (build_objfile_section_table (objfile))
+ {
+ error ("Can't find the file sections in `%s': %s",
+ objfile -> name, bfd_errmsg (bfd_error));
+ }
+
/* Push this file onto the head of the linked list of other such files. */
objfile -> next = object_files;
@@ -658,3 +711,21 @@ map_to_address ()
}
#endif /* !defined(NO_MMALLOC) && defined(HAVE_MMAP) */
+
+/* Returns a section whose range includes PC or NULL if none found. */
+
+sec_ptr
+find_pc_section(pc)
+ CORE_ADDR pc;
+{
+ struct obj_section *s;
+ struct objfile *objfile;
+
+ ALL_OBJFILES (objfile)
+ for (s = objfile->sections; s < objfile->sections_end; ++s)
+ if (s->addr <= pc
+ && pc < s->endaddr)
+ return(s->sec_ptr);
+
+ return(NULL);
+}
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index beaebca..3cc5de1 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -114,6 +114,18 @@ struct entry_info
};
+/* This structure is used to map pc values into sections. Note that
+ offset is currently target independent and is redundant to the
+ section_offsets field in the objfile struct. FIXME. */
+
+struct obj_section {
+ CORE_ADDR addr; /* lowest address in section */
+ CORE_ADDR endaddr; /* 1+highest address in section */
+ CORE_ADDR offset; /* offset between (end)addr and actual
+ memory addresses. */
+ sec_ptr sec_ptr; /* BFD section pointer */
+};
+
/* Master structure for keeping track of each input file from which
gdb reads symbols. One of these is allocated for each such file we
access, e.g. the exec_file, symbol_file, and any shared library object
@@ -257,6 +269,14 @@ struct objfile
struct section_offsets *section_offsets;
int num_sections;
+
+ /* set of section begin and end addresses used to map pc addresses
+ into sections. Currently on the psymbol_obstack (which makes no
+ sense, but I'm not sure it's harming anything). */
+
+ struct obj_section
+ *sections,
+ *sections_end;
};
/* Defines for the objfile flag word. */
@@ -333,6 +353,8 @@ have_full_symbols PARAMS ((void));
extern int
have_minimal_symbols PARAMS ((void));
+extern sec_ptr
+find_pc_section PARAMS((CORE_ADDR pc));
/* Traverse all object files. ALL_OBJFILES_SAFE works even if you delete
the objfile during the traversal. */
diff --git a/gdb/solib.h b/gdb/solib.h
index f11470b..ddabf74 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -54,6 +54,3 @@ solib_create_inferior_hook PARAMS((void)); /* solib.c */
extern int
solib_address PARAMS ((CORE_ADDR)); /* solib.c */
-
-struct section_table *
-find_pc_section_from_so_list PARAMS ((CORE_ADDR pc)); /* solib.c */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index b1355d3..306735d 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -40,9 +40,9 @@ struct sym_fns {
/* counts how many bytes of sym_name should be checked against the
BFD target type of the file being read. If an exact match is
- desired, specify the number of characters in sym_name plus 1 for the
- NUL. If a prefix match is desired, specify the number of characters in
- sym_name. */
+ desired, specify the number of characters in sym_name plus 1 for
+ the NULL. If a prefix match is desired, specify the number of
+ characters in sym_name. */
int sym_namelen;
@@ -133,22 +133,7 @@ extend_psymbol_list PARAMS ((struct psymbol_allocation_list *,
PSYMBOL_CLASS (psym) = (CLASS); \
VT (psym) = (VALUE); \
SYMBOL_LANGUAGE (psym) = (LANGUAGE); \
- if ((LANGUAGE) == language_cplus) \
- { \
- demangled_name = \
- cplus_demangle (SYMBOL_NAME (psym), DMGL_PARAMS | DMGL_ANSI); \
- if (demangled_name == NULL) \
- { \
- SYMBOL_DEMANGLED_NAME (psym) = NULL; \
- } \
- else \
- { \
- SYMBOL_DEMANGLED_NAME (psym) = \
- obsavestring (demangled_name, strlen (demangled_name), \
- &objfile->psymbol_obstack); \
- free (demangled_name); \
- } \
- } \
+ SYMBOL_INIT_DEMANGLED_NAME (psym, &objfile->psymbol_obstack); \
} while (0);
/* Add a symbol with an integer value to a psymtab. */