public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: constify addrmap_find
Date: Thu, 28 Apr 2022 02:40:08 +0000 (GMT)	[thread overview]
Message-ID: <20220428024008.A590F385840C@sourceware.org> (raw)

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


                 reply	other threads:[~2022-04-28  2:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220428024008.A590F385840C@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).