mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-21 11:13:30 +00:00
Vendor import of NetBSD's libexecinfo at 2013-08-29
This commit is contained in:
parent
28df749925
commit
06d02944c7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/NetBSD/libexecinfo/dist/; revision=255025 svn path=/vendor/NetBSD/libexecinfo/20130829/; revision=255026; tag=vendor/NetBSD/libexecinfo/20130829
@ -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 $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2012 The NetBSD Foundation, Inc.
|
.\" Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
@ -116,7 +116,7 @@ on failure.
|
|||||||
.Sh RETURN VALUES
|
.Sh RETURN VALUES
|
||||||
The
|
The
|
||||||
.Fn backtrace
|
.Fn backtrace
|
||||||
function returns the number of elements tht were filled in the backtrace.
|
function returns the number of elements that were filled in the backtrace.
|
||||||
The
|
The
|
||||||
.Fn backtrace_symbols
|
.Fn backtrace_symbols
|
||||||
and
|
and
|
||||||
|
26
backtrace.c
26
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.
|
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||||
@ -29,7 +29,7 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include <sys/cdefs.h>
|
#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 <sys/param.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -50,9 +50,29 @@ __RCSID("$NetBSD: backtrace.c,v 1.2 2012/07/09 03:11:59 christos Exp $");
|
|||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#define SELF "/proc/self/exe"
|
#define SELF "/proc/self/exe"
|
||||||
#else
|
#else
|
||||||
|
#include <sys/sysctl.h>
|
||||||
#define SELF "/proc/curproc/file"
|
#define SELF "/proc/curproc/file"
|
||||||
#endif
|
#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, __arraycount(name), path, &len, NULL, 0) != -1)
|
||||||
|
pathname = path;
|
||||||
|
#endif
|
||||||
|
return open(pathname, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int __printflike(4, 5)
|
static int __printflike(4, 5)
|
||||||
rasprintf(char **buf, size_t *bufsiz, size_t offs, const char *fmt, ...)
|
rasprintf(char **buf, size_t *bufsiz, size_t offs, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
@ -162,7 +182,7 @@ backtrace_symbols_fmt(void *const *trace, size_t len, const char *fmt)
|
|||||||
symtab_t *st;
|
symtab_t *st;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if ((fd = open(SELF, O_RDONLY)) != -1)
|
if ((fd = open_self(O_RDONLY)) != -1)
|
||||||
st = symtab_create(fd, -1, STT_FUNC);
|
st = symtab_create(fd, -1, STT_FUNC);
|
||||||
else
|
else
|
||||||
st = NULL;
|
st = NULL;
|
||||||
|
5
symtab.c
5
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.
|
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||||
@ -29,11 +29,12 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include <sys/cdefs.h>
|
#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 <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user