Last active
August 29, 2015 14:02
-
-
Save Rayer/7ba704f442fa10bc326d to your computer and use it in GitHub Desktop.
Get argument using function frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
using namespace std; | |
int testCall(int a, int b) { | |
void* p = __builtin_frame_address(0); | |
printf("Function pointer frame : %p\n", p); | |
printf("Param a pointer = %p\n", &a); | |
printf("Param b pointer = %p\n", &b); | |
int* i = (int*)p; | |
i--; | |
printf("a = %d, at address : %p\n", *i, i); | |
i--; | |
printf("b = %d, at address : %p\n", *i, i); | |
return 0; | |
} | |
int main(int argc, char *argv[]) { | |
testCall(20, 30); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment