I'm attempting to modify a MIPS simulator to display the contents of its registers during run time. My question refers to the way in which I plan to do this. So...
I have a file, file1.cpp and file2.cpp. There is a local public variable in file1.cpp called
typedef long ValueGPR;
ValueGPR reg[33];
that I want to access in file2.cpp. Each of these files have a header file. File2.cpp contains a function which iteratively tracks the execution of a program instruction by instruction making this the perfect place to insert a printf("REG[%d]:%d\n",i,reg[i]); statement or something like that but reg is a local variable in file1.cpp. How do I stitch together something that will allow me to access this reg variable?
This is what both files actually look like (after thinking about this a bit more): "File1.h"
typedef long ValueGPR;
...
class ThreadContext {
...
public:
ValueGPR reg[33];
...
...
}
...
"File2.cpp"
...
#include ".../ThreadContext.h"
...
long ExecutionFlow::exeInst(void) {
...
//ADD PRINTF OF reg[1] - reg[32] HERE
...
}
...