CVS commit: src/lib/libexecinfo

2023-08-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Aug 23 12:24:59 UTC 2023

Modified Files:
src/lib/libexecinfo: execinfo.h symtab.c unwind_arm_ehabi_stub.c

Log Message:
libexecinfo: whitespace, missing RCSID, no binary changes


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/execinfo.h
cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/symtab.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/unwind_arm_ehabi_stub.c

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

Modified files:

Index: src/lib/libexecinfo/execinfo.h
diff -u src/lib/libexecinfo/execinfo.h:1.3 src/lib/libexecinfo/execinfo.h:1.4
--- src/lib/libexecinfo/execinfo.h:1.3	Fri Jun 30 21:39:43 2017
+++ src/lib/libexecinfo/execinfo.h	Wed Aug 23 12:24:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: execinfo.h,v 1.3 2017/06/30 21:39:43 christos Exp $	*/
+/*	$NetBSD: execinfo.h,v 1.4 2023/08/23 12:24:59 rin Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #include 
 #include 
 #include 
-  
+
 #ifdef  _BSD_SIZE_T_
 typedef _BSD_SIZE_T_size_t;
 #undef  _BSD_SIZE_T_

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.9 src/lib/libexecinfo/symtab.c:1.10
--- src/lib/libexecinfo/symtab.c:1.9	Sat Jun 25 06:51:37 2022
+++ src/lib/libexecinfo/symtab.c	Wed Aug 23 12:24:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: symtab.c,v 1.9 2022/06/25 06:51:37 skrll Exp $	*/
+/*	$NetBSD: symtab.c,v 1.10 2023/08/23 12:24:59 rin Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: symtab.c,v 1.9 2022/06/25 06:51:37 skrll Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.10 2023/08/23 12:24:59 rin Exp $");
 
 #include 
 #include 
@@ -141,7 +141,7 @@ symtab_create(int fd, int bind, int type
 
 		for (size_t i = 0; i < ns; i++) {
 			GElf_Sym sym;
-gelf_getsym(edata, (int)i, );
+			gelf_getsym(edata, (int)i, );
 
 			DPRINTF("%s@%#jx=%d,%d",
 			elf_strptr(elf, shdr.sh_link, sym.st_name),
@@ -165,7 +165,7 @@ symtab_create(int fd, int bind, int type
 goto out;
 			}
 			s++;
-}
+		}
 		st->nsymbols = s - st->symbols;
 		if (st->nsymbols == 0) {
 			warnx("No symbols found");
@@ -196,9 +196,9 @@ symtab_find(const symtab_t *st, const vo
 	uintptr_t sa = SYMBOL_CANONICALIZE(dli->dli_saddr);
 	uintptr_t ad = sa - fbase;
 
- 	DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]",
+	DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]",
 	(uintmax_t)fbase, dli->dli_saddr, (uintmax_t)sa,
- 	(uintmax_t)me, (uintmax_t)ad);
+	(uintmax_t)me, (uintmax_t)ad);
 
 	for (;;) {
 		if (s[mid].st_value < me)

Index: src/lib/libexecinfo/unwind_arm_ehabi_stub.c
diff -u src/lib/libexecinfo/unwind_arm_ehabi_stub.c:1.2 src/lib/libexecinfo/unwind_arm_ehabi_stub.c:1.3
--- src/lib/libexecinfo/unwind_arm_ehabi_stub.c:1.2	Tue May  6 16:02:10 2014
+++ src/lib/libexecinfo/unwind_arm_ehabi_stub.c	Wed Aug 23 12:24:59 2023
@@ -1,3 +1,5 @@
+/*	$NetBSD: unwind_arm_ehabi_stub.c,v 1.3 2023/08/23 12:24:59 rin Exp $	*/
+
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.



CVS commit: src/lib/libexecinfo

2023-08-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Aug 23 12:24:59 UTC 2023

Modified Files:
src/lib/libexecinfo: execinfo.h symtab.c unwind_arm_ehabi_stub.c

Log Message:
libexecinfo: whitespace, missing RCSID, no binary changes


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/execinfo.h
cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/symtab.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/unwind_arm_ehabi_stub.c

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



CVS commit: src/lib/libexecinfo

2022-06-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 25 06:51:37 UTC 2022

Modified Files:
src/lib/libexecinfo: Makefile backtrace.c symtab.c
Added Files:
src/lib/libexecinfo: symbol.h symbol_hppa.c

Log Message:
Decode function descriptors (aka plabels) on hppa to fix backtrace.

PR/56881: hppa: backtrace_symbols() delivers bogus results for some dynloaded 
functions


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/Makefile
cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/backtrace.c
cvs rdiff -u -r0 -r1.1 src/lib/libexecinfo/symbol.h \
src/lib/libexecinfo/symbol_hppa.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libexecinfo/symtab.c

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



CVS commit: src/lib/libexecinfo

2022-06-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jun 25 06:51:37 UTC 2022

Modified Files:
src/lib/libexecinfo: Makefile backtrace.c symtab.c
Added Files:
src/lib/libexecinfo: symbol.h symbol_hppa.c

Log Message:
Decode function descriptors (aka plabels) on hppa to fix backtrace.

PR/56881: hppa: backtrace_symbols() delivers bogus results for some dynloaded 
functions


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/Makefile
cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/backtrace.c
cvs rdiff -u -r0 -r1.1 src/lib/libexecinfo/symbol.h \
src/lib/libexecinfo/symbol_hppa.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libexecinfo/symtab.c

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

Modified files:

Index: src/lib/libexecinfo/Makefile
diff -u src/lib/libexecinfo/Makefile:1.9 src/lib/libexecinfo/Makefile:1.10
--- src/lib/libexecinfo/Makefile:1.9	Wed Jan 22 15:10:32 2020
+++ src/lib/libexecinfo/Makefile	Sat Jun 25 06:51:37 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.9 2020/01/22 15:10:32 mgorny Exp $
+# $NetBSD: Makefile,v 1.10 2022/06/25 06:51:37 skrll Exp $
 
 .include 
 
@@ -27,6 +27,10 @@ SRCS+=unwind_arm_ehabi_stub.c
 SRCS+=builtin.c
 .endif
 
+.if exists(${.CURDIR}/symbol_${LIBEXECINFO_MACHINE_ARCH}.c)
+SRCS+=symbol_${LIBEXECINFO_MACHINE_ARCH}.c
+.endif
+
 MLINKS+= backtrace.3 backtrace_symbols.3
 MLINKS+= backtrace.3 backtrace_symbols_fmt.3
 MLINKS+= backtrace.3 backtrace_symbols_fd.3

Index: src/lib/libexecinfo/backtrace.c
diff -u src/lib/libexecinfo/backtrace.c:1.7 src/lib/libexecinfo/backtrace.c:1.8
--- src/lib/libexecinfo/backtrace.c:1.7	Thu Jun 23 09:48:00 2022
+++ src/lib/libexecinfo/backtrace.c	Sat Jun 25 06:51:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: backtrace.c,v 1.7 2022/06/23 09:48:00 skrll Exp $	*/
+/*	$NetBSD: backtrace.c,v 1.8 2022/06/25 06:51:37 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: backtrace.c,v 1.7 2022/06/23 09:48:00 skrll Exp $");
+__RCSID("$NetBSD: backtrace.c,v 1.8 2022/06/25 06:51:37 skrll Exp $");
 
 #include 
 #include 
@@ -45,6 +45,7 @@ __RCSID("$NetBSD: backtrace.c,v 1.7 2022
 #include 
 
 #include "execinfo.h"
+#include "symbol.h"
 #include "symtab.h"
 
 #ifdef __linux__
@@ -114,7 +115,8 @@ static ssize_t
 format_string(char **buf, size_t *bufsiz, size_t offs, const char *fmt,
 Dl_info *dli, const void *addr)
 {
-	ptrdiff_t diff = (const char *)addr - (const char *)dli->dli_saddr;
+	const uintptr_t symaddr = SYMBOL_CANONICALIZE(dli->dli_saddr);
+	ptrdiff_t diff = (const char *)addr - (const char *)symaddr;
 	size_t o = offs;
 	int len;
 

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.8 src/lib/libexecinfo/symtab.c:1.9
--- src/lib/libexecinfo/symtab.c:1.8	Thu Jun 23 09:58:25 2022
+++ src/lib/libexecinfo/symtab.c	Sat Jun 25 06:51:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: symtab.c,v 1.8 2022/06/23 09:58:25 skrll Exp $	*/
+/*	$NetBSD: symtab.c,v 1.9 2022/06/25 06:51:37 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: symtab.c,v 1.8 2022/06/23 09:58:25 skrll Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.9 2022/06/25 06:51:37 skrll Exp $");
 
 #include 
 #include 
@@ -48,6 +48,7 @@ __RCSID("$NetBSD: symtab.c,v 1.8 2022/06
 #define ELF_ST_TYPE(x)  (((unsigned int)x) & 0xf)
 #endif
 
+#include "symbol.h"
 #include "symtab.h"
 
 #ifdef SYMTAB_DEBUG
@@ -192,11 +193,12 @@ symtab_find(const symtab_t *st, const vo
 	size_t mid = ns / 2;
 	uintptr_t fbase = st->ispie ? (uintptr_t)dli->dli_fbase : 0;
 	uintptr_t dd, sd, me = (uintptr_t)p - fbase;
-	uintptr_t ad = (uintptr_t)dli->dli_saddr - fbase;
+	uintptr_t sa = SYMBOL_CANONICALIZE(dli->dli_saddr);
+	uintptr_t ad = sa - fbase;
 
-	DPRINTF("[fbase=%#jx, saddr=%p, me=%#jx ad=%#jx]",
-	(uintmax_t)fbase, dli->dli_saddr,
-	(uintmax_t)me, (uintmax_t)ad);
+ 	DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]",
+	(uintmax_t)fbase, dli->dli_saddr, (uintmax_t)sa,
+ 	(uintmax_t)me, (uintmax_t)ad);
 
 	for (;;) {
 		if (s[mid].st_value < me)

Added files:

Index: src/lib/libexecinfo/symbol.h
diff -u /dev/null src/lib/libexecinfo/symbol.h:1.1
--- /dev/null	Sat Jun 25 06:51:37 2022
+++ src/lib/libexecinfo/symbol.h	Sat Jun 25 06:51:37 2022
@@ -0,0 +1,49 @@
+/*	$NetBSD: symbol.h,v 1.1 2022/06/25 06:51:37 skrll Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions 

CVS commit: src/lib/libexecinfo

2022-06-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jun 23 09:58:26 UTC 2022

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
Oops... fix SYMTAB_DEBUG build


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/symtab.c

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

Modified files:

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.7 src/lib/libexecinfo/symtab.c:1.8
--- src/lib/libexecinfo/symtab.c:1.7	Thu Jun 23 09:53:49 2022
+++ src/lib/libexecinfo/symtab.c	Thu Jun 23 09:58:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: symtab.c,v 1.7 2022/06/23 09:53:49 skrll Exp $	*/
+/*	$NetBSD: symtab.c,v 1.8 2022/06/23 09:58:25 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: symtab.c,v 1.7 2022/06/23 09:53:49 skrll Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.8 2022/06/23 09:58:25 skrll Exp $");
 
 #include 
 #include 
@@ -194,7 +194,7 @@ symtab_find(const symtab_t *st, const vo
 	uintptr_t dd, sd, me = (uintptr_t)p - fbase;
 	uintptr_t ad = (uintptr_t)dli->dli_saddr - fbase;
 
-	DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]",
+	DPRINTF("[fbase=%#jx, saddr=%p, me=%#jx ad=%#jx]",
 	(uintmax_t)fbase, dli->dli_saddr,
 	(uintmax_t)me, (uintmax_t)ad);
 



CVS commit: src/lib/libexecinfo

2022-06-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jun 23 09:58:26 UTC 2022

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
Oops... fix SYMTAB_DEBUG build


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/symtab.c

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



CVS commit: src/lib/libexecinfo

2022-06-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jun 23 09:53:49 UTC 2022

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
Define and use a DPRINTF macro


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/symtab.c

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

Modified files:

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.6 src/lib/libexecinfo/symtab.c:1.7
--- src/lib/libexecinfo/symtab.c:1.6	Thu Jun 23 09:48:00 2022
+++ src/lib/libexecinfo/symtab.c	Thu Jun 23 09:53:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: symtab.c,v 1.6 2022/06/23 09:48:00 skrll Exp $	*/
+/*	$NetBSD: symtab.c,v 1.7 2022/06/23 09:53:49 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: symtab.c,v 1.6 2022/06/23 09:48:00 skrll Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.7 2022/06/23 09:53:49 skrll Exp $");
 
 #include 
 #include 
@@ -50,6 +50,12 @@ __RCSID("$NetBSD: symtab.c,v 1.6 2022/06
 
 #include "symtab.h"
 
+#ifdef SYMTAB_DEBUG
+#define DPRINTF(fmt, ...)	fprintf(stderr, "%s: " fmt "\n", __func__, __VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...)
+#endif
+
 struct symbol {
 	char *st_name;
 	uintptr_t st_value;
@@ -136,12 +142,10 @@ symtab_create(int fd, int bind, int type
 			GElf_Sym sym;
 gelf_getsym(edata, (int)i, );
 
-#ifdef SYMTAB_DEBUG
-			fprintf(stderr, "%s: %s@%#jx=%d,%d\n", __func__,
+			DPRINTF("%s@%#jx=%d,%d",
 			elf_strptr(elf, shdr.sh_link, sym.st_name),
 			(uintmax_t)sym.st_value, ELF_ST_BIND(sym.st_info),
 			ELF_ST_TYPE(sym.st_info));
-#endif
 
 			if (bind != -1 &&
 			(unsigned)bind != ELF_ST_BIND(sym.st_info))
@@ -190,11 +194,10 @@ symtab_find(const symtab_t *st, const vo
 	uintptr_t dd, sd, me = (uintptr_t)p - fbase;
 	uintptr_t ad = (uintptr_t)dli->dli_saddr - fbase;
 
-#ifdef SYMTAB_DEBUG
-	fprintf(stderr, "%s: [fbase=%#jx, saddr=%p, me=%#jx ad=%#jx]\n",
-	__func__, (uintmax_t)fbase, dli->dli_saddr, (uintmax_t)me,
-	(uintmax_t)ad);
-#endif
+	DPRINTF("[fbase=%#jx, saddr=%p, sa=%#jx, me=%#jx ad=%#jx]",
+	(uintmax_t)fbase, dli->dli_saddr,
+	(uintmax_t)me, (uintmax_t)ad);
+
 	for (;;) {
 		if (s[mid].st_value < me)
 			lo = mid;
@@ -213,15 +216,11 @@ symtab_find(const symtab_t *st, const vo
 	if (dd > sd) {
 		dli->dli_saddr = (void *)s[mid].st_value;
 		dli->dli_sname = s[mid].st_name;
-#ifdef SYMTAB_DEBUG
-		fprintf(stderr, "%s: me=%#jx -> [%#jx, %s]\n", __func__,
-		(uintmax_t)me, (uintmax_t)sd, dli->dli_sname);
-#endif
+		DPRINTF("me=%#jx -> [%#jx, %s]", (uintmax_t)me, (uintmax_t)sd,
+		dli->dli_sname);
+	} else {
+		DPRINTF("%#jx -> [%#jx, ***]", (uintmax_t)me, (uintmax_t)sd);
 	}
-#ifdef SYMTAB_DEBUG
-	else
-		fprintf(stderr, "%s: %#jx -> [%#jx, ***]\n", __func__,
-		(uintmax_t)me, (uintmax_t)sd);
-#endif
+
 	return 1;
 }



CVS commit: src/lib/libexecinfo

2022-06-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jun 23 09:53:49 UTC 2022

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
Define and use a DPRINTF macro


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/symtab.c

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



CVS commit: src/lib/libexecinfo

2022-06-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jun 23 09:48:00 UTC 2022

Modified Files:
src/lib/libexecinfo: backtrace.c symtab.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/backtrace.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/symtab.c

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

Modified files:

Index: src/lib/libexecinfo/backtrace.c
diff -u src/lib/libexecinfo/backtrace.c:1.6 src/lib/libexecinfo/backtrace.c:1.7
--- src/lib/libexecinfo/backtrace.c:1.6	Fri Sep 25 19:27:31 2015
+++ src/lib/libexecinfo/backtrace.c	Thu Jun 23 09:48:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: backtrace.c,v 1.6 2015/09/25 19:27:31 christos Exp $	*/
+/*	$NetBSD: backtrace.c,v 1.7 2022/06/23 09:48:00 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: backtrace.c,v 1.6 2015/09/25 19:27:31 christos Exp $");
+__RCSID("$NetBSD: backtrace.c,v 1.7 2022/06/23 09:48:00 skrll Exp $");
 
 #include 
 #include 
@@ -93,7 +93,7 @@ rasprintf(char **buf, size_t *bufsiz, si
 			nbufsiz = MAX(*bufsiz + 512, (size_t)len + 1);
 		} else
 			nbufsiz = MAX(offs, *bufsiz) + 512;
-			
+
 		nbuf = realloc(*buf, nbufsiz);
 		if (nbuf == NULL)
 			return -1;

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.5 src/lib/libexecinfo/symtab.c:1.6
--- src/lib/libexecinfo/symtab.c:1.5	Wed Apr 20 14:00:16 2016
+++ src/lib/libexecinfo/symtab.c	Thu Jun 23 09:48:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: symtab.c,v 1.5 2016/04/20 14:00:16 christos Exp $	*/
+/*	$NetBSD: symtab.c,v 1.6 2022/06/23 09:48:00 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: symtab.c,v 1.5 2016/04/20 14:00:16 christos Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.6 2022/06/23 09:48:00 skrll Exp $");
 
 #include 
 #include 
@@ -142,7 +142,7 @@ symtab_create(int fd, int bind, int type
 			(uintmax_t)sym.st_value, ELF_ST_BIND(sym.st_info),
 			ELF_ST_TYPE(sym.st_info));
 #endif
-			
+
 			if (bind != -1 &&
 			(unsigned)bind != ELF_ST_BIND(sym.st_info))
 continue;
@@ -177,7 +177,7 @@ out:
 	return NULL;
 }
 
-	
+
 int
 symtab_find(const symtab_t *st, const void *p, Dl_info *dli)
 {



CVS commit: src/lib/libexecinfo

2022-06-23 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jun 23 09:48:00 UTC 2022

Modified Files:
src/lib/libexecinfo: backtrace.c symtab.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/backtrace.c
cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/symtab.c

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



CVS commit: src/lib/libexecinfo

2020-07-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jul 26 15:53:05 UTC 2020

Modified Files:
src/lib/libexecinfo: unwind.c

Log Message:
If Unwind_Backtrace is broken, ctx.n will still contain ~0, and we will
return that which poor behavior for the user, so return 0 instead.
We could document ~0 to be an error, but that would deviate from the
Linux behavior which is not desirable. Noted by Poul-Henning Kamp


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/unwind.c

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

Modified files:

Index: src/lib/libexecinfo/unwind.c
diff -u src/lib/libexecinfo/unwind.c:1.4 src/lib/libexecinfo/unwind.c:1.5
--- src/lib/libexecinfo/unwind.c:1.4	Wed Jan 22 11:07:40 2020
+++ src/lib/libexecinfo/unwind.c	Sun Jul 26 11:53:05 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unwind.c,v 1.4 2020/01/22 16:07:40 mgorny Exp $	*/
+/*	$NetBSD: unwind.c,v 1.5 2020/07/26 15:53:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -67,7 +67,9 @@ backtrace(void **arr, size_t len)
 	ctx.n = (size_t)~0;
 
 	_Unwind_Backtrace(tracer, );
-	if (ctx.n != (size_t)~0 && ctx.n > 0)
+	if (ctx.n == (size_t)~0)
+		ctx.n = 0;
+	else if (ctx.n > 0)
 		ctx.arr[--ctx.n] = NULL;	/* Skip frame below __start */
 
 	return ctx.n;



CVS commit: src/lib/libexecinfo

2020-07-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jul 26 15:53:05 UTC 2020

Modified Files:
src/lib/libexecinfo: unwind.c

Log Message:
If Unwind_Backtrace is broken, ctx.n will still contain ~0, and we will
return that which poor behavior for the user, so return 0 instead.
We could document ~0 to be an error, but that would deviate from the
Linux behavior which is not desirable. Noted by Poul-Henning Kamp


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/unwind.c

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



CVS commit: src/lib/libexecinfo

2020-01-22 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Wed Jan 22 16:07:40 UTC 2020

Modified Files:
src/lib/libexecinfo: unwind.c

Log Message:
Fix using gcc's unwind.h


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/unwind.c

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

Modified files:

Index: src/lib/libexecinfo/unwind.c
diff -u src/lib/libexecinfo/unwind.c:1.3 src/lib/libexecinfo/unwind.c:1.4
--- src/lib/libexecinfo/unwind.c:1.3	Wed Jan 30 22:46:49 2019
+++ src/lib/libexecinfo/unwind.c	Wed Jan 22 16:07:40 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: unwind.c,v 1.3 2019/01/30 22:46:49 mrg Exp $	*/
+/*	$NetBSD: unwind.c,v 1.4 2020/01/22 16:07:40 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 #include 
 
-#include "unwind.h"
+#include 
 #include "execinfo.h"
 
 struct tracer_context {



CVS commit: src/lib/libexecinfo

2020-01-22 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Wed Jan 22 16:07:40 UTC 2020

Modified Files:
src/lib/libexecinfo: unwind.c

Log Message:
Fix using gcc's unwind.h


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/unwind.c

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



CVS commit: src/lib/libexecinfo

2019-01-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 30 22:46:49 UTC 2019

Modified Files:
src/lib/libexecinfo: unwind.c

Log Message:
make the backtrace()'s tracer() return _URC_FOREIGN_EXCEPTION_CAUGHT
when the array is full.  it won't be able to do any more work if so,
and avoids infinite loops in unwinding as seen on arm64.

XXX:  lack of signal support here means that backtrace() is useless
XXX:  from a signal handler, such as attempting to display the stack
XXX:  when handling a SIGSEGV.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/unwind.c

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



CVS commit: src/lib/libexecinfo

2019-01-30 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan 30 22:46:49 UTC 2019

Modified Files:
src/lib/libexecinfo: unwind.c

Log Message:
make the backtrace()'s tracer() return _URC_FOREIGN_EXCEPTION_CAUGHT
when the array is full.  it won't be able to do any more work if so,
and avoids infinite loops in unwinding as seen on arm64.

XXX:  lack of signal support here means that backtrace() is useless
XXX:  from a signal handler, such as attempting to display the stack
XXX:  when handling a SIGSEGV.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/unwind.c

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

Modified files:

Index: src/lib/libexecinfo/unwind.c
diff -u src/lib/libexecinfo/unwind.c:1.2 src/lib/libexecinfo/unwind.c:1.3
--- src/lib/libexecinfo/unwind.c:1.2	Mon Mar 24 21:26:01 2014
+++ src/lib/libexecinfo/unwind.c	Wed Jan 30 22:46:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: unwind.c,v 1.2 2014/03/24 21:26:01 joerg Exp $	*/
+/*	$NetBSD: unwind.c,v 1.3 2019/01/30 22:46:49 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -52,6 +52,8 @@ tracer(struct _Unwind_Context *ctx, void
 	}
 	if (t->n < t->len)
 		t->arr[t->n++] = (void *)_Unwind_GetIP(ctx);
+	else
+		return _URC_FOREIGN_EXCEPTION_CAUGHT;
 	return 0;
 }
 



CVS commit: src/lib/libexecinfo

2017-10-22 Thread Abhinav Upadhyay
Module Name:src
Committed By:   abhinav
Date:   Sun Oct 22 14:07:03 UTC 2017

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Add rest of the functions from the SYNOPSIS section to the NAME section


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.9 src/lib/libexecinfo/backtrace.3:1.10
--- src/lib/libexecinfo/backtrace.3:1.9	Mon Oct 31 07:37:10 2016
+++ src/lib/libexecinfo/backtrace.3	Sun Oct 22 14:07:03 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: backtrace.3,v 1.9 2016/10/31 07:37:10 pgoyette Exp $
+.\"	$NetBSD: backtrace.3,v 1.10 2017/10/22 14:07:03 abhinav Exp $
 .\"
 .\" Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -31,7 +31,11 @@
 .Dt BACKTRACE 3
 .Os
 .Sh NAME
-.Nm backtrace
+.Nm backtrace ,
+.Nm backtrace_symbols ,
+.Nm backtrace_symbols_fd ,
+.Nm backtrace_symbols_fmt ,
+.Nm backtrace_symbols_fd_fmt
 .Nd fill in the backtrace of the currently executing thread
 .Sh LIBRARY
 .Lb libexecinfo



CVS commit: src/lib/libexecinfo

2017-06-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 30 21:39:43 UTC 2017

Modified Files:
src/lib/libexecinfo: execinfo.h

Log Message:
make this standalone.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/execinfo.h

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

Modified files:

Index: src/lib/libexecinfo/execinfo.h
diff -u src/lib/libexecinfo/execinfo.h:1.2 src/lib/libexecinfo/execinfo.h:1.3
--- src/lib/libexecinfo/execinfo.h:1.2	Sat Jun  9 17:22:17 2012
+++ src/lib/libexecinfo/execinfo.h	Fri Jun 30 17:39:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: execinfo.h,v 1.2 2012/06/09 21:22:17 christos Exp $	*/
+/*	$NetBSD: execinfo.h,v 1.3 2017/06/30 21:39:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,14 @@
 #ifndef _EXECINFO_H_
 #define _EXECINFO_H_
 
-#include 
+#include 
+#include 
+#include 
+  
+#ifdef  _BSD_SIZE_T_
+typedef _BSD_SIZE_T_size_t;
+#undef  _BSD_SIZE_T_
+#endif
 
 __BEGIN_DECLS
 size_t backtrace(void **, size_t);



CVS commit: src/lib/libexecinfo

2017-06-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 30 21:39:43 UTC 2017

Modified Files:
src/lib/libexecinfo: execinfo.h

Log Message:
make this standalone.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/execinfo.h

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



CVS commit: src/lib/libexecinfo

2016-12-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 19 01:24:40 UTC 2016

Modified Files:
src/lib/libexecinfo: unwind.h

Log Message:
flesh out _Unwind_Exception, rust needs it.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/unwind.h

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

Modified files:

Index: src/lib/libexecinfo/unwind.h
diff -u src/lib/libexecinfo/unwind.h:1.4 src/lib/libexecinfo/unwind.h:1.5
--- src/lib/libexecinfo/unwind.h:1.4	Fri Dec  2 14:25:19 2016
+++ src/lib/libexecinfo/unwind.h	Sun Dec 18 20:24:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: unwind.h,v 1.4 2016/12/02 19:25:19 christos Exp $	*/
+/*	$NetBSD: unwind.h,v 1.5 2016/12/19 01:24:40 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -28,7 +28,8 @@
 #ifndef _UNWIND_H_
 #define _UNWIND_H_
 
-#include 
+#include 
+#include 
 
 __BEGIN_DECLS
 struct _Unwind_Context;
@@ -54,6 +55,14 @@ typedef long _Unwind_Word;
 #define	_URC_INSTALL_CONTEXT		7
 #define	_URC_CONTINUE_UNWIND		8
 
+struct _Unwind_Exception {
+	uint64_t exception_class;
+	void (*exception_cleanup)(_Unwind_Reason_Code,
+	struct _Unwind_Exception *);
+	uintptr_t private_1;
+	uintptr_t private_2;
+} __attribute__((__aligned__));
+
 typedef _Unwind_Reason_Code
 (*_Unwind_Trace_Fn)(struct _Unwind_Context *, void *);
 #ifdef notyet



CVS commit: src/lib/libexecinfo

2016-12-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 19 01:24:40 UTC 2016

Modified Files:
src/lib/libexecinfo: unwind.h

Log Message:
flesh out _Unwind_Exception, rust needs it.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/unwind.h

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



CVS commit: src/lib/libexecinfo

2016-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  2 19:25:19 UTC 2016

Modified Files:
src/lib/libexecinfo: unwind.h

Log Message:
Add unwind action type and constants


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/unwind.h

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

Modified files:

Index: src/lib/libexecinfo/unwind.h
diff -u src/lib/libexecinfo/unwind.h:1.3 src/lib/libexecinfo/unwind.h:1.4
--- src/lib/libexecinfo/unwind.h:1.3	Wed Oct 22 12:30:21 2014
+++ src/lib/libexecinfo/unwind.h	Fri Dec  2 14:25:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: unwind.h,v 1.3 2014/10/22 16:30:21 christos Exp $	*/
+/*	$NetBSD: unwind.h,v 1.4 2016/12/02 19:25:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,9 +34,16 @@ __BEGIN_DECLS
 struct _Unwind_Context;
 struct _Unwind_Exception;
 typedef int _Unwind_Reason_Code;
+typedef int _Unwind_Action;
 typedef void *_Unwind_Ptr;
 typedef long _Unwind_Word;
 
+#define	_UA_SEARCH_PHASE	0x01
+#define	_UA_CLEANUP_PHASE	0x02
+#define	_UA_HANDLER_FRAME 	0x04
+#define	_UA_FORCE_UNWIND	0x08
+#define	_UA_END_OF_STACK 	0x10
+
 #define	_URC_NO_REASON			0
 #define	_URC_FOREIGN_EXCEPTION_CAUGHT	1
 #define	_URC_FATAL_PHASE2_ERROR		2



CVS commit: src/lib/libexecinfo

2016-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  2 19:25:19 UTC 2016

Modified Files:
src/lib/libexecinfo: unwind.h

Log Message:
Add unwind action type and constants


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/unwind.h

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



CVS commit: src/lib/libexecinfo

2016-10-31 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Oct 31 07:37:10 UTC 2016

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Fix markup .Dv --> .Dq

(Thanks, wiz!)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libexecinfo/backtrace.3

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



CVS commit: src/lib/libexecinfo

2016-10-31 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Oct 31 07:37:10 UTC 2016

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Fix markup .Dv --> .Dq

(Thanks, wiz!)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.8 src/lib/libexecinfo/backtrace.3:1.9
--- src/lib/libexecinfo/backtrace.3:1.8	Mon Oct 31 01:31:25 2016
+++ src/lib/libexecinfo/backtrace.3	Mon Oct 31 07:37:10 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: backtrace.3,v 1.8 2016/10/31 01:31:25 pgoyette Exp $
+.\"	$NetBSD: backtrace.3,v 1.9 2016/10/31 07:37:10 pgoyette Exp $
 .\"
 .\" Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -100,7 +100,7 @@ The
 function is equivalent of calling
 .Fn backtrace_symbols_fmt
 with a format argument of
-.Dv "%a <%n%D> at %f"
+.Dq "%a <%n%D> at %f"
 .Pp
 The
 .Fn backtrace_symbols_fd



CVS commit: src/lib/libexecinfo

2016-10-30 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Oct 31 01:31:25 UTC 2016

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Typo


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/backtrace.3

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



CVS commit: src/lib/libexecinfo

2016-10-30 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Oct 31 01:31:25 UTC 2016

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Typo


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.7 src/lib/libexecinfo/backtrace.3:1.8
--- src/lib/libexecinfo/backtrace.3:1.7	Sat Dec 26 10:34:36 2015
+++ src/lib/libexecinfo/backtrace.3	Mon Oct 31 01:31:25 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: backtrace.3,v 1.7 2015/12/26 10:34:36 wiz Exp $
+.\"	$NetBSD: backtrace.3,v 1.8 2016/10/31 01:31:25 pgoyette Exp $
 .\"
 .\" Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -107,7 +107,7 @@ The
 and
 .Fn backtrace_symbols_fd_fmt
 are similar to the non _fd named functions, only instead of returning
-an array or strings, they print a new-line separated array of strings in
+an array of strings, they print a new-line separated array of strings in
 fd, and return
 .Dv 0
 on success and



Re: CVS commit: src/lib/libexecinfo

2016-04-20 Thread Joerg Sonnenberger
On Wed, Apr 20, 2016 at 10:00:16AM -0400, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Wed Apr 20 14:00:16 UTC 2016
> 
> Modified Files:
>   src/lib/libexecinfo: symtab.c
> 
> Log Message:
> Don't subtract base if not pie.

Can we please stop making this even more complicated and go back to the
original version and *then* analyse what went wrong?

Joerg


CVS commit: src/lib/libexecinfo

2016-04-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 20 14:00:16 UTC 2016

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
Don't subtract base if not pie.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/symtab.c

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

Modified files:

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.4 src/lib/libexecinfo/symtab.c:1.5
--- src/lib/libexecinfo/symtab.c:1.4	Mon Apr 11 11:30:18 2016
+++ src/lib/libexecinfo/symtab.c	Wed Apr 20 10:00:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: symtab.c,v 1.4 2016/04/11 15:30:18 christos Exp $	*/
+/*	$NetBSD: symtab.c,v 1.5 2016/04/20 14:00:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,12 +29,13 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: symtab.c,v 1.4 2016/04/11 15:30:18 christos Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.5 2016/04/20 14:00:16 christos Exp $");
 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -58,6 +59,7 @@ struct symbol {
 struct symtab {
 	size_t nsymbols;
 	struct symbol *symbols;
+	bool ispie;
 };
 
 static int
@@ -85,6 +87,7 @@ symtab_create(int fd, int bind, int type
 	Elf *elf;
 	symtab_t *st;
 	Elf_Scn *scn = NULL;
+	GElf_Ehdr ehdr;
 
 	if (elf_version(EV_CURRENT) == EV_NONE) {
 		warnx("Elf Library is out of date.");
@@ -102,6 +105,13 @@ symtab_create(int fd, int bind, int type
 		elf_end(elf);
 		return NULL;
 	}
+	if (gelf_getehdr(elf, ) == NULL) {
+		warnx("Error getting ELF Ehdr");
+		elf_end(elf);
+		return NULL;
+	}
+
+	st->ispie = ehdr.e_type == ET_DYN;
 
 	while ((scn = elf_nextscn(elf, scn)) != NULL) {
 		GElf_Shdr shdr;
@@ -176,12 +186,14 @@ symtab_find(const symtab_t *st, const vo
 	size_t hi = ns;
 	size_t lo = 0;
 	size_t mid = ns / 2;
-	uintptr_t dd, sd, me = (uintptr_t)p - (uintptr_t)dli->dli_fbase;
-	uintptr_t ad = (uintptr_t)dli->dli_saddr - (uintptr_t)dli->dli_fbase;
+	uintptr_t fbase = st->ispie ? (uintptr_t)dli->dli_fbase : 0;
+	uintptr_t dd, sd, me = (uintptr_t)p - fbase;
+	uintptr_t ad = (uintptr_t)dli->dli_saddr - fbase;
 
 #ifdef SYMTAB_DEBUG
-	fprintf(stderr, "%s: [fbase=%p, saddr=%p, me=%#jx]\n", __func__,
-	dli->dli_fbase, dli->dli_saddr, (uintmax_t)me);
+	fprintf(stderr, "%s: [fbase=%#jx, saddr=%p, me=%#jx ad=%#jx]\n",
+	__func__, (uintmax_t)fbase, dli->dli_saddr, (uintmax_t)me,
+	(uintmax_t)ad);
 #endif
 	for (;;) {
 		if (s[mid].st_value < me)
@@ -202,14 +214,14 @@ symtab_find(const symtab_t *st, const vo
 		dli->dli_saddr = (void *)s[mid].st_value;
 		dli->dli_sname = s[mid].st_name;
 #ifdef SYMTAB_DEBUG
-		fprintf(stderr, "%s: %p -> [%p, %s]\n", __func__,
-		p, dli->dli_saddr, dli->dli_sname);
+		fprintf(stderr, "%s: me=%#jx -> [%#jx, %s]\n", __func__,
+		(uintmax_t)me, (uintmax_t)sd, dli->dli_sname);
 #endif
 	}
 #ifdef SYMTAB_DEBUG
 	else
-		fprintf(stderr, "%s: %p -> [%p, ***]\n", __func__,
-		p, dli->dli_saddr);
+		fprintf(stderr, "%s: %#jx -> [%#jx, ***]\n", __func__,
+		(uintmax_t)me, (uintmax_t)sd);
 #endif
 	return 1;
 }



CVS commit: src/lib/libexecinfo

2016-04-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 20 14:00:16 UTC 2016

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
Don't subtract base if not pie.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/symtab.c

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



CVS commit: src/lib/libexecinfo

2016-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr 11 15:30:18 UTC 2016

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
make this work with pie binaries (subtract dli_fbase from addresses).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/symtab.c

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



CVS commit: src/lib/libexecinfo

2016-04-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr 11 15:30:18 UTC 2016

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
make this work with pie binaries (subtract dli_fbase from addresses).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/symtab.c

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

Modified files:

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.3 src/lib/libexecinfo/symtab.c:1.4
--- src/lib/libexecinfo/symtab.c:1.3	Tue Sep  3 04:44:45 2013
+++ src/lib/libexecinfo/symtab.c	Mon Apr 11 11:30:18 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: symtab.c,v 1.3 2013/09/03 08:44:45 christos Exp $	*/
+/*	$NetBSD: symtab.c,v 1.4 2016/04/11 15:30:18 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: symtab.c,v 1.3 2013/09/03 08:44:45 christos Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.4 2016/04/11 15:30:18 christos Exp $");
 
 #include 
 #include 
@@ -47,7 +47,6 @@ __RCSID("$NetBSD: symtab.c,v 1.3 2013/09
 #define ELF_ST_TYPE(x)  (((unsigned int)x) & 0xf)
 #endif
 
-
 #include "symtab.h"
 
 struct symbol {
@@ -127,6 +126,13 @@ symtab_create(int fd, int bind, int type
 			GElf_Sym sym;
 gelf_getsym(edata, (int)i, );
 
+#ifdef SYMTAB_DEBUG
+			fprintf(stderr, "%s: %s@%#jx=%d,%d\n", __func__,
+			elf_strptr(elf, shdr.sh_link, sym.st_name),
+			(uintmax_t)sym.st_value, ELF_ST_BIND(sym.st_info),
+			ELF_ST_TYPE(sym.st_info));
+#endif
+			
 			if (bind != -1 &&
 			(unsigned)bind != ELF_ST_BIND(sym.st_info))
 continue;
@@ -170,8 +176,13 @@ symtab_find(const symtab_t *st, const vo
 	size_t hi = ns;
 	size_t lo = 0;
 	size_t mid = ns / 2;
-	uintptr_t dd, sd, me = (uintptr_t)p;
+	uintptr_t dd, sd, me = (uintptr_t)p - (uintptr_t)dli->dli_fbase;
+	uintptr_t ad = (uintptr_t)dli->dli_saddr - (uintptr_t)dli->dli_fbase;
 
+#ifdef SYMTAB_DEBUG
+	fprintf(stderr, "%s: [fbase=%p, saddr=%p, me=%#jx]\n", __func__,
+	dli->dli_fbase, dli->dli_saddr, (uintmax_t)me);
+#endif
 	for (;;) {
 		if (s[mid].st_value < me)
 			lo = mid;
@@ -185,11 +196,20 @@ symtab_find(const symtab_t *st, const vo
 		}
 		mid = (hi + lo) / 2;
 	}
-	dd = me - (uintptr_t)dli->dli_saddr;
+	dd = me - ad;
 	sd = me - s[mid].st_value;
 	if (dd > sd) {
 		dli->dli_saddr = (void *)s[mid].st_value;
 		dli->dli_sname = s[mid].st_name;
+#ifdef SYMTAB_DEBUG
+		fprintf(stderr, "%s: %p -> [%p, %s]\n", __func__,
+		p, dli->dli_saddr, dli->dli_sname);
+#endif
 	}
+#ifdef SYMTAB_DEBUG
+	else
+		fprintf(stderr, "%s: %p -> [%p, ***]\n", __func__,
+		p, dli->dli_saddr);
+#endif
 	return 1;
 }



CVS commit: src/lib/libexecinfo

2015-12-26 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec 26 10:34:36 UTC 2015

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Fix typo, from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.6 src/lib/libexecinfo/backtrace.3:1.7
--- src/lib/libexecinfo/backtrace.3:1.6	Thu Nov  5 08:29:42 2015
+++ src/lib/libexecinfo/backtrace.3	Sat Dec 26 10:34:36 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: backtrace.3,v 1.6 2015/11/05 08:29:42 wiz Exp $
+.\"	$NetBSD: backtrace.3,v 1.7 2015/12/26 10:34:36 wiz Exp $
 .\"
 .\" Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -84,7 +84,7 @@ the /proc filesystem is available to det
 The difference of the symbol address and the address element printed
 using 0x%tx.
 .It Dv D
-The difference of the symbol addresss and the address element printed using
+The difference of the symbol address and the address element printed using
 +0x%tx if non-zero, or nothing if zero.
 .It Dv f
 The filename of the symbol as determined by



CVS commit: src/lib/libexecinfo

2015-12-26 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec 26 10:34:36 UTC 2015

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Fix typo, from FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/backtrace.3

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



CVS commit: src/lib/libexecinfo

2015-11-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Nov  5 08:29:42 UTC 2015

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Correctly document backtrace_symbols_fd_fmt.

>From Henning Petersen in PR 50407.

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/backtrace.3

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



CVS commit: src/lib/libexecinfo

2015-11-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Nov  5 08:29:42 UTC 2015

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Correctly document backtrace_symbols_fd_fmt.

>From Henning Petersen in PR 50407.

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.5 src/lib/libexecinfo/backtrace.3:1.6
--- src/lib/libexecinfo/backtrace.3:1.5	Thu Aug 22 17:08:43 2013
+++ src/lib/libexecinfo/backtrace.3	Thu Nov  5 08:29:42 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: backtrace.3,v 1.5 2013/08/22 17:08:43 christos Exp $
+.\"	$NetBSD: backtrace.3,v 1.6 2015/11/05 08:29:42 wiz Exp $
 .\"
 .\" Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 26, 2012
+.Dd November 5, 2015
 .Dt BACKTRACE 3
 .Os
 .Sh NAME
@@ -46,7 +46,7 @@
 .Ft "char **"
 .Fn backtrace_symbols_fmt "void * const *addrlist" "size_t len" "const char *fmt"
 .Ft int
-.Fn backtrace_symbols_fmt_fd "void * const *addrlist" "size_t len" "const char *fmt" "int fd"
+.Fn backtrace_symbols_fd_fmt "void * const *addrlist" "size_t len" "int fd" "const char *fmt"
 .Sh DESCRIPTION
 The
 .Fn backtrace
@@ -105,7 +105,7 @@ with a format argument of
 The
 .Fn backtrace_symbols_fd
 and
-.Fn backtrace_symbols_fmt_fd
+.Fn backtrace_symbols_fd_fmt
 are similar to the non _fd named functions, only instead of returning
 an array or strings, they print a new-line separated array of strings in
 fd, and return



CVS commit: src/lib/libexecinfo

2015-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 25 19:18:29 UTC 2015

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
use provide KERN_PROC_PATHNAME in PROC_ARGS.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/backtrace.c

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



CVS commit: src/lib/libexecinfo

2015-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 25 19:18:29 UTC 2015

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
use provide KERN_PROC_PATHNAME in PROC_ARGS.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/backtrace.c

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

Modified files:

Index: src/lib/libexecinfo/backtrace.c
diff -u src/lib/libexecinfo/backtrace.c:1.4 src/lib/libexecinfo/backtrace.c:1.5
--- src/lib/libexecinfo/backtrace.c:1.4	Thu Nov 21 11:02:21 2013
+++ src/lib/libexecinfo/backtrace.c	Fri Sep 25 15:18:28 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: backtrace.c,v 1.4 2013/11/21 16:02:21 christos Exp $	*/
+/*	$NetBSD: backtrace.c,v 1.5 2015/09/25 19:18:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: backtrace.c,v 1.4 2013/11/21 16:02:21 christos Exp $");
+__RCSID("$NetBSD: backtrace.c,v 1.5 2015/09/25 19:18:28 christos Exp $");
 
 #include 
 #include 
@@ -60,7 +60,7 @@ open_self(int flags)
 	const char *pathname = SELF;
 #ifdef KERN_PROC_PATHNAME
 	static const int name[] = {
-		CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1,
+		CTL_KERN, KERN_PROC_ARGS, KERN_PROC_PATHNAME, -1,
 	};
 	char path[MAXPATHLEN];
 	size_t len;



CVS commit: src/lib/libexecinfo

2015-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 25 19:27:31 UTC 2015

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
args are flipped.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/backtrace.c

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

Modified files:

Index: src/lib/libexecinfo/backtrace.c
diff -u src/lib/libexecinfo/backtrace.c:1.5 src/lib/libexecinfo/backtrace.c:1.6
--- src/lib/libexecinfo/backtrace.c:1.5	Fri Sep 25 15:18:28 2015
+++ src/lib/libexecinfo/backtrace.c	Fri Sep 25 15:27:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: backtrace.c,v 1.5 2015/09/25 19:18:28 christos Exp $	*/
+/*	$NetBSD: backtrace.c,v 1.6 2015/09/25 19:27:31 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: backtrace.c,v 1.5 2015/09/25 19:18:28 christos Exp $");
+__RCSID("$NetBSD: backtrace.c,v 1.6 2015/09/25 19:27:31 christos Exp $");
 
 #include 
 #include 
@@ -60,7 +60,7 @@ open_self(int flags)
 	const char *pathname = SELF;
 #ifdef KERN_PROC_PATHNAME
 	static const int name[] = {
-		CTL_KERN, KERN_PROC_ARGS, KERN_PROC_PATHNAME, -1,
+		CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME,
 	};
 	char path[MAXPATHLEN];
 	size_t len;



CVS commit: src/lib/libexecinfo

2015-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 25 19:27:31 UTC 2015

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
args are flipped.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/backtrace.c

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



CVS commit: src/lib/libexecinfo

2014-10-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Oct 24 22:42:16 UTC 2014

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
Don't overwrite the real unwind.h if it is present.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/Makefile

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

Modified files:

Index: src/lib/libexecinfo/Makefile
diff -u src/lib/libexecinfo/Makefile:1.7 src/lib/libexecinfo/Makefile:1.8
--- src/lib/libexecinfo/Makefile:1.7	Wed Oct 22 19:29:31 2014
+++ src/lib/libexecinfo/Makefile	Fri Oct 24 22:42:16 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2014/10/22 19:29:31 christos Exp $
+# $NetBSD: Makefile,v 1.8 2014/10/24 22:42:16 joerg Exp $
 
 .include bsd.own.mk
 
@@ -6,7 +6,11 @@ LIBEXECINFO_MACHINE_ARCH?= ${MACHINE_ARC
 USE_UNWIND=yes
 WARNS?=4
 INCSDIR=/usr/include
-INCS=execinfo.h unwind.h
+INCS=execinfo.h
+
+.if ${HAVE_LIBGCC_EH} == yes
+INCS+=	unwind.h
+.endif
 
 #CPPFLAGS+='-D__RCSID(a)=' -D_GNU_SOURCE '-D__printflike(a,b)='
 #CPPFLAGS+=-I/usr/include/libelf



CVS commit: src/lib/libexecinfo

2014-10-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Oct 24 22:42:16 UTC 2014

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
Don't overwrite the real unwind.h if it is present.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/lib/libexecinfo/Makefile

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



CVS commit: src/lib/libexecinfo

2014-10-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 22 16:30:22 UTC 2014

Modified Files:
src/lib/libexecinfo: Makefile unwind.h

Log Message:
Make unwind.h installable.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/Makefile
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/unwind.h

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

Modified files:

Index: src/lib/libexecinfo/Makefile
diff -u src/lib/libexecinfo/Makefile:1.5 src/lib/libexecinfo/Makefile:1.6
--- src/lib/libexecinfo/Makefile:1.5	Sun Mar  9 17:37:37 2014
+++ src/lib/libexecinfo/Makefile	Wed Oct 22 12:30:21 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5 2014/03/09 21:37:37 christos Exp $
+# $NetBSD: Makefile,v 1.6 2014/10/22 16:30:21 christos Exp $
 
 .include bsd.own.mk
 
@@ -27,6 +27,8 @@ SRCS+=unwind_arm_ehabi_stub.c
 SRCS+=builtin.c
 .endif
 
+INCS=unwind.h
+
 MLINKS+= backtrace.3 backtrace_symbols.3
 MLINKS+= backtrace.3 backtrace_symbols_fmt.3
 MLINKS+= backtrace.3 backtrace_symbols_fd.3

Index: src/lib/libexecinfo/unwind.h
diff -u src/lib/libexecinfo/unwind.h:1.2 src/lib/libexecinfo/unwind.h:1.3
--- src/lib/libexecinfo/unwind.h:1.2	Mon Mar 24 17:26:01 2014
+++ src/lib/libexecinfo/unwind.h	Wed Oct 22 12:30:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: unwind.h,v 1.2 2014/03/24 21:26:01 joerg Exp $	*/
+/*	$NetBSD: unwind.h,v 1.3 2014/10/22 16:30:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -28,6 +28,8 @@
 #ifndef _UNWIND_H_
 #define _UNWIND_H_
 
+#include sys/cdefs.h
+
 __BEGIN_DECLS
 struct _Unwind_Context;
 struct _Unwind_Exception;
@@ -35,6 +37,16 @@ typedef int _Unwind_Reason_Code;
 typedef void *_Unwind_Ptr;
 typedef long _Unwind_Word;
 
+#define	_URC_NO_REASON			0
+#define	_URC_FOREIGN_EXCEPTION_CAUGHT	1
+#define	_URC_FATAL_PHASE2_ERROR		2
+#define	_URC_FATAL_PHASE1_ERROR		3
+#define	_URC_NORMAL_STOP		4
+#define	_URC_END_OF_STACK		5
+#define	_URC_HANDLER_FOUND		6
+#define	_URC_INSTALL_CONTEXT		7
+#define	_URC_CONTINUE_UNWIND		8
+
 typedef _Unwind_Reason_Code
 (*_Unwind_Trace_Fn)(struct _Unwind_Context *, void *);
 #ifdef notyet



CVS commit: src/lib/libexecinfo

2014-10-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 22 19:29:31 UTC 2014

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
don't kill the existing includes


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/Makefile

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

Modified files:

Index: src/lib/libexecinfo/Makefile
diff -u src/lib/libexecinfo/Makefile:1.6 src/lib/libexecinfo/Makefile:1.7
--- src/lib/libexecinfo/Makefile:1.6	Wed Oct 22 12:30:21 2014
+++ src/lib/libexecinfo/Makefile	Wed Oct 22 15:29:31 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.6 2014/10/22 16:30:21 christos Exp $
+# $NetBSD: Makefile,v 1.7 2014/10/22 19:29:31 christos Exp $
 
 .include bsd.own.mk
 
@@ -6,7 +6,7 @@ LIBEXECINFO_MACHINE_ARCH?= ${MACHINE_ARC
 USE_UNWIND=yes
 WARNS?=4
 INCSDIR=/usr/include
-INCS=execinfo.h
+INCS=execinfo.h unwind.h
 
 #CPPFLAGS+='-D__RCSID(a)=' -D_GNU_SOURCE '-D__printflike(a,b)='
 #CPPFLAGS+=-I/usr/include/libelf
@@ -27,8 +27,6 @@ SRCS+=unwind_arm_ehabi_stub.c
 SRCS+=builtin.c
 .endif
 
-INCS=unwind.h
-
 MLINKS+= backtrace.3 backtrace_symbols.3
 MLINKS+= backtrace.3 backtrace_symbols_fmt.3
 MLINKS+= backtrace.3 backtrace_symbols_fd.3



CVS commit: src/lib/libexecinfo

2014-10-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 22 16:30:22 UTC 2014

Modified Files:
src/lib/libexecinfo: Makefile unwind.h

Log Message:
Make unwind.h installable.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libexecinfo/Makefile
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/unwind.h

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



CVS commit: src/lib/libexecinfo

2014-10-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 22 19:29:31 UTC 2014

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
don't kill the existing includes


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libexecinfo/Makefile

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



CVS commit: src/lib/libexecinfo

2014-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  9 21:37:37 UTC 2014

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
another libelf instance


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/Makefile

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

Modified files:

Index: src/lib/libexecinfo/Makefile
diff -u src/lib/libexecinfo/Makefile:1.4 src/lib/libexecinfo/Makefile:1.5
--- src/lib/libexecinfo/Makefile:1.4	Mon Apr 29 21:41:01 2013
+++ src/lib/libexecinfo/Makefile	Sun Mar  9 17:37:37 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2013/04/30 01:41:01 matt Exp $
+# $NetBSD: Makefile,v 1.5 2014/03/09 21:37:37 christos Exp $
 
 .include bsd.own.mk
 
@@ -12,7 +12,7 @@ INCS=execinfo.h
 #CPPFLAGS+=-I/usr/include/libelf
 #COPTS+=-std=gnu99
 
-LIBDPLIBS+= elf	${NETBSDSRCDIR}/external/bsd/libelf/lib
+LIBDPLIBS+= elf	${NETBSDSRCDIR}/external/bsd/elftoolchain/lib/libelf
 
 LIB=execinfo
 SRCS=symtab.c backtrace.c



CVS commit: src/lib/libexecinfo

2014-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar  9 21:37:37 UTC 2014

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
another libelf instance


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/Makefile

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



CVS commit: src/lib/libexecinfo

2013-11-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 21 16:02:21 UTC 2013

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
From Ed Maste:

  libexecinfo: Include terminating null in byte count

  Otherwise, a formatted string with a strlen equal to the remaining
  buffer space would have the last character omitted (because vsnprintf
  always null-terminates), and later the assert in backtrace_symbols_fmt
  would fail.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/backtrace.c

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

Modified files:

Index: src/lib/libexecinfo/backtrace.c
diff -u src/lib/libexecinfo/backtrace.c:1.3 src/lib/libexecinfo/backtrace.c:1.4
--- src/lib/libexecinfo/backtrace.c:1.3	Thu Aug 29 10:58:56 2013
+++ src/lib/libexecinfo/backtrace.c	Thu Nov 21 11:02:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: backtrace.c,v 1.3 2013/08/29 14:58:56 christos Exp $	*/
+/*	$NetBSD: backtrace.c,v 1.4 2013/11/21 16:02:21 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.3 2013/08/29 14:58:56 christos Exp $);
+__RCSID($NetBSD: backtrace.c,v 1.4 2013/11/21 16:02:21 christos Exp $);
 
 #include sys/param.h
 #include assert.h
@@ -88,7 +88,7 @@ rasprintf(char **buf, size_t *bufsiz, si
 			len = vsnprintf(*buf + offs, *bufsiz - offs, fmt, ap);
 			va_end(ap);
 
-			if (len  0 || (size_t)len  *bufsiz - offs)
+			if (len  0 || (size_t)len + 1  *bufsiz - offs)
 return len;
 			nbufsiz = MAX(*bufsiz + 512, (size_t)len + 1);
 		} else



CVS commit: src/lib/libexecinfo

2013-11-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 21 16:02:21 UTC 2013

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
From Ed Maste:

  libexecinfo: Include terminating null in byte count

  Otherwise, a formatted string with a strlen equal to the remaining
  buffer space would have the last character omitted (because vsnprintf
  always null-terminates), and later the assert in backtrace_symbols_fmt
  would fail.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/backtrace.c

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



CVS commit: src/lib/libexecinfo

2013-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep  3 08:44:45 UTC 2013

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
print an error if we failed to allocate.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/symtab.c

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

Modified files:

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.2 src/lib/libexecinfo/symtab.c:1.3
--- src/lib/libexecinfo/symtab.c:1.2	Thu Aug 29 11:01:57 2013
+++ src/lib/libexecinfo/symtab.c	Tue Sep  3 04:44:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: symtab.c,v 1.2 2013/08/29 15:01:57 christos Exp $	*/
+/*	$NetBSD: symtab.c,v 1.3 2013/09/03 08:44:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: symtab.c,v 1.2 2013/08/29 15:01:57 christos Exp $);
+__RCSID($NetBSD: symtab.c,v 1.3 2013/09/03 08:44:45 christos Exp $);
 
 #include stdlib.h
 #include stdio.h
@@ -139,8 +139,10 @@ symtab_create(int fd, int bind, int type
 			s-st_info = sym.st_info;
 			s-st_name = strdup(
 			elf_strptr(elf, shdr.sh_link, sym.st_name));
-			if (s-st_name == NULL)
+			if (s-st_name == NULL) {
+warn(Cannot allocate symbol);
 goto out;
+			}
 			s++;
 }
 		st-nsymbols = s - st-symbols;



CVS commit: src/lib/libexecinfo

2013-09-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep  3 08:44:45 UTC 2013

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
print an error if we failed to allocate.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/symtab.c

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



CVS commit: src/lib/libexecinfo

2013-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 29 14:58:56 UTC 2013

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
use sysctl to find the pathname argv[0] if available (from FreeBSD via
Ed Maste)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/backtrace.c

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

Modified files:

Index: src/lib/libexecinfo/backtrace.c
diff -u src/lib/libexecinfo/backtrace.c:1.2 src/lib/libexecinfo/backtrace.c:1.3
--- src/lib/libexecinfo/backtrace.c:1.2	Sun Jul  8 23:11:59 2012
+++ src/lib/libexecinfo/backtrace.c	Thu Aug 29 10:58:56 2013
@@ -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
@@ -50,9 +50,29 @@ __RCSID($NetBSD: backtrace.c,v 1.2 2012
 #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, __arraycount(name), 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, ...)
 {
@@ -162,7 +182,7 @@ backtrace_symbols_fmt(void *const *trace
 	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;



CVS commit: src/lib/libexecinfo

2013-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 29 15:01:57 UTC 2013

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
add stdint.h for FreeBSD compat.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/symtab.c

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

Modified files:

Index: src/lib/libexecinfo/symtab.c
diff -u src/lib/libexecinfo/symtab.c:1.1 src/lib/libexecinfo/symtab.c:1.2
--- src/lib/libexecinfo/symtab.c:1.1	Sat May 26 18:02:29 2012
+++ src/lib/libexecinfo/symtab.c	Thu Aug 29 11:01:57 2013
@@ -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,11 +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 string.h
+#include stdint.h
 #include err.h
 #include dlfcn.h
 



CVS commit: src/lib/libexecinfo

2013-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 29 14:58:56 UTC 2013

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
use sysctl to find the pathname argv[0] if available (from FreeBSD via
Ed Maste)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/backtrace.c

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



CVS commit: src/lib/libexecinfo

2013-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 29 15:01:57 UTC 2013

Modified Files:
src/lib/libexecinfo: symtab.c

Log Message:
add stdint.h for FreeBSD compat.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/symtab.c

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



CVS commit: src/lib/libexecinfo

2013-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 22 17:08:43 UTC 2013

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
fix typo (Sergey Kandaurov)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.4 src/lib/libexecinfo/backtrace.3:1.5
--- src/lib/libexecinfo/backtrace.3:1.4	Sat Jun  9 20:24:36 2012
+++ src/lib/libexecinfo/backtrace.3	Thu Aug 22 13:08:43 2013
@@ -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.
 .\ All rights reserved.
@@ -116,7 +116,7 @@ on failure.
 .Sh RETURN VALUES
 The
 .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
 .Fn backtrace_symbols
 and



CVS commit: src/lib/libexecinfo

2013-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 22 17:08:43 UTC 2013

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
fix typo (Sergey Kandaurov)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libexecinfo/backtrace.3

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



CVS commit: src/lib/libexecinfo

2013-04-29 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Tue Apr 30 01:41:02 UTC 2013

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
earm - earm*


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/Makefile

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

Modified files:

Index: src/lib/libexecinfo/Makefile
diff -u src/lib/libexecinfo/Makefile:1.3 src/lib/libexecinfo/Makefile:1.4
--- src/lib/libexecinfo/Makefile:1.3	Sat Apr 27 06:24:23 2013
+++ src/lib/libexecinfo/Makefile	Tue Apr 30 01:41:01 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2013/04/27 06:24:23 matt Exp $
+# $NetBSD: Makefile,v 1.4 2013/04/30 01:41:01 matt Exp $
 
 .include bsd.own.mk
 
@@ -20,7 +20,7 @@ MAN= backtrace.3
 
 .if ${USE_UNWIND} == yes
 SRCS+=unwind.c
-.if !empty(LIBEXECINFO_MACHINE_ARCH:Mearm)
+.if !empty(LIBEXECINFO_MACHINE_ARCH:Mearm*)
 SRCS+=unwind_arm_ehabi_stub.c
 .endif
 .else



CVS commit: src/lib/libexecinfo

2013-04-29 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Tue Apr 30 01:41:02 UTC 2013

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
earm - earm*


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/Makefile

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



CVS commit: src/lib/libexecinfo

2013-04-25 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr 25 14:47:30 UTC 2013

Added Files:
src/lib/libexecinfo: unwind_arm_ehabi_stub.c

Log Message:
libgcc/libcompiler_rt inlines some functions needed by libexecinfo when
using ARM EHABI.  Provide uninlined versions for libexecinfo.
from skrll@


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libexecinfo/unwind_arm_ehabi_stub.c

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

Added files:

Index: src/lib/libexecinfo/unwind_arm_ehabi_stub.c
diff -u /dev/null src/lib/libexecinfo/unwind_arm_ehabi_stub.c:1.1
--- /dev/null	Thu Apr 25 14:47:30 2013
+++ src/lib/libexecinfo/unwind_arm_ehabi_stub.c	Thu Apr 25 14:47:30 2013
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include sys/cdefs.h
+#include sys/types.h
+#include unwind.h
+
+void _Unwind_VRS_Get(struct _Unwind_Context *, int, _Unwind_Word, int, void *);
+void _Unwind_VRS_Set(struct _Unwind_Context *, int, _Unwind_Word, int, void *);
+
+_Unwind_Word
+_Unwind_GetGR(struct _Unwind_Context *context, int regno)
+{
+	_Unwind_Word val;
+	_Unwind_VRS_Get(context, 0 /*_UVRSC_CORE*/, regno, 0 /*_UVRSD_UINT32*/,
+	val);
+
+	return val;
+}
+
+_Unwind_Ptr
+_Unwind_GetIP(struct _Unwind_Context *context)
+{
+	return (_Unwind_Ptr)(_Unwind_GetGR (context, 15)  ~(_Unwind_Word)1);
+}
+
+_Unwind_Ptr
+_Unwind_GetIPInfo(struct _Unwind_Context *context, int *p)
+{
+	*p = 0;
+	return _Unwind_GetIP(context);
+}
+
+void
+_Unwind_SetGR(struct _Unwind_Context *context, int reg, _Unwind_Ptr val)
+{
+	_Unwind_VRS_Set(context, 0 /*_UVRSC_CORE*/, reg, 0 /*_UVRSD_UINT32*/,
+		val);
+}



CVS commit: src/lib/libexecinfo

2013-04-25 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr 25 14:48:09 UTC 2013

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
When building for earm, make sure to build unwind_arm_ehabi_stub.*


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/Makefile

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

Modified files:

Index: src/lib/libexecinfo/Makefile
diff -u src/lib/libexecinfo/Makefile:1.1 src/lib/libexecinfo/Makefile:1.2
--- src/lib/libexecinfo/Makefile:1.1	Sat May 26 22:02:29 2012
+++ src/lib/libexecinfo/Makefile	Thu Apr 25 14:48:09 2013
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2012/05/26 22:02:29 christos Exp $
+# $NetBSD: Makefile,v 1.2 2013/04/25 14:48:09 matt Exp $
 
 .include bsd.own.mk
 
@@ -19,6 +19,9 @@ MAN= backtrace.3
 
 .if ${USE_UNWIND} == yes
 SRCS+=unwind.c
+.if !empty(MACHINE_ARCH:Mearm)
+SRCS+=unwind_arm_ehabi_stub.c
+.endif
 .else
 SRCS+=builtin.c
 .endif



CVS commit: src/lib/libexecinfo

2013-04-25 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr 25 14:47:30 UTC 2013

Added Files:
src/lib/libexecinfo: unwind_arm_ehabi_stub.c

Log Message:
libgcc/libcompiler_rt inlines some functions needed by libexecinfo when
using ARM EHABI.  Provide uninlined versions for libexecinfo.
from skrll@


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libexecinfo/unwind_arm_ehabi_stub.c

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



CVS commit: src/lib/libexecinfo

2013-04-25 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Thu Apr 25 14:48:09 UTC 2013

Modified Files:
src/lib/libexecinfo: Makefile

Log Message:
When building for earm, make sure to build unwind_arm_ehabi_stub.*


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/Makefile

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



CVS commit: src/lib/libexecinfo

2012-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul  9 03:11:59 UTC 2012

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
fix cleanup on error


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/backtrace.c

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

Modified files:

Index: src/lib/libexecinfo/backtrace.c
diff -u src/lib/libexecinfo/backtrace.c:1.1 src/lib/libexecinfo/backtrace.c:1.2
--- src/lib/libexecinfo/backtrace.c:1.1	Sat May 26 18:02:29 2012
+++ src/lib/libexecinfo/backtrace.c	Sun Jul  8 23:11:59 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: backtrace.c,v 1.1 2012/05/26 22:02:29 christos Exp $	*/
+/*	$NetBSD: backtrace.c,v 1.2 2012/07/09 03:11:59 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.1 2012/05/26 22:02:29 christos Exp $);
+__RCSID($NetBSD: backtrace.c,v 1.2 2012/07/09 03:11:59 christos Exp $);
 
 #include sys/param.h
 #include assert.h
@@ -168,7 +168,7 @@ backtrace_symbols_fmt(void *const *trace
 		st = NULL;
 
 	if ((ptr = calloc(len, slen)) == NULL)
-		return NULL;
+		goto out;
 
 	size_t psize = len * slen;
 	size_t offs = len * sizeof(char *);
@@ -180,7 +180,8 @@ backtrace_symbols_fmt(void *const *trace
 		x = format_address(st, ptr, psize, offs, fmt, trace[i]);
 		if (x == -1) {
 			free(ptr);
-			return NULL;
+			ptr = NULL;
+			goto out;
 		}
 		offs += x;
 		ptr[offs++] = '\0';
@@ -191,6 +192,7 @@ backtrace_symbols_fmt(void *const *trace
 	for (size_t j = 0; j  len; j++)
 		((char **)(void *)ptr)[j] += (intptr_t)ptr;
 
+out:
 	symtab_destroy(st);
 	if (fd != -1)
 		(void)close(fd);



CVS commit: src/lib/libexecinfo

2012-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul  9 03:11:59 UTC 2012

Modified Files:
src/lib/libexecinfo: backtrace.c

Log Message:
fix cleanup on error


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/backtrace.c

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



CVS commit: src/lib/libexecinfo

2012-06-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun  9 21:22:17 UTC 2012

Modified Files:
src/lib/libexecinfo: execinfo.h

Log Message:
PR/46571: Yui NARUSE: execinfo.h should include stddef.h


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/execinfo.h

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

Modified files:

Index: src/lib/libexecinfo/execinfo.h
diff -u src/lib/libexecinfo/execinfo.h:1.1 src/lib/libexecinfo/execinfo.h:1.2
--- src/lib/libexecinfo/execinfo.h:1.1	Sat May 26 18:02:29 2012
+++ src/lib/libexecinfo/execinfo.h	Sat Jun  9 17:22:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: execinfo.h,v 1.1 2012/05/26 22:02:29 christos Exp $	*/
+/*	$NetBSD: execinfo.h,v 1.2 2012/06/09 21:22:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,6 +31,8 @@
 #ifndef _EXECINFO_H_
 #define _EXECINFO_H_
 
+#include stddef.h
+
 __BEGIN_DECLS
 size_t backtrace(void **, size_t);
 char **backtrace_symbols(void *const *, size_t);



CVS commit: src/lib/libexecinfo

2012-06-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun 10 00:24:36 UTC 2012

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
mention .Nx 7.0


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.3 src/lib/libexecinfo/backtrace.3:1.4
--- src/lib/libexecinfo/backtrace.3:1.3	Sun May 27 09:25:28 2012
+++ src/lib/libexecinfo/backtrace.3	Sat Jun  9 20:24:36 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: backtrace.3,v 1.3 2012/05/27 13:25:28 christos Exp $
+.\	$NetBSD: backtrace.3,v 1.4 2012/06/10 00:24:36 christos Exp $
 .\
 .\ Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -133,7 +133,7 @@ Diagnostic output may also be produced b
 The
 .Fn backtrace
 library of functions first appeared in
-.Nx 6 .
+.Nx 7.0 .
 .Sh BUGS
 .Bl -enum
 .It



CVS commit: src/lib/libexecinfo

2012-06-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun  9 21:22:17 UTC 2012

Modified Files:
src/lib/libexecinfo: execinfo.h

Log Message:
PR/46571: Yui NARUSE: execinfo.h should include stddef.h


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/execinfo.h

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



CVS commit: src/lib/libexecinfo

2012-06-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jun 10 00:24:36 UTC 2012

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
mention .Nx 7.0


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libexecinfo/backtrace.3

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



CVS commit: src/lib/libexecinfo

2012-05-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun May 27 12:03:02 UTC 2012

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Sort sections.
Remove dot at end of Nd
Sort SEE ALSO.
Punctuation fixes.
Bump date to import date.
Comment out a partial sentence.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.1 src/lib/libexecinfo/backtrace.3:1.2
--- src/lib/libexecinfo/backtrace.3:1.1	Sat May 26 22:02:29 2012
+++ src/lib/libexecinfo/backtrace.3	Sun May 27 12:03:02 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: backtrace.3,v 1.1 2012/05/26 22:02:29 christos Exp $
+.\	$NetBSD: backtrace.3,v 1.2 2012/05/27 12:03:02 wiz Exp $
 .\
 .\ Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -27,12 +27,12 @@
 .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd January 24, 2012
+.Dd May 26, 2012
 .Dt BACKTRACE 3
 .Os
 .Sh NAME
 .Nm backtrace
-.Nd fill in the backtrace of the currently executing thread.
+.Nd fill in the backtrace of the currently executing thread
 .Sh LIBRARY
 .Lb libexecinfo
 .Sh SYNOPSIS
@@ -61,7 +61,7 @@ is returned.
 .Pp
 The
 .Fn backtrace_symbols_fmt
-function, takes an array of previously filled addresses from
+function takes an array of previously filled addresses from
 .Fn backtrace
 in
 .Fa addrlist
@@ -126,8 +126,17 @@ return a string array on success, and
 on failure, setting
 .Va errno .
 .\ XXX
-Diagnostic output may also be produced, by the ELF symbol lookup functions.
-function returns a pointer to a string that is the parent directory of
+Diagnostic output may also be produced by the ELF symbol lookup functions.
+.\ XXX: what's this?
+.\ function returns a pointer to a string that is the parent directory of
+.Sh SEE ALSO
+.Xr dladdr 3 ,
+.Xr elf 3
+.Sh HISTORY
+The
+.Fn backtrace
+library of functions first appeared in
+.Nx 6 .
 .Sh BUGS
 .Bl -enum
 .It
@@ -135,10 +144,10 @@ Errors should not be printed but communi
 .It
 Because these functions use
 .Xr elf 3
-this is a separate library instead of be part of libc/libutil so that library
-dependencies are not introduced.
+this is a separate library instead of being part of libc/libutil
+so that no library dependencies are introduced.
 .It
-The linux versions of the functions (there are no _fmt variants), use
+The Linux versions of the functions (there are no _fmt variants) use
 .Ft int
 instead of
 .Ft size_t
@@ -148,14 +157,6 @@ Since
 .Xr dladdr 3
 only deals with dynamic symbols, we need to find the symbols from the main
 portion of the program.
-For that we need to locate the executable, and we use procfs for to find it
-which is not portable.
+For that we need to locate the executable, and we use procfs for
+finding it, which is not portable.
 .El
-.Sh SEE ALSO
-.Xr elf 3
-.Xr dladdr 3
-.Sh HISTORY
-The
-.Fn backtrace
-library of functions first appeared in
-.Nx 6 .



CVS commit: src/lib/libexecinfo

2012-05-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 27 13:25:28 UTC 2012

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
remove unrelated fragment.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/backtrace.3

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

Modified files:

Index: src/lib/libexecinfo/backtrace.3
diff -u src/lib/libexecinfo/backtrace.3:1.2 src/lib/libexecinfo/backtrace.3:1.3
--- src/lib/libexecinfo/backtrace.3:1.2	Sun May 27 08:03:02 2012
+++ src/lib/libexecinfo/backtrace.3	Sun May 27 09:25:28 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: backtrace.3,v 1.2 2012/05/27 12:03:02 wiz Exp $
+.\	$NetBSD: backtrace.3,v 1.3 2012/05/27 13:25:28 christos Exp $
 .\
 .\ Copyright (c) 2012 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -125,10 +125,7 @@ return a string array on success, and
 .Dv NULL
 on failure, setting
 .Va errno .
-.\ XXX
 Diagnostic output may also be produced by the ELF symbol lookup functions.
-.\ XXX: what's this?
-.\ function returns a pointer to a string that is the parent directory of
 .Sh SEE ALSO
 .Xr dladdr 3 ,
 .Xr elf 3



CVS commit: src/lib/libexecinfo

2012-05-27 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun May 27 12:03:02 UTC 2012

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
Sort sections.
Remove dot at end of Nd
Sort SEE ALSO.
Punctuation fixes.
Bump date to import date.
Comment out a partial sentence.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/lib/libexecinfo/backtrace.3

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



CVS commit: src/lib/libexecinfo

2012-05-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 27 13:25:28 UTC 2012

Modified Files:
src/lib/libexecinfo: backtrace.3

Log Message:
remove unrelated fragment.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/lib/libexecinfo/backtrace.3

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



CVS commit: src/lib/libexecinfo

2012-05-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 26 22:02:29 UTC 2012

Added Files:
src/lib/libexecinfo: Makefile backtrace.3 backtrace.c builtin.c
execinfo.h shlib_version symtab.c symtab.h unwind.c unwind.h

Log Message:
Add a similar to linux backtrace_* and execinfo.h family of functions


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libexecinfo/Makefile \
src/lib/libexecinfo/backtrace.3 src/lib/libexecinfo/backtrace.c \
src/lib/libexecinfo/builtin.c src/lib/libexecinfo/execinfo.h \
src/lib/libexecinfo/shlib_version src/lib/libexecinfo/symtab.c \
src/lib/libexecinfo/symtab.h src/lib/libexecinfo/unwind.c \
src/lib/libexecinfo/unwind.h

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

Added files:

Index: src/lib/libexecinfo/Makefile
diff -u /dev/null src/lib/libexecinfo/Makefile:1.1
--- /dev/null	Sat May 26 18:02:29 2012
+++ src/lib/libexecinfo/Makefile	Sat May 26 18:02:29 2012
@@ -0,0 +1,31 @@
+# $NetBSD: Makefile,v 1.1 2012/05/26 22:02:29 christos Exp $
+
+.include bsd.own.mk
+
+USE_UNWIND=yes
+WARNS?=4
+INCSDIR=/usr/include
+INCS=execinfo.h
+
+#CPPFLAGS+='-D__RCSID(a)=' -D_GNU_SOURCE '-D__printflike(a,b)='
+#CPPFLAGS+=-I/usr/include/libelf
+#COPTS+=-std=gnu99
+
+LIBDPLIBS+= elf	${NETBSDSRCDIR}/external/bsd/libelf/lib
+
+LIB=execinfo
+SRCS=symtab.c backtrace.c
+MAN= backtrace.3
+
+.if ${USE_UNWIND} == yes
+SRCS+=unwind.c
+.else
+SRCS+=builtin.c
+.endif
+
+MLINKS+= backtrace.3 backtrace_symbols.3
+MLINKS+= backtrace.3 backtrace_symbols_fmt.3
+MLINKS+= backtrace.3 backtrace_symbols_fd.3
+MLINKS+= backtrace.3 backtrace_symbols_fd_fmt.3
+
+.include bsd.lib.mk
Index: src/lib/libexecinfo/backtrace.3
diff -u /dev/null src/lib/libexecinfo/backtrace.3:1.1
--- /dev/null	Sat May 26 18:02:29 2012
+++ src/lib/libexecinfo/backtrace.3	Sat May 26 18:02:29 2012
@@ -0,0 +1,161 @@
+.\	$NetBSD: backtrace.3,v 1.1 2012/05/26 22:02:29 christos Exp $
+.\
+.\ Copyright (c) 2012 The NetBSD Foundation, Inc.
+.\ All rights reserved.
+.\
+.\ This code is derived from software contributed to The NetBSD Foundation
+.\ by Christos Zoulas
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\ PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\ POSSIBILITY OF SUCH DAMAGE.
+.\
+.Dd January 24, 2012
+.Dt BACKTRACE 3
+.Os
+.Sh NAME
+.Nm backtrace
+.Nd fill in the backtrace of the currently executing thread.
+.Sh LIBRARY
+.Lb libexecinfo
+.Sh SYNOPSIS
+.In execinfo.h
+.Ft size_t
+.Fn backtrace void **addrlist size_t len
+.Ft char **
+.Fn backtrace_symbols void * const *addrlist size_t len
+.Ft int
+.Fn backtrace_symbols_fd void * const *addrlist size_t len int fd
+.Ft char **
+.Fn backtrace_symbols_fmt void * const *addrlist size_t len const char *fmt
+.Ft int
+.Fn backtrace_symbols_fmt_fd void * const *addrlist size_t len const char *fmt int fd
+.Sh DESCRIPTION
+The
+.Fn backtrace
+function places into the array pointed by
+.Fa addrlist
+the array of the values of the program counter for each frame called up to
+.Fa len
+frames.
+The number of frames found (which can be fewer than
+.Fa len )
+is returned.
+.Pp
+The
+.Fn backtrace_symbols_fmt
+function, takes an array of previously filled addresses from
+.Fn backtrace
+in
+.Fa addrlist
+of
+.Fa len
+elements, and uses
+.Fa fmt
+to format them.
+The formatting characters available are:
+.Bl -tag -width a -offset indent
+.It Dv a
+The numeric address of each element as would be printed using %p.
+.It Dv n
+The name of the nearest function symbol (smaller than the address element)
+as determined by
+.Xr dladdr 3
+if the symbol was dynamic, or looked up in the executable if static and
+the /proc filesystem is available to determine the executable path.
+.It Dv d
+The difference