dtrace accessing global variables from application
题
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
解决方案
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)
不隶属于 StackOverflow