diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | c2a1af049e9deca890e9923abe64fe6c59060348 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/terminate_handler | |
parent | 1f553f46fb4f3c5eec631352cdd900a0709016af (diff) | |
download | ydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/terminate_handler')
-rw-r--r-- | library/cpp/terminate_handler/sample/exception/main.cpp | 30 | ||||
-rw-r--r-- | library/cpp/terminate_handler/sample/exception/ya.make | 22 | ||||
-rw-r--r-- | library/cpp/terminate_handler/sample/pure-virtual/main.cpp | 40 | ||||
-rw-r--r-- | library/cpp/terminate_handler/sample/pure-virtual/ya.make | 24 | ||||
-rw-r--r-- | library/cpp/terminate_handler/sample/rethrow/main.cpp | 40 | ||||
-rw-r--r-- | library/cpp/terminate_handler/sample/rethrow/ya.make | 24 | ||||
-rw-r--r-- | library/cpp/terminate_handler/sample/segv/main.cpp | 28 | ||||
-rw-r--r-- | library/cpp/terminate_handler/sample/segv/ya.make | 24 | ||||
-rw-r--r-- | library/cpp/terminate_handler/sample/ya.make | 4 | ||||
-rw-r--r-- | library/cpp/terminate_handler/segv_handler.cpp | 60 | ||||
-rw-r--r-- | library/cpp/terminate_handler/segv_handler.h | 6 | ||||
-rw-r--r-- | library/cpp/terminate_handler/terminate_handler.cpp | 24 | ||||
-rw-r--r-- | library/cpp/terminate_handler/ya.make | 16 |
13 files changed, 171 insertions, 171 deletions
diff --git a/library/cpp/terminate_handler/sample/exception/main.cpp b/library/cpp/terminate_handler/sample/exception/main.cpp index e764101d0e..35bfae8874 100644 --- a/library/cpp/terminate_handler/sample/exception/main.cpp +++ b/library/cpp/terminate_handler/sample/exception/main.cpp @@ -1,15 +1,15 @@ -#include <util/generic/yexception.h> - - -void Foo(unsigned i = 0) { - if (i >= 10) { - ythrow yexception() << "from Foo()"; - } else { - Foo(i + 1); - } -} - -int main() { - Foo(); - return 0; -} +#include <util/generic/yexception.h> + + +void Foo(unsigned i = 0) { + if (i >= 10) { + ythrow yexception() << "from Foo()"; + } else { + Foo(i + 1); + } +} + +int main() { + Foo(); + return 0; +} diff --git a/library/cpp/terminate_handler/sample/exception/ya.make b/library/cpp/terminate_handler/sample/exception/ya.make index 077586fe14..958c26f89a 100644 --- a/library/cpp/terminate_handler/sample/exception/ya.make +++ b/library/cpp/terminate_handler/sample/exception/ya.make @@ -1,13 +1,13 @@ PROGRAM(exception_sample) - -OWNER(nga) - -SRCS( - main.cpp -) - -PEERDIR( + +OWNER(nga) + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/terminate_handler -) - -END() +) + +END() diff --git a/library/cpp/terminate_handler/sample/pure-virtual/main.cpp b/library/cpp/terminate_handler/sample/pure-virtual/main.cpp index 6e9c9fbff4..58217d5f24 100644 --- a/library/cpp/terminate_handler/sample/pure-virtual/main.cpp +++ b/library/cpp/terminate_handler/sample/pure-virtual/main.cpp @@ -1,22 +1,22 @@ - -struct TFoo { - TFoo() { - Baz(); - } - - void Baz() { - Bar(); - } - - virtual void Bar() = 0; -}; - -struct TQux: public TFoo { + +struct TFoo { + TFoo() { + Baz(); + } + + void Baz() { + Bar(); + } + + virtual void Bar() = 0; +}; + +struct TQux: public TFoo { void Bar() override { } -}; - -int main() { - TQux(); - return 0; -} +}; + +int main() { + TQux(); + return 0; +} diff --git a/library/cpp/terminate_handler/sample/pure-virtual/ya.make b/library/cpp/terminate_handler/sample/pure-virtual/ya.make index 27ef18f3a0..4100da630d 100644 --- a/library/cpp/terminate_handler/sample/pure-virtual/ya.make +++ b/library/cpp/terminate_handler/sample/pure-virtual/ya.make @@ -1,13 +1,13 @@ -PROGRAM() - -OWNER(nga) - -SRCS( - main.cpp -) - -PEERDIR( +PROGRAM() + +OWNER(nga) + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/terminate_handler -) - -END() +) + +END() diff --git a/library/cpp/terminate_handler/sample/rethrow/main.cpp b/library/cpp/terminate_handler/sample/rethrow/main.cpp index 57e0722a3d..fcd8592613 100644 --- a/library/cpp/terminate_handler/sample/rethrow/main.cpp +++ b/library/cpp/terminate_handler/sample/rethrow/main.cpp @@ -1,20 +1,20 @@ -#include <util/generic/yexception.h> - - -void Bar() { - ythrow yexception() << "from Foo()"; -} - -void Foo() { - try { - Bar(); - } catch (...) { - Cerr << "caught; rethrowing\n"; - throw; - } -} - -int main() { - Foo(); - return 0; -} +#include <util/generic/yexception.h> + + +void Bar() { + ythrow yexception() << "from Foo()"; +} + +void Foo() { + try { + Bar(); + } catch (...) { + Cerr << "caught; rethrowing\n"; + throw; + } +} + +int main() { + Foo(); + return 0; +} diff --git a/library/cpp/terminate_handler/sample/rethrow/ya.make b/library/cpp/terminate_handler/sample/rethrow/ya.make index 27ef18f3a0..4100da630d 100644 --- a/library/cpp/terminate_handler/sample/rethrow/ya.make +++ b/library/cpp/terminate_handler/sample/rethrow/ya.make @@ -1,13 +1,13 @@ -PROGRAM() - -OWNER(nga) - -SRCS( - main.cpp -) - -PEERDIR( +PROGRAM() + +OWNER(nga) + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/terminate_handler -) - -END() +) + +END() diff --git a/library/cpp/terminate_handler/sample/segv/main.cpp b/library/cpp/terminate_handler/sample/segv/main.cpp index 0b29cc193e..52851bdb19 100644 --- a/library/cpp/terminate_handler/sample/segv/main.cpp +++ b/library/cpp/terminate_handler/sample/segv/main.cpp @@ -1,15 +1,15 @@ -#include "../../segv_handler.h" - -void Bar(int* x) { - *x = 11; -} - -void Foo(int* x) { - Bar(x); -} - -int main() { - InstallSegvHandler(); +#include "../../segv_handler.h" + +void Bar(int* x) { + *x = 11; +} + +void Foo(int* x) { + Bar(x); +} + +int main() { + InstallSegvHandler(); Foo((int*)1); - return 0; -} + return 0; +} diff --git a/library/cpp/terminate_handler/sample/segv/ya.make b/library/cpp/terminate_handler/sample/segv/ya.make index 27ef18f3a0..4100da630d 100644 --- a/library/cpp/terminate_handler/sample/segv/ya.make +++ b/library/cpp/terminate_handler/sample/segv/ya.make @@ -1,13 +1,13 @@ -PROGRAM() - -OWNER(nga) - -SRCS( - main.cpp -) - -PEERDIR( +PROGRAM() + +OWNER(nga) + +SRCS( + main.cpp +) + +PEERDIR( library/cpp/terminate_handler -) - -END() +) + +END() diff --git a/library/cpp/terminate_handler/sample/ya.make b/library/cpp/terminate_handler/sample/ya.make index f60f58e799..af089abc65 100644 --- a/library/cpp/terminate_handler/sample/ya.make +++ b/library/cpp/terminate_handler/sample/ya.make @@ -1,6 +1,6 @@ -RECURSE( +RECURSE( exception pure-virtual rethrow segv -) +) diff --git a/library/cpp/terminate_handler/segv_handler.cpp b/library/cpp/terminate_handler/segv_handler.cpp index fc720eff18..f24ece4125 100644 --- a/library/cpp/terminate_handler/segv_handler.cpp +++ b/library/cpp/terminate_handler/segv_handler.cpp @@ -1,34 +1,34 @@ -#include <util/system/platform.h> -#include <util/system/yassert.h> -#include <util/stream/output.h> -#include <util/system/backtrace.h> - -#ifdef _unix_ -#include <signal.h> -#include <errno.h> -#include <stdlib.h> +#include <util/system/platform.h> +#include <util/system/yassert.h> +#include <util/stream/output.h> +#include <util/system/backtrace.h> + +#ifdef _unix_ +#include <signal.h> +#include <errno.h> +#include <stdlib.h> #include <unistd.h> -#endif - -#include "segv_handler.h" - -#ifndef _win_ -static void SegvHandler(int sig) { +#endif + +#include "segv_handler.h" + +#ifndef _win_ +static void SegvHandler(int sig) { Y_UNUSED(sig); - const char msg[] = "Got SEGV\n"; + const char msg[] = "Got SEGV\n"; Y_UNUSED(write(STDERR_FILENO, msg, sizeof(msg))); - //PrintBackTrace(); - sig_t r = signal(SIGSEGV, SIG_DFL); - if (r == SIG_ERR) { - abort(); - } - // returning back and failing -} -#endif // !_win_ - -void InstallSegvHandler() { -#ifndef _win_ - sig_t r = signal(SIGSEGV, &SegvHandler); + //PrintBackTrace(); + sig_t r = signal(SIGSEGV, SIG_DFL); + if (r == SIG_ERR) { + abort(); + } + // returning back and failing +} +#endif // !_win_ + +void InstallSegvHandler() { +#ifndef _win_ + sig_t r = signal(SIGSEGV, &SegvHandler); Y_VERIFY(r != SIG_ERR, "signal failed: %s", strerror(errno)); -#endif // !_win_ -} +#endif // !_win_ +} diff --git a/library/cpp/terminate_handler/segv_handler.h b/library/cpp/terminate_handler/segv_handler.h index 5f53810460..c9f9051c7d 100644 --- a/library/cpp/terminate_handler/segv_handler.h +++ b/library/cpp/terminate_handler/segv_handler.h @@ -1,3 +1,3 @@ -#pragma once - -void InstallSegvHandler(); +#pragma once + +void InstallSegvHandler(); diff --git a/library/cpp/terminate_handler/terminate_handler.cpp b/library/cpp/terminate_handler/terminate_handler.cpp index 30f17ae4bf..d7e8fbed95 100644 --- a/library/cpp/terminate_handler/terminate_handler.cpp +++ b/library/cpp/terminate_handler/terminate_handler.cpp @@ -1,15 +1,15 @@ #include <cstdlib> -#include <exception> - -#include <util/stream/output.h> -#include <util/system/backtrace.h> -#include <util/generic/yexception.h> - +#include <exception> + +#include <util/stream/output.h> +#include <util/system/backtrace.h> +#include <util/generic/yexception.h> + namespace { // Avoid infinite recursion if std::terminate is triggered anew by the // FancyTerminateHandler. thread_local int TerminateCount = 0; - + void FancyTerminateHandler() { switch (++TerminateCount) { case 1: @@ -21,7 +21,7 @@ namespace { abort(); break; } - + if (std::current_exception()) { Cerr << "Uncaught exception: " << CurrentExceptionMessage() << '\n'; } else { @@ -29,8 +29,8 @@ namespace { } PrintBackTrace(); Cerr.Flush(); - abort(); - } - + abort(); + } + [[maybe_unused]] auto _ = std::set_terminate(&FancyTerminateHandler); -} +} diff --git a/library/cpp/terminate_handler/ya.make b/library/cpp/terminate_handler/ya.make index 40ca71a5cc..70a9712fed 100644 --- a/library/cpp/terminate_handler/ya.make +++ b/library/cpp/terminate_handler/ya.make @@ -1,13 +1,13 @@ -LIBRARY() - +LIBRARY() + OWNER( ilnurkh eeight ) - -SRCS( + +SRCS( GLOBAL terminate_handler.cpp - segv_handler.cpp -) - -END() + segv_handler.cpp +) + +END() |