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

Side by Side Diff: gdb/minsyms.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 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-irix-tdep.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-2013 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.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
(...skipping 18 matching lines...) Expand all
31 information to build useful minimal symbol tables using this structure. 31 information to build useful minimal symbol tables using this structure.
32 32
33 Even when a file contains enough debugging information to build a full 33 Even when a file contains enough debugging information to build a full
34 symbol table, these minimal symbols are still useful for quickly mapping 34 symbol table, these minimal symbols are still useful for quickly mapping
35 between names and addresses, and vice versa. They are also sometimes used 35 between names and addresses, and vice versa. They are also sometimes used
36 to figure out what full symbol table entries need to be read in. */ 36 to figure out what full symbol table entries need to be read in. */
37 37
38 38
39 #include "defs.h" 39 #include "defs.h"
40 #include <ctype.h> 40 #include <ctype.h>
41 #include "gdb_string.h" 41 #include <string.h>
42 #include "symtab.h" 42 #include "symtab.h"
43 #include "bfd.h" 43 #include "bfd.h"
44 #include "filenames.h" 44 #include "filenames.h"
45 #include "symfile.h" 45 #include "symfile.h"
46 #include "objfiles.h" 46 #include "objfiles.h"
47 #include "demangle.h" 47 #include "demangle.h"
48 #include "value.h" 48 #include "value.h"
49 #include "cp-abi.h" 49 #include "cp-abi.h"
50 #include "target.h" 50 #include "target.h"
51 #include "cp-support.h" 51 #include "cp-support.h"
52 #include "language.h" 52 #include "language.h"
53 #include "cli/cli-utils.h"
53 54
54 /* Accumulate the minimal symbols for each objfile in bunches of BUNCH_SIZE. 55 /* Accumulate the minimal symbols for each objfile in bunches of BUNCH_SIZE.
55 At the end, copy them all into one newly allocated location on an objfile's 56 At the end, copy them all into one newly allocated location on an objfile's
56 symbol obstack. */ 57 symbol obstack. */
57 58
58 #define BUNCH_SIZE 127 59 #define BUNCH_SIZE 127
59 60
60 struct msym_bunch 61 struct msym_bunch
61 { 62 {
62 struct msym_bunch *next; 63 struct msym_bunch *next;
(...skipping 15 matching lines...) Expand all
78 79
79 /* See minsyms.h. */ 80 /* See minsyms.h. */
80 81
81 unsigned int 82 unsigned int
82 msymbol_hash_iw (const char *string) 83 msymbol_hash_iw (const char *string)
83 { 84 {
84 unsigned int hash = 0; 85 unsigned int hash = 0;
85 86
86 while (*string && *string != '(') 87 while (*string && *string != '(')
87 { 88 {
88 while (isspace (*string)) 89 string = skip_spaces_const (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 /* See minsyms.h. */ 99 /* See minsyms.h. */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. */
143
144 struct objfile *
145 msymbol_objfile (struct minimal_symbol *sym)
146 {
147 struct objfile *objf;
148 struct minimal_symbol *tsym;
149
150 unsigned int hash
151 = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
152
153 for (objf = object_files; objf; objf = objf->next)
154 for (tsym = objf->msymbol_hash[hash]; tsym; tsym = tsym->hash_next)
155 if (tsym == sym)
156 return objf;
157
158 /* We should always be able to find the objfile ... */
159 internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
160 }
161
162
163 /* Look through all the current minimal symbol tables and find the 142 /* Look through all the current minimal symbol tables and find the
164 first minimal symbol that matches NAME. If OBJF is non-NULL, limit 143 first minimal symbol that matches NAME. If OBJF is non-NULL, limit
165 the search to that objfile. If SFILE is non-NULL, the only file-scope 144 the search to that objfile. If SFILE is non-NULL, the only file-scope
166 symbols considered will be from that source file (global symbols are 145 symbols considered will be from that source file (global symbols are
167 still preferred). Returns a pointer to the minimal symbol that 146 still preferred). Returns a pointer to the minimal symbol that
168 matches, or NULL if no match is found. 147 matches, or NULL if no match is found.
169 148
170 Note: One instance where there may be duplicate minimal symbols with 149 Note: One instance where there may be duplicate minimal symbols with
171 the same name is when the symbol tables for a shared library and the 150 the same name is when the symbol tables for a shared library and the
172 symbol tables for an executable contain global symbols with the same 151 symbol tables for an executable contain global symbols with the same
173 names (the dynamic linker deals with the duplication). 152 names (the dynamic linker deals with the duplication).
174 153
175 It's also possible to have minimal symbols with different mangled 154 It's also possible to have minimal symbols with different mangled
176 names, but identical demangled names. For example, the GNU C++ v3 155 names, but identical demangled names. For example, the GNU C++ v3
177 ABI requires the generation of two (or perhaps three) copies of 156 ABI requires the generation of two (or perhaps three) copies of
178 constructor functions --- "in-charge", "not-in-charge", and 157 constructor functions --- "in-charge", "not-in-charge", and
179 "allocate" copies; destructors may be duplicated as well. 158 "allocate" copies; destructors may be duplicated as well.
180 Obviously, there must be distinct mangled names for each of these, 159 Obviously, there must be distinct mangled names for each of these,
181 but the demangled names are all the same: S::S or S::~S. */ 160 but the demangled names are all the same: S::S or S::~S. */
182 161
183 struct minimal_symbol * 162 static struct bound_minimal_symbol
184 lookup_minimal_symbol (const char *name, const char *sfile, 163 lookup_minimal_symbol_internal (const char *name, const char *sfile,
185 » » struct objfile *objf) 164 » » » » struct objfile *objf)
186 { 165 {
187 struct objfile *objfile; 166 struct objfile *objfile;
188 struct minimal_symbol *msymbol; 167 struct bound_minimal_symbol found_symbol = { NULL, NULL };
189 struct minimal_symbol *found_symbol = NULL; 168 struct bound_minimal_symbol found_file_symbol = { NULL, NULL };
190 struct minimal_symbol *found_file_symbol = NULL; 169 struct bound_minimal_symbol trampoline_symbol = { NULL, NULL };
191 struct minimal_symbol *trampoline_symbol = NULL;
192 170
193 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; 171 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
194 unsigned int dem_hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE; 172 unsigned int dem_hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE;
195 173
196 int needtofreename = 0; 174 int needtofreename = 0;
197 const char *modified_name; 175 const char *modified_name;
198 176
199 if (sfile != NULL) 177 if (sfile != NULL)
200 sfile = lbasename (sfile); 178 sfile = lbasename (sfile);
201 179
202 /* For C++, canonicalize the input name. */ 180 /* For C++, canonicalize the input name. */
203 modified_name = name; 181 modified_name = name;
204 if (current_language->la_language == language_cplus) 182 if (current_language->la_language == language_cplus)
205 { 183 {
206 char *cname = cp_canonicalize_string (name); 184 char *cname = cp_canonicalize_string (name);
207 185
208 if (cname) 186 if (cname)
209 { 187 {
210 modified_name = cname; 188 modified_name = cname;
211 needtofreename = 1; 189 needtofreename = 1;
212 } 190 }
213 } 191 }
214 192
215 for (objfile = object_files; 193 for (objfile = object_files;
216 objfile != NULL && found_symbol == NULL; 194 objfile != NULL && found_symbol.minsym == NULL;
217 objfile = objfile->next) 195 objfile = objfile->next)
218 { 196 {
197 struct minimal_symbol *msymbol;
198
219 if (objf == NULL || objf == objfile 199 if (objf == NULL || objf == objfile
220 || objf == objfile->separate_debug_objfile_backlink) 200 || objf == objfile->separate_debug_objfile_backlink)
221 { 201 {
222 /* Do two passes: the first over the ordinary hash table, 202 /* Do two passes: the first over the ordinary hash table,
223 and the second over the demangled hash table. */ 203 and the second over the demangled hash table. */
224 int pass; 204 int pass;
225 205
226 for (pass = 1; pass <= 2 && found_symbol == NULL; pass++) 206 for (pass = 1; pass <= 2 && found_symbol.minsym == NULL; pass++)
227 { 207 {
228 /* Select hash list according to pass. */ 208 /* Select hash list according to pass. */
229 if (pass == 1) 209 if (pass == 1)
230 msymbol = objfile->msymbol_hash[hash]; 210 msymbol = objfile->msymbol_hash[hash];
231 else 211 else
232 msymbol = objfile->msymbol_demangled_hash[dem_hash]; 212 msymbol = objfile->msymbol_demangled_hash[dem_hash];
233 213
234 while (msymbol != NULL && found_symbol == NULL) 214 while (msymbol != NULL && found_symbol.minsym == NULL)
235 { 215 {
236 int match; 216 int match;
237 217
238 if (pass == 1) 218 if (pass == 1)
239 { 219 {
240 int (*cmp) (const char *, const char *); 220 int (*cmp) (const char *, const char *);
241 221
242 cmp = (case_sensitivity == case_sensitive_on 222 cmp = (case_sensitivity == case_sensitive_on
243 ? strcmp : strcasecmp); 223 ? strcmp : strcasecmp);
244 match = cmp (SYMBOL_LINKAGE_NAME (msymbol), 224 match = cmp (SYMBOL_LINKAGE_NAME (msymbol),
245 modified_name) == 0; 225 modified_name) == 0;
246 } 226 }
247 else 227 else
248 { 228 {
249 /* The function respects CASE_SENSITIVITY. */ 229 /* The function respects CASE_SENSITIVITY. */
250 match = SYMBOL_MATCHES_SEARCH_NAME (msymbol, 230 match = SYMBOL_MATCHES_SEARCH_NAME (msymbol,
251 modified_name); 231 modified_name);
252 } 232 }
253 233
254 if (match) 234 if (match)
255 { 235 {
256 switch (MSYMBOL_TYPE (msymbol)) 236 switch (MSYMBOL_TYPE (msymbol))
257 { 237 {
258 case mst_file_text: 238 case mst_file_text:
259 case mst_file_data: 239 case mst_file_data:
260 case mst_file_bss: 240 case mst_file_bss:
261 if (sfile == NULL 241 if (sfile == NULL
262 || filename_cmp (msymbol->filename, sfile) == 0) 242 || filename_cmp (msymbol->filename, sfile) == 0)
263 found_file_symbol = msymbol; 243 » » » {
244 » » » found_file_symbol.minsym = msymbol;
245 » » » found_file_symbol.objfile = objfile;
246 » » » }
264 break; 247 break;
265 248
266 case mst_solib_trampoline: 249 case mst_solib_trampoline:
267 250
268 /* If a trampoline symbol is found, we prefer to 251 /* If a trampoline symbol is found, we prefer to
269 keep looking for the *real* symbol. If the 252 keep looking for the *real* symbol. If the
270 actual symbol is not found, then we'll use the 253 actual symbol is not found, then we'll use the
271 trampoline entry. */ 254 trampoline entry. */
272 if (trampoline_symbol == NULL) 255 if (trampoline_symbol.minsym == NULL)
273 trampoline_symbol = msymbol; 256 » » » {
257 » » » trampoline_symbol.minsym = msymbol;
258 » » » trampoline_symbol.objfile = objfile;
259 » » » }
274 break; 260 break;
275 261
276 case mst_unknown: 262 case mst_unknown:
277 default: 263 default:
278 found_symbol = msymbol; 264 found_symbol.minsym = msymbol;
265 » » » found_symbol.objfile = objfile;
279 break; 266 break;
280 } 267 }
281 } 268 }
282 269
283 /* Find the next symbol on the hash chain. */ 270 /* Find the next symbol on the hash chain. */
284 if (pass == 1) 271 if (pass == 1)
285 msymbol = msymbol->hash_next; 272 msymbol = msymbol->hash_next;
286 else 273 else
287 msymbol = msymbol->demangled_hash_next; 274 msymbol = msymbol->demangled_hash_next;
288 } 275 }
289 } 276 }
290 } 277 }
291 } 278 }
292 279
293 if (needtofreename) 280 if (needtofreename)
294 xfree ((void *) modified_name); 281 xfree ((void *) modified_name);
295 282
296 /* External symbols are best. */ 283 /* External symbols are best. */
297 if (found_symbol) 284 if (found_symbol.minsym != NULL)
298 return found_symbol; 285 return found_symbol;
299 286
300 /* File-local symbols are next best. */ 287 /* File-local symbols are next best. */
301 if (found_file_symbol) 288 if (found_file_symbol.minsym != NULL)
302 return found_file_symbol; 289 return found_file_symbol;
303 290
304 /* Symbols for shared library trampolines are next best. */ 291 /* Symbols for shared library trampolines are next best. */
305 if (trampoline_symbol) 292 return trampoline_symbol;
306 return trampoline_symbol;
307
308 return NULL;
309 } 293 }
310 294
311 /* See minsyms.h. */ 295 /* See minsyms.h. */
296
297 struct minimal_symbol *
298 lookup_minimal_symbol (const char *name, const char *sfile,
299 struct objfile *objf)
300 {
301 struct bound_minimal_symbol bms = lookup_minimal_symbol_internal (name,
302 sfile,
303 objf);
304
305 return bms.minsym;
306 }
307
308 /* See minsyms.h. */
309
310 struct bound_minimal_symbol
311 lookup_bound_minimal_symbol (const char *name)
312 {
313 return lookup_minimal_symbol_internal (name, NULL, NULL);
314 }
315
316 /* See minsyms.h. */
312 317
313 void 318 void
314 iterate_over_minimal_symbols (struct objfile *objf, const char *name, 319 iterate_over_minimal_symbols (struct objfile *objf, const char *name,
315 void (*callback) (struct minimal_symbol *, 320 void (*callback) (struct minimal_symbol *,
316 void *), 321 void *),
317 void *user_data) 322 void *user_data)
318 { 323 {
319 unsigned int hash; 324 unsigned int hash;
320 struct minimal_symbol *iter; 325 struct minimal_symbol *iter;
321 int (*cmp) (const char *, const char *); 326 int (*cmp) (const char *, const char *);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 Note that we need to look through ALL the minimal symbol tables 472 Note that we need to look through ALL the minimal symbol tables
468 before deciding on the symbol that comes closest to the specified PC. 473 before deciding on the symbol that comes closest to the specified PC.
469 This is because objfiles can overlap, for example objfile A has .text 474 This is because objfiles can overlap, for example objfile A has .text
470 at 0x100 and .data at 0x40000 and objfile B has .text at 0x234 and 475 at 0x100 and .data at 0x40000 and objfile B has .text at 0x234 and
471 .data at 0x40048. 476 .data at 0x40048.
472 477
473 If WANT_TRAMPOLINE is set, prefer mst_solib_trampoline symbols when 478 If WANT_TRAMPOLINE is set, prefer mst_solib_trampoline symbols when
474 there are text and trampoline symbols at the same address. 479 there are text and trampoline symbols at the same address.
475 Otherwise prefer mst_text symbols. */ 480 Otherwise prefer mst_text symbols. */
476 481
477 static struct minimal_symbol * 482 static struct bound_minimal_symbol
478 lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, 483 lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc,
479 struct obj_section *section, 484 struct obj_section *section,
480 int want_trampoline) 485 int want_trampoline)
481 { 486 {
482 int lo; 487 int lo;
483 int hi; 488 int hi;
484 int new; 489 int new;
485 struct objfile *objfile; 490 struct objfile *objfile;
486 struct minimal_symbol *msymbol; 491 struct minimal_symbol *msymbol;
487 struct minimal_symbol *best_symbol = NULL; 492 struct minimal_symbol *best_symbol = NULL;
493 struct objfile *best_objfile = NULL;
494 struct bound_minimal_symbol result;
488 enum minimal_symbol_type want_type, other_type; 495 enum minimal_symbol_type want_type, other_type;
489 496
490 want_type = want_trampoline ? mst_solib_trampoline : mst_text; 497 want_type = want_trampoline ? mst_solib_trampoline : mst_text;
491 other_type = want_trampoline ? mst_text : mst_solib_trampoline; 498 other_type = want_trampoline ? mst_text : mst_solib_trampoline;
492 499
493 /* We can not require the symbol found to be in section, because 500 /* We can not require the symbol found to be in section, because
494 e.g. IRIX 6.5 mdebug relies on this code returning an absolute 501 e.g. IRIX 6.5 mdebug relies on this code returning an absolute
495 symbol - but find_pc_section won't return an absolute section and 502 symbol - but find_pc_section won't return an absolute section and
496 hence the code below would skip over absolute symbols. We can 503 hence the code below would skip over absolute symbols. We can
497 still take advantage of the call to find_pc_section, though - the 504 still take advantage of the call to find_pc_section, though - the
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 hi--; 591 hi--;
585 continue; 592 continue;
586 } 593 }
587 594
588 /* If SECTION was specified, skip any symbol from 595 /* If SECTION was specified, skip any symbol from
589 wrong section. */ 596 wrong section. */
590 if (section 597 if (section
591 /* Some types of debug info, such as COFF, 598 /* Some types of debug info, such as COFF,
592 don't fill the bfd_section member, so don't 599 don't fill the bfd_section member, so don't
593 throw away symbols on those platforms. */ 600 throw away symbols on those platforms. */
594 » » && SYMBOL_OBJ_SECTION (&msymbol[hi]) != NULL 601 » » && SYMBOL_OBJ_SECTION (objfile, &msymbol[hi]) != NULL
595 && (!matching_obj_sections 602 && (!matching_obj_sections
596 » » » (SYMBOL_OBJ_SECTION (&msymbol[hi]), section))) 603 » » » (SYMBOL_OBJ_SECTION (objfile, &msymbol[hi]),
604 » » » section)))
597 { 605 {
598 hi--; 606 hi--;
599 continue; 607 continue;
600 } 608 }
601 609
602 /* If we are looking for a trampoline and this is a 610 /* If we are looking for a trampoline and this is a
603 text symbol, or the other way around, check the 611 text symbol, or the other way around, check the
604 preceding symbol too. If they are otherwise 612 preceding symbol too. If they are otherwise
605 identical prefer that one. */ 613 identical prefer that one. */
606 if (hi > 0 614 if (hi > 0
607 && MSYMBOL_TYPE (&msymbol[hi]) == other_type 615 && MSYMBOL_TYPE (&msymbol[hi]) == other_type
608 && MSYMBOL_TYPE (&msymbol[hi - 1]) == want_type 616 && MSYMBOL_TYPE (&msymbol[hi - 1]) == want_type
609 && (MSYMBOL_SIZE (&msymbol[hi]) 617 && (MSYMBOL_SIZE (&msymbol[hi])
610 == MSYMBOL_SIZE (&msymbol[hi - 1])) 618 == MSYMBOL_SIZE (&msymbol[hi - 1]))
611 && (SYMBOL_VALUE_ADDRESS (&msymbol[hi]) 619 && (SYMBOL_VALUE_ADDRESS (&msymbol[hi])
612 == SYMBOL_VALUE_ADDRESS (&msymbol[hi - 1])) 620 == SYMBOL_VALUE_ADDRESS (&msymbol[hi - 1]))
613 » » && (SYMBOL_OBJ_SECTION (&msymbol[hi]) 621 » » && (SYMBOL_OBJ_SECTION (objfile, &msymbol[hi])
614 » » » == SYMBOL_OBJ_SECTION (&msymbol[hi - 1]))) 622 » » » == SYMBOL_OBJ_SECTION (objfile, &msymbol[hi - 1])))
615 { 623 {
616 hi--; 624 hi--;
617 continue; 625 continue;
618 } 626 }
619 627
620 /* If the minimal symbol has a zero size, save it 628 /* If the minimal symbol has a zero size, save it
621 but keep scanning backwards looking for one with 629 but keep scanning backwards looking for one with
622 a non-zero size. A zero size may mean that the 630 a non-zero size. A zero size may mean that the
623 symbol isn't an object or function (e.g. a 631 symbol isn't an object or function (e.g. a
624 label), or it may just mean that the size was not 632 label), or it may just mean that the size was not
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 /* The minimal symbol indexed by hi now is the best one in this 691 /* The minimal symbol indexed by hi now is the best one in this
684 objfile's minimal symbol table. See if it is the best one 692 objfile's minimal symbol table. See if it is the best one
685 overall. */ 693 overall. */
686 694
687 if (hi >= 0 695 if (hi >= 0
688 && ((best_symbol == NULL) || 696 && ((best_symbol == NULL) ||
689 (SYMBOL_VALUE_ADDRESS (best_symbol) < 697 (SYMBOL_VALUE_ADDRESS (best_symbol) <
690 SYMBOL_VALUE_ADDRESS (&msymbol[hi])))) 698 SYMBOL_VALUE_ADDRESS (&msymbol[hi]))))
691 { 699 {
692 best_symbol = &msymbol[hi]; 700 best_symbol = &msymbol[hi];
701 best_objfile = objfile;
693 } 702 }
694 } 703 }
695 } 704 }
696 } 705 }
697 return (best_symbol); 706
707 result.minsym = best_symbol;
708 result.objfile = best_objfile;
709 return result;
698 } 710 }
699 711
700 struct minimal_symbol * 712 struct bound_minimal_symbol
701 lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, struct obj_section *section) 713 lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, struct obj_section *section)
702 { 714 {
703 if (section == NULL) 715 if (section == NULL)
704 { 716 {
705 /* NOTE: cagney/2004-01-27: This was using find_pc_mapped_section to 717 /* NOTE: cagney/2004-01-27: This was using find_pc_mapped_section to
706 force the section but that (well unless you're doing overlay 718 force the section but that (well unless you're doing overlay
707 debugging) always returns NULL making the call somewhat useless. */ 719 debugging) always returns NULL making the call somewhat useless. */
708 section = find_pc_section (pc); 720 section = find_pc_section (pc);
709 if (section == NULL) 721 if (section == NULL)
710 » return NULL; 722 » {
723 » struct bound_minimal_symbol result;
724
725 » memset (&result, 0, sizeof (result));
726 » return result;
727 » }
711 } 728 }
712 return lookup_minimal_symbol_by_pc_section_1 (pc, section, 0); 729 return lookup_minimal_symbol_by_pc_section_1 (pc, section, 0);
713 } 730 }
714 731
715 /* See minsyms.h. */ 732 /* See minsyms.h. */
716 733
717 struct minimal_symbol * 734 struct bound_minimal_symbol
718 lookup_minimal_symbol_by_pc (CORE_ADDR pc) 735 lookup_minimal_symbol_by_pc (CORE_ADDR pc)
719 { 736 {
720 return lookup_minimal_symbol_by_pc_section (pc, NULL); 737 struct obj_section *section = find_pc_section (pc);
738
739 if (section == NULL)
740 {
741 struct bound_minimal_symbol result;
742
743 memset (&result, 0, sizeof (result));
744 return result;
745 }
746 return lookup_minimal_symbol_by_pc_section_1 (pc, section, 0);
721 } 747 }
722 748
723 /* Return non-zero iff PC is in an STT_GNU_IFUNC function resolver. */ 749 /* Return non-zero iff PC is in an STT_GNU_IFUNC function resolver. */
724 750
725 int 751 int
726 in_gnu_ifunc_stub (CORE_ADDR pc) 752 in_gnu_ifunc_stub (CORE_ADDR pc)
727 { 753 {
728 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); 754 struct bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (pc);
729 755
730 return msymbol && MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc; 756 return msymbol.minsym && MSYMBOL_TYPE (msymbol.minsym) == mst_text_gnu_ifunc;
731 } 757 }
732 758
733 /* See elf_gnu_ifunc_resolve_addr for its real implementation. */ 759 /* See elf_gnu_ifunc_resolve_addr for its real implementation. */
734 760
735 static CORE_ADDR 761 static CORE_ADDR
736 stub_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc) 762 stub_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc)
737 { 763 {
738 error (_("GDB cannot resolve STT_GNU_IFUNC symbol at address %s without " 764 error (_("GDB cannot resolve STT_GNU_IFUNC symbol at address %s without "
739 "the ELF support compiled in."), 765 "the ELF support compiled in."),
740 paddress (gdbarch, pc)); 766 paddress (gdbarch, pc));
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 stub_gnu_ifunc_resolver_stop, 804 stub_gnu_ifunc_resolver_stop,
779 stub_gnu_ifunc_resolver_return_stop, 805 stub_gnu_ifunc_resolver_return_stop,
780 }; 806 };
781 807
782 /* A placeholder for &elf_gnu_ifunc_fns. */ 808 /* A placeholder for &elf_gnu_ifunc_fns. */
783 809
784 const struct gnu_ifunc_fns *gnu_ifunc_fns_p = &stub_gnu_ifunc_fns; 810 const struct gnu_ifunc_fns *gnu_ifunc_fns_p = &stub_gnu_ifunc_fns;
785 811
786 /* See minsyms.h. */ 812 /* See minsyms.h. */
787 813
788 struct minimal_symbol * 814 struct bound_minimal_symbol
789 lookup_minimal_symbol_and_objfile (const char *name, 815 lookup_minimal_symbol_and_objfile (const char *name)
790 » » » » struct objfile **objfile_p)
791 { 816 {
817 struct bound_minimal_symbol result;
792 struct objfile *objfile; 818 struct objfile *objfile;
793 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; 819 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
794 820
795 ALL_OBJFILES (objfile) 821 ALL_OBJFILES (objfile)
796 { 822 {
797 struct minimal_symbol *msym; 823 struct minimal_symbol *msym;
798 824
799 for (msym = objfile->msymbol_hash[hash]; 825 for (msym = objfile->msymbol_hash[hash];
800 msym != NULL; 826 msym != NULL;
801 msym = msym->hash_next) 827 msym = msym->hash_next)

error: old chunk mismatch

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

Powered by Google App Engine
This is Rietveld 408576698