Can anybody please tell me what is the difference b/w the two types of stacks.
If I see /proc/<pid>/map and proc/pid/task/<tid> I see same map. Is there a way we can see the stack belonging to thread exclusively (I mean not the stack of process thread) or if there is any gdb command to find out thread specific stack.
Thanks,
Kapil
There is no such thing: all the threads share the entire address space, so the stack doesn’t “belong exclusively” to any given thread. In fact, you can take an address of a local variable, and pass that address to a different thread, which can then read or write values to it.
What I believe you are asking is “how to tell which memory region in
/proc/<pid>/mapsis thread X currently using as its stack?”. If that’s the question, you canprint $spto find out current stack pointer for the thread you are interested in, and then find a region in/proc/<pid>/mapsthat overlaps$sp.