[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] [PATCH 22/27] test-resume-sig-rt: test unw_resume() in
From: |
Tommi Rantala |
Subject: |
[Libunwind-devel] [PATCH 22/27] test-resume-sig-rt: test unw_resume() in presence of "realtime" signal frame |
Date: |
Wed, 22 Aug 2012 14:28:48 +0300 |
Introduce a new test case that is derived from test-resume-sig, but
using the SA_SIGINFO sigaction() flag. This case is referred in the
linux kernel sources as "realtime" signal handler, and is handled
differently in the kernel on many architectures and in libunwind as
well.
---
.gitignore | 1 +
tests/Gtest-resume-sig-rt.c | 31 +++++++++++++++++++++++++++++++
tests/Gtest-resume-sig.c | 28 +++++++++++++++++++++++++---
tests/Ltest-resume-sig-rt.c | 5 +++++
tests/Makefile.am | 3 +++
5 files changed, 65 insertions(+), 3 deletions(-)
create mode 100644 tests/Gtest-resume-sig-rt.c
create mode 100644 tests/Ltest-resume-sig-rt.c
diff --git a/.gitignore b/.gitignore
index eee3921..f5fe6dc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,6 +36,7 @@ tests/[GL]test-dyn1
tests/[GL]test-exc
tests/[GL]test-init
tests/[GL]test-resume-sig
+tests/[GL]test-resume-sig-rt
tests/[GL]perf-simple
tests/Ltest-nomalloc
tests/Ltest-nocalloc
diff --git a/tests/Gtest-resume-sig-rt.c b/tests/Gtest-resume-sig-rt.c
new file mode 100644
index 0000000..df515fc
--- /dev/null
+++ b/tests/Gtest-resume-sig-rt.c
@@ -0,0 +1,31 @@
+/* libunwind - a platform-independent unwind library
+ Copyright (C) 2003-2004 Hewlett-Packard Co
+ Contributed by David Mosberger-Tang <address@hidden>
+ Copyright (C) 2012 Tommi Rantala <address@hidden>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+/* The purpose of this test is to invoke different code paths in libunwind (on
+ * some architectures), that are executed when the SA_SIGINFO sigaction() flag
+ * is used.
+ */
+
+#define TEST_WITH_SIGINFO 1
+#include "Gtest-resume-sig.c"
diff --git a/tests/Gtest-resume-sig.c b/tests/Gtest-resume-sig.c
index 4ed42e3..57939cd 100644
--- a/tests/Gtest-resume-sig.c
+++ b/tests/Gtest-resume-sig.c
@@ -31,7 +31,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
+#include <errno.h>
#ifdef HAVE_IA64INTRIN_H
# include <ia64intrin.h>
@@ -59,8 +61,15 @@ get_bsp (void)
#endif
}
+#ifdef TEST_WITH_SIGINFO
+void
+handler (int sig,
+ siginfo_t *si __attribute__((unused)),
+ void *ucontext __attribute__((unused)))
+#else
void
handler (int sig)
+#endif
{
unw_word_t ip;
sigset_t mask, oldmask;
@@ -88,7 +97,6 @@ handler (int sig)
kill (getpid (), SIGUSR2); /* pend SIGUSR2 */
signal (SIGUSR1, SIG_IGN);
- signal (SIGUSR2, handler);
if ((ret = unw_getcontext (&uc)) < 0)
panic ("unw_getcontext() failed: ret=%d\n", ret);
@@ -102,7 +110,7 @@ handler (int sig)
if ((ret = unw_step (&c)) < 0) /* step to signal trampoline */
panic ("unw_step(1) failed: ret=%d\n", ret);
- if ((ret = unw_step (&c)) < 0) /* step to signal trampoline */
+ if ((ret = unw_step (&c)) < 0) /* step to kill() */
panic ("unw_step(2) failed: ret=%d\n", ret);
if ((ret = unw_get_reg (&c, UNW_REG_IP, &ip)) < 0)
@@ -129,13 +137,27 @@ handler (int sig)
int
main (int argc, char **argv __attribute__((unused)))
{
+ struct sigaction sa;
float d = 1.0;
int n = 0;
if (argc > 1)
verbose = 1;
- signal (SIGUSR1, handler);
+ memset (&sa, 0, sizeof(sa));
+#ifdef TEST_WITH_SIGINFO
+ sa.sa_sigaction = handler;
+ sa.sa_flags = SA_SIGINFO;
+#else
+ sa.sa_handler = handler;
+#endif
+
+ if (sigaction (SIGUSR1, &sa, NULL) != 0 ||
+ sigaction (SIGUSR2, &sa, NULL) != 0)
+ {
+ fprintf (stderr, "sigaction() failed: %s\n", strerror (errno));
+ return -1;
+ }
/* Use the FPU a bit; otherwise we get spurious errors should the
signal handler need to use the FPU for any reason. This seems to
diff --git a/tests/Ltest-resume-sig-rt.c b/tests/Ltest-resume-sig-rt.c
new file mode 100644
index 0000000..01fd6dc
--- /dev/null
+++ b/tests/Ltest-resume-sig-rt.c
@@ -0,0 +1,5 @@
+#define UNW_LOCAL_ONLY
+#include <libunwind.h>
+#if !defined(UNW_REMOTE_ONLY)
+#include "Gtest-resume-sig-rt.c"
+#endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dafd1c6..f4f6f3e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -42,6 +42,7 @@ endif #ARCH_IA64
Gtest-init Ltest-init \
Gtest-concurrent Ltest-concurrent \
Gtest-resume-sig Ltest-resume-sig \
+ Gtest-resume-sig-rt Ltest-resume-sig-rt \
Gtest-dyn1 Ltest-dyn1 \
Gtest-trace Ltest-trace \
test-async-sig test-flush-cache test-init-remote \
@@ -154,6 +155,7 @@ Gtest_dyn1_LDADD = $(LIBUNWIND) $(LIBUNWIND_local)
Gtest_exc_LDADD = $(LIBUNWIND) $(LIBUNWIND_local)
Gtest_init_LDADD = $(LIBUNWIND) $(LIBUNWIND_local)
Gtest_resume_sig_LDADD = $(LIBUNWIND) $(LIBUNWIND_local)
+Gtest_resume_sig_rt_LDADD = $(LIBUNWIND) $(LIBUNWIND_local)
Gperf_simple_LDADD = $(LIBUNWIND) $(LIBUNWIND_local)
Gtest_trace_LDADD=$(LIBUNWIND) $(LIBUNWIND_local)
Gperf_trace_LDADD = $(LIBUNWIND) $(LIBUNWIND_local)
@@ -166,6 +168,7 @@ Ltest_init_LDADD = $(LIBUNWIND_local)
Ltest_nomalloc_LDADD = $(LIBUNWIND_local) @DLLIB@
Ltest_nocalloc_LDADD = $(LIBUNWIND_local) @DLLIB@ -lpthread
Ltest_resume_sig_LDADD = $(LIBUNWIND_local)
+Ltest_resume_sig_rt_LDADD = $(LIBUNWIND_local)
Lperf_simple_LDADD = $(LIBUNWIND_local)
Ltest_trace_LDADD = $(LIBUNWIND_local)
Lperf_trace_LDADD = $(LIBUNWIND_local)
--
1.7.9.5
- [Libunwind-devel] [PATCH 15/27] MIPS: implement dwarf_to_unw_regnum() macro without table, (continued)
- [Libunwind-devel] [PATCH 15/27] MIPS: implement dwarf_to_unw_regnum() macro without table, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 13/27] Allow for architecture specific dwarf_to_unw_regnum(), Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 12/27] PPC: do not export dwarf_to_unw_regnum_map, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 10/27] Stop using nonportable echo arguments in tests, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 14/27] ARM: implement dwarf_to_unw_regnum() macro without table, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 17/27] Use constants for ELF magic bytes in _UCD_create.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 23/27] Avoid -Wunused-value warning in tests/Gtest-exc.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 18/27] Remove unneeded length modifier from suppressed match in sscanf() format in tests/crasher.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 19/27] Fix memory leaks in unw_create_addr_space() wrong-endian error paths, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 16/27] Fix plain return from main() in tests/test-async-sig.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 22/27] test-resume-sig-rt: test unw_resume() in presence of "realtime" signal frame,
Tommi Rantala <=
- [Libunwind-devel] [PATCH 25/27] Place `inline' at beginning of declaration of invalidate_edi(), Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 20/27] ARM: fix non-signal-frame local unw_resume() due to compiler optimization cleverness, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 21/27] ARM: fix with-signal-frame local unw_resume(), Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 24/27] Flush icache with __builtin___clear_cache() in tests when compiling with GCC, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 26/27] Fix function name duplication in Debug() output, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 27/27] Add missing newline to debug message in _UCD_access_reg_linux.c, Tommi Rantala, 2012/08/22
- [Libunwind-devel] [PATCH 02/27] HPPA: add `global_cache' member to unw_addr_space struct, Tommi Rantala, 2012/08/22