CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: christos Date: Wed Sep 9 20:04:10 UTC 2020 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: PR/55648: Kyle Evans: Minor warnings in compilation of libexecinfo test2 To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.16 src/tests/lib/libexecinfo/t_backtrace.c:1.17 --- src/tests/lib/libexecinfo/t_backtrace.c:1.16 Mon Nov 3 19:20:19 2014 +++ src/tests/lib/libexecinfo/t_backtrace.c Wed Sep 9 16:04:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.16 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.17 2020/09/09 20:04:10 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.16 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.17 2020/09/09 20:04:10 christos Exp $"); #include #include @@ -47,7 +47,7 @@ void myfunc2(size_t ncalls); void myfunc1(size_t origcalls, volatile size_t ncalls); void myfunc(size_t ncalls); -volatile int prevent_inline; +static volatile int prevent_inline; void myfunc3(size_t ncalls)
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: nakayama Date: Sat Jan 31 20:55:43 UTC 2015 Modified Files: src/tests/lib/libexecinfo: Makefile Log Message: The test requires symbols, so put STRIPFLAG= explicitly to avoid stripping them if STRIPFLAG?=-s is defined in /etc/mk.conf. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/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/tests/lib/libexecinfo/Makefile diff -u src/tests/lib/libexecinfo/Makefile:1.5 src/tests/lib/libexecinfo/Makefile:1.6 --- src/tests/lib/libexecinfo/Makefile:1.5 Tue Mar 18 18:20:44 2014 +++ src/tests/lib/libexecinfo/Makefile Sat Jan 31 20:55:43 2015 @@ -1,10 +1,11 @@ -# $NetBSD: Makefile,v 1.5 2014/03/18 18:20:44 riastradh Exp $ +# $NetBSD: Makefile,v 1.6 2015/01/31 20:55:43 nakayama Exp $ .include TESTSDIR= ${TESTSBASE}/lib/libexecinfo TESTS_C+= t_backtrace +STRIPFLAG= LDADD+= -lexecinfo -lelf DPADD+= ${LIBEXECINFO} ${LIBELF}
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: joerg Date: Thu May 1 03:46:11 UTC 2014 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Check for mounted /proc. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.14 src/tests/lib/libexecinfo/t_backtrace.c:1.15 --- src/tests/lib/libexecinfo/t_backtrace.c:1.14 Sun Apr 13 20:58:26 2014 +++ src/tests/lib/libexecinfo/t_backtrace.c Thu May 1 03:46:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.14 2014/04/13 20:58:26 joerg Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.15 2014/05/01 03:46:11 joerg Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.14 2014/04/13 20:58:26 joerg Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.15 2014/05/01 03:46:11 joerg Exp $"); #include #include @@ -147,7 +147,8 @@ myfunc(size_t ncalls) ATF_TC(backtrace_fmt_basic); ATF_TC_HEAD(backtrace_fmt_basic, tc) { -atf_tc_set_md_var(tc, "descr", "Test backtrace_fmt(3)"); + atf_tc_set_md_var(tc, "descr", "Test backtrace_fmt(3)"); + atf_tc_set_md_var(tc, "require.files", "/proc/self"); } ATF_TC_BODY(backtrace_fmt_basic, tc)
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: joerg Date: Sun Apr 13 20:58:26 UTC 2014 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Bail out if backtrace(3) failed. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.13 src/tests/lib/libexecinfo/t_backtrace.c:1.14 --- src/tests/lib/libexecinfo/t_backtrace.c:1.13 Tue Mar 11 13:43:23 2014 +++ src/tests/lib/libexecinfo/t_backtrace.c Sun Apr 13 20:58:26 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.13 2014/03/11 13:43:23 joerg Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.14 2014/04/13 20:58:26 joerg Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.13 2014/03/11 13:43:23 joerg Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.14 2014/04/13 20:58:26 joerg Exp $"); #include #include @@ -79,6 +79,7 @@ myfunc3(size_t ncalls) ++max_frames; } nptrs = backtrace(buffer, __arraycount(buffer)); + ATF_REQUIRE(nptrs != (size_t)-1); strings = backtrace_symbols_fmt(buffer, nptrs, "%n"); ATF_CHECK(strings != NULL);
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: joerg Date: Tue Mar 11 13:43:23 UTC 2014 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Use a struct for pair of frame name and whether it is optional. Add some additional entries found in a -O0 build of ATF on PowerPC. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.12 src/tests/lib/libexecinfo/t_backtrace.c:1.13 --- src/tests/lib/libexecinfo/t_backtrace.c:1.12 Sat Jan 11 19:48:22 2014 +++ src/tests/lib/libexecinfo/t_backtrace.c Tue Mar 11 13:43:23 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.12 2014/01/11 19:48:22 martin Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.13 2014/03/11 13:43:23 joerg Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.12 2014/01/11 19:48:22 martin Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.13 2014/03/11 13:43:23 joerg Exp $"); #include #include @@ -53,19 +53,28 @@ volatile int prevent_inline; 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, - true, true }; + static const struct { + const char *name; + bool is_optional; + } frames[] = { + { "myfunc", false }, + { "atfu_backtrace_fmt_basic_body", false }, + { "atf_tc_run", false }, + { "atf_tp_run", true }, + { "run_tc", true }, + { "controlled_main", true }, + { "atf_tp_main", false }, + { "main", true }, + { "___start", true }, + }; size_t j, nptrs, min_frames, max_frames; void *buffer[ncalls + 10]; char **strings; - __CTASSERT(__arraycount(top) == __arraycount(optional_frame)); min_frames = 0; max_frames = 0; - for (j = 0; j < __arraycount(optional_frame); ++j) { - if (!optional_frame[j]) + for (j = 0; j < __arraycount(frames); ++j) { + if (!frames[j].is_optional) ++min_frames; ++max_frames; } @@ -90,11 +99,12 @@ myfunc3(size_t ncalls) ATF_CHECK_STREQ(strings[j], "myfunc1"); for (size_t i = 0; j < nptrs; i++, j++) { - if (optional_frame[i] && strcmp(strings[j], top[i])) { + if (frames[i].is_optional && + strcmp(strings[j], frames[i].name)) { --i; continue; } - ATF_CHECK_STREQ(strings[j], top[i]); + ATF_CHECK_STREQ(strings[j], frames[i].name); } free(strings);
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: martin Date: Sat Jan 11 19:48:22 UTC 2014 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: New gcc can reuse stack frames for tail calls, so "main" is an optional frame as well. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.11 src/tests/lib/libexecinfo/t_backtrace.c:1.12 --- src/tests/lib/libexecinfo/t_backtrace.c:1.11 Sat Jan 11 19:13:41 2014 +++ src/tests/lib/libexecinfo/t_backtrace.c Sat Jan 11 19:48:22 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.11 2014/01/11 19:13:41 martin Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.12 2014/01/11 19:48:22 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.11 2014/01/11 19:13:41 martin Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.12 2014/01/11 19:48:22 martin Exp $"); #include #include @@ -56,7 +56,7 @@ 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, true }; + true, true }; size_t j, nptrs, min_frames, max_frames; void *buffer[ncalls + 10]; char **strings;
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: martin Date: Sat Jan 11 19:13:41 UTC 2014 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Make the output of the test case better suited for debugging (output full backtrace before failing any unclear asserts) To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.10 src/tests/lib/libexecinfo/t_backtrace.c:1.11 --- src/tests/lib/libexecinfo/t_backtrace.c:1.10 Fri Aug 16 11:57:15 2013 +++ src/tests/lib/libexecinfo/t_backtrace.c Sat Jan 11 19:13:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.10 2013/08/16 11:57:15 martin Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.11 2014/01/11 19:13:41 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,11 +29,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.10 2013/08/16 11:57:15 martin Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.11 2014/01/11 19:13:41 martin Exp $"); #include #include #include +#include #include #include #include @@ -69,12 +70,19 @@ myfunc3(size_t ncalls) ++max_frames; } nptrs = backtrace(buffer, __arraycount(buffer)); - ATF_REQUIRE(nptrs >= ncalls + 2 + min_frames); - ATF_REQUIRE(nptrs <= ncalls + 2 + max_frames); - strings = backtrace_symbols_fmt(buffer, nptrs, "%n"); ATF_CHECK(strings != NULL); + + printf("got nptrs=%zu ncalls=%zu (min_frames: %zu, max_frames: %zu)\n", + nptrs, ncalls, min_frames, max_frames); + printf("backtrace is:\n"); + for (j = 0; j < nptrs; j++) { + printf("#%zu: %s\n", j, strings[j]); + } + + ATF_REQUIRE(nptrs >= ncalls + 2 + min_frames); + ATF_REQUIRE(nptrs <= ncalls + 2 + max_frames); ATF_CHECK_STREQ(strings[0], "myfunc3"); ATF_CHECK_STREQ(strings[1], "myfunc2");
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: martin Date: Fri Aug 16 11:57:15 UTC 2013 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Prevent inlining of the main testcase body function. Do not mark the inner functions static, as they might get cloned then (ending up being called "myfunc3.clone.3" instead of "myfunc"). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.9 src/tests/lib/libexecinfo/t_backtrace.c:1.10 --- src/tests/lib/libexecinfo/t_backtrace.c:1.9 Thu Aug 15 12:42:25 2013 +++ src/tests/lib/libexecinfo/t_backtrace.c Fri Aug 16 11:57:15 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.9 2013/08/15 12:42:25 joerg Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.10 2013/08/16 11:57:15 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.9 2013/08/15 12:42:25 joerg Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.10 2013/08/16 11:57:15 martin Exp $"); #include #include @@ -42,9 +42,14 @@ __RCSID("$NetBSD: t_backtrace.c,v 1.9 20 #define __arraycount(a) (sizeof(a) / sizeof(a[0])) #endif +void myfunc3(size_t ncalls); +void myfunc2(size_t ncalls); +void myfunc1(size_t origcalls, volatile size_t ncalls); +void myfunc(size_t ncalls); + volatile int prevent_inline; -static void +void myfunc3(size_t ncalls) { static const char *top[] = { "myfunc", "atfu_backtrace_fmt_basic_body", @@ -90,7 +95,7 @@ myfunc3(size_t ncalls) vfork(); } -static void +void myfunc2(size_t ncalls) { myfunc3(ncalls); @@ -99,7 +104,7 @@ myfunc2(size_t ncalls) vfork(); } -static void +void myfunc1(size_t origcalls, volatile size_t ncalls) { if (ncalls > 1) @@ -111,7 +116,7 @@ myfunc1(size_t origcalls, volatile size_ vfork(); } -static void +void myfunc(size_t ncalls) { myfunc1(ncalls, ncalls); @@ -129,6 +134,9 @@ ATF_TC_HEAD(backtrace_fmt_basic, tc) ATF_TC_BODY(backtrace_fmt_basic, tc) { myfunc(12); + + if (prevent_inline) + vfork(); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: joerg Date: Thu Aug 15 12:42:25 UTC 2013 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Now that all architectures default to unwind data, remove the failure for !amd64. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.8 src/tests/lib/libexecinfo/t_backtrace.c:1.9 --- src/tests/lib/libexecinfo/t_backtrace.c:1.8 Fri Jul 5 09:55:39 2013 +++ src/tests/lib/libexecinfo/t_backtrace.c Thu Aug 15 12:42:25 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.8 2013/07/05 09:55:39 joerg Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.9 2013/08/15 12:42:25 joerg Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.8 2013/07/05 09:55:39 joerg Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.9 2013/08/15 12:42:25 joerg Exp $"); #include #include @@ -128,12 +128,6 @@ ATF_TC_HEAD(backtrace_fmt_basic, tc) ATF_TC_BODY(backtrace_fmt_basic, tc) { - const char *arch = atf_config_get("atf_arch"); - -if (strcmp(arch, "x86_64") != 0) - atf_tc_skip("PR toolchain/46490: libexecinfo only" - " works on amd64 currently"); - myfunc(12); }
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: tron Date: Sun Jul 21 15:29:04 UTC 2013 Modified Files: src/tests/lib/libexecinfo: Makefile Log Message: Fix build with stack-protection enabled. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/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/tests/lib/libexecinfo/Makefile diff -u src/tests/lib/libexecinfo/Makefile:1.3 src/tests/lib/libexecinfo/Makefile:1.4 --- src/tests/lib/libexecinfo/Makefile:1.3 Thu Jul 4 23:53:13 2013 +++ src/tests/lib/libexecinfo/Makefile Sun Jul 21 15:29:04 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.3 2013/07/04 23:53:13 joerg Exp $ +# $NetBSD: Makefile,v 1.4 2013/07/21 15:29:04 tron Exp $ .include @@ -9,4 +9,6 @@ TESTS_C+= t_backtrace LDADD+= -lexecinfo -lelf DPADD+= ${LIBEXECINFO} ${LIBELF} +COPTS.t_backtrace.c= -Wno-stack-protector + .include
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: joerg Date: Fri Jul 5 09:55:39 UTC 2013 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Put the vfork at the end. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.7 src/tests/lib/libexecinfo/t_backtrace.c:1.8 --- src/tests/lib/libexecinfo/t_backtrace.c:1.7 Thu Jul 4 23:53:13 2013 +++ src/tests/lib/libexecinfo/t_backtrace.c Fri Jul 5 09:55:39 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.7 2013/07/04 23:53:13 joerg Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.8 2013/07/05 09:55:39 joerg Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.7 2013/07/04 23:53:13 joerg Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.8 2013/07/05 09:55:39 joerg Exp $"); #include #include @@ -56,9 +56,6 @@ myfunc3(size_t ncalls) 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) { @@ -88,36 +85,39 @@ myfunc3(size_t ncalls) } free(strings); + + if (prevent_inline) + vfork(); } static void myfunc2(size_t ncalls) { + myfunc3(ncalls); + if (prevent_inline) vfork(); - - myfunc3(ncalls); } static void -myfunc1(size_t origcalls, size_t ncalls) +myfunc1(size_t origcalls, volatile size_t ncalls) { - if (prevent_inline) - vfork(); - if (ncalls > 1) myfunc1(origcalls, ncalls - 1); else myfunc2(origcalls); + + if (prevent_inline) + vfork(); } static void myfunc(size_t ncalls) { + myfunc1(ncalls, ncalls); + if (prevent_inline) vfork(); - - myfunc1(ncalls, ncalls); } ATF_TC(backtrace_fmt_basic);
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: joerg Date: Thu Jul 4 23:53:13 UTC 2013 Modified Files: src/tests/lib/libexecinfo: Makefile t_backtrace.c Log Message: Use conditional calls to vfork() to prevent the compiler from inlining the intermediate stack frames. Mark the __start frame as optional. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libexecinfo/Makefile cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/Makefile diff -u src/tests/lib/libexecinfo/Makefile:1.2 src/tests/lib/libexecinfo/Makefile:1.3 --- src/tests/lib/libexecinfo/Makefile:1.2 Sun May 27 22:57:24 2012 +++ src/tests/lib/libexecinfo/Makefile Thu Jul 4 23:53:13 2013 @@ -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 @@ -8,6 +8,5 @@ TESTS_C+= t_backtrace LDADD+= -lexecinfo -lelf DPADD+= ${LIBEXECINFO} ${LIBELF} -DBG=-O0 # prevent inlining, nothing else helps. .include Index: src/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.6 src/tests/lib/libexecinfo/t_backtrace.c:1.7 --- src/tests/lib/libexecinfo/t_backtrace.c:1.6 Thu Jun 6 17:40:09 2013 +++ src/tests/lib/libexecinfo/t_backtrace.c Thu Jul 4 23:53:13 2013 @@ -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 -__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 #include #include #include #include +#include #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 @@ myfunc3(size_t ncalls) 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); }
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: joerg Date: Thu Jun 6 17:40:09 UTC 2013 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Make back trace more robust. At least on i386, one of the intermediate functions in ATF is not replaced by tail recursion elimination, so mark it as optional. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.5 src/tests/lib/libexecinfo/t_backtrace.c:1.6 --- src/tests/lib/libexecinfo/t_backtrace.c:1.5 Sat Jun 2 14:52:28 2012 +++ src/tests/lib/libexecinfo/t_backtrace.c Thu Jun 6 17:40:09 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.5 2012/06/02 14:52:28 njoly Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.6 2013/06/06 17:40:09 joerg Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.5 2012/06/02 14:52:28 njoly Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.6 2013/06/06 17:40:09 joerg Exp $"); #include #include @@ -45,13 +45,23 @@ static void __attribute__((__noinline__) myfunc3(size_t ncalls) { static const char *top[] = { "myfunc", "atfu_backtrace_fmt_basic_body", - "atf_tc_run", "atf_tp_main", "main", "___start" }; - size_t j, nptrs; + "atf_tc_run", "atf_tp_run", "atf_tp_main", "main", "___start" }; + static bool optional_frame[] = { false, false, false, true, false, false, false }; + size_t j, nptrs, min_frames, max_frames; void *buffer[ncalls + 10]; char **strings; + __CTASSERT(__arraycount(top) == __arraycount(optional_frame)); + min_frames = 0; + max_frames = 0; + for (j = 0; j < __arraycount(optional_frame); ++j) { + if (!optional_frame[j]) + ++min_frames; + ++max_frames; + } nptrs = backtrace(buffer, __arraycount(buffer)); - ATF_REQUIRE_EQ(nptrs, ncalls + 8); + ATF_REQUIRE(nptrs >= ncalls + 2 + min_frames); + ATF_REQUIRE(nptrs <= ncalls + 2 + max_frames); strings = backtrace_symbols_fmt(buffer, nptrs, "%n"); @@ -62,8 +72,13 @@ myfunc3(size_t ncalls) for (j = 2; j < ncalls + 2; j++) ATF_CHECK_STREQ(strings[j], "myfunc1"); - for (size_t i = 0; j < nptrs; i++, j++) + for (size_t i = 0; j < nptrs; i++, j++) { + if (optional_frame[i] && strcmp(strings[j], top[i])) { + --i; + continue; + } ATF_CHECK_STREQ(strings[j], top[i]); + } free(strings); }
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: njoly Date: Sat Jun 2 14:52:28 UTC 2012 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Adjust test for recent atf_machine (amd64) -> atf_arch (x86_64) change. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.4 src/tests/lib/libexecinfo/t_backtrace.c:1.5 --- src/tests/lib/libexecinfo/t_backtrace.c:1.4 Wed May 30 15:11:58 2012 +++ src/tests/lib/libexecinfo/t_backtrace.c Sat Jun 2 14:52:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.4 2012/05/30 15:11:58 jruoho Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.5 2012/06/02 14:52:28 njoly Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.4 2012/05/30 15:11:58 jruoho Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.5 2012/06/02 14:52:28 njoly Exp $"); #include #include @@ -99,7 +99,7 @@ ATF_TC_BODY(backtrace_fmt_basic, tc) { const char *arch = atf_config_get("atf_arch"); -if (strcmp(arch, "amd64") != 0) +if (strcmp(arch, "x86_64") != 0) atf_tc_skip("PR toolchain/46490: libexecinfo only" " works on amd64 currently");
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: jruoho Date: Wed May 30 15:11:58 UTC 2012 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Use "atf_arch" instead of "atf_machine"; see atf-config(1). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.3 src/tests/lib/libexecinfo/t_backtrace.c:1.4 --- src/tests/lib/libexecinfo/t_backtrace.c:1.3 Wed May 30 06:01:22 2012 +++ src/tests/lib/libexecinfo/t_backtrace.c Wed May 30 15:11:58 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.3 2012/05/30 06:01:22 martin Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.4 2012/05/30 15:11:58 jruoho Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.3 2012/05/30 06:01:22 martin Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.4 2012/05/30 15:11:58 jruoho Exp $"); #include #include @@ -97,7 +97,7 @@ ATF_TC_HEAD(backtrace_fmt_basic, tc) ATF_TC_BODY(backtrace_fmt_basic, tc) { - const char *arch = atf_config_get("atf_machine"); + const char *arch = atf_config_get("atf_arch"); if (strcmp(arch, "amd64") != 0) atf_tc_skip("PR toolchain/46490: libexecinfo only"
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: martin Date: Wed May 30 06:01:22 UTC 2012 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Skip test on non-amd64 machines for now, pointing to PR 46490. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.2 src/tests/lib/libexecinfo/t_backtrace.c:1.3 --- src/tests/lib/libexecinfo/t_backtrace.c:1.2 Mon May 28 09:51:34 2012 +++ src/tests/lib/libexecinfo/t_backtrace.c Wed May 30 06:01:22 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.2 2012/05/28 09:51:34 martin Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.3 2012/05/30 06:01:22 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,9 +29,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.2 2012/05/28 09:51:34 martin Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.3 2012/05/30 06:01:22 martin Exp $"); #include +#include #include #include #include @@ -96,6 +97,12 @@ ATF_TC_HEAD(backtrace_fmt_basic, tc) ATF_TC_BODY(backtrace_fmt_basic, tc) { + const char *arch = atf_config_get("atf_machine"); + +if (strcmp(arch, "amd64") != 0) + atf_tc_skip("PR toolchain/46490: libexecinfo only" + " works on amd64 currently"); + myfunc(12); }
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: martin Date: Mon May 28 09:51:34 UTC 2012 Modified Files: src/tests/lib/libexecinfo: t_backtrace.c Log Message: Not a good idea to continue testing if basic assertions fail - only will cause core dumps later. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libexecinfo/t_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/tests/lib/libexecinfo/t_backtrace.c diff -u src/tests/lib/libexecinfo/t_backtrace.c:1.1 src/tests/lib/libexecinfo/t_backtrace.c:1.2 --- src/tests/lib/libexecinfo/t_backtrace.c:1.1 Sun May 27 18:47:18 2012 +++ src/tests/lib/libexecinfo/t_backtrace.c Mon May 28 09:51:34 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_backtrace.c,v 1.1 2012/05/27 18:47:18 christos Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.2 2012/05/28 09:51:34 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_backtrace.c,v 1.1 2012/05/27 18:47:18 christos Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.2 2012/05/28 09:51:34 martin Exp $"); #include #include @@ -50,7 +50,7 @@ myfunc3(size_t ncalls) char **strings; nptrs = backtrace(buffer, __arraycount(buffer)); - ATF_CHECK_EQ(nptrs, ncalls + 8); + ATF_REQUIRE_EQ(nptrs, ncalls + 8); strings = backtrace_symbols_fmt(buffer, nptrs, "%n");
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: martin Date: Sun May 27 22:57:24 UTC 2012 Modified Files: src/tests/lib/libexecinfo: Makefile Log Message: Fix destination directory To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/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/tests/lib/libexecinfo/Makefile diff -u src/tests/lib/libexecinfo/Makefile:1.1 src/tests/lib/libexecinfo/Makefile:1.2 --- src/tests/lib/libexecinfo/Makefile:1.1 Sun May 27 18:47:18 2012 +++ src/tests/lib/libexecinfo/Makefile Sun May 27 22:57:24 2012 @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.1 2012/05/27 18:47:18 christos Exp $ +# $NetBSD: Makefile,v 1.2 2012/05/27 22:57:24 martin Exp $ .include -TESTSDIR= ${TESTSBASE}/lib/libm +TESTSDIR= ${TESTSBASE}/lib/libexecinfo TESTS_C+= t_backtrace
CVS commit: src/tests/lib/libexecinfo
Module Name:src Committed By: christos Date: Sun May 27 18:47:18 UTC 2012 Added Files: src/tests/lib/libexecinfo: Makefile t_backtrace.c Log Message: add a test for the backtrace function. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/tests/lib/libexecinfo/Makefile \ src/tests/lib/libexecinfo/t_backtrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/tests/lib/libexecinfo/Makefile diff -u /dev/null src/tests/lib/libexecinfo/Makefile:1.1 --- /dev/null Sun May 27 14:47:18 2012 +++ src/tests/lib/libexecinfo/Makefile Sun May 27 14:47:18 2012 @@ -0,0 +1,13 @@ +# $NetBSD: Makefile,v 1.1 2012/05/27 18:47:18 christos Exp $ + +.include + +TESTSDIR= ${TESTSBASE}/lib/libm + +TESTS_C+= t_backtrace + +LDADD+= -lexecinfo -lelf +DPADD+= ${LIBEXECINFO} ${LIBELF} +DBG=-O0 # prevent inlining, nothing else helps. + +.include Index: src/tests/lib/libexecinfo/t_backtrace.c diff -u /dev/null src/tests/lib/libexecinfo/t_backtrace.c:1.1 --- /dev/null Sun May 27 14:47:18 2012 +++ src/tests/lib/libexecinfo/t_backtrace.c Sun May 27 14:47:18 2012 @@ -0,0 +1,108 @@ +/* $NetBSD: t_backtrace.c,v 1.1 2012/05/27 18:47:18 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. + */ +#include +__RCSID("$NetBSD: t_backtrace.c,v 1.1 2012/05/27 18:47:18 christos Exp $"); + +#include +#include +#include +#include + +#ifndef __arraycount +#define __arraycount(a) (sizeof(a) / sizeof(a[0])) +#endif + +static void __attribute__((__noinline__)) +myfunc3(size_t ncalls) +{ + static const char *top[] = { "myfunc", "atfu_backtrace_fmt_basic_body", + "atf_tc_run", "atf_tp_main", "main", "___start" }; + size_t j, nptrs; + void *buffer[ncalls + 10]; + char **strings; + + nptrs = backtrace(buffer, __arraycount(buffer)); + ATF_CHECK_EQ(nptrs, ncalls + 8); + + strings = backtrace_symbols_fmt(buffer, nptrs, "%n"); + + ATF_CHECK(strings != NULL); + ATF_CHECK_STREQ(strings[0], "myfunc3"); + ATF_CHECK_STREQ(strings[1], "myfunc2"); + + for (j = 2; j < ncalls + 2; j++) + ATF_CHECK_STREQ(strings[j], "myfunc1"); + + for (size_t i = 0; j < nptrs; i++, j++) + ATF_CHECK_STREQ(strings[j], top[i]); + + free(strings); +} + +static void __attribute__((__noinline__)) +myfunc2(size_t ncalls) +{ + myfunc3(ncalls); +} + +static void __attribute__((__noinline__)) +myfunc1(size_t origcalls, size_t ncalls) +{ + if (ncalls > 1) + myfunc1(origcalls, ncalls - 1); + else + myfunc2(origcalls); +} + +static void __attribute__((__noinline__)) +myfunc(size_t ncalls) +{ + myfunc1(ncalls, ncalls); +} + +ATF_TC(backtrace_fmt_basic); +ATF_TC_HEAD(backtrace_fmt_basic, tc) +{ +atf_tc_set_md_var(tc, "descr", "Test backtrace_fmt(3)"); +} + +ATF_TC_BODY(backtrace_fmt_basic, tc) +{ + myfunc(12); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, backtrace_fmt_basic); + + return atf_no_error(); +}