6

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 end of the heap?

3 Answers 3

8

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

2
  • 1
    This will not work on a core dump loaded on GDB. In that case maintenance info sections migh help.
    – brokenfoot
    Commented Mar 11, 2016 at 1:23
  • Please add for completeness, that the address space that belongs to stack is titled as [stack] in the last column of the output.
    – Hi-Angel
    Commented Dec 4, 2019 at 7:26
0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.