aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/backtrace/cursors/libunwind/libunwind_cursor.h
blob: 08b01d07ef7114d7622b81d254953500e29e572e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <contrib/libs/libunwind/include/libunwind.h>

namespace NYT::NBacktrace {

////////////////////////////////////////////////////////////////////////////////

class TLibunwindCursor
{
public:
    TLibunwindCursor();
    explicit TLibunwindCursor(const unw_context_t& context);

    bool IsFinished() const;
    const void* GetCurrentIP() const;
    void MoveNext();

private:
    unw_context_t Context_;
    unw_cursor_t Cursor_;

    bool Finished_ = false;

    const void* CurrentIP_ = nullptr;

    void Initialize();
    void ReadCurrentIP();
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT::NBacktrace