Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libexecinfo Use conditional calls to vfork() to pr...
details: https://anonhg.NetBSD.org/src/rev/28b1d80f4c5e
branches: trunk
changeset: 787820:28b1d80f4c5e
user: joerg <joerg%NetBSD.org@localhost>
date: Thu Jul 04 23:53:13 2013 +0000
description:
Use conditional calls to vfork() to prevent the compiler from inlining
the intermediate stack frames. Mark the __start frame as optional.
diffstat:
tests/lib/libexecinfo/Makefile | 3 +--
tests/lib/libexecinfo/t_backtrace.c | 30 +++++++++++++++++++++++-------
2 files changed, 24 insertions(+), 9 deletions(-)
diffs (102 lines):
diff -r 21f9f9133b29 -r 28b1d80f4c5e tests/lib/libexecinfo/Makefile
--- a/tests/lib/libexecinfo/Makefile Thu Jul 04 23:00:23 2013 +0000
+++ b/tests/lib/libexecinfo/Makefile Thu Jul 04 23:53:13 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2012/05/27 22:57:24 martin Exp $
+# $NetBSD: Makefile,v 1.3 2013/07/04 23:53:13 joerg Exp $
.include <bsd.own.mk>
@@ -8,6 +8,5 @@
LDADD+= -lexecinfo -lelf
DPADD+= ${LIBEXECINFO} ${LIBELF}
-DBG=-O0 # prevent inlining, nothing else helps.
.include <bsd.test.mk>
diff -r 21f9f9133b29 -r 28b1d80f4c5e tests/lib/libexecinfo/t_backtrace.c
--- a/tests/lib/libexecinfo/t_backtrace.c Thu Jul 04 23:00:23 2013 +0000
+++ b/tests/lib/libexecinfo/t_backtrace.c Thu Jul 04 23:53:13 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_backtrace.c,v 1.6 2013/06/06 17:40:09 joerg Exp $ */
+/* $NetBSD: t_backtrace.c,v 1.7 2013/07/04 23:53:13 joerg Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,29 +29,36 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_backtrace.c,v 1.6 2013/06/06 17:40:09 joerg Exp $");
+__RCSID("$NetBSD: t_backtrace.c,v 1.7 2013/07/04 23:53:13 joerg Exp $");
#include <atf-c.h>
#include <atf-c/config.h>
#include <string.h>
#include <stdlib.h>
#include <execinfo.h>
+#include <unistd.h>
#ifndef __arraycount
#define __arraycount(a) (sizeof(a) / sizeof(a[0]))
#endif
-static void __attribute__((__noinline__))
+volatile int prevent_inline;
+
+static void
myfunc3(size_t ncalls)
{
static const char *top[] = { "myfunc", "atfu_backtrace_fmt_basic_body",
"atf_tc_run", "atf_tp_run", "atf_tp_main", "main", "___start" };
- static bool optional_frame[] = { false, false, false, true, false, false, false };
+ static bool optional_frame[] = { false, false, false, true, false,
+ false, true };
size_t j, nptrs, min_frames, max_frames;
void *buffer[ncalls + 10];
char **strings;
__CTASSERT(__arraycount(top) == __arraycount(optional_frame));
+ if (prevent_inline)
+ vfork();
+
min_frames = 0;
max_frames = 0;
for (j = 0; j < __arraycount(optional_frame); ++j) {
@@ -83,24 +90,33 @@
free(strings);
}
-static void __attribute__((__noinline__))
+static void
myfunc2(size_t ncalls)
{
+ if (prevent_inline)
+ vfork();
+
myfunc3(ncalls);
}
-static void __attribute__((__noinline__))
+static void
myfunc1(size_t origcalls, size_t ncalls)
{
+ if (prevent_inline)
+ vfork();
+
if (ncalls > 1)
myfunc1(origcalls, ncalls - 1);
else
myfunc2(origcalls);
}
-static void __attribute__((__noinline__))
+static void
myfunc(size_t ncalls)
{
+ if (prevent_inline)
+ vfork();
+
myfunc1(ncalls, ncalls);
}
Home |
Main Index |
Thread Index |
Old Index