Browse Source

Intermediate changes

robot-piglet 6 months ago
parent
commit
3606f14bef

+ 4 - 40
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

+ 27 - 0
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

+ 26 - 0
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

+ 1 - 1
library/cpp/yt/backtrace/cursors/frame_pointer/frame_pointer_cursor.cpp → 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>
 

+ 43 - 0
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

+ 9 - 3
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()

+ 26 - 0
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

+ 2 - 2
library/cpp/yt/backtrace/cursors/interop/interop.cpp → 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),

+ 9 - 3
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

+ 0 - 0
yt/yt/library/ytprof/symbolize_other.cpp → yt/yt/library/ytprof/symbolize_dummy.cpp


Some files were not shown because too many files changed in this diff