GDB (xrefs)
Loading...
Searching...
No Matches
/tmp/gdb-13.1/gdb/corelow.c
Go to the documentation of this file.
1/* Core dump and executable file functions below target vector, for GDB.
2
3 Copyright (C) 1986-2023 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 "arch-utils.h"
22#include <signal.h>
23#include <fcntl.h>
24#include "frame.h" /* required by inferior.h */
25#include "inferior.h"
26#include "infrun.h"
27#include "symtab.h"
28#include "command.h"
29#include "bfd.h"
30#include "target.h"
32#include "gdbcore.h"
33#include "gdbthread.h"
34#include "regcache.h"
35#include "regset.h"
36#include "symfile.h"
37#include "exec.h"
38#include "readline/tilde.h"
39#include "solib.h"
40#include "solist.h"
41#include "filenames.h"
42#include "progspace.h"
43#include "objfiles.h"
44#include "gdb_bfd.h"
45#include "completer.h"
46#include "gdbsupport/filestuff.h"
47#include "build-id.h"
48#include "gdbsupport/pathstuff.h"
49#include "gdbsupport/scoped_fd.h"
50#include "debuginfod-support.h"
51#include <unordered_map>
52#include <unordered_set>
53#include "gdbcmd.h"
54#include "xml-tdesc.h"
55#include "memtag.h"
56
57#ifndef O_LARGEFILE
58#define O_LARGEFILE 0
59#endif
60
61/* The core file target. */
62
64 "core",
65 N_("Local core dump file"),
66 N_("Use a core file as a target.\n\
67Specify the filename of the core file.")
68};
69
71{
72public:
73 core_target ();
74
75 const target_info &info () const override
76 { return core_target_info; }
77
78 void close () override;
79 void detach (inferior *, int) override;
80 void fetch_registers (struct regcache *, int) override;
81
83 const char *annex,
84 gdb_byte *readbuf,
85 const gdb_byte *writebuf,
86 ULONGEST offset, ULONGEST len,
87 ULONGEST *xfered_len) override;
88 void files_info () override;
89
90 bool thread_alive (ptid_t ptid) override;
91 const struct target_desc *read_description () override;
92
93 std::string pid_to_str (ptid_t) override;
94
95 const char *thread_name (struct thread_info *) override;
96
97 bool has_all_memory () override { return true; }
98 bool has_memory () override;
99 bool has_stack () override;
100 bool has_registers () override;
101 bool has_execution (inferior *inf) override { return false; }
102
103 bool info_proc (const char *, enum info_proc_what) override;
104
105 bool supports_memory_tagging () override;
106
107 /* Core file implementation of fetch_memtags. Fetch the memory tags from
108 core file notes. */
109 bool fetch_memtags (CORE_ADDR address, size_t len,
110 gdb::byte_vector &tags, int type) override;
111
112 /* A few helpers. */
113
114 /* Getter, see variable definition. */
116 {
117 return m_core_gdbarch;
118 }
119
120 /* See definition. */
122 const struct regset *regset,
123 const char *name,
124 int section_min_size,
125 const char *human_name,
126 bool required);
127
128 /* See definition. */
129 void info_proc_mappings (struct gdbarch *gdbarch);
130
131private: /* per-core data */
132
133 /* Get rid of the core inferior. */
134 void clear_core ();
135
136 /* The core's section table. Note that these target sections are
137 *not* mapped in the current address spaces' set of target
138 sections --- those should come only from pure executable or
139 shared library bfds. The core bfd sections are an implementation
140 detail of the core target, just like ptrace is for unix child
141 targets. */
143
144 /* File-backed address space mappings: some core files include
145 information about memory mapped files. */
147
148 /* Unavailable mappings. These correspond to pathnames which either
149 weren't found or could not be opened. Knowing these addresses can
150 still be useful. */
151 std::vector<mem_range> m_core_unavailable_mappings;
152
153 /* Build m_core_file_mappings. Called from the constructor. */
154 void build_file_mappings ();
155
156 /* Helper method for xfer_partial. */
157 enum target_xfer_status xfer_memory_via_mappings (gdb_byte *readbuf,
158 const gdb_byte *writebuf,
159 ULONGEST offset,
160 ULONGEST len,
161 ULONGEST *xfered_len);
162
163 /* FIXME: kettenis/20031023: Eventually this field should
164 disappear. */
165 struct gdbarch *m_core_gdbarch = NULL;
166};
167
169{
170 /* Find a first arch based on the BFD. We need the initial gdbarch so
171 we can setup the hooks to find a target description. */
173
174 /* If the arch is able to read a target description from the core, it
175 could yield a more specific gdbarch. */
176 const struct target_desc *tdesc = read_description ();
177
178 if (tdesc != nullptr)
179 {
180 struct gdbarch_info info;
181 info.abfd = core_bfd;
182 info.target_desc = tdesc;
184 }
185
186 if (!m_core_gdbarch
188 error (_("\"%s\": Core file format not supported"),
189 bfd_get_filename (core_bfd));
190
191 /* Find the data section */
193
195}
196
197/* Construct the target_section_table for file-backed mappings if
198 they exist.
199
200 For each unique path in the note, we'll open a BFD with a bfd
201 target of "binary". This is an unstructured bfd target upon which
202 we'll impose a structure from the mappings in the architecture-specific
203 mappings note. A BFD section is allocated and initialized for each
204 file-backed mapping.
205
206 We take care to not share already open bfds with other parts of
207 GDB; in particular, we don't want to add new sections to existing
208 BFDs. We do, however, ensure that the BFDs that we allocate here
209 will go away (be deallocated) when the core target is detached. */
210
211void
213{
214 std::unordered_map<std::string, struct bfd *> bfd_map;
215 std::unordered_set<std::string> unavailable_paths;
216
217 /* See linux_read_core_file_mappings() in linux-tdep.c for an example
218 read_core_file_mappings method. */
220
221 /* After determining the number of mappings, read_core_file_mappings
222 will invoke this lambda. */
223 [&] (ULONGEST)
224 {
225 },
226
227 /* read_core_file_mappings will invoke this lambda for each mapping
228 that it finds. */
229 [&] (int num, ULONGEST start, ULONGEST end, ULONGEST file_ofs,
230 const char *filename, const bfd_build_id *build_id)
231 {
232 /* Architecture-specific read_core_mapping methods are expected to
233 weed out non-file-backed mappings. */
234 gdb_assert (filename != nullptr);
235
236 struct bfd *bfd = bfd_map[filename];
237 if (bfd == nullptr)
238 {
239 /* Use exec_file_find() to do sysroot expansion. It'll
240 also strip the potential sysroot "target:" prefix. If
241 there is no sysroot, an equivalent (possibly more
242 canonical) pathname will be provided. */
243 gdb::unique_xmalloc_ptr<char> expanded_fname
244 = exec_file_find (filename, NULL);
245
246 if (expanded_fname == nullptr && build_id != nullptr)
247 debuginfod_exec_query (build_id->data, build_id->size,
248 filename, &expanded_fname);
249
250 if (expanded_fname == nullptr)
251 {
252 m_core_unavailable_mappings.emplace_back (start, end - start);
253 /* Print just one warning per path. */
254 if (unavailable_paths.insert (filename).second)
255 warning (_("Can't open file %s during file-backed mapping "
256 "note processing"),
257 filename);
258 return;
259 }
260
261 bfd = bfd_map[filename] = bfd_openr (expanded_fname.get (),
262 "binary");
263
264 if (bfd == nullptr || !bfd_check_format (bfd, bfd_object))
265 {
266 m_core_unavailable_mappings.emplace_back (start, end - start);
267 /* If we get here, there's a good chance that it's due to
268 an internal error. We issue a warning instead of an
269 internal error because of the possibility that the
270 file was removed in between checking for its
271 existence during the expansion in exec_file_find()
272 and the calls to bfd_openr() / bfd_check_format().
273 Output both the path from the core file note along
274 with its expansion to make debugging this problem
275 easier. */
276 warning (_("Can't open file %s which was expanded to %s "
277 "during file-backed mapping note processing"),
278 filename, expanded_fname.get ());
279 if (bfd != nullptr)
280 bfd_close (bfd);
281 return;
282 }
283 /* Ensure that the bfd will be closed when core_bfd is closed.
284 This can be checked before/after a core file detach via
285 "maint info bfds". */
287 }
288
289 /* Make new BFD section. All sections have the same name,
290 which is permitted by bfd_make_section_anyway(). */
291 asection *sec = bfd_make_section_anyway (bfd, "load");
292 if (sec == nullptr)
293 error (_("Can't make section"));
294 sec->filepos = file_ofs;
295 bfd_set_section_flags (sec, SEC_READONLY | SEC_HAS_CONTENTS);
296 bfd_set_section_size (sec, end - start);
297 bfd_set_section_vma (sec, start);
298 bfd_set_section_lma (sec, start);
299 bfd_set_section_alignment (sec, 2);
300
301 /* Set target_section fields. */
302 m_core_file_mappings.emplace_back (start, end, sec);
303
304 /* If this is a bfd of a shared library, record its soname
305 and build id. */
306 if (build_id != nullptr)
307 {
308 gdb::unique_xmalloc_ptr<char> soname
309 = gdb_bfd_read_elf_soname (bfd->filename);
310 if (soname != nullptr)
312 soname.get (), build_id);
313 }
314 });
315
317}
318
319/* An arbitrary identifier for the core inferior. */
320#define CORELOW_PID 1
321
322void
324{
325 if (core_bfd)
326 {
327 switch_to_no_thread (); /* Avoid confusion from thread
328 stuff. */
330
331 /* Clear out solib state while the bfd is still open. See
332 comments in clear_solib in solib.c. */
333 clear_solib ();
334
335 current_program_space->cbfd.reset (nullptr);
336 }
337}
338
339/* Close the core target. */
340
341void
343{
344 clear_core ();
345
346 /* Core targets are heap-allocated (see core_target_open), so here
347 we delete ourselves. */
348 delete this;
349}
350
351/* Look for sections whose names start with `.reg/' so that we can
352 extract the list of threads in a core file. */
353
354static void
355add_to_thread_list (asection *asect, asection *reg_sect)
356{
357 int core_tid;
358 int pid, lwpid;
359 bool fake_pid_p = false;
360 struct inferior *inf;
361
362 if (!startswith (bfd_section_name (asect), ".reg/"))
363 return;
364
365 core_tid = atoi (bfd_section_name (asect) + 5);
366
367 pid = bfd_core_file_pid (core_bfd);
368 if (pid == 0)
369 {
370 fake_pid_p = true;
372 }
373
374 lwpid = core_tid;
375
377 if (inf->pid == 0)
378 {
380 inf->fake_pid_p = fake_pid_p;
381 }
382
383 ptid_t ptid (pid, lwpid);
384
385 thread_info *thr = add_thread (inf->process_target (), ptid);
386
387/* Warning, Will Robinson, looking at BFD private data! */
388
389 if (reg_sect != NULL
390 && asect->filepos == reg_sect->filepos) /* Did we find .reg? */
391 switch_to_thread (thr); /* Yes, make it current. */
392}
393
394/* Issue a message saying we have no core to debug, if FROM_TTY. */
395
396static void
398{
399 if (from_tty)
400 gdb_printf (_("No core file now.\n"));
401}
402
403/* Backward compatibility with old way of specifying core files. */
404
405void
406core_file_command (const char *filename, int from_tty)
407{
408 dont_repeat (); /* Either way, seems bogus. */
409
410 if (filename == NULL)
411 {
412 if (core_bfd != NULL)
413 {
414 target_detach (current_inferior (), from_tty);
415 gdb_assert (core_bfd == NULL);
416 }
417 else
419 }
420 else
421 core_target_open (filename, from_tty);
422}
423
424/* Locate (and load) an executable file (and symbols) given the core file
425 BFD ABFD. */
426
427static void
428locate_exec_from_corefile_build_id (bfd *abfd, int from_tty)
429{
430 const bfd_build_id *build_id = build_id_bfd_get (abfd);
431 if (build_id == nullptr)
432 return;
433
434 gdb_bfd_ref_ptr execbfd
435 = build_id_to_exec_bfd (build_id->size, build_id->data);
436
437 if (execbfd == nullptr)
438 {
439 /* Attempt to query debuginfod for the executable. */
440 gdb::unique_xmalloc_ptr<char> execpath;
441 scoped_fd fd = debuginfod_exec_query (build_id->data, build_id->size,
442 abfd->filename, &execpath);
443
444 if (fd.get () >= 0)
445 {
446 execbfd = gdb_bfd_open (execpath.get (), gnutarget);
447
448 if (execbfd == nullptr)
449 warning (_("\"%s\" from debuginfod cannot be opened as bfd: %s"),
450 execpath.get (),
451 gdb_bfd_errmsg (bfd_get_error (), nullptr).c_str ());
452 else if (!build_id_verify (execbfd.get (), build_id->size,
453 build_id->data))
454 execbfd.reset (nullptr);
455 }
456 }
457
458 if (execbfd != nullptr)
459 {
460 exec_file_attach (bfd_get_filename (execbfd.get ()), from_tty);
461 symbol_file_add_main (bfd_get_filename (execbfd.get ()),
462 symfile_add_flag (from_tty ? SYMFILE_VERBOSE : 0));
463 }
464}
465
466/* See gdbcore.h. */
467
468void
469core_target_open (const char *arg, int from_tty)
470{
471 const char *p;
472 int siggy;
473 int scratch_chan;
474 int flags;
475
476 target_preopen (from_tty);
477 if (!arg)
478 {
479 if (core_bfd)
480 error (_("No core file specified. (Use `detach' "
481 "to stop debugging a core file.)"));
482 else
483 error (_("No core file specified."));
484 }
485
486 gdb::unique_xmalloc_ptr<char> filename (tilde_expand (arg));
487 if (strlen (filename.get ()) != 0
488 && !IS_ABSOLUTE_PATH (filename.get ()))
489 filename = make_unique_xstrdup (gdb_abspath (filename.get ()).c_str ());
490
492 if (write_files)
493 flags |= O_RDWR;
494 else
495 flags |= O_RDONLY;
496 scratch_chan = gdb_open_cloexec (filename.get (), flags, 0).release ();
497 if (scratch_chan < 0)
498 perror_with_name (filename.get ());
499
500 gdb_bfd_ref_ptr temp_bfd (gdb_bfd_fopen (filename.get (), gnutarget,
501 write_files ? FOPEN_RUB : FOPEN_RB,
502 scratch_chan));
503 if (temp_bfd == NULL)
504 perror_with_name (filename.get ());
505
506 if (!bfd_check_format (temp_bfd.get (), bfd_core))
507 {
508 /* Do it after the err msg */
509 /* FIXME: should be checking for errors from bfd_close (for one
510 thing, on error it does not free all the storage associated
511 with the bfd). */
512 error (_("\"%s\" is not a core dump: %s"),
513 filename.get (), bfd_errmsg (bfd_get_error ()));
514 }
515
516 current_program_space->cbfd = std::move (temp_bfd);
517
518 core_target *target = new core_target ();
519
520 /* Own the target until it is successfully pushed. */
521 target_ops_up target_holder (target);
522
524
525 /* If we have no exec file, try to set the architecture from the
526 core file. We don't do this unconditionally since an exec file
527 typically contains more information that helps us determine the
528 architecture than a core file. */
531
532 current_inferior ()->push_target (std::move (target_holder));
533
535
536 /* Need to flush the register cache (and the frame cache) from a
537 previous debug session. If inferior_ptid ends up the same as the
538 last debug session --- e.g., b foo; run; gcore core1; step; gcore
539 core2; core core1; core core2 --- then there's potential for
540 get_current_regcache to return the cached regcache of the
541 previous session, and the frame cache being stale. */
543
544 /* Build up thread list from BFD sections, and possibly set the
545 current thread to the .reg/NN section matching the .reg
546 section. */
547 asection *reg_sect = bfd_get_section_by_name (core_bfd, ".reg");
548 for (asection *sect : gdb_bfd_sections (core_bfd))
549 add_to_thread_list (sect, reg_sect);
550
551 if (inferior_ptid == null_ptid)
552 {
553 /* Either we found no .reg/NN section, and hence we have a
554 non-threaded core (single-threaded, from gdb's perspective),
555 or for some reason add_to_thread_list couldn't determine
556 which was the "main" thread. The latter case shouldn't
557 usually happen, but we're dealing with input here, which can
558 always be broken in different ways. */
560
561 if (thread == NULL)
562 {
564 thread = add_thread_silent (target, ptid_t (CORELOW_PID));
565 }
566
567 switch_to_thread (thread);
568 }
569
570 if (current_program_space->exec_bfd () == nullptr)
572
573 post_create_inferior (from_tty);
574
575 /* Now go through the target stack looking for threads since there
576 may be a thread_stratum target loaded on top of target core by
577 now. The layer above should claim threads found in the BFD
578 sections. */
579 try
580 {
582 }
583
584 catch (const gdb_exception_error &except)
585 {
586 exception_print (gdb_stderr, except);
587 }
588
589 p = bfd_core_file_failing_command (core_bfd);
590 if (p)
591 gdb_printf (_("Core was generated by `%s'.\n"), p);
592
593 /* Clearing any previous state of convenience variables. */
595
596 siggy = bfd_core_file_failing_signal (core_bfd);
597 if (siggy > 0)
598 {
599 gdbarch *core_gdbarch = target->core_gdbarch ();
600
601 /* If we don't have a CORE_GDBARCH to work with, assume a native
602 core (map gdb_signal from host signals). If we do have
603 CORE_GDBARCH to work with, but no gdb_signal_from_target
604 implementation for that gdbarch, as a fallback measure,
605 assume the host signal mapping. It'll be correct for native
606 cores, but most likely incorrect for cross-cores. */
607 enum gdb_signal sig = (core_gdbarch != NULL
608 && gdbarch_gdb_signal_from_target_p (core_gdbarch)
609 ? gdbarch_gdb_signal_from_target (core_gdbarch,
610 siggy)
611 : gdb_signal_from_host (siggy));
612
613 gdb_printf (_("Program terminated with signal %s, %s"),
614 gdb_signal_to_name (sig), gdb_signal_to_string (sig));
615 if (gdbarch_report_signal_info_p (core_gdbarch))
616 gdbarch_report_signal_info (core_gdbarch, current_uiout, sig);
617 gdb_printf (_(".\n"));
618
619 /* Set the value of the internal variable $_exitsignal,
620 which holds the signal uncaught by the inferior. */
622 siggy);
623 }
624
625 /* Fetch all registers from core file. */
627
628 /* Now, set up the frame cache, and print the top of stack. */
631
632 /* Current thread should be NUM 1 but the user does not know that.
633 If a program is single threaded gdb in general does not mention
634 anything about threads. That is why the test is >= 2. */
635 if (thread_count (target) >= 2)
636 {
637 try
638 {
639 thread_command (NULL, from_tty);
640 }
641 catch (const gdb_exception_error &except)
642 {
643 exception_print (gdb_stderr, except);
644 }
645 }
646}
647
648void
650{
651 /* Get rid of the core. Don't rely on core_target::close doing it,
652 because target_detach may be called with core_target's refcount > 1,
653 meaning core_target::close may not be called yet by the
654 unpush_target call below. */
655 clear_core ();
656
657 /* Note that 'this' may be dangling after this call. unpush_target
658 closes the target if the refcount reaches 0, and our close
659 implementation deletes 'this'. */
660 inf->unpush_target (this);
661
662 /* Clear the register cache and the frame cache. */
666}
667
668/* Try to retrieve registers from a section in core_bfd, and supply
669 them to REGSET.
670
671 If ptid's lwp member is zero, do the single-threaded
672 thing: look for a section named NAME. If ptid's lwp
673 member is non-zero, do the multi-threaded thing: look for a section
674 named "NAME/LWP", where LWP is the shortest ASCII decimal
675 representation of ptid's lwp member.
676
677 HUMAN_NAME is a human-readable name for the kind of registers the
678 NAME section contains, for use in error messages.
679
680 If REQUIRED is true, print an error if the core file doesn't have a
681 section by the appropriate name. Otherwise, just do nothing. */
682
683void
685 const struct regset *regset,
686 const char *name,
687 int section_min_size,
688 const char *human_name,
689 bool required)
690{
691 gdb_assert (regset != nullptr);
692
693 struct bfd_section *section;
694 bfd_size_type size;
695 bool variable_size_section = (regset->flags & REGSET_VARIABLE_SIZE);
696
697 thread_section_name section_name (name, regcache->ptid ());
698
699 section = bfd_get_section_by_name (core_bfd, section_name.c_str ());
700 if (! section)
701 {
702 if (required)
703 warning (_("Couldn't find %s registers in core file."),
704 human_name);
705 return;
706 }
707
708 size = bfd_section_size (section);
709 if (size < section_min_size)
710 {
711 warning (_("Section `%s' in core file too small."),
712 section_name.c_str ());
713 return;
714 }
715 if (size != section_min_size && !variable_size_section)
716 {
717 warning (_("Unexpected size of section `%s' in core file."),
718 section_name.c_str ());
719 }
720
721 gdb::byte_vector contents (size);
722 if (!bfd_get_section_contents (core_bfd, section, contents.data (),
723 (file_ptr) 0, size))
724 {
725 warning (_("Couldn't read %s registers from `%s' section in core file."),
726 human_name, section_name.c_str ());
727 return;
728 }
729
730 regset->supply_regset (regset, regcache, -1, contents.data (), size);
731}
732
733/* Data passed to gdbarch_iterate_over_regset_sections's callback. */
735{
738};
739
740/* Callback for get_core_registers that handles a single core file
741 register note section. */
742
743static void
744get_core_registers_cb (const char *sect_name, int supply_size, int collect_size,
745 const struct regset *regset,
746 const char *human_name, void *cb_data)
747{
748 gdb_assert (regset != nullptr);
749
750 auto *data = (get_core_registers_cb_data *) cb_data;
751 bool required = false;
752 bool variable_size_section = (regset->flags & REGSET_VARIABLE_SIZE);
753
754 if (!variable_size_section)
755 gdb_assert (supply_size == collect_size);
756
757 if (strcmp (sect_name, ".reg") == 0)
758 {
759 required = true;
760 if (human_name == NULL)
761 human_name = "general-purpose";
762 }
763 else if (strcmp (sect_name, ".reg2") == 0)
764 {
765 if (human_name == NULL)
766 human_name = "floating-point";
767 }
768
769 data->target->get_core_register_section (data->regcache, regset, sect_name,
770 supply_size, human_name, required);
771}
772
773/* Get the registers out of a core file. This is the machine-
774 independent part. Fetch_core_registers is the machine-dependent
775 part, typically implemented in the xm-file for each
776 architecture. */
777
778/* We just get all the registers, so we don't use regno. */
779
780void
782{
783 if (!(m_core_gdbarch != nullptr
785 {
787 "Can't fetch registers from this type of core file\n");
788 return;
789 }
790
791 struct gdbarch *gdbarch = regcache->arch ();
792 get_core_registers_cb_data data = { this, regcache };
795 (void *) &data, NULL);
796
797 /* Mark all registers not found in the core as unavailable. */
798 for (int i = 0; i < gdbarch_num_regs (regcache->arch ()); i++)
799 if (regcache->get_register_status (i) == REG_UNKNOWN)
800 regcache->raw_supply (i, NULL);
801}
802
803void
805{
807}
808
809/* Helper method for core_target::xfer_partial. */
810
813 const gdb_byte *writebuf,
814 ULONGEST offset, ULONGEST len,
815 ULONGEST *xfered_len)
816{
817 enum target_xfer_status xfer_status;
818
820 (readbuf, writebuf,
821 offset, len, xfered_len,
823
824 if (xfer_status == TARGET_XFER_OK || m_core_unavailable_mappings.empty ())
825 return xfer_status;
826
827 /* There are instances - e.g. when debugging within a docker
828 container using the AUFS storage driver - where the pathnames
829 obtained from the note section are incorrect. Despite the path
830 being wrong, just knowing the start and end addresses of the
831 mappings is still useful; we can attempt an access of the file
832 stratum constrained to the address ranges corresponding to the
833 unavailable mappings. */
834
835 ULONGEST memaddr = offset;
836 ULONGEST memend = offset + len;
837
838 for (const auto &mr : m_core_unavailable_mappings)
839 {
840 if (address_in_mem_range (memaddr, &mr))
841 {
842 if (!address_in_mem_range (memend, &mr))
843 len = mr.start + mr.length - memaddr;
844
845 xfer_status = this->beneath ()->xfer_partial (TARGET_OBJECT_MEMORY,
846 NULL,
847 readbuf,
848 writebuf,
849 offset,
850 len,
851 xfered_len);
852 break;
853 }
854 }
855
856 return xfer_status;
857}
858
860core_target::xfer_partial (enum target_object object, const char *annex,
861 gdb_byte *readbuf, const gdb_byte *writebuf,
862 ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
863{
864 switch (object)
865 {
867 {
868 enum target_xfer_status xfer_status;
869
870 /* Try accessing memory contents from core file data,
871 restricting consideration to those sections for which
872 the BFD section flag SEC_HAS_CONTENTS is set. */
873 auto has_contents_cb = [] (const struct target_section *s)
874 {
875 return ((s->the_bfd_section->flags & SEC_HAS_CONTENTS) != 0);
876 };
878 (readbuf, writebuf,
879 offset, len, xfered_len,
881 has_contents_cb);
882 if (xfer_status == TARGET_XFER_OK)
883 return TARGET_XFER_OK;
884
885 /* Check file backed mappings. If they're available, use
886 core file provided mappings (e.g. from .note.linuxcore.file
887 or the like) as this should provide a more accurate
888 result. If not, check the stratum beneath us, which should
889 be the file stratum.
890
891 We also check unavailable mappings due to Docker/AUFS driver
892 issues. */
893 if (!m_core_file_mappings.empty ()
894 || !m_core_unavailable_mappings.empty ())
895 {
896 xfer_status = xfer_memory_via_mappings (readbuf, writebuf, offset,
897 len, xfered_len);
898 }
899 else
900 xfer_status = this->beneath ()->xfer_partial (object, annex, readbuf,
901 writebuf, offset, len,
902 xfered_len);
903 if (xfer_status == TARGET_XFER_OK)
904 return TARGET_XFER_OK;
905
906 /* Finally, attempt to access data in core file sections with
907 no contents. These will typically read as all zero. */
908 auto no_contents_cb = [&] (const struct target_section *s)
909 {
910 return !has_contents_cb (s);
911 };
913 (readbuf, writebuf,
914 offset, len, xfered_len,
916 no_contents_cb);
917
918 return xfer_status;
919 }
921 if (readbuf)
922 {
923 /* When the aux vector is stored in core file, BFD
924 represents this with a fake section called ".auxv". */
925
926 struct bfd_section *section;
927 bfd_size_type size;
928
929 section = bfd_get_section_by_name (core_bfd, ".auxv");
930 if (section == NULL)
931 return TARGET_XFER_E_IO;
932
933 size = bfd_section_size (section);
934 if (offset >= size)
935 return TARGET_XFER_EOF;
936 size -= offset;
937 if (size > len)
938 size = len;
939
940 if (size == 0)
941 return TARGET_XFER_EOF;
942 if (!bfd_get_section_contents (core_bfd, section, readbuf,
943 (file_ptr) offset, size))
944 {
945 warning (_("Couldn't read NT_AUXV note in core file."));
946 return TARGET_XFER_E_IO;
947 }
948
949 *xfered_len = (ULONGEST) size;
950 return TARGET_XFER_OK;
951 }
952 return TARGET_XFER_E_IO;
953
955 if (readbuf)
956 {
957 /* When the StackGhost cookie is stored in core file, BFD
958 represents this with a fake section called
959 ".wcookie". */
960
961 struct bfd_section *section;
962 bfd_size_type size;
963
964 section = bfd_get_section_by_name (core_bfd, ".wcookie");
965 if (section == NULL)
966 return TARGET_XFER_E_IO;
967
968 size = bfd_section_size (section);
969 if (offset >= size)
970 return TARGET_XFER_EOF;
971 size -= offset;
972 if (size > len)
973 size = len;
974
975 if (size == 0)
976 return TARGET_XFER_EOF;
977 if (!bfd_get_section_contents (core_bfd, section, readbuf,
978 (file_ptr) offset, size))
979 {
980 warning (_("Couldn't read StackGhost cookie in core file."));
981 return TARGET_XFER_E_IO;
982 }
983
984 *xfered_len = (ULONGEST) size;
985 return TARGET_XFER_OK;
986
987 }
988 return TARGET_XFER_E_IO;
989
991 if (m_core_gdbarch != nullptr
993 {
994 if (writebuf)
995 return TARGET_XFER_E_IO;
996 else
997 {
999 readbuf,
1000 offset, len);
1001
1002 if (*xfered_len == 0)
1003 return TARGET_XFER_EOF;
1004 else
1005 return TARGET_XFER_OK;
1006 }
1007 }
1008 return TARGET_XFER_E_IO;
1009
1011 if (m_core_gdbarch != nullptr
1013 {
1014 if (writebuf)
1015 return TARGET_XFER_E_IO;
1016 else
1017 {
1018 *xfered_len
1020 readbuf, offset,
1021 len);
1022
1023 if (*xfered_len == 0)
1024 return TARGET_XFER_EOF;
1025 else
1026 return TARGET_XFER_OK;
1027 }
1028 }
1029 return TARGET_XFER_E_IO;
1030
1032 if (readbuf)
1033 {
1034 if (m_core_gdbarch != nullptr
1036 {
1037 LONGEST l = gdbarch_core_xfer_siginfo (m_core_gdbarch, readbuf,
1038 offset, len);
1039
1040 if (l >= 0)
1041 {
1042 *xfered_len = l;
1043 if (l == 0)
1044 return TARGET_XFER_EOF;
1045 else
1046 return TARGET_XFER_OK;
1047 }
1048 }
1049 }
1050 return TARGET_XFER_E_IO;
1051
1052 default:
1053 return this->beneath ()->xfer_partial (object, annex, readbuf,
1054 writebuf, offset, len,
1055 xfered_len);
1056 }
1057}
1058
1059
1060
1061/* Okay, let's be honest: threads gleaned from a core file aren't
1062 exactly lively, are they? On the other hand, if we don't claim
1063 that each & every one is alive, then we don't get any of them
1064 to appear in an "info thread" command, which is quite a useful
1065 behaviour.
1066 */
1067bool
1069{
1070 return true;
1071}
1072
1073/* Ask the current architecture what it knows about this core file.
1074 That will be used, in turn, to pick a better architecture. This
1075 wrapper could be avoided if targets got a chance to specialize
1076 core_target. */
1077
1078const struct target_desc *
1080{
1081 /* If the core file contains a target description note then we will use
1082 that in preference to anything else. */
1083 bfd_size_type tdesc_note_size = 0;
1084 struct bfd_section *tdesc_note_section
1085 = bfd_get_section_by_name (core_bfd, ".gdb-tdesc");
1086 if (tdesc_note_section != nullptr)
1087 tdesc_note_size = bfd_section_size (tdesc_note_section);
1088 if (tdesc_note_size > 0)
1089 {
1090 gdb::char_vector contents (tdesc_note_size + 1);
1091 if (bfd_get_section_contents (core_bfd, tdesc_note_section,
1092 contents.data (), (file_ptr) 0,
1093 tdesc_note_size))
1094 {
1095 /* Ensure we have a null terminator. */
1096 contents[tdesc_note_size] = '\0';
1097 const struct target_desc *result
1098 = string_read_description_xml (contents.data ());
1099 if (result != nullptr)
1100 return result;
1101 }
1102 }
1103
1105 {
1106 const struct target_desc *result;
1107
1109 if (result != NULL)
1110 return result;
1111 }
1112
1113 return this->beneath ()->read_description ();
1114}
1115
1116std::string
1118{
1119 struct inferior *inf;
1120 int pid;
1121
1122 /* The preferred way is to have a gdbarch/OS specific
1123 implementation. */
1124 if (m_core_gdbarch != nullptr
1127
1128 /* Otherwise, if we don't have one, we'll just fallback to
1129 "process", with normal_pid_to_str. */
1130
1131 /* Try the LWPID field first. */
1132 pid = ptid.lwp ();
1133 if (pid != 0)
1134 return normal_pid_to_str (ptid_t (pid));
1135
1136 /* Otherwise, this isn't a "threaded" core -- use the PID field, but
1137 only if it isn't a fake PID. */
1138 inf = find_inferior_ptid (this, ptid);
1139 if (inf != NULL && !inf->fake_pid_p)
1140 return normal_pid_to_str (ptid);
1141
1142 /* No luck. We simply don't have a valid PID to print. */
1143 return "<main task>";
1144}
1145
1146const char *
1148{
1149 if (m_core_gdbarch != nullptr
1152 return NULL;
1153}
1154
1155bool
1157{
1158 return (core_bfd != NULL);
1159}
1160
1161bool
1163{
1164 return (core_bfd != NULL);
1165}
1166
1167bool
1169{
1170 return (core_bfd != NULL);
1171}
1172
1173/* Implement the to_info_proc method. */
1174
1175bool
1176core_target::info_proc (const char *args, enum info_proc_what request)
1177{
1178 struct gdbarch *gdbarch = get_current_arch ();
1179
1180 /* Since this is the core file target, call the 'core_info_proc'
1181 method on gdbarch, not 'info_proc'. */
1183 gdbarch_core_info_proc (gdbarch, args, request);
1184
1185 return true;
1186}
1187
1188/* Implementation of the "supports_memory_tagging" target_ops method. */
1189
1190bool
1192{
1193 /* Look for memory tag sections. If they exist, that means this core file
1194 supports memory tagging. */
1195
1196 return (bfd_get_section_by_name (core_bfd, "memtag") != nullptr);
1197}
1198
1199/* Implementation of the "fetch_memtags" target_ops method. */
1200
1201bool
1202core_target::fetch_memtags (CORE_ADDR address, size_t len,
1203 gdb::byte_vector &tags, int type)
1204{
1205 struct gdbarch *gdbarch = target_gdbarch ();
1206
1207 /* Make sure we have a way to decode the memory tag notes. */
1209 error (_("gdbarch_decode_memtag_section not implemented for this "
1210 "architecture."));
1211
1213 info.memtag_section = nullptr;
1214
1215 while (get_next_core_memtag_section (core_bfd, info.memtag_section,
1216 address, info))
1217 {
1218 size_t adjusted_length
1219 = (address + len < info.end_address) ? len : (info.end_address - address);
1220
1221 /* Decode the memory tag note and return the tags. */
1222 gdb::byte_vector tags_read
1223 = gdbarch_decode_memtag_section (gdbarch, info.memtag_section, type,
1224 address, adjusted_length);
1225
1226 /* Transfer over the tags that have been read. */
1227 tags.insert (tags.end (), tags_read.begin (), tags_read.end ());
1228
1229 /* ADDRESS + LEN may cross the boundaries of a particular memory tag
1230 segment. Check if we need to fetch tags from a different section. */
1231 if (!tags_read.empty () && (address + len) < info.end_address)
1232 return true;
1233
1234 /* There are more tags to fetch. Update ADDRESS and LEN. */
1235 len -= (info.end_address - address);
1236 address = info.end_address;
1237 }
1238
1239 return false;
1240}
1241
1242/* Get a pointer to the current core target. If not connected to a
1243 core target, return NULL. */
1244
1245static core_target *
1247{
1248 target_ops *proc_target = current_inferior ()->process_target ();
1249 return dynamic_cast<core_target *> (proc_target);
1250}
1251
1252/* Display file backed mappings from core file. */
1253
1254void
1256{
1257 if (!m_core_file_mappings.empty ())
1258 {
1259 gdb_printf (_("Mapped address spaces:\n\n"));
1260 if (gdbarch_addr_bit (gdbarch) == 32)
1261 {
1262 gdb_printf ("\t%10s %10s %10s %10s %s\n",
1263 "Start Addr",
1264 " End Addr",
1265 " Size", " Offset", "objfile");
1266 }
1267 else
1268 {
1269 gdb_printf (" %18s %18s %10s %10s %s\n",
1270 "Start Addr",
1271 " End Addr",
1272 " Size", " Offset", "objfile");
1273 }
1274 }
1275
1276 for (const target_section &tsp : m_core_file_mappings)
1277 {
1278 ULONGEST start = tsp.addr;
1279 ULONGEST end = tsp.endaddr;
1280 ULONGEST file_ofs = tsp.the_bfd_section->filepos;
1281 const char *filename = bfd_get_filename (tsp.the_bfd_section->owner);
1282
1283 if (gdbarch_addr_bit (gdbarch) == 32)
1284 gdb_printf ("\t%10s %10s %10s %10s %s\n",
1285 paddress (gdbarch, start),
1286 paddress (gdbarch, end),
1287 hex_string (end - start),
1288 hex_string (file_ofs),
1289 filename);
1290 else
1291 gdb_printf (" %18s %18s %10s %10s %s\n",
1292 paddress (gdbarch, start),
1293 paddress (gdbarch, end),
1294 hex_string (end - start),
1295 hex_string (file_ofs),
1296 filename);
1297 }
1298}
1299
1300/* Implement "maintenance print core-file-backed-mappings" command.
1301
1302 If mappings are loaded, the results should be similar to the
1303 mappings shown by "info proc mappings". This command is mainly a
1304 debugging tool for GDB developers to make sure that the expected
1305 mappings are present after loading a core file. For Linux, the
1306 output provided by this command will be very similar (if not
1307 identical) to that provided by "info proc mappings". This is not
1308 necessarily the case for other OSes which might provide
1309 more/different information in the "info proc mappings" output. */
1310
1311static void
1312maintenance_print_core_file_backed_mappings (const char *args, int from_tty)
1313{
1315 if (targ != nullptr)
1316 targ->info_proc_mappings (targ->core_gdbarch ());
1317}
1318
1319void _initialize_corelow ();
1320void
1322{
1324 add_cmd ("core-file-backed-mappings", class_maintenance,
1326 _("Print core file's file-backed mappings."),
1328}
const char *const name
Definition: aarch64-tdep.c:67
struct gdbarch * gdbarch_from_bfd(bfd *abfd)
Definition: arch-utils.c:637
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:846
void set_gdbarch_from_file(bfd *abfd)
Definition: arch-utils.c:649
struct gdbarch * target_gdbarch(void)
Definition: arch-utils.c:1453
struct gdbarch * gdbarch_find_by_info(struct gdbarch_info info)
Definition: arch-utils.c:1321
int build_id_verify(bfd *abfd, size_t check_len, const bfd_byte *check)
Definition: build-id.c:49
gdb_bfd_ref_ptr build_id_to_exec_bfd(size_t build_id_len, const bfd_byte *build_id)
Definition: build-id.c:197
const struct bfd_build_id * build_id_bfd_get(bfd *abfd)
Definition: build-id.c:33
std::string pid_to_str(ptid_t) override
Definition: corelow.c:1117
bool has_all_memory() override
Definition: corelow.c:97
bool supports_memory_tagging() override
Definition: corelow.c:1191
void build_file_mappings()
Definition: corelow.c:212
void fetch_registers(struct regcache *, int) override
Definition: corelow.c:781
enum target_xfer_status xfer_partial(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override
Definition: corelow.c:860
void get_core_register_section(struct regcache *regcache, const struct regset *regset, const char *name, int section_min_size, const char *human_name, bool required)
Definition: corelow.c:684
bool has_stack() override
Definition: corelow.c:1162
void detach(inferior *, int) override
Definition: corelow.c:649
bool thread_alive(ptid_t ptid) override
Definition: corelow.c:1068
bool has_execution(inferior *inf) override
Definition: corelow.c:101
const struct target_desc * read_description() override
Definition: corelow.c:1079
void close() override
Definition: corelow.c:342
enum target_xfer_status xfer_memory_via_mappings(gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
Definition: corelow.c:812
target_section_table m_core_file_mappings
Definition: corelow.c:146
const target_info & info() const override
Definition: corelow.c:75
bool fetch_memtags(CORE_ADDR address, size_t len, gdb::byte_vector &tags, int type) override
Definition: corelow.c:1202
void files_info() override
Definition: corelow.c:804
const char * thread_name(struct thread_info *) override
Definition: corelow.c:1147
bool has_registers() override
Definition: corelow.c:1168
void info_proc_mappings(struct gdbarch *gdbarch)
Definition: corelow.c:1255
target_section_table m_core_section_table
Definition: corelow.c:142
void clear_core()
Definition: corelow.c:323
core_target()
Definition: corelow.c:168
std::vector< mem_range > m_core_unavailable_mappings
Definition: corelow.c:151
bool info_proc(const char *, enum info_proc_what) override
Definition: corelow.c:1176
struct gdbarch * m_core_gdbarch
Definition: corelow.c:165
struct gdbarch * core_gdbarch()
Definition: corelow.c:115
bool has_memory() override
Definition: corelow.c:1156
bool fake_pid_p
Definition: inferior.h:528
void push_target(struct target_ops *t)
Definition: inferior.h:376
struct process_stratum_target * process_target()
Definition: inferior.h:419
const std::string & args() const
Definition: inferior.h:498
gdbarch * arch() const
Definition: regcache.c:230
void raw_supply(int regnum, const void *buf) override
Definition: regcache.c:1053
enum register_status get_register_status(int regnum) const override
Definition: regcache.c:303
ptid_t ptid() const
Definition: regcache.h:407
const char * c_str() const
Definition: gdbcore.h:194
struct cmd_list_element * maintenanceprintlist
Definition: cli-cmds.c:149
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition: cli-decode.c:233
void dont_repeat()
Definition: top.c:809
@ class_maintenance
Definition: command.h:65
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition: completer.c:204
void validate_files(void)
Definition: corefile.c:133
const char * gnutarget
Definition: corefile.c:394
#define CORELOW_PID
Definition: corelow.c:320
#define O_LARGEFILE
Definition: corelow.c:58
static void add_to_thread_list(asection *asect, asection *reg_sect)
Definition: corelow.c:355
void _initialize_corelow()
Definition: corelow.c:1321
static void get_core_registers_cb(const char *sect_name, int supply_size, int collect_size, const struct regset *regset, const char *human_name, void *cb_data)
Definition: corelow.c:744
static const target_info core_target_info
Definition: corelow.c:63
static void maybe_say_no_core_file_now(int from_tty)
Definition: corelow.c:397
void core_file_command(const char *filename, int from_tty)
Definition: corelow.c:406
void core_target_open(const char *arg, int from_tty)
Definition: corelow.c:469
static void locate_exec_from_corefile_build_id(bfd *abfd, int from_tty)
Definition: corelow.c:428
static core_target * get_current_core_target()
Definition: corelow.c:1246
static void maintenance_print_core_file_backed_mappings(const char *args, int from_tty)
Definition: corelow.c:1312
scoped_fd debuginfod_exec_query(const unsigned char *build_id, int build_id_len, const char *filename, gdb::unique_xmalloc_ptr< char > *destname)
#define O_BINARY
Definition: defs.h:116
info_proc_what
Definition: defs.h:381
void exception_print(struct ui_file *file, const struct gdb_exception &e)
Definition: exceptions.c:105
bool write_files
Definition: exec.c:133
enum target_xfer_status section_table_xfer_memory_partial(gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len, const target_section_table &sections, gdb::function_view< bool(const struct target_section *)> match_cb)
Definition: exec.c:812
target_section_table build_section_table(struct bfd *some_bfd)
Definition: exec.c:563
void exec_file_attach(const char *filename, int from_tty)
Definition: exec.c:365
void print_section_info(const target_section_table *t, bfd *abfd)
Definition: exec.c:903
void reinit_frame_cache(void)
Definition: frame.c:2006
frame_info_ptr get_selected_frame(const char *message)
Definition: frame.c:1813
@ SRC_AND_LOC
Definition: frame.h:594
void print_stack_frame(frame_info_ptr, int print_level, enum print_what print_what, int set_current_sal)
Definition: stack.c:356
gdb_bfd_ref_ptr gdb_bfd_fopen(const char *filename, const char *target, const char *mode, int fd)
Definition: gdb_bfd.c:875
std::string gdb_bfd_errmsg(bfd_error_type error_tag, char **matching)
Definition: gdb_bfd.c:1048
void gdb_bfd_record_inclusion(bfd *includer, bfd *includee)
Definition: gdb_bfd.c:965
gdb_bfd_ref_ptr gdb_bfd_open(const char *name, const char *target, int fd, bool warn_if_slow)
Definition: gdb_bfd.c:491
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
Definition: gdb_bfd.h:78
static gdb_bfd_section_range gdb_bfd_sections(bfd *abfd)
Definition: gdb_bfd.h:222
LONGEST gdbarch_core_xfer_siginfo(struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: gdbarch.c:3892
bool gdbarch_core_info_proc_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:4948
ULONGEST gdbarch_core_xfer_shared_libraries_aix(struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: gdbarch.c:3820
void gdbarch_iterate_over_regset_sections(struct gdbarch *gdbarch, iterate_over_regset_sections_cb *cb, void *cb_data, const struct regcache *regcache)
Definition: gdbarch.c:3652
bool gdbarch_decode_memtag_section_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3765
const char * gdbarch_core_thread_name(struct gdbarch *gdbarch, struct thread_info *thr)
Definition: gdbarch.c:3868
int gdbarch_addr_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1708
const struct target_desc * gdbarch_core_read_description(struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd)
Definition: gdbarch.c:4214
ULONGEST gdbarch_core_xfer_shared_libraries(struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
Definition: gdbarch.c:3796
int gdbarch_num_regs(struct gdbarch *gdbarch)
Definition: gdbarch.c:1899
bool gdbarch_core_thread_name_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3861
bool gdbarch_core_read_description_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:4207
void gdbarch_report_signal_info(struct gdbarch *gdbarch, struct ui_out *uiout, enum gdb_signal siggnal)
Definition: gdbarch.c:1989
bool gdbarch_report_signal_info_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:1982
bool gdbarch_gdb_signal_from_target_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:4296
bool gdbarch_core_xfer_siginfo_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3885
enum gdb_signal gdbarch_gdb_signal_from_target(struct gdbarch *gdbarch, int signo)
Definition: gdbarch.c:4303
bool gdbarch_core_xfer_shared_libraries_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3789
bool gdbarch_iterate_over_regset_sections_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3645
void gdbarch_core_info_proc(struct gdbarch *gdbarch, const char *args, enum info_proc_what what)
Definition: gdbarch.c:4955
bool gdbarch_core_xfer_shared_libraries_aix_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3813
bool gdbarch_core_pid_to_str_p(struct gdbarch *gdbarch)
Definition: gdbarch.c:3837
void gdbarch_read_core_file_mappings(struct gdbarch *gdbarch, struct bfd *cbfd, read_core_file_mappings_pre_loop_ftype pre_loop_cb, read_core_file_mappings_loop_ftype loop_cb)
Definition: gdbarch.c:5302
gdb::byte_vector gdbarch_decode_memtag_section(struct gdbarch *gdbarch, bfd_section *section, int type, CORE_ADDR address, size_t length)
Definition: gdbarch.c:3772
std::string gdbarch_core_pid_to_str(struct gdbarch *gdbarch, ptid_t ptid)
Definition: gdbarch.c:3844
#define core_bfd
Definition: gdbcore.h:130
struct thread_info * add_thread(process_stratum_target *targ, ptid_t ptid)
Definition: thread.c:303
int thread_count(process_stratum_target *proc_target)
Definition: thread.c:586
struct thread_info * add_thread_silent(process_stratum_target *targ, ptid_t ptid)
Definition: thread.c:263
struct thread_info * first_thread_of_inferior(inferior *inf)
Definition: thread.c:620
void switch_to_thread(struct thread_info *thr)
Definition: thread.c:1335
void thread_command(const char *tidstr, int from_tty)
Definition: thread.c:1811
void switch_to_no_thread()
Definition: thread.c:1320
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
Definition: gnu-nat.c:1862
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
Definition: gnu-nat.c:1792
size_t size
Definition: go32-nat.c:241
ptid_t inferior_ptid
Definition: infcmd.c:91
void post_create_inferior(int from_tty)
Definition: infcmd.c:241
void inferior_appeared(struct inferior *inf, int pid)
Definition: inferior.c:322
struct inferior * find_inferior_ptid(process_stratum_target *targ, ptid_t ptid)
Definition: inferior.c:365
struct inferior * current_inferior(void)
Definition: inferior.c:54
void exit_inferior_silent(inferior *inf)
Definition: inferior.c:300
void clear_exit_convenience_vars(void)
Definition: infrun.c:9440
int address_in_mem_range(CORE_ADDR address, const struct mem_range *r)
Definition: memrange.c:38
void normalize_mem_ranges(std::vector< mem_range > *memory)
Definition: memrange.c:45
bool get_next_core_memtag_section(bfd *abfd, asection *section, CORE_ADDR address, memtag_section_info &info)
Definition: memtag.c:27
struct program_space * current_program_space
Definition: progspace.c:39
struct regcache * get_current_regcache(void)
Definition: regcache.c:426
void registers_changed(void)
Definition: regcache.c:577
#define REGSET_VARIABLE_SIZE
Definition: regset.h:52
void set_cbfd_soname_build_id(gdb_bfd_ref_ptr abfd, const char *soname, const bfd_build_id *build_id)
Definition: solib.c:499
gdb::unique_xmalloc_ptr< char > exec_file_find(const char *in_pathname, int *fd)
Definition: solib.c:340
void clear_solib(void)
Definition: solib.c:1220
gdb::unique_xmalloc_ptr< char > gdb_bfd_read_elf_soname(const char *filename)
Definition: solib.c:1638
core_target * target
Definition: corelow.c:736
struct regcache * regcache
Definition: corelow.c:737
Definition: gnu-nat.c:154
pid_t pid
Definition: gnu-nat.c:166
bfd * exec_bfd() const
Definition: progspace.h:264
gdb_bfd_ref_ptr cbfd
Definition: progspace.h:324
Definition: regset.h:35
unsigned flags
Definition: regset.h:47
supply_regset_ftype * supply_regset
Definition: regset.h:42
target_ops * beneath() const
Definition: target.c:3020
virtual enum target_xfer_status xfer_partial(enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
virtual const struct target_desc * read_description() TARGET_DEFAULT_RETURN(NULL)
Definition: gdbtypes.h:922
symfile_add_flag
@ SYMFILE_VERBOSE
void symbol_file_add_main(const char *args, symfile_add_flags add_flags)
Definition: symfile.c:1194
std::vector< target_section > target_section_table
void target_detach(inferior *inf, int from_tty)
Definition: target.c:2512
void target_fetch_registers(struct regcache *regcache, int regno)
Definition: target.c:3921
void target_update_thread_list(void)
Definition: target.c:3769
void add_target(const target_info &t, target_open_ftype *func, completer_ftype *completer)
Definition: target.c:863
std::string normal_pid_to_str(ptid_t ptid)
Definition: target.c:3672
void target_preopen(int from_tty)
Definition: target.c:2479
target_xfer_status
Definition: target.h:214
@ TARGET_XFER_E_IO
Definition: target.h:227
@ TARGET_XFER_EOF
Definition: target.h:219
@ TARGET_XFER_OK
Definition: target.h:216
target_object
Definition: target.h:138
@ TARGET_OBJECT_LIBRARIES_AIX
Definition: target.h:175
@ TARGET_OBJECT_AUXV
Definition: target.h:157
@ TARGET_OBJECT_SIGNAL_INFO
Definition: target.h:182
@ TARGET_OBJECT_MEMORY
Definition: target.h:142
@ TARGET_OBJECT_WCOOKIE
Definition: target.h:159
@ TARGET_OBJECT_LIBRARIES
Definition: target.h:171
std::unique_ptr< target_ops, target_ops_deleter > target_ops_up
Definition: target.h:1338
#define current_uiout
Definition: ui-out.h:40
void perror_with_name(const char *string)
Definition: utils.c:643
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition: utils.c:3114
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition: utils.c:1865
#define gdb_stderr
Definition: utils.h:193
struct internalvar * lookup_internalvar(const char *name)
Definition: value.c:2235
void set_internalvar_integer(struct internalvar *var, LONGEST l)
Definition: value.c:2465
const struct target_desc * string_read_description_xml(const char *xml)
Definition: xml-tdesc.c:763