From: Simon Marchi Date: Wed, 20 Apr 2022 21:18:57 +0000 (-0400) Subject: gdb: constify addrmap_find X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bad9471aab31d1b5aa733b8985b8e40e2a97b8e7;p=binutils-gdb.git gdb: constify addrmap_find addrmap_find shouldn't need to modify the addrmap, so constify the addrmap parameter. This helps for the following patch, where getting the map of a const blockvector will return a const addrmap. Change-Id: If670e425ed013724a3a77aab7961db50366dccb2 --- diff --git a/gdb/addrmap.c b/gdb/addrmap.c index f88880614ec..8141337e484 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -38,7 +38,7 @@ struct addrmap_funcs void (*set_empty) (struct addrmap *self, CORE_ADDR start, CORE_ADDR end_inclusive, void *obj); - void *(*find) (struct addrmap *self, CORE_ADDR addr); + void *(*find) (const addrmap *self, CORE_ADDR addr); struct addrmap *(*create_fixed) (struct addrmap *self, struct obstack *obstack); void (*relocate) (struct addrmap *self, CORE_ADDR offset); @@ -62,7 +62,7 @@ addrmap_set_empty (struct addrmap *map, void * -addrmap_find (struct addrmap *map, CORE_ADDR addr) +addrmap_find (const addrmap *map, CORE_ADDR addr) { return map->funcs->find (map, addr); } @@ -130,11 +130,11 @@ addrmap_fixed_set_empty (struct addrmap *self, static void * -addrmap_fixed_find (struct addrmap *self, CORE_ADDR addr) +addrmap_fixed_find (const addrmap *self, CORE_ADDR addr) { - struct addrmap_fixed *map = (struct addrmap_fixed *) self; - struct addrmap_transition *bottom = &map->transitions[0]; - struct addrmap_transition *top = &map->transitions[map->num_transitions - 1]; + const addrmap_fixed *map = (const addrmap_fixed *) self; + const addrmap_transition *bottom = &map->transitions[0]; + const addrmap_transition *top = &map->transitions[map->num_transitions - 1]; while (bottom < top) { @@ -142,7 +142,7 @@ addrmap_fixed_find (struct addrmap *self, CORE_ADDR addr) 1 (i.e., two entries are under consideration), then mid == bottom, and then we may not narrow the range when (mid->addr < addr). */ - struct addrmap_transition *mid = top - (top - bottom) / 2; + const addrmap_transition *mid = top - (top - bottom) / 2; if (mid->addr == addr) { @@ -389,7 +389,7 @@ addrmap_mutable_set_empty (struct addrmap *self, static void * -addrmap_mutable_find (struct addrmap *self, CORE_ADDR addr) +addrmap_mutable_find (const addrmap *self, CORE_ADDR addr) { struct addrmap_mutable *map = (struct addrmap_mutable *) self; splay_tree_node n = addrmap_splay_tree_lookup (map, addr); diff --git a/gdb/addrmap.h b/gdb/addrmap.h index 54567fa0d9d..412e4288897 100644 --- a/gdb/addrmap.h +++ b/gdb/addrmap.h @@ -82,7 +82,7 @@ void addrmap_set_empty (struct addrmap *map, void *obj); /* Return the object associated with ADDR in MAP. */ -void *addrmap_find (struct addrmap *map, CORE_ADDR addr); +void *addrmap_find (const addrmap *map, CORE_ADDR addr); /* Create a fixed address map which is a copy of the mutable address map ORIGINAL. Allocate entries in OBSTACK. */