[x86,x86_64] Fix libgcc unwinding through signal
This change provides __restore/__restore_rt on x86 and __restore_rt on
x86_64 with unwinding information to be able to unwind through signal
frame via libgcc provided unwinding interface. See comments inlined for
more details.
Also remove the test that had a dependency on
__attribute__((cleanup(foo_cleanup))). It doesn't provide us with any
better test coverage than we have from the newer tests, and it doesn't
work well across a variety architectures (presumably because no one uses
this attribute in the real world).
Tested this on host via bionic-unit-tests-run-on-host on both x86 and
x86-64.
Bug: 17436734
Change-Id: I2f06814e82c8faa732cb4f5648868dc0fd2e5fe4
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
diff --git a/tests/stack_unwinding_test.cpp b/tests/stack_unwinding_test.cpp
index 017a5f2..3fc45c5 100644
--- a/tests/stack_unwinding_test.cpp
+++ b/tests/stack_unwinding_test.cpp
@@ -31,7 +31,8 @@
#include "ScopedSignalHandler.h"
-#define noinline __attribute__((noinline))
+#define noinline __attribute__((__noinline__))
+#define __unused __attribute__((__unused__))
static _Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx __unused, void* arg) {
int* count_ptr = reinterpret_cast<int*>(arg);
@@ -85,6 +86,7 @@
}
TEST(stack_unwinding, unwind_through_signal_frame) {
+ killer_count = handler_count = handler_one_deeper_count = 0;
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler);
_Unwind_Backtrace(FrameCounter, &killer_count);
@@ -92,11 +94,12 @@
ASSERT_EQ(0, kill(getpid(), SIGUSR1));
}
-extern "C" void unwind_through_frame_with_cleanup_function();
+// On LP32, the SA_SIGINFO flag gets you __restore_rt instead of __restore.
+TEST(stack_unwinding, unwind_through_signal_frame_SA_SIGINFO) {
+ killer_count = handler_count = handler_one_deeper_count = 0;
+ ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler, SA_SIGINFO);
-// We have to say "DeathTest" here so gtest knows to run this test (which exits)
-// in its own process.
-TEST(stack_unwinding_DeathTest, unwind_through_frame_with_cleanup_function) {
- ::testing::FLAGS_gtest_death_test_style = "threadsafe";
- ASSERT_EXIT(unwind_through_frame_with_cleanup_function(), ::testing::ExitedWithCode(42), "");
+ _Unwind_Backtrace(FrameCounter, &killer_count);
+
+ ASSERT_EQ(0, kill(getpid(), SIGUSR1));
}