12159047fSniklas /* Core file generic interface routines for BFD.
2*007c2a45Smiod Copyright 1990, 1991, 1992, 1993, 1994, 2000, 2001, 2002, 2003
35f210c2aSfgsch Free Software Foundation, Inc.
42159047fSniklas Written by Cygnus Support.
52159047fSniklas
62159047fSniklas This file is part of BFD, the Binary File Descriptor library.
72159047fSniklas
82159047fSniklas This program is free software; you can redistribute it and/or modify
92159047fSniklas it under the terms of the GNU General Public License as published by
102159047fSniklas the Free Software Foundation; either version 2 of the License, or
112159047fSniklas (at your option) any later version.
122159047fSniklas
132159047fSniklas This program is distributed in the hope that it will be useful,
142159047fSniklas but WITHOUT ANY WARRANTY; without even the implied warranty of
152159047fSniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
162159047fSniklas GNU General Public License for more details.
172159047fSniklas
182159047fSniklas You should have received a copy of the GNU General Public License
192159047fSniklas along with this program; if not, write to the Free Software
202159047fSniklas Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
212159047fSniklas
222159047fSniklas /*
232159047fSniklas SECTION
242159047fSniklas Core files
252159047fSniklas
262159047fSniklas DESCRIPTION
272159047fSniklas These are functions pertaining to core files.
282159047fSniklas */
292159047fSniklas
302159047fSniklas #include "bfd.h"
312159047fSniklas #include "sysdep.h"
322159047fSniklas #include "libbfd.h"
332159047fSniklas
342159047fSniklas /*
352159047fSniklas FUNCTION
362159047fSniklas bfd_core_file_failing_command
372159047fSniklas
382159047fSniklas SYNOPSIS
39c074d1c9Sdrahn const char *bfd_core_file_failing_command (bfd *abfd);
402159047fSniklas
412159047fSniklas DESCRIPTION
422159047fSniklas Return a read-only string explaining which program was running
432159047fSniklas when it failed and produced the core file @var{abfd}.
442159047fSniklas
452159047fSniklas */
462159047fSniklas
47c074d1c9Sdrahn const char *
bfd_core_file_failing_command(bfd * abfd)48*007c2a45Smiod bfd_core_file_failing_command (bfd *abfd)
492159047fSniklas {
50*007c2a45Smiod if (abfd->format != bfd_core)
51*007c2a45Smiod {
522159047fSniklas bfd_set_error (bfd_error_invalid_operation);
532159047fSniklas return NULL;
542159047fSniklas }
552159047fSniklas return BFD_SEND (abfd, _core_file_failing_command, (abfd));
562159047fSniklas }
572159047fSniklas
582159047fSniklas /*
592159047fSniklas FUNCTION
602159047fSniklas bfd_core_file_failing_signal
612159047fSniklas
622159047fSniklas SYNOPSIS
632159047fSniklas int bfd_core_file_failing_signal (bfd *abfd);
642159047fSniklas
652159047fSniklas DESCRIPTION
662159047fSniklas Returns the signal number which caused the core dump which
672159047fSniklas generated the file the BFD @var{abfd} is attached to.
682159047fSniklas */
692159047fSniklas
702159047fSniklas int
bfd_core_file_failing_signal(bfd * abfd)71*007c2a45Smiod bfd_core_file_failing_signal (bfd *abfd)
722159047fSniklas {
73*007c2a45Smiod if (abfd->format != bfd_core)
74*007c2a45Smiod {
752159047fSniklas bfd_set_error (bfd_error_invalid_operation);
762159047fSniklas return 0;
772159047fSniklas }
782159047fSniklas return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
792159047fSniklas }
802159047fSniklas
812159047fSniklas /*
822159047fSniklas FUNCTION
832159047fSniklas core_file_matches_executable_p
842159047fSniklas
852159047fSniklas SYNOPSIS
86c074d1c9Sdrahn bfd_boolean core_file_matches_executable_p
872159047fSniklas (bfd *core_bfd, bfd *exec_bfd);
882159047fSniklas
892159047fSniklas DESCRIPTION
90c074d1c9Sdrahn Return <<TRUE>> if the core file attached to @var{core_bfd}
912159047fSniklas was generated by a run of the executable file attached to
92c074d1c9Sdrahn @var{exec_bfd}, <<FALSE>> otherwise.
932159047fSniklas */
94*007c2a45Smiod
95c074d1c9Sdrahn bfd_boolean
core_file_matches_executable_p(bfd * core_bfd,bfd * exec_bfd)96*007c2a45Smiod core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
972159047fSniklas {
98*007c2a45Smiod if (core_bfd->format != bfd_core || exec_bfd->format != bfd_object)
99*007c2a45Smiod {
1002159047fSniklas bfd_set_error (bfd_error_wrong_format);
101c074d1c9Sdrahn return FALSE;
1022159047fSniklas }
1032159047fSniklas
1042159047fSniklas return BFD_SEND (core_bfd, _core_file_matches_executable_p,
1052159047fSniklas (core_bfd, exec_bfd));
1062159047fSniklas }
107