More non-stop single-stepping problems: 'next' fails to set internal breakpoint 0

Marc Khouzam marc.khouzam@ericsson.com
Sun Apr 17 13:14:00 GMT 2011


Sorry for the top-post.

I have proposed a fix for this problem in
http://sourceware.org/ml/gdb-patches/2011-04/msg00261.html

Marc
________________________________________
From: Marc Khouzam
Sent: April 15, 2011 10:29 AM
To: 'gdb@sourceware.org'
Subject: More non-stop single-stepping problems: 'next' fails to set internal breakpoint 0

Hi,

During a 'next' operation I'm getting

(gdb) Warning:
Cannot insert breakpoint 0.
Error accessing memory address 0x80484ef: Input/output error.

I'm on linux 32bit but the problem was also reported to me on 64bit.

I reproduced it with a simple program below.
The conditions that I needed to reproduce are:
1- multi-thread (2 or more)
2- non-stop
3- all but one thread are running
4- the stopped thread tries to 'next' over a method

I debugged GDB and I think that ptrace gives a failure
when trying to read memory to see if we can set
the breakpoint, inside inf_ptrace_xfer_partial().

I see the bug with 7.1, 7.2 and 7.3 but I don't see it
using GDB 7.0.

Should I open a PR?  At first glance, this seems pretty
serious.  It would indicate that we cannot step-over
a method in multi-threaded non-stop unless we have
a second thread stopped.

Chris Hall also reported some stepping problems in
non-stop in:
http://sourceware.org/ml/gdb/2011-03/msg00049.html
which may or may not be related.

Thanks

Marc


> gdb.7.3 a.out
GNU gdb (GDB) 7.2.90.20110414-cvs
[snip]
Reading symbols from /home/lmckhou/testing/a.out...done.
(gdb) set target-async on
(gdb) set pagination off
(gdb) set non-stop on
(gdb) l 1
1       #include <pthread.h>
2       #include <unistd.h>
3
4       void *thread_exec1(void *ptr)
5       {
6           int i;
7           for (i=0;i<50;i++) {
8               sleep(2);
9           }
10      }
(gdb) l
11
12      int main()
13      {
14          pthread_t thread2;
15          int iret2 = pthread_create( &thread2, NULL, thread_exec1, (void*) "Thread 2");
16
17          pthread_join(thread2, NULL);
18
19          return 0;
20      }
(gdb) b 8
Breakpoint 1 at 0x80484e3: file multithread.c, line 8.
(gdb) r&
Starting program: /home/lmckhou/testing/a.out
(gdb) [Thread debugging using libthread_db enabled]
[New Thread 0xb7fe7b70 (LWP 5379)]

Breakpoint 1, thread_exec1 (ptr=0x8048610) at multithread.c:8
8               sleep(2);
info thr
  Id   Target Id         Frame
  2    Thread 0xb7fe7b70 (LWP 5379) thread_exec1 (ptr=0x8048610) at multithread.c:8
* 1    Thread 0xb7fe86c0 (LWP 5375) (running)
(gdb) thread 2
[Switching to thread 2 (Thread 0xb7fe7b70 (LWP 5379))]
#0  thread_exec1 (ptr=0x8048610) at multithread.c:8
8               sleep(2);
(gdb) n&
(gdb) Warning:
Cannot insert breakpoint 0.
Error accessing memory address 0x80484ef: Input/output error.

0x08048408 in sleep@plt ()

Single stepping until exit from function sleep@plt,
which has no line number information.
(gdb)



More information about the Gdb mailing list