X-Git-Url: http://git.joshuawise.com/netwatch.git/blobdiff_plain/923ea2c2cd9df7f02ddcfd8c543f63b76be44660..18a0d8bbdf5091d39ce852c03a2a35000e1e0760:/net/http/fs.c diff --git a/net/http/fs.c b/net/http/fs.c index 54c5bd9..0bf11cb 100644 --- a/net/http/fs.c +++ b/net/http/fs.c @@ -34,12 +34,15 @@ #include "fsdata.h" #include "fsdata.c" #include +#include +#include +#include /*-----------------------------------------------------------------------------------*/ void handle_regs(struct fs_file *file) { - static unsigned char buf[2048]; + static char buf[2048]; sprintf(buf, "Registers" @@ -67,6 +70,50 @@ void handle_regs(struct fs_file *file) file->len = strlen(buf)-1; } +void handle_backtrace(struct fs_file *file) +{ + static char buf[2048]; + static char buf2[64]; + int i = 10; + unsigned long *pebp, *peip; + unsigned long ebp; + unsigned long cr3; + + strcpy(buf, "Backtrace
");
+  ebp = *(unsigned long *)0xAFFE4;
+  cr3 = *(unsigned long *)0xAFFF8;
+  
+  sprintf(buf2, "0x%08x, from\n", *(unsigned long*)0xAFFF0);
+  strcat(buf, buf2);
+  
+  /* I never thought I'd do this again. */
+  while ((peip = demap(cr3, ebp+4)) != 0x0 && i--)
+  {
+    sprintf(buf2, "0x%08x, from\n", *peip);
+    strcat(buf, buf2);
+    pebp = demap(cr3, ebp);
+    if (!pebp)
+    {
+      strcat(buf, "<unreadable %ebp>\n");
+      break;
+    }
+    if (ebp >= *pebp && *pebp)
+    {
+      strcat(buf, "<recursive %ebp>\n");
+      break;
+    }
+    ebp = *pebp;
+  }
+  if (i == -1)
+    strcat(buf, "...\n");
+  else
+    strcat(buf, "<root>");
+  strcat(buf, "
"); + + file->data = buf; + file->len = strlen(buf)-1; +} + void handle_reboot(struct fs_file *file) { outb(0xCF9, 0x4); @@ -87,6 +134,11 @@ fs_open(const char *name, struct fs_file *file) handle_regs(file); return 1; } + if (!strcmp(name, "/backtrace.html")) + { + handle_backtrace(file); + return 1; + } if (!strcmp(name, "/reboot")) { handle_reboot(file);