Index: include/parrot/pobj.h =================================================================== --- include/parrot/pobj.h (revision 35601) +++ include/parrot/pobj.h (working copy) @@ -55,13 +55,36 @@ #define PObj_bufstart(pmc) (pmc)->cache._b._bufstart #define PObj_buflen(pmc) (pmc)->cache._b._buflen +#if 0 #define PMC_struct_val(pmc) (pmc)->cache._ptrs._struct_val #define PMC_pmc_val(pmc) (pmc)->cache._ptrs._pmc_val #define PMC_int_val(pmc) (pmc)->cache._i._int_val #define PMC_int_val2(pmc) (pmc)->cache._i._int_val2 #define PMC_num_val(pmc) (pmc)->cache._num_val #define PMC_str_val(pmc) (pmc)->cache._string_val +#else +#define PMC_struct_val(pmc) (((PMC**)pmc)[ instrumenting_func( (long*) &((pmc)->cache._ptrs._struct_val) - (long*)pmc, __LINE__, __FILE__, "PMC_struct_val", WHOAMI(pmc)) ]) +#define PMC_pmc_val(pmc) (((PMC**)pmc)[ instrumenting_func( (long*) &((pmc)->cache._ptrs._pmc_val) - (long*)pmc, __LINE__, __FILE__, "PMC_pmc_val", WHOAMI(pmc)) ]) +#define PMC_int_val(pmc) (((INTVAL*)pmc)[ instrumenting_func( (long*) &((pmc)->cache._i._int_val) - (long*)pmc, __LINE__, __FILE__, "PMC_int_val", WHOAMI(pmc)) ]) +#define PMC_int_val2(pmc) (((INTVAL*)pmc)[ instrumenting_func( (long*) &((pmc)->cache._i._int_val2) - (long*)pmc, __LINE__, __FILE__, "PMC_int_val2", WHOAMI(pmc)) ]) +#define PMC_num_val(pmc) (((FLOATVAL*)pmc)[ instrumenting_func( (long*) &((pmc)->cache._num_val) - (long*)pmc, __LINE__, __FILE__, "PMC_num_val", WHOAMI(pmc)) ]) +#define PMC_str_val(pmc) (((STRING**)pmc)[ instrumenting_func( (long*) &((pmc)->cache._string_val) - (long*)pmc, __LINE__, __FILE__, "PMC_str_val", WHOAMI(pmc)) ]) + +#define WHOAMI(pmc) ( \ + ((PMC*)pmc)->vtable != 0xDEADBEEF ? \ + ((PMC*)pmc)->vtable->whoami->strstart \ + :NULL ) + +static inline int instrumenting_func(int, int, const char*, const char*, const char*); +static inline int instrumenting_func(int ptr, int line, const char *file, const char *macro, const char *pmc_name) { + FILE *f = fopen("/tmp/parrot_macro_log","a"); + fprintf(f, "%s used in %s, %s, line %d\n", pmc_name, macro, file, line); + fclose(f); + return ptr; +} + +#endif /* See src/gc/resources.c. the basic idea is that buffer memory is set up as follows: +-----------------+