From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1224 invoked by alias); 26 Dec 2011 19:28:52 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 1183 invoked by uid 9674); 26 Dec 2011 19:28:50 -0000 Date: Mon, 26 Dec 2011 19:28:00 -0000 Message-ID: <20111226192850.1168.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-jankratochvil-watchpoint3: Merge branch 'f-cleanup-fork-multifix' into archer-jankratochvil-watchpoint3 X-Git-Refname: refs/heads/archer-jankratochvil-watchpoint3 X-Git-Reftype: branch X-Git-Oldrev: 9797f0a8b0277c263ca7f2f39e22dcba46e0c38b X-Git-Newrev: fe68a8c899120cb2b1c03ebc426ee64d2c94eec3 X-SW-Source: 2011-q4/txt/msg00075.txt.bz2 List-Id: The branch, archer-jankratochvil-watchpoint3 has been updated via fe68a8c899120cb2b1c03ebc426ee64d2c94eec3 (commit) via c0045e75f7b11d73af89bbd17fdc926a5549e8c4 (commit) via 19ee362ff39645cf020c3f401d5f18adab29ed43 (commit) via 3850649d1eded9498bdfe5345ca7a0efd53766fe (commit) via 770ffc951319983f7a6209b767b7a16df9789a8e (commit) via 8b9e030e645a139328499626a1f8ae7cf8696b11 (commit) via f39bc634a93573f10922b2528895b92c4585ed9f (commit) via 64f5007ad54565b6da311c7e019ee841ddafdfd8 (commit) via bc2b708de65d37d9e5e5ec00e1ea7ac6814366c5 (commit) via 97f4cb7763bd9b539c45f00f7e089e011185d7e7 (commit) via 38f21f4621042ab7221463b00a27af1f85e1353e (commit) via 737b61a743077993bb50fa22630b612e29921e99 (commit) from 9797f0a8b0277c263ca7f2f39e22dcba46e0c38b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit fe68a8c899120cb2b1c03ebc426ee64d2c94eec3 Merge: 9797f0a c0045e7 Author: Jan Kratochvil Date: Mon Dec 26 20:28:27 2011 +0100 Merge branch 'f-cleanup-fork-multifix' into archer-jankratochvil-watchpoint3 commit c0045e75f7b11d73af89bbd17fdc926a5549e8c4 Merge: 3850649 19ee362 Author: Jan Kratochvil Date: Mon Dec 26 20:22:50 2011 +0100 Merge branch 'f-cleanup-fork' into f-cleanup-fork-multifix commit 19ee362ff39645cf020c3f401d5f18adab29ed43 Author: Jan Kratochvil Date: Mon Dec 26 20:22:44 2011 +0100 . commit 3850649d1eded9498bdfe5345ca7a0efd53766fe Merge: bc2b708 770ffc9 Author: Jan Kratochvil Date: Mon Dec 26 17:41:06 2011 +0100 Merge branch 'e-cleanup-fork' into e-cleanup-fork-multifix commit 770ffc951319983f7a6209b767b7a16df9789a8e Merge: 97f4cb7 8b9e030 Author: Jan Kratochvil Date: Mon Dec 26 17:41:05 2011 +0100 Merge branch 'e-cleanup' into e-cleanup-fork commit 8b9e030e645a139328499626a1f8ae7cf8696b11 Merge: c243480 f39bc63 Author: Jan Kratochvil Date: Mon Dec 26 17:41:05 2011 +0100 Merge branch 'e' into e-cleanup commit f39bc634a93573f10922b2528895b92c4585ed9f Author: Jan Kratochvil Date: Mon Dec 26 11:24:55 2011 +0000 gdb/testsuite/ Fix double send_gdb leading to racy FAILs. * gdb.base/break.exp (set silent break bp_location1): Replace 3x send_gdb and gdb_expect by gdb_test. * gdb.base/fileio.exp: Replace 2x send_gdb by gdb_exit and sleep. * gdb.base/foll-vfork.exp (vfork_and_exec_child_follow_to_main_bp) (vfork_and_exec_child_follow_through_step): Use gdb_test_no_output instead of send_gdb. Twice. * gdb.base/sepdebug.exp (set silent break bp_location1): Replace 3x send_gdb and gdb_expect by gdb_test. * gdb.mi/mi-nsmoribund.exp: Replace 3x send_gdb by mi_gdb_test. commit 64f5007ad54565b6da311c7e019ee841ddafdfd8 Author: gdbadmin Date: Mon Dec 26 00:00:03 2011 +0000 *** empty log message *** commit bc2b708de65d37d9e5e5ec00e1ea7ac6814366c5 Merge: 38f21f4 97f4cb7 Author: Jan Kratochvil Date: Mon Dec 26 00:50:49 2011 +0100 Merge branch 'e-cleanup-fork' into e-cleanup-fork-multifix commit 97f4cb7763bd9b539c45f00f7e089e011185d7e7 Author: Jan Kratochvil Date: Mon Dec 26 00:50:47 2011 +0100 . commit 38f21f4621042ab7221463b00a27af1f85e1353e Merge: d948033 737b61a Author: Jan Kratochvil Date: Mon Dec 26 00:41:34 2011 +0100 Merge branch 'e-cleanup-fork' into e-cleanup-fork-multifix commit 737b61a743077993bb50fa22630b612e29921e99 Author: Jan Kratochvil Date: Mon Dec 26 00:41:30 2011 +0100 . ----------------------------------------------------------------------- Summary of changes: gdb/amd64-linux-nat.c | 7 -- gdb/i386-linux-nat.c | 7 -- gdb/i386-nat.c | 2 +- gdb/linux-nat.c | 175 ++++++++++++++++++++++---------- gdb/testsuite/ChangeLog | 13 +++ gdb/testsuite/gdb.base/break.exp | 9 +-- gdb/testsuite/gdb.base/fileio.exp | 5 +- gdb/testsuite/gdb.base/foll-vfork.exp | 4 +- gdb/testsuite/gdb.base/sepdebug.exp | 9 +-- gdb/testsuite/gdb.mi/mi-nsmoribund.exp | 6 +- gdb/version.in | 2 +- 11 files changed, 147 insertions(+), 92 deletions(-) First 500 lines of diff: diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index ec6480c..4396870 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -343,13 +343,6 @@ amd64_linux_dr_get_status (void) static int update_debug_registers_callback (struct lwp_info *lwp, void *arg) { - if (lwp == NULL) - { - /* A forked-off process. 0 means continue the traversal but there won't - be any other LWP. */ - return 0; - } - if (lwp->arch_private == NULL) lwp->arch_private = XCNEW (struct arch_lwp_info); diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index 5c20c8b..32be177 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -715,13 +715,6 @@ i386_linux_dr_get_status (void) static int update_debug_registers_callback (struct lwp_info *lwp, void *arg) { - if (lwp == NULL) - { - /* A forked-off process. 0 means continue the traversal but there won't - be any other LWP. */ - return 0; - } - if (lwp->arch_private == NULL) lwp->arch_private = XCNEW (struct arch_lwp_info); diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c index b11a693..a485851 100644 --- a/gdb/i386-nat.c +++ b/gdb/i386-nat.c @@ -209,7 +209,7 @@ i386_inferior_data_get (void) if (detached_inf_pid != ptid_get_pid (inferior_ptid)) { detached_inf_pid = ptid_get_pid (inferior_ptid); - + /* Forked processes get a copy of the debug registers. */ memcpy (&detached_inf_data_local, inf_data, sizeof (detached_inf_data_local)); diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index d0320e7..fa52ec2 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -289,6 +289,7 @@ static void restore_child_signals_mask (sigset_t *prev_mask); struct lwp_info; static struct lwp_info *add_lwp (ptid_t ptid); static void purge_lwp_list (int pid); +static void delete_lwp (ptid_t ptid); static struct lwp_info *find_lwp_pid (ptid_t ptid); @@ -600,15 +601,22 @@ num_lwps (int pid) return count; } +/* Call delete_lwp with prototype compatible for make_cleanup. */ + +static void +delete_lwp_cleanup (void *lp_voidp) +{ + struct lwp_info *lp = lp_voidp; + + delete_lwp (lp->ptid); +} + static int linux_child_follow_fork (struct target_ops *ops, int follow_child) { sigset_t prev_mask; int has_vforked; int parent_pid, child_pid; - struct inferior *parent_inf, *child_inf; - struct lwp_info *parent_lp = find_lwp_pid (inferior_ptid); - struct lwp_info *child_lp; block_child_signals (&prev_mask); @@ -640,50 +648,29 @@ holding the child stopped. Try \"set detach-on-fork\" or \ return 1; } - /* Add the new inferior first, so that the target_detach below - doesn't unpush the target. */ - - child_inf = add_inferior (child_pid); - - parent_inf = current_inferior (); - child_inf->attach_flag = parent_inf->attach_flag; - copy_terminal_info (child_inf, parent_inf); - - inferior_ptid = ptid_build (child_pid, child_pid, 0); - - reinit_frame_cache (); - registers_changed (); - - add_thread (inferior_ptid); - child_lp = add_lwp (inferior_ptid); - child_lp->stopped = 1; - child_lp->last_resume_kind = resume_stop; - - /* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it. - Still on Linux kernel before 2.6.33 commit - 72f674d203cd230426437cdcf7dd6f681dad8b0d - fork/vfork/clone were inheriting the hardware debug registers from parent. - Newer Linux kernels create such tasks with zeroed debug registers. - Ensure linux_nat_prepare_to_resume will reset them during target_detach. - It is ensured by the linux_nat_new_thread call, which is being skipped in - add_lwp above for the first lwp of a pid. */ - gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1); - if (linux_nat_new_thread != NULL) - linux_nat_new_thread (child_lp); - if (! follow_child) { + struct lwp_info *child_lp = NULL; + /* We're already attached to the parent, by default. */ /* Detach new forked process? */ if (detach_fork) { + struct cleanup *old_chain; + /* Before detaching from the child, remove all breakpoints from it. If we forked, then this has already been taken care of by infrun.c. If we vforked however, any breakpoint inserted in the parent is visible in the child, even those added while stopped in a vfork - catchpoint. target_detach will remove them from the child. */ + catchpoint. This will remove the breakpoints from the + parent also, but they'll be reinserted below. */ + if (has_vforked) + { + /* keep breakpoints list in sync. */ + remove_breakpoints_pid (GET_PID (inferior_ptid)); + } if (info_verbose || debug_linux_nat) { @@ -694,10 +681,56 @@ holding the child stopped. Try \"set detach-on-fork\" or \ child_pid); } - target_detach (NULL, 0); + old_chain = save_inferior_ptid (); + inferior_ptid = ptid_build (child_pid, child_pid, 0); + + child_lp = add_lwp (inferior_ptid); + child_lp->stopped = 1; + child_lp->last_resume_kind = resume_stop; + make_cleanup (delete_lwp_cleanup, child_lp); + + /* CHILD_LP has new PID, therefore linux_nat_new_thread is not called for it. + Still on Linux kernel before 2.6.33 commit + 72f674d203cd230426437cdcf7dd6f681dad8b0d + fork/vfork/clone were inheriting the hardware debug registers from parent. + Newer Linux kernels create such tasks with zeroed debug registers. + Ensure linux_nat_prepare_to_resume will reset them during target_detach. + It is ensured by the linux_nat_new_thread call, which is being skipped in + add_lwp above for the first lwp of a pid. */ + gdb_assert (num_lwps (GET_PID (child_lp->ptid)) == 1); + if (linux_nat_new_thread != NULL) + linux_nat_new_thread (child_lp); + + if (linux_nat_prepare_to_resume != NULL) + linux_nat_prepare_to_resume (child_lp); + ptrace (PTRACE_DETACH, child_pid, 0, 0); + + do_cleanups (old_chain); } else { + struct inferior *parent_inf, *child_inf; + struct cleanup *old_chain; + + /* Add process to GDB's tables. */ + child_inf = add_inferior (child_pid); + + parent_inf = current_inferior (); + child_inf->attach_flag = parent_inf->attach_flag; + copy_terminal_info (child_inf, parent_inf); + + old_chain = save_inferior_ptid (); + save_current_program_space (); + + inferior_ptid = ptid_build (child_pid, child_pid, 0); + reinit_frame_cache (); + registers_changed (); + + add_thread (inferior_ptid); + child_lp = add_lwp (inferior_ptid); + child_lp->stopped = 1; + child_lp->last_resume_kind = resume_stop; + /* If this is a vfork child, then the address-space is shared with the parent. */ if (has_vforked) @@ -732,14 +765,17 @@ holding the child stopped. Try \"set detach-on-fork\" or \ /* Let the thread_db layer learn about this new process. */ check_for_thread_db (); - } - - /* Note that the detach above makes CHILD_INF dangling. */ - inferior_ptid = parent_lp->ptid; + do_cleanups (old_chain); + } if (has_vforked) { + struct lwp_info *parent_lp; + struct inferior *parent_inf; + + parent_inf = current_inferior (); + /* If we detached from the child, then we have to be careful to not insert breakpoints in the parent until the child is done with the shared memory region. However, if we're @@ -750,6 +786,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ parent_inf->waiting_for_vfork_done = detach_fork; parent_inf->pspace->breakpoints_not_allowed = detach_fork; + parent_lp = find_lwp_pid (pid_to_ptid (parent_pid)); gdb_assert (linux_supports_tracefork_flag >= 0); if (linux_supports_tracevforkdone (0)) @@ -820,6 +857,10 @@ holding the child stopped. Try \"set detach-on-fork\" or \ } else { + struct inferior *parent_inf, *child_inf; + struct lwp_info *child_lp; + struct program_space *parent_pspace; + if (info_verbose || debug_linux_nat) { target_terminal_ours (); @@ -835,6 +876,17 @@ holding the child stopped. Try \"set detach-on-fork\" or \ parent_pid, child_pid); } + /* Add the new inferior first, so that the target_detach below + doesn't unpush the target. */ + + child_inf = add_inferior (child_pid); + + parent_inf = current_inferior (); + child_inf->attach_flag = parent_inf->attach_flag; + copy_terminal_info (child_inf, parent_inf); + + parent_pspace = parent_inf->pspace; + /* If we're vforking, we want to hold on to the parent until the child exits or execs. At child exec or exit time we can remove the old breakpoints from the parent and detach or @@ -856,26 +908,29 @@ holding the child stopped. Try \"set detach-on-fork\" or \ parent_inf->waiting_for_vfork_done = 0; } else if (detach_fork) - { - struct cleanup *old_chain; + target_detach (NULL, 0); - /* Save here child_lp->ptid. */ - old_chain = save_inferior_ptid (); + /* Note that the detach above makes PARENT_INF dangling. */ - inferior_ptid = parent_lp->ptid; - target_detach (NULL, 0); + /* Add the child thread to the appropriate lists, and switch to + this new thread, before cloning the program space, and + informing the solib layer about this new process. */ - do_cleanups (old_chain); - } + inferior_ptid = ptid_build (child_pid, child_pid, 0); + reinit_frame_cache (); + registers_changed (); - /* Note that the detach above makes PARENT_INF dangling. */ + add_thread (inferior_ptid); + child_lp = add_lwp (inferior_ptid); + child_lp->stopped = 1; + child_lp->last_resume_kind = resume_stop; /* If this is a vfork child, then the address-space is shared with the parent. If we detached from the parent, then we can reuse the parent's program/address spaces. */ if (has_vforked || detach_fork) { - child_inf->pspace = parent_inf->pspace; + child_inf->pspace = parent_pspace; child_inf->aspace = child_inf->pspace->aspace; } else @@ -884,7 +939,7 @@ holding the child stopped. Try \"set detach-on-fork\" or \ child_inf->pspace = add_program_space (child_inf->aspace); child_inf->removable = 1; set_current_program_space (child_inf->pspace); - clone_program_space (child_inf->pspace, parent_inf->pspace); + clone_program_space (child_inf->pspace, parent_pspace); /* Let the shared library layer (solib-svr4) learn about this new process, relocate the cloned exec, pull in @@ -1251,8 +1306,22 @@ linux_nat_iterate_watchpoint_lwps else { /* Detaching a new child PID temporarily present in INFERIOR_PID. */ - - callback (NULL, callback_data); + struct lwp_info *child_lp; + struct cleanup *old_chain; + pid_t child_pid = GET_PID (inferior_ptid); + ptid_t child_ptid = ptid_build (child_pid, child_pid, 0); + + gdb_assert (!is_lwp (inferior_ptid)); + gdb_assert (find_lwp_pid (inferior_ptid) == NULL); + gdb_assert (find_lwp_pid (child_ptid) == NULL); + child_lp = add_lwp (child_ptid); + child_lp->stopped = 1; + child_lp->last_resume_kind = resume_stop; + old_chain = make_cleanup (delete_lwp_cleanup, child_lp); + + callback (child_lp, callback_data); + + do_cleanups (old_chain); } } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c32c048..9b540e4 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2011-12-26 Jan Kratochvil + + Fix double send_gdb leading to racy FAILs. + * gdb.base/break.exp (set silent break bp_location1): Replace + 3x send_gdb and gdb_expect by gdb_test. + * gdb.base/fileio.exp: Replace 2x send_gdb by gdb_exit and sleep. + * gdb.base/foll-vfork.exp (vfork_and_exec_child_follow_to_main_bp) + (vfork_and_exec_child_follow_through_step): Use gdb_test_no_output + instead of send_gdb. Twice. + * gdb.base/sepdebug.exp (set silent break bp_location1): Replace + 3x send_gdb and gdb_expect by gdb_test. + * gdb.mi/mi-nsmoribund.exp: Replace 3x send_gdb by mi_gdb_test. + 2011-12-23 Jan Kratochvil * gdb.linespec/linespec.exp: Compile using {c++}. diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index 6d6f310..2292373 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -576,14 +576,7 @@ gdb_test_multiple "break $bp_location1" \ } } -send_gdb "commands $expect_out(1,string)\n" -send_gdb "silent\n" -send_gdb "end\n" -gdb_expect { - -re ".*$gdb_prompt $"\ - {pass "set silent break bp_location1"} - timeout {fail "(timeout) set silent break bp_location1"} -} +gdb_test "commands $expect_out(1,string)\nsilent\nend" ">end" "set silent break bp_location1" gdb_test "info break $expect_out(1,string)" \ "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*" \ diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp index a145e2b..101da15 100644 --- a/gdb/testsuite/gdb.base/fileio.exp +++ b/gdb/testsuite/gdb.base/fileio.exp @@ -247,8 +247,9 @@ gdb_test continue \ "Continuing\\..*time 2:.*OK$stop_msg" \ "Time(2) returns feasible values" -send_gdb "quit\n" -send_gdb "y\n" +gdb_exit +# Wait till GDB really exits. +sleep 1 remote_exec build {sh -xc test\ -r\ dir2.fileio.test\ &&\ chmod\ -f\ +w\ dir2.fileio.test} remote_exec build {sh -xc rm\ -rf\ *.fileio.test} diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index f8a3eeb..1982f9e 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -166,7 +166,7 @@ proc vfork_and_exec_child_follow_to_main_bp {} { send_gdb "kill\n" gdb_expect { -re ".*Kill the program being debugged.*y or n. $" { - send_gdb "y\n" + gdb_test_no_output "y" "" send_gdb "file $binfile\n" gdb_expect { -re ".*Load new symbol table from.*y or n. $" { @@ -224,7 +224,7 @@ proc vfork_and_exec_child_follow_through_step {} { send_gdb "kill\n" gdb_expect { -re ".*Kill the program being debugged.*y or n. $" { - send_gdb "y\n" + gdb_test_no_output "y" "" send_gdb "file $binfile\n" gdb_expect { -re ".*Load new symbol table from.*y or n. $" { diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp index 90fe4ec..57ce305 100644 --- a/gdb/testsuite/gdb.base/sepdebug.exp +++ b/gdb/testsuite/gdb.base/sepdebug.exp @@ -370,14 +370,7 @@ gdb_test_multiple "break $bp_location1" \ } } -send_gdb "commands $expect_out(1,string)\n" -send_gdb "silent\n" -send_gdb "end\n" -gdb_expect { - -re ".*$gdb_prompt $"\ - {pass "set silent break bp_location1"} - timeout {fail "(timeout) set silent break bp_location1"} -} +gdb_test "commands $expect_out(1,string)\nsilent\nend" ">end" "set silent break bp_location1" gdb_test "info break $expect_out(1,string)" \ "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*" \ diff --git a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp index 286004b..10b04ba 100644 --- a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp +++ b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp @@ -118,9 +118,9 @@ mi_check_thread_states \ # we are interested in, so we can't use mi_gdb_test or # gdb_test_multiple (or an MI equivalent) -send_gdb "102-break-delete\n" -send_gdb "print done = 1\n" -send_gdb "103-exec-continue --all\n" +mi_gdb_test "102-break-delete" "102\\^done.*" +mi_gdb_test "print done = 1" { = 1"} +mi_gdb_test "103-exec-continue --all" "\[^\n\]*\r\n$running_re" gdb_expect { -re "\\*stopped,reason=\"exited-normally\"" { diff --git a/gdb/version.in b/gdb/version.in index 13224d2..9a03483 100644 --- a/gdb/version.in +++ b/gdb/version.in @@ -1 +1 @@ -7.4.50.20111225-cvs +7.4.50.20111226-cvs hooks/post-receive -- Repository for Project Archer.