am d687905f: Merge "Display errors instead of running infinitely."
* commit 'd687905f11102a7f6bad461b6f501dc870c59999': Display errors instead of running infinitely.
This commit is contained in:
commit
6880ec44c3
@ -73,37 +73,47 @@ TEST(stack_unwinding, easy) {
|
|||||||
ASSERT_EQ(count + 1, deeper_count);
|
ASSERT_EQ(count + 1, deeper_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static volatile bool signal_handler_run = false;
|
struct UnwindData {
|
||||||
static int killer_count = 0;
|
volatile bool signal_handler_complete = false;
|
||||||
static int handler_count = 0;
|
int expected_frame_count = 0;
|
||||||
static int handler_one_deeper_count = 0;
|
int handler_frame_count = 0;
|
||||||
|
int handler_one_deeper_frame_count = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
static UnwindData g_unwind_data;
|
||||||
|
|
||||||
static void noinline UnwindSignalHandler(int) {
|
static void noinline UnwindSignalHandler(int) {
|
||||||
_Unwind_Backtrace(FrameCounter, &handler_count);
|
_Unwind_Backtrace(FrameCounter, &g_unwind_data.handler_frame_count);
|
||||||
ASSERT_GT(handler_count, killer_count);
|
|
||||||
|
|
||||||
handler_one_deeper_count = unwind_one_frame_deeper();
|
g_unwind_data.handler_one_deeper_frame_count = unwind_one_frame_deeper();
|
||||||
ASSERT_EQ(handler_count + 1, handler_one_deeper_count);
|
g_unwind_data.signal_handler_complete = true;
|
||||||
signal_handler_run = true;
|
}
|
||||||
|
|
||||||
|
static void verify_unwind_data(const UnwindData& unwind_data) {
|
||||||
|
EXPECT_GT(unwind_data.handler_frame_count, unwind_data.expected_frame_count);
|
||||||
|
EXPECT_EQ(unwind_data.handler_frame_count + 1, unwind_data.handler_one_deeper_frame_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(stack_unwinding, unwind_through_signal_frame) {
|
TEST(stack_unwinding, unwind_through_signal_frame) {
|
||||||
killer_count = handler_count = handler_one_deeper_count = 0;
|
g_unwind_data = {};
|
||||||
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler);
|
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler);
|
||||||
|
|
||||||
_Unwind_Backtrace(FrameCounter, &killer_count);
|
_Unwind_Backtrace(FrameCounter, &g_unwind_data.expected_frame_count);
|
||||||
signal_handler_run = false;
|
|
||||||
ASSERT_EQ(0, kill(getpid(), SIGUSR1));
|
ASSERT_EQ(0, kill(getpid(), SIGUSR1));
|
||||||
while (!signal_handler_run) {}
|
while (!g_unwind_data.signal_handler_complete) {}
|
||||||
|
|
||||||
|
verify_unwind_data(g_unwind_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// On LP32, the SA_SIGINFO flag gets you __restore_rt instead of __restore.
|
// On LP32, the SA_SIGINFO flag gets you __restore_rt instead of __restore.
|
||||||
TEST(stack_unwinding, unwind_through_signal_frame_SA_SIGINFO) {
|
TEST(stack_unwinding, unwind_through_signal_frame_SA_SIGINFO) {
|
||||||
killer_count = handler_count = handler_one_deeper_count = 0;
|
g_unwind_data = {};
|
||||||
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler, SA_SIGINFO);
|
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler, SA_SIGINFO);
|
||||||
|
|
||||||
_Unwind_Backtrace(FrameCounter, &killer_count);
|
_Unwind_Backtrace(FrameCounter, &g_unwind_data.expected_frame_count);
|
||||||
signal_handler_run = false;
|
|
||||||
ASSERT_EQ(0, kill(getpid(), SIGUSR1));
|
ASSERT_EQ(0, kill(getpid(), SIGUSR1));
|
||||||
while (!signal_handler_run) {}
|
while (!g_unwind_data.signal_handler_complete) {}
|
||||||
|
|
||||||
|
verify_unwind_data(g_unwind_data);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user