I think you will have to use the built-in assembly for this. The following code stores the current values ββof the base pointer and current pointer in base and current . It is for gcc on a 64 bit machine:
// make these variables global (if not, the stack registers would change) void *base, *current; __asm__("movq %%rbp, %0;" "movq %%rsp, %1;" : "=r"(base), "=r"(current) : : );
If you are on a 32-bit machine, you should use ebp and esp instead of rbp and rsp and movl instead of movq .
I recommend that you check out this built-in compilation for gcc if you have any questions with syntax.
qwertz
source share