public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: constify addrmap_find
@ 2022-04-28  2:40 Simon Marchi
  0 siblings, 0 replies; only message in thread
From: Simon Marchi @ 2022-04-28  2:40 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bad9471aab31d1b5aa733b8985b8e40e2a97b8e7

commit bad9471aab31d1b5aa733b8985b8e40e2a97b8e7
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Wed Apr 20 17:18:57 2022 -0400

    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:
---
 gdb/addrmap.c | 16 ++++++++--------
 gdb/addrmap.h |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

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.  */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-28  2:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28  2:40 [binutils-gdb] gdb: constify addrmap_find Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).