Skip to content

Instantly share code, notes, and snippets.

@Rayer
Last active August 29, 2015 14:02
Show Gist options
  • Save Rayer/7ba704f442fa10bc326d to your computer and use it in GitHub Desktop.
Save Rayer/7ba704f442fa10bc326d to your computer and use it in GitHub Desktop.
Get argument using function frame
#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