GDB (xrefs)

/tmp/gdb-8.1/gdb/block.c
Go to the documentation of this file.
1 /* Block-related functions for the GNU debugger, GDB.
2
3 Copyright (C) 2003-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #include "defs.h"
21 #include "block.h"
22 #include "symtab.h"
23 #include "symfile.h"
24 #include "gdb_obstack.h"
25 #include "cp-support.h"
26 #include "addrmap.h"
27 #include "gdbtypes.h"
28 #include "objfiles.h"
29
30 /* This is used by struct block to store namespace-related info for
31 C++ files, namely using declarations and the current namespace in
32 scope. */
33
34 struct block_namespace_info
35 {
36 const char *scope;
37 struct using_direct *using_decl;
38 };
39
40 static void block_initialize_namespace (struct block *block,
41 struct obstack *obstack);
42
43 /* See block.h. */
44
45 struct objfile *
46 block_objfile (const struct block *block)
47 {
48 const struct global_block *global_block;
49
50 if (BLOCK_FUNCTION (block) != NULL)
51 return symbol_objfile (BLOCK_FUNCTION (block));
52
53 global_block = (struct global_block *) block_global_block (block);
54 return COMPUNIT_OBJFILE (global_block->compunit_symtab);
55 }
56
57 /* See block. */
58
59 struct gdbarch *
60 block_gdbarch (const struct block *block)
61 {
62 if (BLOCK_FUNCTION (block) != NULL)
63 return symbol_arch (BLOCK_FUNCTION (block));
64
65 return get_objfile_arch (block_objfile (block));
66 }
67
68 /* Return Nonzero if block a is lexically nested within block b,
69 or if a and b have the same pc range.
70 Return zero otherwise. */
71
72 int
73 contained_in (const struct block *a, const struct block *b)
74 {
75 if (!a || !b)
76 return 0;
77
78 do
79 {
80 if (a == b)
81 return 1;
82 /* If A is a function block, then A cannot be contained in B,
83 except if A was inlined. */
84 if (BLOCK_FUNCTION (a) != NULL && !block_inlined_p (a))
85 return 0;
86 a = BLOCK_SUPERBLOCK (a);
87 }
88 while (a != NULL);
89
90 return 0;
91 }
92
93
94 /* Return the symbol for the function which contains a specified
95 lexical block, described by a struct block BL. The return value
96 will not be an inlined function; the containing function will be
97 returned instead. */
98
99 struct symbol *
100 block_linkage_function (const struct block *bl)
101 {
102 while ((BLOCK_FUNCTION (bl) == NULL || block_inlined_p (bl))
103 && BLOCK_SUPERBLOCK (bl) != NULL)
104 bl = BLOCK_SUPERBLOCK (bl);
105
106 return BLOCK_FUNCTION (bl);
107 }
108
109 /* Return the symbol for the function which contains a specified
110 block, described by a struct block BL. The return value will be
111 the closest enclosing function, which might be an inline
112 function. */
113
114 struct symbol *
115 block_containing_function (const struct block *bl)
116 {
117 while (BLOCK_FUNCTION (bl) == NULL && BLOCK_SUPERBLOCK (bl) != NULL)
118 bl = BLOCK_SUPERBLOCK (bl);
119
120 return BLOCK_FUNCTION (bl);
121 }
122
123 /* Return one if BL represents an inlined function. */
124
125 int
126 block_inlined_p (const struct block *bl)
127 {
128 return BLOCK_FUNCTION (bl) != NULL && SYMBOL_INLINED (BLOCK_FUNCTION (bl));
129 }
130
131 /* A helper function that checks whether PC is in the blockvector BL.
132 It returns the containing block if there is one, or else NULL. */
133
134 static struct block *
135 find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc)
136 {
137 struct block *b;
138 int bot, top, half;
139
140 /* If we have an addrmap mapping code addresses to blocks, then use
141 that. */
142 if (BLOCKVECTOR_MAP (bl))
143 return (struct block *) addrmap_find (BLOCKVECTOR_MAP (bl), pc);
144
145 /* Otherwise, use binary search to find the last block that starts
146 before PC.
147 Note: GLOBAL_BLOCK is block 0, STATIC_BLOCK is block 1.
148 They both have the same START,END values.
149 Historically this code would choose STATIC_BLOCK over GLOBAL_BLOCK but the
150 fact that this choice was made was subtle, now we make it explicit. */
151 gdb_assert (BLOCKVECTOR_NBLOCKS (bl) >= 2);
152 bot = STATIC_BLOCK;
153 top = BLOCKVECTOR_NBLOCKS (bl);
154
155 while (top - bot > 1)
156 {
157 half = (top - bot + 1) >> 1;
158 b = BLOCKVECTOR_BLOCK (bl, bot + half);
159 if (BLOCK_START (b) <= pc)
160 bot += half;
161 else
162 top = bot + half;
163 }
164
165 /* Now search backward for a block that ends after PC. */
166
167 while (bot >= STATIC_BLOCK)
168 {
169 b = BLOCKVECTOR_BLOCK (bl, bot);
170 if (BLOCK_END (b) > pc)
171 return b;
172 bot--;
173 }
174
175 return NULL;
176 }
177
178 /* Return the blockvector immediately containing the innermost lexical
179 block containing the specified pc value and section, or 0 if there
180 is none. PBLOCK is a pointer to the block. If PBLOCK is NULL, we
181 don't pass this information back to the caller. */
182
183 const struct blockvector *
184 blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
185 const struct block **pblock,
186 struct compunit_symtab *cust)
187 {
188 const struct blockvector *bl;
189 struct block *b;
190
191 if (cust == NULL)
192 {
193 /* First search all symtabs for one whose file contains our pc */
194 cust = find_pc_sect_compunit_symtab (pc, section);
195 if (cust == NULL)
196 return 0;
197 }
198
199 bl = COMPUNIT_BLOCKVECTOR (cust);
200
201 /* Then search that symtab for the smallest block that wins. */
202 b = find_block_in_blockvector (bl, pc);
203 if (b == NULL)
204 return NULL;
205
206 if (pblock)
207 *pblock = b;
208 return bl;
209 }
210
211 /* Return true if the blockvector BV contains PC, false otherwise. */
212
213 int
214 blockvector_contains_pc (const struct blockvector *bv, CORE_ADDR pc)
215 {
216 return find_block_in_blockvector (bv, pc) != NULL;
217 }
218
219 /* Return call_site for specified PC in GDBARCH. PC must match exactly, it
220 must be the next instruction after call (or after tail call jump). Throw
221 NO_ENTRY_VALUE_ERROR otherwise. This function never returns NULL. */
222
223 struct call_site *
224 call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
225 {
226 struct compunit_symtab *cust;
227 void **slot = NULL;
228
229 /* -1 as tail call PC can be already after the compilation unit range. */
230 cust = find_pc_compunit_symtab (pc - 1);
231
232 if (cust != NULL && COMPUNIT_CALL_SITE_HTAB (cust) != NULL)
233 slot = htab_find_slot (COMPUNIT_CALL_SITE_HTAB (cust), &pc, NO_INSERT);
234
235 if (slot == NULL)
236 {
237 struct bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (pc);
238
239 /* DW_TAG_gnu_call_site will be missing just if GCC could not determine
240 the call target. */
241 throw_error (NO_ENTRY_VALUE_ERROR,
242 _("DW_OP_entry_value resolving cannot find "
243 "DW_TAG_call_site %s in %s"),
244 paddress (gdbarch, pc),
245 (msym.minsym == NULL ? "???"
246 : MSYMBOL_PRINT_NAME (msym.minsym)));
247 }
248
249 return (struct call_site *) *slot;
250 }
251
252 /* Return the blockvector immediately containing the innermost lexical block
253 containing the specified pc value, or 0 if there is none.
254 Backward compatibility, no section. */
255
256 const struct blockvector *
257 blockvector_for_pc (CORE_ADDR pc, const struct block **pblock)
258 {
259 return blockvector_for_pc_sect (pc, find_pc_mapped_section (pc),
260 pblock, NULL);
261 }
262
263 /* Return the innermost lexical block containing the specified pc value
264 in the specified section, or 0 if there is none. */
265
266 const struct block *
267 block_for_pc_sect (CORE_ADDR pc, struct obj_section *section)
268 {
269 const struct blockvector *bl;
270 const struct block *b;
271
272 bl = blockvector_for_pc_sect (pc, section, &b, NULL);
273 if (bl)
274 return b;
275 return 0;
276 }
277
278 /* Return the innermost lexical block containing the specified pc value,
279 or 0 if there is none. Backward compatibility, no section. */
280
281 const struct block *
282 block_for_pc (CORE_ADDR pc)
283 {
284 return block_for_pc_sect (pc, find_pc_mapped_section (pc));
285 }
286
287 /* Now come some functions designed to deal with C++ namespace issues.
288 The accessors are safe to use even in the non-C++ case. */
289
290 /* This returns the namespace that BLOCK is enclosed in, or "" if it
291 isn't enclosed in a namespace at all. This travels the chain of
292 superblocks looking for a scope, if necessary. */
293
294 const char *
295 block_scope (const struct block *block)
296 {
297 for (; block != NULL; block = BLOCK_SUPERBLOCK (block))
298 {
299 if (BLOCK_NAMESPACE (block) != NULL
300 && BLOCK_NAMESPACE (block)->scope != NULL)
301 return BLOCK_NAMESPACE (block)->scope;
302 }
303
304 return "";
305 }
306
307 /* Set BLOCK's scope member to SCOPE; if needed, allocate memory via
308 OBSTACK. (It won't make a copy of SCOPE, however, so that already
309 has to be allocated correctly.) */
310
311 void
312 block_set_scope (struct block *block, const char *scope,
313 struct obstack *obstack)
314 {
315 block_initialize_namespace (block, obstack);
316
317 BLOCK_NAMESPACE (block)->scope = scope;
318 }
319
320 /* This returns the using directives list associated with BLOCK, if
321 any. */
322
323 struct using_direct *
324 block_using (const struct block *block)
325 {
326 if (block == NULL || BLOCK_NAMESPACE (block) == NULL)
327 return NULL;
328 else
329 return BLOCK_NAMESPACE (block)->using_decl;
330 }
331
332 /* Set BLOCK's using member to USING; if needed, allocate memory via
333 OBSTACK. (It won't make a copy of USING, however, so that already
334 has to be allocated correctly.) */
335
336 void
337 block_set_using (struct block *block,
338 struct using_direct *using_decl,
339 struct obstack *obstack)
340 {
341 block_initialize_namespace (block, obstack);
342
343 BLOCK_NAMESPACE (block)->using_decl = using_decl;
344 }
345
346 /* If BLOCK_NAMESPACE (block) is NULL, allocate it via OBSTACK and
347 ititialize its members to zero. */
348
349 static void
350 block_initialize_namespace (struct block *block, struct obstack *obstack)
351 {
352 if (BLOCK_NAMESPACE (block) == NULL)
353 {
354 BLOCK_NAMESPACE (block) = XOBNEW (obstack, struct block_namespace_info);
355 BLOCK_NAMESPACE (block)->scope = NULL;
356 BLOCK_NAMESPACE (block)->using_decl = NULL;
357 }
358 }
359
360 /* Return the static block associated to BLOCK. Return NULL if block
361 is NULL or if block is a global block. */
362
363 const struct block *
364 block_static_block (const struct block *block)
365 {
366 if (block == NULL || BLOCK_SUPERBLOCK (block) == NULL)
367 return NULL;
368
369 while (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) != NULL)
370 block = BLOCK_SUPERBLOCK (block);
371
372 return block;
373 }
374
375 /* Return the static block associated to BLOCK. Return NULL if block
376 is NULL. */
377
378 const struct block *
379 block_global_block (const struct block *block)
380 {
381 if (block == NULL)
382 return NULL;
383
384 while (BLOCK_SUPERBLOCK (block) != NULL)
385 block = BLOCK_SUPERBLOCK (block);
386
387 return block;
388 }
389
390 /* Allocate a block on OBSTACK, and initialize its elements to
391 zero/NULL. This is useful for creating "dummy" blocks that don't
392 correspond to actual source files.
393
394 Warning: it sets the block's BLOCK_DICT to NULL, which isn't a
395 valid value. If you really don't want the block to have a
396 dictionary, then you should subsequently set its BLOCK_DICT to
397 dict_create_linear (obstack, NULL). */
398
399 struct block *
400 allocate_block (struct obstack *obstack)
401 {
402 struct block *bl = OBSTACK_ZALLOC (obstack, struct block);
403
404 return bl;
405 }
406
407 /* Allocate a global block. */
408
409 struct block *
410 allocate_global_block (struct obstack *obstack)
411 {
412 struct global_block *bl = OBSTACK_ZALLOC (obstack, struct global_block);
413
414 return &bl->block;
415 }
416
417 /* Set the compunit of the global block. */
418
419 void
420 set_block_compunit_symtab (struct block *block, struct compunit_symtab *cu)
421 {
422 struct global_block *gb;
423
424 gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
425 gb = (struct global_block *) block;
426 gdb_assert (gb->compunit_symtab == NULL);
427 gb->compunit_symtab = cu;
428 }
429
430 /* See block.h. */
431
432 struct dynamic_prop *
433 block_static_link (const struct block *block)
434 {
435 struct objfile *objfile = block_objfile (block);
436
437 /* Only objfile-owned blocks that materialize top function scopes can have
438 static links. */
439 if (objfile == NULL || BLOCK_FUNCTION (block) == NULL)
440 return NULL;
441
442 return (struct dynamic_prop *) objfile_lookup_static_link (objfile, block);
443 }
444
445 /* Return the compunit of the global block. */
446
447 static struct compunit_symtab *
448 get_block_compunit_symtab (const struct block *block)
449 {
450 struct global_block *gb;
451
452 gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
453 gb = (struct global_block *) block;
454 gdb_assert (gb->compunit_symtab != NULL);
455 return gb->compunit_symtab;
456 }
457
458
459
460 /* Initialize a block iterator, either to iterate over a single block,
461 or, for static and global blocks, all the included symtabs as
462 well. */
463
464 static void
465 initialize_block_iterator (const struct block *block,
466 struct block_iterator *iter)
467 {
468 enum block_enum which;
469 struct compunit_symtab *cu;
470
471 iter->idx = -1;
472
473 if (BLOCK_SUPERBLOCK (block) == NULL)
474 {
475 which = GLOBAL_BLOCK;
476 cu = get_block_compunit_symtab (block);
477 }
478 else if (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
479 {
480 which = STATIC_BLOCK;
481 cu = get_block_compunit_symtab (BLOCK_SUPERBLOCK (block));
482 }
483 else
484 {
485 iter->d.block = block;
486 /* A signal value meaning that we're iterating over a single
487 block. */
488 iter->which = FIRST_LOCAL_BLOCK;
489 return;
490 }
491
492 /* If this is an included symtab, find the canonical includer and
493 use it instead. */
494 while (cu->user != NULL)
495 cu = cu->user;
496
497 /* Putting this check here simplifies the logic of the iterator
498 functions. If there are no included symtabs, we only need to
499 search a single block, so we might as well just do that
500 directly. */
501 if (cu->includes == NULL)
502 {
503 iter->d.block = block;
504 /* A signal value meaning that we're iterating over a single
505 block. */
506 iter->which = FIRST_LOCAL_BLOCK;
507 }
508 else
509 {
510 iter->d.compunit_symtab = cu;
511 iter->which = which;
512 }
513 }
514
515 /* A helper function that finds the current compunit over whose static
516 or global block we should iterate. */
517
518 static struct compunit_symtab *
519 find_iterator_compunit_symtab (struct block_iterator *iterator)
520 {
521 if (iterator->idx == -1)
522 return iterator->d.compunit_symtab;
523 return iterator->d.compunit_symtab->includes[iterator->idx];
524 }
525
526 /* Perform a single step for a plain block iterator, iterating across
527 symbol tables as needed. Returns the next symbol, or NULL when
528 iteration is complete. */
529
530 static struct symbol *
531 block_iterator_step (struct block_iterator *iterator, int first)
532 {
533 struct symbol *sym;
534
535 gdb_assert (iterator->which != FIRST_LOCAL_BLOCK);
536
537 while (1)
538 {
539 if (first)
540 {
541 struct compunit_symtab *cust
542 = find_iterator_compunit_symtab (iterator);
543 const struct block *block;
544
545 /* Iteration is complete. */
546 if (cust == NULL)
547 return NULL;
548
549 block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
550 iterator->which);
551 sym = dict_iterator_first (BLOCK_DICT (block), &iterator->dict_iter);
552 }
553 else
554 sym = dict_iterator_next (&iterator->dict_iter);
555
556 if (sym != NULL)
557 return sym;
558
559 /* We have finished iterating the appropriate block of one
560 symtab. Now advance to the next symtab and begin iteration
561 there. */
562 ++iterator->idx;
563 first = 1;
564 }
565 }
566
567 /* See block.h. */
568
569 struct symbol *
570 block_iterator_first (const struct block *block,
571 struct block_iterator *iterator)
572 {
573 initialize_block_iterator (block, iterator);
574
575 if (iterator->which == FIRST_LOCAL_BLOCK)
576 return dict_iterator_first (block->dict, &iterator->dict_iter);
577
578 return block_iterator_step (iterator, 1);
579 }
580
581 /* See block.h. */
582
583 struct symbol *
584 block_iterator_next (struct block_iterator *iterator)
585 {
586 if (iterator->which == FIRST_LOCAL_BLOCK)
587 return dict_iterator_next (&iterator->dict_iter);
588
589 return block_iterator_step (iterator, 0);
590 }
591
592 /* Perform a single step for a "match" block iterator, iterating
593 across symbol tables as needed. Returns the next symbol, or NULL
594 when iteration is complete. */
595
596 static struct symbol *
597 block_iter_match_step (struct block_iterator *iterator,
598 const lookup_name_info &name,
599 int first)
600 {
601 struct symbol *sym;
602
603 gdb_assert (iterator->which != FIRST_LOCAL_BLOCK);
604
605 while (1)
606 {
607 if (first)
608 {
609 struct compunit_symtab *cust
610 = find_iterator_compunit_symtab (iterator);
611 const struct block *block;
612
613 /* Iteration is complete. */
614 if (cust == NULL)
615 return NULL;
616
617 block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
618 iterator->which);
619 sym = dict_iter_match_first (BLOCK_DICT (block), name,
620 &iterator->dict_iter);
621 }
622 else
623 sym = dict_iter_match_next (name, &iterator->dict_iter);
624
625 if (sym != NULL)
626 return sym;
627
628 /* We have finished iterating the appropriate block of one
629 symtab. Now advance to the next symtab and begin iteration
630 there. */
631 ++iterator->idx;
632 first = 1;
633 }
634 }
635
636 /* See block.h. */
637
638 struct symbol *
639 block_iter_match_first (const struct block *block,
640 const lookup_name_info &name,
641 struct block_iterator *iterator)
642 {
643 initialize_block_iterator (block, iterator);
644
645 if (iterator->which == FIRST_LOCAL_BLOCK)
646 return dict_iter_match_first (block->dict, name, &iterator->dict_iter);
647
648 return block_iter_match_step (iterator, name, 1);
649 }
650
651 /* See block.h. */
652
653 struct symbol *
654 block_iter_match_next (const lookup_name_info &name,
655 struct block_iterator *iterator)
656 {
657 if (iterator->which == FIRST_LOCAL_BLOCK)
658 return dict_iter_match_next (name, &iterator->dict_iter);
659
660 return block_iter_match_step (iterator, name, 0);
661 }
662
663 /* See block.h.
664
665 Note that if NAME is the demangled form of a C++ symbol, we will fail
666 to find a match during the binary search of the non-encoded names, but
667 for now we don't worry about the slight inefficiency of looking for
668 a match we'll never find, since it will go pretty quick. Once the
669 binary search terminates, we drop through and do a straight linear
670 search on the symbols. Each symbol which is marked as being a ObjC/C++
671 symbol (language_cplus or language_objc set) has both the encoded and
672 non-encoded names tested for a match. */
673
674 struct symbol *
675 block_lookup_symbol (const struct block *block, const char *name,
676 symbol_name_match_type match_type,
677 const domain_enum domain)
678 {
679 struct block_iterator iter;
680 struct symbol *sym;
681
682 lookup_name_info lookup_name (name, match_type);
683
684 if (!BLOCK_FUNCTION (block))
685 {
686 struct symbol *other = NULL;
687
688 ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
689 {
690 if (SYMBOL_DOMAIN (sym) == domain)
691 return sym;
692 /* This is a bit of a hack, but symbol_matches_domain might ignore
693 STRUCT vs VAR domain symbols. So if a matching symbol is found,
694 make sure there is no "better" matching symbol, i.e., one with
695 exactly the same domain. PR 16253. */
696 if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
697 SYMBOL_DOMAIN (sym), domain))
698 other = sym;
699 }
700 return other;
701 }
702 else
703 {
704 /* Note that parameter symbols do not always show up last in the
705 list; this loop makes sure to take anything else other than
706 parameter symbols first; it only uses parameter symbols as a
707 last resort. Note that this only takes up extra computation
708 time on a match.
709 It's hard to define types in the parameter list (at least in
710 C/C++) so we don't do the same PR 16253 hack here that is done
711 for the !BLOCK_FUNCTION case. */
712
713 struct symbol *sym_found = NULL;
714
715 ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
716 {
717 if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
718 SYMBOL_DOMAIN (sym), domain))
719 {
720 sym_found = sym;
721 if (!SYMBOL_IS_ARGUMENT (sym))
722 {
723 break;
724 }
725 }
726 }
727 return (sym_found); /* Will be NULL if not found. */
728 }
729 }
730
731 /* See block.h. */
732
733 struct symbol *
734 block_lookup_symbol_primary (const struct block *block, const char *name,
735 const domain_enum domain)
736 {
737 struct symbol *sym, *other;
738 struct dict_iterator dict_iter;
739
740 lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
741
742 /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
743 gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
744 || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
745
746 other = NULL;
747 for (sym = dict_iter_match_first (block->dict, lookup_name, &dict_iter);
748 sym != NULL;
749 sym = dict_iter_match_next (lookup_name, &dict_iter))
750 {
751 if (SYMBOL_DOMAIN (sym) == domain)
752 return sym;
753
754 /* This is a bit of a hack, but symbol_matches_domain might ignore
755 STRUCT vs VAR domain symbols. So if a matching symbol is found,
756 make sure there is no "better" matching symbol, i.e., one with
757 exactly the same domain. PR 16253. */
758 if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
759 SYMBOL_DOMAIN (sym), domain))
760 other = sym;
761 }
762
763 return other;
764 }
765
766 /* See block.h. */
767
768 struct symbol *
769 block_find_symbol (const struct block *block, const char *name,
770 const domain_enum domain,
771 block_symbol_matcher_ftype *matcher, void *data)
772 {
773 struct block_iterator iter;
774 struct symbol *sym;
775
776 lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
777
778 /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
779 gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
780 || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
781
782 ALL_BLOCK_SYMBOLS_WITH_NAME (block, lookup_name, iter, sym)
783 {
784 /* MATCHER is deliberately called second here so that it never sees
785 a non-domain-matching symbol. */
786 if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
787 SYMBOL_DOMAIN (sym), domain)
788 && matcher (sym, data))
789 return sym;
790 }
791 return NULL;
792 }
793
794 /* See block.h. */
795
796 int
797 block_find_non_opaque_type (struct symbol *sym, void *data)
798 {
799 return !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym));
800 }
801
802 /* See block.h. */
803
804 int
805 block_find_non_opaque_type_preferred (struct symbol *sym, void *data)
806 {
807 struct symbol **best = (struct symbol **) data;
808
809 if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
810 return 1;
811 *best = sym;
812 return 0;
813 }
gdbarch
Definition: gdbarch.c:127
block_iterator_next
struct symbol * block_iterator_next(struct block_iterator *iterator)
Definition: block.c:584
get_block_compunit_symtab
static struct compunit_symtab * get_block_compunit_symtab(const struct block *block)
Definition: block.c:448
dict_iter_match_next
struct symbol * dict_iter_match_next(const lookup_name_info &name, struct dict_iterator *iterator)
Definition: dictionary.c:531
block_namespace_info::scope
const char * scope
Definition: block.c:36
gdb_obstack.h
blockvector_for_pc_sect
const struct blockvector * blockvector_for_pc_sect(CORE_ADDR pc, struct obj_section *section, const struct block **pblock, struct compunit_symtab *cust)
Definition: block.c:184
call_site
Definition: gdbtypes.h:1154
global_block::compunit_symtab
struct compunit_symtab * compunit_symtab
Definition: block.h:102
block_find_non_opaque_type_preferred
int block_find_non_opaque_type_preferred(struct symbol *sym, void *data)
Definition: block.c:805
block_iterator::block
const struct block * block
Definition: block.h:205
CORE_ADDR
bfd_vma CORE_ADDR
Definition: common-types.h:41
block_containing_function
struct symbol * block_containing_function(const struct block *bl)
Definition: block.c:115
block_global_block
const struct block * block_global_block(const struct block *block)
Definition: block.c:379
block_lookup_symbol_primary
struct symbol * block_lookup_symbol_primary(const struct block *block, const char *name, const domain_enum domain)
Definition: block.c:734
block_iterator::compunit_symtab
struct compunit_symtab * compunit_symtab
Definition: block.h:204
domain_enum
enum domain_enum_tag domain_enum
TYPE_IS_OPAQUE
#define TYPE_IS_OPAQUE(thistype)
Definition: gdbtypes.h:1472
block_initialize_namespace
static void block_initialize_namespace(struct block *block, struct obstack *obstack)
Definition: block.c:350
block_linkage_function
struct symbol * block_linkage_function(const struct block *bl)
Definition: block.c:100
BLOCK_NAMESPACE
#define BLOCK_NAMESPACE(bl)
Definition: block.h:110
symbol_arch
struct gdbarch * symbol_arch(const struct symbol *symbol)
Definition: symtab.c:5793
cp-support.h
compunit_symtab
Definition: symtab.h:1380
BLOCKVECTOR_BLOCK
#define BLOCKVECTOR_BLOCK(blocklist, n)
Definition: block.h:125
dynamic_prop
Definition: gdbtypes.h:398
_
#define _(String)
Definition: gdb_locale.h:35
block_iter_match_first
struct symbol * block_iter_match_first(const struct block *block, const lookup_name_info &name, struct block_iterator *iterator)
Definition: block.c:639
defs.h
BLOCK_START
#define BLOCK_START(bl)
Definition: block.h:105
symbol_objfile
struct objfile * symbol_objfile(const struct symbol *symbol)
Definition: symtab.c:5784
block_iter_match_step
static struct symbol * block_iter_match_step(struct block_iterator *iterator, const lookup_name_info &name, int first)
Definition: block.c:597
block_for_pc
const struct block * block_for_pc(CORE_ADDR pc)
Definition: block.c:282
paddress
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:2745
objfiles.h
block::dict
struct dictionary * dict
Definition: block.h:83
BLOCK_FUNCTION
#define BLOCK_FUNCTION(bl)
Definition: block.h:107
find_pc_compunit_symtab
struct compunit_symtab * find_pc_compunit_symtab(CORE_ADDR pc)
Definition: symtab.c:2988
GLOBAL_BLOCK
Definition: defs.h:686
symtab.h
block_set_using
void block_set_using(struct block *block, struct using_direct *using_decl, struct obstack *obstack)
Definition: block.c:337
MSYMBOL_PRINT_NAME
#define MSYMBOL_PRINT_NAME(symbol)
Definition: symtab.h:708
name
const char *const name
Definition: aarch64-tdep.c:76
compunit_symtab::includes
struct compunit_symtab ** includes
Definition: symtab.h:1451
dict_iter_match_first
struct symbol * dict_iter_match_first(const struct dictionary *dict, const lookup_name_info &name, struct dict_iterator *iterator)
Definition: dictionary.c:523
block_iterator_step
static struct symbol * block_iterator_step(struct block_iterator *iterator, int first)
Definition: block.c:531
contained_in
int contained_in(const struct block *a, const struct block *b)
Definition: block.c:73
block_set_scope
void block_set_scope(struct block *block, const char *scope, struct obstack *obstack)
Definition: block.c:312
block_iter_match_next
struct symbol * block_iter_match_next(const lookup_name_info &name, struct block_iterator *iterator)
Definition: block.c:654
SYMBOL_DOMAIN
#define SYMBOL_DOMAIN(symbol)
Definition: symtab.h:1152
NO_ENTRY_VALUE_ERROR
Definition: common-exceptions.h:89
bound_minimal_symbol
Definition: minsyms.h:29
block_iterator::dict_iter
struct dict_iterator dict_iter
Definition: block.h:223
call_site::pc
CORE_ADDR pc
Definition: gdbtypes.h:1160
get_objfile_arch
struct gdbarch * get_objfile_arch(const struct objfile *objfile)
Definition: objfiles.c:445
block_using
struct using_direct * block_using(const struct block *block)
Definition: block.c:324
initialize_block_iterator
static void initialize_block_iterator(const struct block *block, struct block_iterator *iter)
Definition: block.c:465
BLOCK_SUPERBLOCK
#define BLOCK_SUPERBLOCK(bl)
Definition: block.h:108
find_iterator_compunit_symtab
static struct compunit_symtab * find_iterator_compunit_symtab(struct block_iterator *iterator)
Definition: block.c:519
using_direct
Definition: namespace.h:90
global_block::block
struct block block
Definition: block.h:98
block_iterator::idx
int idx
Definition: block.h:213
find_pc_sect_compunit_symtab
struct compunit_symtab * find_pc_sect_compunit_symtab(CORE_ADDR pc, struct obj_section *section)
Definition: symtab.c:2872
global_block
Definition: block.h:94
BLOCK_END
#define BLOCK_END(bl)
Definition: block.h:106
allocate_block
struct block * allocate_block(struct obstack *obstack)
Definition: block.c:400
block_find_non_opaque_type
int block_find_non_opaque_type(struct symbol *sym, void *data)
Definition: block.c:797
BLOCK_DICT
#define BLOCK_DICT(bl)
Definition: block.h:109
block_for_pc_sect
const struct block * block_for_pc_sect(CORE_ADDR pc, struct obj_section *section)
Definition: block.c:267
dict_iterator_next
struct symbol * dict_iterator_next(struct dict_iterator *iterator)
Definition: dictionary.c:516
objfile_lookup_static_link
const struct dynamic_prop * objfile_lookup_static_link(struct objfile *objfile, const struct block *block)
Definition: objfiles.c:282
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
block
Definition: block.h:60
dict_iterator
Definition: dictionary.h:106
block_enum
block_enum
Definition: defs.h:684
blockvector
Definition: block.h:112
addrmap.h
blockvector_contains_pc
int blockvector_contains_pc(const struct blockvector *bv, CORE_ADDR pc)
Definition: block.c:214
objfile
Definition: objfiles.h:286
block_symbol_matcher_ftype
int() block_symbol_matcher_ftype(struct symbol *, void *)
Definition: block.h:274
COMPUNIT_BLOCKVECTOR
#define COMPUNIT_BLOCKVECTOR(cust)
Definition: symtab.h:1465
block_static_link
struct dynamic_prop * block_static_link(const struct block *block)
Definition: block.c:433
obj_section
Definition: objfiles.h:123
block_inlined_p
int block_inlined_p(const struct block *bl)
Definition: block.c:126
block_find_symbol
struct symbol * block_find_symbol(const struct block *block, const char *name, const domain_enum domain, block_symbol_matcher_ftype *matcher, void *data)
Definition: block.c:769
find_pc_mapped_section
struct obj_section * find_pc_mapped_section(CORE_ADDR pc)
Definition: symfile.c:3202
lookup_minimal_symbol_by_pc
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
Definition: minsyms.c:928
block_static_block
const struct block * block_static_block(const struct block *block)
Definition: block.c:364
bound_minimal_symbol::minsym
struct minimal_symbol * minsym
Definition: minsyms.h:34
block_gdbarch
struct gdbarch * block_gdbarch(const struct block *block)
Definition: block.c:60
COMPUNIT_OBJFILE
#define COMPUNIT_OBJFILE(cust)
Definition: symtab.h:1460
SYMBOL_LANGUAGE
#define SYMBOL_LANGUAGE(symbol)
Definition: symtab.h:469
block_objfile
struct objfile * block_objfile(const struct block *block)
Definition: block.c:46
symbol_matches_domain
int symbol_matches_domain(enum language symbol_language, domain_enum symbol_domain, domain_enum domain)
Definition: symtab.c:2700
BLOCKVECTOR_NBLOCKS
#define BLOCKVECTOR_NBLOCKS(blocklist)
Definition: block.h:124
block_iterator
Definition: block.h:197
block_iterator::d
union block_iterator::@15 d
set_block_compunit_symtab
void set_block_compunit_symtab(struct block *block, struct compunit_symtab *cu)
Definition: block.c:420
find_block_in_blockvector
static struct block * find_block_in_blockvector(const struct blockvector *bl, CORE_ADDR pc)
Definition: block.c:135
gdbtypes.h
STATIC_BLOCK
Definition: defs.h:687
call_site_for_pc
struct call_site * call_site_for_pc(struct gdbarch *gdbarch, CORE_ADDR pc)
Definition: block.c:224
SYMBOL_INLINED
#define SYMBOL_INLINED(symbol)
Definition: symtab.h:1158
block_namespace_info
Definition: block.c:34
SYMBOL_TYPE
#define SYMBOL_TYPE(symbol)
Definition: symtab.h:1161
symbol
Definition: symtab.h:1049
addrmap_find
void * addrmap_find(struct addrmap *map, CORE_ADDR addr)
Definition: addrmap.c:59
BLOCKVECTOR_MAP
#define BLOCKVECTOR_MAP(blocklist)
Definition: block.h:126
block_iterator_first
struct symbol * block_iterator_first(const struct block *block, struct block_iterator *iterator)
Definition: block.c:570
OBSTACK_ZALLOC
#define OBSTACK_ZALLOC(OBSTACK, TYPE)
Definition: gdb_obstack.h:27
allocate_global_block
struct block * allocate_global_block(struct obstack *obstack)
Definition: block.c:410
ALL_BLOCK_SYMBOLS_WITH_NAME
#define ALL_BLOCK_SYMBOLS_WITH_NAME(block, name, iter, sym)
Definition: block.h:320
compunit_symtab::user
struct compunit_symtab * user
Definition: symtab.h:1457
symbol_name_match_type::FULL
block_lookup_symbol
struct symbol * block_lookup_symbol(const struct block *block, const char *name, symbol_name_match_type match_type, const domain_enum domain)
Definition: block.c:675
block_namespace_info::using_decl
struct using_direct * using_decl
Definition: block.c:37
lookup_name_info
Definition: symtab.h:179
block_iterator::which
enum block_enum which
Definition: block.h:219
blockvector_for_pc
const struct blockvector * blockvector_for_pc(CORE_ADDR pc, const struct block **pblock)
Definition: block.c:257
COMPUNIT_CALL_SITE_HTAB
#define COMPUNIT_CALL_SITE_HTAB(cust)
Definition: symtab.h:1469
block_scope
const char * block_scope(const struct block *block)
Definition: block.c:295
FIRST_LOCAL_BLOCK
Definition: defs.h:688
block.h
throw_error
void throw_error(enum errors error, const char *fmt,...)
Definition: common-exceptions.c:389
dict_iterator_first
struct symbol * dict_iterator_first(const struct dictionary *dict, struct dict_iterator *iterator)
Definition: dictionary.c:506
SYMBOL_IS_ARGUMENT
#define SYMBOL_IS_ARGUMENT(symbol)
Definition: symtab.h:1157
symfile.h
symbol_name_match_type
symbol_name_match_type
Definition: symtab.h:52
symbol::domain
__extension__ enum domain_enum_tag domain
Definition: symtab.h:1076