diff options
| author | nga <[email protected]> | 2022-02-10 16:48:09 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:48:09 +0300 | 
| commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
| tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /library/cpp/terminate_handler | |
| parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 1 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 35bfae8874a..e764101d0e2 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 958c26f89a5..077586fe140 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 58217d5f240..6e9c9fbff40 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 4100da630d3..27ef18f3a0e 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 fcd8592613a..57e0722a3d3 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 4100da630d3..27ef18f3a0e 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 52851bdb196..0b29cc193e3 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 4100da630d3..27ef18f3a0e 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 af089abc65b..f60f58e7996 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 f24ece41250..fc720eff188 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 c9f9051c7d4..5f538104607 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 d7e8fbed95f..30f17ae4bfc 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 70a9712feda..40ca71a5ccb 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()   | 
