From owner-svn-src-all@FreeBSD.ORG Tue Nov 26 19:54:12 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DA3F4BFE; Tue, 26 Nov 2013 19:54:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B012B288A; Tue, 26 Nov 2013 19:54:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAQJsCmK013591; Tue, 26 Nov 2013 19:54:12 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAQJsC3J013590; Tue, 26 Nov 2013 19:54:12 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201311261954.rAQJsC3J013590@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 26 Nov 2013 19:54:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258663 - head/contrib/gdb/gdb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Nov 2013 19:54:12 -0000 Author: kib Date: Tue Nov 26 19:54:12 2013 New Revision: 258663 URL: http://svnweb.freebsd.org/changeset/base/258663 Log: Use sysctl KERN_PROC_SIGTRAMP to retrieve the signal trampoline location for the native amd64 ABI. This fixes unwinding over the signal frame after trampoline was moved to the shared page. The code would be more correct if using sysctl for the target process instead of inspecting gdb' own trampoline, but the current change is least intrusive and currently, we always initialize the native ABI sysvec first, which means that trampoline location for FreeBSD/amd64 ABI is relatively stable. Similar change will benefit libunwind. Analyzed by: avg Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/contrib/gdb/gdb/amd64fbsd-nat.c Modified: head/contrib/gdb/gdb/amd64fbsd-nat.c ============================================================================== --- head/contrib/gdb/gdb/amd64fbsd-nat.c Tue Nov 26 19:51:53 2013 (r258662) +++ head/contrib/gdb/gdb/amd64fbsd-nat.c Tue Nov 26 19:54:12 2013 (r258663) @@ -29,6 +29,7 @@ #include #include #include +#include #include #ifdef HAVE_SYS_PROCFS_H @@ -212,24 +213,23 @@ Please report this to . SC_RBP_OFFSET = offset; - /* FreeBSD provides a kern.ps_strings sysctl that we can use to + /* FreeBSD provides a kern.proc.sigtramp sysctl that we can use to locate the sigtramp. That way we can still recognize a sigtramp - if its location is changed in a new kernel. Of course this is - still based on the assumption that the sigtramp is placed - directly under the location where the program arguments and - environment can be found. */ + if its location is changed in a new kernel. */ { - int mib[2]; - long ps_strings; + int mib[4]; + struct kinfo_sigtramp kst; size_t len; mib[0] = CTL_KERN; - mib[1] = KERN_PS_STRINGS; - len = sizeof (ps_strings); - if (sysctl (mib, 2, &ps_strings, &len, NULL, 0) == 0) + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_SIGTRAMP; + mib[3] = getpid(); + len = sizeof (kst); + if (sysctl (mib, sizeof(mib) / sizeof(mib[0]), &kst, &len, NULL, 0) == 0) { - amd64fbsd_sigtramp_start_addr = ps_strings - 32; - amd64fbsd_sigtramp_end_addr = ps_strings; + amd64fbsd_sigtramp_start_addr = kst.ksigtramp_start; + amd64fbsd_sigtramp_end_addr = kst.ksigtramp_end; } } }