3 * Copyright 2013 Google Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #include "backward.hpp"
27 #include <sys/resource.h>
28 #include "test/test.hpp"
30 using namespace backward;
32 void badass_function()
34 char* ptr = (char*)42;
38 TEST_SEGFAULT (invalid_write)
43 int you_shall_not_pass()
45 char* ptr = (char*)42;
50 TEST_SEGFAULT(invalid_read)
52 int v = you_shall_not_pass();
53 std::cout << "v=" << v << std::endl;
56 void abort_abort_I_repeat_abort_abort()
58 std::cout << "Jumping off the boat!" << std::endl;
62 TEST_ABORT (calling_abort)
64 abort_abort_I_repeat_abort_abort();
67 // aarch64 does not trap Division by zero
69 volatile int zero = 0;
73 std::cout << "And the wild black hole appears..." << std::endl;
78 TEST_DIVZERO (divide_by_zero)
80 int v = divide_by_zero();
81 std::cout << "v=" << v << std::endl;
85 // Darwin does not allow RLIMIT_STACK to be reduced
87 int bye_bye_stack(int i) {
88 return bye_bye_stack(i + 1) + bye_bye_stack(i * 2);
91 TEST_SEGFAULT(stackoverflow)
94 limit.rlim_max = 8096;
95 setrlimit(RLIMIT_STACK, &limit);
96 int r = bye_bye_stack(42);
97 std::cout << "r=" << r << std::endl;