+2005-12-23 Joel Brobecker <brobecker@adacore.com>
+
+ * corefile.c (generic_core_file_matches_executable_p): New function.
+ * libbfd-in.h (generic_core_file_matches_executable_p): Add
+ declaration.
+ * libbfd.h: Regenerate.
+ * hpux-core.c: ANSIfy function declarations and prototypes.
+ (thread_section_p): Manually expand bfd_section_name macro
+ to make it clear that parameter ABFD is not used.
+ (hpux_core_core_file_matches_executable_p): Delete, replaced
+ by macro pointing to generic_core_file_matches_executable_p.
+
+ * aix386-core.c: Replace core_file_matches_executable_p null
+ implementation by generic_core_file_matches_executable_p by
+ using a macro.
+ * aix5ppc-core.c: Likewise.
+ * cisco-core.c: Likewise.
+ * hppabsd-core.c: Likewise.
+ * irix-core.c: Likewise.
+ * lynx-core.c: Likewise.
+ * mach-o.c: Likewise.
+ * netbsd-core.c: Likewise.
+ * osf-core.c: Likewise.
+ * ptrace-core.c: Likewise.
+ * sco5-core.c: Likewise.
+ * trad-core.c: Likewise.
+
2005-12-19 David Heine <dlheine@tensilica.com>
* elf32-xtensa.c (action_list_count, xlate_map_entry, xlate_map,
return core_hdr (abfd)->cd_cursig;
}
-static bfd_boolean
-aix386_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd;
- bfd *exec_bfd;
-{
- /* FIXME: We have no way of telling at this point. */
- return TRUE;
-}
+#define aix386_core_file_matches_executable_p generic_core_file_matches_executable_p
/* If somebody calls any byte-swapping routines, shoot them. */
#else /* AIX_5_CORE */
const bfd_target *xcoff64_core_p (bfd *);
-bfd_boolean xcoff64_core_file_matches_executable_p (bfd *, bfd *);
+#define xcoff64_core_file_matches_executable_p generic_core_file_matches_executable_p
char *xcoff64_core_file_failing_command (bfd *);
int xcoff64_core_file_failing_signal (bfd *);
return 0;
}
-bfd_boolean
-xcoff64_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED,
- bfd *exec_bfd ATTRIBUTE_UNUSED)
-{
- return FALSE;
-}
-
char *
xcoff64_core_file_failing_command (bfd *abfd ATTRIBUTE_UNUSED)
{
static const bfd_target *cisco_core_file_p PARAMS ((bfd *));
char *cisco_core_file_failing_command PARAMS ((bfd *));
int cisco_core_file_failing_signal PARAMS ((bfd *));
-bfd_boolean cisco_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
+#define cisco_core_file_matches_executable_p generic_core_file_matches_executable_p
\f
/* Examine the file for a crash info struct at the offset given by
CRASH_INFO_LOC. */
{
return abfd->tdata.cisco_core_data->sig;
}
-
-bfd_boolean
-cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd ATTRIBUTE_UNUSED;
- bfd *exec_bfd ATTRIBUTE_UNUSED;
-{
- return TRUE;
-}
\f
extern const bfd_target cisco_core_little_vec;
return BFD_SEND (core_bfd, _core_file_matches_executable_p,
(core_bfd, exec_bfd));
}
+
+/*
+FUNCTION
+ generic_core_file_matches_executable_p
+
+SYNOPSIS
+ bfd_boolean generic_core_file_matches_executable_p
+ (bfd *core_bfd, bfd *exec_bfd)
+
+DESCRIPTION
+ Return TRUE if the core file attached to @var{core_bfd}
+ was generated by a run of the executable file attached
+ to @var{exec_bfd}. The match is based on executable
+ basenames only.
+
+ Note: When not able to determine the core file failing
+ command or the executable name, we still return TRUE even
+ though we're not sure that core file and executable match.
+ This is to avoid generating a false warning in situations
+ where we really don't know whether they match or not.
+*/
+
+bfd_boolean
+generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
+{
+ char *exec;
+ char *core;
+ char *last_slash;
+
+ if (exec_bfd == NULL || core_bfd == NULL)
+ return TRUE;
+
+ /* The cast below is to avoid a compiler warning due to the assignment
+ of the const char * returned by bfd_core_file_failing_command to a
+ non-const char *. In this case, the assignement does not lead to
+ breaking the const, as we're only reading the string. */
+
+ core = (char *) bfd_core_file_failing_command (core_bfd);
+ if (core == NULL)
+ return TRUE;
+
+ exec = bfd_get_filename (exec_bfd);
+ if (exec == NULL)
+ return TRUE;
+
+ last_slash = strrchr (core, '/');
+ if (last_slash != NULL)
+ core = last_slash + 1;
+
+ last_slash = strrchr (exec, '/');
+ if (last_slash != NULL)
+ exec = last_slash + 1;
+
+ return strcmp (exec, core) == 0;
+}
+
PARAMS ((bfd *));
static int hppabsd_core_core_file_failing_signal
PARAMS ((bfd *));
-static bfd_boolean hppabsd_core_core_file_matches_executable_p
- PARAMS ((bfd *, bfd *));
+#define hppabsd_core_core_file_matches_executable_p generic_core_file_matches_executable_p
static void swap_abort
PARAMS ((void));
{
return core_signal (abfd);
}
-
-static bfd_boolean
-hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- /* There's no way to know this... */
- return TRUE;
-}
\f
/* If somebody calls any byte-swapping routines, shoot them. */
static void
#define core_command(bfd) (core_hdr(bfd)->cmd)
#define core_kernel_thread_id(bfd) (core_hdr(bfd)->lwpid)
#define core_user_thread_id(bfd) (core_hdr(bfd)->user_tid)
+#define hpux_core_core_file_matches_executable_p generic_core_file_matches_executable_p
-static asection *make_bfd_asection
- PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma,
- unsigned int));
-static const bfd_target *hpux_core_core_file_p
- PARAMS ((bfd *));
-static char *hpux_core_core_file_failing_command
- PARAMS ((bfd *));
-static int hpux_core_core_file_failing_signal
- PARAMS ((bfd *));
-static bfd_boolean hpux_core_core_file_matches_executable_p
- PARAMS ((bfd *, bfd *));
-static void swap_abort
- PARAMS ((void));
+static asection *make_bfd_asection (bfd *, const char *, flagword,
+ bfd_size_type, bfd_vma, unsigned int);
+static const bfd_target *hpux_core_core_file_p (bfd *);
+static char *hpux_core_core_file_failing_command (bfd *);
+static int hpux_core_core_file_failing_signal (bfd *);
+static void swap_abort (void);
static asection *
-make_bfd_asection (abfd, name, flags, size, vma, alignment_power)
- bfd *abfd;
- const char *name;
- flagword flags;
- bfd_size_type size;
- bfd_vma vma;
- unsigned int alignment_power;
+make_bfd_asection (bfd *abfd, const char *name, flagword flags,
+ bfd_size_type size, bfd_vma vma,
+ unsigned int alignment_power)
{
asection *asect;
char *newname;
asection *sect,
void *obj ATTRIBUTE_UNUSED)
{
- return (strncmp (bfd_section_name (abfd, sect), ".reg/", 5) == 0);
+ return (strncmp (sect->name, ".reg/", 5) == 0);
}
/* this function builds a bfd target if the file is a corefile.
(I am just guessing here!)
*/
static const bfd_target *
-hpux_core_core_file_p (abfd)
- bfd *abfd;
+hpux_core_core_file_p (bfd *abfd)
{
int good_sections = 0;
int unknown_sections = 0;
}
static char *
-hpux_core_core_file_failing_command (abfd)
- bfd *abfd;
+hpux_core_core_file_failing_command (bfd *abfd)
{
return core_command (abfd);
}
static int
-hpux_core_core_file_failing_signal (abfd)
- bfd *abfd;
+hpux_core_core_file_failing_signal (bfd *abfd)
{
return core_signal (abfd);
}
-static bfd_boolean
-hpux_core_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd ATTRIBUTE_UNUSED;
- bfd *exec_bfd ATTRIBUTE_UNUSED;
-{
- return TRUE; /* FIXME, We have no way of telling at this point */
-}
\f
/* If somebody calls any byte-swapping routines, shoot them. */
static void
-swap_abort ()
+swap_abort (void)
{
abort(); /* This way doesn't require any declaration for ANSI to fuck up */
}
#define core_signal(bfd) (core_hdr(bfd)->sig)
#define core_command(bfd) (core_hdr(bfd)->cmd)
+#define irix_core_core_file_matches_executable_p generic_core_file_matches_executable_p
+
static asection *make_bfd_asection
(bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr);
return core_signal (abfd);
}
-static bfd_boolean
-irix_core_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED,
- bfd *exec_bfd ATTRIBUTE_UNUSED)
-{
- return TRUE; /* XXX - FIXME */
-}
-
/* If somebody calls any byte-swapping routines, shoot them. */
static void
swap_abort(void)
extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
(bfd *, bfd *);
+/* A generic implementation of CORE_FILE_MATCHES_EXECUTABLE_P that
+ is independent of the target. */
+
+extern bfd_boolean generic_core_file_matches_executable_p
+ (bfd *core_bfd, bfd *exec_bfd);
+
/* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
(bfd *, bfd *);
+/* A generic implementation of CORE_FILE_MATCHES_EXECUTABLE_P that
+ is independent of the target. */
+
+extern bfd_boolean generic_core_file_matches_executable_p
+ (bfd *core_bfd, bfd *exec_bfd);
+
/* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
#define core_signal(bfd) (core_hdr(bfd)->sig)
#define core_command(bfd) (core_hdr(bfd)->cmd)
+#define lynx_core_file_matches_executable_p generic_core_file_matches_executable_p
+
/* Handle Lynx core dump file. */
static asection *
return core_signal (abfd);
}
-bfd_boolean
-lynx_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- return TRUE; /* FIXME, We have no way of telling at this point */
-}
-
#endif /* LYNX_CORE */
#define bfd_mach_o_bfd_discard_group bfd_generic_discard_group
#define bfd_mach_o_section_already_linked _bfd_generic_section_already_linked
#define bfd_mach_o_bfd_copy_private_header_data _bfd_generic_bfd_copy_private_header_data
+#define bfd_mach_o_core_file_matches_executable_p generic_core_file_matches_executable_p
/* The flags field of a section structure is separated into two parts a section
return 0;
}
-bfd_boolean
-bfd_mach_o_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED,
- bfd *exec_bfd ATTRIBUTE_UNUSED)
-{
- return TRUE;
-}
-
#define TARGET_NAME mach_o_be_vec
#define TARGET_STRING "mach-o-be"
#define TARGET_BIG_ENDIAN 1
OpenBSD/sparc64. */
#define SPARC64_WCOOKIE_OFFSET 832
+#define netbsd_core_file_matches_executable_p generic_core_file_matches_executable_p
+
struct netbsd_core_struct
{
struct core core;
/*return core_signal (abfd);*/
return abfd->tdata.netbsd_core_data->core.c_signo;
}
-
-static bfd_boolean
-netbsd_core_file_matches_executable_p (bfd *core_bfd ATTRIBUTE_UNUSED,
- bfd *exec_bfd ATTRIBUTE_UNUSED)
-{
- /* FIXME, We have no way of telling at this point. */
- return TRUE;
-}
\f
/* If somebody calls any byte-swapping routines, shoot them. */
PARAMS ((bfd *));
static int osf_core_core_file_failing_signal
PARAMS ((bfd *));
-static bfd_boolean osf_core_core_file_matches_executable_p
- PARAMS ((bfd *, bfd *));
+#define osf_core_core_file_matches_executable_p generic_core_file_matches_executable_p
static void swap_abort
PARAMS ((void));
{
return core_signal (abfd);
}
-
-static bfd_boolean
-osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd ATTRIBUTE_UNUSED;
- bfd *exec_bfd ATTRIBUTE_UNUSED;
-{
- return TRUE; /* FIXME, We have no way of telling at this point */
-}
\f
/* If somebody calls any byte-swapping routines, shoot them. */
static void
const bfd_target *ptrace_unix_core_file_p PARAMS ((bfd *abfd));
char * ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd));
int ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd));
-bfd_boolean ptrace_unix_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
+#define ptrace_unix_core_file_matches_executable_p generic_core_file_matches_executable_p
static void swap_abort PARAMS ((void));
const bfd_target *
{
return abfd->tdata.trad_core_data->u.pt_sigframe.sig_num;
}
-
-bfd_boolean
-ptrace_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
-{
- /* FIXME: Use pt_timdat field of the ptrace_user structure to match
- the date of the executable */
- return TRUE;
-}
\f
/* If somebody calls any byte-swapping routines, shoot them. */
static void
const bfd_target *sco5_core_file_p PARAMS ((bfd *abfd));
char *sco5_core_file_failing_command PARAMS ((bfd *abfd));
int sco5_core_file_failing_signal PARAMS ((bfd *abfd));
-bfd_boolean sco5_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
+#define sco5_core_file_matches_executable_p generic_core_file_matches_executable_p
static void swap_abort PARAMS ((void));
static asection *
: -1);
}
-bfd_boolean
-sco5_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd ATTRIBUTE_UNUSED;
- bfd *exec_bfd ATTRIBUTE_UNUSED;
-{
- return TRUE; /* FIXME, We have no way of telling at this point */
-}
-
/* If somebody calls any byte-swapping routines, shoot them. */
static void
swap_abort ()
const bfd_target *trad_unix_core_file_p PARAMS ((bfd *abfd));
char * trad_unix_core_file_failing_command PARAMS ((bfd *abfd));
int trad_unix_core_file_failing_signal PARAMS ((bfd *abfd));
-bfd_boolean trad_unix_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
+#define trad_unix_core_file_matches_executable_p generic_core_file_matches_executable_p
static void swap_abort PARAMS ((void));
/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */
return -1; /* FIXME, where is it? */
#endif
}
-
-bfd_boolean
-trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd ATTRIBUTE_UNUSED;
- bfd *exec_bfd ATTRIBUTE_UNUSED;
-{
- return TRUE; /* FIXME, We have no way of telling at this point */
-}
\f
/* If somebody calls any byte-swapping routines, shoot them. */
static void