xref: /dflybsd-src/contrib/gdb-7/gdb/psympriv.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
1cf7f2e2dSJohn Marino /* Private partial symbol table definitions.
2cf7f2e2dSJohn Marino 
3*ef5ccd6cSJohn Marino    Copyright (C) 2009-2013 Free Software Foundation, Inc.
4cf7f2e2dSJohn Marino 
5cf7f2e2dSJohn Marino    This file is part of GDB.
6cf7f2e2dSJohn Marino 
7cf7f2e2dSJohn Marino    This program is free software; you can redistribute it and/or modify
8cf7f2e2dSJohn Marino    it under the terms of the GNU General Public License as published by
9cf7f2e2dSJohn Marino    the Free Software Foundation; either version 3 of the License, or
10cf7f2e2dSJohn Marino    (at your option) any later version.
11cf7f2e2dSJohn Marino 
12cf7f2e2dSJohn Marino    This program is distributed in the hope that it will be useful,
13cf7f2e2dSJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
14cf7f2e2dSJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15cf7f2e2dSJohn Marino    GNU General Public License for more details.
16cf7f2e2dSJohn Marino 
17cf7f2e2dSJohn Marino    You should have received a copy of the GNU General Public License
18cf7f2e2dSJohn Marino    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19cf7f2e2dSJohn Marino 
20cf7f2e2dSJohn Marino #ifndef PSYMPRIV_H
21cf7f2e2dSJohn Marino #define PSYMPRIV_H
22cf7f2e2dSJohn Marino 
23cf7f2e2dSJohn Marino #include "psymtab.h"
24cf7f2e2dSJohn Marino 
25c50c785cSJohn Marino struct psymbol_allocation_list;
26c50c785cSJohn Marino 
27cf7f2e2dSJohn Marino /* A partial_symbol records the name, domain, and address class of
28cf7f2e2dSJohn Marino    symbols whose types we have not parsed yet.  For functions, it also
29cf7f2e2dSJohn Marino    contains their memory address, so we can find them from a PC value.
30cf7f2e2dSJohn Marino    Each partial_symbol sits in a partial_symtab, all of which are chained
31cf7f2e2dSJohn Marino    on a  partial symtab list and which points to the corresponding
32cf7f2e2dSJohn Marino    normal symtab once the partial_symtab has been referenced.  */
33cf7f2e2dSJohn Marino 
34cf7f2e2dSJohn Marino /* This structure is space critical.  See space comments at the top of
35cf7f2e2dSJohn Marino    symtab.h.  */
36cf7f2e2dSJohn Marino 
37cf7f2e2dSJohn Marino struct partial_symbol
38cf7f2e2dSJohn Marino {
39cf7f2e2dSJohn Marino 
40cf7f2e2dSJohn Marino   /* The general symbol info required for all types of symbols.  */
41cf7f2e2dSJohn Marino 
42cf7f2e2dSJohn Marino   struct general_symbol_info ginfo;
43cf7f2e2dSJohn Marino 
44cf7f2e2dSJohn Marino   /* Name space code.  */
45cf7f2e2dSJohn Marino 
46cf7f2e2dSJohn Marino   ENUM_BITFIELD(domain_enum_tag) domain : 6;
47cf7f2e2dSJohn Marino 
48c50c785cSJohn Marino   /* Address class (for info_symbols).  */
49cf7f2e2dSJohn Marino 
50cf7f2e2dSJohn Marino   ENUM_BITFIELD(address_class) aclass : 6;
51cf7f2e2dSJohn Marino 
52cf7f2e2dSJohn Marino };
53cf7f2e2dSJohn Marino 
54cf7f2e2dSJohn Marino #define PSYMBOL_DOMAIN(psymbol)	(psymbol)->domain
55cf7f2e2dSJohn Marino #define PSYMBOL_CLASS(psymbol)		(psymbol)->aclass
56cf7f2e2dSJohn Marino 
57*ef5ccd6cSJohn Marino /* A convenience enum to give names to some constants used when
58*ef5ccd6cSJohn Marino    searching psymtabs.  This is internal to psymtab and should not be
59*ef5ccd6cSJohn Marino    used elsewhere.  */
60*ef5ccd6cSJohn Marino 
61*ef5ccd6cSJohn Marino enum psymtab_search_status
62*ef5ccd6cSJohn Marino   {
63*ef5ccd6cSJohn Marino     PST_NOT_SEARCHED,
64*ef5ccd6cSJohn Marino     PST_SEARCHED_AND_FOUND,
65*ef5ccd6cSJohn Marino     PST_SEARCHED_AND_NOT_FOUND
66*ef5ccd6cSJohn Marino   };
67*ef5ccd6cSJohn Marino 
68cf7f2e2dSJohn Marino /* Each source file that has not been fully read in is represented by
69cf7f2e2dSJohn Marino    a partial_symtab.  This contains the information on where in the
70cf7f2e2dSJohn Marino    executable the debugging symbols for a specific file are, and a
71cf7f2e2dSJohn Marino    list of names of global symbols which are located in this file.
72cf7f2e2dSJohn Marino    They are all chained on partial symtab lists.
73cf7f2e2dSJohn Marino 
74cf7f2e2dSJohn Marino    Even after the source file has been read into a symtab, the
75cf7f2e2dSJohn Marino    partial_symtab remains around.  They are allocated on an obstack,
76cf7f2e2dSJohn Marino    objfile_obstack.  */
77cf7f2e2dSJohn Marino 
78cf7f2e2dSJohn Marino struct partial_symtab
79cf7f2e2dSJohn Marino {
80cf7f2e2dSJohn Marino 
81cf7f2e2dSJohn Marino   /* Chain of all existing partial symtabs.  */
82cf7f2e2dSJohn Marino 
83cf7f2e2dSJohn Marino   struct partial_symtab *next;
84cf7f2e2dSJohn Marino 
85*ef5ccd6cSJohn Marino   /* Name of the source file which this partial_symtab defines,
86*ef5ccd6cSJohn Marino      or if the psymtab is anonymous then a descriptive name for
87*ef5ccd6cSJohn Marino      debugging purposes, or "".  It must not be NULL.  */
88cf7f2e2dSJohn Marino 
89c50c785cSJohn Marino   const char *filename;
90cf7f2e2dSJohn Marino 
91cf7f2e2dSJohn Marino   /* Full path of the source file.  NULL if not known.  */
92cf7f2e2dSJohn Marino 
93cf7f2e2dSJohn Marino   char *fullname;
94cf7f2e2dSJohn Marino 
95cf7f2e2dSJohn Marino   /* Directory in which it was compiled, or NULL if we don't know.  */
96cf7f2e2dSJohn Marino 
97c50c785cSJohn Marino   const char *dirname;
98cf7f2e2dSJohn Marino 
99cf7f2e2dSJohn Marino   /* Set of relocation offsets to apply to each section.  */
100cf7f2e2dSJohn Marino 
101cf7f2e2dSJohn Marino   struct section_offsets *section_offsets;
102cf7f2e2dSJohn Marino 
103cf7f2e2dSJohn Marino   /* Range of text addresses covered by this file; texthigh is the
104a45ae5f8SJohn Marino      beginning of the next section.  Do not use if PSYMTABS_ADDRMAP_SUPPORTED
105a45ae5f8SJohn Marino      is set.  */
106cf7f2e2dSJohn Marino 
107cf7f2e2dSJohn Marino   CORE_ADDR textlow;
108cf7f2e2dSJohn Marino   CORE_ADDR texthigh;
109cf7f2e2dSJohn Marino 
110cf7f2e2dSJohn Marino   /* Array of pointers to all of the partial_symtab's which this one
111cf7f2e2dSJohn Marino      depends on.  Since this array can only be set to previous or
112cf7f2e2dSJohn Marino      the current (?) psymtab, this dependency tree is guaranteed not
113cf7f2e2dSJohn Marino      to have any loops.  "depends on" means that symbols must be read
114cf7f2e2dSJohn Marino      for the dependencies before being read for this psymtab; this is
115cf7f2e2dSJohn Marino      for type references in stabs, where if foo.c includes foo.h, declarations
116cf7f2e2dSJohn Marino      in foo.h may use type numbers defined in foo.c.  For other debugging
117cf7f2e2dSJohn Marino      formats there may be no need to use dependencies.  */
118cf7f2e2dSJohn Marino 
119cf7f2e2dSJohn Marino   struct partial_symtab **dependencies;
120cf7f2e2dSJohn Marino 
121cf7f2e2dSJohn Marino   int number_of_dependencies;
122cf7f2e2dSJohn Marino 
123*ef5ccd6cSJohn Marino   /* If NULL, this is an ordinary partial symbol table.
124*ef5ccd6cSJohn Marino 
125*ef5ccd6cSJohn Marino      If non-NULL, this holds a single includer of this partial symbol
126*ef5ccd6cSJohn Marino      table, and this partial symbol table is a shared one.
127*ef5ccd6cSJohn Marino 
128*ef5ccd6cSJohn Marino      A shared psymtab is one that is referenced by multiple other
129*ef5ccd6cSJohn Marino      psymtabs, and which conceptually has its contents directly
130*ef5ccd6cSJohn Marino      included in those.
131*ef5ccd6cSJohn Marino 
132*ef5ccd6cSJohn Marino      Shared psymtabs have special semantics.  When a search finds a
133*ef5ccd6cSJohn Marino      symbol in a shared table, we instead return one of the non-shared
134*ef5ccd6cSJohn Marino      tables that include this one.
135*ef5ccd6cSJohn Marino 
136*ef5ccd6cSJohn Marino      A shared psymtabs can be referred to by other shared ones.
137*ef5ccd6cSJohn Marino 
138*ef5ccd6cSJohn Marino      The psymtabs that refer to a shared psymtab will list the shared
139*ef5ccd6cSJohn Marino      psymtab in their 'dependencies' array.
140*ef5ccd6cSJohn Marino 
141*ef5ccd6cSJohn Marino      In DWARF terms, a shared psymtab is a DW_TAG_partial_unit; but
142*ef5ccd6cSJohn Marino      of course using a name based on that would be too confusing, so
143*ef5ccd6cSJohn Marino      "shared" was chosen instead.
144*ef5ccd6cSJohn Marino 
145*ef5ccd6cSJohn Marino      Only a single user is needed because, when expanding a shared
146*ef5ccd6cSJohn Marino      psymtab, we only need to expand its "canonical" non-shared user.
147*ef5ccd6cSJohn Marino      The choice of which one should be canonical is left to the
148*ef5ccd6cSJohn Marino      debuginfo reader; it can be arbitrary.  */
149*ef5ccd6cSJohn Marino 
150*ef5ccd6cSJohn Marino   struct partial_symtab *user;
151*ef5ccd6cSJohn Marino 
152cf7f2e2dSJohn Marino   /* Global symbol list.  This list will be sorted after readin to
153cf7f2e2dSJohn Marino      improve access.  Binary search will be the usual method of
154cf7f2e2dSJohn Marino      finding a symbol within it.  globals_offset is an integer offset
155cf7f2e2dSJohn Marino      within global_psymbols[].  */
156cf7f2e2dSJohn Marino 
157cf7f2e2dSJohn Marino   int globals_offset;
158cf7f2e2dSJohn Marino   int n_global_syms;
159cf7f2e2dSJohn Marino 
160cf7f2e2dSJohn Marino   /* Static symbol list.  This list will *not* be sorted after readin;
161cf7f2e2dSJohn Marino      to find a symbol in it, exhaustive search must be used.  This is
162cf7f2e2dSJohn Marino      reasonable because searches through this list will eventually
163cf7f2e2dSJohn Marino      lead to either the read in of a files symbols for real (assumed
164cf7f2e2dSJohn Marino      to take a *lot* of time; check) or an error (and we don't care
165cf7f2e2dSJohn Marino      how long errors take).  This is an offset and size within
166cf7f2e2dSJohn Marino      static_psymbols[].  */
167cf7f2e2dSJohn Marino 
168cf7f2e2dSJohn Marino   int statics_offset;
169cf7f2e2dSJohn Marino   int n_static_syms;
170cf7f2e2dSJohn Marino 
171c50c785cSJohn Marino   /* Non-zero if the symtab corresponding to this psymtab has been
172c50c785cSJohn Marino      readin.  This is located here so that this structure packs better
173c50c785cSJohn Marino      on 64-bit systems.  */
174c50c785cSJohn Marino 
175c50c785cSJohn Marino   unsigned char readin;
176c50c785cSJohn Marino 
177a45ae5f8SJohn Marino   /* True iff objfile->psymtabs_addrmap is properly populated for this
178a45ae5f8SJohn Marino      partial_symtab.  For discontiguous overlapping psymtabs is the only usable
179a45ae5f8SJohn Marino      info in PSYMTABS_ADDRMAP.  */
180a45ae5f8SJohn Marino 
181a45ae5f8SJohn Marino   unsigned char psymtabs_addrmap_supported;
182a45ae5f8SJohn Marino 
183*ef5ccd6cSJohn Marino   /* True if the name of this partial symtab is not a source file name.  */
184*ef5ccd6cSJohn Marino 
185*ef5ccd6cSJohn Marino   unsigned char anonymous;
186*ef5ccd6cSJohn Marino 
187*ef5ccd6cSJohn Marino   /* A flag that is temporarily used when searching psymtabs.  */
188*ef5ccd6cSJohn Marino 
189*ef5ccd6cSJohn Marino   ENUM_BITFIELD (psymtab_search_status) searched_flag : 2;
190*ef5ccd6cSJohn Marino 
191cf7f2e2dSJohn Marino   /* Pointer to symtab eventually allocated for this source file, 0 if
192cf7f2e2dSJohn Marino      !readin or if we haven't looked for the symtab after it was readin.  */
193cf7f2e2dSJohn Marino 
194cf7f2e2dSJohn Marino   struct symtab *symtab;
195cf7f2e2dSJohn Marino 
196cf7f2e2dSJohn Marino   /* Pointer to function which will read in the symtab corresponding to
197cf7f2e2dSJohn Marino      this psymtab.  */
198cf7f2e2dSJohn Marino 
199*ef5ccd6cSJohn Marino   void (*read_symtab) (struct partial_symtab *, struct objfile *);
200cf7f2e2dSJohn Marino 
201cf7f2e2dSJohn Marino   /* Information that lets read_symtab() locate the part of the symbol table
202cf7f2e2dSJohn Marino      that this psymtab corresponds to.  This information is private to the
203cf7f2e2dSJohn Marino      format-dependent symbol reading routines.  For further detail examine
204cf7f2e2dSJohn Marino      the various symbol reading modules.  */
205cf7f2e2dSJohn Marino 
206cf7f2e2dSJohn Marino   void *read_symtab_private;
207cf7f2e2dSJohn Marino };
208cf7f2e2dSJohn Marino 
209*ef5ccd6cSJohn Marino extern void sort_pst_symbols (struct objfile *, struct partial_symtab *);
210cf7f2e2dSJohn Marino 
211c50c785cSJohn Marino /* Add any kind of symbol to a psymbol_allocation_list.  */
212c50c785cSJohn Marino 
213*ef5ccd6cSJohn Marino extern void add_psymbol_to_list (const char *, int,
214c50c785cSJohn Marino 				 int, domain_enum,
215c50c785cSJohn Marino 				 enum address_class,
216c50c785cSJohn Marino 				 struct psymbol_allocation_list *,
217c50c785cSJohn Marino 				 long, CORE_ADDR,
218c50c785cSJohn Marino 				 enum language, struct objfile *);
219c50c785cSJohn Marino 
220c50c785cSJohn Marino extern void init_psymbol_list (struct objfile *, int);
221c50c785cSJohn Marino 
222c50c785cSJohn Marino extern struct partial_symtab *start_psymtab_common (struct objfile *,
223c50c785cSJohn Marino 						    struct section_offsets *,
224c50c785cSJohn Marino 						    const char *, CORE_ADDR,
225c50c785cSJohn Marino 						    struct partial_symbol **,
226c50c785cSJohn Marino 						    struct partial_symbol **);
227c50c785cSJohn Marino 
228c50c785cSJohn Marino extern struct partial_symtab *allocate_psymtab (const char *,
229*ef5ccd6cSJohn Marino 						struct objfile *)
230*ef5ccd6cSJohn Marino   ATTRIBUTE_NONNULL (1);
231c50c785cSJohn Marino 
232*ef5ccd6cSJohn Marino extern void discard_psymtab (struct objfile *, struct partial_symtab *);
233*ef5ccd6cSJohn Marino 
234*ef5ccd6cSJohn Marino extern struct cleanup *make_cleanup_discard_psymtabs (struct objfile *);
235c50c785cSJohn Marino 
236cf7f2e2dSJohn Marino /* Traverse all psymtabs in one objfile.  */
237cf7f2e2dSJohn Marino 
238cf7f2e2dSJohn Marino #define	ALL_OBJFILE_PSYMTABS(objfile, p) \
239cf7f2e2dSJohn Marino     for ((p) = (objfile) -> psymtabs; (p) != NULL; (p) = (p) -> next)
240cf7f2e2dSJohn Marino 
241cf7f2e2dSJohn Marino #endif /* PSYMPRIV_H */
242