Skip to content

Commit d44964d

Browse files
authored
Merge 9cd4dc6 into b0ad121
2 parents b0ad121 + 9cd4dc6 commit d44964d

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

ydb/core/mon_alloc/tcmalloc.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55
#include <ydb/library/actors/prof/tag.h>
66
#include <library/cpp/cache/cache.h>
7-
#include <library/cpp/dwarf_backtrace/backtrace.h>
7+
8+
#if defined(USE_DWARF_BACKTRACE)
9+
# include <library/cpp/dwarf_backtrace/backtrace.h>
10+
#endif
11+
812
#include <library/cpp/html/pcdata/pcdata.h>
913
#include <library/cpp/monlib/service/pages/templates.h>
1014

@@ -207,6 +211,7 @@ class TAllocationAnalyzer {
207211
bool Prepared = false;
208212

209213
private:
214+
#if defined(USE_DWARF_BACKTRACE)
210215
void PrintBackTrace(IOutputStream& out, void* const* stack, size_t size, const char* sep) {
211216
// TODO: ignore symbol cache for now - because of inlines.
212217
if (auto error = NDwarf::ResolveBacktrace(TArrayRef<const void* const>(stack, size), [&](const NDwarf::TLineInfo& info) {
@@ -219,6 +224,28 @@ class TAllocationAnalyzer {
219224
out << sep;
220225
}
221226
}
227+
#else
228+
void PrintBackTrace(IOutputStream& out, void* const* stack, size_t sz, const char* sep) {
229+
char name[1024];
230+
for (size_t i = 0; i < sz; ++i) {
231+
TSymbol symbol;
232+
auto it = SymbolCache.Find(stack[i]);
233+
if (it != SymbolCache.End()) {
234+
symbol = it.Value();
235+
} else {
236+
TResolvedSymbol rs = ResolveSymbol(stack[i], name, sizeof(name));
237+
symbol = {rs.NearestSymbol, rs.Name};
238+
SymbolCache.Insert(stack[i], symbol);
239+
}
240+
241+
out << Hex((intptr_t)stack[i], HF_FULL) << " " << symbol.Name;
242+
intptr_t offset = (intptr_t)stack[i] - (intptr_t)symbol.Address;
243+
if (offset)
244+
out << " +" << offset;
245+
out << sep;
246+
}
247+
}
248+
#endif
222249

223250
void PrintSample(IOutputStream& out, const tcmalloc::Profile::Sample* sample,
224251
const char* sep) const

ydb/core/mon_alloc/ya.make

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ SRCS(
1414
tcmalloc.cpp
1515
)
1616

17+
IF (OS_LINUX AND ARCH_X86_64)
18+
CFLAGS(
19+
-DUSE_DWARF_BACKTRACE
20+
)
21+
PEERDIR(
22+
library/cpp/dwarf_backtrace
23+
)
24+
ENDIF()
25+
1726
PEERDIR(
1827
contrib/libs/tcmalloc/malloc_extension
19-
library/cpp/dwarf_backtrace
2028
library/cpp/html/pcdata
2129
library/cpp/lfalloc/alloc_profiler
2230
library/cpp/lfalloc/dbg_info

0 commit comments

Comments
 (0)