MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CurrentStackTrace

Function CurrentStackTrace

tensorflow/core/platform/default/stacktrace.h:43–75  ·  view source on GitHub ↗

Function to create a pretty stacktrace.

Source from the content-addressed store, hash-verified

41
42// Function to create a pretty stacktrace.
43inline std::string CurrentStackTrace() {
44#if defined(TF_GENERATE_BACKTRACE)
45 std::stringstream ss("");
46 ss << "*** Begin stack trace ***" << std::endl;
47
48 // Get the mangled stack trace.
49 int buffer_size = 128;
50 void* trace[128];
51 buffer_size = backtrace(trace, buffer_size);
52
53 for (int i = 0; i < buffer_size; ++i) {
54 const char* symbol = "";
55 Dl_info info;
56 if (dladdr(trace[i], &info)) {
57 if (info.dli_sname != nullptr) {
58 symbol = info.dli_sname;
59 }
60 }
61
62 std::string demangled = tensorflow::port::MaybeAbiDemangle(symbol);
63 if (demangled.length()) {
64 ss << "\t" << demangled << std::endl;
65 } else {
66 ss << "\t" << symbol << std::endl;
67 }
68 }
69
70 ss << "*** End stack trace ***" << std::endl;
71 return ss.str();
72#else
73 return std::string();
74#endif // defined(TF_GENERATE_BACKTRACE)
75}
76
77inline void DebugWriteToString(const char* data, void* arg) {
78 reinterpret_cast<std::string*>(arg)->append(data);

Callers 13

StackTraceIfVLOG10Function · 0.85
CallStrFunction · 0.85
SynchronizeOrDieFunction · 0.85
SynchronizeContextMethod · 0.85
SynchronizeStreamMethod · 0.85
SynchronizeOrDieFunction · 0.85
SynchronizeContextMethod · 0.85
LogErrorFunction · 0.85
WithLogBacktraceFunction · 0.85
OptimizeMethod · 0.85
WarnIfInCallbackFunction · 0.85
StacktraceHandlerFunction · 0.85

Calls 2

MaybeAbiDemangleFunction · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected