Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Muhammad Waqas <mwaqas@codesourcery.com>
To: Yao Qi <yao@codesourcery.com>
Cc: <gdb-patches@sourceware.org>, <tromey@redhat.com>,
	<ali_anwar@codesourcery.com>
Subject: Re: [PATCH with testcase] Bug 11568 - delete thread-specific breakpoint on the thread exit
Date: Mon, 29 Jul 2013 11:42:00 -0000	[thread overview]
Message-ID: <51F65519.2080806@codesourcery.com> (raw)
In-Reply-To: <51F633E5.7000302@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 6445 bytes --]

On 07/29/2013 02:20 PM, Yao Qi wrote:
> On 07/29/2013 03:29 PM, Muhammad Waqas wrote:
>> 2013-07-24   Muhammad Waqas<waqas.jamil47@gmail.com>
>
> Wrong e-mail address?
> Should mention PR number in ChangeLog.
>
>>
>>       * breakpoint.c (breakpoint_auto_delete): Remove breakpoint
>>       Remove thread related breakpoints if threads are exited.
>>
>
> "Remove breakpoint" can be removed, IMO.
>
>
>> cvs diff -up gdb/breakpoint.c
>>
>>
>> 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    24 Jul 2013 05:18:24 -0000
>> @@ -11910,6 +11910,12 @@ 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*/
>
> This line is too long, and your mailer wrap the patch.
>
>> +      {
>> +    struct thread_info * tp = find_thread_id (b->thread) ;
>> +    if (tp != NULL && (tp->state == THREAD_EXITED ||
>> !target_thread_alive (tp->ptid)))
>
> Likewise.
>
>> +      delete_breakpoint (b);
>> +      }
>>      }
>>    }
>>
>
> I am wondering why don't we register to thread_exit observer, and 
> remove breakpoints when thread exits.  arm-linux-nat.c and 
> ppc-linux-nat.c did something similar to delete thread hw breakpoint.  
> However, I am not sure it is safe to do so considering async/non-stop 
> mode.
>
>> gdb/testcase/Changlog
>>
>> 2013-07-29  Muhammad Waqas<mwaqas@codesourcery.com>
>>
>>       * gdb.threads/thread-specific-bp.c: New file
>
> It is copied from Jan's example in bugzilla, better to list his name 
> here too.
>
>>       * gdb.threads/thread-specific-bp.exp: New file.
>>
>
>
>
>>
>> gdb.threads/thread-specific-bp.c
>
> Please include these new added files into the patch.  So that 
> reviewers can apply your patch to get these new files.
>
> We need a copyright header for test files too.
>
>
>> gdb.threads/thread-specific-bp.exp
>>
>> #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)"
>>       gdb_continue_to_breakpoint "line # 13"
>>       gdb_test "info break" ".*breakpoint.*(thread \[^$thre\])*"
>> }
>>
>
> This test passes even without your patch to breakpoint_auto_delete 
> above.  Please make sure the test fails without your patch, and fails 
> go away when your patch is applied.
>
>
>>
>> Running target unix
>> Running ./gdb.threads/thread-specific-bp.exp ...
>> PASS: gdb.threads/thread-specific-bp.exp: successfully compiled posix
>> threads test case
>> PASS: gdb.threads/thread-specific-bp.exp: continue to breakpoint: start
>> PASS: gdb.threads/thread-specific-bp.exp: thread created
>> PASS: gdb.threads/thread-specific-bp.exp: info break
>                                             ^^^^^^^^^^
>> PASS: gdb.threads/thread-specific-bp.exp: continue to breakpoint: 
>> line # 13
>> PASS: gdb.threads/thread-specific-bp.exp: info break
>                                             ^^^^^^^^^^^
>
> Duplicated test results.  Please make them unique.  Like,
>
> PASS: gdb.threads/thread-specific-bp.exp: info break 1
> ...
> PASS: gdb.threads/thread-specific-bp.exp: info break 2
>
Thanks for reviewing the patch.
gdb/ChangLog

2013-07-24   Muhammad Waqas  <mwaqas@codesourcery.com>

     PR gdb/11568
     * breakpoint.c (breakpoint_auto_delete): add new condition
     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*/
+      {
+    struct thread_info * tp = find_thread_id (b->thread) ;
+    if (tp != NULL && (tp->state == THREAD_EXITED
+               || !target_thread_alive (tp->ptid)))
+      delete_breakpoint (b);
+      }
    }
  }


testsuite/Changlog

2013-07-29  Muhammad Waqas  <mwaqas@codesourcery.com>
         Jan Kratochvil  <jan.kratochvil@redhat.com>

     * gdb.threads/thread-specific-bp.c: New file.
     * gdb.threads/thread-specific-bp.exp: New file.

find the attached file for testcase and now testcase fails without my 
patch and passes with my patch


Test Run By waqas on Mon Jul 29 15:47:40 2013
Native configuration is x86_64-unknown-linux-gnu

         === gdb tests ===

Schedule of variations:
     unix

Running target unix
Running ./gdb.threads/thread-specific-bp.exp ...
PASS: gdb.threads/thread-specific-bp.exp: successfully compiled posix 
threads test case
PASS: gdb.threads/thread-specific-bp.exp: continue to breakpoint: start
PASS: gdb.threads/thread-specific-bp.exp: thread created
PASS: gdb.threads/thread-specific-bp.exp: info break
PASS: gdb.threads/thread-specific-bp.exp: continue to breakpoint: line # 13
PASS: gdb.threads/thread-specific-bp.exp: threaded breakpoint deleted

         === gdb Summary ===

# of expected passes        6
/home/waqas/gdb/mygdb/newgdb/src/gdb/testsuite/../../gdb/gdb version  
7.6.50.20130724-cvs -nw -nx -data-directory 
/home/waqas/gdb/mygdb/newgdb/src/gdb/testsuite/../data-directory


[-- Attachment #2: patch.tar.gz --]
[-- Type: application/x-gzip, Size: 2976 bytes --]

  reply	other threads:[~2013-07-29 11:42 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29  7:29 Muhammad Waqas
2013-07-29  9:21 ` Yao Qi
2013-07-29 11:42   ` Muhammad Waqas [this message]
2013-07-29 14:18     ` Yao Qi
2013-07-30 10:34       ` Muhammad Waqas
2013-07-31  2:41         ` Yao Qi
2013-08-01 10:51           ` Pedro Alves
2013-08-01 10:59             ` Yao Qi
2013-08-01 11:27               ` Pedro Alves
2013-08-01 12:10                 ` Yao Qi
2013-08-01 11:57         ` Pedro Alves
2013-08-01 12:44           ` Muhammad Waqas
2013-08-02  9:45             ` Pedro Alves
2013-08-05 12:01               ` Muhammad Waqas
2013-08-05 13:57                 ` Tom Tromey
2013-08-06  6:12                   ` Muhammad Waqas
2013-08-22  9:42                     ` Muhammad Waqas
2013-08-22 17:14                       ` Pedro Alves
2013-08-23  5:31                         ` Muhammad Waqas
2013-08-27 11:31                         ` Muhammad Waqas
2013-08-27 19:02                           ` Pedro Alves
2013-08-27 19:06                             ` Pedro Alves
2013-08-28 12:26                             ` Muhammad Waqas
2013-08-30 16:28                               ` Pedro Alves
2013-09-02  4:06                                 ` Muhammad Waqas
2013-09-02  8:39                                   ` Pedro Alves
2013-09-02  9:46                                     ` Muhammad Waqas
2013-09-02 10:24                                       ` Pedro Alves
2013-09-02 10:32                                         ` Muhammad Waqas
2013-09-02 10:48                                           ` Pedro Alves
2013-09-02 16:46                               ` Pedro Alves
2013-09-02 16:52                                 ` [PATCH] PR gdb/11568 - delete thread-specific breakpoints on " Pedro Alves
2013-09-09 16:07                                   ` Tom Tromey
2013-09-17 19:36                                     ` Pedro Alves
2013-09-19 14:48                                       ` [COMMIT PATCH] Fix regressions caused by thread-specific breakpoint deletion. (was: Re: [PATCH] PR gdb/11568 - delete thread-specific breakpoints on thread exit) Pedro Alves
2013-08-28 12:26                             ` [PATCH with testcase] Bug 11568 - delete thread-specific breakpoint on the thread exit Muhammad Waqas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51F65519.2080806@codesourcery.com \
    --to=mwaqas@codesourcery.com \
    --cc=ali_anwar@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    --cc=yao@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox