From owner-freebsd-questions@FreeBSD.ORG Sat Nov 10 16:55:10 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 196BB16A46E for ; Sat, 10 Nov 2007 16:55:10 +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 C495113C48A for ; Sat, 10 Nov 2007 16:55:09 +0000 (UTC) (envelope-from jurjenm@stack.nl) Received: by mx1.stack.nl (Postfix, from userid 65534) id D1B0D3FCA0; Sat, 10 Nov 2007 17:55:08 +0100 (CET) X-Spam-DCC: : toad.stack.nl 1356; 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=-0.5 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 07BB740780 for ; Sat, 10 Nov 2007 17:55:01 +0100 (CET) Received: by jurjen (sSMTP sendmail emulation); Sat, 10 Nov 2007 17:53:09 +0000 Date: Sat, 10 Nov 2007 17:53:09 +0000 From: Jurjen Middendorp To: freebsd-questions Message-ID: <20071110175309.GA52076@s062107.lan> Mail-Followup-To: Jurjen Middendorp , freebsd-questions Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Organization: FOTLP (Federation Of Terribly Lazy People) Subject: 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: Sat, 10 Nov 2007 16:55:10 -0000 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 $gdb -v GNU gdb 6.1.1 [FreeBSD] Copyright 2004 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-marcel-freebsd". /home/jurjen/C $gdb threadthingy (gdb) break main Breakpoint 1 at 0x804860c: file threadthingy.c, line 11. (gdb) r Starting program: /stuff/backup/C/threadthingy warning: Unable to get location for thread creation breakpoint: generic error [New LWP 100143] ^C^C^Chelp, gdb hang and now i have to kill it!!^C^C^C^CKilled /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"... 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. (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. Breakpoint 2, start (blah=0x0) at threadthingy.c:5 5 printf("hello from a thread!\n"); (gdb) c Continuing. Breakpoint 2, start (blah=0x0) at threadthingy.c:5 5 printf("hello from a thread!\n"); (gdb) c Continuing. Breakpoint 2, start (blah=0x0) at threadthingy.c:5 5 printf("hello from a thread!\n"); (gdb) n 0x2809373e in ?? () from /lib/libpthread.so.2 (gdb) d b Delete all breakpoints? (y or n) y (gdb) c Continuing. hello from a thread! done! Program exited normally. (gdb) quit Script done on Sat Nov 10 16:53:31 2007 --------------------------------------------------------------------------------