From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109763 invoked by alias); 14 Feb 2016 18:44:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 109749 invoked by uid 89); 14 Feb 2016 18:44:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=marker1, sk:reverse, marker2, UD:gdb.reverse X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 14 Feb 2016 18:44:39 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id CA164C0AD408 for ; Sun, 14 Feb 2016 18:37:54 +0000 (UTC) Received: from brno.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1EIboCp009649 for ; Sun, 14 Feb 2016 13:37:54 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 4/4] Fix PR gdb/19187 (process record over a fork causes internal error) Date: Sun, 14 Feb 2016 18:44:00 -0000 Message-Id: <1455475070-17797-5-git-send-email-palves@redhat.com> In-Reply-To: <1455475070-17797-1-git-send-email-palves@redhat.com> References: <1455475070-17797-1-git-send-email-palves@redhat.com> X-SW-Source: 2016-02/txt/msg00452.txt.bz2 Right after a fork is detected, we detach breakpoints from the child (detach_breakpoints), which calls into target_remove_breakpoint with inferior_ptid pointing at the child process, but leaves the breakpoint marked inserted (in the parent). The problem is that record-full.c always deletes all knowledge of the breakpoint. Then when we later really delete the breakpoint from the parent, we fail the assertion, since the breakpoint is unexpectedly not found in the record-full.c breakpoint table. The fix is simply to not forget about the breakpoint if we're detaching it from a fork child. gdb/ChangeLog: 2016-02-14 Pedro Alves PR gdb/19187 * record-full.c (record_full_remove_breakpoint): Don't remove the breakpoint from the record_full_breakpoints VEC if we're detaching the breakpoint from a fork child. gdb/testsuite/ChangeLog: 2016-02-14 Pedro Alves PR gdb/19187 * gdb.reverse/waitpid-reverse.exp: Add comment and remove setup_kfails. --- gdb/record-full.c | 7 +++++-- gdb/testsuite/gdb.reverse/waitpid-reverse.exp | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb/record-full.c b/gdb/record-full.c index 418a346..e325869 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -1712,8 +1712,11 @@ record_full_remove_breakpoint (struct target_ops *ops, return ret; } - VEC_unordered_remove (record_full_breakpoint_p, - record_full_breakpoints, ix); + if (reason == REMOVE_BREAKPOINT) + { + VEC_unordered_remove (record_full_breakpoint_p, + record_full_breakpoints, ix); + } return 0; } } diff --git a/gdb/testsuite/gdb.reverse/waitpid-reverse.exp b/gdb/testsuite/gdb.reverse/waitpid-reverse.exp index d583953..e8a1690 100644 --- a/gdb/testsuite/gdb.reverse/waitpid-reverse.exp +++ b/gdb/testsuite/gdb.reverse/waitpid-reverse.exp @@ -18,6 +18,8 @@ # # This test tests waitpid syscall for reverse execution. # +# Also serves as regression test for gdb/19187 (recording across a +# fork). if ![supports_reverse] { return @@ -40,14 +42,12 @@ gdb_test "break marker2" \ "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker2" -setup_kfail "gdb/19187" *-*-* gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*" gdb_test "break marker1" \ "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \ "set breakpoint at marker1" -setup_kfail "gdb/19187" *-*-* gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1" # If the variable was recorded properly on syscall, the old contents (-1) -- 1.9.3