public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Constify notif_client
@ 2023-01-20 18:00 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2023-01-20 18:00 UTC (permalink / raw)
  To: gdb-cvs

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

commit 42938c1a5b84207e9b6526e56d8e57e1ad3bab5f
Author: Tom Tromey <tromey@adacore.com>
Date:   Wed Dec 21 14:15:16 2022 -0700

    Constify notif_client
    
    It seems to me that a notif_client is read-only, so this patch changes
    the code to use "const" everywhere.

Diff:
---
 gdb/remote-notif.c | 12 ++++++------
 gdb/remote-notif.h | 16 ++++++++--------
 gdb/remote.c       | 22 +++++++++++-----------
 gdb/remote.h       |  2 +-
 4 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index b39f6dff1c7..dfa1d33a7e1 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -46,7 +46,7 @@ bool notif_debug = false;
 
 /* Supported clients of notifications.  */
 
-static struct notif_client *notifs[] =
+static const notif_client *const notifs[] =
 {
   &notif_client_stop,
 };
@@ -58,7 +58,7 @@ gdb_static_assert (ARRAY_SIZE (notifs) == REMOTE_NOTIF_LAST);
 
 void
 remote_notif_ack (remote_target *remote,
-		  struct notif_client *nc, const char *buf)
+		  const notif_client *nc, const char *buf)
 {
   notif_event_up event = nc->alloc_event ();
 
@@ -74,7 +74,7 @@ remote_notif_ack (remote_target *remote,
 
 struct notif_event *
 remote_notif_parse (remote_target *remote,
-		    struct notif_client *nc, const char *buf)
+		    const notif_client *nc, const char *buf)
 {
   notif_event_up event = nc->alloc_event ();
 
@@ -91,11 +91,11 @@ remote_notif_parse (remote_target *remote,
 
 void
 remote_notif_process (struct remote_notif_state *state,
-		      struct notif_client *except)
+		      const notif_client *except)
 {
   while (!state->notif_queue.empty ())
     {
-      struct notif_client *nc = state->notif_queue.front ();
+      const notif_client *nc = state->notif_queue.front ();
       state->notif_queue.pop_front ();
 
       gdb_assert (nc != except);
@@ -120,7 +120,7 @@ remote_async_get_pending_events_handler (gdb_client_data data)
 void
 handle_notification (struct remote_notif_state *state, const char *buf)
 {
-  struct notif_client *nc;
+  const notif_client *nc;
   size_t i;
 
   for (i = 0; i < ARRAY_SIZE (notifs); i++)
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index 58c57ac40e1..c95e1f6ff14 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -60,19 +60,19 @@ struct notif_client
      function may throw exception if contents in BUF is not the
      expected event.  */
   void (*parse) (remote_target *remote,
-		 struct notif_client *self, const char *buf,
+		 const notif_client *self, const char *buf,
 		 struct notif_event *event);
 
   /* Send field <ack_command> to remote, and do some checking.  If
      something wrong, throw an exception.  */
   void (*ack) (remote_target *remote,
-	       struct notif_client *self, const char *buf,
+	       const notif_client *self, const char *buf,
 	       struct notif_event *event);
 
   /* Check this notification client can get pending events in
      'remote_notif_process'.  */
   int (*can_get_pending_events) (remote_target *remote,
-				 struct notif_client *self);
+				 const notif_client *self);
 
   /* Allocate an event.  */
   notif_event_up (*alloc_event) ();
@@ -95,7 +95,7 @@ struct remote_notif_state
 
   /* Notification queue.  */
 
-  std::list<notif_client *> notif_queue;
+  std::list<const notif_client *> notif_queue;
 
   /* Asynchronous signal handle registered as event loop source for when
      the remote sent us a notification.  The registered callback
@@ -114,20 +114,20 @@ struct remote_notif_state
   struct notif_event *pending_event[REMOTE_NOTIF_LAST] {};
 };
 
-void remote_notif_ack (remote_target *remote, notif_client *nc,
+void remote_notif_ack (remote_target *remote, const notif_client *nc,
 		       const char *buf);
 struct notif_event *remote_notif_parse (remote_target *remote,
-					notif_client *nc,
+					const notif_client *nc,
 					const char *buf);
 
 void handle_notification (struct remote_notif_state *notif_state,
 			  const char *buf);
 
 void remote_notif_process (struct remote_notif_state *state,
-			   struct notif_client *except);
+			   const notif_client *except);
 remote_notif_state *remote_notif_state_allocate (remote_target *remote);
 
-extern struct notif_client notif_client_stop;
+extern const notif_client notif_client_stop;
 
 extern bool notif_debug;
 
diff --git a/gdb/remote.c b/gdb/remote.c
index 0a6e293c095..aaac434bc2b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -844,7 +844,7 @@ public: /* Remote specific methods.  */
   void send_interrupt_sequence ();
   void interrupt_query ();
 
-  void remote_notif_get_pending_events (notif_client *nc);
+  void remote_notif_get_pending_events (const notif_client *nc);
 
   int fetch_register_using_p (struct regcache *regcache,
 			      packet_reg *reg);
@@ -4995,7 +4995,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
 	 mechanism.  */
       if (strcmp (rs->buf.data (), "OK") != 0)
 	{
-	  struct notif_client *notif = &notif_client_stop;
+	  const notif_client *notif = &notif_client_stop;
 
 	  /* remote_notif_get_pending_replies acks this one, and gets
 	     the rest out.  */
@@ -7219,7 +7219,7 @@ remote_target::stop_reply_queue_length ()
 
 static void
 remote_notif_stop_parse (remote_target *remote,
-			 struct notif_client *self, const char *buf,
+			 const notif_client *self, const char *buf,
 			 struct notif_event *event)
 {
   remote->remote_parse_stop_reply (buf, (struct stop_reply *) event);
@@ -7227,7 +7227,7 @@ remote_notif_stop_parse (remote_target *remote,
 
 static void
 remote_notif_stop_ack (remote_target *remote,
-		       struct notif_client *self, const char *buf,
+		       const notif_client *self, const char *buf,
 		       struct notif_event *event)
 {
   struct stop_reply *stop_reply = (struct stop_reply *) event;
@@ -7244,7 +7244,7 @@ remote_notif_stop_ack (remote_target *remote,
 
 static int
 remote_notif_stop_can_get_pending_events (remote_target *remote,
-					  struct notif_client *self)
+					  const notif_client *self)
 {
   /* We can't get pending events in remote_notif_process for
      notification stop, and we have to do this in remote_wait_ns
@@ -7270,7 +7270,7 @@ remote_notif_stop_alloc_reply ()
 
 /* A client of notification Stop.  */
 
-struct notif_client notif_client_stop =
+const notif_client notif_client_stop =
 {
   "Stop",
   "vStopped",
@@ -7290,7 +7290,7 @@ struct notif_client notif_client_stop =
 void
 remote_target::remove_new_fork_children (threads_listing_context *context)
 {
-  struct notif_client *notif = &notif_client_stop;
+  const notif_client *notif = &notif_client_stop;
 
   /* For any threads stopped at a fork event, remove the corresponding
      fork child threads from the CONTEXT list.  */
@@ -7326,7 +7326,7 @@ void
 remote_target::check_pending_events_prevent_wildcard_vcont
   (bool *may_global_wildcard)
 {
-  struct notif_client *notif = &notif_client_stop;
+  const notif_client *notif = &notif_client_stop;
 
   remote_notif_get_pending_events (notif);
   for (auto &event : get_remote_state ()->stop_reply_queue)
@@ -7896,7 +7896,7 @@ Packet: '%s'\n"),
 */
 
 void
-remote_target::remote_notif_get_pending_events (notif_client *nc)
+remote_target::remote_notif_get_pending_events (const notif_client *nc)
 {
   struct remote_state *rs = get_remote_state ();
 
@@ -7934,7 +7934,7 @@ remote_target::remote_notif_get_pending_events (notif_client *nc)
    avoid having to export the whole remote_target class.  */
 
 void
-remote_notif_get_pending_events (remote_target *remote, notif_client *nc)
+remote_notif_get_pending_events (remote_target *remote, const notif_client *nc)
 {
   remote->remote_notif_get_pending_events (nc);
 }
@@ -10058,7 +10058,7 @@ void
 remote_target::kill_new_fork_children (inferior *inf)
 {
   remote_state *rs = get_remote_state ();
-  struct notif_client *notif = &notif_client_stop;
+  const notif_client *notif = &notif_client_stop;
 
   /* Kill the fork child threads of any threads in inferior INF that are stopped
      at a fork event.  */
diff --git a/gdb/remote.h b/gdb/remote.h
index bce271d2419..74366cdbcfb 100644
--- a/gdb/remote.h
+++ b/gdb/remote.h
@@ -78,7 +78,7 @@ extern int remote_register_number_and_offset (struct gdbarch *gdbarch,
 					      int *poffset);
 
 extern void remote_notif_get_pending_events (remote_target *remote,
-					     struct notif_client *np);
+					     const notif_client *np);
 extern bool remote_target_is_non_stop_p (remote_target *t);
 
 /* An abstract class that represents the set of callbacks that are made

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

only message in thread, other threads:[~2023-01-20 18:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-20 18:00 [binutils-gdb] Constify notif_client Tom Tromey

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).