diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-09-04 20:25:33 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-09-04 20:31:51 +0300 |
commit | 3606f14bef45ea2e5608de3d4ca4a6840ca16b4d (patch) | |
tree | 1db64556d3d03b9b5949eaead4e12441b221d4af /library/cpp | |
parent | d539a0375a47697c169702a9aa18306b2c70bb3f (diff) | |
download | ydb-3606f14bef45ea2e5608de3d4ca4a6840ca16b4d.tar.gz |
Intermediate changes
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.h | 44 | ||||
-rw-r--r-- | library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_dummy.cpp | 27 | ||||
-rw-r--r-- | library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_dummy.h | 26 | ||||
-rw-r--r-- | library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_x86_64.cpp (renamed from library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.cpp) | 2 | ||||
-rw-r--r-- | library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_x86_64.h | 43 | ||||
-rw-r--r-- | library/cpp/yt/backtrace/cursors/frame_pointer/ya.make | 12 | ||||
-rw-r--r-- | library/cpp/yt/backtrace/cursors/interop/interop_dummy.cpp | 26 | ||||
-rw-r--r-- | library/cpp/yt/backtrace/cursors/interop/interop_x86_64.cpp (renamed from library/cpp/yt/backtrace/cursors/interop/interop.cpp) | 4 | ||||
-rw-r--r-- | library/cpp/yt/backtrace/cursors/interop/ya.make | 12 |
9 files changed, 147 insertions, 49 deletions
diff --git a/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.h b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.h index 526b41d94b..fc2baae654 100644 --- a/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.h +++ b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.h @@ -1,43 +1,7 @@ #pragma once -#include <library/cpp/yt/memory/safe_memory_reader.h> - -namespace NYT::NBacktrace { - -//////////////////////////////////////////////////////////////////////////////// - -#ifndef _x86_64_ -#error Unsupported platform +#ifdef __x86_64__ + #include "frame_pointer_cursor_x86_64.h" +#else + #include "frame_pointer_cursor_dummy.h" #endif - -struct TFramePointerCursorContext -{ - ui64 Rip; - ui64 Rsp; - ui64 Rbp; -}; - -class TFramePointerCursor -{ -public: - TFramePointerCursor( - TSafeMemoryReader* memoryReader, - const TFramePointerCursorContext& context); - - bool IsFinished() const; - const void* GetCurrentIP() const; - void MoveNext(); - -private: - TSafeMemoryReader* MemoryReader_; - bool Finished_ = false; - bool First_ = true; - - const void* Rip_ = nullptr; - const void* Rbp_ = nullptr; - const void* StartRsp_ = nullptr; -}; - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT::NBacktrace diff --git a/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_dummy.cpp b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_dummy.cpp new file mode 100644 index 0000000000..a97badc6bd --- /dev/null +++ b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_dummy.cpp @@ -0,0 +1,27 @@ +#include "frame_pointer_cursor_dummy.h" + +namespace NYT::NBacktrace { + +//////////////////////////////////////////////////////////////////////////////// + +TFramePointerCursor::TFramePointerCursor( + TSafeMemoryReader* /*memoryReader*/, + const TFramePointerCursorContext& /*context*/) +{ } + +bool TFramePointerCursor::IsFinished() const +{ + return true; +} + +const void* TFramePointerCursor::GetCurrentIP() const +{ + return nullptr; +} + +void TFramePointerCursor::MoveNext() +{ } + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT::NBacktrace diff --git a/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_dummy.h b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_dummy.h new file mode 100644 index 0000000000..6732e6f280 --- /dev/null +++ b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_dummy.h @@ -0,0 +1,26 @@ +#pragma once + +#include <library/cpp/yt/memory/safe_memory_reader.h> + +namespace NYT::NBacktrace { + +//////////////////////////////////////////////////////////////////////////////// + +struct TFramePointerCursorContext +{ }; + +class TFramePointerCursor +{ +public: + TFramePointerCursor( + TSafeMemoryReader* memoryReader, + const TFramePointerCursorContext& context); + + bool IsFinished() const; + const void* GetCurrentIP() const; + void MoveNext(); +}; + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT::NBacktrace diff --git a/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.cpp b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_x86_64.cpp index 290d30c3ce..0a2c301577 100644 --- a/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.cpp +++ b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_x86_64.cpp @@ -1,4 +1,4 @@ -#include "frame_pointer_cursor.h" +#include "frame_pointer_cursor_x86_64.h" #include <util/generic/size_literals.h> diff --git a/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_x86_64.h b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_x86_64.h new file mode 100644 index 0000000000..c2f1b86b75 --- /dev/null +++ b/library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor_x86_64.h @@ -0,0 +1,43 @@ +#pragma once + +#include <library/cpp/yt/memory/safe_memory_reader.h> + +namespace NYT::NBacktrace { + +//////////////////////////////////////////////////////////////////////////////// + +struct TFramePointerCursorContext +{ +#ifdef _x86_64_ + ui64 Rip; + ui64 Rsp; + ui64 Rbp; +#endif +}; + +class TFramePointerCursor +{ +public: + TFramePointerCursor( + TSafeMemoryReader* memoryReader, + const TFramePointerCursorContext& context); + + bool IsFinished() const; + const void* GetCurrentIP() const; + void MoveNext(); + +private: +#ifdef _x86_64_ + TSafeMemoryReader* const MemoryReader_; + bool Finished_ = false; + bool First_ = true; + + const void* Rip_ = nullptr; + const void* Rbp_ = nullptr; + const void* StartRsp_ = nullptr; +#endif +}; + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT::NBacktrace diff --git a/library/cpp/yt/backtrace/cursors/frame_pointer/ya.make b/library/cpp/yt/backtrace/cursors/frame_pointer/ya.make index cb85d70315..ba6b66b3c3 100644 --- a/library/cpp/yt/backtrace/cursors/frame_pointer/ya.make +++ b/library/cpp/yt/backtrace/cursors/frame_pointer/ya.make @@ -2,8 +2,14 @@ LIBRARY() INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) -SRCS( - frame_pointer_cursor.cpp -) +IF (ARCH_X86_64) + SRCS( + frame_pointer_cursor_x86_64.cpp + ) +ELSE() + SRCS( + frame_pointer_cursor_dummy.cpp + ) +ENDIF() END() diff --git a/library/cpp/yt/backtrace/cursors/interop/interop_dummy.cpp b/library/cpp/yt/backtrace/cursors/interop/interop_dummy.cpp new file mode 100644 index 0000000000..37e15ded85 --- /dev/null +++ b/library/cpp/yt/backtrace/cursors/interop/interop_dummy.cpp @@ -0,0 +1,26 @@ +#include "interop.h" + +namespace NYT::NBacktrace { + +//////////////////////////////////////////////////////////////////////////////// + +TFramePointerCursorContext FramePointerCursorContextFromUcontext(const ucontext_t& /*ucontext*/) +{ + return {}; +} + +std::optional<unw_context_t> TrySynthesizeLibunwindContextFromMachineContext( + const TContMachineContext& /*machineContext*/) +{ + return {}; +} + +TFramePointerCursorContext FramePointerCursorContextFromLibunwindCursor( + const unw_cursor_t& /*cursor*/) +{ + return {}; +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT::NBacktrace diff --git a/library/cpp/yt/backtrace/cursors/interop/interop.cpp b/library/cpp/yt/backtrace/cursors/interop/interop_x86_64.cpp index 5ef38f326d..b4e6cfbe6e 100644 --- a/library/cpp/yt/backtrace/cursors/interop/interop.cpp +++ b/library/cpp/yt/backtrace/cursors/interop/interop_x86_64.cpp @@ -6,13 +6,13 @@ namespace NYT::NBacktrace { TFramePointerCursorContext FramePointerCursorContextFromUcontext(const ucontext_t& ucontext) { -#if defined(_linux_) && defined(_x86_64_) +#if defined(_linux_) return { .Rip = static_cast<ui64>(ucontext.uc_mcontext.gregs[REG_RIP]), .Rsp = static_cast<ui64>(ucontext.uc_mcontext.gregs[REG_RSP]), .Rbp = static_cast<ui64>(ucontext.uc_mcontext.gregs[REG_RBP]), }; -#elif defined(_darwin_) && defined(_x86_64_) +#elif defined(_darwin_) return { .Rip = static_cast<ui64>(ucontext.uc_mcontext->__ss.__rip), .Rsp = static_cast<ui64>(ucontext.uc_mcontext->__ss.__rsp), diff --git a/library/cpp/yt/backtrace/cursors/interop/ya.make b/library/cpp/yt/backtrace/cursors/interop/ya.make index 6637f6a9b4..491b0e1339 100644 --- a/library/cpp/yt/backtrace/cursors/interop/ya.make +++ b/library/cpp/yt/backtrace/cursors/interop/ya.make @@ -2,9 +2,15 @@ LIBRARY() INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) -SRCS( - interop.cpp -) +IF (ARCH_X86_64) + SRCS( + interop_x86_64.cpp + ) +ELSE() + SRCS( + interop_dummy.cpp + ) +ENDIF() PEERDIR( library/cpp/yt/backtrace/cursors/frame_pointer |