[gdb/f14/master] - Display pthread_t for threads even from core files (PR 8210, BZ 673696).

Jan Kratochvil jankratochvil at fedoraproject.org
Sun Jan 30 19:39:55 UTC 2011


commit dedd61bd27bd8bc89658b8913418513ba30aabbc
Author: Jan Kratochvil <jan.kratochvil at redhat.com>
Date:   Sun Jan 30 20:39:39 2011 +0100

    - Display pthread_t for threads even from core files (PR 8210, BZ 673696).

 gdb-core-threads-1of5.patch |  898 +++++++++++++++++++++++++++++++++++++++++++
 gdb-core-threads-2of5.patch |  230 +++++++++++
 gdb-core-threads-3of5.patch |  194 ++++++++++
 gdb-core-threads-4of5.patch |   50 +++
 gdb-core-threads-5of5.patch |   81 ++++
 gdb.spec                    |   17 +-
 6 files changed, 1469 insertions(+), 1 deletions(-)
---
diff --git a/gdb-core-threads-1of5.patch b/gdb-core-threads-1of5.patch
new file mode 100644
index 0000000..b3f2875
--- /dev/null
+++ b/gdb-core-threads-1of5.patch
@@ -0,0 +1,898 @@
+http://sourceware.org/ml/binutils-cvs/2010-08/msg00105.html
+
+### src/bfd/ChangeLog	2010/08/13 20:50:25	1.5106
+### src/bfd/ChangeLog	2010/08/18 12:24:02	1.5107
+## -1,3 +1,89 @@
++2010-08-18  Pedro Alves  <pedro at 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 at intel.com>
+ 
+ 	PR ld/11913
+Index: gdb-7.2/bfd/aix386-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/aix386-core.c	2009-09-02 09:18:35.000000000 +0200
++++ gdb-7.2/bfd/aix386-core.c	2011-01-30 19:30:35.000000000 +0100
+@@ -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: gdb-7.2/bfd/aout-target.h
+===================================================================
+--- gdb-7.2.orig/bfd/aout-target.h	2010-03-24 16:41:58.000000000 +0100
++++ gdb-7.2/bfd/aout-target.h	2011-01-30 19:30:35.000000000 +0100
+@@ -401,6 +401,9 @@ MY_bfd_final_link (bfd *abfd, struct bfd
+ #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: gdb-7.2/bfd/aout-tic30.c
+===================================================================
+--- gdb-7.2.orig/bfd/aout-tic30.c	2010-03-24 16:41:58.000000000 +0100
++++ gdb-7.2/bfd/aout-tic30.c	2011-01-30 19:30:35.000000000 +0100
+@@ -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: gdb-7.2/bfd/bfd-in2.h
+===================================================================
+--- gdb-7.2.orig/bfd/bfd-in2.h	2010-06-29 06:17:20.000000000 +0200
++++ gdb-7.2/bfd/bfd-in2.h	2011-01-30 19:30:35.000000000 +0100
+@@ -5344,6 +5344,8 @@ const char *bfd_core_file_failing_comman
+ 
+ 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);
+ 
+@@ -5540,11 +5542,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: gdb-7.2/bfd/coff-rs6000.c
+===================================================================
+--- gdb-7.2.orig/bfd/coff-rs6000.c	2010-06-27 06:07:51.000000000 +0200
++++ gdb-7.2/bfd/coff-rs6000.c	2011-01-30 19:30:35.000000000 +0100
+@@ -112,6 +112,8 @@ extern int rs6000coff_core_file_failing_
+   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_
+   _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: gdb-7.2/bfd/coff64-rs6000.c
+===================================================================
+--- gdb-7.2.orig/bfd/coff64-rs6000.c	2010-03-24 16:41:58.000000000 +0100
++++ gdb-7.2/bfd/coff64-rs6000.c	2011-01-30 19:30:35.000000000 +0100
+@@ -256,6 +256,8 @@ extern int rs6000coff_core_file_failing_
+   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_
+   _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_c
+   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: gdb-7.2/bfd/corefile.c
+===================================================================
+--- gdb-7.2.orig/bfd/corefile.c	2007-07-03 16:26:40.000000000 +0200
++++ gdb-7.2/bfd/corefile.c	2011-01-30 19:30:35.000000000 +0100
+@@ -84,6 +84,31 @@ bfd_core_file_failing_signal (bfd *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
+ 
+ SYNOPSIS
+Index: gdb-7.2/bfd/elf-bfd.h
+===================================================================
+--- gdb-7.2.orig/bfd/elf-bfd.h	2011-01-30 19:30:14.000000000 +0100
++++ gdb-7.2/bfd/elf-bfd.h	2011-01-30 19:30:35.000000000 +0100
+@@ -1989,6 +1989,8 @@ extern int bfd_elf32_core_file_failing_s
+   (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_s
+   (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: gdb-7.2/bfd/elf.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf.c	2011-01-30 19:30:14.000000000 +0100
++++ gdb-7.2/bfd/elf.c	2011-01-30 19:30:35.000000000 +0100
+@@ -7513,13 +7513,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
+@@ -7609,7 +7615,8 @@ elfcore_grok_prstatus (bfd *abfd, Elf_In
+ 	 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+
+@@ -7619,6 +7626,8 @@ elfcore_grok_prstatus (bfd *abfd, Elf_In
+ 	 */
+ #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)
+@@ -7635,7 +7644,8 @@ elfcore_grok_prstatus (bfd *abfd, Elf_In
+ 	 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+
+@@ -7645,6 +7655,8 @@ elfcore_grok_prstatus (bfd *abfd, Elf_In
+ 	 */
+ #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: gdb-7.2/bfd/elf32-am33lin.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-am33lin.c	2007-07-03 16:26:40.000000000 +0200
++++ gdb-7.2/bfd/elf32-am33lin.c	2011-01-30 19:30:35.000000000 +0100
+@@ -55,7 +55,7 @@ elf32_am33lin_grok_prstatus (bfd *abfd, 
+ 	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: gdb-7.2/bfd/elf32-arm.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-arm.c	2010-06-27 06:07:51.000000000 +0200
++++ gdb-7.2/bfd/elf32-arm.c	2011-01-30 19:30:35.000000000 +0100
+@@ -1829,7 +1829,7 @@ elf32_arm_nabi_grok_prstatus (bfd *abfd,
+ 	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: gdb-7.2/bfd/elf32-cris.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-cris.c	2010-06-27 06:07:51.000000000 +0200
++++ gdb-7.2/bfd/elf32-cris.c	2011-01-30 19:30:35.000000000 +0100
+@@ -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: gdb-7.2/bfd/elf32-frv.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-frv.c	2010-02-04 10:16:39.000000000 +0100
++++ gdb-7.2/bfd/elf32-frv.c	2011-01-30 19:30:35.000000000 +0100
+@@ -6935,7 +6935,7 @@ elf32_frv_grok_prstatus (bfd *abfd, Elf_
+ 	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: gdb-7.2/bfd/elf32-hppa.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-hppa.c	2010-06-27 06:07:51.000000000 +0200
++++ gdb-7.2/bfd/elf32-hppa.c	2011-01-30 19:30:36.000000000 +0100
+@@ -1736,7 +1736,7 @@ elf32_hppa_grok_prstatus (bfd *abfd, Elf
+ 	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: gdb-7.2/bfd/elf32-i386.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-i386.c	2010-04-30 20:27:31.000000000 +0200
++++ gdb-7.2/bfd/elf32-i386.c	2011-01-30 19:30:36.000000000 +0100
+@@ -419,7 +419,7 @@ elf_i386_grok_prstatus (bfd *abfd, Elf_I
+       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_I
+ 	  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_Int
+ 	  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: gdb-7.2/bfd/elf32-mips.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-mips.c	2009-09-02 09:18:36.000000000 +0200
++++ gdb-7.2/bfd/elf32-mips.c	2011-01-30 19:30:36.000000000 +0100
+@@ -1507,7 +1507,7 @@ elf32_mips_grok_prstatus (bfd *abfd, Elf
+ 	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: gdb-7.2/bfd/elf32-ppc.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-ppc.c	2010-07-06 11:29:46.000000000 +0200
++++ gdb-7.2/bfd/elf32-ppc.c	2011-01-30 19:30:36.000000000 +0100
+@@ -1858,7 +1858,7 @@ ppc_elf_grok_prstatus (bfd *abfd, Elf_In
+       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: gdb-7.2/bfd/elf32-s390.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-s390.c	2010-02-04 10:16:39.000000000 +0100
++++ gdb-7.2/bfd/elf32-s390.c	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/elf32-score.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-score.c	2010-06-27 06:07:51.000000000 +0200
++++ gdb-7.2/bfd/elf32-score.c	2011-01-30 19:30:36.000000000 +0100
+@@ -3917,7 +3917,7 @@ s3_bfd_score_elf_grok_prstatus (bfd *abf
+       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: gdb-7.2/bfd/elf32-score7.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-score7.c	2010-06-27 06:07:52.000000000 +0200
++++ gdb-7.2/bfd/elf32-score7.c	2011-01-30 19:30:36.000000000 +0100
+@@ -3734,7 +3734,7 @@ s7_bfd_score_elf_grok_prstatus (bfd *abf
+       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: gdb-7.2/bfd/elf32-sh.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-sh.c	2010-06-27 06:07:52.000000000 +0200
++++ gdb-7.2/bfd/elf32-sh.c	2011-01-30 19:30:36.000000000 +0100
+@@ -7438,7 +7438,7 @@ elf32_shlin_grok_prstatus (bfd *abfd, El
+ 	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: gdb-7.2/bfd/elf32-xtensa.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf32-xtensa.c	2010-06-27 06:07:53.000000000 +0200
++++ gdb-7.2/bfd/elf32-xtensa.c	2011-01-30 19:30:36.000000000 +0100
+@@ -3802,7 +3802,7 @@ elf_xtensa_grok_prstatus (bfd *abfd, Elf
+   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: gdb-7.2/bfd/elf64-hppa.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf64-hppa.c	2010-06-27 06:07:53.000000000 +0200
++++ gdb-7.2/bfd/elf64-hppa.c	2011-01-30 19:30:36.000000000 +0100
+@@ -2611,7 +2611,7 @@ elf64_hppa_grok_prstatus (bfd *abfd, Elf
+ 	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: gdb-7.2/bfd/elf64-mips.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf64-mips.c	2010-03-24 16:41:59.000000000 +0100
++++ gdb-7.2/bfd/elf64-mips.c	2011-01-30 19:30:36.000000000 +0100
+@@ -3083,7 +3083,7 @@ elf64_mips_grok_prstatus (bfd *abfd, Elf
+ 	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: gdb-7.2/bfd/elf64-ppc.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf64-ppc.c	2010-07-01 11:48:26.000000000 +0200
++++ gdb-7.2/bfd/elf64-ppc.c	2011-01-30 19:30:36.000000000 +0100
+@@ -2651,7 +2651,7 @@ ppc64_elf_grok_prstatus (bfd *abfd, Elf_
+   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: gdb-7.2/bfd/elf64-x86-64.c
+===================================================================
+--- gdb-7.2.orig/bfd/elf64-x86-64.c	2010-04-30 20:27:31.000000000 +0200
++++ gdb-7.2/bfd/elf64-x86-64.c	2011-01-30 19:30:36.000000000 +0100
+@@ -308,7 +308,7 @@ elf64_x86_64_grok_prstatus (bfd *abfd, E
+ 	  = 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
+ 	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: gdb-7.2/bfd/elfcode.h
+===================================================================
+--- gdb-7.2.orig/bfd/elfcode.h	2010-05-26 09:37:36.000000000 +0200
++++ gdb-7.2/bfd/elfcode.h	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/elfcore.h
+===================================================================
+--- gdb-7.2.orig/bfd/elfcore.h	2010-01-19 14:50:55.000000000 +0100
++++ gdb-7.2/bfd/elfcore.h	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/elfn32-mips.c
+===================================================================
+--- gdb-7.2.orig/bfd/elfn32-mips.c	2009-09-02 09:18:36.000000000 +0200
++++ gdb-7.2/bfd/elfn32-mips.c	2011-01-30 19:30:36.000000000 +0100
+@@ -2333,7 +2333,7 @@ elf32_mips_grok_prstatus (bfd *abfd, Elf
+ 	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: gdb-7.2/bfd/hppabsd-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/hppabsd-core.c	2007-07-03 16:26:42.000000000 +0200
++++ gdb-7.2/bfd/hppabsd-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -59,6 +59,7 @@ static char *hppabsd_core_core_file_fail
+ 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: gdb-7.2/bfd/hpux-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/hpux-core.c	2009-09-02 09:18:37.000000000 +0200
++++ gdb-7.2/bfd/hpux-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/irix-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/irix-core.c	2009-09-02 09:18:37.000000000 +0200
++++ gdb-7.2/bfd/irix-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/libbfd-in.h
+===================================================================
+--- gdb-7.2.orig/bfd/libbfd-in.h	2010-06-08 10:26:01.000000000 +0200
++++ gdb-7.2/bfd/libbfd-in.h	2011-01-30 19:30:36.000000000 +0100
+@@ -270,6 +270,8 @@ extern int _bfd_nocore_core_file_failing
+   (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: gdb-7.2/bfd/libbfd.c
+===================================================================
+--- gdb-7.2.orig/bfd/libbfd.c	2009-12-11 14:42:04.000000000 +0100
++++ gdb-7.2/bfd/libbfd.c	2011-01-30 19:30:36.000000000 +0100
+@@ -150,6 +150,16 @@ _bfd_nocore_core_file_failing_signal (bf
+   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: gdb-7.2/bfd/libbfd.h
+===================================================================
+--- gdb-7.2.orig/bfd/libbfd.h	2010-06-29 06:17:22.000000000 +0200
++++ gdb-7.2/bfd/libbfd.h	2011-01-30 19:30:36.000000000 +0100
+@@ -275,6 +275,8 @@ extern int _bfd_nocore_core_file_failing
+   (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: gdb-7.2/bfd/lynx-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/lynx-core.c	2009-09-02 09:18:37.000000000 +0200
++++ gdb-7.2/bfd/lynx-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/mach-o-target.c
+===================================================================
+--- gdb-7.2.orig/bfd/mach-o-target.c	2010-03-24 16:41:59.000000000 +0100
++++ gdb-7.2/bfd/mach-o-target.c	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/netbsd-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/netbsd-core.c	2007-07-03 16:26:42.000000000 +0200
++++ gdb-7.2/bfd/netbsd-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/osf-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/osf-core.c	2009-09-02 09:18:37.000000000 +0200
++++ gdb-7.2/bfd/osf-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -43,6 +43,7 @@ static char *osf_core_core_file_failing_
+ 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: gdb-7.2/bfd/plugin.c
+===================================================================
+--- gdb-7.2.orig/bfd/plugin.c	2010-03-17 09:50:36.000000000 +0100
++++ gdb-7.2/bfd/plugin.c	2011-01-30 19:30:36.000000000 +0100
+@@ -319,6 +319,13 @@ bfd_plugin_core_file_failing_signal (bfd
+   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: gdb-7.2/bfd/ptrace-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/ptrace-core.c	2009-09-02 09:18:37.000000000 +0200
++++ gdb-7.2/bfd/ptrace-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -53,6 +53,7 @@ const bfd_target *ptrace_unix_core_file_
+ 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: gdb-7.2/bfd/sco5-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/sco5-core.c	2007-07-03 16:26:42.000000000 +0200
++++ gdb-7.2/bfd/sco5-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -51,6 +51,7 @@ const bfd_target *sco5_core_file_p PARAM
+ 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: gdb-7.2/bfd/targets.c
+===================================================================
+--- gdb-7.2.orig/bfd/targets.c	2010-06-29 06:17:22.000000000 +0200
++++ gdb-7.2/bfd/targets.c	2011-01-30 19:30:36.000000000 +0100
+@@ -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: gdb-7.2/bfd/trad-core.c
+===================================================================
+--- gdb-7.2.orig/bfd/trad-core.c	2007-07-15 08:33:34.000000000 +0200
++++ gdb-7.2/bfd/trad-core.c	2011-01-30 19:30:36.000000000 +0100
+@@ -71,6 +71,7 @@ const bfd_target *trad_unix_core_file_p 
+ 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: gdb-7.2/bfd/xcoff-target.h
+===================================================================
+--- gdb-7.2.orig/bfd/xcoff-target.h	2009-09-02 09:18:37.000000000 +0200
++++ gdb-7.2/bfd/xcoff-target.h	2011-01-30 19:30:36.000000000 +0100
+@@ -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
diff --git a/gdb-core-threads-2of5.patch b/gdb-core-threads-2of5.patch
new file mode 100644
index 0000000..5916b99
--- /dev/null
+++ b/gdb-core-threads-2of5.patch
@@ -0,0 +1,230 @@
+http://sourceware.org/ml/gdb-cvs/2010-08/msg00100.html
+
+### src/gdb/ChangeLog	2010/08/18 02:24:47	1.12092
+### src/gdb/ChangeLog	2010/08/18 12:24:08	1.12093
+## -1,3 +1,20 @@
++2010-08-18  Pedro Alves  <pedro at 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 at codesourcery.com>
+ 
+ 	* MAINTAINERS : Add myself under Write After Approval.
+--- src/gdb/amd64-sol2-tdep.c	2010/01/01 07:31:29	1.11
++++ src/gdb/amd64-sol2-tdep.c	2010/08/18 12:24:12	1.12
+@@ -114,10 +114,6 @@
+   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);
+ }
+--- src/gdb/corelow.c	2010/08/04 15:27:56	1.102
++++ src/gdb/corelow.c	2010/08/18 12:24:12	1.103
+@@ -252,29 +252,15 @@
+ 
+   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 @@
+ 
+   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);
+--- src/gdb/gdbarch.c	2010/08/06 19:02:14	1.470
++++ src/gdb/gdbarch.c	2010/08/18 12:24:12	1.471
+@@ -234,7 +234,6 @@
+   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 @@
+   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 @@
+   /* 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 */
+@@ -818,9 +815,6 @@
+                       "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));
+   fprintf_unfiltered (file,
+@@ -3095,23 +3089,6 @@
+   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)
+ {
+--- src/gdb/gdbarch.h	2010/08/06 19:02:14	1.419
++++ src/gdb/gdbarch.h	2010/08/18 12:24:12	1.420
+@@ -666,15 +666,6 @@
+ 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);
+--- src/gdb/gdbarch.sh	2010/08/06 19:02:14	1.515
++++ src/gdb/gdbarch.sh	2010/08/18 12:24:13	1.516
+@@ -612,13 +612,6 @@
+ # 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)
+ 
+--- src/gdb/i386-sol2-tdep.c	2010/01/01 07:31:34	1.29
++++ src/gdb/i386-sol2-tdep.c	2010/08/18 12:24:13	1.30
+@@ -136,10 +136,6 @@
+   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);
+ }
+--- src/gdb/sparc-sol2-tdep.c	2010/01/01 07:31:42	1.21
++++ src/gdb/sparc-sol2-tdep.c	2010/08/18 12:24:13	1.22
+@@ -232,10 +232,6 @@
+ 
+   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);
+ }
+--- src/gdb/sparc64-sol2-tdep.c	2010/01/01 07:31:42	1.20
++++ src/gdb/sparc64-sol2-tdep.c	2010/08/18 12:24:13	1.21
+@@ -181,10 +181,6 @@
+   /* 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);
+ }
diff --git a/gdb-core-threads-3of5.patch b/gdb-core-threads-3of5.patch
new file mode 100644
index 0000000..73575d6
--- /dev/null
+++ b/gdb-core-threads-3of5.patch
@@ -0,0 +1,194 @@
+http://sourceware.org/ml/gdb-cvs/2010-08/msg00101.html
+
+### src/gdb/ChangeLog	2010/08/18 12:24:08	1.12093
+### src/gdb/ChangeLog	2010/08/18 12:25:48	1.12094
+## -2,6 +2,27 @@
+ 
+ 	PR corefile/8210
+ 
++	* linux-thread-db.c (add_thread_db_info): Skip glibc/BZ5983
++	workaround on core files.
++	(try_thread_db_load_1): Don't try enabling thread event reporting
++	on core files.
++	(thread_db_load): Allow thread_db on core files.
++	(attach_thread): Don't check thread signals on core files, nor try
++	really attaching to the thread, nor enabling thread event event
++	reporting.
++	(thread_db_detach): Don't try disabing thread event reporting or
++	removing thread event breakpoints when debugging a core file.
++	(find_new_threads_callback): Don't try enabling thread event
++	reporting on core files.
++	(thread_db_find_new_threads_2): Don't look for a stopped lwp when
++	debugging a core file.
++	(thread_db_find_new_threads): Don't update thread
++	cores (processors) when debugging a core (dump).
++
++2010-08-18  Pedro Alves  <pedro at 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
+--- src/gdb/linux-thread-db.c	2010/07/31 15:34:41	1.76
++++ src/gdb/linux-thread-db.c	2010/08/18 12:25:49	1.77
+@@ -189,7 +189,11 @@
+   info = xcalloc (1, sizeof (*info));
+   info->pid = ptid_get_pid (inferior_ptid);
+   info->handle = handle;
+-  info->need_stale_parent_threads_check = 1;
++
++  /* The workaround works by reading from /proc/pid/status, so it is
++     disabled for core files.  */
++  if (target_has_execution)
++    info->need_stale_parent_threads_check = 1;
+ 
+   info->next = thread_db_list;
+   thread_db_list = info;
+@@ -737,7 +741,9 @@
+   if (thread_db_list->next == NULL)
+     push_target (&thread_db_ops);
+ 
+-  enable_thread_event_reporting ();
++  /* Enable event reporting, but not when debugging a core file.  */
++  if (target_has_execution)
++    enable_thread_event_reporting ();
+ 
+   /* There appears to be a bug in glibc-2.3.6: calls to td_thr_get_info fail
+      with TD_ERR for statically linked executables if td_thr_get_info is
+@@ -869,13 +875,13 @@
+   if (info != NULL)
+     return 1;
+ 
+-  /* Don't attempt to use thread_db on targets which can not run
+-     (executables not running yet, core files) for now.  */
+-  if (!target_has_execution)
++  /* Don't attempt to use thread_db on executables not running
++     yet.  */
++  if (!target_has_registers)
+     return 0;
+ 
+   /* Don't attempt to use thread_db for remote targets.  */
+-  if (!target_can_run (&current_target))
++  if (!(target_can_run (&current_target) || core_bfd))
+     return 0;
+ 
+   if (thread_db_load_search ())
+@@ -1030,13 +1036,15 @@
+ 	}
+     }
+ 
+-  check_thread_signals ();
++  if (target_has_execution)
++    check_thread_signals ();
+ 
+   if (ti_p->ti_state == TD_THR_UNKNOWN || ti_p->ti_state == TD_THR_ZOMBIE)
+     return 0;			/* A zombie thread -- do not attach.  */
+ 
+   /* Under GNU/Linux, we have to attach to each and every thread.  */
+-  if (tp == NULL
++  if (target_has_execution
++      && tp == NULL
+       && lin_lwp_attach_lwp (BUILD_LWP (ti_p->ti_lid, GET_PID (ptid))) < 0)
+     return 0;
+ 
+@@ -1061,11 +1069,16 @@
+ 
+   info = get_thread_db_info (GET_PID (ptid));
+ 
+-  /* Enable thread event reporting for this thread.  */
+-  err = info->td_thr_event_enable_p (th_p, 1);
+-  if (err != TD_OK)
+-    error (_("Cannot enable thread event reporting for %s: %s"),
+-	   target_pid_to_str (ptid), thread_db_err_str (err));
++  /* Enable thread event reporting for this thread, except when
++     debugging a core file.  */
++  if (target_has_execution)
++    {
++      err = info->td_thr_event_enable_p (th_p, 1);
++      if (err != TD_OK)
++	error (_("Cannot enable thread event reporting for %s: %s"),
++	       target_pid_to_str (ptid), thread_db_err_str (err));
++    }
++
+   return 1;
+ }
+ 
+@@ -1097,14 +1110,17 @@
+ 
+   if (info)
+     {
+-      disable_thread_event_reporting (info);
++      if (target_has_execution)
++	{
++	  disable_thread_event_reporting (info);
+ 
+-      /* Delete the old thread event breakpoints.  Note that unlike
+-	 when mourning, we can remove them here because there's still
+-	 a live inferior to poke at.  In any case, GDB will not try to
+-	 insert anything in the inferior when removing a
+-	 breakpoint.  */
+-      remove_thread_event_breakpoints ();
++	  /* Delete the old thread event breakpoints.  Note that
++	     unlike when mourning, we can remove them here because
++	     there's still a live inferior to poke at.  In any case,
++	     GDB will not try to insert anything in the inferior when
++	     removing a breakpoint.  */
++	  remove_thread_event_breakpoints ();
++	}
+ 
+       delete_thread_db_info (GET_PID (inferior_ptid));
+     }
+@@ -1317,7 +1333,7 @@
+   if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE)
+     return 0;			/* A zombie -- ignore.  */
+ 
+-  if (ti.ti_tid == 0)
++  if (ti.ti_tid == 0 && target_has_execution)
+     {
+       /* A thread ID of zero means that this is the main thread, but
+ 	 glibc has not yet initialized thread-local storage and the
+@@ -1417,19 +1433,23 @@
+ thread_db_find_new_threads_2 (ptid_t ptid, int until_no_new)
+ {
+   td_err_e err;
+-  struct lwp_info *lp;
+   struct thread_db_info *info;
+   int pid = ptid_get_pid (ptid);
+   int i, loop;
+ 
+-  /* In linux, we can only read memory through a stopped lwp.  */
+-  ALL_LWPS (lp, ptid)
+-    if (lp->stopped && ptid_get_pid (lp->ptid) == pid)
+-      break;
++  if (target_has_execution)
++    {
++      struct lwp_info *lp;
+ 
+-  if (!lp)
+-    /* There is no stopped thread.  Bail out.  */
+-    return;
++      /* In linux, we can only read memory through a stopped lwp.  */
++      ALL_LWPS (lp, ptid)
++	if (lp->stopped && ptid_get_pid (lp->ptid) == pid)
++	  break;
++
++      if (!lp)
++	/* There is no stopped thread.  Bail out.  */
++	return;
++    }
+ 
+   info = get_thread_db_info (GET_PID (ptid));
+ 
+@@ -1480,8 +1500,9 @@
+ 
+   thread_db_find_new_threads_1 (inferior_ptid);
+ 
+-  iterate_over_lwps (minus_one_ptid /* iterate over all */,
+-		     update_thread_core, NULL);
++  if (target_has_execution)
++    iterate_over_lwps (minus_one_ptid /* iterate over all */,
++		       update_thread_core, NULL);
+ }
+ 
+ static char *
diff --git a/gdb-core-threads-4of5.patch b/gdb-core-threads-4of5.patch
new file mode 100644
index 0000000..9e8edff
--- /dev/null
+++ b/gdb-core-threads-4of5.patch
@@ -0,0 +1,50 @@
+http://sourceware.org/ml/gdb-cvs/2010-08/msg00167.html
+
+### src/gdb/ChangeLog	2010/08/26 16:47:54	1.12117
+### src/gdb/ChangeLog	2010/08/26 19:47:22	1.12118
+## -1,3 +1,7 @@
++2010-08-26  Pedro Alves  <pedro at codesourcery.com>
++
++	* NEWS: Mention libthread_db debugging with core files.
++
+ 2010-08-26  Doug Evans  <dje at google.com>
+ 
+ 	* dwarf2read.c (dwarf2_build_include_psymtabs): Remove unnecessary
+Index: gdb-7.2/gdb/NEWS
+===================================================================
+--- gdb-7.2.orig/gdb/NEWS	2010-09-03 01:37:25.000000000 +0200
++++ gdb-7.2/gdb/NEWS	2011-01-30 19:32:06.000000000 +0100
+@@ -1,6 +1,33 @@
+ 		What has changed in GDB?
+ 	     (Organized release by release)
+ 
++*** Changes since GDB 7.2
++
++* GDB now supports thread debugging of core dumps on GNU/Linux.
++
++  GDB now activates thread debugging using the libthread_db library
++  when debugging GNU/Linux core dumps, similarly to when debugging
++  live processes.  As a result, when debugging a core dump file, GDB
++  is now able to display pthread_t ids of threads.  For example, "info
++  threads" shows the same output as when debugging the process when it
++  was live.  In earlier releases, you'd see something like this:
++
++  (gdb) info threads
++   * 1 LWP 6780  main () at main.c:10
++
++  While now you see this:
++
++  (gdb) info threads
++   * 1 Thread 0x7f0f5712a700 (LWP 6780)  main () at main.c:10
++
++  It is also now possible to inspect TLS variables when debugging core
++  dumps.
++
++  When debugging a core dump generated on a machine other than the one
++  used to run GDB, you may need to point GDB at the correct
++  libthread_db library with the "set libthread-db-search-path"
++  command.  See the user manual for more details on this command.
++
+ *** Changes in GDB 7.2
+ 
+ * Shared library support for remote targets by default
diff --git a/gdb-core-threads-5of5.patch b/gdb-core-threads-5of5.patch
new file mode 100644
index 0000000..abd182d
--- /dev/null
+++ b/gdb-core-threads-5of5.patch
@@ -0,0 +1,81 @@
+http://sourceware.org/ml/gdb-patches/2011-01/msg00566.html
+Subject: [patch] testcase: PR 8210 corefiles threads
+
+Hi,
+
+PR 8210 did not provide a new testcase, here it is.  I have limited the check
+only to *-*-linux* as other targets seem to identify the thread differently
+(untested outside of GNU/Linux).
+
+I will check it in after a while, it seems safe to me.
+
+Tested on x86_64-fedora14-linux-gnu.
+
+
+Thanks,
+Jan
+
+
+gdb/testsuite/
+2011-01-30  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	Test PR corefiles/8210.
+	* gdb.threads/gcore-thread.exp (pthread_self): New.
+	New variables main_self, thread1_self, thread2_self.
+	(main pthread_self found, thread1 pthread_self found)
+	(thread2 pthread_self found): New tests.
+
+--- ./gdb/testsuite/gdb.threads/gcore-thread.exp	2010-06-02 21:58:21.000000000 +0200
++++ ./gdb/testsuite/gdb.threads/gcore-thread.exp	2011-01-30 20:02:53.000000000 +0100
+@@ -53,6 +53,19 @@ set horiz "\[^\n\r\]*"
+ # regexp for newline
+ set nl "\[\r\n\]+"
+ 
++proc pthread_self {name} {
++    global gdb_prompt
++
++    set test "print pthread_t of $name"
++    gdb_test_multiple "p/x (*(pthread_t (*)(void)) pthread_self) ()" $test {
++	-re " = (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
++	    pass $test
++	    return $expect_out(1,string)
++	}
++    }
++    return ""
++}
++
+ set prev_timeout $timeout
+ set timeout 30
+ 
+@@ -82,15 +95,19 @@ gdb_test_multiple "info threads" "thread
+     }
+ }
+ 
++set main_self [pthread_self main]
++
+ # Make sure thread 1 is running
+ delete_breakpoints
+ gdb_breakpoint "thread1"
+ gdb_test "continue" "Continuing.*Breakpoint.* thread1 .*" "thread 1 is running"
++set thread1_self [pthread_self thread1]
+ 
+ # Make sure thread 2 is running
+ delete_breakpoints
+ gdb_breakpoint "thread2"
+ gdb_test "continue" "Continuing.*Breakpoint.* thread2 .*" "thread 2 is running"
++set thread2_self [pthread_self thread2]
+ 
+ set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test]
+ # Drop corefile
+@@ -159,4 +176,10 @@ gdb_test "info threads" ".* thread2 .*" 
+ gdb_test "info threads" ".*${nl}\\* ${horiz} thread2 .*" \
+ 	"thread2 is current thread in corefile"
+ 
++if [istarget "*-*-linux*"] then {
++    gdb_test "info threads" "Thread $main_self .*" "main pthread_self found"
++    gdb_test "info threads" "Thread $thread1_self .*" "thread1 pthread_self found"
++    gdb_test "info threads" "Thread $thread2_self .*" "thread2 pthread_self found"
++}
++
+ set timeout $prev_timeout
+
diff --git a/gdb.spec b/gdb.spec
index 90a0ef8..4b01651 100644
--- a/gdb.spec
+++ b/gdb.spec
@@ -27,7 +27,7 @@ Version: 7.2
 
 # The release always contains a leading reserved number, start it at 1.
 # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 38%{?_with_upstream:.upstream}%{dist}
+Release: 39%{?_with_upstream:.upstream}%{dist}
 
 License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and GFDL and BSD and Public Domain
 Group: Development/Debuggers
@@ -716,6 +716,13 @@ Patch553: gdb-gdbindex-v4-3of3.patch
 # [ifunc] Fix possible crash on deleting breakpoints (BZ 673483).
 Patch558: gdb-ifunc-unchain.patch
 
+# Display pthread_t for threads even from core files (PR 8210, BZ 673696).
+Patch559: gdb-core-threads-1of5.patch 
+Patch560: gdb-core-threads-2of5.patch
+Patch561: gdb-core-threads-3of5.patch
+Patch562: gdb-core-threads-4of5.patch
+Patch563: gdb-core-threads-5of5.patch
+
 BuildRequires: ncurses-devel%{?_isa} texinfo gettext flex bison expat-devel%{?_isa}
 Requires: readline%{?_isa}
 BuildRequires: readline-devel%{?_isa}
@@ -1020,6 +1027,11 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
 %patch552 -p1
 %patch553 -p1
 %patch558 -p1
+%patch559 -p1
+%patch560 -p1
+%patch561 -p1
+%patch562 -p1
+%patch563 -p1
 
 %patch390 -p1
 %patch393 -p1
@@ -1417,6 +1429,9 @@ fi
 %endif
 
 %changelog
+* Sun Jan 30 2011 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.2-39.fc14
+- Display pthread_t for threads even from core files (PR 8210, BZ 673696).
+
 * Fri Jan 28 2011 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.2-38.fc14
 - [ifunc] Fix possible crash on deleting breakpoints (BZ 673483).
 


More information about the scm-commits mailing list