MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / getBackTrace

Method getBackTrace

libminifi/src/utils/BackTrace.cpp:124–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124BackTrace TraceResolver::getBackTrace(std::string thread_name, std::thread::native_handle_type thread_handle) {
125 // lock so that we only perform one backtrace at a time.
126#ifdef HAS_EXECINFO
127 std::lock_guard<std::mutex> lock(mutex_);
128 trace_ = BackTrace(std::move(thread_name));
129
130 if (0 == thread_handle || pthread_equal(pthread_self(), thread_handle)) {
131 pull_trace();
132 } else {
133 if (thread_handle == 0) {
134 return std::move(trace_);
135 }
136 emplace_handler();
137 std::unique_lock<std::mutex> ulock(trace_mutex_);
138 if (pthread_kill(thread_handle, SIGUSR2) != 0) {
139 return std::move(trace_);
140 }
141 pull_traces_ = false;
142 trace_condition_.wait(ulock, [this] { return pull_traces_; });
143 }
144#else
145 // even if tracing is disabled, include thread name into the trace object
146 trace_ = BackTrace(std::move(thread_name));
147#endif
148 return std::move(trace_);
149}
150#ifdef HAS_EXECINFO
151void handler(int /*signr*/, siginfo_t* /*info*/, void* /*secret*/) {
152 std::unique_lock<std::mutex> lock(TraceResolver::getResolver().lock());

Callers 2

BackTraceTests.cppFile · 0.45
getTracesMethod · 0.45

Calls 3

BackTraceClass · 0.85
pull_traceFunction · 0.85
emplace_handlerFunction · 0.85

Tested by

no test coverage detected