+2010-08-18 Pedro Alves <pedro@codesourcery.com>
+
+ PR corefile/8210
+
+ * bfd-in2.h: Regenerate.
+ * corefile.c (bfd_core_file_pid): New.
+
+ * targets.c (BFD_JUMP_TABLE_CORE): Add NAME##_core_file_pid.
+ (struct bfd_target) <_core_file_pid>: New.
+
+ * libbfd-in.h (_bfd_nocore_core_file_pid): Declare.
+ * libbfd.c (_bfd_nocore_core_file_pid): New.
+
+ * elf-bfd.h (bfd_elf32_core_file_pid, bfd_elf64_core_file_pid):
+ Declare.
+ * elfcode.h (elf_core_file_pid): New define.
+ * elfcore.h (elf_core_file_pid): New function.
+
+ * elf.c (elfcore_make_pid): Rewrite.
+ (elfcore_grok_prstatus): Only set core_pid if not set yet.
+ (elfcore_grok_prstatus) [!HAVE_PRSTATUS_T_PR_WHO]: Fallback to
+ getting the lwpid from prstat.pr_pid.
+
+ * elf64-x86-64.c (elf64_x86_64_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ (elf64_x86_64_grok_psinfo): Extract the the main process's PID,
+ and store it in elf_tdata's core_pid field.
+ * elf32-i386.c (elf_i386_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ (elf_i386_grok_psinfo): Extract the the main process's PID, and
+ store it in elf_tdata's core_pid field.
+
+ * elf32-am33lin.c (elf32_am33lin_grok_prstatus): Write the LWPID
+ to elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-arm.c (elf32_arm_nabi_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-cris.c (cris_elf_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-frv.c (elf32_frv_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-hppa.c (elf32_hppa_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-ppc.c (ppc_elf_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-s390.c (elf_s390_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-score.c (s3_bfd_score_elf_grok_prstatus): Write the LWPID
+ to elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-score7.c (s7_bfd_score_elf_grok_prstatus): Write the LWPID
+ to elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-sh.c (elf32_shlin_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf32-xtensa.c (elf_xtensa_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf64-hppa.c (elf64_hppa_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf64-mips.c (elf64_mips_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elf64-ppc.c (ppc64_elf_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+ * elfn32-mips.c (elf32_mips_grok_prstatus): Write the LWPID to
+ elf_tdata's core_lwpid instead of to core_pid.
+
+ * plugin.c (bfd_plugin_core_file_pid): New function.
+ * aout-target.h (MY_core_file_pid): Define.
+ * aout-tic30.c (MY_core_file_pid, MY_core_file_p): New defines.
+ * coff-rs6000.c (coff_core_file_pid): New define.
+ (rs6000coff_vec, pmac_xcoff_vec): Use BFD_JUMP_TABLE_CORE.
+ * coff64-rs6000.c (coff_core_file_pid): New define.
+ (rs6000coff64_vec): Use BFD_JUMP_TABLE_CORE.
+ (xcoff64_core_file_pid): New define.
+ (aix5coff64_vec): Use BFD_JUMP_TABLE_CORE.
+ * mach-o-target.c (bfd_mach_o_core_file_pid): New define.
+ * aix386-core.c (aix386_core_file_pid): New define.
+ * hppabsd-core.c (hppabsd_core_core_file_pid): New define.
+ * hpux-core.c (hpux_core_core_file_pid): New define.
+ * irix-core.c (irix_core_core_file_pid): New define.
+ * lynx-core.c (lynx_core_file_pid): New define.
+ * osf-core.c (osf_core_core_file_pid): New define.
+ * ptrace-core.c (ptrace_unix_core_file_pid): New define.
+ * sco5-core.c (sco5_core_file_pid): New define.
+ * xcoff-target.h (coff_core_file_pid): New define.
+ * netbsd-core.c (netbsd_core_core_file_pid): New define.
+
2010-08-13 H.J. Lu <hongjiu.lu@intel.com>
PR ld/11913
#define aix386_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define aix386_core_file_pid _bfd_nocore_core_file_pid
+
/* If somebody calls any byte-swapping routines, shoot them. */
static void
#define MY_core_file_matches_executable_p \
_bfd_nocore_core_file_matches_executable_p
#endif
+#ifndef MY_core_file_pid
+#define MY_core_file_pid _bfd_nocore_core_file_pid
+#endif
#ifndef MY_core_file_p
#define MY_core_file_p _bfd_dummy_target
#endif
#define MY_core_file_matches_executable_p \
_bfd_nocore_core_file_matches_executable_p
#endif
+#ifndef MY_core_file_pid
+#define MY_core_file_pid _bfd_nocore_core_file_pid
+#endif
#ifndef MY_core_file_p
#define MY_core_file_p _bfd_dummy_target
#endif
#define bfd_mach_v850 1
#define bfd_mach_v850e 'E'
#define bfd_mach_v850e1 '1'
-#define bfd_mach_v850e2 0x4532 /* ('E'<<8|'2') */
-#define bfd_mach_v850e2v3 0x45325633 /* ('E'<<24|'2'<<16|'V'<<8|'3') */
+#define bfd_mach_v850e2 0x4532
+#define bfd_mach_v850e2v3 0x45325633
bfd_arch_arc, /* ARC Cores */
#define bfd_mach_arc_5 5
#define bfd_mach_arc_6 6
int bfd_core_file_failing_signal (bfd *abfd);
+int bfd_core_file_pid (bfd *abfd);
+
bfd_boolean core_file_matches_executable_p
(bfd *core_bfd, bfd *exec_bfd);
#define BFD_JUMP_TABLE_CORE(NAME) \
NAME##_core_file_failing_command, \
NAME##_core_file_failing_signal, \
- NAME##_core_file_matches_executable_p
+ NAME##_core_file_matches_executable_p, \
+ NAME##_core_file_pid
char * (*_core_file_failing_command) (bfd *);
int (*_core_file_failing_signal) (bfd *);
bfd_boolean (*_core_file_matches_executable_p) (bfd *, bfd *);
+ int (*_core_file_pid) (bfd *);
/* Archive entry points. */
#define BFD_JUMP_TABLE_ARCHIVE(NAME) \
rs6000coff_core_file_failing_signal
#define coff_core_file_matches_executable_p \
rs6000coff_core_file_matches_executable_p
+#define coff_core_file_pid \
+ _bfd_nocore_core_file_pid
#else
#define CORE_FILE_P _bfd_dummy_target
#define coff_core_file_failing_command \
_bfd_nocore_core_file_failing_signal
#define coff_core_file_matches_executable_p \
_bfd_nocore_core_file_matches_executable_p
+#define coff_core_file_pid \
+ _bfd_nocore_core_file_pid
#endif
#define coff_SWAP_sym_in _bfd_xcoff_swap_sym_in
#define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out
_bfd_generic_bfd_print_private_bfd_data,
/* Core */
- coff_core_file_failing_command,
- coff_core_file_failing_signal,
- coff_core_file_matches_executable_p,
+ BFD_JUMP_TABLE_CORE (coff),
/* Archive */
_bfd_xcoff_slurp_armap,
_bfd_generic_bfd_print_private_bfd_data,
/* Core */
- coff_core_file_failing_command,
- coff_core_file_failing_signal,
- coff_core_file_matches_executable_p,
+ BFD_JUMP_TABLE_CORE (coff),
/* Archive */
_bfd_xcoff_slurp_armap,
rs6000coff_core_file_failing_signal
#define coff_core_file_matches_executable_p \
rs6000coff_core_file_matches_executable_p
+#define coff_core_file_pid \
+ _bfd_nocore_core_file_pid
#else
#define CORE_FILE_P _bfd_dummy_target
#define coff_core_file_failing_command \
_bfd_nocore_core_file_failing_signal
#define coff_core_file_matches_executable_p \
_bfd_nocore_core_file_matches_executable_p
+#define coff_core_file_pid \
+ _bfd_nocore_core_file_pid
#endif
#define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
#define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
_bfd_generic_bfd_print_private_bfd_data,
/* Core */
- coff_core_file_failing_command,
- coff_core_file_failing_signal,
- coff_core_file_matches_executable_p,
+ BFD_JUMP_TABLE_CORE (coff),
/* Archive */
xcoff64_slurp_armap,
PARAMS ((bfd *));
extern int xcoff64_core_file_failing_signal
PARAMS ((bfd *));
+#define xcoff64_core_file_pid \
+ _bfd_nocore_core_file_pid
/* AIX 5 */
static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data =
_bfd_generic_bfd_print_private_bfd_data,
/* Core */
- xcoff64_core_file_failing_command,
- xcoff64_core_file_failing_signal,
- xcoff64_core_file_matches_executable_p,
+ BFD_JUMP_TABLE_CORE (xcoff64),
/* Archive */
xcoff64_slurp_armap,
return BFD_SEND (abfd, _core_file_failing_signal, (abfd));
}
+/*
+FUNCTION
+ bfd_core_file_pid
+
+SYNOPSIS
+ int bfd_core_file_pid (bfd *abfd);
+
+DESCRIPTION
+
+ Returns the PID of the process the core dump the BFD
+ @var{abfd} is attached to was generated from.
+*/
+
+int
+bfd_core_file_pid (bfd *abfd)
+{
+ if (abfd->format != bfd_core)
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return 0;
+ }
+ return BFD_SEND (abfd, _core_file_pid, (abfd));
+}
+
+
/*
FUNCTION
core_file_matches_executable_p
(bfd *);
extern bfd_boolean bfd_elf32_core_file_matches_executable_p
(bfd *, bfd *);
+extern int bfd_elf32_core_file_pid
+ (bfd *);
extern bfd_boolean bfd_elf32_swap_symbol_in
(bfd *, const void *, const void *, Elf_Internal_Sym *);
(bfd *);
extern bfd_boolean bfd_elf64_core_file_matches_executable_p
(bfd *, bfd *);
+extern int bfd_elf64_core_file_pid
+ (bfd *);
extern bfd_boolean bfd_elf64_swap_symbol_in
(bfd *, const void *, const void *, Elf_Internal_Sym *);
# include <sys/procfs.h>
#endif
-/* FIXME: this is kinda wrong, but it's what gdb wants. */
+/* Return a PID that identifies a "thread" for threaded cores, or the
+ PID of the main process for non-threaded cores. */
static int
elfcore_make_pid (bfd *abfd)
{
- return ((elf_tdata (abfd)->core_lwpid << 16)
- + (elf_tdata (abfd)->core_pid));
+ int pid;
+
+ pid = elf_tdata (abfd)->core_lwpid;
+ if (pid == 0)
+ pid = elf_tdata (abfd)->core_pid;
+
+ return pid;
}
/* If there isn't a section called NAME, make one, using
has already been set by another thread. */
if (elf_tdata (abfd)->core_signal == 0)
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
- elf_tdata (abfd)->core_pid = prstat.pr_pid;
+ if (elf_tdata (abfd)->core_pid == 0)
+ elf_tdata (abfd)->core_pid = prstat.pr_pid;
/* pr_who exists on:
solaris 2.5+
*/
#if defined (HAVE_PRSTATUS_T_PR_WHO)
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
+#else
+ elf_tdata (abfd)->core_lwpid = prstat.pr_pid;
#endif
}
#if defined (HAVE_PRSTATUS32_T)
has already been set by another thread. */
if (elf_tdata (abfd)->core_signal == 0)
elf_tdata (abfd)->core_signal = prstat.pr_cursig;
- elf_tdata (abfd)->core_pid = prstat.pr_pid;
+ if (elf_tdata (abfd)->core_pid == 0)
+ elf_tdata (abfd)->core_pid = prstat.pr_pid;
/* pr_who exists on:
solaris 2.5+
*/
#if defined (HAVE_PRSTATUS32_T_PR_WHO)
elf_tdata (abfd)->core_lwpid = prstat.pr_who;
+#else
+ elf_tdata (abfd)->core_lwpid = prstat.pr_pid;
#endif
}
#endif /* HAVE_PRSTATUS32_T */
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 22);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 22);
/* pr_reg */
offset = 70;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 22);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 22);
/* pr_reg */
offset = 70;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* `pr_pid' is at offset 24. */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* `pr_reg' is at offset 72. */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_32 (abfd, note->descdata + 20);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 28;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
return FALSE;
case 124: /* Linux/i386 elf_prpsinfo. */
+ elf_tdata (abfd)->core_pid
+ = bfd_get_32 (abfd, note->descdata + 12);
elf_tdata (abfd)->core_program
= _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
elf_tdata (abfd)->core_command
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = score_bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = score_bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = score_bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
/* pr_reg */
offset = 112;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
/* pr_reg */
offset = 112;
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 32);
/* pr_reg */
offset = 112;
= bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid
+ elf_tdata (abfd)->core_lwpid
= bfd_get_32 (abfd, note->descdata + 32);
/* pr_reg */
return FALSE;
case 136: /* sizeof(struct elf_prpsinfo) on Linux/x86_64 */
+ elf_tdata (abfd)->core_pid
+ = bfd_get_32 (abfd, note->descdata + 24);
elf_tdata (abfd)->core_program
= _bfd_elfcore_strndup (abfd, note->descdata + 40, 16);
elf_tdata (abfd)->core_command
#define elf_core_file_failing_signal NAME(bfd_elf,core_file_failing_signal)
#define elf_core_file_matches_executable_p \
NAME(bfd_elf,core_file_matches_executable_p)
+#define elf_core_file_pid NAME(bfd_elf,core_file_pid)
#define elf_object_p NAME(bfd_elf,object_p)
#define elf_core_file_p NAME(bfd_elf,core_file_p)
#define elf_get_symtab_upper_bound NAME(bfd_elf,get_symtab_upper_bound)
return elf_tdata (abfd)->core_signal;
}
+int
+elf_core_file_pid (bfd *abfd)
+{
+ return elf_tdata (abfd)->core_pid;
+}
+
bfd_boolean
elf_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd)
{
elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
static int hppabsd_core_core_file_failing_signal
PARAMS ((bfd *));
#define hppabsd_core_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define hppabsd_core_core_file_pid _bfd_nocore_core_file_pid
static void swap_abort
PARAMS ((void));
#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
+#define hpux_core_core_file_pid _bfd_nocore_core_file_pid
static asection *make_bfd_asection (bfd *, const char *, flagword,
bfd_size_type, bfd_vma, unsigned int);
#define core_command(bfd) (core_hdr(bfd)->cmd)
#define irix_core_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define irix_core_core_file_pid _bfd_nocore_core_file_pid
static asection *make_bfd_asection
(bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr);
(bfd *);
extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
(bfd *, bfd *);
+extern int _bfd_nocore_core_file_pid
+ (bfd *);
/* Routines to use for BFD_JUMP_TABLE_ARCHIVE when there is no archive
file support. Use BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive). */
return 0;
}
+/* Routine to handle the core_file_pid entry point for targets without
+ core file support. */
+
+int
+_bfd_nocore_core_file_pid (bfd *ignore_abfd ATTRIBUTE_UNUSED)
+{
+ bfd_set_error (bfd_error_invalid_operation);
+ return 0;
+}
+
const bfd_target *
_bfd_dummy_target (bfd *ignore_abfd ATTRIBUTE_UNUSED)
{
(bfd *);
extern bfd_boolean _bfd_nocore_core_file_matches_executable_p
(bfd *, bfd *);
+extern int _bfd_nocore_core_file_pid
+ (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_command(bfd) (core_hdr(bfd)->cmd)
#define lynx_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define lynx_core_file_pid _bfd_nocore_core_file_pid
/* Handle Lynx core dump file. */
#define bfd_mach_o_bfd_define_common_symbol bfd_generic_define_common_symbol
#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
+#define bfd_mach_o_core_file_pid _bfd_nocore_core_file_pid
#define bfd_mach_o_get_dynamic_symtab_upper_bound bfd_mach_o_get_symtab_upper_bound
#define bfd_mach_o_canonicalize_dynamic_symtab bfd_mach_o_canonicalize_symtab
#define SPARC64_WCOOKIE_OFFSET 832
#define netbsd_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define netbsd_core_core_file_pid _bfd_nocore_core_file_pid
struct netbsd_core_struct
{
static int osf_core_core_file_failing_signal
PARAMS ((bfd *));
#define osf_core_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define osf_core_core_file_pid _bfd_nocore_core_file_pid
static void swap_abort
PARAMS ((void));
return 0;
}
+static int
+bfd_plugin_core_file_pid (bfd *abfd ATTRIBUTE_UNUSED)
+{
+ BFD_ASSERT (0);
+ return 0;
+}
+
static long
bfd_plugin_get_symtab_upper_bound (bfd *abfd)
{
char * ptrace_unix_core_file_failing_command PARAMS ((bfd *abfd));
int ptrace_unix_core_file_failing_signal PARAMS ((bfd *abfd));
#define ptrace_unix_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define ptrace_unix_core_file_pid _bfd_nocore_core_file_pid
static void swap_abort PARAMS ((void));
const bfd_target *
char *sco5_core_file_failing_command PARAMS ((bfd *abfd));
int sco5_core_file_failing_signal PARAMS ((bfd *abfd));
#define sco5_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define sco5_core_file_pid _bfd_nocore_core_file_pid
static void swap_abort PARAMS ((void));
static asection *
.#define BFD_JUMP_TABLE_CORE(NAME) \
. NAME##_core_file_failing_command, \
. NAME##_core_file_failing_signal, \
-. NAME##_core_file_matches_executable_p
+. NAME##_core_file_matches_executable_p, \
+. NAME##_core_file_pid
.
. char * (*_core_file_failing_command) (bfd *);
. int (*_core_file_failing_signal) (bfd *);
. bfd_boolean (*_core_file_matches_executable_p) (bfd *, bfd *);
+. int (*_core_file_pid) (bfd *);
.
. {* Archive entry points. *}
.#define BFD_JUMP_TABLE_ARCHIVE(NAME) \
char * trad_unix_core_file_failing_command PARAMS ((bfd *abfd));
int trad_unix_core_file_failing_signal PARAMS ((bfd *abfd));
#define trad_unix_core_file_matches_executable_p generic_core_file_matches_executable_p
+#define trad_unix_core_file_pid _bfd_nocore_core_file_pid
static void swap_abort PARAMS ((void));
/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */
#define coff_core_file_failing_command _bfd_nocore_core_file_failing_command
#define coff_core_file_failing_signal _bfd_nocore_core_file_failing_signal
#define coff_core_file_matches_executable_p _bfd_nocore_core_file_matches_executable_p
+#define coff_core_file_pid _bfd_nocore_core_file_pid
#define _bfd_xcoff_bfd_get_relocated_section_contents coff_bfd_get_relocated_section_contents
#define _bfd_xcoff_bfd_relax_section coff_bfd_relax_section
#define _bfd_xcoff_bfd_gc_sections coff_bfd_gc_sections
+2010-08-18 Pedro Alves <pedro@codesourcery.com>
+
+ PR corefile/8210
+
+ * corelow.c (add_to_thread_list): Don't use
+ gdbarch_core_reg_section_encodes_pid. Use bfd_core_file_pid.
+ (get_core_register_section): Don't use
+ gdbarch_core_reg_section_encodes_pid.
+
+ * gdbarch.sh (core_reg_section_encodes_pid): Delete.
+ * gdbarch.h, gdbarch.c: Regenerate.
+ * amd64-sol2-tdep.c (amd64_sol2_init_abi): Don't set
+ gdbarch_core_reg_section_encodes_pid.
+ * i386-sol2-tdep.c (i386_sol2_init_abi): Ditto.
+ * sparc-sol2-tdep.c (sparc32_sol2_init_abi): Ditto.
+ * sparc64-sol2-tdep.c (sparc64_sol2_init_abi): Ditto.
+
2010-08-18 Yao Qi <yao@codesourcery.com>
* MAINTAINERS : Add myself under Write After Approval.
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_lp64_fetch_link_map_offsets);
- /* Solaris encodes the pid of the inferior in regset section
- names. */
- set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
-
/* How to print LWP PTIDs from core files. */
set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
}
core_tid = atoi (bfd_section_name (abfd, asect) + 5);
- if (core_gdbarch
- && gdbarch_core_reg_section_encodes_pid (core_gdbarch))
- {
- uint32_t merged_pid = core_tid;
- pid = merged_pid & 0xffff;
- lwpid = merged_pid >> 16;
-
- /* This can happen on solaris core, for example, if we don't
- find a NT_PSTATUS note in the core, but do find NT_LWPSTATUS
- notes. */
- if (pid == 0)
- {
- core_has_fake_pid = 1;
- pid = CORELOW_PID;
- }
- }
- else
+ pid = bfd_core_file_pid (core_bfd);
+ if (pid == 0)
{
core_has_fake_pid = 1;
pid = CORELOW_PID;
- lwpid = core_tid;
}
+ lwpid = core_tid;
+
if (current_inferior ()->pid == 0)
inferior_appeared (current_inferior (), pid);
xfree (section_name);
- if (core_gdbarch
- && gdbarch_core_reg_section_encodes_pid (core_gdbarch))
- {
- uint32_t merged_pid;
- int pid = ptid_get_pid (inferior_ptid);
-
- if (core_has_fake_pid)
- pid = 0;
-
- merged_pid = ptid_get_lwp (inferior_ptid);
- merged_pid = merged_pid << 16 | pid;
-
- section_name = xstrprintf ("%s/%s", name, plongest (merged_pid));
- }
- else if (ptid_get_lwp (inferior_ptid))
+ if (ptid_get_lwp (inferior_ptid))
section_name = xstrprintf ("%s/%ld", name, ptid_get_lwp (inferior_ptid));
else
section_name = xstrdup (name);
gdbarch_register_reggroup_p_ftype *register_reggroup_p;
gdbarch_fetch_pointer_argument_ftype *fetch_pointer_argument;
gdbarch_regset_from_core_section_ftype *regset_from_core_section;
- int core_reg_section_encodes_pid;
struct core_regset_section * core_regset_sections;
gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries;
gdbarch_core_pid_to_str_ftype *core_pid_to_str;
default_register_reggroup_p, /* register_reggroup_p */
0, /* fetch_pointer_argument */
0, /* regset_from_core_section */
- 0, /* core_reg_section_encodes_pid */
0, /* core_regset_sections */
0, /* core_xfer_shared_libraries */
0, /* core_pid_to_str */
/* Skip verify of register_reggroup_p, invalid_p == 0 */
/* Skip verify of fetch_pointer_argument, has predicate */
/* Skip verify of regset_from_core_section, has predicate */
- /* Skip verify of core_reg_section_encodes_pid, invalid_p == 0 */
/* Skip verify of core_xfer_shared_libraries, has predicate */
/* Skip verify of core_pid_to_str, has predicate */
/* Skip verify of gcore_bfd_target, has predicate */
fprintf_unfiltered (file,
"gdbarch_dump: core_read_description = <%s>\n",
host_address_to_string (gdbarch->core_read_description));
- fprintf_unfiltered (file,
- "gdbarch_dump: core_reg_section_encodes_pid = %s\n",
- plongest (gdbarch->core_reg_section_encodes_pid));
fprintf_unfiltered (file,
"gdbarch_dump: core_regset_sections = %s\n",
host_address_to_string (gdbarch->core_regset_sections));
gdbarch->regset_from_core_section = regset_from_core_section;
}
-int
-gdbarch_core_reg_section_encodes_pid (struct gdbarch *gdbarch)
-{
- gdb_assert (gdbarch != NULL);
- /* Skip verify of core_reg_section_encodes_pid, invalid_p == 0 */
- if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_core_reg_section_encodes_pid called\n");
- return gdbarch->core_reg_section_encodes_pid;
-}
-
-void
-set_gdbarch_core_reg_section_encodes_pid (struct gdbarch *gdbarch,
- int core_reg_section_encodes_pid)
-{
- gdbarch->core_reg_section_encodes_pid = core_reg_section_encodes_pid;
-}
-
struct core_regset_section *
gdbarch_core_regset_sections (struct gdbarch *gdbarch)
{
extern const struct regset * gdbarch_regset_from_core_section (struct gdbarch *gdbarch, const char *sect_name, size_t sect_size);
extern void set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch, gdbarch_regset_from_core_section_ftype *regset_from_core_section);
-/* When creating core dumps, some systems encode the PID in addition
- to the LWP id in core file register section names. In those cases, the
- "XXX" in ".reg/XXX" is encoded as [LWPID << 16 | PID]. This setting
- is set to true for such architectures; false if "XXX" represents an LWP
- or thread id with no special encoding. */
-
-extern int gdbarch_core_reg_section_encodes_pid (struct gdbarch *gdbarch);
-extern void set_gdbarch_core_reg_section_encodes_pid (struct gdbarch *gdbarch, int core_reg_section_encodes_pid);
-
/* Supported register notes in a core file. */
extern struct core_regset_section * gdbarch_core_regset_sections (struct gdbarch *gdbarch);
# name SECT_NAME and size SECT_SIZE.
M:const struct regset *:regset_from_core_section:const char *sect_name, size_t sect_size:sect_name, sect_size
-# When creating core dumps, some systems encode the PID in addition
-# to the LWP id in core file register section names. In those cases, the
-# "XXX" in ".reg/XXX" is encoded as [LWPID << 16 | PID]. This setting
-# is set to true for such architectures; false if "XXX" represents an LWP
-# or thread id with no special encoding.
-v:int:core_reg_section_encodes_pid:::0:0::0
-
# Supported register notes in a core file.
v:struct core_regset_section *:core_regset_sections:const char *name, int len::::::host_address_to_string (gdbarch->core_regset_sections)
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
- /* Solaris encodes the pid of the inferior in regset section
- names. */
- set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
-
/* How to print LWP PTIDs from core files. */
set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
}
frame_unwind_append_unwinder (gdbarch, &sparc32_sol2_sigtramp_frame_unwind);
- /* Solaris encodes the pid of the inferior in regset section
- names. */
- set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
-
/* How to print LWP PTIDs from core files. */
set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
}
/* Solaris has kernel-assisted single-stepping support. */
set_gdbarch_software_single_step (gdbarch, NULL);
- /* Solaris encodes the pid of the inferior in regset section
- names. */
- set_gdbarch_core_reg_section_encodes_pid (gdbarch, 1);
-
/* How to print LWP PTIDs from core files. */
set_gdbarch_core_pid_to_str (gdbarch, sol2_core_pid_to_str);
}