From owner-freebsd-questions@FreeBSD.ORG Tue Nov 13 11:43:34 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 426F816A468 for ; Tue, 13 Nov 2007 11:43:34 +0000 (UTC) (envelope-from jurjenm@stack.nl) Received: from mx1.stack.nl (meestal-mk5.stack.nl [IPv6:2001:610:1108:5010::149]) by mx1.freebsd.org (Postfix) with ESMTP id EF3A713C4A3 for ; Tue, 13 Nov 2007 11:43:33 +0000 (UTC) (envelope-from jurjenm@stack.nl) Received: by mx1.stack.nl (Postfix, from userid 65534) id EB36740A5D; Tue, 13 Nov 2007 12:43:32 +0100 (CET) X-Spam-DCC: SIHOPE-DCC-3: toad.stack.nl 1085; Body=1 Fuz1=1 Fuz2=1 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on toad.stack.nl X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RDNS_DYNAMIC, SPF_NEUTRAL autolearn=no version=3.2.3 X-Spam-Relay-Country: NL Received: from jurjen (a62-251-106-27.adsl.xs4all.nl [62.251.106.27]) by mailhost.stack.nl (Postfix) with ESMTP id F0A0740B1E for ; Tue, 13 Nov 2007 12:43:24 +0100 (CET) Received: by jurjen (sSMTP sendmail emulation); Tue, 13 Nov 2007 12:41:32 +0000 Date: Tue, 13 Nov 2007 12:41:31 +0000 From: Jurjen Middendorp To: freebsd-questions Message-ID: <20071113124131.GA1494@s062107.lan> Mail-Followup-To: Jurjen Middendorp , freebsd-questions References: <20071110175309.GA52076@s062107.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071110175309.GA52076@s062107.lan> User-Agent: Mutt/1.4.2.3i Organization: FOTLP (Federation Of Terribly Lazy People) Subject: Re: problems using gdb on threaded programs X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Nov 2007 11:43:34 -0000 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 >#include > >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