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

Side by Side Diff: gdb/minsyms.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/minsyms.h ('k') | gdb/mips-linux-nat.c » ('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 /* GDB routines for manipulating the minimal symbol tables. 1 /* GDB routines for manipulating the minimal symbol tables.
2 Copyright (C) 1992-2004, 2007-2012 Free Software Foundation, Inc. 2 Copyright (C) 1992-2004, 2007-2012 Free Software Foundation, Inc.
3 Contributed by Cygnus Support, using pieces from other GDB modules. 3 Contributed by Cygnus Support, using pieces from other GDB modules.
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 static struct msym_bunch *msym_bunch; 69 static struct msym_bunch *msym_bunch;
70 70
71 /* Number of slots filled in current bunch. */ 71 /* Number of slots filled in current bunch. */
72 72
73 static int msym_bunch_index; 73 static int msym_bunch_index;
74 74
75 /* Total number of minimal symbols recorded so far for the objfile. */ 75 /* Total number of minimal symbols recorded so far for the objfile. */
76 76
77 static int msym_count; 77 static int msym_count;
78 78
79 /* Compute a hash code based using the same criteria as `strcmp_iw'. */ 79 /* See minsyms.h. */
80 80
81 unsigned int 81 unsigned int
82 msymbol_hash_iw (const char *string) 82 msymbol_hash_iw (const char *string)
83 { 83 {
84 unsigned int hash = 0; 84 unsigned int hash = 0;
85 85
86 while (*string && *string != '(') 86 while (*string && *string != '(')
87 { 87 {
88 while (isspace (*string)) 88 while (isspace (*string))
89 ++string; 89 ++string;
90 if (*string && *string != '(') 90 if (*string && *string != '(')
91 { 91 {
92 hash = SYMBOL_HASH_NEXT (hash, *string); 92 hash = SYMBOL_HASH_NEXT (hash, *string);
93 ++string; 93 ++string;
94 } 94 }
95 } 95 }
96 return hash; 96 return hash;
97 } 97 }
98 98
99 /* Compute a hash code for a string. */ 99 /* See minsyms.h. */
100 100
101 unsigned int 101 unsigned int
102 msymbol_hash (const char *string) 102 msymbol_hash (const char *string)
103 { 103 {
104 unsigned int hash = 0; 104 unsigned int hash = 0;
105 105
106 for (; *string; ++string) 106 for (; *string; ++string)
107 hash = SYMBOL_HASH_NEXT (hash, *string); 107 hash = SYMBOL_HASH_NEXT (hash, *string);
108 return hash; 108 return hash;
109 } 109 }
110 110
111 /* Add the minimal symbol SYM to an objfile's minsym hash table, TABLE. */ 111 /* Add the minimal symbol SYM to an objfile's minsym hash table, TABLE. */
112 void 112 static void
113 add_minsym_to_hash_table (struct minimal_symbol *sym, 113 add_minsym_to_hash_table (struct minimal_symbol *sym,
114 struct minimal_symbol **table) 114 struct minimal_symbol **table)
115 { 115 {
116 if (sym->hash_next == NULL) 116 if (sym->hash_next == NULL)
117 { 117 {
118 unsigned int hash 118 unsigned int hash
119 = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE; 119 = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
120 120
121 sym->hash_next = table[hash]; 121 sym->hash_next = table[hash];
122 table[hash] = sym; 122 table[hash] = sym;
123 } 123 }
124 } 124 }
125 125
126 /* Add the minimal symbol SYM to an objfile's minsym demangled hash table, 126 /* Add the minimal symbol SYM to an objfile's minsym demangled hash table,
127 TABLE. */ 127 TABLE. */
128 static void 128 static void
129 add_minsym_to_demangled_hash_table (struct minimal_symbol *sym, 129 add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
130 struct minimal_symbol **table) 130 struct minimal_symbol **table)
131 { 131 {
132 if (sym->demangled_hash_next == NULL) 132 if (sym->demangled_hash_next == NULL)
133 { 133 {
134 unsigned int hash = msymbol_hash_iw (SYMBOL_SEARCH_NAME (sym)) 134 unsigned int hash = msymbol_hash_iw (SYMBOL_SEARCH_NAME (sym))
135 % MINIMAL_SYMBOL_HASH_SIZE; 135 % MINIMAL_SYMBOL_HASH_SIZE;
136 136
137 sym->demangled_hash_next = table[hash]; 137 sym->demangled_hash_next = table[hash];
138 table[hash] = sym; 138 table[hash] = sym;
139 } 139 }
140 } 140 }
141 141
142 /* See minsyms.h. */
142 143
143 /* Return OBJFILE where minimal symbol SYM is defined. */
144 struct objfile * 144 struct objfile *
145 msymbol_objfile (struct minimal_symbol *sym) 145 msymbol_objfile (struct minimal_symbol *sym)
146 { 146 {
147 struct objfile *objf; 147 struct objfile *objf;
148 struct minimal_symbol *tsym; 148 struct minimal_symbol *tsym;
149 149
150 unsigned int hash 150 unsigned int hash
151 = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE; 151 = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
152 152
153 for (objf = object_files; objf; objf = objf->next) 153 for (objf = object_files; objf; objf = objf->next)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (found_file_symbol) 301 if (found_file_symbol)
302 return found_file_symbol; 302 return found_file_symbol;
303 303
304 /* Symbols for shared library trampolines are next best. */ 304 /* Symbols for shared library trampolines are next best. */
305 if (trampoline_symbol) 305 if (trampoline_symbol)
306 return trampoline_symbol; 306 return trampoline_symbol;
307 307
308 return NULL; 308 return NULL;
309 } 309 }
310 310
311 /* Iterate over all the minimal symbols in the objfile OBJF which 311 /* See minsyms.h. */
312 match NAME. Both the ordinary and demangled names of each symbol
313 are considered. The caller is responsible for canonicalizing NAME,
314 should that need to be done.
315
316 For each matching symbol, CALLBACK is called with the symbol and
317 USER_DATA as arguments. */
318 312
319 void 313 void
320 iterate_over_minimal_symbols (struct objfile *objf, const char *name, 314 iterate_over_minimal_symbols (struct objfile *objf, const char *name,
321 void (*callback) (struct minimal_symbol *, 315 void (*callback) (struct minimal_symbol *,
322 void *), 316 void *),
323 void *user_data) 317 void *user_data)
324 { 318 {
325 unsigned int hash; 319 unsigned int hash;
326 struct minimal_symbol *iter; 320 struct minimal_symbol *iter;
327 int (*cmp) (const char *, const char *); 321 int (*cmp) (const char *, const char *);
(...skipping 13 matching lines...) Expand all
341 hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE; 335 hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE;
342 iter = objf->msymbol_demangled_hash[hash]; 336 iter = objf->msymbol_demangled_hash[hash];
343 while (iter) 337 while (iter)
344 { 338 {
345 if (SYMBOL_MATCHES_SEARCH_NAME (iter, name)) 339 if (SYMBOL_MATCHES_SEARCH_NAME (iter, name))
346 (*callback) (iter, user_data); 340 (*callback) (iter, user_data);
347 iter = iter->demangled_hash_next; 341 iter = iter->demangled_hash_next;
348 } 342 }
349 } 343 }
350 344
351 /* Look through all the current minimal symbol tables and find the 345 /* See minsyms.h. */
352 first minimal symbol that matches NAME and has text type. If OBJF
353 is non-NULL, limit the search to that objfile. Returns a pointer
354 to the minimal symbol that matches, or NULL if no match is found.
355
356 This function only searches the mangled (linkage) names. */
357 346
358 struct minimal_symbol * 347 struct minimal_symbol *
359 lookup_minimal_symbol_text (const char *name, struct objfile *objf) 348 lookup_minimal_symbol_text (const char *name, struct objfile *objf)
360 { 349 {
361 struct objfile *objfile; 350 struct objfile *objfile;
362 struct minimal_symbol *msymbol; 351 struct minimal_symbol *msymbol;
363 struct minimal_symbol *found_symbol = NULL; 352 struct minimal_symbol *found_symbol = NULL;
364 struct minimal_symbol *found_file_symbol = NULL; 353 struct minimal_symbol *found_file_symbol = NULL;
365 354
366 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; 355 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (found_symbol) 387 if (found_symbol)
399 return found_symbol; 388 return found_symbol;
400 389
401 /* File-local symbols are next best. */ 390 /* File-local symbols are next best. */
402 if (found_file_symbol) 391 if (found_file_symbol)
403 return found_file_symbol; 392 return found_file_symbol;
404 393
405 return NULL; 394 return NULL;
406 } 395 }
407 396
408 /* Look through all the current minimal symbol tables and find the 397 /* See minsyms.h. */
409 first minimal symbol that matches NAME and PC. If OBJF is non-NULL,
410 limit the search to that objfile. Returns a pointer to the minimal
411 symbol that matches, or NULL if no match is found. */
412 398
413 struct minimal_symbol * 399 struct minimal_symbol *
414 lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name, 400 lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name,
415 struct objfile *objf) 401 struct objfile *objf)
416 { 402 {
417 struct objfile *objfile; 403 struct objfile *objfile;
418 struct minimal_symbol *msymbol; 404 struct minimal_symbol *msymbol;
419 405
420 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; 406 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
421 407
(...skipping 11 matching lines...) Expand all
433 if (SYMBOL_VALUE_ADDRESS (msymbol) == pc 419 if (SYMBOL_VALUE_ADDRESS (msymbol) == pc
434 && strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0) 420 && strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0)
435 return msymbol; 421 return msymbol;
436 } 422 }
437 } 423 }
438 } 424 }
439 425
440 return NULL; 426 return NULL;
441 } 427 }
442 428
443 /* Look through all the current minimal symbol tables and find the 429 /* See minsyms.h. */
444 first minimal symbol that matches NAME and is a solib trampoline.
445 If OBJF is non-NULL, limit the search to that objfile. Returns a
446 pointer to the minimal symbol that matches, or NULL if no match is
447 found.
448
449 This function only searches the mangled (linkage) names. */
450 430
451 struct minimal_symbol * 431 struct minimal_symbol *
452 lookup_minimal_symbol_solib_trampoline (const char *name, 432 lookup_minimal_symbol_solib_trampoline (const char *name,
453 struct objfile *objf) 433 struct objfile *objf)
454 { 434 {
455 struct objfile *objfile; 435 struct objfile *objfile;
456 struct minimal_symbol *msymbol; 436 struct minimal_symbol *msymbol;
457 struct minimal_symbol *found_symbol = NULL; 437 struct minimal_symbol *found_symbol = NULL;
458 438
459 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; 439 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 /* NOTE: cagney/2004-01-27: This was using find_pc_mapped_section to 705 /* NOTE: cagney/2004-01-27: This was using find_pc_mapped_section to
726 force the section but that (well unless you're doing overlay 706 force the section but that (well unless you're doing overlay
727 debugging) always returns NULL making the call somewhat useless. */ 707 debugging) always returns NULL making the call somewhat useless. */
728 section = find_pc_section (pc); 708 section = find_pc_section (pc);
729 if (section == NULL) 709 if (section == NULL)
730 return NULL; 710 return NULL;
731 } 711 }
732 return lookup_minimal_symbol_by_pc_section_1 (pc, section, 0); 712 return lookup_minimal_symbol_by_pc_section_1 (pc, section, 0);
733 } 713 }
734 714
735 /* Backward compatibility: search through the minimal symbol table 715 /* See minsyms.h. */
736 for a matching PC (no section given). */
737 716
738 struct minimal_symbol * 717 struct minimal_symbol *
739 lookup_minimal_symbol_by_pc (CORE_ADDR pc) 718 lookup_minimal_symbol_by_pc (CORE_ADDR pc)
740 { 719 {
741 return lookup_minimal_symbol_by_pc_section (pc, NULL); 720 return lookup_minimal_symbol_by_pc_section (pc, NULL);
742 } 721 }
743 722
744 /* Return non-zero iff PC is in an STT_GNU_IFUNC function resolver. */ 723 /* Return non-zero iff PC is in an STT_GNU_IFUNC function resolver. */
745 724
746 int 725 int
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 stub_gnu_ifunc_resolve_addr, 776 stub_gnu_ifunc_resolve_addr,
798 stub_gnu_ifunc_resolve_name, 777 stub_gnu_ifunc_resolve_name,
799 stub_gnu_ifunc_resolver_stop, 778 stub_gnu_ifunc_resolver_stop,
800 stub_gnu_ifunc_resolver_return_stop, 779 stub_gnu_ifunc_resolver_return_stop,
801 }; 780 };
802 781
803 /* A placeholder for &elf_gnu_ifunc_fns. */ 782 /* A placeholder for &elf_gnu_ifunc_fns. */
804 783
805 const struct gnu_ifunc_fns *gnu_ifunc_fns_p = &stub_gnu_ifunc_fns; 784 const struct gnu_ifunc_fns *gnu_ifunc_fns_p = &stub_gnu_ifunc_fns;
806 785
807 /* Find the minimal symbol named NAME, and return both the minsym 786 /* See minsyms.h. */
808 struct and its objfile. This only checks the linkage name. Sets
809 *OBJFILE_P and returns the minimal symbol, if it is found. If it
810 is not found, returns NULL. */
811 787
812 struct minimal_symbol * 788 struct minimal_symbol *
813 lookup_minimal_symbol_and_objfile (const char *name, 789 lookup_minimal_symbol_and_objfile (const char *name,
814 struct objfile **objfile_p) 790 struct objfile **objfile_p)
815 { 791 {
816 struct objfile *objfile; 792 struct objfile *objfile;
817 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; 793 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
818 794
819 ALL_OBJFILES (objfile) 795 ALL_OBJFILES (objfile)
820 { 796 {
(...skipping 20 matching lines...) Expand all
841 return the leading symbol character from the main objfile. */ 817 return the leading symbol character from the main objfile. */
842 818
843 static int get_symbol_leading_char (bfd *); 819 static int get_symbol_leading_char (bfd *);
844 820
845 static int 821 static int
846 get_symbol_leading_char (bfd *abfd) 822 get_symbol_leading_char (bfd *abfd)
847 { 823 {
848 if (abfd != NULL) 824 if (abfd != NULL)
849 return bfd_get_symbol_leading_char (abfd); 825 return bfd_get_symbol_leading_char (abfd);
850 if (symfile_objfile != NULL && symfile_objfile->obfd != NULL) 826 if (symfile_objfile != NULL && symfile_objfile->obfd != NULL)

error: old chunk mismatch

OLDNEW
« no previous file with comments | « gdb/minsyms.h ('k') | gdb/mips-linux-nat.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698