1 //==========================================================================
5 // Support aribtrary set of breakpoints.
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
44 // Contributors: gthomas
50 //####DESCRIPTIONEND####
52 //=========================================================================
56 #ifndef USE_ECOS_HAL_BREAKPOINTS
66 #include "stub-tservice.h"
71 static struct bp *last_bp_ptr;
72 static struct bp *first_bp_ptr;
75 static struct bp *free_bp_list;
76 static struct bp bp_list[MAX_NUM_BP];
77 static int curr_bp_num;
81 add_mon_breakpoint (mem_addr_t location)
84 struct bp *new_bp_ptr;
86 for (ptr = first_bp_ptr; ptr != NULL; ptr = ptr->next)
88 if (MEM_ADDR_EQ_P (ptr->address, location))
92 if (free_bp_list != NULL)
94 new_bp_ptr = free_bp_list;
95 free_bp_list = new_bp_ptr->next;
99 if (curr_bp_num < MAX_NUM_BP)
101 new_bp_ptr = &bp_list[curr_bp_num++];
105 xprintf ("No more breakpoints\n");
110 new_bp_ptr = (struct bp *)malloc (sizeof (struct bp));
113 if (first_bp_ptr == NULL)
115 first_bp_ptr = new_bp_ptr;
119 last_bp_ptr->next = new_bp_ptr;
121 last_bp_ptr = new_bp_ptr;
123 last_bp_ptr->next = NULL;
124 last_bp_ptr->address = location;
125 last_bp_ptr->in_memory = 0;
131 install_breakpoints (void)
133 struct bp *ptr = first_bp_ptr;
136 set_breakpoint (ptr);
143 clear_breakpoints (void)
145 struct bp *ptr = first_bp_ptr;
149 clear_breakpoint (ptr);
155 show_breakpoints (void)
159 for (ptr = first_bp_ptr; ptr != NULL; ptr = ptr->next)
163 addr2str (&ptr->address, buf);
164 xprintf ("%s\n", buf);
173 clear_mon_breakpoint (mem_addr_t location)
176 struct bp *ptr = first_bp_ptr;
177 struct bp *prev_ptr = NULL;
179 /* Scan the list looking for the address to clear */
180 while (ptr != NULL && !MEM_ADDR_EQ_P (ptr->address, location))
182 /* keep a pointer one behind the current position */
188 xprintf ("That address has no breakpoint on it.\n");
193 /* Just in case it's still in memory. */
194 clear_breakpoint (ptr);
196 /* now we'll point the previous bp->next at the one after the one
197 we're deleting, unless there is no previous bp. */
198 if (prev_ptr != NULL)
200 prev_ptr->next = ptr->next;
203 if (first_bp_ptr == ptr)
204 first_bp_ptr = ptr->next;
206 if (last_bp_ptr == ptr)
207 last_bp_ptr = prev_ptr;
209 /* eliminate the offending bp struct */
211 ptr->next = free_bp_list;
220 #endif /* USE_ECOS_HAL_BREAKPOINTS */