This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/23251] New: GDB ignores breakpoint when scheduler-locking is on


https://sourceware.org/bugzilla/show_bug.cgi?id=23251

            Bug ID: 23251
           Summary: GDB ignores breakpoint when scheduler-locking is on
           Product: gdb
           Version: 8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: vivi00791 at gmail dot com
  Target Milestone: ---

gdb will ignore the breakpoint on line 10 of program below
-------------------------------------------------------------
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>

int i=2;
void sub(void)
{
        if(i != 0){
            i = 1/i;
        }
}
int main(void)
{
        pthread_t id, id2;
        int ret, ret2;
        ret=pthread_create(&id,NULL,(void *) sub,NULL);
        ret2=pthread_create(&id2,NULL,(void *) sub,NULL);
        if(ret!=0 & ret2!=0)
        {
                printf ("Create pthread error!\n");
                exit (1);
        }
        pthread_join(id,NULL);
        int re = 0;
        pthread_join(id2,NULL);
        return (0);
}
------------------------------------------------------------------
all gdb command and response list below:

(gdb) b 9
Breakpoint 1 at 0x804: file ./if.c, line 9.
(gdb) b 10
Breakpoint 2 at 0x80e: file ./if.c, line 10.
(gdb) r
Starting program: /home/aaaa/code/if 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff77f1700 (LWP 4035)]
[New Thread 0x7ffff6ff0700 (LWP 4036)]
[Switching to Thread 0x7ffff77f1700 (LWP 4035)]

Thread 2 "if" hit Breakpoint 1, sub () at ./if.c:9
9               if(i != 0){
(gdb) info th
  Id   Target Id         Frame 
  1    Thread 0x7ffff7fda700 (LWP 4031) "if" 0x00007ffff7bc19dd in pthread_join
(
    threadid=140737345689344, thread_return=0x0) at pthread_join.c:90
* 2    Thread 0x7ffff77f1700 (LWP 4035) "if" sub () at ./if.c:9
  3    Thread 0x7ffff6ff0700 (LWP 4036) "if" clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:80
(gdb) thread 3
[Switching to thread 3 (Thread 0x7ffff6ff0700 (LWP 4036))]
#0  clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:80
80      ../sysdeps/unix/sysv/linux/x86_64/clone.S: No such file or directory.
(gdb) set scheduler-locking on
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) c
Continuing.

Thread 3 "if" hit Breakpoint 1, sub () at ./if.c:9
9               if(i != 0){
(gdb) info th
  Id   Target Id         Frame 
  1    Thread 0x7ffff7fda700 (LWP 4031) "if" 0x00007ffff7bc19dd in pthread_join
(
    threadid=140737345689344, thread_return=0x0) at pthread_join.c:90
  2    Thread 0x7ffff77f1700 (LWP 4035) "if" sub () at ./if.c:9
* 3    Thread 0x7ffff6ff0700 (LWP 4036) "if" sub () at ./if.c:9
(gdb) thread 2
[Switching to thread 2 (Thread 0x7ffff77f1700 (LWP 4035))]
#0  sub () at ./if.c:9
9               if(i != 0){
(gdb) c
Continuing.

Thread 2 "if" hit Breakpoint 2, sub () at ./if.c:10
10                  i = 1/i;
(gdb) thread 2
[Switching to thread 2 (Thread 0x7ffff77f1700 (LWP 4035))]
#0  sub () at ./if.c:10
10                  i = 1/i;
(gdb) c
Continuing.
[Thread 0x7ffff77f1700 (LWP 4035) exited]
No unwaited-for children left.
(gdb) thread 3
[Switching to thread 3 (Thread 0x7ffff6ff0700 (LWP 4036))]
#0  sub () at ./if.c:9
9               if(i != 0){
(gdb) c
Continuing.
[Thread 0x7ffff6ff0700 (LWP 4036) exited]
No unwaited-for children left.
(gdb) info b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000555555554804 in sub at ./if.c:9
        breakpoint already hit 2 times
2       breakpoint     keep y   0x000055555555480e in sub at ./if.c:10
        breakpoint already hit 1 time
(gdb)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]