1 /* Core dump and executable file functions below target vector, for GDB.
3 Copyright (C) 1986-2018 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/>. */
21 #include "arch-utils.h"
24 #ifdef HAVE_SYS_FILE_H
25 #include <sys/file.h> /* needed for F_OK and friends */
27 #include "frame.h" /* required by inferior.h */
35 #include "gdbthread.h"
40 #include "readline/readline.h"
42 #include "filenames.h"
43 #include "progspace.h"
46 #include "completer.h"
47 #include "filestuff.h"
53 static core_fns
*sniff_core_bfd (gdbarch
*core_gdbarch
,
56 /* The core file target. */
58 static const target_info core_target_info
= {
60 N_("Local core dump file"),
61 N_("Use a core file as a target. Specify the filename of the core file.")
64 class core_target final
: public target_ops
68 ~core_target () override
;
70 const target_info
&info () const override
71 { return core_target_info
; }
73 void close () override
;
74 void detach (inferior
*, int) override
;
75 void fetch_registers (struct regcache
*, int) override
;
77 enum target_xfer_status
xfer_partial (enum target_object object
,
80 const gdb_byte
*writebuf
,
81 ULONGEST offset
, ULONGEST len
,
82 ULONGEST
*xfered_len
) override
;
83 void files_info () override
;
85 bool thread_alive (ptid_t ptid
) override
;
86 const struct target_desc
*read_description () override
;
88 const char *pid_to_str (ptid_t
) override
;
90 const char *thread_name (struct thread_info
*) override
;
92 bool has_memory () override
;
93 bool has_stack () override
;
94 bool has_registers () override
;
95 bool info_proc (const char *, enum info_proc_what
) override
;
99 /* Getter, see variable definition. */
100 struct gdbarch
*core_gdbarch ()
102 return m_core_gdbarch
;
105 /* See definition. */
106 void get_core_register_section (struct regcache
*regcache
,
107 const struct regset
*regset
,
111 const char *human_name
,
114 private: /* per-core data */
116 /* The core's section table. Note that these target sections are
117 *not* mapped in the current address spaces' set of target
118 sections --- those should come only from pure executable or
119 shared library bfds. The core bfd sections are an implementation
120 detail of the core target, just like ptrace is for unix child
122 target_section_table m_core_section_table
{};
124 /* The core_fns for a core file handler that is prepared to read the
125 core file currently open on core_bfd. */
126 core_fns
*m_core_vec
= NULL
;
128 /* FIXME: kettenis/20031023: Eventually this field should
130 struct gdbarch
*m_core_gdbarch
= NULL
;
133 core_target::core_target ()
135 to_stratum
= process_stratum
;
137 m_core_gdbarch
= gdbarch_from_bfd (core_bfd
);
139 /* Find a suitable core file handler to munch on core_bfd */
140 m_core_vec
= sniff_core_bfd (m_core_gdbarch
, core_bfd
);
142 /* Find the data section */
143 if (build_section_table (core_bfd
,
144 &m_core_section_table
.sections
,
145 &m_core_section_table
.sections_end
))
146 error (_("\"%s\": Can't find sections: %s"),
147 bfd_get_filename (core_bfd
), bfd_errmsg (bfd_get_error ()));
150 core_target::~core_target ()
152 xfree (m_core_section_table
.sections
);
155 /* List of all available core_fns. On gdb startup, each core file
156 register reader calls deprecated_add_core_fns() to register
157 information on each core format it is prepared to read. */
159 static struct core_fns
*core_file_fns
= NULL
;
161 static int gdb_check_format (bfd
*);
163 static void add_to_thread_list (bfd
*, asection
*, void *);
165 /* An arbitrary identifier for the core inferior. */
166 #define CORELOW_PID 1
168 /* Link a new core_fns into the global core_file_fns list. Called on
169 gdb startup by the _initialize routine in each core file register
170 reader, to register information about each format the reader is
171 prepared to handle. */
174 deprecated_add_core_fns (struct core_fns
*cf
)
176 cf
->next
= core_file_fns
;
180 /* The default function that core file handlers can use to examine a
181 core file BFD and decide whether or not to accept the job of
182 reading the core file. */
185 default_core_sniffer (struct core_fns
*our_fns
, bfd
*abfd
)
189 result
= (bfd_get_flavour (abfd
) == our_fns
-> core_flavour
);
193 /* Walk through the list of core functions to find a set that can
194 handle the core file open on ABFD. Returns pointer to set that is
197 static struct core_fns
*
198 sniff_core_bfd (struct gdbarch
*core_gdbarch
, bfd
*abfd
)
201 struct core_fns
*yummy
= NULL
;
204 /* Don't sniff if we have support for register sets in
206 if (core_gdbarch
&& gdbarch_iterate_over_regset_sections_p (core_gdbarch
))
209 for (cf
= core_file_fns
; cf
!= NULL
; cf
= cf
->next
)
211 if (cf
->core_sniffer (cf
, abfd
))
219 warning (_("\"%s\": ambiguous core format, %d handlers match"),
220 bfd_get_filename (abfd
), matches
);
222 else if (matches
== 0)
223 error (_("\"%s\": no core file handler recognizes format"),
224 bfd_get_filename (abfd
));
229 /* The default is to reject every core file format we see. Either
230 BFD has to recognize it, or we have to provide a function in the
231 core file handler that recognizes it. */
234 default_check_format (bfd
*abfd
)
239 /* Attempt to recognize core file formats that BFD rejects. */
242 gdb_check_format (bfd
*abfd
)
246 for (cf
= core_file_fns
; cf
!= NULL
; cf
= cf
->next
)
248 if (cf
->check_format (abfd
))
256 /* Close the core target. */
259 core_target::close ()
263 int pid
= ptid_get_pid (inferior_ptid
);
264 inferior_ptid
= null_ptid
; /* Avoid confusion from thread
267 exit_inferior_silent (pid
);
269 /* Clear out solib state while the bfd is still open. See
270 comments in clear_solib in solib.c. */
273 gdb_bfd_unref (core_bfd
);
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_build (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
)
364 struct cleanup
*old_chain
;
368 target_preopen (from_tty
);
372 error (_("No core file specified. (Use `detach' "
373 "to stop debugging a core file.)"));
375 error (_("No core file specified."));
378 gdb::unique_xmalloc_ptr
<char> filename (tilde_expand (arg
));
379 if (!IS_ABSOLUTE_PATH (filename
.get ()))
380 filename
.reset (concat (current_directory
, "/",
381 filename
.get (), (char *) NULL
));
383 flags
= O_BINARY
| O_LARGEFILE
;
388 scratch_chan
= gdb_open_cloexec (filename
.get (), flags
, 0);
389 if (scratch_chan
< 0)
390 perror_with_name (filename
.get ());
392 gdb_bfd_ref_ptr
temp_bfd (gdb_bfd_fopen (filename
.get (), gnutarget
,
393 write_files
? FOPEN_RUB
: FOPEN_RB
,
395 if (temp_bfd
== NULL
)
396 perror_with_name (filename
.get ());
398 if (!bfd_check_format (temp_bfd
.get (), bfd_core
)
399 && !gdb_check_format (temp_bfd
.get ()))
401 /* Do it after the err msg */
402 /* FIXME: should be checking for errors from bfd_close (for one
403 thing, on error it does not free all the storage associated
405 error (_("\"%s\" is not a core dump: %s"),
406 filename
.get (), bfd_errmsg (bfd_get_error ()));
409 core_bfd
= temp_bfd
.release ();
411 core_target
*target
= new core_target ();
413 /* Own the target until it is successfully pushed. */
414 target_ops_up
target_holder (target
);
418 /* If we have no exec file, try to set the architecture from the
419 core file. We don't do this unconditionally since an exec file
420 typically contains more information that helps us determine the
421 architecture than a core file. */
423 set_gdbarch_from_file (core_bfd
);
425 push_target (target
);
426 target_holder
.release ();
428 /* Do this before acknowledging the inferior, so if
429 post_create_inferior throws (can happen easilly if you're loading
430 a core file with the wrong exec), we aren't left with threads
431 from the previous inferior. */
434 inferior_ptid
= null_ptid
;
436 /* Need to flush the register cache (and the frame cache) from a
437 previous debug session. If inferior_ptid ends up the same as the
438 last debug session --- e.g., b foo; run; gcore core1; step; gcore
439 core2; core core1; core core2 --- then there's potential for
440 get_current_regcache to return the cached regcache of the
441 previous session, and the frame cache being stale. */
442 registers_changed ();
444 /* Build up thread list from BFD sections, and possibly set the
445 current thread to the .reg/NN section matching the .reg
447 bfd_map_over_sections (core_bfd
, add_to_thread_list
,
448 bfd_get_section_by_name (core_bfd
, ".reg"));
450 if (ptid_equal (inferior_ptid
, null_ptid
))
452 /* Either we found no .reg/NN section, and hence we have a
453 non-threaded core (single-threaded, from gdb's perspective),
454 or for some reason add_to_thread_list couldn't determine
455 which was the "main" thread. The latter case shouldn't
456 usually happen, but we're dealing with input here, which can
457 always be broken in different ways. */
458 struct thread_info
*thread
= first_thread_of_process (-1);
462 inferior_appeared (current_inferior (), CORELOW_PID
);
463 inferior_ptid
= pid_to_ptid (CORELOW_PID
);
464 add_thread_silent (inferior_ptid
);
467 switch_to_thread (thread
->ptid
);
470 post_create_inferior (target
, from_tty
);
472 /* Now go through the target stack looking for threads since there
473 may be a thread_stratum target loaded on top of target core by
474 now. The layer above should claim threads found in the BFD
478 target_update_thread_list ();
481 CATCH (except
, RETURN_MASK_ERROR
)
483 exception_print (gdb_stderr
, except
);
487 p
= bfd_core_file_failing_command (core_bfd
);
489 printf_filtered (_("Core was generated by `%s'.\n"), p
);
491 /* Clearing any previous state of convenience variables. */
492 clear_exit_convenience_vars ();
494 siggy
= bfd_core_file_failing_signal (core_bfd
);
497 gdbarch
*core_gdbarch
= target
->core_gdbarch ();
499 /* If we don't have a CORE_GDBARCH to work with, assume a native
500 core (map gdb_signal from host signals). If we do have
501 CORE_GDBARCH to work with, but no gdb_signal_from_target
502 implementation for that gdbarch, as a fallback measure,
503 assume the host signal mapping. It'll be correct for native
504 cores, but most likely incorrect for cross-cores. */
505 enum gdb_signal sig
= (core_gdbarch
!= NULL
506 && gdbarch_gdb_signal_from_target_p (core_gdbarch
)
507 ? gdbarch_gdb_signal_from_target (core_gdbarch
,
509 : gdb_signal_from_host (siggy
));
511 printf_filtered (_("Program terminated with signal %s, %s.\n"),
512 gdb_signal_to_name (sig
), gdb_signal_to_string (sig
));
514 /* Set the value of the internal variable $_exitsignal,
515 which holds the signal uncaught by the inferior. */
516 set_internalvar_integer (lookup_internalvar ("_exitsignal"),
520 /* Fetch all registers from core file. */
521 target_fetch_registers (get_current_regcache (), -1);
523 /* Now, set up the frame cache, and print the top of stack. */
524 reinit_frame_cache ();
525 print_stack_frame (get_selected_frame (NULL
), 1, SRC_AND_LOC
, 1);
527 /* Current thread should be NUM 1 but the user does not know that.
528 If a program is single threaded gdb in general does not mention
529 anything about threads. That is why the test is >= 2. */
530 if (thread_count () >= 2)
534 thread_command (NULL
, from_tty
);
536 CATCH (except
, RETURN_MASK_ERROR
)
538 exception_print (gdb_stderr
, except
);
545 core_target::detach (inferior
*inf
, int from_tty
)
547 /* Note that 'this' is dangling after this call. unpush_target
548 closes the target, and our close implementation deletes
550 unpush_target (this);
552 reinit_frame_cache ();
553 maybe_say_no_core_file_now (from_tty
);
556 /* Try to retrieve registers from a section in core_bfd, and supply
557 them to m_core_vec->core_read_registers, as the register set
560 If ptid's lwp member is zero, do the single-threaded
561 thing: look for a section named NAME. If ptid's lwp
562 member is non-zero, do the multi-threaded thing: look for a section
563 named "NAME/LWP", where LWP is the shortest ASCII decimal
564 representation of ptid's lwp member.
566 HUMAN_NAME is a human-readable name for the kind of registers the
567 NAME section contains, for use in error messages.
569 If REQUIRED is true, print an error if the core file doesn't have a
570 section by the appropriate name. Otherwise, just do nothing. */
573 core_target::get_core_register_section (struct regcache
*regcache
,
574 const struct regset
*regset
,
578 const char *human_name
,
581 struct bfd_section
*section
;
584 bool variable_size_section
= (regset
!= NULL
585 && regset
->flags
& REGSET_VARIABLE_SIZE
);
587 thread_section_name
section_name (name
, regcache
->ptid ());
589 section
= bfd_get_section_by_name (core_bfd
, section_name
.c_str ());
593 warning (_("Couldn't find %s registers in core file."),
598 size
= bfd_section_size (core_bfd
, section
);
601 warning (_("Section `%s' in core file too small."),
602 section_name
.c_str ());
605 if (size
!= min_size
&& !variable_size_section
)
607 warning (_("Unexpected size of section `%s' in core file."),
608 section_name
.c_str ());
611 contents
= (char *) alloca (size
);
612 if (! bfd_get_section_contents (core_bfd
, section
, contents
,
615 warning (_("Couldn't read %s registers from `%s' section in core file."),
616 human_name
, section_name
.c_str ());
622 regset
->supply_regset (regset
, regcache
, -1, contents
, size
);
626 gdb_assert (m_core_vec
!= nullptr);
627 m_core_vec
->core_read_registers (regcache
, contents
, size
, which
,
629 bfd_section_vma (core_bfd
, section
)));
632 /* Data passed to gdbarch_iterate_over_regset_sections's callback. */
633 struct get_core_registers_cb_data
636 struct regcache
*regcache
;
639 /* Callback for get_core_registers that handles a single core file
640 register note section. */
643 get_core_registers_cb (const char *sect_name
, int size
,
644 const struct regset
*regset
,
645 const char *human_name
, void *cb_data
)
647 auto *data
= (get_core_registers_cb_data
*) cb_data
;
648 bool required
= false;
650 if (strcmp (sect_name
, ".reg") == 0)
653 if (human_name
== NULL
)
654 human_name
= "general-purpose";
656 else if (strcmp (sect_name
, ".reg2") == 0)
658 if (human_name
== NULL
)
659 human_name
= "floating-point";
662 /* The 'which' parameter is only used when no regset is provided.
663 Thus we just set it to -1. */
664 data
->target
->get_core_register_section (data
->regcache
, regset
, sect_name
,
665 size
, -1, human_name
, required
);
668 /* Get the registers out of a core file. This is the machine-
669 independent part. Fetch_core_registers is the machine-dependent
670 part, typically implemented in the xm-file for each
673 /* We just get all the registers, so we don't use regno. */
676 core_target::fetch_registers (struct regcache
*regcache
, int regno
)
679 struct gdbarch
*gdbarch
;
681 if (!(m_core_gdbarch
!= nullptr
682 && gdbarch_iterate_over_regset_sections_p (m_core_gdbarch
))
683 && (m_core_vec
== NULL
|| m_core_vec
->core_read_registers
== NULL
))
685 fprintf_filtered (gdb_stderr
,
686 "Can't fetch registers from this type of core file\n");
690 gdbarch
= regcache
->arch ();
691 if (gdbarch_iterate_over_regset_sections_p (gdbarch
))
693 get_core_registers_cb_data data
= { this, regcache
};
694 gdbarch_iterate_over_regset_sections (gdbarch
,
695 get_core_registers_cb
,
696 (void *) &data
, NULL
);
700 get_core_register_section (regcache
, NULL
,
701 ".reg", 0, 0, "general-purpose", 1);
702 get_core_register_section (regcache
, NULL
,
703 ".reg2", 0, 2, "floating-point", 0);
706 /* Mark all registers not found in the core as unavailable. */
707 for (i
= 0; i
< gdbarch_num_regs (regcache
->arch ()); i
++)
708 if (regcache_register_status (regcache
, i
) == REG_UNKNOWN
)
709 regcache_raw_supply (regcache
, i
, NULL
);
713 core_target::files_info ()
715 print_section_info (&m_core_section_table
, core_bfd
);
728 add_to_spuid_list (bfd
*abfd
, asection
*asect
, void *list_p
)
730 struct spuid_list
*list
= (struct spuid_list
*) list_p
;
731 enum bfd_endian byte_order
732 = bfd_big_endian (abfd
) ? BFD_ENDIAN_BIG
: BFD_ENDIAN_LITTLE
;
735 sscanf (bfd_section_name (abfd
, asect
), "SPU/%d/regs%n", &fd
, &pos
);
739 if (list
->pos
>= list
->offset
&& list
->pos
+ 4 <= list
->offset
+ list
->len
)
741 store_unsigned_integer (list
->buf
+ list
->pos
- list
->offset
,
748 enum target_xfer_status
749 core_target::xfer_partial (enum target_object object
, const char *annex
,
750 gdb_byte
*readbuf
, const gdb_byte
*writebuf
,
751 ULONGEST offset
, ULONGEST len
, ULONGEST
*xfered_len
)
755 case TARGET_OBJECT_MEMORY
:
756 return (section_table_xfer_memory_partial
758 offset
, len
, xfered_len
,
759 m_core_section_table
.sections
,
760 m_core_section_table
.sections_end
,
763 case TARGET_OBJECT_AUXV
:
766 /* When the aux vector is stored in core file, BFD
767 represents this with a fake section called ".auxv". */
769 struct bfd_section
*section
;
772 section
= bfd_get_section_by_name (core_bfd
, ".auxv");
774 return TARGET_XFER_E_IO
;
776 size
= bfd_section_size (core_bfd
, section
);
778 return TARGET_XFER_EOF
;
784 return TARGET_XFER_EOF
;
785 if (!bfd_get_section_contents (core_bfd
, section
, readbuf
,
786 (file_ptr
) offset
, size
))
788 warning (_("Couldn't read NT_AUXV note in core file."));
789 return TARGET_XFER_E_IO
;
792 *xfered_len
= (ULONGEST
) size
;
793 return TARGET_XFER_OK
;
795 return TARGET_XFER_E_IO
;
797 case TARGET_OBJECT_WCOOKIE
:
800 /* When the StackGhost cookie is stored in core file, BFD
801 represents this with a fake section called
804 struct bfd_section
*section
;
807 section
= bfd_get_section_by_name (core_bfd
, ".wcookie");
809 return TARGET_XFER_E_IO
;
811 size
= bfd_section_size (core_bfd
, section
);
813 return TARGET_XFER_EOF
;
819 return TARGET_XFER_EOF
;
820 if (!bfd_get_section_contents (core_bfd
, section
, readbuf
,
821 (file_ptr
) offset
, size
))
823 warning (_("Couldn't read StackGhost cookie in core file."));
824 return TARGET_XFER_E_IO
;
827 *xfered_len
= (ULONGEST
) size
;
828 return TARGET_XFER_OK
;
831 return TARGET_XFER_E_IO
;
833 case TARGET_OBJECT_LIBRARIES
:
834 if (m_core_gdbarch
!= nullptr
835 && gdbarch_core_xfer_shared_libraries_p (m_core_gdbarch
))
838 return TARGET_XFER_E_IO
;
841 *xfered_len
= gdbarch_core_xfer_shared_libraries (m_core_gdbarch
,
845 if (*xfered_len
== 0)
846 return TARGET_XFER_EOF
;
848 return TARGET_XFER_OK
;
853 case TARGET_OBJECT_LIBRARIES_AIX
:
854 if (m_core_gdbarch
!= nullptr
855 && gdbarch_core_xfer_shared_libraries_aix_p (m_core_gdbarch
))
858 return TARGET_XFER_E_IO
;
862 = gdbarch_core_xfer_shared_libraries_aix (m_core_gdbarch
,
866 if (*xfered_len
== 0)
867 return TARGET_XFER_EOF
;
869 return TARGET_XFER_OK
;
874 case TARGET_OBJECT_SPU
:
875 if (readbuf
&& annex
)
877 /* When the SPU contexts are stored in a core file, BFD
878 represents this with a fake section called
881 struct bfd_section
*section
;
883 char sectionstr
[100];
885 xsnprintf (sectionstr
, sizeof sectionstr
, "SPU/%s", annex
);
887 section
= bfd_get_section_by_name (core_bfd
, sectionstr
);
889 return TARGET_XFER_E_IO
;
891 size
= bfd_section_size (core_bfd
, section
);
893 return TARGET_XFER_EOF
;
899 return TARGET_XFER_EOF
;
900 if (!bfd_get_section_contents (core_bfd
, section
, readbuf
,
901 (file_ptr
) offset
, size
))
903 warning (_("Couldn't read SPU section in core file."));
904 return TARGET_XFER_E_IO
;
907 *xfered_len
= (ULONGEST
) size
;
908 return TARGET_XFER_OK
;
912 /* NULL annex requests list of all present spuids. */
913 struct spuid_list list
;
916 list
.offset
= offset
;
920 bfd_map_over_sections (core_bfd
, add_to_spuid_list
, &list
);
922 if (list
.written
== 0)
923 return TARGET_XFER_EOF
;
926 *xfered_len
= (ULONGEST
) list
.written
;
927 return TARGET_XFER_OK
;
930 return TARGET_XFER_E_IO
;
932 case TARGET_OBJECT_SIGNAL_INFO
:
935 if (m_core_gdbarch
!= nullptr
936 && gdbarch_core_xfer_siginfo_p (m_core_gdbarch
))
938 LONGEST l
= gdbarch_core_xfer_siginfo (m_core_gdbarch
, readbuf
,
945 return TARGET_XFER_EOF
;
947 return TARGET_XFER_OK
;
951 return TARGET_XFER_E_IO
;
954 return this->beneath
->xfer_partial (object
, annex
, readbuf
,
955 writebuf
, offset
, len
,
962 /* Okay, let's be honest: threads gleaned from a core file aren't
963 exactly lively, are they? On the other hand, if we don't claim
964 that each & every one is alive, then we don't get any of them
965 to appear in an "info thread" command, which is quite a useful
969 core_target::thread_alive (ptid_t ptid
)
974 /* Ask the current architecture what it knows about this core file.
975 That will be used, in turn, to pick a better architecture. This
976 wrapper could be avoided if targets got a chance to specialize
979 const struct target_desc
*
980 core_target::read_description ()
982 if (m_core_gdbarch
&& gdbarch_core_read_description_p (m_core_gdbarch
))
984 const struct target_desc
*result
;
986 result
= gdbarch_core_read_description (m_core_gdbarch
, this, core_bfd
);
991 return this->beneath
->read_description ();
995 core_target::pid_to_str (ptid_t ptid
)
998 struct inferior
*inf
;
1001 /* The preferred way is to have a gdbarch/OS specific
1003 if (m_core_gdbarch
!= nullptr
1004 && gdbarch_core_pid_to_str_p (m_core_gdbarch
))
1005 return gdbarch_core_pid_to_str (m_core_gdbarch
, ptid
);
1007 /* Otherwise, if we don't have one, we'll just fallback to
1008 "process", with normal_pid_to_str. */
1010 /* Try the LWPID field first. */
1011 pid
= ptid_get_lwp (ptid
);
1013 return normal_pid_to_str (pid_to_ptid (pid
));
1015 /* Otherwise, this isn't a "threaded" core -- use the PID field, but
1016 only if it isn't a fake PID. */
1017 inf
= find_inferior_ptid (ptid
);
1018 if (inf
!= NULL
&& !inf
->fake_pid_p
)
1019 return normal_pid_to_str (ptid
);
1021 /* No luck. We simply don't have a valid PID to print. */
1022 xsnprintf (buf
, sizeof buf
, "<main task>");
1027 core_target::thread_name (struct thread_info
*thr
)
1029 if (m_core_gdbarch
!= nullptr
1030 && gdbarch_core_thread_name_p (m_core_gdbarch
))
1031 return gdbarch_core_thread_name (m_core_gdbarch
, thr
);
1036 core_target::has_memory ()
1038 return (core_bfd
!= NULL
);
1042 core_target::has_stack ()
1044 return (core_bfd
!= NULL
);
1048 core_target::has_registers ()
1050 return (core_bfd
!= NULL
);
1053 /* Implement the to_info_proc method. */
1056 core_target::info_proc (const char *args
, enum info_proc_what request
)
1058 struct gdbarch
*gdbarch
= get_current_arch ();
1060 /* Since this is the core file target, call the 'core_info_proc'
1061 method on gdbarch, not 'info_proc'. */
1062 if (gdbarch_core_info_proc_p (gdbarch
))
1063 gdbarch_core_info_proc (gdbarch
, args
, request
);
1069 _initialize_corelow (void)
1071 add_target (core_target_info
, core_target_open
, filename_completer
);