Category : thread-local-storage

cppreference states the following on thread_local variables The storage for the object is allocated when the thread begins and deallocated when the thread ends. Each thread has its own instance of the object. Only objects declared thread_local have this storage duration. I think of using a thread_local static member variable declared inside a shared library ..

Read more

I’m trying to add a tls callback function that change the value of a variable. I tried things that I saw in google like: static int a = 0; void NTAPI tls_callback(void* DllHandle, DWORD Reason, void* Reserved) { a = 1; } #pragma comment (linker, "/INCLUDE:__tls_used") #pragma comment (linker, "/INCLUDE:__xl_b") #pragma data_seg(".CRT$XLB") EXTERN_C PIMAGE_TLS_CALLBACK _xl_b ..

Read more

I’m trying to add a tls callback function that prints something to the screen. I tried things that I saw in google like: about TLS Callback in windows http://lallouslab.net/2017/05/30/using-cc-tls-callbacks-in-visual-studio-with-your-32-or-64bits-programs/ https://gist.github.com/merces/1336cd4739cb1368efed but nothing work. I’m using MinGW windows. Is that because there are already callbacks by default when I compile with MinGW? What can I do? ..

Read more

Given the following source code: namespace EventThreadLocal { static thread_local std::unique_ptr<std::vector<EventInfo>> Stack; static const EventInfo* Top() { auto stack = Stack.get(); if (!stack) return nullptr; if (stack->empty()) return nullptr; return &(stack->back()); } } How can I inspect the contents of the static thread_local variable Stack on a heap dump? My understanding is that the command ..

Read more