diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/terminate_handler/sample | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/terminate_handler/sample')
9 files changed, 130 insertions, 0 deletions
diff --git a/library/cpp/terminate_handler/sample/exception/main.cpp b/library/cpp/terminate_handler/sample/exception/main.cpp new file mode 100644 index 0000000000..35bfae8874 --- /dev/null +++ b/library/cpp/terminate_handler/sample/exception/main.cpp @@ -0,0 +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; +} diff --git a/library/cpp/terminate_handler/sample/exception/ya.make b/library/cpp/terminate_handler/sample/exception/ya.make new file mode 100644 index 0000000000..958c26f89a --- /dev/null +++ b/library/cpp/terminate_handler/sample/exception/ya.make @@ -0,0 +1,13 @@ +PROGRAM(exception_sample) + +OWNER(nga) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/terminate_handler +) + +END() diff --git a/library/cpp/terminate_handler/sample/pure-virtual/main.cpp b/library/cpp/terminate_handler/sample/pure-virtual/main.cpp new file mode 100644 index 0000000000..58217d5f24 --- /dev/null +++ b/library/cpp/terminate_handler/sample/pure-virtual/main.cpp @@ -0,0 +1,22 @@ + +struct TFoo { + TFoo() { + Baz(); + } + + void Baz() { + Bar(); + } + + virtual void Bar() = 0; +}; + +struct TQux: public TFoo { + void Bar() override { + } +}; + +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 new file mode 100644 index 0000000000..4100da630d --- /dev/null +++ b/library/cpp/terminate_handler/sample/pure-virtual/ya.make @@ -0,0 +1,13 @@ +PROGRAM() + +OWNER(nga) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/terminate_handler +) + +END() diff --git a/library/cpp/terminate_handler/sample/rethrow/main.cpp b/library/cpp/terminate_handler/sample/rethrow/main.cpp new file mode 100644 index 0000000000..fcd8592613 --- /dev/null +++ b/library/cpp/terminate_handler/sample/rethrow/main.cpp @@ -0,0 +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; +} diff --git a/library/cpp/terminate_handler/sample/rethrow/ya.make b/library/cpp/terminate_handler/sample/rethrow/ya.make new file mode 100644 index 0000000000..4100da630d --- /dev/null +++ b/library/cpp/terminate_handler/sample/rethrow/ya.make @@ -0,0 +1,13 @@ +PROGRAM() + +OWNER(nga) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/terminate_handler +) + +END() diff --git a/library/cpp/terminate_handler/sample/segv/main.cpp b/library/cpp/terminate_handler/sample/segv/main.cpp new file mode 100644 index 0000000000..52851bdb19 --- /dev/null +++ b/library/cpp/terminate_handler/sample/segv/main.cpp @@ -0,0 +1,15 @@ +#include "../../segv_handler.h" + +void Bar(int* x) { + *x = 11; +} + +void Foo(int* x) { + Bar(x); +} + +int main() { + InstallSegvHandler(); + Foo((int*)1); + return 0; +} diff --git a/library/cpp/terminate_handler/sample/segv/ya.make b/library/cpp/terminate_handler/sample/segv/ya.make new file mode 100644 index 0000000000..4100da630d --- /dev/null +++ b/library/cpp/terminate_handler/sample/segv/ya.make @@ -0,0 +1,13 @@ +PROGRAM() + +OWNER(nga) + +SRCS( + main.cpp +) + +PEERDIR( + library/cpp/terminate_handler +) + +END() diff --git a/library/cpp/terminate_handler/sample/ya.make b/library/cpp/terminate_handler/sample/ya.make new file mode 100644 index 0000000000..af089abc65 --- /dev/null +++ b/library/cpp/terminate_handler/sample/ya.make @@ -0,0 +1,6 @@ +RECURSE( + exception + pure-virtual + rethrow + segv +) |