Question

I would like to access the data from the incoming arguments of the caller function A in function B. Is there is a way to do so?

#define get_caller_incoming_arg(call) 0
void B(int z)
{
    int _arg0  = get_caller_incoming_arg(0);
    printf ("in A(arg0): %x\n", _arg0);
    printf ("in B: %x\n", z);
}

void A(int x)
{
    int buff[10];

    for (int i = 0; i < 10; ++i)
        buff[i] = i + 5;

    B(buff[1]);
}

int main(int argc, const char * argv[])
{
    A(0xdeadbeef);
    return 0;
}

Target machine is x86_64 running OSX and compiler is clang

No correct solution

OTHER TIPS

Try creating a global variable and then pass the argument value to that variable as in the code

#define get_caller_incoming_arg(call) 0
int value=0;
void B(int z)
{
 int _arg0  = get_caller_incoming_arg(0);
 int valueofA=value;
 printf ("in A(arg0): %x\n", _arg0);
 printf ("in B: %x\n", z);
}

void A(int x)
{
 int buff[10];
 value=x;
 for (int i = 0; i < 10; ++i)
    buff[i] = i + 5;

 B(buff[1]);
}

int main(int argc, const char * argv[])
{
  A(0xdeadbeef);
  return 0;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top