NetBSD Problem Report #47430

From prlw1@inf.phy.cam.ac.uk  Thu Jan 10 20:14:37 2013
Return-Path: <prlw1@inf.phy.cam.ac.uk>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id EED6C63EA72
	for <gnats-bugs@gnats.netbsd.org>; Thu, 10 Jan 2013 20:14:36 +0000 (UTC)
Message-Id: <E1TtOWG-0007bF-FW@quartz.inf.phy.cam.ac.uk>
Date: Thu, 10 Jan 2013 20:14:32 +0000
From: prlw1@cam.ac.uk
Sender: Patrick Welche <prlw1@inf.phy.cam.ac.uk>
Reply-To: prlw1@cam.ac.uk
To: gnats-bugs@gnats.NetBSD.org
Subject: gdb can't debug threaded programs
X-Send-Pr-Version: 3.95

>Number:         47430
>Category:       bin
>Synopsis:       gdb can't debug threaded programs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 10 20:15:00 +0000 2013
>Closed-Date:    Tue Jul 15 22:28:27 +0000 2014
>Last-Modified:  Tue Jul 15 22:28:27 +0000 2014
>Originator:     Patrick Welche
>Release:        NetBSD 6.99.16
>Organization:

>Environment:
-current/amd64 of 7th Jan 2013
>Description:
This began with:
  http://mail-index.netbsd.org/current-users/2012/03/19/msg019561.html

When trying to debug a multithreaded program, gdb receives many SIGTRAPS
and looses the plot. Best seen with an example:
>How-To-Repeat:
% gdb `which dig`
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64--netbsd".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/dig...(no debugging symbols found)...done.
(gdb) break main
Breakpoint 1 at 0x408c17
(gdb) run
Starting program: /usr/bin/dig 

Breakpoint 1, 0x0000000000408c17 in main ()
(gdb) n
Single stepping until exit from function main,
which has no line number information.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007f7ff5638dfa in _sys___kevent50 () from /usr/lib/libc.so.12
(gdb) 
Single stepping until exit from function _sys___kevent50,
which has no line number information.
0x00007f7ff6005f21 in __kevent50 () from /usr/lib/libpthread.so.1
(gdb) 
Single stepping until exit from function __kevent50,
which has no line number information.
0x00007f7ff641df20 in ?? () from /usr/lib/libisc.so.5
(gdb) 
Cannot find bounds of current function
(gdb) 
Cannot find bounds of current function
(gdb) 
Cannot find bounds of current function
(gdb) 
Cannot find bounds of current function
(gdb) quit
A debugging session is active.

	Inferior 1 [process 1443] will be killed.

Quit anyway? (y or n) y
%

I would expect some dig output, and for dig to complete executing
successfully.
>Fix:

>Release-Note:

>Audit-Trail:
From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/47430
Date: Mon, 9 Sep 2013 17:44:37 +0100

 PR47430 appears to have been fixed. Thanks!

State-Changed-From-To: open->closed
State-Changed-By: prlw1@NetBSD.org
State-Changed-When: Fri, 13 Sep 2013 17:27:28 +0000
State-Changed-Why:
Fixed - the dig example works.


State-Changed-From-To: closed->open
State-Changed-By: prlw1@NetBSD.org
State-Changed-When: Sat, 14 Dec 2013 20:22:27 +0000
State-Changed-Why:
-current/amd64 is broken again: dig example fails.


From: Andreas Gustafsson <gson@gson.org>
To: gnats-bugs@NetBSD.org
Cc: christos@NetBSD.org
Subject: Re: bin/47430: gdb can't debug threaded programs
Date: Sun, 2 Feb 2014 12:54:01 +0200

 I ran a couple of automated bisections to determine when this was
 first fixed and when it regressed.

 The success criterion was that the following shell script
 should exit with a zero exit status:

 cat <<EOF >test.gdb
 run +time=1 +tries=1 @127.0.0.177
 cont
 cont
 cont
 cont
 cont
 EOF
 gdb --batch -x test.gdb dig >gdb.out
 cat gdb.out
 ! grep "Program received signal SIGTRAP" gdb.out

 Based on this criterion, the bug was fixed by christos in 
 January 2013:

   2013.01.20.18.18.07 christos src/lib/libpthread_dbg/pthread_dbg.c 1.41
   2013.01.20.18.18.07 christos src/lib/libpthread_dbg/pthread_dbg_int.h 1.7

 And reintroduced by 

From: Andreas Gustafsson <gson@gson.org>
To: gnats-bugs@NetBSD.org
Cc: christos@NetBSD.org
Subject: Re: bin/47430: gdb can't debug threaded programs
Date: Sun, 2 Feb 2014 13:04:47 +0200

 [Second attempt, the first one got sent prematurely...]

 I ran a couple of automated bisections on i386 to determine when this
 bug was first fixed and when it regressed.

 The success criterion was that the following shell script
 should exit with a zero exit status:

 cat <<EOF >test.gdb
 run +time=1 +tries=1 @127.0.0.177
 cont
 cont
 cont
 cont
 cont
 EOF
 gdb --batch -x test.gdb dig >gdb.out
 cat gdb.out
 ! grep "Program received signal SIGTRAP" gdb.out

 Based on this criterion, the bug was fixed by christos in 
 January 2013 with these commits:

   2013.01.20.18.18.07 christos src/lib/libpthread_dbg/pthread_dbg.c 1.41
   2013.01.20.18.18.07 christos src/lib/libpthread_dbg/pthread_dbg_int.h 1.7

 And it was reintroduced in October 2013 between source dates
 2013.10.03.13.40.26 and 2013.10.04.15.24.44, which coincides with
 the import of gdb 7.4.1.
 -- 
 Andreas Gustafsson, gson@gson.org

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, 
	prlw1@cam.ac.uk
Cc: 
Subject: Re: bin/47430: gdb can't debug threaded programs
Date: Sun, 2 Feb 2014 17:01:26 -0500

 On Feb 2, 11:05am, gson@gson.org (Andreas Gustafsson) wrote:
 -- Subject: Re: bin/47430: gdb can't debug threaded programs


 I am stupid; I was testing with a non-threaded named because of the
 pthread_cond bug, so I could not reproduce it. Anyway, it is fixed.

 christos

From: Andreas Gustafsson <gson@gson.org>
To: prlw1@cam.ac.uk
Cc: gnats-bugs@NetBSD.org
Subject: Re: bin/47430: gdb can't debug threaded programs
Date: Fri, 21 Feb 2014 10:22:40 +0200

 On Feb 2, Christos Zoulas wrote:
 > Anyway, it is fixed.

 Confirmed; my test script passes again since Christos' commit of
 src/external/gpl3/gdb/dist/gdb/inf-ptrace.c 1.7.

 Patrick - OK to close the PR?
 -- 
 Andreas Gustafsson, gson@gson.org

From: Patrick Welche <prlw1@cam.ac.uk>
To: Andreas Gustafsson <gson@gson.org>
Cc: gnats-bugs@NetBSD.org
Subject: Re: bin/47430: gdb can't debug threaded programs
Date: Fri, 21 Feb 2014 10:41:08 +0000

 On Fri, Feb 21, 2014 at 10:22:40AM +0200, Andreas Gustafsson wrote:
 > On Feb 2, Christos Zoulas wrote:
 > > Anyway, it is fixed.
 > 
 > Confirmed; my test script passes again since Christos' commit of
 > src/external/gpl3/gdb/dist/gdb/inf-ptrace.c 1.7.
 > 
 > Patrick - OK to close the PR?

 Yes! (Sorry - I should have done that earlier...)

 P

State-Changed-From-To: open->closed
State-Changed-By: gson@NetBSD.org
State-Changed-When: Fri, 21 Feb 2014 11:11:24 +0000
State-Changed-Why:
Submitter says OK to close.


State-Changed-From-To: closed->open
State-Changed-By: prlw1@NetBSD.org
State-Changed-When: Fri, 04 Jul 2014 07:04:56 +0000
State-Changed-Why:
reopen: gdb dig test fails again after import of 7.7.1


From: Patrick Welche <prlw1@cam.ac.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/47430: gdb can't debug threaded programs
Date: Tue, 15 Jul 2014 15:44:24 +0100

 BTW the last fix (inf-ptrace.c) hasn't been lost in the import of 7.7.1, so
 something else is causing the same symptom. (6.99.47/amd64, gdb `which dig` ...)

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47430 CVS commit: src/external/gpl3/gdb/dist/gdb
Date: Tue, 15 Jul 2014 13:35:54 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Tue Jul 15 17:35:54 UTC 2014

 Modified Files:
 	src/external/gpl3/gdb/dist/gdb: amd64bsd-nat.c armnbsd-nat.c
 	    hppanbsd-nat.c i386bsd-nat.c m68kbsd-nat.c mipsnbsd-nat.c
 	    ppcnbsd-nat.c shnbsd-nat.c sparc-nat.c vaxbsd-nat.c

 Log Message:
 PR/47430: Fix debugging threads again, GETTID == ptid_get_lwp for us, not
 ptid_get_tid :-)


 To generate a diff of this commit:
 cvs rdiff -u -r1.5 -r1.6 src/external/gpl3/gdb/dist/gdb/amd64bsd-nat.c \
     src/external/gpl3/gdb/dist/gdb/hppanbsd-nat.c \
     src/external/gpl3/gdb/dist/gdb/i386bsd-nat.c \
     src/external/gpl3/gdb/dist/gdb/sparc-nat.c
 cvs rdiff -u -r1.10 -r1.11 src/external/gpl3/gdb/dist/gdb/armnbsd-nat.c
 cvs rdiff -u -r1.7 -r1.8 src/external/gpl3/gdb/dist/gdb/m68kbsd-nat.c \
     src/external/gpl3/gdb/dist/gdb/mipsnbsd-nat.c \
     src/external/gpl3/gdb/dist/gdb/ppcnbsd-nat.c \
     src/external/gpl3/gdb/dist/gdb/shnbsd-nat.c
 cvs rdiff -u -r1.6 -r1.7 src/external/gpl3/gdb/dist/gdb/vaxbsd-nat.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: prlw1@NetBSD.org
State-Changed-When: Tue, 15 Jul 2014 22:28:27 +0000
State-Changed-Why:
Fixed again!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.