mirror of
https://github.com/QuasarApp/backward-cpp.git
synced 2025-05-16 03:19:39 +00:00
Improve as per bombela's suggestions, add test
This commit is contained in:
parent
fea5667108
commit
5a638eafd8
@ -69,6 +69,7 @@ set(TESTS
|
||||
invalidread
|
||||
suicide
|
||||
divbyzero
|
||||
select_signals
|
||||
)
|
||||
|
||||
foreach(test ${TESTS})
|
||||
|
23
backward.hpp
23
backward.hpp
@ -2007,8 +2007,11 @@ private:
|
||||
|
||||
#ifdef BACKWARD_SYSTEM_LINUX
|
||||
|
||||
std::vector<int> make_default_signals() {
|
||||
const int signals[] = {
|
||||
|
||||
class SignalHandling {
|
||||
public:
|
||||
static std::vector<int> make_default_signals() {
|
||||
const int signals[] = {
|
||||
// default action: Core
|
||||
SIGILL,
|
||||
SIGABRT,
|
||||
@ -2037,20 +2040,10 @@ std::vector<int> make_default_signals() {
|
||||
SIGXCPU,
|
||||
SIGXFSZ
|
||||
};
|
||||
std::vector<int> result;
|
||||
for (const int* sig = signals;
|
||||
sig != signals + sizeof signals / sizeof *signals; ++sig) {
|
||||
result.push_back(*sig);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return std::vector<int>(signals, signals + sizeof signals);
|
||||
}
|
||||
|
||||
|
||||
const std::vector<int> default_signals = make_default_signals();
|
||||
|
||||
class SignalHandling {
|
||||
public:
|
||||
SignalHandling(const std::vector<int>& signals = default_signals): _loaded(false) {
|
||||
SignalHandling(const std::vector<int>& signals = make_default_signals()) : _loaded(false) {
|
||||
bool success = true;
|
||||
|
||||
const size_t stack_size = 1024 * 1024 * 8;
|
||||
|
48
test/select_signals.cpp
Normal file
48
test/select_signals.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* test/segfault.cpp
|
||||
* Copyright 2013 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//#define BACKWARD_SYSTEN_UNKNOWN
|
||||
//#define BACKWARD_HAS_UNWIND 0
|
||||
//#define BACKWARD_CXX98
|
||||
|
||||
#include "backward.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "test/test.hpp"
|
||||
|
||||
using namespace backward;
|
||||
|
||||
void badass_function()
|
||||
{
|
||||
char* ptr = (char*)42;
|
||||
*ptr = 42;
|
||||
}
|
||||
|
||||
TEST (select_signals)
|
||||
{
|
||||
std::vector<int> signals;
|
||||
signals.push_back(SIGSEGV);
|
||||
SignalHandling sh(signals);
|
||||
std::cout << std::boolalpha << "sh.loaded() == " << sh.loaded() << std::endl;
|
||||
badass_function();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user