Question

suppose my app code looks like this:

#include <stdio.h>
int global_var;

void change_var(){
    global_var++;
}    

int main(void){
    change_var();
    retrun 0;
}

Now, can You please tell me, if there is any possibilty to access global_var in dtrace script and print it ?

Best regards

Was it helpful?

Solution

You can, but you have to know the variable's address. Your D would resemble

self->kp = (int *) copyin(<address>, sizeof (int));
printf("global_var = 0x%d\n", *self->kp)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top