]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/objfiles.c
Automatic date update in version.in
[thirdparty/binutils-gdb.git] / gdb / objfiles.c
CommitLineData
c906108c 1/* GDB routines for manipulating objfiles.
af5f3db6 2
d01e8234 3 Copyright (C) 1992-2025 Free Software Foundation, Inc.
af5f3db6 4
c906108c
SS
5 Contributed by Cygnus Support, using pieces from other GDB modules.
6
c5aa993b 7 This file is part of GDB.
c906108c 8
c5aa993b
JM
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
a9762ec7 11 the Free Software Foundation; either version 3 of the License, or
c5aa993b 12 (at your option) any later version.
c906108c 13
c5aa993b
JM
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
c906108c 18
c5aa993b 19 You should have received a copy of the GNU General Public License
a9762ec7 20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c
SS
21
22/* This file contains support routines for creating, manipulating, and
0df8b418 23 destroying objfile structures. */
c906108c 24
ef0f16cc 25#include "bfd.h"
c906108c
SS
26#include "symtab.h"
27#include "symfile.h"
28#include "objfiles.h"
c906108c 29#include "target.h"
9bdcbae7
DJ
30#include "expression.h"
31#include "parser-defs.h"
32
c906108c 33#include <sys/types.h>
53ce3c39 34#include <sys/stat.h>
c906108c 35#include <fcntl.h>
bf31fd38 36#include "gdbsupport/gdb_obstack.h"
c906108c 37
7a292a7a 38#include "breakpoint.h"
fe898f56 39#include "block.h"
de4f826b 40#include "dictionary.h"
cb5d864f 41#include "source.h"
801e3a5b 42#include "addrmap.h"
5e2b427d 43#include "arch-utils.h"
30510692 44#include "exec.h"
76727919 45#include "observable.h"
6fbf07cd 46#include "complaints.h"
cbb099e8 47#include "gdb_bfd.h"
afedecd3 48#include "btrace.h"
268a13a5 49#include "gdbsupport/pathstuff.h"
7a292a7a 50
d0801dd8 51#include <algorithm>
cfe826d4 52
c906108c 53/* Externally visible variables that are owned by this module.
0df8b418 54 See declarations in objfile.h for more info. */
c906108c 55
6c95b8df
PA
56struct objfile_pspace_info
57{
f6aa7436
TT
58 objfile_pspace_info () = default;
59 ~objfile_pspace_info ();
60
61 struct obj_section **sections = nullptr;
62 int num_sections = 0;
607ece04
GB
63
64 /* Nonzero if object files have been added since the section map
65 was last updated. */
f6aa7436 66 int new_objfiles_available = 0;
607ece04
GB
67
68 /* Nonzero if the section map MUST be updated before use. */
f6aa7436 69 int section_map_dirty = 0;
607ece04
GB
70
71 /* Nonzero if section map updates should be inhibited if possible. */
f6aa7436 72 int inhibit_updates = 0;
6c95b8df
PA
73};
74
75/* Per-program-space data key. */
08b8a139 76static const registry<program_space>::key<objfile_pspace_info>
f6aa7436 77 objfiles_pspace_data;
6c95b8df 78
f6aa7436 79objfile_pspace_info::~objfile_pspace_info ()
6c95b8df 80{
f6aa7436 81 xfree (sections);
6c95b8df
PA
82}
83
84/* Get the current svr4 data. If none is found yet, add it now. This
85 function always returns a valid object. */
86
87static struct objfile_pspace_info *
88get_objfile_pspace_data (struct program_space *pspace)
89{
90 struct objfile_pspace_info *info;
91
f6aa7436 92 info = objfiles_pspace_data.get (pspace);
6c95b8df 93 if (info == NULL)
f6aa7436 94 info = objfiles_pspace_data.emplace (pspace);
6c95b8df
PA
95
96 return info;
97}
98
706e3705
TT
99\f
100
101/* Per-BFD data key. */
102
08b8a139 103static const registry<bfd>::key<objfile_per_bfd_storage> objfiles_bfd_data;
706e3705 104
d6797f46
TT
105objfile_per_bfd_storage::~objfile_per_bfd_storage ()
106{
d6797f46
TT
107}
108
706e3705
TT
109/* Create the per-BFD storage object for OBJFILE. If ABFD is not
110 NULL, and it already has a per-BFD storage object, use that.
9161c89a 111 Otherwise, allocate a new per-BFD storage object. */
706e3705 112
88c4cce8
TT
113void
114set_objfile_per_bfd (struct objfile *objfile)
706e3705 115{
88c4cce8 116 bfd *abfd = objfile->obfd.get ();
706e3705
TT
117 struct objfile_per_bfd_storage *storage = NULL;
118
119 if (abfd != NULL)
f6aa7436 120 storage = objfiles_bfd_data.get (abfd);
706e3705
TT
121
122 if (storage == NULL)
123 {
0072c873 124 storage = new objfile_per_bfd_storage (abfd);
1da77581
TT
125 /* If the object requires gdb to do relocations, we simply fall
126 back to not sharing data across users. These cases are rare
127 enough that this seems reasonable. */
128 if (abfd != NULL && !gdb_bfd_requires_relocations (abfd))
f6aa7436 129 objfiles_bfd_data.set (abfd, storage);
88c4cce8
TT
130 else
131 objfile->per_bfd_storage.reset (storage);
706e3705 132
1da77581
TT
133 /* Look up the gdbarch associated with the BFD. */
134 if (abfd != NULL)
135 storage->gdbarch = gdbarch_from_bfd (abfd);
706e3705
TT
136 }
137
88c4cce8 138 objfile->per_bfd = storage;
706e3705
TT
139}
140
3d548a53
TT
141/* Set the objfile's per-BFD notion of the "main" name and
142 language. */
143
144void
145set_objfile_main_name (struct objfile *objfile,
146 const char *name, enum language lang)
147{
148 if (objfile->per_bfd->name_of_main == NULL
149 || strcmp (objfile->per_bfd->name_of_main, name) != 0)
150 objfile->per_bfd->name_of_main
021887d8 151 = obstack_strdup (&objfile->per_bfd->storage_obstack, name);
3d548a53
TT
152 objfile->per_bfd->language_of_main = lang;
153}
154
63e43d3a
PMR
155/* Register STATIC_LINK as the static link for BLOCK, which is part of OBJFILE.
156 Must not be called more than once for each BLOCK. */
157
158void
159objfile_register_static_link (struct objfile *objfile,
160 const struct block *block,
161 const struct dynamic_prop *static_link)
162{
9f334198
SM
163 /* Enter the mapping and make sure it's the first mapping for this
164 block. */
165 bool inserted = objfile->static_links.emplace (block, static_link).second;
166 gdb_assert (inserted);
63e43d3a
PMR
167}
168
169/* Look for a static link for BLOCK, which is part of OBJFILE. Return NULL if
170 none was found. */
171
172const struct dynamic_prop *
173objfile_lookup_static_link (struct objfile *objfile,
174 const struct block *block)
175{
9f334198
SM
176 if (auto iter = objfile->static_links.find (block);
177 iter != objfile->static_links.end ())
178 return iter->second;
179
180 return nullptr;
63e43d3a
PMR
181}
182
706e3705
TT
183\f
184
cb814f2e
TT
185/* Build up the section table that the objfile references. The
186 objfile contains pointers to the start of the table
187 (objfile->sections) and to the first location after the end of the
188 table (objfile->sections_end). */
96baa820 189
65cf3563 190static void
cb814f2e 191add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
65cf3563
TT
192 struct objfile *objfile, int force)
193{
194 struct obj_section *section;
195
196 if (!force)
197 {
198 flagword aflag;
199
fd361982 200 aflag = bfd_section_flags (asect);
65cf3563
TT
201 if (!(aflag & SEC_ALLOC))
202 return;
203 }
204
9ed8433a 205 section = &objfile->sections_start[gdb_bfd_section_index (abfd, asect)];
65cf3563
TT
206 section->objfile = objfile;
207 section->the_bfd_section = asect;
208 section->ovly_mapped = 0;
209}
210
c906108c 211/* Builds a section table for OBJFILE.
96baa820 212
65cf3563
TT
213 Note that the OFFSET and OVLY_MAPPED in each table entry are
214 initialized to zero. */
c906108c 215
d82ea6a8 216void
fba45db2 217build_objfile_section_table (struct objfile *objfile)
c906108c 218{
98badbfd 219 int count = gdb_bfd_count_sections (objfile->obfd.get ());
65cf3563 220
9ed8433a
TT
221 objfile->sections_start = OBSTACK_CALLOC (&objfile->objfile_obstack,
222 count,
223 struct obj_section);
224 objfile->sections_end = (objfile->sections_start + count);
cb814f2e 225 for (asection *sect : gdb_bfd_sections (objfile->obfd))
98badbfd 226 add_to_objfile_sections (objfile->obfd.get (), sect, objfile, 0);
65cf3563
TT
227
228 /* See gdb_bfd_section_index. */
98badbfd
TT
229 add_to_objfile_sections (objfile->obfd.get (), bfd_com_section_ptr,
230 objfile, 1);
231 add_to_objfile_sections (objfile->obfd.get (), bfd_und_section_ptr,
232 objfile, 1);
233 add_to_objfile_sections (objfile->obfd.get (), bfd_abs_section_ptr,
234 objfile, 1);
235 add_to_objfile_sections (objfile->obfd.get (), bfd_ind_section_ptr,
236 objfile, 1);
c906108c
SS
237}
238
9e86da07
TT
239/* Given a pointer to an initialized bfd (ABFD) and some flag bits,
240 initialize the new objfile as best we can and link it into the list
241 of all known objfiles.
c906108c 242
24ba069a
JK
243 NAME should contain original non-canonicalized filename or other
244 identifier as entered by user. If there is no better source use
245 bfd_get_filename (ABFD). NAME may be NULL only if ABFD is NULL.
246 NAME content is copied into returned objfile.
247
2df3850c 248 The FLAGS word contains various bits (OBJF_*) that can be taken as
78a4a9b9 249 requests for specific operations. Other bits like OBJF_SHARED are
0df8b418 250 simply copied through to the new objfile flags member. */
c906108c 251
da877546
SM
252objfile::objfile (gdb_bfd_ref_ptr bfd_, program_space *pspace,
253 const char *name, objfile_flags flags_)
9e86da07 254 : flags (flags_),
da877546 255 m_pspace (pspace),
98badbfd 256 obfd (std::move (bfd_))
c906108c 257{
14278e1f 258 const char *expanded_name;
c906108c 259
7ab2607f 260 std::string name_holder;
24ba069a
JK
261 if (name == NULL)
262 {
98badbfd 263 gdb_assert (obfd == nullptr);
40135bb1 264 gdb_assert ((flags & OBJF_NOT_FILENAME) != 0);
e3e41d58 265 expanded_name = "<<anonymous objfile>>";
24ba069a 266 }
5fbae7d1
GB
267 else if ((flags & OBJF_NOT_FILENAME) != 0
268 || is_target_filename (name))
e3e41d58 269 expanded_name = name;
04affae3 270 else
e3e41d58
TT
271 {
272 name_holder = gdb_abspath (name);
7ab2607f 273 expanded_name = name_holder.c_str ();
e3e41d58 274 }
021887d8 275 original_name = obstack_strdup (&objfile_obstack, expanded_name);
04affae3 276
d3e81981
DE
277 /* Update the per-objfile information that comes from the bfd, ensuring
278 that any data that is reference is saved in the per-objfile data
279 region. */
280
98badbfd 281 if (obfd != nullptr)
c906108c 282 {
a357defd 283 mtime = gdb_bfd_get_mtime (obfd.get ());
c906108c
SS
284
285 /* Build section table. */
9e86da07 286 build_objfile_section_table (this);
c906108c
SS
287 }
288
88c4cce8 289 set_objfile_per_bfd (this);
c906108c
SS
290}
291
b7513ebd 292/* See objfiles.h. */
9ab9195f 293
abd0a5fa 294int
b7513ebd 295entry_point_address_query (program_space *pspace, CORE_ADDR *entry_p)
9ab9195f 296{
b7513ebd 297 objfile *objf = pspace->symfile_object_file;
a42d7dd8 298 if (objf == NULL || !objf->per_bfd->ei.entry_point_p)
3612b192
DJ
299 return 0;
300
a42d7dd8
TT
301 int idx = objf->per_bfd->ei.the_bfd_section_index;
302 *entry_p = objf->per_bfd->ei.entry_point + objf->section_offsets[idx];
3612b192 303
abd0a5fa
JK
304 return 1;
305}
306
d1e4438f 307/* See objfiles.h. */
abd0a5fa
JK
308
309CORE_ADDR
d1e4438f 310entry_point_address (program_space *pspace)
abd0a5fa
JK
311{
312 CORE_ADDR retval;
313
d1e4438f 314 if (!entry_point_address_query (pspace, &retval))
abd0a5fa
JK
315 error (_("Entry point address is not known."));
316
317 return retval;
9ab9195f 318}
15831452 319
e9ad22ee
TT
320separate_debug_iterator &
321separate_debug_iterator::operator++ ()
15d123c9 322{
e9ad22ee
TT
323 gdb_assert (m_objfile != nullptr);
324
15d123c9
TG
325 struct objfile *res;
326
399f313b 327 /* If any, return the first child. */
e9ad22ee
TT
328 res = m_objfile->separate_debug_objfile;
329 if (res != nullptr)
330 {
331 m_objfile = res;
332 return *this;
333 }
15d123c9 334
15d123c9 335 /* Common case where there is no separate debug objfile. */
e9ad22ee
TT
336 if (m_objfile == m_parent)
337 {
338 m_objfile = nullptr;
339 return *this;
340 }
15d123c9 341
399f313b
TG
342 /* Return the brother if any. Note that we don't iterate on brothers of
343 the parents. */
e9ad22ee
TT
344 res = m_objfile->separate_debug_objfile_link;
345 if (res != nullptr)
346 {
347 m_objfile = res;
348 return *this;
349 }
399f313b 350
e9ad22ee
TT
351 for (res = m_objfile->separate_debug_objfile_backlink;
352 res != m_parent;
15d123c9
TG
353 res = res->separate_debug_objfile_backlink)
354 {
e9ad22ee
TT
355 gdb_assert (res != nullptr);
356 if (res->separate_debug_objfile_link != nullptr)
357 {
358 m_objfile = res->separate_debug_objfile_link;
359 return *this;
360 }
15d123c9 361 }
e9ad22ee
TT
362 m_objfile = nullptr;
363 return *this;
15d123c9 364}
15831452 365
15d123c9
TG
366/* Add OBJFILE as a separate debug objfile of PARENT. */
367
f65fe570 368static void
15d123c9
TG
369add_separate_debug_objfile (struct objfile *objfile, struct objfile *parent)
370{
371 gdb_assert (objfile && parent);
372
373 /* Must not be already in a list. */
374 gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
375 gdb_assert (objfile->separate_debug_objfile_link == NULL);
8a92335b
JK
376 gdb_assert (objfile->separate_debug_objfile == NULL);
377 gdb_assert (parent->separate_debug_objfile_backlink == NULL);
378 gdb_assert (parent->separate_debug_objfile_link == NULL);
15d123c9
TG
379
380 objfile->separate_debug_objfile_backlink = parent;
381 objfile->separate_debug_objfile_link = parent->separate_debug_objfile;
382 parent->separate_debug_objfile = objfile;
15d123c9
TG
383}
384
f65fe570
TT
385/* See objfiles.h. */
386
387objfile *
8991986e
SM
388objfile::make (gdb_bfd_ref_ptr bfd_, program_space *pspace, const char *name_,
389 objfile_flags flags_, objfile *parent)
f65fe570 390{
137f38de 391 objfile *result = new objfile (std::move (bfd_), pspace, name_, flags_);
f65fe570
TT
392 if (parent != nullptr)
393 add_separate_debug_objfile (result, parent);
7cac64af 394
137f38de 395 pspace->add_objfile (std::unique_ptr<objfile> (result), parent);
7cac64af
TT
396
397 /* Rebuild section map next time we need it. */
137f38de 398 get_objfile_pspace_data (pspace)->new_objfiles_available = 1;
7cac64af 399
f65fe570
TT
400 return result;
401}
402
268e4f09
TT
403/* See objfiles.h. */
404
405void
406objfile::unlink ()
407{
93016848 408 this->pspace ()->remove_objfile (this);
268e4f09
TT
409}
410
15d123c9
TG
411/* Free all separate debug objfile of OBJFILE, but don't free OBJFILE
412 itself. */
413
414void
415free_objfile_separate_debug (struct objfile *objfile)
416{
417 struct objfile *child;
418
419 for (child = objfile->separate_debug_objfile; child;)
420 {
421 struct objfile *next_child = child->separate_debug_objfile_link;
268e4f09 422 child->unlink ();
15d123c9
TG
423 child = next_child;
424 }
425}
c906108c 426
7580e917 427/* Destroy an objfile and all the symtabs and psymtabs under it. */
c906108c 428
9e86da07 429objfile::~objfile ()
c906108c 430{
63644780 431 /* First notify observers that this objfile is about to be freed. */
76727919 432 gdb::observers::free_objfile.notify (this);
63644780 433
15d123c9 434 /* Free all separate debug objfiles. */
9e86da07 435 free_objfile_separate_debug (this);
15d123c9 436
9e86da07 437 if (separate_debug_objfile_backlink)
5b5d99cf
JB
438 {
439 /* We freed the separate debug file, make sure the base objfile
440 doesn't reference it. */
15d123c9
TG
441 struct objfile *child;
442
9e86da07 443 child = separate_debug_objfile_backlink->separate_debug_objfile;
15d123c9 444
9e86da07 445 if (child == this)
dda83cd7
SM
446 {
447 /* THIS is the first child. */
448 separate_debug_objfile_backlink->separate_debug_objfile =
449 separate_debug_objfile_link;
450 }
15d123c9 451 else
dda83cd7
SM
452 {
453 /* Find THIS in the list. */
454 while (1)
455 {
456 if (child->separate_debug_objfile_link == this)
457 {
458 child->separate_debug_objfile_link =
459 separate_debug_objfile_link;
460 break;
461 }
462 child = child->separate_debug_objfile_link;
463 gdb_assert (child);
464 }
465 }
5b5d99cf 466 }
9e86da07 467
ae5a43e0
DJ
468 /* Remove any references to this objfile in the global value
469 lists. */
9e86da07 470 preserve_values (this);
ae5a43e0 471
9f743ef6
JK
472 /* It still may reference data modules have associated with the objfile and
473 the symbol file data. */
21f6be77 474 forget_cached_source_info ();
4122e647
TT
475 for (compunit_symtab *cu : compunits ())
476 cu->finalize ();
9f743ef6 477
9e86da07
TT
478 breakpoint_free_objfile (this);
479 btrace_free_objfile (this);
2f202fde 480
c906108c
SS
481 /* First do any symbol file specific actions required when we are
482 finished with a particular symbol file. Note that if the objfile
483 is using reusable symbol information (via mmalloc) then each of
484 these routines is responsible for doing the correct thing, either
485 freeing things which are valid only during this particular gdb
0df8b418 486 execution, or leaving them to be reused during the next one. */
c906108c 487
9e86da07
TT
488 if (sf != NULL)
489 (*sf->sym_finish) (this);
c906108c 490
c906108c
SS
491 /* Before the symbol table code was redone to make it easier to
492 selectively load and remove information particular to a specific
493 linkage unit, gdb used to do these things whenever the monolithic
494 symbol table was blown away. How much still needs to be done
495 is unknown, but we play it safe for now and keep each action until
0df8b418 496 it is shown to be no longer needed. */
c5aa993b 497
cb5d864f
FF
498 /* Not all our callers call clear_symtab_users (objfile_purge_solibs,
499 for example), so we need to call this here. */
c906108c
SS
500 clear_pc_function_cache ();
501
cb5d864f 502 /* Check to see if the current_source_symtab belongs to this objfile,
0df8b418 503 and if so, call clear_current_source_symtab_and_line. */
5a43f7f0 504 clear_current_source_symtab_and_line (this);
cb5d864f 505
6c95b8df 506 /* Rebuild section map next time we need it. */
5a43f7f0
TV
507 auto info = objfiles_pspace_data.get (pspace ());
508 if (info != nullptr)
509 info->section_map_dirty = 1;
c906108c
SS
510}
511
c906108c 512\f
34eaf542
TT
513/* A helper function for objfile_relocate1 that relocates a single
514 symbol. */
515
516static void
517relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
6a053cb1 518 const section_offsets &delta)
34eaf542 519{
34eaf542
TT
520 /* The RS6000 code from which this was taken skipped
521 any symbols in STRUCT_DOMAIN or UNDEF_DOMAIN.
522 But I'm leaving out that test, on the theory that
523 they can't possibly pass the tests below. */
66d7f48f
SM
524 if ((sym->aclass () == LOC_LABEL
525 || sym->aclass () == LOC_STATIC)
a52d653e 526 && sym->section_index () >= 0)
4aeddc50
SM
527 sym->set_value_address (sym->value_address ()
528 + delta[sym->section_index ()]);
34eaf542
TT
529}
530
c906108c 531/* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS
b260e109
JK
532 entries in new_offsets. SEPARATE_DEBUG_OBJFILE is not touched here.
533 Return non-zero iff any change happened. */
567995e1 534
b260e109 535static int
5cc80db3 536objfile_relocate1 (struct objfile *objfile,
6a053cb1 537 const section_offsets &new_offsets)
c906108c 538{
6a053cb1 539 section_offsets delta (objfile->section_offsets.size ());
c906108c 540
5cc80db3
MS
541 int something_changed = 0;
542
6a053cb1 543 for (int i = 0; i < objfile->section_offsets.size (); ++i)
5cc80db3 544 {
6a053cb1
TT
545 delta[i] = new_offsets[i] - objfile->section_offsets[i];
546 if (delta[i] != 0)
5cc80db3
MS
547 something_changed = 1;
548 }
549 if (!something_changed)
550 return 0;
c906108c
SS
551
552 /* OK, get all the symtabs. */
82c5090c
TT
553 for (compunit_symtab *cust : objfile->compunits ())
554 {
555 struct blockvector *bv = cust->blockvector ();
556 int block_line_section = SECT_OFF_TEXT (objfile);
c906108c 557
82c5090c
TT
558 if (bv->map () != nullptr)
559 bv->map ()->relocate (delta[block_line_section]);
34eaf542 560
82c5090c
TT
561 for (block *b : bv->blocks ())
562 {
82c5090c
TT
563 b->set_start (b->start () + delta[block_line_section]);
564 b->set_end (b->end () + delta[block_line_section]);
5cc80db3 565
82c5090c
TT
566 for (blockrange &r : b->ranges ())
567 {
568 r.set_start (r.start () + delta[block_line_section]);
569 r.set_end (r.end () + delta[block_line_section]);
570 }
571
572 /* We only want to iterate over the local symbols, not any
573 symbols in included symtabs. */
8e8d48f9
TT
574 for (struct symbol *sym : b->multidict_symbols ())
575 relocate_one_symbol (sym, objfile, delta);
82c5090c
TT
576 }
577 }
578
579 /* Relocate isolated symbols. */
580 for (symbol *iter = objfile->template_symbols; iter; iter = iter->hash_next)
581 relocate_one_symbol (iter, objfile, delta);
582
583 for (int i = 0; i < objfile->section_offsets.size (); ++i)
584 objfile->section_offsets[i] = new_offsets[i];
f1f2b5f4
PA
585
586 /* Rebuild section map next time we need it. */
134a0a10 587 get_objfile_pspace_data (objfile->pspace ())->section_map_dirty = 1;
f1f2b5f4 588
30510692 589 /* Update the table in exec_ops, used to read memory. */
5250cbc8 590 for (obj_section *s : objfile->sections ())
30510692 591 {
9ed8433a 592 int idx = s - objfile->sections_start;
30510692 593
98badbfd 594 exec_set_section_address (bfd_get_filename (objfile->obfd.get ()), idx,
0c1bcd23 595 s->addr ());
30510692 596 }
b260e109
JK
597
598 /* Data changed. */
599 return 1;
567995e1
JK
600}
601
602/* Relocate OBJFILE to NEW_OFFSETS. There should be OBJFILE->NUM_SECTIONS
603 entries in new_offsets. Process also OBJFILE's SEPARATE_DEBUG_OBJFILEs.
604
605 The number and ordering of sections does differ between the two objfiles.
606 Only their names match. Also the file offsets will differ (objfile being
607 possibly prelinked but separate_debug_objfile is probably not prelinked) but
608 the in-memory absolute address as specified by NEW_OFFSETS must match both
609 files. */
610
611void
3189cb12 612objfile_relocate (struct objfile *objfile,
6a053cb1 613 const section_offsets &new_offsets)
567995e1 614{
b260e109 615 int changed = 0;
567995e1 616
b260e109 617 changed |= objfile_relocate1 (objfile, new_offsets);
567995e1 618
bde09ab7 619 for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
567995e1 620 {
e9ad22ee
TT
621 if (debug_objfile == objfile)
622 continue;
623
37e136b1
TT
624 section_addr_info objfile_addrs
625 = build_section_addr_info_from_objfile (objfile);
567995e1
JK
626
627 /* Here OBJFILE_ADDRS contain the correct absolute addresses, the
628 relative ones must be already created according to debug_objfile. */
629
98badbfd 630 addr_info_make_relative (&objfile_addrs, debug_objfile->obfd.get ());
567995e1 631
6a053cb1 632 gdb_assert (debug_objfile->section_offsets.size ()
98badbfd 633 == gdb_bfd_count_sections (debug_objfile->obfd.get ()));
6a053cb1
TT
634 section_offsets new_debug_offsets
635 (debug_objfile->section_offsets.size ());
636 relative_addr_info_to_section_offsets (new_debug_offsets, objfile_addrs);
567995e1 637
6a053cb1 638 changed |= objfile_relocate1 (debug_objfile, new_debug_offsets);
567995e1 639 }
30510692 640
0df8b418 641 /* Relocate breakpoints as necessary, after things are relocated. */
b260e109
JK
642 if (changed)
643 breakpoint_re_set ();
c906108c 644}
4141a416
JB
645
646/* Rebase (add to the offsets) OBJFILE by SLIDE. SEPARATE_DEBUG_OBJFILE is
647 not touched here.
648 Return non-zero iff any change happened. */
649
650static int
651objfile_rebase1 (struct objfile *objfile, CORE_ADDR slide)
652{
6a053cb1 653 section_offsets new_offsets (objfile->section_offsets.size (), slide);
4141a416
JB
654 return objfile_relocate1 (objfile, new_offsets);
655}
656
657/* Rebase (add to the offsets) OBJFILE by SLIDE. Process also OBJFILE's
658 SEPARATE_DEBUG_OBJFILEs. */
659
660void
661objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
662{
4141a416
JB
663 int changed = 0;
664
bde09ab7 665 for (::objfile *debug_objfile : objfile->separate_debug_objfiles ())
4141a416
JB
666 changed |= objfile_rebase1 (debug_objfile, slide);
667
668 /* Relocate breakpoints as necessary, after things are relocated. */
669 if (changed)
670 breakpoint_re_set ();
671}
55333a84 672
cc7541ce
SM
673/* See objfiles.h. */
674
675bool
006fb761 676objfile::has_full_symbols ()
55333a84 677{
006fb761 678 return this->compunit_symtabs != nullptr;
55333a84
DE
679}
680
cc7541ce 681/* See objfiles.h. */
e361b228 682
cc7541ce 683bool
006fb761 684objfile::has_symbols ()
e361b228 685{
006fb761
SM
686 for (::objfile *o : this->separate_debug_objfiles ())
687 if (o->has_partial_symbols () || o->has_full_symbols ())
cc7541ce 688 return true;
e361b228 689
cc7541ce
SM
690 return false;
691}
e361b228 692
cc7541ce 693/* See objfiles.h. */
c906108c 694
cc7541ce 695bool
9c067e28 696have_partial_symbols (program_space *pspace)
c906108c 697{
9c067e28 698 for (objfile *ofp : pspace->objfiles ())
cc7541ce
SM
699 if (ofp->has_partial_symbols ())
700 return true;
701
702 return false;
c906108c
SS
703}
704
cc7541ce 705/* See objfiles.h. */
c906108c 706
cc7541ce 707bool
9c067e28 708have_full_symbols (program_space *pspace)
c906108c 709{
9c067e28 710 for (objfile *ofp : pspace->objfiles ())
006fb761 711 if (ofp->has_full_symbols ())
cc7541ce
SM
712 return true;
713
714 return false;
c906108c
SS
715}
716
717
98793b83 718/* See objfiles.h. */
0df8b418 719
c906108c 720void
98793b83 721objfile_purge_solibs (program_space *pspace)
c906108c 722{
98793b83 723 for (objfile *objf : pspace->objfiles_safe ())
cac85af2
TT
724 {
725 /* We assume that the solib package has been purged already, or will
726 be soon. */
0df8b418 727
cac85af2 728 if (!(objf->flags & OBJF_USERLOADED) && (objf->flags & OBJF_SHARED))
268e4f09 729 objf->unlink ();
cac85af2 730 }
c906108c
SS
731}
732
cc7541ce 733/* See objfiles.h. */
c906108c 734
cc7541ce 735bool
9c067e28 736have_minimal_symbols (program_space *pspace)
c906108c 737{
9c067e28 738 for (objfile *ofp : pspace->objfiles ())
cc7541ce
SM
739 if (ofp->per_bfd->minimal_symbol_count > 0)
740 return true;
741
742 return false;
c906108c
SS
743}
744
a845f5cb
PP
745/* Qsort comparison function. */
746
39ef2f62
CB
747static bool
748sort_cmp (const struct obj_section *sect1, const obj_section *sect2)
a845f5cb 749{
0c1bcd23
SM
750 const CORE_ADDR sect1_addr = sect1->addr ();
751 const CORE_ADDR sect2_addr = sect2->addr ();
a845f5cb
PP
752
753 if (sect1_addr < sect2_addr)
39ef2f62 754 return true;
a845f5cb 755 else if (sect1_addr > sect2_addr)
39ef2f62 756 return false;
6fbf07cd 757 else
5cc80db3
MS
758 {
759 /* Sections are at the same address. This could happen if
760 A) we have an objfile and a separate debuginfo.
761 B) we are confused, and have added sections without proper relocation,
0df8b418 762 or something like that. */
5cc80db3
MS
763
764 const struct objfile *const objfile1 = sect1->objfile;
765 const struct objfile *const objfile2 = sect2->objfile;
766
767 if (objfile1->separate_debug_objfile == objfile2
768 || objfile2->separate_debug_objfile == objfile1)
769 {
770 /* Case A. The ordering doesn't matter: separate debuginfo files
771 will be filtered out later. */
772
39ef2f62 773 return false;
5cc80db3
MS
774 }
775
776 /* Case B. Maintain stable sort order, so bugs in GDB are easier to
777 triage. This section could be slow (since we iterate over all
39ef2f62 778 objfiles in each call to sort_cmp), but this shouldn't happen
5cc80db3
MS
779 very often (GDB is already in a confused state; one hopes this
780 doesn't happen at all). If you discover that significant time is
781 spent in the loops below, do 'set complaints 100' and examine the
782 resulting complaints. */
5cc80db3
MS
783 if (objfile1 == objfile2)
784 {
45f47c3a
AB
785 /* Both sections came from the same objfile. We are really
786 confused. Sort on sequence order of sections within the
787 objfile. The order of checks is important here, if we find a
788 match on SECT2 first then either SECT2 is before SECT1, or,
789 SECT2 == SECT1, in both cases we should return false. The
790 second case shouldn't occur during normal use, but std::sort
791 does check that '!(a < a)' when compiled in debug mode. */
5cc80db3 792
5250cbc8 793 for (const obj_section *osect : objfile1->sections ())
45f47c3a 794 if (osect == sect2)
39ef2f62 795 return false;
45f47c3a
AB
796 else if (osect == sect1)
797 return true;
5cc80db3
MS
798
799 /* We should have found one of the sections before getting here. */
f3574227 800 gdb_assert_not_reached ("section not found");
5cc80db3
MS
801 }
802 else
803 {
804 /* Sort on sequence number of the objfile in the chain. */
805
2030c079 806 for (objfile *objfile : current_program_space->objfiles ())
5cc80db3 807 if (objfile == objfile1)
39ef2f62 808 return true;
5cc80db3 809 else if (objfile == objfile2)
39ef2f62 810 return false;
5cc80db3
MS
811
812 /* We should have found one of the objfiles before getting here. */
f3574227 813 gdb_assert_not_reached ("objfile not found");
5cc80db3
MS
814 }
815 }
6fbf07cd
PP
816
817 /* Unreachable. */
f3574227 818 gdb_assert_not_reached ("unexpected code path");
39ef2f62 819 return false;
a845f5cb
PP
820}
821
3aad21cf
PP
822/* Select "better" obj_section to keep. We prefer the one that came from
823 the real object, rather than the one from separate debuginfo.
824 Most of the time the two sections are exactly identical, but with
825 prelinking the .rel.dyn section in the real object may have different
826 size. */
827
828static struct obj_section *
829preferred_obj_section (struct obj_section *a, struct obj_section *b)
830{
0c1bcd23 831 gdb_assert (a->addr () == b->addr ());
3aad21cf
PP
832 gdb_assert ((a->objfile->separate_debug_objfile == b->objfile)
833 || (b->objfile->separate_debug_objfile == a->objfile));
834 gdb_assert ((a->objfile->separate_debug_objfile_backlink == b->objfile)
835 || (b->objfile->separate_debug_objfile_backlink == a->objfile));
836
837 if (a->objfile->separate_debug_objfile != NULL)
838 return a;
839 return b;
840}
841
6fbf07cd 842/* Return 1 if SECTION should be inserted into the section map.
625b6eae 843 We want to insert only non-overlay non-TLS non-empty sections. */
6fbf07cd
PP
844
845static int
846insert_section_p (const struct bfd *abfd,
847 const struct bfd_section *section)
848{
fd361982 849 const bfd_vma lma = bfd_section_lma (section);
6fbf07cd 850
fd361982 851 if (overlay_debugging && lma != 0 && lma != bfd_section_vma (section)
6fbf07cd
PP
852 && (bfd_get_file_flags (abfd) & BFD_IN_MEMORY) == 0)
853 /* This is an overlay section. IN_MEMORY check is needed to avoid
854 discarding sections from the "system supplied DSO" (aka vdso)
855 on some Linux systems (e.g. Fedora 11). */
856 return 0;
fd361982 857 if ((bfd_section_flags (section) & SEC_THREAD_LOCAL) != 0)
6fbf07cd
PP
858 /* This is a TLS section. */
859 return 0;
625b6eae
IL
860 if (bfd_section_size (section) == 0)
861 {
862 /* This is an empty section. It has no PCs for find_pc_section (), so
863 there is no reason to insert it into the section map. */
864 return 0;
865 }
6fbf07cd
PP
866
867 return 1;
868}
869
870/* Filter out overlapping sections where one section came from the real
871 objfile, and the other from a separate debuginfo file.
872 Return the size of table after redundant sections have been eliminated. */
873
874static int
875filter_debuginfo_sections (struct obj_section **map, int map_size)
876{
877 int i, j;
878
879 for (i = 0, j = 0; i < map_size - 1; i++)
880 {
881 struct obj_section *const sect1 = map[i];
882 struct obj_section *const sect2 = map[i + 1];
883 const struct objfile *const objfile1 = sect1->objfile;
884 const struct objfile *const objfile2 = sect2->objfile;
0c1bcd23
SM
885 const CORE_ADDR sect1_addr = sect1->addr ();
886 const CORE_ADDR sect2_addr = sect2->addr ();
6fbf07cd
PP
887
888 if (sect1_addr == sect2_addr
889 && (objfile1->separate_debug_objfile == objfile2
890 || objfile2->separate_debug_objfile == objfile1))
891 {
892 map[j++] = preferred_obj_section (sect1, sect2);
893 ++i;
894 }
895 else
896 map[j++] = sect1;
897 }
898
899 if (i < map_size)
900 {
901 gdb_assert (i == map_size - 1);
902 map[j++] = map[i];
903 }
904
905 /* The map should not have shrunk to less than half the original size. */
906 gdb_assert (map_size / 2 <= j);
907
908 return j;
909}
910
911/* Filter out overlapping sections, issuing a warning if any are found.
912 Overlapping sections could really be overlay sections which we didn't
913 classify as such in insert_section_p, or we could be dealing with a
914 corrupt binary. */
915
916static int
917filter_overlapping_sections (struct obj_section **map, int map_size)
918{
919 int i, j;
920
921 for (i = 0, j = 0; i < map_size - 1; )
922 {
923 int k;
924
925 map[j++] = map[i];
926 for (k = i + 1; k < map_size; k++)
927 {
928 struct obj_section *const sect1 = map[i];
929 struct obj_section *const sect2 = map[k];
0c1bcd23
SM
930 const CORE_ADDR sect1_addr = sect1->addr ();
931 const CORE_ADDR sect2_addr = sect2->addr ();
932 const CORE_ADDR sect1_endaddr = sect1->endaddr ();
6fbf07cd
PP
933
934 gdb_assert (sect1_addr <= sect2_addr);
935
936 if (sect1_endaddr <= sect2_addr)
937 break;
938 else
939 {
940 /* We have an overlap. Report it. */
941
942 struct objfile *const objf1 = sect1->objfile;
943 struct objfile *const objf2 = sect2->objfile;
944
6fbf07cd
PP
945 const struct bfd_section *const bfds1 = sect1->the_bfd_section;
946 const struct bfd_section *const bfds2 = sect2->the_bfd_section;
947
0c1bcd23 948 const CORE_ADDR sect2_endaddr = sect2->endaddr ();
6fbf07cd 949
08feed99 950 struct gdbarch *const gdbarch = objf1->arch ();
6fbf07cd 951
b98664d3 952 complaint (_("unexpected overlap between:\n"
6fbf07cd
PP
953 " (A) section `%s' from `%s' [%s, %s)\n"
954 " (B) section `%s' from `%s' [%s, %s).\n"
955 "Will ignore section B"),
fd361982 956 bfd_section_name (bfds1), objfile_name (objf1),
6fbf07cd
PP
957 paddress (gdbarch, sect1_addr),
958 paddress (gdbarch, sect1_endaddr),
fd361982 959 bfd_section_name (bfds2), objfile_name (objf2),
6fbf07cd
PP
960 paddress (gdbarch, sect2_addr),
961 paddress (gdbarch, sect2_endaddr));
962 }
963 }
964 i = k;
965 }
966
967 if (i < map_size)
968 {
969 gdb_assert (i == map_size - 1);
970 map[j++] = map[i];
971 }
972
973 return j;
974}
975
976
977/* Update PMAP, PMAP_SIZE with sections from all objfiles, excluding any
978 TLS, overlay and overlapping sections. */
a845f5cb
PP
979
980static void
6c95b8df
PA
981update_section_map (struct program_space *pspace,
982 struct obj_section ***pmap, int *pmap_size)
a845f5cb 983{
607ece04 984 struct objfile_pspace_info *pspace_info;
6fbf07cd 985 int alloc_size, map_size, i;
5250cbc8 986 struct obj_section **map;
a845f5cb 987
607ece04
GB
988 pspace_info = get_objfile_pspace_data (pspace);
989 gdb_assert (pspace_info->section_map_dirty != 0
990 || pspace_info->new_objfiles_available != 0);
a845f5cb
PP
991
992 map = *pmap;
993 xfree (map);
994
6fbf07cd 995 alloc_size = 0;
2030c079 996 for (objfile *objfile : pspace->objfiles ())
5250cbc8 997 for (obj_section *s : objfile->sections ())
98badbfd 998 if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
6c95b8df 999 alloc_size += 1;
a845f5cb 1000
65a97ab3
PP
1001 /* This happens on detach/attach (e.g. in gdb.base/attach.exp). */
1002 if (alloc_size == 0)
1003 {
1004 *pmap = NULL;
1005 *pmap_size = 0;
1006 return;
1007 }
1008
8d749320 1009 map = XNEWVEC (struct obj_section *, alloc_size);
a845f5cb 1010
3aad21cf 1011 i = 0;
2030c079 1012 for (objfile *objfile : pspace->objfiles ())
5250cbc8 1013 for (obj_section *s : objfile->sections ())
98badbfd 1014 if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
6c95b8df 1015 map[i++] = s;
a845f5cb 1016
39ef2f62 1017 std::sort (map, map + alloc_size, sort_cmp);
6fbf07cd
PP
1018 map_size = filter_debuginfo_sections(map, alloc_size);
1019 map_size = filter_overlapping_sections(map, map_size);
a845f5cb 1020
6fbf07cd
PP
1021 if (map_size < alloc_size)
1022 /* Some sections were eliminated. Trim excess space. */
224c3ddb 1023 map = XRESIZEVEC (struct obj_section *, map, map_size);
3aad21cf 1024 else
6fbf07cd 1025 gdb_assert (alloc_size == map_size);
3aad21cf 1026
a845f5cb
PP
1027 *pmap = map;
1028 *pmap_size = map_size;
1029}
1030
0df8b418 1031/* Bsearch comparison function. */
a845f5cb
PP
1032
1033static int
1034bsearch_cmp (const void *key, const void *elt)
1035{
1036 const CORE_ADDR pc = *(CORE_ADDR *) key;
1037 const struct obj_section *section = *(const struct obj_section **) elt;
1038
0c1bcd23 1039 if (pc < section->addr ())
a845f5cb 1040 return -1;
0c1bcd23 1041 if (pc < section->endaddr ())
a845f5cb
PP
1042 return 0;
1043 return 1;
1044}
1045
714835d5 1046/* Returns a section whose range includes PC or NULL if none found. */
c906108c
SS
1047
1048struct obj_section *
714835d5 1049find_pc_section (CORE_ADDR pc)
c906108c 1050{
6c95b8df 1051 struct objfile_pspace_info *pspace_info;
a845f5cb 1052 struct obj_section *s, **sp;
c5aa993b 1053
714835d5
UW
1054 /* Check for mapped overlay section first. */
1055 s = find_pc_mapped_section (pc);
1056 if (s)
1057 return s;
c906108c 1058
6c95b8df 1059 pspace_info = get_objfile_pspace_data (current_program_space);
607ece04
GB
1060 if (pspace_info->section_map_dirty
1061 || (pspace_info->new_objfiles_available
1062 && !pspace_info->inhibit_updates))
a845f5cb 1063 {
6c95b8df
PA
1064 update_section_map (current_program_space,
1065 &pspace_info->sections,
1066 &pspace_info->num_sections);
c906108c 1067
6c95b8df 1068 /* Don't need updates to section map until objfiles are added,
dda83cd7 1069 removed or relocated. */
607ece04
GB
1070 pspace_info->new_objfiles_available = 0;
1071 pspace_info->section_map_dirty = 0;
a845f5cb
PP
1072 }
1073
65a97ab3
PP
1074 /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
1075 bsearch be non-NULL. */
1076 if (pspace_info->sections == NULL)
1077 {
1078 gdb_assert (pspace_info->num_sections == 0);
1079 return NULL;
1080 }
1081
6c95b8df
PA
1082 sp = (struct obj_section **) bsearch (&pc,
1083 pspace_info->sections,
1084 pspace_info->num_sections,
1085 sizeof (*pspace_info->sections),
1086 bsearch_cmp);
a845f5cb
PP
1087 if (sp != NULL)
1088 return *sp;
714835d5 1089 return NULL;
c906108c 1090}
c5aa993b 1091
c906108c 1092
3e5d3a5a 1093/* Return non-zero if PC is in a section called NAME. */
c906108c 1094
6ec27270 1095bool
a121b7c1 1096pc_in_section (CORE_ADDR pc, const char *name)
c906108c 1097{
6ec27270
TT
1098 struct obj_section *s = find_pc_section (pc);
1099 return (s != nullptr
1100 && s->the_bfd_section->name != nullptr
1101 && strcmp (s->the_bfd_section->name, name) == 0);
c906108c 1102}
0d0e1a63 1103
da273247 1104/* See objfiles.h. */
a845f5cb
PP
1105
1106void
da273247 1107objfiles_changed (program_space *pspace)
a845f5cb 1108{
6c95b8df 1109 /* Rebuild section map next time we need it. */
da273247 1110 get_objfile_pspace_data (pspace)->section_map_dirty = 1;
607ece04
GB
1111}
1112
1113/* See comments in objfiles.h. */
1114
06424eac 1115scoped_restore_tmpl<int>
607ece04
GB
1116inhibit_section_map_updates (struct program_space *pspace)
1117{
06424eac
TT
1118 return scoped_restore_tmpl<int>
1119 (&get_objfile_pspace_data (pspace)->inhibit_updates, 1);
a845f5cb 1120}
e3c69974 1121
02ff80c2 1122/* See objfiles.h. */
63644780 1123
02ff80c2 1124bool
63644780
NB
1125is_addr_in_objfile (CORE_ADDR addr, const struct objfile *objfile)
1126{
63644780 1127 if (objfile == NULL)
02ff80c2 1128 return false;
63644780 1129
5250cbc8 1130 for (obj_section *osect : objfile->sections ())
63644780
NB
1131 {
1132 if (section_is_overlay (osect) && !section_is_mapped (osect))
1133 continue;
1134
94a75b03 1135 if (osect->contains (addr))
02ff80c2 1136 return true;
63644780 1137 }
02ff80c2 1138 return false;
63644780
NB
1139}
1140
02ff80c2
SM
1141/* See objfiles.h. */
1142
1143bool
d03de421
PA
1144shared_objfile_contains_address_p (struct program_space *pspace,
1145 CORE_ADDR address)
08351840 1146{
2030c079 1147 for (objfile *objfile : pspace->objfiles ())
08351840 1148 {
d03de421 1149 if ((objfile->flags & OBJF_SHARED) != 0
08351840 1150 && is_addr_in_objfile (address, objfile))
02ff80c2 1151 return true;
08351840
PA
1152 }
1153
02ff80c2 1154 return false;
08351840
PA
1155}
1156
19630284 1157/* The default implementation for the "iterate_over_objfiles_in_search_order"
2030c079 1158 gdbarch method. It is equivalent to use the objfiles iterable,
19630284
JB
1159 searching the objfiles in the order they are stored internally,
1160 ignoring CURRENT_OBJFILE.
1161
85102364 1162 On most platforms, it should be close enough to doing the best
19630284
JB
1163 we can without some knowledge specific to the architecture. */
1164
1165void
1166default_iterate_over_objfiles_in_search_order
6e9cd73e
SM
1167 (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb,
1168 objfile *current_objfile)
19630284 1169{
2030c079 1170 for (objfile *objfile : current_program_space->objfiles ())
6e9cd73e
SM
1171 if (cb (objfile))
1172 return;
19630284
JB
1173}
1174
e02c96a7 1175/* See objfiles.h. */
4262abfb
JK
1176
1177const char *
1178objfile_name (const struct objfile *objfile)
1179{
24ba069a 1180 if (objfile->obfd != NULL)
98badbfd 1181 return bfd_get_filename (objfile->obfd.get ());
24ba069a 1182
4262abfb
JK
1183 return objfile->original_name;
1184}
1185
cc485e62
DE
1186/* See objfiles.h. */
1187
e02c96a7
DE
1188const char *
1189objfile_filename (const struct objfile *objfile)
1190{
1191 if (objfile->obfd != NULL)
98badbfd 1192 return bfd_get_filename (objfile->obfd.get ());
e02c96a7
DE
1193
1194 return NULL;
1195}
1196
1197/* See objfiles.h. */
1198
cc485e62
DE
1199const char *
1200objfile_debug_name (const struct objfile *objfile)
1201{
1202 return lbasename (objfile->original_name);
1203}
1204
015d2e7e
DE
1205/* See objfiles.h. */
1206
1207const char *
1208objfile_flavour_name (struct objfile *objfile)
1209{
1210 if (objfile->obfd != NULL)
98badbfd 1211 return bfd_flavour_name (bfd_get_flavour (objfile->obfd.get ()));
015d2e7e
DE
1212 return NULL;
1213}
b3a01ce2
WP
1214
1215/* See objfiles.h. */
1216
1217struct type *
1218objfile_int_type (struct objfile *of, int size_in_bytes, bool unsigned_p)
1219{
1220 struct type *int_type;
1221
1222 /* Helper macro to examine the various builtin types. */
1223#define TRY_TYPE(F) \
1224 int_type = (unsigned_p \
a8ed3dde
TT
1225 ? builtin_type (of)->builtin_unsigned_ ## F \
1226 : builtin_type (of)->builtin_ ## F); \
df86565b 1227 if (int_type != NULL && int_type->length () == size_in_bytes) \
b3a01ce2
WP
1228 return int_type
1229
1230 TRY_TYPE (char);
1231 TRY_TYPE (short);
1232 TRY_TYPE (int);
1233 TRY_TYPE (long);
1234 TRY_TYPE (long_long);
1235
1236#undef TRY_TYPE
1237
1238 gdb_assert_not_reached ("unable to find suitable integer type");
1239}