This is the mail archive of the gdb@sources.redhat.com 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]

Re: pthreads debug with gdbserver


On Monday 22 November 2004 04:06 pm, Daniel Jacobowitz wrote:
> On Mon, Nov 22, 2004 at 02:40:21PM +0200, Vladimir Vorobyov wrote:
> > I think I've added all missing routines and it ALMOST work. First, I
> > have to specify 'set remotetimeout 60' otherwise gdb reports timeout
> > error (Ignoring packet error, continuing...).
> > - Is it normal ?
> > Second, after I set any break point (e.g. break main) I cant use
> > 'continue' command. Program stops after any instruction with SIGTRAP.
> > When I force gdbserver to ignore 'stepping' variable, everything works
> > fine. But Im sure it is wrong correction. Who is responsible for reseting
> > stepping? And why we need it?
>
> Try CVS; Andreas has also just implemented m68k support.

I've downloaded the CVS version and have some questions:
1) When I try to debug following example:
*************************************************************************************
3       #define NUM_THREADS 5
4
5       void *thread_function(void *arg)
6       {
7           printf("Hello World from %d!\n", arg);
8           sleep(10);
9           printf("Exited %d!\n", arg);
10          pthread_exit(NULL);
11      }
12
13      int main (int argc, char *argv[])
14      {
15          pthread_t threads[NUM_THREADS];
16          int i;
17
18          for (i = 0; i < NUM_THREADS; i++)
19          {
20              pthread_create(&threads[i], NULL, thread_function, (void *)i);
21              printf("Thread %d created.\n", i);
22          }
23          for (i = 0; i < NUM_THREADS; i++)
24              pthread_join(threads[i], NULL);
25
26          printf("finish!\n");
27          return (0);
28      }
******************************************************************************************
I put first break point to line 23. When program stops, 'info threads' shows:
(gdb) info threads
  7 Thread 81926  0x40126f56 in nanosleep ()
   from /tftpboot/rootfsdir/lib/libc.so.6
  6 Thread 65541  0x40126f56 in nanosleep ()
   from /tftpboot/rootfsdir/lib/libc.so.6
  5 Thread 49156  0x40126f56 in nanosleep ()
   from /tftpboot/rootfsdir/lib/libc.so.6
  4 Thread 32771  0x40126f56 in nanosleep ()
   from /tftpboot/rootfsdir/lib/libc.so.6
  3 Thread 16386  0x40126f56 in nanosleep ()
   from /tftpboot/rootfsdir/lib/libc.so.6
  2 Thread 32769  0x40150a0e in loser_poll ()
   from /tftpboot/rootfsdir/lib/libc.so.6
* 1 Thread 16384  main (argc=1, argv=0xbffffe04) at hello.c:23

Looks perfectly for me.
After this if I set "break 9 thread 3" and "continue", program stops on 
correct line but I can't 'step' it:

(gdb) c
Continuing.
[Switching to Thread 16386]

Breakpoint 4, thread_function (arg=0x0) at hello.c:9
9           printf("Exited from %d!\n", arg);
(gdb) step

Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 32771]
0x80000540 in thread_function (arg=0x1) at hello.c:9
9           printf("Exited from %d!\n", arg);
(gdb) c
Continuing.

Program received signal SIGILL, Illegal instruction.
0x80000540 in thread_function (arg=0x1) at hello.c:9
9           printf("Exited from %d!\n", arg);
(gdb) x /20i $pc
0x80000540 <thread_function+36>:        010
0x80000542 <thread_function+38>:        pea 0x800006d4 <_IO_stdin_used+26>
0x80000548 <thread_function+44>:        bsrl 0x80000414 <printf>
0x8000054e <thread_function+50>:        addql #8,%sp
0x80000550 <thread_function+52>:        clrl %sp@-
0x80000552 <thread_function+54>:        bsrl 0x80000444 <pthread_exit>
0x80000558 <thread_function+60>:        nop
0x8000055a <main>:      linkw %fp,#-24
0x8000055e <main+4>:    clrl %fp@(-24)
......
Andreas, do you have this problem on your side?

2) I still need 'set remotetimeout 30' because otherwise I get error "Ignoring 
packet error, continuing...". What can gdbserver do for 30 seconds?

Sorry for the long post.
Could you recommend anything?

Regards,
Vladimir.


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