MCPcopy Create free account
hub / github.com/bombela/backward-cpp / load_thread_info

Method load_thread_info

backward.hpp:738–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736
737protected:
738 void load_thread_info() {
739#ifdef BACKWARD_SYSTEM_LINUX
740#ifndef __ANDROID__
741 _thread_id = static_cast<size_t>(syscall(SYS_gettid));
742#else
743 _thread_id = static_cast<size_t>(gettid());
744#endif
745 if (_thread_id == static_cast<size_t>(getpid())) {
746 // If the thread is the main one, let's hide that.
747 // I like to keep little secret sometimes.
748 _thread_id = 0;
749 }
750#elif defined(BACKWARD_SYSTEM_DARWIN)
751 _thread_id = reinterpret_cast<size_t>(pthread_self());
752 if (pthread_main_np() == 1) {
753 // If the thread is the main one, let's hide that.
754 _thread_id = 0;
755 }
756#endif
757 }
758
759 void set_context(void *context) { _context = context; }
760 void *context() const { return _context; }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected