Date: Tue, 13 Nov 2007 12:41:31 +0000 From: Jurjen Middendorp <jurjenm@stack.nl> To: freebsd-questions <freebsd-questions@freebsd.org> Subject: Re: problems using gdb on threaded programs Message-ID: <20071113124131.GA1494@s062107.lan> In-Reply-To: <20071110175309.GA52076@s062107.lan> References: <20071110175309.GA52076@s062107.lan>
next in thread | previous in thread | raw e-mail | index | archive | help
Ok let me try again (more explanation/question below). Also sorry that i screwed up the script output by having a copy of the text in it... not sure how that happened! On Sat, Nov 10, 2007 at 05:53:09PM +0000, Jurjen Middendorp wrote: >Hello, when i try to debug a program with threads (with gdb) gdb complains >about not being able to find thread start point and kind of hangs (see >below). It is quite likely i misconfigured something, but i have no idea >what that something would be (maybe forgot to put stuff in kernel?). >I tried installing a newer version of gdb (6.6) but that fails in a >different way, it can't get the thread info (breakpoints seem to work >better though :) I also tried to recompile libpthread in /usr/src/lib with >debug flag, but no potato. >What else can i try now? i'm kind of stumped. > >- jurjen > >PS. Below is an output of the errors of gdb and a small program that fails. >-------------------------------------------------------------------------------- >Script started on Sat Nov 10 16:51:32 2007 > >/home/jurjen/C > $cat threadthingy.c >#include <stdio.h> >#include <pthread.h> > >void * >start(void* blah) >{ > printf("hello from a thread!\n"); > return NULL; >} > >int >main(void) >{ > pthread_t tid; > pthread_create(&tid, NULL, start, NULL); > pthread_join(tid, NULL); > printf("done!\n"); > return 0; >} > >/home/jurjen/C > $gdb66 threadthingy >GNU gdb 6.6 [GDB v6.6 for FreeBSD] >Copyright (C) 2006 Free Software Foundation, Inc. >GDB is free software, covered by the GNU General Public License, and you are >welcome to change it and/or distribute copies of it under certain conditions. >Type "show copying" to see the conditions. >There is absolutely no warranty for GDB. Type "show warranty" for details. >This GDB was configured as "i386-portbld-freebsd6.2"... >(gdb) b main >Breakpoint 1 at 0x804860c: file threadthingy.c, line 11. >(gdb) b start >Breakpoint 2 at 0x80485d6: file threadthingy.c, line 5. >(gdb) r >Starting program: /stuff/backup/C/threadthingy > >Breakpoint 1, main () at threadthingy.c:11 >11 pthread_create(&tid, NULL, start, NULL); >(gdb) c >Continuing. > >Breakpoint 2, start (blah=0x0) at threadthingy.c:5 >5 printf("hello from a thread!\n"); >(gdb) info threads >(gdb) info thread >(gdb) help info threads >IDs of currently known threads. >(gdb) thread 1 >Thread ID 1 not known. >(gdb) thread 0 >Thread ID 0 not known. >(gdb) thread >[Current thread is 0 (process 53031)] >(gdb) thread next >No symbol "next" in current context. >(gdb) thread 0 >Thread ID 0 not known. >(gdb) info thread >(gdb) c >Continuing. The problem is here i think, why can't gdb display the thread-info? (Or find thread creation points (?) using an older version of gdb). Do i need to use another library/compiler flags if i want to debug threaded programs? - jurjen
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071113124131.GA1494>