| 1 | /* Address ranges. |
| 2 | Copyright (C) 1998-2019 Free Software Foundation, Inc. |
| 3 | Contributed by Cygnus Solutions. |
| 4 | |
| 5 | This file is part of the GNU Simulators. |
| 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 3 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU 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, see <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | /* This file is meant to be included by sim-basics.h. */ |
| 21 | |
| 22 | #ifndef SIM_ARANGE_H |
| 23 | #define SIM_ARANGE_H |
| 24 | |
| 25 | /* A list of address ranges. */ |
| 26 | |
| 27 | typedef struct _addr_subrange { |
| 28 | struct _addr_subrange *next; |
| 29 | |
| 30 | /* Range of addresses to be traced is [start,end]. */ |
| 31 | address_word start,end; |
| 32 | } ADDR_SUBRANGE; |
| 33 | |
| 34 | /* For speed, searching is done on a tree. */ |
| 35 | |
| 36 | typedef struct _addr_range_tree { |
| 37 | struct _addr_range_tree *lower; |
| 38 | struct _addr_range_tree *higher; |
| 39 | |
| 40 | /* Range of addresses to be traced is [start,end]. */ |
| 41 | address_word start,end; |
| 42 | } ADDR_RANGE_TREE; |
| 43 | |
| 44 | /* The top level struct. */ |
| 45 | |
| 46 | typedef struct _addr_range { |
| 47 | ADDR_SUBRANGE *ranges; |
| 48 | #define ADDR_RANGE_RANGES(ar) ((ar)->ranges) |
| 49 | ADDR_RANGE_TREE *range_tree; |
| 50 | #define ADDR_RANGE_TREE(ar) ((ar)->range_tree) |
| 51 | } ADDR_RANGE; |
| 52 | |
| 53 | /* Add address range START,END to AR. */ |
| 54 | INLINE_SIM_ARANGE (void) sim_addr_range_add (ADDR_RANGE * /*ar*/, |
| 55 | address_word /*start*/, |
| 56 | address_word /*end*/); |
| 57 | |
| 58 | /* Delete address range START,END from AR. */ |
| 59 | INLINE_SIM_ARANGE (void) sim_addr_range_delete (ADDR_RANGE * /*ar*/, |
| 60 | address_word /*start*/, |
| 61 | address_word /*end*/); |
| 62 | |
| 63 | /* Return non-zero if ADDR is in range AR, traversing the entire tree. |
| 64 | If no range is specified, that is defined to mean "everything". */ |
| 65 | INLINE_SIM_ARANGE (int) sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, |
| 66 | address_word /*addr*/); |
| 67 | #define ADDR_RANGE_HIT_P(ar, addr) \ |
| 68 | ((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr))) |
| 69 | |
| 70 | #if H_REVEALS_MODULE_P (SIM_ARANGE_INLINE) |
| 71 | #include "sim-arange.c" |
| 72 | #endif |
| 73 | |
| 74 | #endif /* SIM_ARANGE_H */ |