* src/vm/jit/patcher-common.cpp (patcher_list_show): Supports above task.
* src/vm/jit/patcher-common.hpp: Likewise.
* src/vm/global.h (PRINTF_FORMAT_INTPTR_T): Added very useful define.
/* Define printf formats which change size between 32- and 64-bit. */
#if SIZEOF_VOID_P == 8
+# define PRINTF_FORMAT_INTPTR_T "0x%016lx"
# define PRINTF_FORMAT_INT64_T "%ld"
#else
+# define PRINTF_FORMAT_INTPTR_T "0x%08lx"
# define PRINTF_FORMAT_INT64_T "%lld"
#endif
}
+/**
+ * Show the content of the whole patcher reference list for
+ * debugging purposes.
+ *
+ * @param code The codeinfo containing the patcher list.
+ */
+#if !defined(NDEBUG)
+void patcher_list_show(codeinfo *code)
+{
+ for (List<patchref_t>::iterator it = code->patchers->begin(); it != code->patchers->end(); it++) {
+ patchref_t& pr = *it;
+
+ // Lookup name in patcher function list.
+ patcher_function_list_t* l;
+ for (l = patcher_function_list; l->patcher != NULL; l++)
+ if (l->patcher == pr.patcher)
+ break;
+
+ // Display information about patcher.
+ printf("\tpatcher pc:"PRINTF_FORMAT_INTPTR_T, pr.mpc);
+ printf(" datap:"PRINTF_FORMAT_INTPTR_T, pr.datap);
+ printf(" ref:"PRINTF_FORMAT_INTPTR_T, (intptr_t) pr.ref);
+#if PATCHER_CALL_SIZE == 4
+ printf(" mcode:%08x", (uint32_t) pr.mcode);
+#elif PATCHER_CALL_SIZE == 2
+ printf(" mcode:%04x", (uint16_t) pr.mcode);
+#else
+# error Unknown PATCHER_CALL_SIZE
+#endif
+ printf(" type:%s\n", l->name);
+
+ // Display machine code of patched position.
+#if 0 && defined(ENABLE_DISASSEMBLER)
+ printf("\t\tcurrent -> ");
+ disassinstr((uint8_t*) pr.mpc);
+ printf("\t\tapplied -> ");
+ disassinstr((uint8_t*) &(pr.mcode));
+#endif
+ }
+}
+#endif
+
+
/* patcher_add_patch_ref *******************************************************
Appends a new patcher reference to the list of patching positions.
void patcher_list_reset(codeinfo *code);
void patcher_list_free(codeinfo *code);
+#if !defined(NDEBUG)
+void patcher_list_show(codeinfo *code);
+#endif
+
void patcher_add_patch_ref(jitdata *jd, functionptr patcher, void* ref, s4 disp);
void patcher_resolve(jitdata* jd);
}
if (stage >= SHOW_PARSE) {
- printf("Exceptions (Number: %d):\n", jd->exceptiontablelength);
+ printf("Exceptions (number=%d):\n", jd->exceptiontablelength);
for (ex = jd->exceptiontable; ex != NULL; ex = ex->down) {
printf(" L%03d ... ", ex->start->nr );
printf("L%03d = ", ex->end->nr);
int max;
max = rd->memuse;
- printf("Stack slots: (memuse=%d", rd->memuse);
+ printf("Stack slots (memuse=%d", rd->memuse);
if (irstage >= SHOW_CODE) {
printf(", stackframesize=%d", cd->stackframesize);
max = cd->stackframesize;
}
- printf(")\n");
+ printf("):\n");
for (i = 0; i < max; ++i) {
printf(" M%02d = 0x%02x(sp): ", i, i * 8);
for (j = 0; j < jd->vartop; ++j) {
printf("\n");
}
+ if (!code->patchers->empty()) {
+ int number = code->patchers->size();
+ printf("Patcher References (number=%d):\n", number);
+ patcher_list_show(code);
+ printf("\n");
+ }
+
#if defined(ENABLE_REPLACEMENT)
if (code->rplpoints) {
printf("Replacement Points:\n");