Can I find through GDB if the variable belongs to a heap or a stack?

My breakpoint points to a variable. (dots somewhere. Can I find out if there is a heap or stack somewhere?)

is there any way to find where the beginning and end of the stack is? is there any way to find where the beginning and end of the heap?

+4
source share
3 answers

Use info proc mappings for /proc information about your memory layout.

+6
source

I don’t think gdb will tell you directly, but you can compare the addresses to find out what range it falls into. You will need to look at the source code of the library to find ithem, but the heap manager usually has some internal variables to keep track of where the heap is.

0
source

Depending on your compiler, you may have the __stack or __stack_end in the debugging information. If so, you can use these characters to compare your pointer with them.

0
source

Source: https://habr.com/ru/post/1343012/


All Articles