From 5c49e68313213d9b37e06788eb8c99938d78a262 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Jul 08 2007 10:45:30 +0000 Subject: - Do not hang on exit of a thread group leader (BZ 247354). - New test for upstream fix of VDSO decoding while attaching to an i386 process. - Fixed BZ # 232014 -> 232015. --- diff --git a/gdb-6.3-attach-see-vdso-test.patch b/gdb-6.3-attach-see-vdso-test.patch new file mode 100644 index 0000000..58a15db --- /dev/null +++ b/gdb-6.3-attach-see-vdso-test.patch @@ -0,0 +1,110 @@ +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/attach-see-vdso.c 6 Jul 2007 14:14:44 -0000 +@@ -0,0 +1,25 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2007 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++ ++#include ++ ++int main () ++{ ++ pause (); ++ return 1; ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.base/attach-see-vdso.exp 6 Jul 2007 14:14:44 -0000 +@@ -0,0 +1,79 @@ ++# Copyright 2007 ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# This file was created by Jan Kratochvil . ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set prms_id 0 ++set bug_id 0 ++ ++# This test only works on Linux ++if { ![istarget "*-*-linux-gnu*"] } { ++ return 0 ++} ++ ++set testfile "attach-see-vdso" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}] ++ ++# The kernel VDSO is used for the syscalls returns only on i386 (not x86_64). ++# ++if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-m32}] != "" } { ++ gdb_suppress_entire_file "Testcase nonthraded compile failed, so all tests in this file will automatically fail." ++} ++ ++if [get_compiler_info ${binfile}] { ++ return -1 ++} ++ ++# Start the program running and then wait for a bit, to be sure ++# that it can be attached to. ++ ++set testpid [eval exec $binfile &] ++ ++# Avoid some race: ++sleep 2 ++ ++# Start with clean gdb ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++# Never call: gdb_load ${binfile} ++# as the former problem would not reproduce otherwise. ++ ++set test "attach" ++gdb_test_multiple "attach $testpid" "$test" { ++ -re "Attaching to process $testpid\r?\n.*$gdb_prompt $" { ++ pass "$test" ++ } ++} ++ ++gdb_test "bt" "#0 *0x\[0-9a-f\]* in \[^?\].*" "backtrace decodes VDSO" ++ ++# Exit and detach the process. ++ ++gdb_exit ++ ++# Make sure we don't leave a process around to confuse ++# the next test run (and prevent the compile by keeping ++# the text file busy), in case the "set should_exit" didn't ++# work. ++ ++remote_exec build "kill -9 ${testpid}" diff --git a/gdb-6.6-bz232014-gcore-ppc-on-ppc64.patch b/gdb-6.6-bz232014-gcore-ppc-on-ppc64.patch deleted file mode 100644 index 8664be3..0000000 --- a/gdb-6.6-bz232014-gcore-ppc-on-ppc64.patch +++ /dev/null @@ -1,201 +0,0 @@ -https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=232014 - - -Based on `gdb-6.5-gcore-i386-on-amd64.patch'. - - -diff -u -rup gdb-6.6-orig/gdb/Makefile.in gdb-6.6/gdb/Makefile.in ---- gdb-6.6-orig/gdb/Makefile.in 2007-03-12 17:59:56.000000000 -0400 -+++ gdb-6.6/gdb/Makefile.in 2007-04-23 13:05:05.000000000 -0400 -@@ -2481,7 +2481,7 @@ ppcbug-rom.o: ppcbug-rom.c $(defs_h) $(g - ppc-linux-nat.o: ppc-linux-nat.c $(defs_h) $(gdb_string_h) $(frame_h) \ - $(inferior_h) $(gdbcore_h) $(regcache_h) $(gdb_assert_h) \ - $(gdb_wait_h) $(gregset_h) $(ppc_tdep_h) $(target_h) \ -- $(linux_nat_h) -+ $(linux_nat_h) $(elf_bfd_h) $(gdb_procfs32_h) - ppc-linux-tdep.o: ppc-linux-tdep.c $(defs_h) $(frame_h) $(inferior_h) \ - $(symtab_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) $(symfile_h) \ - $(objfiles_h) $(regcache_h) $(value_h) $(osabi_h) $(regset_h) \ -diff -u -rup gdb-6.6-orig/gdb/gdb_procfs32.h gdb-6.6/gdb/gdb_procfs32.h ---- gdb-6.6-orig/gdb/gdb_procfs32.h 2007-03-12 17:59:55.000000000 -0400 -+++ gdb-6.6/gdb/gdb_procfs32.h 2007-04-23 13:07:03.000000000 -0400 -@@ -23,6 +23,8 @@ - #ifndef _SYS_PROCFS32_H - #define _SYS_PROCFS32_H 1 - -+#if defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) -+ - /* This is somewhat modelled after the file of the same name on SVR4 - systems. It provides a definition of the core file format for ELF - used on Linux. It doesn't have anything to do with the /proc file -@@ -49,17 +51,27 @@ typedef unsigned int elf_greg32_t; - user_regs_struct' directly in the typedef, but tradition says that - the register set is an array, which does have some peculiar - semantics, so leave it that way. */ -+#if defined(__x86_64__) - #define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t)) -+#elif defined(__ppc64__) || defined(__powerpc64__) -+#define ELF_NGREG32 48 -+#else -+#error "Unsupported platform" -+#endif - typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32]; - - /* Register set for the floating-point registers. */ --typedef struct user_fpregs32_struct elf_fpregset32_t; -- - /* Register set for the extended floating-point registers. Includes - the Pentium III SSE registers in addition to the classic - floating-point stuff. */ -+#if defined(__x86_64__) -+typedef struct user_fpregs32_struct elf_fpregset32_t; - typedef struct user_fpxregs32_struct elf_fpxregset32_t; -- -+#elif defined(__ppc64__) || defined(__powerpc64__) -+typedef elf_fpregset_t elf_fpregset32_t; -+#else -+#error "Unsupported platform" -+#endif - - /* Definitions to generate Intel SVR4-like core files. These mostly - have the same names as the SVR4 types with "elf_" tacked on the -@@ -100,8 +112,15 @@ - char pr_zomb; /* Zombie. */ - char pr_nice; /* Nice val. */ - unsigned int pr_flag; /* Flags. */ -+#if defined(__x86_64__) - unsigned short int pr_uid; - unsigned short int pr_gid; -+#elif defined(__ppc64__) || defined(__powerpc64__) -+ unsigned int pr_uid; -+ unsigned int pr_gid; -+#else -+#error "Unsupported platform" -+#endif - int pr_pid, pr_ppid, pr_pgrp, pr_sid; - /* Lots missing */ - char pr_fname[16]; /* Filename of executable. */ -@@ -123,6 +135,8 @@ typedef struct elf_prpsinfo32 prpsinfo32 - - __END_DECLS - -+#endif /* defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) */ -+ - #endif /* _SYS_PROCFS32_H */ - - #endif /* HAVE_SYS_PROCFS32_H */ -diff -u -rup gdb-6.6-orig/gdb/gdb_user32.h gdb-6.6/gdb/gdb_user32.h ---- gdb-6.6-orig/gdb/gdb_user32.h 2007-03-12 17:59:55.000000000 -0400 -+++ gdb-6.6/gdb/gdb_user32.h 2007-04-23 13:05:05.000000000 -0400 -@@ -32,6 +32,8 @@ typedef unsigned int gdb_uint32_t; - #ifndef _SYS_USER32_H - #define _SYS_USER32_H 1 - -+#ifdef __x86_64__ -+ - /* These are the 32-bit x86 structures. */ - - struct user_fpregs32_struct -@@ -103,6 +105,8 @@ struct user32 - int u_debugreg [8]; - }; - -+#endif /* __x86_64__ */ -+ - #endif /* _SYS_USER32_H */ - - #endif /* HAVE_SYS_USER32_H */ -diff -u -rup gdb-6.6-orig/gdb/ppc-linux-nat.c gdb-6.6/gdb/ppc-linux-nat.c ---- gdb-6.6-orig/gdb/ppc-linux-nat.c 2006-05-05 16:45:03.000000000 -0400 -+++ gdb-6.6/gdb/ppc-linux-nat.c 2007-04-23 13:16:09.000000000 -0400 -@@ -29,6 +29,8 @@ - #include "gdb_assert.h" - #include "target.h" - #include "linux-nat.h" -+#include "bfd/elf-bfd.h" -+#include "gdb_procfs32.h" - - #include - #include -@@ -1002,6 +1004,68 @@ fill_fpregset (gdb_fpregset_t *fpregsetp - } - } - -+#if defined(__ppc64__) || defined(__powerpc64__) -+ -+/* This functions make ELF32 32-bit elfcore note sections -+ on ppc64 environment. */ -+ -+static char * -+ppc_linux_elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz, -+ const char *fname, const char *psargs) -+{ -+ if (gdbarch_ptr_bit(current_gdbarch) == 32) -+ { -+ int note_type; -+ char *note_name = "CORE"; -+ struct elf_prpsinfo32 data; -+ note_type = NT_PRPSINFO; -+ -+ memset (&data, 0, sizeof (data)); -+ strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); -+ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); -+ return elfcore_write_note (abfd, buf, bufsiz, -+ note_name, note_type, &data, sizeof (data)); -+ } -+ else -+ return elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs); -+} -+ -+static void -+ppc_linux_set_registers (const gdb_byte *gregs, gdb_byte *buf) -+{ -+ int i; -+ const int elf_ngreg = 48; -+ -+ /* Copy the ppc registers in the ppc64 layout into ppc layout. */ -+ for (i = 0; i < elf_ngreg; i++) -+ memcpy (buf + 4 * i, gregs + 8 * i + 4, 4); -+ /* CR and XER are an exception as they are shifted left there, -+ see fill_gregset(). */ -+ memcpy (buf + 4 * PT_CCR, gregs + 8 * PT_CCR + 0, 4); -+ memcpy (buf + 4 * PT_XER, gregs + 8 * PT_XER + 0, 4); -+} -+ -+static char * -+ppc_linux_elfcore_write_prstatus (bfd *abfd, char *buf, int *bufsiz, -+ long pid, int cursig, const void *gregs) -+{ -+ if (gdbarch_ptr_bit(current_gdbarch) == 32) -+ { -+ char *note_name = "CORE"; -+ struct elf_prstatus32 prstat; -+ memset (&prstat, 0, sizeof (prstat)); -+ prstat.pr_pid = pid; -+ prstat.pr_cursig = cursig; -+ ppc_linux_set_registers (gregs, (gdb_byte *) &prstat.pr_reg); -+ return elfcore_write_note (abfd, buf, bufsiz, note_name, -+ NT_PRSTATUS, &prstat, sizeof (prstat)); -+ } -+ else -+ return elfcore_write_prstatus (abfd, buf, bufsiz, pid, cursig, gregs); -+} -+ -+#endif /* defined(__ppc64__) || defined(__powerpc64__) */ -+ - void _initialize_ppc_linux_nat (void); - - void -@@ -1024,6 +1084,12 @@ _initialize_ppc_linux_nat (void) - t->to_stopped_by_watchpoint = ppc_linux_stopped_by_watchpoint; - t->to_stopped_data_address = ppc_linux_stopped_data_address; - -+#if defined(__ppc64__) || defined(__powerpc64__) -+ /* This functions make elfcore note sections. */ -+ linux_elfcore_write_prpsinfo = ppc_linux_elfcore_write_prpsinfo; -+ linux_elfcore_write_prstatus = ppc_linux_elfcore_write_prstatus; -+#endif /* defined(__ppc64__) || defined(__powerpc64__) */ -+ - /* Register the target. */ - linux_nat_add_target (t); - } diff --git a/gdb-6.6-bz232015-gcore-ppc-on-ppc64.patch b/gdb-6.6-bz232015-gcore-ppc-on-ppc64.patch new file mode 100644 index 0000000..8664be3 --- /dev/null +++ b/gdb-6.6-bz232015-gcore-ppc-on-ppc64.patch @@ -0,0 +1,201 @@ +https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=232014 + + +Based on `gdb-6.5-gcore-i386-on-amd64.patch'. + + +diff -u -rup gdb-6.6-orig/gdb/Makefile.in gdb-6.6/gdb/Makefile.in +--- gdb-6.6-orig/gdb/Makefile.in 2007-03-12 17:59:56.000000000 -0400 ++++ gdb-6.6/gdb/Makefile.in 2007-04-23 13:05:05.000000000 -0400 +@@ -2481,7 +2481,7 @@ ppcbug-rom.o: ppcbug-rom.c $(defs_h) $(g + ppc-linux-nat.o: ppc-linux-nat.c $(defs_h) $(gdb_string_h) $(frame_h) \ + $(inferior_h) $(gdbcore_h) $(regcache_h) $(gdb_assert_h) \ + $(gdb_wait_h) $(gregset_h) $(ppc_tdep_h) $(target_h) \ +- $(linux_nat_h) ++ $(linux_nat_h) $(elf_bfd_h) $(gdb_procfs32_h) + ppc-linux-tdep.o: ppc-linux-tdep.c $(defs_h) $(frame_h) $(inferior_h) \ + $(symtab_h) $(target_h) $(gdbcore_h) $(gdbcmd_h) $(symfile_h) \ + $(objfiles_h) $(regcache_h) $(value_h) $(osabi_h) $(regset_h) \ +diff -u -rup gdb-6.6-orig/gdb/gdb_procfs32.h gdb-6.6/gdb/gdb_procfs32.h +--- gdb-6.6-orig/gdb/gdb_procfs32.h 2007-03-12 17:59:55.000000000 -0400 ++++ gdb-6.6/gdb/gdb_procfs32.h 2007-04-23 13:07:03.000000000 -0400 +@@ -23,6 +23,8 @@ + #ifndef _SYS_PROCFS32_H + #define _SYS_PROCFS32_H 1 + ++#if defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) ++ + /* This is somewhat modelled after the file of the same name on SVR4 + systems. It provides a definition of the core file format for ELF + used on Linux. It doesn't have anything to do with the /proc file +@@ -49,17 +51,27 @@ typedef unsigned int elf_greg32_t; + user_regs_struct' directly in the typedef, but tradition says that + the register set is an array, which does have some peculiar + semantics, so leave it that way. */ ++#if defined(__x86_64__) + #define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t)) ++#elif defined(__ppc64__) || defined(__powerpc64__) ++#define ELF_NGREG32 48 ++#else ++#error "Unsupported platform" ++#endif + typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32]; + + /* Register set for the floating-point registers. */ +-typedef struct user_fpregs32_struct elf_fpregset32_t; +- + /* Register set for the extended floating-point registers. Includes + the Pentium III SSE registers in addition to the classic + floating-point stuff. */ ++#if defined(__x86_64__) ++typedef struct user_fpregs32_struct elf_fpregset32_t; + typedef struct user_fpxregs32_struct elf_fpxregset32_t; +- ++#elif defined(__ppc64__) || defined(__powerpc64__) ++typedef elf_fpregset_t elf_fpregset32_t; ++#else ++#error "Unsupported platform" ++#endif + + /* Definitions to generate Intel SVR4-like core files. These mostly + have the same names as the SVR4 types with "elf_" tacked on the +@@ -100,8 +112,15 @@ + char pr_zomb; /* Zombie. */ + char pr_nice; /* Nice val. */ + unsigned int pr_flag; /* Flags. */ ++#if defined(__x86_64__) + unsigned short int pr_uid; + unsigned short int pr_gid; ++#elif defined(__ppc64__) || defined(__powerpc64__) ++ unsigned int pr_uid; ++ unsigned int pr_gid; ++#else ++#error "Unsupported platform" ++#endif + int pr_pid, pr_ppid, pr_pgrp, pr_sid; + /* Lots missing */ + char pr_fname[16]; /* Filename of executable. */ +@@ -123,6 +135,8 @@ typedef struct elf_prpsinfo32 prpsinfo32 + + __END_DECLS + ++#endif /* defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) */ ++ + #endif /* _SYS_PROCFS32_H */ + + #endif /* HAVE_SYS_PROCFS32_H */ +diff -u -rup gdb-6.6-orig/gdb/gdb_user32.h gdb-6.6/gdb/gdb_user32.h +--- gdb-6.6-orig/gdb/gdb_user32.h 2007-03-12 17:59:55.000000000 -0400 ++++ gdb-6.6/gdb/gdb_user32.h 2007-04-23 13:05:05.000000000 -0400 +@@ -32,6 +32,8 @@ typedef unsigned int gdb_uint32_t; + #ifndef _SYS_USER32_H + #define _SYS_USER32_H 1 + ++#ifdef __x86_64__ ++ + /* These are the 32-bit x86 structures. */ + + struct user_fpregs32_struct +@@ -103,6 +105,8 @@ struct user32 + int u_debugreg [8]; + }; + ++#endif /* __x86_64__ */ ++ + #endif /* _SYS_USER32_H */ + + #endif /* HAVE_SYS_USER32_H */ +diff -u -rup gdb-6.6-orig/gdb/ppc-linux-nat.c gdb-6.6/gdb/ppc-linux-nat.c +--- gdb-6.6-orig/gdb/ppc-linux-nat.c 2006-05-05 16:45:03.000000000 -0400 ++++ gdb-6.6/gdb/ppc-linux-nat.c 2007-04-23 13:16:09.000000000 -0400 +@@ -29,6 +29,8 @@ + #include "gdb_assert.h" + #include "target.h" + #include "linux-nat.h" ++#include "bfd/elf-bfd.h" ++#include "gdb_procfs32.h" + + #include + #include +@@ -1002,6 +1004,68 @@ fill_fpregset (gdb_fpregset_t *fpregsetp + } + } + ++#if defined(__ppc64__) || defined(__powerpc64__) ++ ++/* This functions make ELF32 32-bit elfcore note sections ++ on ppc64 environment. */ ++ ++static char * ++ppc_linux_elfcore_write_prpsinfo (bfd *abfd, char *buf, int *bufsiz, ++ const char *fname, const char *psargs) ++{ ++ if (gdbarch_ptr_bit(current_gdbarch) == 32) ++ { ++ int note_type; ++ char *note_name = "CORE"; ++ struct elf_prpsinfo32 data; ++ note_type = NT_PRPSINFO; ++ ++ memset (&data, 0, sizeof (data)); ++ strncpy (data.pr_fname, fname, sizeof (data.pr_fname)); ++ strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs)); ++ return elfcore_write_note (abfd, buf, bufsiz, ++ note_name, note_type, &data, sizeof (data)); ++ } ++ else ++ return elfcore_write_prpsinfo (abfd, buf, bufsiz, fname, psargs); ++} ++ ++static void ++ppc_linux_set_registers (const gdb_byte *gregs, gdb_byte *buf) ++{ ++ int i; ++ const int elf_ngreg = 48; ++ ++ /* Copy the ppc registers in the ppc64 layout into ppc layout. */ ++ for (i = 0; i < elf_ngreg; i++) ++ memcpy (buf + 4 * i, gregs + 8 * i + 4, 4); ++ /* CR and XER are an exception as they are shifted left there, ++ see fill_gregset(). */ ++ memcpy (buf + 4 * PT_CCR, gregs + 8 * PT_CCR + 0, 4); ++ memcpy (buf + 4 * PT_XER, gregs + 8 * PT_XER + 0, 4); ++} ++ ++static char * ++ppc_linux_elfcore_write_prstatus (bfd *abfd, char *buf, int *bufsiz, ++ long pid, int cursig, const void *gregs) ++{ ++ if (gdbarch_ptr_bit(current_gdbarch) == 32) ++ { ++ char *note_name = "CORE"; ++ struct elf_prstatus32 prstat; ++ memset (&prstat, 0, sizeof (prstat)); ++ prstat.pr_pid = pid; ++ prstat.pr_cursig = cursig; ++ ppc_linux_set_registers (gregs, (gdb_byte *) &prstat.pr_reg); ++ return elfcore_write_note (abfd, buf, bufsiz, note_name, ++ NT_PRSTATUS, &prstat, sizeof (prstat)); ++ } ++ else ++ return elfcore_write_prstatus (abfd, buf, bufsiz, pid, cursig, gregs); ++} ++ ++#endif /* defined(__ppc64__) || defined(__powerpc64__) */ ++ + void _initialize_ppc_linux_nat (void); + + void +@@ -1024,6 +1084,12 @@ _initialize_ppc_linux_nat (void) + t->to_stopped_by_watchpoint = ppc_linux_stopped_by_watchpoint; + t->to_stopped_data_address = ppc_linux_stopped_data_address; + ++#if defined(__ppc64__) || defined(__powerpc64__) ++ /* This functions make elfcore note sections. */ ++ linux_elfcore_write_prpsinfo = ppc_linux_elfcore_write_prpsinfo; ++ linux_elfcore_write_prstatus = ppc_linux_elfcore_write_prstatus; ++#endif /* defined(__ppc64__) || defined(__powerpc64__) */ ++ + /* Register the target. */ + linux_nat_add_target (t); + } diff --git a/gdb-6.6-bz247354-leader-exit-fix.patch b/gdb-6.6-bz247354-leader-exit-fix.patch new file mode 100644 index 0000000..6cb383f --- /dev/null +++ b/gdb-6.6-bz247354-leader-exit-fix.patch @@ -0,0 +1,140 @@ +2007-07-08 Jan Kratochvil + + * linux-nat.c (linux_lwp_is_zombie): New function. + (wait_lwp): Fix lockup on exit of the thread group leader. + (linux_xfer_partial): Renamed to ... + (linux_xfer_partial_lwp): ... here. + (linux_xfer_partial): New function wrapping LINUX_XFER_PARTIAL_LWP. + +--- ./gdb/linux-nat.c 3 Jul 2007 17:01:55 -0000 1.65 ++++ ./gdb/linux-nat.c 7 Jul 2007 15:21:57 -0000 +@@ -1343,6 +1343,31 @@ linux_handle_extended_wait (struct lwp_i + _("unknown ptrace event %d"), event); + } + ++static int ++linux_lwp_is_zombie (long lwp) ++{ ++ char buffer[MAXPATHLEN]; ++ FILE *procfile; ++ int retval = 0; ++ ++ sprintf (buffer, "/proc/%ld/status", lwp); ++ procfile = fopen (buffer, "r"); ++ if (procfile == NULL) ++ { ++ warning (_("unable to open /proc file '%s'"), buffer); ++ return 0; ++ } ++ while (fgets (buffer, sizeof (buffer), procfile) != NULL) ++ if (strcmp (buffer, "State:\tZ (zombie)\n") == 0) ++ { ++ retval = 1; ++ break; ++ } ++ fclose (procfile); ++ ++ return retval; ++} ++ + /* Wait for LP to stop. Returns the wait status, or 0 if the LWP has + exited. */ + +@@ -1350,16 +1375,31 @@ static int + wait_lwp (struct lwp_info *lp) + { + pid_t pid; +- int status; ++ int status = 0; + int thread_dead = 0; + + gdb_assert (!lp->stopped); + gdb_assert (lp->status == 0); + +- pid = my_waitpid (GET_LWP (lp->ptid), &status, 0); +- if (pid == -1 && errno == ECHILD) ++ /* Thread group leader may have exited but we would lock up by WAITPID as it ++ waits on all its threads; __WCLONE is not applicable for the leader. ++ The thread leader restrictions is only a performance optimization here. ++ LINUX_NAT_THREAD_ALIVE cannot be used here as it requires a STOPPED ++ process; it gets ESRCH both for the zombie and for running processes. */ ++ if (is_lwp (lp->ptid) && GET_PID (lp->ptid) == GET_LWP (lp->ptid) ++ && linux_lwp_is_zombie (GET_LWP (lp->ptid))) ++ { ++ thread_dead = 1; ++ if (debug_linux_nat) ++ fprintf_unfiltered (gdb_stdlog, "WL: Threads leader %s vanished.\n", ++ target_pid_to_str (lp->ptid)); ++ } ++ ++ if (!thread_dead) + { +- pid = my_waitpid (GET_LWP (lp->ptid), &status, __WCLONE); ++ pid = my_waitpid (GET_LWP (lp->ptid), &status, 0); ++ if (pid == -1 && errno == ECHILD) ++ pid = my_waitpid (GET_LWP (lp->ptid), &status, __WCLONE); + if (pid == -1 && errno == ECHILD) + { + /* The thread has previously exited. We need to delete it +@@ -3144,10 +3159,12 @@ linux_proc_pending_signals (int pid, sig + fclose (procfile); + } + ++/* Transfer from the specific LWP currently set by PID of INFERIOR_PTID. */ ++ + static LONGEST +-linux_xfer_partial (struct target_ops *ops, enum target_object object, +- const char *annex, gdb_byte *readbuf, +- const gdb_byte *writebuf, ULONGEST offset, LONGEST len) ++linux_xfer_partial_lwp (struct target_ops *ops, enum target_object object, ++ const char *annex, gdb_byte *readbuf, ++ const gdb_byte *writebuf, ULONGEST offset, LONGEST len) + { + LONGEST xfer; + +@@ -3164,6 +3181,45 @@ linux_xfer_partial (struct target_ops *o + offset, len); + } + ++/* nptl_db expects being able to transfer memory just by specifying PID. ++ After the thread group leader exists the Linux kernel turns the task ++ into zombie no longer permitting accesses to its memory. ++ Transfer the memory from an arbitrary LWP_LIST entry in such case. */ ++ ++static LONGEST ++linux_xfer_partial (struct target_ops *ops, enum target_object object, ++ const char *annex, gdb_byte *readbuf, ++ const gdb_byte *writebuf, ULONGEST offset, LONGEST len) ++{ ++ LONGEST xfer; ++ struct lwp_info *lp; ++ /* Not using SAVE_INFERIOR_PTID already here for better performance. */ ++ struct cleanup *old_chain = NULL; ++ ptid_t inferior_ptid_orig = inferior_ptid; ++ ++ errno = 0; ++ xfer = linux_xfer_partial_lwp (ops, object, annex, readbuf, writebuf, ++ offset, len); ++ ++ for (lp = lwp_list; xfer == 0 && (errno == EACCES || errno == ESRCH) ++ && lp != NULL; lp = lp->next) ++ { ++ if (!is_lwp (lp->ptid) || ptid_equal (lp->ptid, inferior_ptid_orig)) ++ continue; ++ ++ if (old_chain == NULL) ++ old_chain = save_inferior_ptid (); ++ inferior_ptid = BUILD_LWP (GET_LWP (lp->ptid), GET_LWP (lp->ptid)); ++ errno = 0; ++ xfer = linux_xfer_partial_lwp (ops, object, annex, readbuf, writebuf, ++ offset, len); ++ } ++ ++ if (old_chain != NULL) ++ do_cleanups (old_chain); ++ return xfer; ++} ++ + /* Create a prototype generic Linux target. The client can override + it with local methods. */ + diff --git a/gdb-6.6-bz247354-leader-exit-test.patch b/gdb-6.6-bz247354-leader-exit-test.patch new file mode 100644 index 0000000..9fff104 --- /dev/null +++ b/gdb-6.6-bz247354-leader-exit-test.patch @@ -0,0 +1,121 @@ +2007-07-07 Jan Kratochvil + + * gdb.threads/leader-exit.c, gdb.threads/leader-exit.exp: New files. + +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.threads/leader-exit.c 7 Jul 2007 15:21:57 -0000 +@@ -0,0 +1,47 @@ ++/* Clean exit of the thread group leader should not break GDB. ++ ++ Copyright 2007 Free Software Foundation, Inc. ++ ++ This file is part of GDB. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program; if not, write to the Free Software ++ Foundation, Inc., 59 Temple Place - Suite 330, ++ Boston, MA 02111-1307, USA. */ ++ ++#include ++#include ++#include ++ ++static void *start (void *arg) ++{ ++ for (;;) ++ pause (); ++ /* NOTREACHED */ ++ assert (0); ++ return arg; ++} ++ ++int main (void) ++{ ++ pthread_t thread; ++ int i; ++ ++ i = pthread_create (&thread, NULL, start, NULL); /* create1 */ ++ assert (i == 0); ++ ++ pthread_exit (NULL); ++ /* NOTREACHED */ ++ assert (0); ++ return 0; ++} +--- /dev/null 1 Jan 1970 00:00:00 -0000 ++++ ./gdb/testsuite/gdb.threads/leader-exit.exp 7 Jul 2007 15:21:57 -0000 +@@ -0,0 +1,64 @@ ++# Copyright (C) 2007 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 2 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program; if not, write to the Free Software ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# Exit of the thread group leader should not break GDB. ++ ++# This file was written by Jan Kratochvil . ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++set testfile "leader-exit" ++set srcfile ${testfile}.c ++set binfile ${objdir}/${subdir}/${testfile} ++ ++if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { ++ return -1 ++} ++ ++gdb_exit ++gdb_start ++gdb_reinitialize_dir $srcdir/$subdir ++gdb_load ${binfile} ++gdb_run_cmd ++ ++proc stop_process { description } { ++ global gdb_prompt ++ ++ # For this to work we must be sure to consume the "Continuing." ++ # message first, or GDB's signal handler may not be in place. ++ after 1000 {send_gdb "\003"} ++ gdb_expect { ++ -re "Program received signal SIGINT.*$gdb_prompt $" ++ { ++ pass $description ++ } ++ timeout ++ { ++ fail "$description (timeout)" ++ } ++ } ++} ++ ++# Prevent races. ++sleep 2 ++ ++stop_process "Threads could be stopped" ++ ++gdb_test "info threads" \ ++ "\\* 2 Thread \[^\r\n\]* in \[^\r\n\]*pause \\(\\) from \[^\r\n\]*" \ ++ "Single thread has been left" diff --git a/gdb.spec b/gdb.spec index f6f3250..85edda1 100644 --- a/gdb.spec +++ b/gdb.spec @@ -11,7 +11,7 @@ Name: gdb Version: 6.6 # The release always contains a leading reserved number, start it at 1. -Release: 19%{?dist} +Release: 20%{?dist} License: GPL Group: Development/Debuggers @@ -337,8 +337,8 @@ Patch246: gdb-6.6-bz237096-watchthreads-testcasefix.patch # Notify user of a child forked process being detached (BZ 235197). Patch247: gdb-6.6-bz234468-fork-detach-info.patch -# Fix `gcore' command for 32bit PPC inferiors on 64bit PPC hosts (BZ 232014). -Patch248: gdb-6.6-bz232014-gcore-ppc-on-ppc64.patch +# Fix `gcore' command for 32bit PPC inferiors on 64bit PPC hosts (BZ 232015). +Patch248: gdb-6.6-bz232015-gcore-ppc-on-ppc64.patch # New testcase for gcore of 32bit inferiors on 64bit hosts. Patch249: gdb-6.6-gcore32-test.patch @@ -360,6 +360,13 @@ Patch258: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch # Link with libreadline provided by the operating system. Patch261: gdb-6.6-readline-system.patch +# Test kernel VDSO decoding while attaching to an i386 process. +Patch263: gdb-6.3-attach-see-vdso-test.patch + +# Do not hang on exit of a thread group leader (BZ 247354). +Patch265: gdb-6.6-bz247354-leader-exit-fix.patch +Patch266: gdb-6.6-bz247354-leader-exit-test.patch + BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext BuildRequires: flex bison sharutils expat-devel Requires: readline @@ -511,6 +518,9 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c %patch258 -p1 %patch260 -p1 %patch261 -p1 +%patch263 -p1 +%patch265 -p1 +%patch266 -p1 # Change the version that gets printed at GDB startup, so it is RedHat # specific. @@ -663,6 +673,11 @@ fi # don't include the files in include, they are part of binutils %changelog +* Sun Jul 8 2007 Jan Kratochvil - 6.6-20 +- Do not hang on exit of a thread group leader (BZ 247354). +- New test for upstream fix of VDSO decoding while attaching to an i386 process. +- Fixed BZ # 232014 -> 232015. + * Thu Jul 5 2007 Jan Kratochvil - 6.6-19 - Link with libreadline provided by the operating system.