From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10023 invoked by alias); 30 Jul 2013 10:34:08 -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 9998 invoked by uid 89); 30 Jul 2013 10:34:08 -0000 X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_50,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RDNS_NONE autolearn=no version=3.3.1 Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 30 Jul 2013 10:34:06 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1V47Fd-0003BY-Jq from Muhammad_Waqas@mentor.com ; Tue, 30 Jul 2013 03:33:57 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 30 Jul 2013 03:33:56 -0700 Received: from [137.202.157.111] (147.34.91.1) by mail-na.mentorg.com (147.34.97.43) with Microsoft SMTP Server (TLS) id 14.2.247.3; Tue, 30 Jul 2013 03:33:56 -0700 Message-ID: <51F7967E.3060900@codesourcery.com> Date: Tue, 30 Jul 2013 10:34:00 -0000 From: Muhammad Waqas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: Yao Qi CC: , , Subject: Re: [PATCH with testcase] Bug 11568 - delete thread-specific breakpoint on the thread exit References: <51F619CE.5040407@codesourcery.com> <51F633E5.7000302@codesourcery.com> <51F65519.2080806@codesourcery.com> <51F67992.30704@codesourcery.com> In-Reply-To: <51F67992.30704@codesourcery.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2013-07/txt/msg00756.txt.bz2 On 07/29/2013 07:17 PM, Yao Qi wrote: > On 07/29/2013 07:42 PM, Muhammad Waqas wrote: > > Please have a look at > http://sourceware.org/gdb/wiki/ContributionChecklist , it is very > helpful for you to avoid some issues in your patch. > >> 2013-07-24 Muhammad Waqas > ^^^ Two spaces. > >> >> PR gdb/11568 >> * breakpoint.c (breakpoint_auto_delete): add new condition >> Remove thread related breakpoints if threads are exited. > ^^^^^^^ Tab instead of spaces. > > The changelog entry is like this: > > PR gdb/11568 > * breakpoint.c (breakpoint_auto_delete): Remove thread related > breakpoints if threads are exited. > >> >> >> >> Index: ./gdb/breakpoint.c >> =================================================================== >> RCS file: /cvs/src/src/gdb/breakpoint.c,v >> retrieving revision 1.772 >> diff -u -p -r1.772 breakpoint.c >> --- ./gdb/breakpoint.c 6 Jul 2013 07:14:54 -0000 1.772 >> +++ ./gdb/breakpoint.c 29 Jul 2013 11:22:05 -0000 >> @@ -11910,6 +11910,15 @@ breakpoint_auto_delete (bpstat bs) >> { >> if (b->disposition == disp_del_at_next_stop) >> delete_breakpoint (b); >> + else if (b->thread > 0) /* If breakpoint relates to user created >> + thread Check if it's not alive then >> + delete it*/ > > Please move the comments into the brackets below. Period is missing > in your comment, and we need two spaces after period at the end of > comment. > >> + { >> + struct thread_info * tp = find_thread_id (b->thread) ; > > A blank line is needed here. Indentation looks wrong here. > >> + if (tp != NULL && (tp->state == THREAD_EXITED >> + || !target_thread_alive (tp->ptid))) >> + delete_breakpoint (b); > > and here. > >> + } >> } >> } >> > > I run thread-specific-bp.exp in async/non-stop mode, and I get a fail. > I am afraid your patch only works in all-stop mode. > >> >> testsuite/Changlog >> >> 2013-07-29 Muhammad Waqas >> Jan Kratochvil > ^^^^^^^^^^ > Need a tab instead of spaces. Please reference existing entries in > ChangeLog to see how to list two authors. > >> >> * gdb.threads/thread-specific-bp.c: New file. >> * gdb.threads/thread-specific-bp.exp: New file. > > Please include these new added files into your patch, so that people > can review them. Here is an example > (http://sourceware.org/ml/gdb-patches/2013-07/msg00671.html) I include > new added file in the patch. I use git, but you can get the similar > patch in cvs. > >> # Copyright (C) 1996-2013 Free Software Foundation, Inc. > > It should be 2013 only. > >> gdb_test_multiple "info breakpoint" "get info" { >> -re "(\[0-9\]+)(\[^\n\r\]*breakpoint\[^\n\r\]*main.*thread >> $thre)" { > > I don't really understand this pattern. Probably, we only want to > match "thread $thre" > > ".*$gdb_prompt $" is missing at the end of the pattern. Please add it. > >> fail "threaded breakpoint not deleted" >> } >> -re "(\[0-9\]+)(\[^\n\r\]*breakpoint\[^\n\r\]*main.*\n)" { >> pass "threaded breakpoint deleted" > > fail/pass should be the same. > >> } >> } > > Something like this: > > set test "thread-specific breakpoint is deleted" > gdb_test_multiple "info breakpoint" $test { > -re "thread $thre.*$gdb_prompt $" { > fail $test > } > -re "$gdb_prompt $" { > pass $test > } > } > > There are some trailing spaces in the test. Please remove them. > Index: ChangeLog =================================================================== RCS file: /cvs/src/src/ChangeLog,v retrieving revision 1.1075 diff -u -p -r1.1075 ChangeLog --- ChangeLog 22 Jul 2013 15:17:20 -0000 1.1075 +++ ChangeLog 30 Jul 2013 10:20:09 -0000 @@ -1,3 +1,9 @@ +2013-07-24 Muhammad Waqas + + PR gdb/11568 + * breakpoint.c (breakpoint_auto_delete): Remove thread related + breakpoints if threads are exited. + 2013-07-22 Joel Brobecker * src-release (VER): Use $(TOOL)/common/create-version.sh Index: gdb/breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.773 diff -u -p -r1.773 breakpoint.c --- gdb/breakpoint.c 24 Jul 2013 19:50:32 -0000 1.773 +++ gdb/breakpoint.c 30 Jul 2013 10:20:49 -0000 @@ -11941,6 +11941,17 @@ breakpoint_auto_delete (bpstat bs) { if (b->disposition == disp_del_at_next_stop) delete_breakpoint (b); + else if (b->thread > 0) + { + /* If breakpoint relates to user created thread Check if it's + not alive then delete it. */ + struct thread_info *tp = find_thread_id (b->thread); + + if ( tp != NULL && (tp->state == THREAD_EXITED + || !target_thread_alive (tp->ptid))) + delete_breakpoint(b); + + } } } Problem was with my test case, now It works with async/non-stop mode. Index: gdb/testsuite/ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/testsuite/ChangeLog,v retrieving revision 1.3748 diff -u -p -r1.3748 ChangeLog --- gdb/testsuite/ChangeLog 26 Jul 2013 18:15:06 -0000 1.3748 +++ gdb/testsuite/ChangeLog 30 Jul 2013 10:21:11 -0000 @@ -1,3 +1,9 @@ +2013-07-24 Muhammad Waqas + Jan Kratochvil + + *gdb.thread/thread-specific-bp.c: Newfile. + *gdb.thread/thread-specific-bp.exp: Newfile. + 2013-07-26 Keith Seitz * gdb.mi/mi-var-child-f.exp: Pass f90 to gdb_compile instead Index: gdb/testsuite/gdb.threads/thread-specific-bp.exp =================================================================== RCS file: gdb/testsuite/gdb.threads/thread-specific-bp.exp diff -N gdb/testsuite/gdb.threads/thread-specific-bp.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.threads/thread-specific-bp.exp 30 Jul 2013 10:21:24 -0000 @@ -0,0 +1,54 @@ +# Copyright (C) 2013 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 3 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, see . + +# This file was written by Muhammad Waqas +# +#This test verfiy that Breakpoint on a spacific thread is deleted + +standard_testfile + +if {[gdb_compile_pthreads \ + "${srcdir}/${subdir}/${srcfile}" \ + "${binfile}" executable {debug} ] != "" } { + return -1 +} + +clean_restart ${binfile} +if [runto main] then { + + gdb_breakpoint "start" + gdb_continue_to_breakpoint "start" + gdb_test_multiple "info threads" "get thread 1 id" { + -re "(\[0-9\]+)(\[^\n\r\]*Thread\[^\n\r\]*start.*)($gdb_prompt $)" { + pass "thread created" + } + } + # get the id of thread + set thre $expect_out(1,string) + gdb_breakpoint [gdb_get_line_number "line # 13"] + gdb_breakpoint "main thread $thre" + gdb_test "info break" ".*breakpoint.*(thread $thre)" "Breakpoint set" + gdb_test "thread $thre" "Switching to thread $thre.*" "Thread $thre selected" + gdb_continue_to_breakpoint "line # 13" + set test "thread-specific breakpoint is deleted" + gdb_test_multiple "info breakpoint" $test { + -re "thread $thre.*$gdb_prompt $" { + fail $test + } + -re "$gdb_prompt $" { + pass $test + } + } +} Index: gdb/testsuite/gdb.threads/thread-specific-bp.c =================================================================== RCS file: gdb/testsuite/gdb.threads/thread-specific-bp.c diff -N gdb/testsuite/gdb.threads/thread-specific-bp.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.threads/thread-specific-bp.c 30 Jul 2013 10:21:38 -0000 @@ -0,0 +1,34 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013 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 3 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, see . */ + +#include +#include + +static void * +start (void *arg) +{ + return NULL; +} + +int +main (void) +{ + pthread_t thread; + pthread_create (&thread, NULL, start, NULL); + pthread_join (thread, NULL); + return 0; /*line # 13*/ +}