corefile.c revision 104834
133965Sjdp/* Core file generic interface routines for BFD.
2104834Sobrien   Copyright 1990, 1991, 1992, 1993, 1994, 2000, 2001, 2002
378828Sobrien   Free Software Foundation, Inc.
433965Sjdp   Written by Cygnus Support.
533965Sjdp
633965SjdpThis file is part of BFD, the Binary File Descriptor library.
733965Sjdp
833965SjdpThis program is free software; you can redistribute it and/or modify
933965Sjdpit under the terms of the GNU General Public License as published by
1033965Sjdpthe Free Software Foundation; either version 2 of the License, or
1133965Sjdp(at your option) any later version.
1233965Sjdp
1333965SjdpThis program is distributed in the hope that it will be useful,
1433965Sjdpbut WITHOUT ANY WARRANTY; without even the implied warranty of
1533965SjdpMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1633965SjdpGNU General Public License for more details.
1733965Sjdp
1833965SjdpYou should have received a copy of the GNU General Public License
1933965Sjdpalong with this program; if not, write to the Free Software
2033965SjdpFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
2133965Sjdp
2233965Sjdp/*
2333965SjdpSECTION
2433965Sjdp	Core files
2533965Sjdp
2633965SjdpDESCRIPTION
2733965Sjdp	These are functions pertaining to core files.
2833965Sjdp*/
2933965Sjdp
3033965Sjdp#include "bfd.h"
3133965Sjdp#include "sysdep.h"
3233965Sjdp#include "libbfd.h"
3333965Sjdp
3433965Sjdp/*
3533965SjdpFUNCTION
3633965Sjdp	bfd_core_file_failing_command
3733965Sjdp
3833965SjdpSYNOPSIS
3989857Sobrien	const char *bfd_core_file_failing_command(bfd *abfd);
4033965Sjdp
4133965SjdpDESCRIPTION
4233965Sjdp	Return a read-only string explaining which program was running
4333965Sjdp	when it failed and produced the core file @var{abfd}.
4433965Sjdp
4533965Sjdp*/
4633965Sjdp
47104834Sobrienconst char *
4833965Sjdpbfd_core_file_failing_command (abfd)
4933965Sjdp     bfd *abfd;
5033965Sjdp{
5133965Sjdp  if (abfd->format != bfd_core) {
5233965Sjdp    bfd_set_error (bfd_error_invalid_operation);
5333965Sjdp    return NULL;
5433965Sjdp  }
5533965Sjdp  return BFD_SEND (abfd, _core_file_failing_command, (abfd));
5633965Sjdp}
5733965Sjdp
5833965Sjdp/*
5933965SjdpFUNCTION
6033965Sjdp	bfd_core_file_failing_signal
6133965Sjdp
6233965SjdpSYNOPSIS
6333965Sjdp	int bfd_core_file_failing_signal(bfd *abfd);
6433965Sjdp
6533965SjdpDESCRIPTION
6633965Sjdp	Returns the signal number which caused the core dump which
6733965Sjdp	generated the file the BFD @var{abfd} is attached to.
6833965Sjdp*/
6933965Sjdp
7033965Sjdpint
7133965Sjdpbfd_core_file_failing_signal (abfd)
7233965Sjdp     bfd *abfd;
7333965Sjdp{
7433965Sjdp  if (abfd->format != bfd_core) {
7533965Sjdp    bfd_set_error (bfd_error_invalid_operation);
7633965Sjdp    return 0;
7733965Sjdp  }
7833965Sjdp  return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
7933965Sjdp}
8033965Sjdp
8133965Sjdp/*
8233965SjdpFUNCTION
8333965Sjdp	core_file_matches_executable_p
8433965Sjdp
8533965SjdpSYNOPSIS
8633965Sjdp	boolean core_file_matches_executable_p
8733965Sjdp		(bfd *core_bfd, bfd *exec_bfd);
8833965Sjdp
8933965SjdpDESCRIPTION
9033965Sjdp	Return <<true>> if the core file attached to @var{core_bfd}
9133965Sjdp	was generated by a run of the executable file attached to
9233965Sjdp	@var{exec_bfd}, <<false>> otherwise.
9333965Sjdp*/
9433965Sjdpboolean
9533965Sjdpcore_file_matches_executable_p (core_bfd, exec_bfd)
9633965Sjdp     bfd *core_bfd, *exec_bfd;
9733965Sjdp{
9833965Sjdp    if ((core_bfd->format != bfd_core) || (exec_bfd->format != bfd_object)) {
9933965Sjdp	    bfd_set_error (bfd_error_wrong_format);
10033965Sjdp	    return false;
10133965Sjdp	}
10233965Sjdp
10333965Sjdp    return BFD_SEND (core_bfd, _core_file_matches_executable_p,
10433965Sjdp		     (core_bfd, exec_bfd));
10533965Sjdp}
106