1 /* Core dump and executable file functions below target vector, for GDB.
3 Copyright (C) 1986-2019 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
22 /* Standard C includes. */
26 /* Local non-gdb includes. */
27 #include "arch-utils.h"
30 #include "common/filestuff.h"
31 #include "completer.h"
33 #include "filenames.h"
37 #include "gdbthread.h"
41 #include "process-stratum-target.h"
42 #include "progspace.h"
43 #include "readline/readline.h"
55 static core_fns
*sniff_core_bfd (gdbarch
*core_gdbarch
,
58 /* The core file target. */
60 static const target_info core_target_info
= {
62 N_("Local core dump file"),
63 N_("Use a core file as a target. Specify the filename of the core file.")
66 class core_target final
: public process_stratum_target
70 ~core_target () override
;
72 const target_info
&info () const override
73 { return core_target_info
; }
75 void close () override
;
76 void detach (inferior
*, int) override
;
77 void fetch_registers (struct regcache
*, int) override
;
79 enum target_xfer_status
xfer_partial (enum target_object object
,
82 const gdb_byte
*writebuf
,
83 ULONGEST offset
, ULONGEST len
,
84 ULONGEST
*xfered_len
) override
;
85 void files_info () override
;
87 bool thread_alive (ptid_t ptid
) override
;
88 const struct target_desc
*read_description () override
;
90 std::string
pid_to_str (ptid_t
) override
;
92 const char *thread_name (struct thread_info
*) override
;
94 bool has_all_memory () override
{ return false; }
95 bool has_memory () override
;
96 bool has_stack () override
;
97 bool has_registers () override
;
98 bool has_execution (ptid_t
) override
{ return false; }
100 bool info_proc (const char *, enum info_proc_what
) override
;
104 /* Getter, see variable definition. */
105 struct gdbarch
*core_gdbarch ()
107 return m_core_gdbarch
;
110 /* See definition. */
111 void get_core_register_section (struct regcache
*regcache
,
112 const struct regset
*regset
,
114 int section_min_size
,
116 const char *human_name
,
119 private: /* per-core data */
121 /* The core's section table. Note that these target sections are
122 *not* mapped in the current address spaces' set of target
123 sections --- those should come only from pure executable or
124 shared library bfds. The core bfd sections are an implementation
125 detail of the core target, just like ptrace is for unix child
127 target_section_table m_core_section_table
{};
129 /* The core_fns for a core file handler that is prepared to read the
130 core file currently open on core_bfd. */
131 core_fns
*m_core_vec
= NULL
;
133 /* FIXME: kettenis/20031023: Eventually this field should
135 struct gdbarch
*m_core_gdbarch
= NULL
;
138 core_target::core_target ()
140 m_core_gdbarch
= gdbarch_from_bfd (core_bfd
);
142 /* Find a suitable core file handler to munch on core_bfd */
143 m_core_vec
= sniff_core_bfd (m_core_gdbarch
, core_bfd
);
145 /* Find the data section */
146 if (build_section_table (core_bfd
,
147 &m_core_section_table
.sections
,
148 &m_core_section_table
.sections_end
))
149 error (_("\"%s\": Can't find sections: %s"),
150 bfd_get_filename (core_bfd
), bfd_errmsg (bfd_get_error ()));
153 core_target::~core_target ()
155 xfree (m_core_section_table
.sections
);
158 /* List of all available core_fns. On gdb startup, each core file
159 register reader calls deprecated_add_core_fns() to register
160 information on each core format it is prepared to read. */
162 static struct core_fns
*core_file_fns
= NULL
;
164 static int gdb_check_format (bfd
*);
166 static void add_to_thread_list (bfd
*, asection
*, void *);
168 /* An arbitrary identifier for the core inferior. */
169 #define CORELOW_PID 1
171 /* Link a new core_fns into the global core_file_fns list. Called on
172 gdb startup by the _initialize routine in each core file register
173 reader, to register information about each format the reader is
174 prepared to handle. */
177 deprecated_add_core_fns (struct core_fns
*cf
)
179 cf
->next
= core_file_fns
;
183 /* The default function that core file handlers can use to examine a
184 core file BFD and decide whether or not to accept the job of
185 reading the core file. */
188 default_core_sniffer (struct core_fns
*our_fns
, bfd
*abfd
)
192 result
= (bfd_get_flavour (abfd
) == our_fns
-> core_flavour
);
196 /* Walk through the list of core functions to find a set that can
197 handle the core file open on ABFD. Returns pointer to set that is
200 static struct core_fns
*
201 sniff_core_bfd (struct gdbarch
*core_gdbarch
, bfd
*abfd
)
204 struct core_fns
*yummy
= NULL
;
207 /* Don't sniff if we have support for register sets in
209 if (core_gdbarch
&& gdbarch_iterate_over_regset_sections_p (core_gdbarch
))
212 for (cf
= core_file_fns
; cf
!= NULL
; cf
= cf
->next
)
214 if (cf
->core_sniffer (cf
, abfd
))
222 warning (_("\"%s\": ambiguous core format, %d handlers match"),
223 bfd_get_filename (abfd
), matches
);
225 else if (matches
== 0)
226 error (_("\"%s\": no core file handler recognizes format"),
227 bfd_get_filename (abfd
));
232 /* The default is to reject every core file format we see. Either
233 BFD has to recognize it, or we have to provide a function in the
234 core file handler that recognizes it. */
237 default_check_format (bfd
*abfd
)
242 /* Attempt to recognize core file formats that BFD rejects. */
245 gdb_check_format (bfd
*abfd
)
249 for (cf
= core_file_fns
; cf
!= NULL
; cf
= cf
->next
)
251 if (cf
->check_format (abfd
))
259 /* Close the core target. */
262 core_target::close ()
266 inferior_ptid
= null_ptid
; /* Avoid confusion from thread
268 exit_inferior_silent (current_inferior ());
270 /* Clear out solib state while the bfd is still open. See
271 comments in clear_solib in solib.c. */
274 current_program_space
->cbfd
.reset (nullptr);
277 /* Core targets are heap-allocated (see core_target_open), so here
278 we delete ourselves. */
282 /* Look for sections whose names start with `.reg/' so that we can
283 extract the list of threads in a core file. */
286 add_to_thread_list (bfd
*abfd
, asection
*asect
, void *reg_sect_arg
)
291 asection
*reg_sect
= (asection
*) reg_sect_arg
;
293 struct inferior
*inf
;
295 if (!startswith (bfd_section_name (abfd
, asect
), ".reg/"))
298 core_tid
= atoi (bfd_section_name (abfd
, asect
) + 5);
300 pid
= bfd_core_file_pid (core_bfd
);
309 inf
= current_inferior ();
312 inferior_appeared (inf
, pid
);
313 inf
->fake_pid_p
= fake_pid_p
;
316 ptid
= ptid_t (pid
, lwpid
, 0);
320 /* Warning, Will Robinson, looking at BFD private data! */
323 && asect
->filepos
== reg_sect
->filepos
) /* Did we find .reg? */
324 inferior_ptid
= ptid
; /* Yes, make it current. */
327 /* Issue a message saying we have no core to debug, if FROM_TTY. */
330 maybe_say_no_core_file_now (int from_tty
)
333 printf_filtered (_("No core file now.\n"));
336 /* Backward compatability with old way of specifying core files. */
339 core_file_command (const char *filename
, int from_tty
)
341 dont_repeat (); /* Either way, seems bogus. */
343 if (filename
== NULL
)
345 if (core_bfd
!= NULL
)
347 target_detach (current_inferior (), from_tty
);
348 gdb_assert (core_bfd
== NULL
);
351 maybe_say_no_core_file_now (from_tty
);
354 core_target_open (filename
, from_tty
);
360 core_target_open (const char *arg
, int from_tty
)
367 target_preopen (from_tty
);
371 error (_("No core file specified. (Use `detach' "
372 "to stop debugging a core file.)"));
374 error (_("No core file specified."));
377 gdb::unique_xmalloc_ptr
<char> filename (tilde_expand (arg
));
378 if (!IS_ABSOLUTE_PATH (filename
.get ()))
379 filename
.reset (concat (current_directory
, "/",
380 filename
.get (), (char *) NULL
));
382 flags
= O_BINARY
| O_LARGEFILE
;
387 scratch_chan
= gdb_open_cloexec (filename
.get (), flags
, 0);
388 if (scratch_chan
< 0)
389 perror_with_name (filename
.get ());
391 gdb_bfd_ref_ptr
temp_bfd (gdb_bfd_fopen (filename
.get (), gnutarget
,
392 write_files
? FOPEN_RUB
: FOPEN_RB
,
394 if (temp_bfd
== NULL
)
395 perror_with_name (filename
.get ());
397 if (!bfd_check_format (temp_bfd
.get (), bfd_core
)
398 && !gdb_check_format (temp_bfd
.get ()))
400 /* Do it after the err msg */
401 /* FIXME: should be checking for errors from bfd_close (for one
402 thing, on error it does not free all the storage associated
404 error (_("\"%s\" is not a core dump: %s"),
405 filename
.get (), bfd_errmsg (bfd_get_error ()));
408 current_program_space
->cbfd
= std::move (temp_bfd
);
410 core_target
*target
= new core_target ();
412 /* Own the target until it is successfully pushed. */
413 target_ops_up
target_holder (target
);
417 /* If we have no exec file, try to set the architecture from the
418 core file. We don't do this unconditionally since an exec file
419 typically contains more information that helps us determine the
420 architecture than a core file. */
422 set_gdbarch_from_file (core_bfd
);
424 push_target (std::move (target_holder
));
426 inferior_ptid
= null_ptid
;
428 /* Need to flush the register cache (and the frame cache) from a
429 previous debug session. If inferior_ptid ends up the same as the
430 last debug session --- e.g., b foo; run; gcore core1; step; gcore
431 core2; core core1; core core2 --- then there's potential for
432 get_current_regcache to return the cached regcache of the
433 previous session, and the frame cache being stale. */
434 registers_changed ();
436 /* Build up thread list from BFD sections, and possibly set the
437 current thread to the .reg/NN section matching the .reg
439 bfd_map_over_sections (core_bfd
, add_to_thread_list
,
440 bfd_get_section_by_name (core_bfd
, ".reg"));
442 if (inferior_ptid
== null_ptid
)
444 /* Either we found no .reg/NN section, and hence we have a
445 non-threaded core (single-threaded, from gdb's perspective),
446 or for some reason add_to_thread_list couldn't determine
447 which was the "main" thread. The latter case shouldn't
448 usually happen, but we're dealing with input here, which can
449 always be broken in different ways. */
450 thread_info
*thread
= first_thread_of_inferior (current_inferior ());
454 inferior_appeared (current_inferior (), CORELOW_PID
);
455 inferior_ptid
= ptid_t (CORELOW_PID
);
456 add_thread_silent (inferior_ptid
);
459 switch_to_thread (thread
);
462 post_create_inferior (target
, from_tty
);
464 /* Now go through the target stack looking for threads since there
465 may be a thread_stratum target loaded on top of target core by
466 now. The layer above should claim threads found in the BFD
470 target_update_thread_list ();
473 CATCH (except
, RETURN_MASK_ERROR
)
475 exception_print (gdb_stderr
, except
);
479 p
= bfd_core_file_failing_command (core_bfd
);
481 printf_filtered (_("Core was generated by `%s'.\n"), p
);
483 /* Clearing any previous state of convenience variables. */
484 clear_exit_convenience_vars ();
486 siggy
= bfd_core_file_failing_signal (core_bfd
);
489 gdbarch
*core_gdbarch
= target
->core_gdbarch ();
491 /* If we don't have a CORE_GDBARCH to work with, assume a native
492 core (map gdb_signal from host signals). If we do have
493 CORE_GDBARCH to work with, but no gdb_signal_from_target
494 implementation for that gdbarch, as a fallback measure,
495 assume the host signal mapping. It'll be correct for native
496 cores, but most likely incorrect for cross-cores. */
497 enum gdb_signal sig
= (core_gdbarch
!= NULL
498 && gdbarch_gdb_signal_from_target_p (core_gdbarch
)
499 ? gdbarch_gdb_signal_from_target (core_gdbarch
,
501 : gdb_signal_from_host (siggy
));
503 printf_filtered (_("Program terminated with signal %s, %s.\n"),
504 gdb_signal_to_name (sig
), gdb_signal_to_string (sig
));
506 /* Set the value of the internal variable $_exitsignal,
507 which holds the signal uncaught by the inferior. */
508 set_internalvar_integer (lookup_internalvar ("_exitsignal"),
512 /* Fetch all registers from core file. */
513 target_fetch_registers (get_current_regcache (), -1);
515 /* Now, set up the frame cache, and print the top of stack. */
516 reinit_frame_cache ();
517 print_stack_frame (get_selected_frame (NULL
), 1, SRC_AND_LOC
, 1);
519 /* Current thread should be NUM 1 but the user does not know that.
520 If a program is single threaded gdb in general does not mention
521 anything about threads. That is why the test is >= 2. */
522 if (thread_count () >= 2)
526 thread_command (NULL
, from_tty
);
528 CATCH (except
, RETURN_MASK_ERROR
)
530 exception_print (gdb_stderr
, except
);
537 core_target::detach (inferior
*inf
, int from_tty
)
539 /* Note that 'this' is dangling after this call. unpush_target
540 closes the target, and our close implementation deletes
542 unpush_target (this);
544 reinit_frame_cache ();
545 maybe_say_no_core_file_now (from_tty
);
548 /* Try to retrieve registers from a section in core_bfd, and supply
549 them to m_core_vec->core_read_registers, as the register set
552 If ptid's lwp member is zero, do the single-threaded
553 thing: look for a section named NAME. If ptid's lwp
554 member is non-zero, do the multi-threaded thing: look for a section
555 named "NAME/LWP", where LWP is the shortest ASCII decimal
556 representation of ptid's lwp member.
558 HUMAN_NAME is a human-readable name for the kind of registers the
559 NAME section contains, for use in error messages.
561 If REQUIRED is true, print an error if the core file doesn't have a
562 section by the appropriate name. Otherwise, just do nothing. */
565 core_target::get_core_register_section (struct regcache
*regcache
,
566 const struct regset
*regset
,
568 int section_min_size
,
570 const char *human_name
,
573 struct bfd_section
*section
;
576 bool variable_size_section
= (regset
!= NULL
577 && regset
->flags
& REGSET_VARIABLE_SIZE
);
579 thread_section_name
section_name (name
, regcache
->ptid ());
581 section
= bfd_get_section_by_name (core_bfd
, section_name
.c_str ());
585 warning (_("Couldn't find %s registers in core file."),
590 size
= bfd_section_size (core_bfd
, section
);
591 if (size
< section_min_size
)
593 warning (_("Section `%s' in core file too small."),
594 section_name
.c_str ());
597 if (size
!= section_min_size
&& !variable_size_section
)
599 warning (_("Unexpected size of section `%s' in core file."),
600 section_name
.c_str ());
603 contents
= (char *) alloca (size
);
604 if (! bfd_get_section_contents (core_bfd
, section
, contents
,
607 warning (_("Couldn't read %s registers from `%s' section in core file."),
608 human_name
, section_name
.c_str ());
614 regset
->supply_regset (regset
, regcache
, -1, contents
, size
);
618 gdb_assert (m_core_vec
!= nullptr);
619 m_core_vec
->core_read_registers (regcache
, contents
, size
, which
,
621 bfd_section_vma (core_bfd
, section
)));
624 /* Data passed to gdbarch_iterate_over_regset_sections's callback. */
625 struct get_core_registers_cb_data
628 struct regcache
*regcache
;
631 /* Callback for get_core_registers that handles a single core file
632 register note section. */
635 get_core_registers_cb (const char *sect_name
, int supply_size
, int collect_size
,
636 const struct regset
*regset
,
637 const char *human_name
, void *cb_data
)
639 auto *data
= (get_core_registers_cb_data
*) cb_data
;
640 bool required
= false;
641 bool variable_size_section
= (regset
!= NULL
642 && regset
->flags
& REGSET_VARIABLE_SIZE
);
644 if (!variable_size_section
)
645 gdb_assert (supply_size
== collect_size
);
647 if (strcmp (sect_name
, ".reg") == 0)
650 if (human_name
== NULL
)
651 human_name
= "general-purpose";
653 else if (strcmp (sect_name
, ".reg2") == 0)
655 if (human_name
== NULL
)
656 human_name
= "floating-point";
659 /* The 'which' parameter is only used when no regset is provided.
660 Thus we just set it to -1. */
661 data
->target
->get_core_register_section (data
->regcache
, regset
, sect_name
,
662 supply_size
, -1, human_name
,
666 /* Get the registers out of a core file. This is the machine-
667 independent part. Fetch_core_registers is the machine-dependent
668 part, typically implemented in the xm-file for each
671 /* We just get all the registers, so we don't use regno. */
674 core_target::fetch_registers (struct regcache
*regcache
, int regno
)
677 struct gdbarch
*gdbarch
;
679 if (!(m_core_gdbarch
!= nullptr
680 && gdbarch_iterate_over_regset_sections_p (m_core_gdbarch
))
681 && (m_core_vec
== NULL
|| m_core_vec
->core_read_registers
== NULL
))
683 fprintf_filtered (gdb_stderr
,
684 "Can't fetch registers from this type of core file\n");
688 gdbarch
= regcache
->arch ();
689 if (gdbarch_iterate_over_regset_sections_p (gdbarch
))
691 get_core_registers_cb_data data
= { this, regcache
};
692 gdbarch_iterate_over_regset_sections (gdbarch
,
693 get_core_registers_cb
,
694 (void *) &data
, NULL
);
698 get_core_register_section (regcache
, NULL
,
699 ".reg", 0, 0, "general-purpose", 1);
700 get_core_register_section (regcache
, NULL
,
701 ".reg2", 0, 2, "floating-point", 0);
704 /* Mark all registers not found in the core as unavailable. */
705 for (i
= 0; i
< gdbarch_num_regs (regcache
->arch ()); i
++)
706 if (regcache
->get_register_status (i
) == REG_UNKNOWN
)
707 regcache
->raw_supply (i
, NULL
);
711 core_target::files_info ()
713 print_section_info (&m_core_section_table
, core_bfd
);
726 add_to_spuid_list (bfd
*abfd
, asection
*asect
, void *list_p
)
728 struct spuid_list
*list
= (struct spuid_list
*) list_p
;
729 enum bfd_endian byte_order
730 = bfd_big_endian (abfd
) ? BFD_ENDIAN_BIG
: BFD_ENDIAN_LITTLE
;
733 sscanf (bfd_section_name (abfd
, asect
), "SPU/%d/regs%n", &fd
, &pos
);
737 if (list
->pos
>= list
->offset
&& list
->pos
+ 4 <= list
->offset
+ list
->len
)
739 store_unsigned_integer (list
->buf
+ list
->pos
- list
->offset
,
746 enum target_xfer_status
747 core_target::xfer_partial (enum target_object object
, const char *annex
,
748 gdb_byte
*readbuf
, const gdb_byte
*writebuf
,
749 ULONGEST offset
, ULONGEST len
, ULONGEST
*xfered_len
)
753 case TARGET_OBJECT_MEMORY
:
754 return (section_table_xfer_memory_partial
756 offset
, len
, xfered_len
,
757 m_core_section_table
.sections
,
758 m_core_section_table
.sections_end
,
761 case TARGET_OBJECT_AUXV
:
764 /* When the aux vector is stored in core file, BFD
765 represents this with a fake section called ".auxv". */
767 struct bfd_section
*section
;
770 section
= bfd_get_section_by_name (core_bfd
, ".auxv");
772 return TARGET_XFER_E_IO
;
774 size
= bfd_section_size (core_bfd
, section
);
776 return TARGET_XFER_EOF
;
782 return TARGET_XFER_EOF
;
783 if (!bfd_get_section_contents (core_bfd
, section
, readbuf
,
784 (file_ptr
) offset
, size
))
786 warning (_("Couldn't read NT_AUXV note in core file."));
787 return TARGET_XFER_E_IO
;
790 *xfered_len
= (ULONGEST
) size
;
791 return TARGET_XFER_OK
;
793 return TARGET_XFER_E_IO
;
795 case TARGET_OBJECT_WCOOKIE
:
798 /* When the StackGhost cookie is stored in core file, BFD
799 represents this with a fake section called
802 struct bfd_section
*section
;
805 section
= bfd_get_section_by_name (core_bfd
, ".wcookie");
807 return TARGET_XFER_E_IO
;
809 size
= bfd_section_size (core_bfd
, section
);
811 return TARGET_XFER_EOF
;
817 return TARGET_XFER_EOF
;
818 if (!bfd_get_section_contents (core_bfd
, section
, readbuf
,
819 (file_ptr
) offset
, size
))
821 warning (_("Couldn't read StackGhost cookie in core file."));
822 return TARGET_XFER_E_IO
;
825 *xfered_len
= (ULONGEST
) size
;
826 return TARGET_XFER_OK
;
829 return TARGET_XFER_E_IO
;
831 case TARGET_OBJECT_LIBRARIES
:
832 if (m_core_gdbarch
!= nullptr
833 && gdbarch_core_xfer_shared_libraries_p (m_core_gdbarch
))
836 return TARGET_XFER_E_IO
;
839 *xfered_len
= gdbarch_core_xfer_shared_libraries (m_core_gdbarch
,
843 if (*xfered_len
== 0)
844 return TARGET_XFER_EOF
;
846 return TARGET_XFER_OK
;
851 case TARGET_OBJECT_LIBRARIES_AIX
:
852 if (m_core_gdbarch
!= nullptr
853 && gdbarch_core_xfer_shared_libraries_aix_p (m_core_gdbarch
))
856 return TARGET_XFER_E_IO
;
860 = gdbarch_core_xfer_shared_libraries_aix (m_core_gdbarch
,
864 if (*xfered_len
== 0)
865 return TARGET_XFER_EOF
;
867 return TARGET_XFER_OK
;
872 case TARGET_OBJECT_SPU
:
873 if (readbuf
&& annex
)
875 /* When the SPU contexts are stored in a core file, BFD
876 represents this with a fake section called
879 struct bfd_section
*section
;
881 char sectionstr
[100];
883 xsnprintf (sectionstr
, sizeof sectionstr
, "SPU/%s", annex
);
885 section
= bfd_get_section_by_name (core_bfd
, sectionstr
);
887 return TARGET_XFER_E_IO
;
889 size
= bfd_section_size (core_bfd
, section
);
891 return TARGET_XFER_EOF
;
897 return TARGET_XFER_EOF
;
898 if (!bfd_get_section_contents (core_bfd
, section
, readbuf
,
899 (file_ptr
) offset
, size
))
901 warning (_("Couldn't read SPU section in core file."));
902 return TARGET_XFER_E_IO
;
905 *xfered_len
= (ULONGEST
) size
;
906 return TARGET_XFER_OK
;
910 /* NULL annex requests list of all present spuids. */
911 struct spuid_list list
;
914 list
.offset
= offset
;
918 bfd_map_over_sections (core_bfd
, add_to_spuid_list
, &list
);
920 if (list
.written
== 0)
921 return TARGET_XFER_EOF
;
924 *xfered_len
= (ULONGEST
) list
.written
;
925 return TARGET_XFER_OK
;
928 return TARGET_XFER_E_IO
;
930 case TARGET_OBJECT_SIGNAL_INFO
:
933 if (m_core_gdbarch
!= nullptr
934 && gdbarch_core_xfer_siginfo_p (m_core_gdbarch
))
936 LONGEST l
= gdbarch_core_xfer_siginfo (m_core_gdbarch
, readbuf
,
943 return TARGET_XFER_EOF
;
945 return TARGET_XFER_OK
;
949 return TARGET_XFER_E_IO
;
952 return this->beneath ()->xfer_partial (object
, annex
, readbuf
,
953 writebuf
, offset
, len
,
960 /* Okay, let's be honest: threads gleaned from a core file aren't
961 exactly lively, are they? On the other hand, if we don't claim
962 that each & every one is alive, then we don't get any of them
963 to appear in an "info thread" command, which is quite a useful
967 core_target::thread_alive (ptid_t ptid
)
972 /* Ask the current architecture what it knows about this core file.
973 That will be used, in turn, to pick a better architecture. This
974 wrapper could be avoided if targets got a chance to specialize
977 const struct target_desc
*
978 core_target::read_description ()
980 if (m_core_gdbarch
&& gdbarch_core_read_description_p (m_core_gdbarch
))
982 const struct target_desc
*result
;
984 result
= gdbarch_core_read_description (m_core_gdbarch
, this, core_bfd
);
989 return this->beneath ()->read_description ();
993 core_target::pid_to_str (ptid_t ptid
)
995 struct inferior
*inf
;
998 /* The preferred way is to have a gdbarch/OS specific
1000 if (m_core_gdbarch
!= nullptr
1001 && gdbarch_core_pid_to_str_p (m_core_gdbarch
))
1002 return gdbarch_core_pid_to_str (m_core_gdbarch
, ptid
);
1004 /* Otherwise, if we don't have one, we'll just fallback to
1005 "process", with normal_pid_to_str. */
1007 /* Try the LWPID field first. */
1010 return normal_pid_to_str (ptid_t (pid
));
1012 /* Otherwise, this isn't a "threaded" core -- use the PID field, but
1013 only if it isn't a fake PID. */
1014 inf
= find_inferior_ptid (ptid
);
1015 if (inf
!= NULL
&& !inf
->fake_pid_p
)
1016 return normal_pid_to_str (ptid
);
1018 /* No luck. We simply don't have a valid PID to print. */
1019 return "<main task>";
1023 core_target::thread_name (struct thread_info
*thr
)
1025 if (m_core_gdbarch
!= nullptr
1026 && gdbarch_core_thread_name_p (m_core_gdbarch
))
1027 return gdbarch_core_thread_name (m_core_gdbarch
, thr
);
1032 core_target::has_memory ()
1034 return (core_bfd
!= NULL
);
1038 core_target::has_stack ()
1040 return (core_bfd
!= NULL
);
1044 core_target::has_registers ()
1046 return (core_bfd
!= NULL
);
1049 /* Implement the to_info_proc method. */
1052 core_target::info_proc (const char *args
, enum info_proc_what request
)
1054 struct gdbarch
*gdbarch
= get_current_arch ();
1056 /* Since this is the core file target, call the 'core_info_proc'
1057 method on gdbarch, not 'info_proc'. */
1058 if (gdbarch_core_info_proc_p (gdbarch
))
1059 gdbarch_core_info_proc (gdbarch
, args
, request
);
1065 _initialize_corelow (void)
1067 add_target (core_target_info
, core_target_open
, filename_completer
);