home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / microcode / bkpt.c < prev    next >
C/C++ Source or Header  |  1999-01-02  |  3KB  |  100 lines

  1. /* -*-C-*-
  2.  
  3. $Id: bkpt.c,v 9.30 1999/01/02 06:11:34 cph Exp $
  4.  
  5. Copyright (c) 1987-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. /* This file contains breakpoint utilities.
  23.    Disabled when not debugging the interpreter. */
  24.  
  25. #include "scheme.h"
  26.  
  27. #ifdef ENABLE_DEBUGGING_FLAGS
  28.  
  29. #define sp_nil ((struct sp_record *) 0)
  30.  
  31. sp_record_list SP_List = sp_nil;
  32.  
  33. extern Boolean EXFUN (Add_a_Pop_Return_Breakpoint, (SCHEME_OBJECT *));
  34.  
  35. static struct sp_record One_Before =
  36. {
  37.   ((SCHEME_OBJECT *) 0),
  38.   sp_nil
  39. };
  40.  
  41. Boolean
  42. DEFUN (Add_a_Pop_Return_Breakpoint, (SP), SCHEME_OBJECT * SP)
  43. {
  44.   sp_record_list old = SP_List;
  45.   SP_List = ((sp_record_list) (malloc (sizeof(struct sp_record))));
  46.  
  47.   if (SP_List == sp_nil)
  48.   {
  49.     fprintf (stderr, "Could not allocate a breakpoint structure\n");
  50.     SP_List = old;
  51.     return false;
  52.   }
  53.   SP_List->sp = SP;
  54.   SP_List->next = old;
  55.   One_Before.next = SP_List;
  56.   return (true);
  57. }
  58.  
  59. /* A breakpoint can be placed here from a C debugger to examine
  60.    the state of the world. */
  61.  
  62. extern Boolean EXFUN (Print_One_Continuation_Frame, (SCHEME_OBJECT));
  63.  
  64. void
  65. DEFUN_VOID (Handle_Pop_Return_Break)
  66. {
  67.   SCHEME_OBJECT *Old_Stack = Stack_Pointer;
  68.  
  69.   printf ("Pop Return Break: SP = 0x%lx\n", ((long) Stack_Pointer));
  70.   (void) (Print_One_Continuation_Frame (Return));
  71.   Stack_Pointer = Old_Stack;
  72.   return;
  73. }
  74.  
  75. void
  76. DEFUN_VOID (Pop_Return_Break_Point)
  77. {
  78.   fast SCHEME_OBJECT *SP = Stack_Pointer;
  79.   fast sp_record_list previous = &One_Before;
  80.   fast sp_record_list this = previous->next; /* = SP_List */
  81.  
  82.   for ( ;
  83.        this != sp_nil;
  84.        previous = this, this = this->next)
  85.   {
  86.     if (this->sp == SP)
  87.     {
  88.       Handle_Pop_Return_Break ();
  89.       previous->next = this->next;
  90.       break;
  91.     }
  92.   }
  93.   SP_List = One_Before.next;
  94.   return;
  95. }
  96.  
  97. #else
  98. /* Not ENABLE_DEBUGGING_FLAGS */
  99. #endif
  100.