A more direct, and less intrusive method would be to look up the pointer in the memory region maps (such as /proc//maps). Each thread has a region allocated to its stack. Static and global variables will live in the .bss section, constants in a rodata or const segment, and so on.