0.7.13.5
[sbcl.git] / src / runtime / parse.c
index 99729cd..cb71dc4 100644 (file)
@@ -1,3 +1,5 @@
+/* parsing for LDB monitor */
+
 /*
  * This software is part of the SBCL system. See the README file for
  * more information.
  * files for more information.
  */
 
-/*
- * $Header$
- */
-
 #include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
 
 #include "runtime.h"
 #include "sbcl.h"
+
+#if defined(LISP_FEATURE_SB_LDB)
+
 #include "globals.h"
 #include "vars.h"
 #include "parse.h"
 #include "arch.h"
 #include "search.h"
 
+#include "genesis/simple-fun.h"
+#include "genesis/fdefn.h"
+#include "genesis/symbol.h"
+#include "genesis/static-symbols.h"
+
 static void skip_ws(char **ptr)
 {
     while (**ptr <= ' ' && **ptr != '\0')
@@ -240,23 +246,28 @@ static boolean lookup_symbol(char *name, lispobj *result)
     lispobj *headerptr;
 
     /* Search static space. */
-    headerptr = static_space;
-    count = ((lispobj *) SymbolValue(STATIC_SPACE_FREE_POINTER) -
-            static_space);
+    headerptr = (lispobj *)STATIC_SPACE_START;
+    count =
+       (lispobj *)SymbolValue(STATIC_SPACE_FREE_POINTER) -
+       (lispobj *)STATIC_SPACE_START;
     if (search_for_symbol(name, &headerptr, &count)) {
-        *result = (lispobj)headerptr | type_OtherPointer;
+        *result = make_lispobj(headerptr,OTHER_POINTER_LOWTAG);
         return 1;
     }
 
     /* Search dynamic space. */
-    headerptr = current_dynamic_space;
-#if !defined(ibmrt) && !defined(__i386__)
-    count = current_dynamic_space_free_pointer - current_dynamic_space;
+    headerptr = (lispobj *)DYNAMIC_SPACE_START;
+#if !defined(__i386__)
+    count =
+       dynamic_space_free_pointer -
+       (lispobj *)DYNAMIC_SPACE_START;
 #else
-    count = (lispobj *)SymbolValue(ALLOCATION_POINTER) - current_dynamic_space;
+    count =
+       (lispobj *)SymbolValue(ALLOCATION_POINTER) -
+       (lispobj *)DYNAMIC_SPACE_START;
 #endif
     if (search_for_symbol(name, &headerptr, &count)) {
-        *result = (lispobj)headerptr | type_OtherPointer;
+        *result = make_lispobj(headerptr, OTHER_POINTER_LOWTAG);
         return 1;
     }
 
@@ -266,31 +277,31 @@ static boolean lookup_symbol(char *name, lispobj *result)
 static int
 parse_regnum(char *s)
 {
-       if ((s[1] == 'R') || (s[1] == 'r')) {
-               int regnum;
-
-               if (s[2] == '\0')
-                       return -1;
-
-               /* skip the $R part and call atoi on the number */
-               regnum = atoi(s + 2);
-               if ((regnum >= 0) && (regnum < NREGS))
-                       return regnum;
-               else
-                       return -1;
-       } else {
-               int i;
-
-               for (i = 0; i < NREGS ; i++)
-                       if (strcasecmp(s + 1, lisp_register_names[i]) == 0)
+    if ((s[1] == 'R') || (s[1] == 'r')) {
+       int regnum;
+
+       if (s[2] == '\0')
+           return -1;
+
+       /* skip the $R part and call atoi on the number */
+       regnum = atoi(s + 2);
+       if ((regnum >= 0) && (regnum < NREGS))
+           return regnum;
+       else
+           return -1;
+    } else {
+       int i;
+
+       for (i = 0; i < NREGS ; i++)
+           if (strcasecmp(s + 1, lisp_register_names[i]) == 0)
 #ifdef __i386__
-                               return i*2;
+               return i*2;
 #else
-                               return i;
+       return i;
 #endif
                
-               return -1;
-       }
+       return -1;
+    }
 }
 
 lispobj parse_lispobj(ptr)
@@ -305,26 +316,26 @@ char **ptr;
         throw_to_monitor();
     } else if (token[0] == '$') {
        if (isalpha(token[1])) {
-               int free;
-               int regnum;
-               os_context_t *context;
+           int free;
+           int regnum;
+           os_context_t *context;
 
-               free = SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX)>>2;
+           free = SymbolValue(FREE_INTERRUPT_CONTEXT_INDEX)>>2;
 
-               if (free == 0) {
-                       printf("Variable ``%s'' is not valid -- there is no current interrupt context.\n", token);
-                       throw_to_monitor();
-               }
+           if (free == 0) {
+               printf("Variable ``%s'' is not valid -- there is no current interrupt context.\n", token);
+               throw_to_monitor();
+           }
 
-               context = lisp_interrupt_contexts[free - 1];
+           context = lisp_interrupt_contexts[free - 1];
 
-               regnum = parse_regnum(token);
-               if (regnum < 0) {
-                       printf("bogus register: ``%s''\n", token);
-                       throw_to_monitor();
-               }
+           regnum = parse_regnum(token);
+           if (regnum < 0) {
+               printf("bogus register: ``%s''\n", token);
+               throw_to_monitor();
+           }
 
-               result = *os_context_register_addr(context, regnum);
+           result = *os_context_register_addr(context, regnum);
        } else if (!lookup_variable(token+1, &result)) {
             printf("unknown variable: ``%s''\n", token);
             throw_to_monitor();
@@ -355,3 +366,5 @@ char **ptr;
 
     return result;
 }
+
+#endif /* defined(LISP_FEATURE_SB_LDB) */