0.9.11.17
authorRudi Schlatte <rudi@constantly.at>
Fri, 7 Apr 2006 08:47:14 +0000 (08:47 +0000)
committerRudi Schlatte <rudi@constantly.at>
Fri, 7 Apr 2006 08:47:14 +0000 (08:47 +0000)
  Merge patch "Backtrace on Win32" (sbcl-devel 2006-01-14) (Alastair
  Bridgewater)

NEWS
src/runtime/x86-win32-os.c
version.lisp-expr

diff --git a/NEWS b/NEWS
index 2505dde..8baeaae 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ changes in sbcl-0.9.12 relative to sbcl-0.9.11:
        directory (thanks to Yaroslav Kavenchuk)
     ** run-program is implemented (thanks to Mike Thomas)
     ** sockets support (thanks to Timothy Ritchey)
+    ** better backtrace support (thanks to Alastair Bridgewater)
   * new feature: command line options --no-sysinit, --no-userinit to
     inhibit loading the corresponding init files
   * bug fix: LISTEN sometimes returned T even in cases where no data was
index ada97e3..c07d1db 100644 (file)
@@ -44,34 +44,45 @@ size_t os_vm_page_size;
 
 int arch_os_thread_init(struct thread *thread) {
     {
-        //unsigned long cur_stack_base;
-        //unsigned long cur_stack_end;
+       void *top_exception_frame;
         void *cur_stack_end;
-
-        //asm volatile ("movl %%fs:8,%0": "=r" (cur_stack_base));
-        //      asm volatile ("movl %%fs:4,%0": "=r" (cur_stack_end));
-
-        asm volatile ("movl %%fs:0,%0": "=r" (cur_stack_end));
-
-        //      fprintf(stderr, "#x%08lx #x%08lx.\n", cur_stack_base, cur_stack_end);
-
-        //if (cur_stack_base > thread->control_stack_start) {
-        //    cur_stack_base = thread->control_stack_start;
-        //}
-
-        //if (cur_stack_end < thread->control_stack_end) {
-        //    cur_stack_end = thread->control_stack_end;
-        //}
-
-        //      fprintf(stderr, "#x%08lx #x%08lx.\n", cur_stack_base, cur_stack_end);
-        //fflush(stderr);
-
-        //getchar();
-
-        //asm volatile ("movl %0,%%fs:8": : "r" (cur_stack_base));
-        //asm volatile ("movl %0,%%fs:4": : "r" (cur_stack_end));
-
-        thread->control_stack_end = cur_stack_end;
+       void *cur_stack_start;
+
+        asm volatile ("movl %%fs:0,%0": "=r" (top_exception_frame));
+        asm volatile ("movl %%fs:4,%0": "=r" (cur_stack_end));
+
+       /*
+        * Can't pull stack start from fs:4 or fs:8 or whatever,
+        * because that's only what currently has memory behind
+        * it from being used. Our basic options are to know,
+        * a priori, what the stack size is (1 meg by default)
+        * or to grub the default size out of the executable
+        * header in memory by means of hardcoded addresses and
+        * offsets.
+        *
+        * We'll just assume it's 1 megabyte. Easiest that way.
+        */
+       cur_stack_start = cur_stack_end - 0x100000;
+
+       /*
+        * We use top_exception_frame rather than cur_stack_end
+        * to elide the last few (boring) stack entries at the
+        * bottom of the backtrace.
+        */
+       thread->control_stack_start = cur_stack_start;
+        thread->control_stack_end = top_exception_frame;
+
+#ifndef LISP_FEATURE_SB_THREAD
+       /*
+        * Theoretically, threaded SBCL binds directly against
+        * the thread structure for these values. We don't do
+        * threads yet, but we'll probably do the same. We do
+        * need to reset these, though, because they were
+        * initialized based on the wrong stack space.
+        */
+       SetSymbolValue(CONTROL_STACK_START,(lispobj)thread->control_stack_start,thread);
+       SetSymbolValue(CONTROL_STACK_END,(lispobj)thread->control_stack_end,thread);
+#endif
     }
 
 #ifdef LISP_FEATURE_SB_THREAD
index 4a43654..cfae898 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.11.16"
+"0.9.11.17"