From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Oct 10 12:00:02 2012 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DC6A5C2E for ; Wed, 10 Oct 2012 12:00:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [8.8.178.135]) by mx1.freebsd.org (Postfix) with ESMTP id B35BC8FC31 for ; Wed, 10 Oct 2012 12:00:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q9AC0109029183 for ; Wed, 10 Oct 2012 12:00:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q9AC01Gl029177; Wed, 10 Oct 2012 12:00:01 GMT (envelope-from gnats) Resent-Date: Wed, 10 Oct 2012 12:00:01 GMT Resent-Message-Id: <201210101200.q9AC01Gl029177@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Norbert Koch Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id BB7AE70F for ; Wed, 10 Oct 2012 11:54:15 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 891A38FC0C for ; Wed, 10 Oct 2012 11:54:15 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q9ABsEab091307 for ; Wed, 10 Oct 2012 11:54:14 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id q9ABsEwS091306; Wed, 10 Oct 2012 11:54:14 GMT (envelope-from nobody) Message-Id: <201210101154.q9ABsEwS091306@red.freebsd.org> Date: Wed, 10 Oct 2012 11:54:14 GMT From: Norbert Koch To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: ports/172572: [patch] devel/gdb: add missing thread names X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Oct 2012 12:00:02 -0000 >Number: 172572 >Category: ports >Synopsis: [patch] devel/gdb: add missing thread names >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Wed Oct 10 12:00:01 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Norbert Koch >Release: 9.0-RELEASE >Organization: >Environment: >Description: I have an application that sets thread names using pthread_set_name_np(). Those names are visible using FreeBSD's gdb 6.1.1, but not using the latest gdb 7.5 from ports. The required function and its use in fbsd-threads.c are missing in the port's fbsd-threads.c.patch. I simply added the function without changes and it seems to work. Any reason why this is missing in the port? Any known problems? >How-To-Repeat: >Fix: --- gdb.org/Makefile 2012-10-02 08:40:29.000000000 +0200 +++ gdb/Makefile 2012-10-10 13:34:42.000000000 +0200 @@ -7,7 +7,7 @@ PORTNAME= gdb PORTVERSION= 7.5 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel MASTER_SITES= GNU --- gdb.org/files/fbsd-threads.c 2012-08-28 09:24:15.000000000 +0200 +++ gdb/files/fbsd-threads.c 2012-10-10 13:34:18.000000000 +0200 @@ -431,6 +431,46 @@ fbsd_thread_present = 0; } +static char * +fbsd_thread_get_name (lwpid_t lwpid) +{ + static char last_thr_name[MAXCOMLEN + 1]; + char section_name[32]; + struct ptrace_lwpinfo lwpinfo; + bfd_size_type size; + struct bfd_section *section; + + if (target_has_execution) + { + if (ptrace (PT_LWPINFO, lwpid, (caddr_t)&lwpinfo, sizeof (lwpinfo)) == -1) + goto fail; + strncpy (last_thr_name, lwpinfo.pl_tdname, sizeof (last_thr_name) - 1); + } + else + { + snprintf (section_name, sizeof (section_name), ".tname/%u", lwpid); + section = bfd_get_section_by_name (core_bfd, section_name); + if (! section) + goto fail; + + /* Section size fix-up. */ + size = bfd_section_size (core_bfd, section); + if (size > sizeof (last_thr_name)) + size = sizeof (last_thr_name); + + if (! bfd_get_section_contents (core_bfd, section, last_thr_name, + (file_ptr)0, size)) + goto fail; + if (last_thr_name[0] == '\0') + goto fail; + } + last_thr_name[sizeof (last_thr_name) - 1] = '\0'; + return last_thr_name; +fail: + strcpy (last_thr_name, ""); + return last_thr_name; +} + static void check_for_thread_db (void) { @@ -1114,8 +1154,9 @@ if (ti.ti_lid != 0) { - snprintf (buf, sizeof (buf), "Thread %llx (LWP %d)", - (unsigned long long)th.th_thread, ti.ti_lid); + snprintf (buf, sizeof (buf), "Thread %llx (LWP %d/%s)", + (unsigned long long)th.th_thread, ti.ti_lid, + fbsd_thread_get_name (ti.ti_lid)); } else { >Release-Note: >Audit-Trail: >Unformatted: