summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2013-08-29 16:57:55 +0000
committeremaste <emaste@FreeBSD.org>2013-08-29 16:57:55 +0000
commitc5c787b7f208974a60413a18c9843a5e19ef895e (patch)
tree2a9e15c9960e8921c5897480c3dd66c625ae76b6
parent6165f3098023c31d6f65bb00acacd972466dbe35 (diff)
downloadFreeBSD-src-c5c787b7f208974a60413a18c9843a5e19ef895e.zip
FreeBSD-src-c5c787b7f208974a60413a18c9843a5e19ef895e.tar.gz
Update to 2013-08-29 NetBSD libexecinfo snapshot
This adds my patch to use the kern.proc.pathname sysctl instead of relying on procfs(5).
-rw-r--r--contrib/libexecinfo/backtrace.38
-rw-r--r--contrib/libexecinfo/backtrace.c26
-rw-r--r--contrib/libexecinfo/symtab.c6
3 files changed, 27 insertions, 13 deletions
diff --git a/contrib/libexecinfo/backtrace.3 b/contrib/libexecinfo/backtrace.3
index b173dc3..fdd8cec 100644
--- a/contrib/libexecinfo/backtrace.3
+++ b/contrib/libexecinfo/backtrace.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: backtrace.3,v 1.4 2012/06/10 00:24:36 christos Exp $
+.\" $NetBSD: backtrace.3,v 1.5 2013/08/22 17:08:43 christos Exp $
.\" $FreeBSD$
.\"
.\" Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -152,10 +152,4 @@ The Linux versions of the functions (there are no _fmt variants) use
instead of
.Ft size_t
arguments.
-.It
-The
-.Fn backtrace_symbols
-functions currently rely on
-.Xr procfs 5
-to locate the executable.
.El
diff --git a/contrib/libexecinfo/backtrace.c b/contrib/libexecinfo/backtrace.c
index e51c666..756a982 100644
--- a/contrib/libexecinfo/backtrace.c
+++ b/contrib/libexecinfo/backtrace.c
@@ -1,4 +1,4 @@
-/* $NetBSD: backtrace.c,v 1.2 2012/07/09 03:11:59 christos Exp $ */
+/* $NetBSD: backtrace.c,v 1.3 2013/08/29 14:58:56 christos Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: backtrace.c,v 1.2 2012/07/09 03:11:59 christos Exp $");
+__RCSID("$NetBSD: backtrace.c,v 1.3 2013/08/29 14:58:56 christos Exp $");
#include <sys/param.h>
#include <assert.h>
@@ -51,9 +51,29 @@ __RCSID("$NetBSD: backtrace.c,v 1.2 2012/07/09 03:11:59 christos Exp $");
#ifdef __linux__
#define SELF "/proc/self/exe"
#else
+#include <sys/sysctl.h>
#define SELF "/proc/curproc/file"
#endif
+static int
+open_self(int flags)
+{
+ const char *pathname = SELF;
+#ifdef KERN_PROC_PATHNAME
+ static const int name[] = {
+ CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1,
+ };
+ char path[MAXPATHLEN];
+ size_t len;
+
+ len = sizeof(path);
+ if (sysctl(name, 4, path, &len, NULL, 0) != -1)
+ pathname = path;
+#endif
+ return open(pathname, flags);
+}
+
+
static int __printflike(4, 5)
rasprintf(char **buf, size_t *bufsiz, size_t offs, const char *fmt, ...)
{
@@ -163,7 +183,7 @@ backtrace_symbols_fmt(void *const *trace, size_t len, const char *fmt)
symtab_t *st;
int fd;
- if ((fd = open(SELF, O_RDONLY)) != -1)
+ if ((fd = open_self(O_RDONLY)) != -1)
st = symtab_create(fd, -1, STT_FUNC);
else
st = NULL;
diff --git a/contrib/libexecinfo/symtab.c b/contrib/libexecinfo/symtab.c
index 737662e..92d92dc 100644
--- a/contrib/libexecinfo/symtab.c
+++ b/contrib/libexecinfo/symtab.c
@@ -1,4 +1,4 @@
-/* $NetBSD: symtab.c,v 1.1 2012/05/26 22:02:29 christos Exp $ */
+/* $NetBSD: symtab.c,v 1.2 2013/08/29 15:01:57 christos Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,12 +29,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: symtab.c,v 1.1 2012/05/26 22:02:29 christos Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.2 2013/08/29 15:01:57 christos Exp $");
#include <stdlib.h>
#include <stdio.h>
-#include <stdint.h>
#include <string.h>
+#include <stdint.h>
#include <err.h>
#include <dlfcn.h>
OpenPOWER on IntegriCloud