diff options
author | max42 <max42@yandex-team.com> | 2023-06-30 11:13:34 +0300 |
---|---|---|
committer | max42 <max42@yandex-team.com> | 2023-06-30 11:13:34 +0300 |
commit | 3e1899838408bbad47622007aa382bc8a2b01f87 (patch) | |
tree | 0f21c1e6add187ddb6c3ccc048a7d640ce03fb87 /library/cpp/dwarf_backtrace/backtrace.cpp | |
parent | 5463eb3f5e72a86f858a3d27c886470a724ede34 (diff) | |
download | ydb-3e1899838408bbad47622007aa382bc8a2b01f87.tar.gz |
Revert "YT-19324: move YT provider to ydb/library/yql"
This reverts commit ca272f12fdd0e8d5c3e957fc87939148f1caaf72, reversing
changes made to 49f8acfc8b0b5c0071b804423bcf53fda26c7c12.
Diffstat (limited to 'library/cpp/dwarf_backtrace/backtrace.cpp')
-rw-r--r-- | library/cpp/dwarf_backtrace/backtrace.cpp | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/library/cpp/dwarf_backtrace/backtrace.cpp b/library/cpp/dwarf_backtrace/backtrace.cpp deleted file mode 100644 index a955d07249..0000000000 --- a/library/cpp/dwarf_backtrace/backtrace.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "backtrace.h" - -#include <contrib/libs/backtrace/backtrace.h> - -#include <util/generic/yexception.h> -#include <util/system/type_name.h> -#include <util/system/execpath.h> - -namespace NDwarf { - namespace { - struct TContext { - TCallback& Callback; - int Counter = 0; - TMaybe<TError> Error; - }; - - void HandleLibBacktraceError(void* data, const char* msg, int errnum) { - auto* context = reinterpret_cast<TContext*>(data); - context->Error = TError{.Code = errnum, .Message=msg}; - } - - int HandleLibBacktraceFrame(void* data, uintptr_t pc, const char* filename, int lineno, const char* function) { - auto* context = reinterpret_cast<TContext*>(data); - TLineInfo lineInfo{ - .FileName = filename != nullptr ? filename : "???", - .Line = lineno, - .Col = 0, // libbacktrace doesn't provide column numbers, so fill this field with a dummy value. - .FunctionName = function != nullptr ? CppDemangle(function) : "???", - .Address = pc, - .Index = context->Counter++, - }; - return static_cast<int>(context->Callback(lineInfo)); - } - } - - TMaybe<TError> ResolveBacktrace(TArrayRef<const void* const> backtrace, TCallback callback) { - TContext context{.Callback = callback}; - // Intentionally never freed (see https://a.yandex-team.ru/arc/trunk/arcadia/contrib/libs/backtrace/backtrace.h?rev=6789902#L80). - static auto* state = backtrace_create_state( - GetPersistentExecPath().c_str(), - 1 /* threaded */, - HandleLibBacktraceError, - &context /* data for the error callback */ - ); - if (nullptr == state) { - static const auto initError = context.Error; - return initError; - } - for (const void* address : backtrace) { - int status = backtrace_pcinfo( - state, - reinterpret_cast<uintptr_t>(address) - 1, // last byte of the call instruction - HandleLibBacktraceFrame, - HandleLibBacktraceError, - &context /* data for both callbacks */); - if (0 != status) { - break; - } - } - return context.Error; - } -} |