const char* cesk_value_to_string(const cesk_value_t* value, char* buf, int sz) { static char _buf[1024]; if(NULL == value) { return "(nothing)"; } if(NULL == buf) { buf = _buf; sz = sizeof(_buf); } char *p = buf; #define __PR(fmt, args...) do{\ int pret = snprintf(p, buf + sz - p, fmt, ##args);\ if(pret > buf + sz - p) pret = buf + sz - p;\ p += pret;\ }while(0) switch(value->type) { case CESK_TYPE_OBJECT: __PR("(objval (refcnt %d) %s)", value->refcnt ,cesk_object_to_string(value->pointer.object, NULL, 0, 0)); break; case CESK_TYPE_SET: __PR("(setval (refcnt %d) %s)", value->refcnt, cesk_set_to_string(value->pointer.set, NULL, 0)); break; default: __PR("(unknown-val)"); } #undef __PR return buf; }
static inline const char* _cesk_diff_record_to_string(int type, int addr, const void* value, char* buf, int sz) { static char _buf[1024]; if(NULL == buf) { buf = _buf; sz = sizeof(_buf); } char* p = buf; switch(type) { case CESK_DIFF_ALLOC: __PR("(allocate "PRSAddr" %s)", addr, cesk_value_to_string((cesk_value_t*)value, NULL, 0)); break; case CESK_DIFF_DEALLOC: __PR("(deallocate "PRSAddr")", addr); break; case CESK_DIFF_REG: if(CESK_FRAME_REG_IS_STATIC(addr)) __PR("(register f%d %s)", CESK_FRAME_REG_STATIC_IDX(addr), cesk_set_to_string((cesk_set_t*)value, NULL, 0)); else __PR("(register v%d %s)", addr, cesk_set_to_string((cesk_set_t*)value, NULL, 0)); break; case CESK_DIFF_STORE: __PR("(store "PRSAddr" %s)", addr, cesk_value_to_string((cesk_value_t*)value, NULL, 0)); break; case CESK_DIFF_REUSE: __PR("(reuse "PRSAddr" %d)", addr, (value != NULL)); break; default: __PR("(unknown-record)"); } return buf; }
const char* cesk_diff_to_string(const cesk_diff_t* diff, char* buf, int sz) { static char _buf[4096]; if(NULL == buf) { buf = _buf; sz = sizeof(_buf); } char* p = buf; int i; for(i = 0; i < CESK_DIFF_NTYPES; i ++) { __PR("["); int j; for(j = diff->offset[i]; j < diff->offset[i + 1]; j ++) { __PR("%s", _cesk_diff_record_to_string(i, diff->data[j].addr, diff->data[j].arg.generic, NULL, 0)); if(j != diff->offset[i + 1] - 1) __PR(" "); } __PR("]"); } return buf; }
void Globals::print_build_options(void *_st) { Stream *st = (Stream*)_st; st->cr(); st->print_cr("VM build options:"); st->cr(); #define _IS_ENABLED st->print_cr("enabled") #define _IS_DISABLED st->print_cr("-") // IMPL_NOTE: The code in this function can be // simplified if we all switch to the '#if' style of preprocessing // macros, and #define a macro to 0 if it's not defined. __PR(st, "_DEBUG"); #if defined(_DEBUG) _IS_ENABLED; #else _IS_DISABLED; #endif __PR(st, "AZZERT"); #if defined(AZZERT) _IS_ENABLED; #else _IS_DISABLED; #endif { // ENABLE_FLAG_VALUES is defined in the auto-generated jvmconfig.h static const char* enable_flag_values[] = ENABLE_FLAG_VALUES; for (int i=0; i<ARRAY_SIZE(enable_flag_values); i+=2) { const char *name = enable_flag_values[i]; const char *value = enable_flag_values[i+1]; st->print_cr(" %-40s %s", name, value); } } __PR(st, "HARDWARE_LITTLE_ENDIAN"); #if HARDWARE_LITTLE_ENDIAN _IS_ENABLED; #else _IS_DISABLED; #endif __PR(st, "MSW_FIRST_FOR_DOUBLE"); #if MSW_FIRST_FOR_DOUBLE _IS_ENABLED; #else _IS_DISABLED; #endif __PR(st, "MSW_FIRST_FOR_LONG"); #if MSW_FIRST_FOR_LONG _IS_ENABLED; #else _IS_DISABLED; #endif __PR(st, "ROMIZING"); #if ROMIZING _IS_ENABLED; #else _IS_DISABLED; #endif __PR(st, "USE_BSD_SOCKET"); #if USE_BSD_SOCKET _IS_ENABLED; #else _IS_DISABLED; #endif __PR(st, "USE_UNICODE_FOR_FILENAMES"); #if USE_UNICODE_FOR_FILENAMES _IS_ENABLED; #else _IS_DISABLED; #endif #undef _IS_ENABLED #undef _IS_DISABLED }