From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25247 invoked by alias); 23 Jun 2003 12:15:33 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 9785 invoked from network); 23 Jun 2003 10:51:14 -0000 Received: from unknown (HELO calvin.codito.com) (203.197.87.98) by sources.redhat.com with SMTP; 23 Jun 2003 10:51:14 -0000 Received: from numenor.codito.co.in (ramana.codito.co.in [192.168.100.52]) by calvin.codito.com (8.12.5/8.12.5) with ESMTP id h5NAnZhk007848 for ; Mon, 23 Jun 2003 16:19:55 +0530 Subject: Problem with multiple threads using gdbserver on x86. From: Ramana Radhakrishnan Reply-To: ramana@codito.com To: gdb@sources.redhat.com Content-Type: multipart/mixed; boundary="=-sO00cP48+1NsyKA6ahPb" Organization: Codito Technologies Message-Id: <1056365816.1389.20.camel@numenor.codito.co.in> Mime-Version: 1.0 Date: Mon, 23 Jun 2003 12:15:00 -0000 X-SW-Source: 2003-06/txt/msg00443.txt.bz2 --=-sO00cP48+1NsyKA6ahPb Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1987 hi, this is regarding debugging multi-threaded applications using gdbserver. I am facing a weird situation with respect to the same. When i try and run gdbserver on a multi-threaded application and try to debug the same, gdb is unable to stop all the threads on hitting a breakpoint in one of the threads. the steps i followed are the following. $>gdbserver localhost:1234 thr $>gdb thr (gdb) target remote localhost:1234 Remote debugging using localhost:1234 0x40000be0 in ?? () (gdb) set remotelogfile logfile (gdb) b main Breakpoint 1 at 0x80484b0: file thr.c, line 11. (gdb) c Continuing. Ignoring packet error, continuing... Ignoring packet error, continuing... Ignoring packet error, continuing... Breakpoint 1, main (argc=1, argv=0xbffff144) at thr.c:11 11 printf("Creating...\n"); (gdb) n 12 pthread_create( &id, NULL, work2, ((void*) 0) ); (gdb) n 13 printf("Created thread.\n"); fflush(stdout); (gdb) n 15 printf("Waiting...\n"); At this point in time if i do an info threads the only thread it shows me is the main thread though in gdb it shows me both the threads. At the same point of time when the main thread is stopped at this position the thread which has just been created runs away. ! and on doing an info threads i do not get the information about the newly created thread. Is this a limitation of gdbserver with respect to kernel space threads. I saw the comment in thread-db.c in the function thread_db_find_new_threads. which says "iterate" over user space threads ?? The foll. is the information regarding my machine / environment. RedHat linux 9.0 . gdb v 5.3 gcc version 3.2.2 20030222 GNU gdb Red Hat Linux (5.3post-0.20021129.18rh) I wonder if anyone else is getting a similar problem ..I am attaching the 2 files that were used for this purpose. build the 2 files as gcc -g new.c thr.c -lpthread (obviously !) regards Ramana P.S. the same works fine on a native version of gdb. --=-sO00cP48+1NsyKA6ahPb Content-Disposition: attachment; filename=new.c Content-Type: text/x-c; name=new.c; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 154 #include void *work2(void *foo) { while ((int)foo<5) { printf("got %d\n", (int) foo++); sleep(2); } return (void *)110; } --=-sO00cP48+1NsyKA6ahPb Content-Disposition: attachment; filename=thr.c Content-Type: text/x-c; name=thr.c; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-length: 438 #include #include #include extern int work2(void *); int main(int argc, char **argv) { pthread_t id;=20 int retval; printf("Creating...\n"); pthread_create( &id, NULL, work2, ((void*) 0) ); printf("Created thread.\n"); fflush(stdout); printf("Waiting...\n"); pthread_join(id,(void **)&retval); printf("Joined with retval =3D %d\n",retval); return 0; } --=-sO00cP48+1NsyKA6ahPb--