Reputation: 141
In case of Windows OS, Thread Information Block(TIB) contains information regarding the currently executing thread, including addresses of bottom and top of stack. However in Linux, how to get the similar information? Does Thread Specific Data(TSD) help?
Upvotes: 1
Views: 610
Reputation: 609
A program can find the bounds of the memory-mapped region dedicated to the stack by reading the file named /proc/self/maps
. Use the man page for proc
to see how best to read the maps
file. Amongst other things, it gives the start address, end address, permissions and size for each memory region.
You can search for a region containing an address that you know is on the stack. One region will be labelled [stack]
, but I think that only represents the main thread.
Upvotes: 1