Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: gdb/psymtab.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/psymtab.h ('k') | gdb/python/lib/gdb/command/explore.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
None
OLDNEW
1 /* Partial symbol tables. 1 /* Partial symbol tables.
2 2
3 Copyright (C) 2009-2012 Free Software Foundation, Inc. 3 Copyright (C) 2009-2012 Free Software Foundation, Inc.
4 4
5 This file is part of GDB. 5 This file is part of GDB.
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or 9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
(...skipping 27 matching lines...) Expand all
38 38
39 #ifndef DEV_TTY 39 #ifndef DEV_TTY
40 #define DEV_TTY "/dev/tty" 40 #define DEV_TTY "/dev/tty"
41 #endif 41 #endif
42 42
43 struct psymbol_bcache 43 struct psymbol_bcache
44 { 44 {
45 struct bcache *bcache; 45 struct bcache *bcache;
46 }; 46 };
47 47
48 /* A fast way to get from a psymtab to its symtab (after the first time). */
49 #define PSYMTAB_TO_SYMTAB(pst) \
50 ((pst) -> symtab != NULL ? (pst) -> symtab : psymtab_to_symtab (pst))
51
52 static struct partial_symbol *match_partial_symbol (struct partial_symtab *, 48 static struct partial_symbol *match_partial_symbol (struct partial_symtab *,
53 int, 49 int,
54 const char *, domain_enum, 50 const char *, domain_enum,
55 symbol_compare_ftype *, 51 symbol_compare_ftype *,
56 symbol_compare_ftype *); 52 symbol_compare_ftype *);
57 53
58 static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *, 54 static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
59 const char *, int, 55 const char *, int,
60 domain_enum); 56 domain_enum);
61 57
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 partial_map_expand_apply (struct objfile *objfile, 128 partial_map_expand_apply (struct objfile *objfile,
133 const char *name, 129 const char *name,
134 const char *full_path, 130 const char *full_path,
135 const char *real_path, 131 const char *real_path,
136 struct partial_symtab *pst, 132 struct partial_symtab *pst,
137 int (*callback) (struct symtab *, void *), 133 int (*callback) (struct symtab *, void *),
138 void *data) 134 void *data)
139 { 135 {
140 struct symtab *last_made = objfile->symtabs; 136 struct symtab *last_made = objfile->symtabs;
141 137
138 /* Shared psymtabs should never be seen here. Instead they should
139 be handled properly by the caller. */
140 gdb_assert (pst->user == NULL);
141
142 /* Don't visit already-expanded psymtabs. */ 142 /* Don't visit already-expanded psymtabs. */
143 if (pst->readin) 143 if (pst->readin)
144 return 0; 144 return 0;
145 145
146 /* This may expand more than one symtab, and we want to iterate over 146 /* This may expand more than one symtab, and we want to iterate over
147 all of them. */ 147 all of them. */
148 psymtab_to_symtab (pst); 148 psymtab_to_symtab (pst);
149 149
150 return iterate_over_some_symtabs (name, full_path, real_path, callback, data, 150 return iterate_over_some_symtabs (name, full_path, real_path, callback, data,
151 objfile->symtabs, last_made); 151 objfile->symtabs, last_made);
152 } 152 }
153 153
154 /* Implementation of the map_symtabs_matching_filename method. */ 154 /* Implementation of the map_symtabs_matching_filename method. */
155 155
156 static int 156 static int
157 partial_map_symtabs_matching_filename (struct objfile *objfile, 157 partial_map_symtabs_matching_filename (struct objfile *objfile,
158 const char *name, 158 const char *name,
159 const char *full_path, 159 const char *full_path,
160 const char *real_path, 160 const char *real_path,
161 int (*callback) (struct symtab *, 161 int (*callback) (struct symtab *,
162 void *), 162 void *),
163 void *data) 163 void *data)
164 { 164 {
165 struct partial_symtab *pst; 165 struct partial_symtab *pst;
166 const char *name_basename = lbasename (name); 166 const char *name_basename = lbasename (name);
167 int name_len = strlen (name);
168 int is_abs = IS_ABSOLUTE_PATH (name);
167 169
168 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst) 170 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
169 { 171 {
170 if (FILENAME_CMP (name, pst->filename) == 0) 172 /* We can skip shared psymtabs here, because any file name will be
173 attached to the unshared psymtab. */
174 if (pst->user != NULL)
175 continue;
176
177 /* Anonymous psymtabs don't have a file name. */
178 if (pst->anonymous)
179 continue;
180
181 if (FILENAME_CMP (name, pst->filename) == 0
182 » || (!is_abs && compare_filenames_for_search (pst->filename,
183 » » » » » » name, name_len)))
171 { 184 {
172 if (partial_map_expand_apply (objfile, name, full_path, real_path, 185 if (partial_map_expand_apply (objfile, name, full_path, real_path,
173 pst, callback, data)) 186 pst, callback, data))
174 return 1; 187 return 1;
175 } 188 }
176 189
177 /* Before we invoke realpath, which can get expensive when many 190 /* Before we invoke realpath, which can get expensive when many
178 files are involved, do a quick comparison of the basenames. */ 191 files are involved, do a quick comparison of the basenames. */
179 if (! basenames_may_differ 192 if (! basenames_may_differ
180 && FILENAME_CMP (name_basename, lbasename (pst->filename)) != 0) 193 && FILENAME_CMP (name_basename, lbasename (pst->filename)) != 0)
181 continue; 194 continue;
182 195
183 /* If the user gave us an absolute path, try to find the file in 196 /* If the user gave us an absolute path, try to find the file in
184 this symtab and use its absolute path. */ 197 this symtab and use its absolute path. */
185 if (full_path != NULL) 198 if (full_path != NULL)
186 { 199 {
187 psymtab_to_fullname (pst); 200 psymtab_to_fullname (pst);
188 if (pst->fullname != NULL 201 if (pst->fullname != NULL
189 » && FILENAME_CMP (full_path, pst->fullname) == 0) 202 » && (FILENAME_CMP (full_path, pst->fullname) == 0
203 » » || (!is_abs && compare_filenames_for_search (pst->fullname,
204 » » » » » » » name, name_len))))
190 { 205 {
191 if (partial_map_expand_apply (objfile, name, full_path, real_path, 206 if (partial_map_expand_apply (objfile, name, full_path, real_path,
192 pst, callback, data)) 207 pst, callback, data))
193 return 1; 208 return 1;
194 } 209 }
195 } 210 }
196 211
197 if (real_path != NULL) 212 if (real_path != NULL)
198 { 213 {
199 char *rp = NULL; 214 char *rp = NULL;
200 psymtab_to_fullname (pst); 215 psymtab_to_fullname (pst);
201 if (pst->fullname != NULL) 216 if (pst->fullname != NULL)
202 { 217 {
203 rp = gdb_realpath (pst->fullname); 218 rp = gdb_realpath (pst->fullname);
204 make_cleanup (xfree, rp); 219 make_cleanup (xfree, rp);
205 } 220 }
206 » if (rp != NULL && FILENAME_CMP (real_path, rp) == 0) 221 » if (rp != NULL
222 » && (FILENAME_CMP (real_path, rp) == 0
223 » » || (!is_abs && compare_filenames_for_search (real_path,
224 » » » » » » » name, name_len))))
207 { 225 {
208 if (partial_map_expand_apply (objfile, name, full_path, real_path, 226 if (partial_map_expand_apply (objfile, name, full_path, real_path,
209 pst, callback, data)) 227 pst, callback, data))
210 return 1; 228 return 1;
211 } 229 }
212 } 230 }
213 } 231 }
214 232
215 /* Now, search for a matching tail (only if name doesn't have any dirs). */
216
217 if (name_basename == name)
218 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
219 {
220 if (FILENAME_CMP (lbasename (pst->filename), name) == 0)
221 if (partial_map_expand_apply (objfile, name, full_path, real_path, pst,
222 callback, data))
223 return 1;
224 }
225
226 return 0; 233 return 0;
227 } 234 }
228 235
229 /* Find which partial symtab contains PC and SECTION starting at psymtab PST. 236 /* Find which partial symtab contains PC and SECTION starting at psymtab PST.
230 We may find a different psymtab than PST. See FIND_PC_SECT_PSYMTAB. */ 237 We may find a different psymtab than PST. See FIND_PC_SECT_PSYMTAB. */
231 238
232 static struct partial_symtab * 239 static struct partial_symtab *
233 find_pc_sect_psymtab_closer (CORE_ADDR pc, struct obj_section *section, 240 find_pc_sect_psymtab_closer (CORE_ADDR pc, struct obj_section *section,
234 struct partial_symtab *pst, 241 struct partial_symtab *pst,
235 struct minimal_symbol *msymbol) 242 struct minimal_symbol *msymbol)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 msymbol); 394 msymbol);
388 if (ps) 395 if (ps)
389 { 396 {
390 if (warn_if_readin && ps->readin) 397 if (warn_if_readin && ps->readin)
391 /* Might want to error() here (in case symtab is corrupt and 398 /* Might want to error() here (in case symtab is corrupt and
392 will cause a core dump), but maybe we can successfully 399 will cause a core dump), but maybe we can successfully
393 continue, so let's not. */ 400 continue, so let's not. */
394 warning (_("\ 401 warning (_("\
395 (Internal error: pc %s in read in psymtab, but not in symtab.)\n"), 402 (Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
396 paddress (get_objfile_arch (ps->objfile), pc)); 403 paddress (get_objfile_arch (ps->objfile), pc));
397 return PSYMTAB_TO_SYMTAB (ps); 404 psymtab_to_symtab (ps);
405 return ps->symtab;
398 } 406 }
399 return NULL; 407 return NULL;
400 } 408 }
401 409
402 /* Find which partial symbol within a psymtab matches PC and SECTION. 410 /* Find which partial symbol within a psymtab matches PC and SECTION.
403 Return 0 if none. */ 411 Return 0 if none. */
404 412
405 static struct partial_symbol * 413 static struct partial_symbol *
406 find_pc_sect_psymbol (struct partial_symtab *psymtab, CORE_ADDR pc, 414 find_pc_sect_psymbol (struct partial_symtab *psymtab, CORE_ADDR pc,
407 struct obj_section *section) 415 struct obj_section *section)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return psym; 507 return psym;
500 } 508 }
501 509
502 static struct symtab * 510 static struct symtab *
503 lookup_symbol_aux_psymtabs (struct objfile *objfile, 511 lookup_symbol_aux_psymtabs (struct objfile *objfile,
504 int block_index, const char *name, 512 int block_index, const char *name,
505 const domain_enum domain) 513 const domain_enum domain)
506 { 514 {
507 struct partial_symtab *ps; 515 struct partial_symtab *ps;
508 const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0); 516 const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
517 struct symtab *stab_best = NULL;
509 518
510 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) 519 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
511 { 520 {
512 if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain)) 521 if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain))
513 { 522 {
514 struct symbol *sym = NULL; 523 struct symbol *sym = NULL;
515 » struct symtab *stab = PSYMTAB_TO_SYMTAB (ps); 524 » struct symtab *stab = psymtab_to_symtab (ps);
516 525
517 /* Some caution must be observed with overloaded functions 526 /* Some caution must be observed with overloaded functions
518 and methods, since the psymtab will not contain any overload 527 and methods, since the psymtab will not contain any overload
519 information (but NAME might contain it). */ 528 information (but NAME might contain it). */
520 if (stab->primary) 529 if (stab->primary)
521 { 530 {
522 struct blockvector *bv = BLOCKVECTOR (stab); 531 struct blockvector *bv = BLOCKVECTOR (stab);
523 struct block *block = BLOCKVECTOR_BLOCK (bv, block_index); 532 struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
524 533
525 sym = lookup_block_symbol (block, name, domain); 534 sym = lookup_block_symbol (block, name, domain);
526 } 535 }
527 536
528 if (sym && strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0) 537 if (sym && strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0)
529 » return stab; 538 » {
539 » if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
540 » return stab;
541
542 » stab_best = stab;
543 » }
530 544
531 /* Keep looking through other psymtabs. */ 545 /* Keep looking through other psymtabs. */
532 } 546 }
533 } 547 }
534 548
535 return NULL; 549 return stab_best;
536 } 550 }
537 551
538 /* Look in PST for a symbol in DOMAIN whose name matches NAME. Search 552 /* Look in PST for a symbol in DOMAIN whose name matches NAME. Search
539 the global block of PST if GLOBAL, and otherwise the static block. 553 the global block of PST if GLOBAL, and otherwise the static block.
540 MATCH is the comparison operation that returns true iff MATCH (s, 554 MATCH is the comparison operation that returns true iff MATCH (s,
541 NAME), where s is a SYMBOL_SEARCH_NAME. If ORDERED_COMPARE is 555 NAME), where s is a SYMBOL_SEARCH_NAME. If ORDERED_COMPARE is
542 non-null, the symbols in the block are assumed to be ordered 556 non-null, the symbols in the block are assumed to be ordered
543 according to it (allowing binary search). It must be compatible 557 according to it (allowing binary search). It must be compatible
544 with MATCH. Returns the symbol, if found, and otherwise NULL. */ 558 with MATCH. Returns the symbol, if found, and otherwise NULL. */
545 559
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 return (*psym); 768 return (*psym);
755 } 769 }
756 } 770 }
757 } 771 }
758 772
759 do_cleanups (cleanup); 773 do_cleanups (cleanup);
760 return (NULL); 774 return (NULL);
761 } 775 }
762 776
763 /* Get the symbol table that corresponds to a partial_symtab. 777 /* Get the symbol table that corresponds to a partial_symtab.
764 This is fast after the first time you do it. In fact, there 778 This is fast after the first time you do it. */
765 is an even faster macro PSYMTAB_TO_SYMTAB that does the fast
766 case inline. */
767 779
768 static struct symtab * 780 static struct symtab *
769 psymtab_to_symtab (struct partial_symtab *pst) 781 psymtab_to_symtab (struct partial_symtab *pst)
770 { 782 {
783 /* If it is a shared psymtab, find an unshared psymtab that includes
784 it. Any such psymtab will do. */
785 while (pst->user != NULL)
786 pst = pst->user;
787
771 /* If it's been looked up before, return it. */ 788 /* If it's been looked up before, return it. */
772 if (pst->symtab) 789 if (pst->symtab)
773 return pst->symtab; 790 return pst->symtab;
774 791
775 /* If it has not yet been read in, read it. */ 792 /* If it has not yet been read in, read it. */
776 if (!pst->readin) 793 if (!pst->readin)
777 { 794 {
778 struct cleanup *back_to = increment_reading_symtab (); 795 struct cleanup *back_to = increment_reading_symtab ();
779 796
780 (*pst->read_symtab) (pst); 797 (*pst->read_symtab) (pst);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 853
837 if (cs_pst) 854 if (cs_pst)
838 { 855 {
839 if (cs_pst->readin) 856 if (cs_pst->readin)
840 { 857 {
841 internal_error (__FILE__, __LINE__, 858 internal_error (__FILE__, __LINE__,
842 _("select_source_symtab: " 859 _("select_source_symtab: "
843 "readin pst found and no symtabs.")); 860 "readin pst found and no symtabs."));
844 } 861 }
845 else 862 else
846 » return PSYMTAB_TO_SYMTAB (cs_pst); 863 » return psymtab_to_symtab (cs_pst);
847 } 864 }
848 return NULL; 865 return NULL;
849 } 866 }
850 867
851 static void 868 static void
852 forget_cached_source_info_partial (struct objfile *objfile) 869 forget_cached_source_info_partial (struct objfile *objfile)
853 { 870 {
854 struct partial_symtab *pst; 871 struct partial_symtab *pst;
855 872
856 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst) 873 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, pst)
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 } 970 }
954 } 971 }
955 972
956 static void 973 static void
957 dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab, 974 dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
958 struct ui_file *outfile) 975 struct ui_file *outfile)
959 { 976 {
960 struct gdbarch *gdbarch = get_objfile_arch (objfile); 977 struct gdbarch *gdbarch = get_objfile_arch (objfile);
961 int i; 978 int i;
962 979
963 fprintf_filtered (outfile, "\nPartial symtab for source file %s ", 980 if (psymtab->anonymous)
964 » » psymtab->filename); 981 {
982 fprintf_filtered (outfile, "\nAnonymous partial symtab (%s) ",
983 » » » psymtab->filename);
984 }
985 else
986 {
987 fprintf_filtered (outfile, "\nPartial symtab for source file %s ",
988 » » » psymtab->filename);
989 }
965 fprintf_filtered (outfile, "(object "); 990 fprintf_filtered (outfile, "(object ");
966 gdb_print_host_address (psymtab, outfile); 991 gdb_print_host_address (psymtab, outfile);
967 fprintf_filtered (outfile, ")\n\n"); 992 fprintf_filtered (outfile, ")\n\n");
968 fprintf_unfiltered (outfile, " Read from object file %s (", 993 fprintf_unfiltered (outfile, " Read from object file %s (",
969 objfile->name); 994 objfile->name);
970 gdb_print_host_address (objfile, outfile); 995 gdb_print_host_address (objfile, outfile);
971 fprintf_unfiltered (outfile, ")\n"); 996 fprintf_unfiltered (outfile, ")\n");
972 997
973 if (psymtab->readin) 998 if (psymtab->readin)
974 { 999 {
(...skipping 26 matching lines...) Expand all
1001 psymtab->psymtabs_addrmap_supported ? "yes" : "no"); 1026 psymtab->psymtabs_addrmap_supported ? "yes" : "no");
1002 fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", 1027 fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n",
1003 psymtab->number_of_dependencies); 1028 psymtab->number_of_dependencies);
1004 for (i = 0; i < psymtab->number_of_dependencies; i++) 1029 for (i = 0; i < psymtab->number_of_dependencies; i++)
1005 { 1030 {
1006 fprintf_filtered (outfile, " %d ", i); 1031 fprintf_filtered (outfile, " %d ", i);
1007 gdb_print_host_address (psymtab->dependencies[i], outfile); 1032 gdb_print_host_address (psymtab->dependencies[i], outfile);
1008 fprintf_filtered (outfile, " %s\n", 1033 fprintf_filtered (outfile, " %s\n",
1009 psymtab->dependencies[i]->filename); 1034 psymtab->dependencies[i]->filename);
1010 } 1035 }
1036 if (psymtab->user != NULL)
1037 {
1038 fprintf_filtered (outfile, " Shared partial symtab with user ");
1039 gdb_print_host_address (psymtab->user, outfile);
1040 fprintf_filtered (outfile, "\n");
1041 }
1011 if (psymtab->n_global_syms > 0) 1042 if (psymtab->n_global_syms > 0)
1012 { 1043 {
1013 print_partial_symbols (gdbarch, 1044 print_partial_symbols (gdbarch,
1014 objfile->global_psymbols.list 1045 objfile->global_psymbols.list
1015 + psymtab->globals_offset, 1046 + psymtab->globals_offset,
1016 psymtab->n_global_syms, "Global", outfile); 1047 psymtab->n_global_syms, "Global", outfile);
1017 } 1048 }
1018 if (psymtab->n_static_syms > 0) 1049 if (psymtab->n_static_syms > 0)
1019 { 1050 {
1020 print_partial_symbols (gdbarch, 1051 print_partial_symbols (gdbarch,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 } 1129 }
1099 } 1130 }
1100 1131
1101 static void 1132 static void
1102 read_psymtabs_with_filename (struct objfile *objfile, const char *filename) 1133 read_psymtabs_with_filename (struct objfile *objfile, const char *filename)
1103 { 1134 {
1104 struct partial_symtab *p; 1135 struct partial_symtab *p;
1105 1136
1106 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p) 1137 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, p)
1107 { 1138 {
1139 /* Anonymous psymtabs don't have a name of a source file. */
1140 if (p->anonymous)
1141 continue;
1142
1108 if (filename_cmp (filename, p->filename) == 0) 1143 if (filename_cmp (filename, p->filename) == 0)
1109 » PSYMTAB_TO_SYMTAB (p); 1144 » psymtab_to_symtab (p);
1110 } 1145 }
1111 } 1146 }
1112 1147
1113 static void 1148 static void
1114 map_symbol_filenames_psymtab (struct objfile *objfile, 1149 map_symbol_filenames_psymtab (struct objfile *objfile,
1115 symbol_filename_ftype *fun, void *data, 1150 symbol_filename_ftype *fun, void *data,
1116 int need_fullname) 1151 int need_fullname)
1117 { 1152 {
1118 struct partial_symtab *ps; 1153 struct partial_symtab *ps;
1119 1154
1120 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) 1155 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
1121 { 1156 {
1122 const char *fullname; 1157 const char *fullname;
1123 1158
1124 if (ps->readin) 1159 if (ps->readin)
1125 continue; 1160 continue;
1126 1161
1162 /* We can skip shared psymtabs here, because any file name will be
1163 attached to the unshared psymtab. */
1164 if (ps->user != NULL)
1165 continue;
1166
1167 /* Anonymous psymtabs don't have a file name. */
1168 if (ps->anonymous)
1169 continue;
1170
1127 QUIT; 1171 QUIT;
1128 if (need_fullname) 1172 if (need_fullname)
1129 fullname = psymtab_to_fullname (ps); 1173 fullname = psymtab_to_fullname (ps);
1130 else 1174 else
1131 fullname = NULL; 1175 fullname = NULL;
1132 (*fun) (ps->filename, fullname, data); 1176 (*fun) (ps->filename, fullname, data);
1133 } 1177 }
1134 } 1178 }
1135 1179
1136 int find_and_open_source (const char *filename,
1137 const char *dirname,
1138 char **fullname);
1139
1140 /* Finds the fullname that a partial_symtab represents. 1180 /* Finds the fullname that a partial_symtab represents.
1141 1181
1142 If this functions finds the fullname, it will save it in ps->fullname 1182 If this functions finds the fullname, it will save it in ps->fullname
1143 and it will also return the value. 1183 and it will also return the value.
1144 1184
1145 If this function fails to find the file that this partial_symtab represents, 1185 If this function fails to find the file that this partial_symtab represents,
1146 NULL will be returned and ps->fullname will be set to NULL. */ 1186 NULL will be returned and ps->fullname will be set to NULL. */
1147 1187
1148 static char * 1188 static char *
1149 psymtab_to_fullname (struct partial_symtab *ps) 1189 psymtab_to_fullname (struct partial_symtab *ps)
1150 { 1190 {
1151 int r; 1191 int r;
1152 1192
1153 if (!ps) 1193 if (!ps)
1154 return NULL; 1194 return NULL;
1195 if (ps->anonymous)
1196 return NULL;
1155 1197
1156 /* Use cached copy if we have it. 1198 /* Use cached copy if we have it.
1157 We rely on forget_cached_source_info being called appropriately 1199 We rely on forget_cached_source_info being called appropriately
1158 to handle cases like the file being moved. */ 1200 to handle cases like the file being moved. */
1159 if (ps->fullname) 1201 if (ps->fullname)
1160 return ps->fullname; 1202 return ps->fullname;
1161 1203
1162 r = find_and_open_source (ps->filename, ps->dirname, &ps->fullname); 1204 r = find_and_open_source (ps->filename, ps->dirname, &ps->fullname);
1163 1205
1164 if (r >= 0) 1206 if (r >= 0)
(...skipping 22 matching lines...) Expand all
1187 according to the function MATCH, call CALLBACK(BLOCK, s, DATA). 1229 according to the function MATCH, call CALLBACK(BLOCK, s, DATA).
1188 BLOCK is assumed to come from OBJFILE. Returns 1 iff CALLBACK 1230 BLOCK is assumed to come from OBJFILE. Returns 1 iff CALLBACK
1189 ever returns non-zero, and otherwise returns 0. */ 1231 ever returns non-zero, and otherwise returns 0. */
1190 1232
1191 static int 1233 static int
1192 map_block (const char *name, domain_enum namespace, struct objfile *objfile, 1234 map_block (const char *name, domain_enum namespace, struct objfile *objfile,
1193 struct block *block, 1235 struct block *block,
1194 int (*callback) (struct block *, struct symbol *, void *), 1236 int (*callback) (struct block *, struct symbol *, void *),
1195 void *data, symbol_compare_ftype *match) 1237 void *data, symbol_compare_ftype *match)
1196 { 1238 {
1197 struct dict_iterator iter; 1239 struct block_iterator iter;
1198 struct symbol *sym; 1240 struct symbol *sym;
1199 1241
1200 for (sym = dict_iter_match_first (BLOCK_DICT (block), name, match, &iter); 1242 for (sym = block_iter_match_first (block, name, match, &iter);
1201 sym != NULL; sym = dict_iter_match_next (name, match, &iter)) 1243 sym != NULL; sym = block_iter_match_next (name, match, &iter))
1202 { 1244 {
1203 if (symbol_matches_domain (SYMBOL_LANGUAGE (sym), 1245 if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
1204 SYMBOL_DOMAIN (sym), namespace)) 1246 SYMBOL_DOMAIN (sym), namespace))
1205 { 1247 {
1206 if (callback (block, sym, data)) 1248 if (callback (block, sym, data))
1207 return 1; 1249 return 1;
1208 } 1250 }
1209 } 1251 }
1210 1252
1211 return 0; 1253 return 0;
(...skipping 14 matching lines...) Expand all
1226 const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; 1268 const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
1227 struct partial_symtab *ps; 1269 struct partial_symtab *ps;
1228 1270
1229 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) 1271 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
1230 { 1272 {
1231 QUIT; 1273 QUIT;
1232 if (ps->readin 1274 if (ps->readin
1233 || match_partial_symbol (ps, global, name, namespace, match, 1275 || match_partial_symbol (ps, global, name, namespace, match,
1234 ordered_compare)) 1276 ordered_compare))
1235 { 1277 {
1236 » struct symtab *s = PSYMTAB_TO_SYMTAB (ps); 1278 » struct symtab *s = psymtab_to_symtab (ps);
1237 struct block *block; 1279 struct block *block;
1238 1280
1239 if (s == NULL || !s->primary) 1281 if (s == NULL || !s->primary)
1240 continue; 1282 continue;
1241 block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), block_kind); 1283 block = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), block_kind);
1242 if (map_block (name, namespace, objfile, block, 1284 if (map_block (name, namespace, objfile, block,
1243 callback, data, match)) 1285 callback, data, match))
1244 return; 1286 return;
1245 if (callback (block, NULL, data)) 1287 if (callback (block, NULL, data))
1246 return; 1288 return;
1247 } 1289 }
1248 } 1290 }
1249 } 1291 }
1250 1292
1293 /* A helper for expand_symtabs_matching_via_partial that handles
1294 searching included psymtabs. This returns 1 if a symbol is found,
1295 and zero otherwise. It also updates the 'searched_flag' on the
1296 various psymtabs that it searches. */
1297
1298 static int
1299 recursively_search_psymtabs (struct partial_symtab *ps,
1300 struct objfile *objfile,
1301 enum search_domain kind,
1302 int (*name_matcher) (const char *, void *),
1303 void *data)
1304 {
1305 struct partial_symbol **psym;
1306 struct partial_symbol **bound, **gbound, **sbound;
1307 int keep_going = 1;
1308 int result = PST_SEARCHED_AND_NOT_FOUND;
1309 int i;
1310
1311 if (ps->searched_flag != PST_NOT_SEARCHED)
1312 return ps->searched_flag == PST_SEARCHED_AND_FOUND;
1313
1314 /* Recurse into shared psymtabs first, because they may have already
1315 been searched, and this could save some time. */
1316 for (i = 0; i < ps->number_of_dependencies; ++i)
1317 {
1318 int r;
1319
1320 /* Skip non-shared dependencies, these are handled elsewhere. */
1321 if (ps->dependencies[i]->user == NULL)
1322 continue;
1323
1324 r = recursively_search_psymtabs (ps->dependencies[i],
1325 objfile, kind, name_matcher, data);
1326 if (r != 0)
1327 {
1328 ps->searched_flag = PST_SEARCHED_AND_FOUND;
1329 return 1;
1330 }
1331 }
1332
1333 gbound = (objfile->global_psymbols.list
1334 + ps->globals_offset + ps->n_global_syms);
1335 sbound = (objfile->static_psymbols.list
1336 + ps->statics_offset + ps->n_static_syms);
1337 bound = gbound;
1338
1339 /* Go through all of the symbols stored in a partial
1340 symtab in one loop. */
1341 psym = objfile->global_psymbols.list + ps->globals_offset;
1342 while (keep_going)
1343 {
1344 if (psym >= bound)
1345 {
1346 if (bound == gbound && ps->n_static_syms != 0)
1347 {
1348 psym = objfile->static_psymbols.list + ps->statics_offset;
1349 bound = sbound;
1350 }
1351 else
1352 keep_going = 0;
1353 continue;
1354 }
1355 else
1356 {
1357 QUIT;
1358
1359 if ((kind == ALL_DOMAIN
1360 || (kind == VARIABLES_DOMAIN
1361 && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
1362 && SYMBOL_CLASS (*psym) != LOC_BLOCK)
1363 || (kind == FUNCTIONS_DOMAIN
1364 && SYMBOL_CLASS (*psym) == LOC_BLOCK)
1365 || (kind == TYPES_DOMAIN
1366 && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))
1367 && (*name_matcher) (SYMBOL_SEARCH_NAME (*psym), data))
1368 {
1369 /* Found a match, so notify our caller. */
1370 result = PST_SEARCHED_AND_FOUND;
1371 keep_going = 0;
1372 }
1373 }
1374 psym++;
1375 }
1376
1377 ps->searched_flag = result;
1378 return result == PST_SEARCHED_AND_FOUND;
1379 }
1380
1251 static void 1381 static void
1252 expand_symtabs_matching_via_partial 1382 expand_symtabs_matching_via_partial
1253 (struct objfile *objfile, 1383 (struct objfile *objfile,
1254 int (*file_matcher) (const char *, void *), 1384 int (*file_matcher) (const char *, void *),
1255 int (*name_matcher) (const struct language_defn *, const char *, void *), 1385 int (*name_matcher) (const char *, void *),
1256 enum search_domain kind, 1386 enum search_domain kind,
1257 void *data) 1387 void *data)
1258 { 1388 {
1259 struct partial_symtab *ps; 1389 struct partial_symtab *ps;
1260 1390
1391 /* Clear the search flags. */
1261 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) 1392 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
1262 { 1393 {
1263 struct partial_symbol **psym; 1394 ps->searched_flag = PST_NOT_SEARCHED;
1264 struct partial_symbol **bound, **gbound, **sbound; 1395 }
1265 int keep_going = 1;
1266 1396
1397 ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
1398 {
1267 if (ps->readin) 1399 if (ps->readin)
1268 continue; 1400 continue;
1269 1401
1270 if (file_matcher && ! (*file_matcher) (ps->filename, data)) 1402 /* We skip shared psymtabs because file-matching doesn't apply
1403 » to them; but we search them later in the loop. */
1404 if (ps->user != NULL)
1271 continue; 1405 continue;
1272 1406
1273 gbound = objfile->global_psymbols.list 1407 if (file_matcher)
1274 » + ps->globals_offset + ps->n_global_syms; 1408 » {
1275 sbound = objfile->static_psymbols.list 1409 » if (ps->anonymous)
1276 » + ps->statics_offset + ps->n_static_syms; 1410 » continue;
1277 bound = gbound; 1411 » if (! (*file_matcher) (ps->filename, data))
1412 » continue;
1413 » }
1278 1414
1279 /* Go through all of the symbols stored in a partial 1415 if (recursively_search_psymtabs (ps, objfile, kind, name_matcher, data))
1280 » symtab in one loop. */ 1416 » psymtab_to_symtab (ps);
1281 psym = objfile->global_psymbols.list + ps->globals_offset;
1282 while (keep_going)
1283 » {
1284 » if (psym >= bound)
1285 » {
1286 » if (bound == gbound && ps->n_static_syms != 0)
1287 » » {
1288 » » psym = objfile->static_psymbols.list + ps->statics_offset;
1289 » » bound = sbound;
1290 » » }
1291 » else
1292 » » keep_going = 0;
1293 » continue;
1294 » }
1295 » else
1296 » {
1297 » QUIT;
1298
1299 » if ((kind == ALL_DOMAIN
1300 » » || (kind == VARIABLES_DOMAIN
1301 » » && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
1302 » » && SYMBOL_CLASS (*psym) != LOC_BLOCK)
1303 » » || (kind == FUNCTIONS_DOMAIN
1304 » » && SYMBOL_CLASS (*psym) == LOC_BLOCK)
1305 » » || (kind == TYPES_DOMAIN
1306 » » && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))
1307 » » && (*name_matcher) (current_language,
1308 » » » » SYMBOL_NATURAL_NAME (*psym), data))
1309 » » {
1310 » » PSYMTAB_TO_SYMTAB (ps);
1311 » » keep_going = 0;
1312 » » }
1313 » }
1314 » psym++;
1315 » }
1316 } 1417 }
1317 } 1418 }
1318 1419
1319 static int 1420 static int
1320 objfile_has_psyms (struct objfile *objfile) 1421 objfile_has_psyms (struct objfile *objfile)
1321 { 1422 {
1322 return objfile->psymtabs != NULL; 1423 return objfile->psymtabs != NULL;
1323 } 1424 }
1324 1425
1325 const struct quick_symbol_functions psym_functions = 1426 const struct quick_symbol_functions psym_functions =
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 append_psymbol_to_list (struct psymbol_allocation_list *list, 1660 append_psymbol_to_list (struct psymbol_allocation_list *list,
1560 const struct partial_symbol *psym, 1661 const struct partial_symbol *psym,
1561 struct objfile *objfile) 1662 struct objfile *objfile)
1562 { 1663 {
1563 if (list->next >= list->list + list->size) 1664 if (list->next >= list->list + list->size)
1564 extend_psymbol_list (list, objfile); 1665 extend_psymbol_list (list, objfile);
1565 *list->next++ = (struct partial_symbol *) psym; 1666 *list->next++ = (struct partial_symbol *) psym;
1566 OBJSTAT (objfile, n_psyms++); 1667 OBJSTAT (objfile, n_psyms++);
1567 } 1668 }
1568 1669

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/psymtab.h ('k') | gdb/python/lib/gdb/command/explore.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698