Reputation: 4903
I am debugging a program which is seg faulting. I want to know which memory space (heap, stack, etc) the pointer belongs. Is there any way to determine this in gdb?
Upvotes: 1
Views: 637
Reputation: 213526
which memory space (heap, stack, etc)
Note that on any modern multithreaded system, there are many stack regions (one or more for each thread), and often many heap regions as well (e.g. glibc malloc will use sbrk
and mmap
to obtain memory pages from the OS. These pages will form disjoint sets).
Is there any way to determine this in gdb
In general, no. On Linux, you can examine /proc/<pid>/maps
and find a region that overlaps your pointer. GDB does not have any special commands to help you.
Upvotes: 5