- sprintf(buf,
- "<html><head><title>Registers</title></head><body>"
- "<p>At the time you requested this page, the system's registers were:</p>"
- "<tt><pre>"
- "%%eax: 0x%08x %%ebx: 0x%08x %%ecx: 0x%08x %%edx: 0x%08x\n"
- "%%ebp: 0x%08x %%esi: 0x%08x %%edi: 0x%08x %%esp: 0x%08x\n"
- "%%cr0: 0x%08x %%cr3: 0x%08x %%eip: 0x%08x %%eflags: 0x%08x\n"
- "</pre></tt></body></html>",
- *(unsigned long*)0xAFFD0,
- *(unsigned long*)0xAFFDC,
- *(unsigned long*)0xAFFD4,
- *(unsigned long*)0xAFFD8,
- *(unsigned long*)0xAFFE4,
- *(unsigned long*)0xAFFE8,
- *(unsigned long*)0xAFFEC,
- *(unsigned long*)0xAFFE0,
- *(unsigned long*)0xAFFFC,
- *(unsigned long*)0xAFFF8,
- *(unsigned long*)0xAFFF0,
- *(unsigned long*)0xAFFF4);
-
+ bp = state_get_reg(STATE_REG_RBP);
+
+ /* I never thought I'd do this again. */
+ while ((peip = demap(bp+(longmode?8:4))) != 0x0 && i--)
+ {
+ if (longmode) {
+ next = *(uint64_t *)peip;
+ len += snprintf(buf + len, LEFT, "0x%08x%08x, from\n", (uint32_t)(next >> 32), (uint32_t)next);
+ } else {
+ next = *(uint32_t *)peip;
+ len += snprintf(buf + len, LEFT, "0x%08x, from\n", (uint32_t)next);
+ }
+
+ pebp = demap(bp);
+
+ if (!pebp)
+ {
+ len += snprintf(buf + len, LEFT, "<unreadable frame>\n");
+ break;
+ }
+
+ if (longmode)
+ next = *(uint64_t *)pebp;
+ else
+ next = *(uint32_t *)pebp;
+
+ if (bp >= next && next)
+ {
+ len += snprintf(buf + len, LEFT, "<recursive frame>\n");
+ break;
+ }
+
+ bp = next;
+ }
+
+ if (i == -1)
+ len += snprintf(buf + len, LEFT, "...\n");
+ else
+ len += snprintf(buf + len, LEFT, "<root>");
+
+ len += snprintf(buf + len, LEFT, "</pre></tt></body></html>");