can I find via GDB if a variable belong to heap or stack?
My breakpoint points to a variable. (points somewhere. Can I figure out if somewhere belongs to the heap or the stack?)
is there any way to find where is the beginning and the end of the stack? is there any way to find where is the beginning and the 开发者_StackOverflow社区end of the heap?
Use info proc mappings
for /proc
info about your memory layout.
I don't think gdb will tell you directly, but you can compare addresses to figure out what range it falls into. You'd have to look through the library source code to find ithem, but the heap manager will typically have some internal variables to track where the heap is.
Depending on your compiler, you may have a symbol like __stack
or __stack_end
in the debug info. If so, you may use these symbols to compare your pointer against them.
精彩评论