GDB (API)
|
00001 /* addrmap.h --- interface to address map data structure. 00002 00003 Copyright (C) 2007-2013 Free Software Foundation, Inc. 00004 00005 This file is part of GDB. 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00019 00020 #ifndef ADDRMAP_H 00021 #define ADDRMAP_H 00022 00023 /* An address map is essentially a table mapping CORE_ADDRs onto GDB 00024 data structures, like blocks, symtabs, partial symtabs, and so on. 00025 An address map uses memory proportional to the number of 00026 transitions in the map, where a CORE_ADDR N is mapped to one 00027 object, and N+1 is mapped to a different object. 00028 00029 Address maps come in two flavors: fixed, and mutable. Mutable 00030 address maps consume more memory, but can be changed and extended. 00031 A fixed address map, once constructed (from a mutable address map), 00032 can't be edited. Both kinds of map are allocated in obstacks. */ 00033 00034 /* The opaque type representing address maps. */ 00035 struct addrmap; 00036 00037 /* Create a mutable address map which maps every address to NULL. 00038 Allocate entries in OBSTACK. */ 00039 struct addrmap *addrmap_create_mutable (struct obstack *obstack); 00040 00041 /* In the mutable address map MAP, associate the addresses from START 00042 to END_INCLUSIVE that are currently associated with NULL with OBJ 00043 instead. Addresses mapped to an object other than NULL are left 00044 unchanged. 00045 00046 As the name suggests, END_INCLUSIVE is also mapped to OBJ. This 00047 convention is unusual, but it allows callers to accurately specify 00048 ranges that abut the top of the address space, and ranges that 00049 cover the entire address space. 00050 00051 This operation seems a bit complicated for a primitive: if it's 00052 needed, why not just have a simpler primitive operation that sets a 00053 range to a value, wiping out whatever was there before, and then 00054 let the caller construct more complicated operations from that, 00055 along with some others for traversal? 00056 00057 It turns out this is the mutation operation we want to use all the 00058 time, at least for now. Our immediate use for address maps is to 00059 represent lexical blocks whose address ranges are not contiguous. 00060 We walk the tree of lexical blocks present in the debug info, and 00061 only create 'struct block' objects after we've traversed all a 00062 block's children. If a lexical block declares no local variables 00063 (and isn't the lexical block for a function's body), we omit it 00064 from GDB's data structures entirely. 00065 00066 However, this means that we don't decide to create a block (and 00067 thus record it in the address map) until after we've traversed its 00068 children. If we do decide to create the block, we do so at a time 00069 when all its children have already been recorded in the map. So 00070 this operation --- change only those addresses left unset --- is 00071 actually the operation we want to use every time. 00072 00073 It seems simpler to let the code which operates on the 00074 representation directly deal with the hair of implementing these 00075 semantics than to provide an interface which allows it to be 00076 implemented efficiently, but doesn't reveal too much of the 00077 representation. */ 00078 void addrmap_set_empty (struct addrmap *map, 00079 CORE_ADDR start, CORE_ADDR end_inclusive, 00080 void *obj); 00081 00082 /* Return the object associated with ADDR in MAP. */ 00083 void *addrmap_find (struct addrmap *map, CORE_ADDR addr); 00084 00085 /* Create a fixed address map which is a copy of the mutable address 00086 map ORIGINAL. Allocate entries in OBSTACK. */ 00087 struct addrmap *addrmap_create_fixed (struct addrmap *original, 00088 struct obstack *obstack); 00089 00090 /* Relocate all the addresses in MAP by OFFSET. (This can be applied 00091 to either mutable or immutable maps.) */ 00092 void addrmap_relocate (struct addrmap *map, CORE_ADDR offset); 00093 00094 /* The type of a function used to iterate over the map. 00095 OBJ is NULL for unmapped regions. */ 00096 typedef int (*addrmap_foreach_fn) (void *data, CORE_ADDR start_addr, 00097 void *obj); 00098 00099 /* Call FN, passing it DATA, for every address in MAP, following an 00100 in-order traversal. If FN ever returns a non-zero value, the 00101 iteration ceases immediately, and the value is returned. 00102 Otherwise, this function returns 0. */ 00103 int addrmap_foreach (struct addrmap *map, addrmap_foreach_fn fn, void *data); 00104 00105 #endif /* ADDRMAP_H */