2010-08-18 Pedro Alves <pedro@codesourcery.com>
authorPedro Alves <palves@redhat.com>
Wed, 18 Aug 2010 12:24:13 +0000 (12:24 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 18 Aug 2010 12:24:13 +0000 (12:24 +0000)
PR corefile/8210

bfd/
* 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.

gdb/
2010-08-18  Pedro Alves  <pedro@codesourcery.com>

PR corefile/8210

gdb/
* 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.

55 files changed:
bfd/ChangeLog
bfd/aix386-core.c
bfd/aout-target.h
bfd/aout-tic30.c
bfd/bfd-in2.h
bfd/coff-rs6000.c
bfd/coff64-rs6000.c
bfd/corefile.c
bfd/elf-bfd.h
bfd/elf.c
bfd/elf32-am33lin.c
bfd/elf32-arm.c
bfd/elf32-cris.c
bfd/elf32-frv.c
bfd/elf32-hppa.c
bfd/elf32-i386.c
bfd/elf32-mips.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-score.c
bfd/elf32-score7.c
bfd/elf32-sh.c
bfd/elf32-xtensa.c
bfd/elf64-hppa.c
bfd/elf64-mips.c
bfd/elf64-ppc.c
bfd/elf64-x86-64.c
bfd/elfcode.h
bfd/elfcore.h
bfd/elfn32-mips.c
bfd/hppabsd-core.c
bfd/hpux-core.c
bfd/irix-core.c
bfd/libbfd-in.h
bfd/libbfd.c
bfd/libbfd.h
bfd/lynx-core.c
bfd/mach-o-target.c
bfd/netbsd-core.c
bfd/osf-core.c
bfd/plugin.c
bfd/ptrace-core.c
bfd/sco5-core.c
bfd/targets.c
bfd/trad-core.c
bfd/xcoff-target.h
gdb/ChangeLog
gdb/amd64-sol2-tdep.c
gdb/corelow.c
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/i386-sol2-tdep.c
gdb/sparc-sol2-tdep.c
gdb/sparc64-sol2-tdep.c

index 5f18054423fcd298b3fcf6636f54a3454c524b61..cfe91d979bfa760cc0305d2498e1f47623810b1c 100644 (file)
@@ -1,3 +1,89 @@
+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
index 4438e2801f3e45c688e1f6d7126b05708a22eb50..634d997c69b22afd5ddb21ebe14fb093f92815fe 100644 (file)
@@ -211,6 +211,8 @@ aix386_core_file_failing_signal (abfd)
 
 #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
index fe1d66e8795898a046455e3930293a9b5897ca95..51624947856cfb81bf78b797956a8079e1c5a7db 100644 (file)
@@ -401,6 +401,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
 #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
index 05e1a80191cf289d0885be225322eaf6d59b58b4..5d5c7e23b70c397663b6fd6b2e67950941dacc10 100644 (file)
@@ -859,6 +859,9 @@ tic30_aout_set_arch_mach (bfd *abfd,
 #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
index 277d4322d2336eb4bb47198f983460918dfc9c63..0e7b337f7719571f92f50be6caacbbd5e66e67c0 100644 (file)
@@ -1977,8 +1977,8 @@ enum bfd_architecture
 #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
@@ -5412,6 +5412,8 @@ const char *bfd_core_file_failing_command (bfd *abfd);
 
 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);
 
@@ -5608,11 +5610,13 @@ typedef struct bfd_target
 #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) \
index 37d668c97bd2e70df17250339ca4019a9a3dacbf..7fb20d8518e5b6ae483f333687cd048ec3973e06 100644 (file)
@@ -112,6 +112,8 @@ extern int rs6000coff_core_file_failing_signal
   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 \
@@ -120,6 +122,8 @@ extern int rs6000coff_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
 #endif
 #define coff_SWAP_sym_in _bfd_xcoff_swap_sym_in
 #define coff_SWAP_sym_out _bfd_xcoff_swap_sym_out
@@ -4182,9 +4186,7 @@ const bfd_target rs6000coff_vec =
     _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,
@@ -4437,9 +4439,7 @@ const bfd_target pmac_xcoff_vec =
     _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,
index 99cbfb7136d0a7ad3e65e6ffa4c6cb75d1c890d6..b154b6762101753bbe8dee531052296100bda6fd 100644 (file)
@@ -256,6 +256,8 @@ extern int rs6000coff_core_file_failing_signal
   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 \
@@ -264,6 +266,8 @@ extern int rs6000coff_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
 #endif
 #define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
 #define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
@@ -2753,9 +2757,7 @@ const bfd_target rs6000coff64_vec =
     _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,
@@ -2835,6 +2837,8 @@ extern char *xcoff64_core_file_failing_command
   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 =
@@ -3009,9 +3013,7 @@ const bfd_target aix5coff64_vec =
     _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,
index 7802a3a3fa297360036543abcd96f50a91589e86..605be8d33da1569edab9c2abc9b0bfa9cc7b58dc 100644 (file)
@@ -82,6 +82,31 @@ bfd_core_file_failing_signal (bfd *abfd)
   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
index 754e7335b651a997d1a9a5b0466d81c6a770ae07..2220d4db5c22749fef0750df45cd33183ef2353c 100644 (file)
@@ -1989,6 +1989,8 @@ extern int bfd_elf32_core_file_failing_signal
   (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 *);
@@ -2033,6 +2035,8 @@ extern int bfd_elf64_core_file_failing_signal
   (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 *);
index 90fc3d1286c2cb3d576488f0bce6b79a3898de1d..f9f2dadb59a51fdac793bbda00f940cc8ee97cb8 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -7519,13 +7519,19 @@ _bfd_elf_rel_vtable_reloc_fn
 # 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
@@ -7615,7 +7621,8 @@ elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
         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+
@@ -7625,6 +7632,8 @@ elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
         */
 #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)
@@ -7641,7 +7650,8 @@ elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
         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+
@@ -7651,6 +7661,8 @@ elfcore_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
         */
 #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 */
index c3ec2dcc454b54e6571ac7629064d909ab24be30..177a7140de7d0dda6a4637f3dba8154166f7e761 100644 (file)
@@ -55,7 +55,7 @@ elf32_am33lin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index f6115bd24e37ea698234457a7b2fbaee21a5c3a7..0cd1e644e8575f5a3fd665e3f1ee7cfd43f08135 100644 (file)
@@ -1829,7 +1829,7 @@ elf32_arm_nabi_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index 1783ae3b66c0e01dfd3d37badd3baafbb4a24d64..0129d6a81486b1ffd38db8fe5bfa98fb544b3232 100644 (file)
@@ -580,7 +580,7 @@ cris_elf_grok_prstatus (abfd, note)
        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;
@@ -599,7 +599,7 @@ cris_elf_grok_prstatus (abfd, note)
        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;
index 8d940c089086556200870b275de6337059101f5f..811d5f5b3ae41ccff1992a498872219a9eeaa9f5 100644 (file)
@@ -6935,7 +6935,7 @@ elf32_frv_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index 32a374fbc512632e08eb7cd4df7e00423c75b17b..794de8282cad92214365a75fda392a1fd48721e0 100644 (file)
@@ -1736,7 +1736,7 @@ elf32_hppa_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index 4ba1ba035d922134de09abedab483ff642eae8b2..581f218c8ca82fe4ea41705560e3875b4c2db0bf 100644 (file)
@@ -419,7 +419,7 @@ elf_i386_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
       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;
@@ -437,7 +437,7 @@ elf_i386_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
          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;
@@ -475,6 +475,8 @@ elf_i386_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
          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
index 5155557913754ab4c42832392fe42d75a4719e86..aabf2847fedc968587064c4f0cb070adcd60c89f 100644 (file)
@@ -1506,7 +1506,7 @@ elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index e3638cd20c68dca4af259cab108758752f408dda..eb8d5404e5f825074f992c2a4ba882ae8d3b1c3b 100644 (file)
@@ -1858,7 +1858,7 @@ ppc_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
       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;
index 336ba36e8dce9cbbdb315467a747353ffcd9c321..4f9e0b336368cdb78768039feabd5046b9fa9dd8 100644 (file)
@@ -3462,7 +3462,7 @@ elf_s390_grok_prstatus (abfd, note)
        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;
index b443b601afcaac8c6cccab40b6854b565e919278..f1f1aae1e721c6566562298ef92a37d5dfa8996b 100644 (file)
@@ -3917,7 +3917,7 @@ s3_bfd_score_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
       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;
index 31784105f95caea7745a62a9c7b524587fc2e2d0..85ce236a4f15a81f070433951447499f1534f5b3 100644 (file)
@@ -3734,7 +3734,7 @@ s7_bfd_score_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
       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;
index bde565ee4694a28805db66997fd33c4c58807c78..a4fdd707439423a6bd4effe61a7a0ae02f2c7217 100644 (file)
@@ -7438,7 +7438,7 @@ elf32_shlin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index 770d9a82d438201189db926aa8d4b0f24ecaac7f..12788ec5fac7f339eb2b70b1267879dce724c6dd 100644 (file)
@@ -3802,7 +3802,7 @@ elf_xtensa_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
   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;
index 9ccb518dbb7e003aa7661e7d85a56c856f20e723..e76593db34f3b25bbc969ef6d7dc294a35f30c3c 100644 (file)
@@ -2611,7 +2611,7 @@ elf64_hppa_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index 95186d4c3aa5c82877120b17d7a43f6630ea79bc..33d7a87d105d7188087a740d26d46fa4ea55aead 100644 (file)
@@ -3083,7 +3083,7 @@ elf64_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index b6ef660046ed18f0796eaa593f61c39d68663c05..954d18df3a16eefdf12353203c0423f507ab9f4a 100644 (file)
@@ -2651,7 +2651,7 @@ ppc64_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
   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;
index 9899fd4a34d848e890fb8e7d984a51956cac8e57..f11584b8a927695a3bb1e14a9cac3c187ec291e8 100644 (file)
@@ -308,7 +308,7 @@ elf64_x86_64_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
          = 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 */
@@ -332,6 +332,8 @@ elf64_x86_64_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
        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
index cd06455664d1613933a4fab386518ab40422061d..f7c89263eeab373f72918a5830e8cc6586a1127c 100644 (file)
@@ -87,6 +87,7 @@
 #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)
index 168c81ae21b0b0c2acd1e2b3c3302c4e4aba63ca..81980c0fecc49a5fb1a353971ea69c6ae9b9fdf0 100644 (file)
@@ -31,6 +31,12 @@ elf_core_file_failing_signal (bfd *abfd)
   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)
 {
index a0725943e54502ea4ca643884b9be6345de0495d..0aa25e7280828e8701336945b96e9951ed051717 100644 (file)
@@ -2332,7 +2332,7 @@ elf32_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
        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;
index 9cac968dd21285e2eba368b23347b15ae45848b2..152d464d19075473aa73607c21159f283a262af8 100644 (file)
@@ -59,6 +59,7 @@ static char *hppabsd_core_core_file_failing_command
 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));
 
index fdcde7e54752812211d445163f075c0510ecd6fa..5199014307874e8e99bebdc88a24451804368015 100644 (file)
@@ -103,6 +103,7 @@ struct hpux_core_struct
 #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);
index 1feff87cfe729c7020b71339afe6121e5903aad3..eb930a4d2e8da018bfbc544e5336183caf819cd4 100644 (file)
@@ -44,6 +44,7 @@ struct sgi_core_struct
 #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);
index 87a73b4623928829ea925fd1cd0b170a026ebe1e..b5b614c96259933eb36cda0a544a7eb3ff0b31dc 100644 (file)
@@ -270,6 +270,8 @@ extern int _bfd_nocore_core_file_failing_signal
   (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).  */
index b378622b6bc25645611cce217568bcd7c79f09b3..5146d9525e1cc0b7b18d6c7943edf3317aba1e97 100644 (file)
@@ -150,6 +150,16 @@ _bfd_nocore_core_file_failing_signal (bfd *ignore_abfd ATTRIBUTE_UNUSED)
   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)
 {
index 94bbd8ef5cd615807bcb509b8bcc366d55e6e106..fb95c40c1c3709ecfc0d8b04d8c068b14f385713 100644 (file)
@@ -275,6 +275,8 @@ extern int _bfd_nocore_core_file_failing_signal
   (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).  */
index a432566a973ca14da5b05de30eb354797c61f88b..ab6a834014cd98d62e6efbd53efd48a0b0538478 100644 (file)
@@ -53,6 +53,7 @@ struct lynx_core_struct
 #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.  */
 
index c9b974e8a52b5506b0c025f77d18f4b5c9fdf91f..64c7ddf5b65f16a63259cc1550eef2c5e61a3428 100644 (file)
@@ -58,6 +58,7 @@
 #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
index 397f1d086acf50d1975754462bdb34ad0507626b..2458a8450bf2046ea619ca549be58d6e6c3ada82 100644 (file)
@@ -44,6 +44,7 @@
 #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
 {
index 513e52afc6b08ea88173d13793baad5ca57b5334..0ebbd1d4a2dc8dc792b6f2eb615dbe7ac3009a51 100644 (file)
@@ -43,6 +43,7 @@ static char *osf_core_core_file_failing_command
 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));
 
index 91bbfd1ff3caaa5dc3096b91b82aef6927bfe66d..4c24a7f6a22f36c384cbc12c50f8ea8f7afb0c2a 100644 (file)
@@ -319,6 +319,13 @@ bfd_plugin_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
   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)
 {
index ce621547fe47cf04cafeb08a0004a33e30e3ff5d..77eaaeb46a1a51d5c81247150cab71dd2361f5ef 100644 (file)
@@ -53,6 +53,7 @@ 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));
 #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 *
index 4b85fa5e6f16328cf315587cc73e6653e43ca98b..7f51a6f40bcfdbb49f1eb1013136d2b23b158e81 100644 (file)
@@ -51,6 +51,7 @@ 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));
 #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 *
index bb20189bfe0edbcd0415c49585bde7fb7675e943..aaf7e99c64f75ad11c910aadc0e2ef2cbab18339 100644 (file)
@@ -314,11 +314,13 @@ BFD_JUMP_TABLE macros.
 .#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) \
index e34851431855039f9921300e3a7dd74632b1d885..e06b56151f4b6872ac561a7637507ea6f0ec0917 100644 (file)
@@ -71,6 +71,7 @@ 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));
 #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.  */
index 4837fdff7a788ffc1eabda2367851c9ca7ade11f..b723eb706bcfd63e0793fb7779edd832210341b2 100644 (file)
@@ -51,6 +51,7 @@
 #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
index 02b2e5aa69231f598be46c89a0b02965ea74f127..eb3491a472296c6f8c2231e766cb1f81feea77e5 100644 (file)
@@ -1,3 +1,20 @@
+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.
index 0cf5e83b469bdba3e132346b6af9e87d83ca7b4f..e8c0a80332e79b6e9616fc7ebc32b75915abd6da 100644 (file)
@@ -114,10 +114,6 @@ amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   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);
 }
index 9d0047124fdc89388f5d860c4cfb4511c737de00..6e97962bfb360d3747df25b20943ad4a7d3696c6 100644 (file)
@@ -252,29 +252,15 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg)
 
   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);
 
@@ -520,21 +506,7 @@ get_core_register_section (struct regcache *regcache,
 
   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);
index 4ff9f542c7b29cbd05461f2ddc6935d907b501de..78e5c4869692dbab8fa9611349505642b3b57321 100644 (file)
@@ -234,7 +234,6 @@ struct gdbarch
   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;
@@ -385,7 +384,6 @@ struct gdbarch startup_gdbarch =
   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 */
@@ -667,7 +665,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* 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 */
@@ -817,9 +814,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   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));
@@ -3095,23 +3089,6 @@ set_gdbarch_regset_from_core_section (struct gdbarch *gdbarch,
   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)
 {
index f6c7ce81aefb548b1743f65364bd4b2e75a65e9e..443e1d5fd81acfd5ce391ada62b4cf9b479cc802 100644 (file)
@@ -666,15 +666,6 @@ typedef const struct regset * (gdbarch_regset_from_core_section_ftype) (struct g
 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);
index 10f9477b6fc97194248da2c0f98603e9967f9c1d..5b661167123180790f3527cda69951f6786afdbd 100755 (executable)
@@ -612,13 +612,6 @@ F:CORE_ADDR:fetch_pointer_argument:struct frame_info *frame, int argi, struct ty
 # 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)
 
index 49a338722ae527249219bb796d25666810c86463..d656d87b275eaf44270aa65df0f7ed750fd19f0b 100644 (file)
@@ -136,10 +136,6 @@ i386_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   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);
 }
index a2f3521caea817965e32163090603fca9662c972..62d113cf4bc9a3d578fd9dc8c61325e20be89ff9 100644 (file)
@@ -232,10 +232,6 @@ sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   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);
 }
index 0c2b9016f2990390e42abc09dc0e81432784dd7c..4e57ff15f17b80eed77fbdfd2055ca22592a6771 100644 (file)
@@ -181,10 +181,6 @@ sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* 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);
 }