[lldb-dev] How to tell if an address belongs to the heap?

Vangelis Tsiatsianas via lldb-dev lldb-dev at lists.llvm.org
Thu Feb 6 07:40:45 PST 2020


Hi everyone,

I am looking for a way to tell whether a memory address belongs to the heap or not.

In other words, I would like to make sure that the address does not reside within any stack frame (even if the stack of the thread has been allocated in the heap) and that it’s not a global variable or instruction.

Checking whether it is a valid or correctly allocated address or a memory-mapped file or register is not a goal, so accessing it in order to decide, at the risk of causing a segmentation fault, is an accepted solution.

I have been thinking of manually checking the address against the boundaries of each active stack frame, the start and end of the instruction segment and the locations of all global variables.

However, I would like to ask where there are better ways to approach this problem in LLDB.

Thank you very much, advance! πŸ™‚


― Vangelis



More information about the lldb-dev mailing list