From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 8B49F385840E; Fri, 20 Jan 2023 18:00:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8B49F385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674237600; bh=7IXOmXksoWvaKkyMxuma8+tU8XMcgUloUqSY6Ns7JAM=; h=From:To:Subject:Date:From; b=rWP1vjGv0jfzExqFxd7cnjyWYvKtA2JwA4X+Y4AXCIK+Cc8XJsFk19cvp/wueHBBq Xq8yyfkBfh/YrppzJdyiNLMheWU5FC69YbUw7egVHrP4tYBAs5NHgyOvZdjaPEmaeo Iz3ipVlaGi4QWOxHSv3YkWWE2niGI4mZ/4RmIauc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Constify notif_client X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 5a5319833d7bcac780f4a21cf1e72a4c5c67f575 X-Git-Newrev: 42938c1a5b84207e9b6526e56d8e57e1ad3bab5f Message-Id: <20230120180000.8B49F385840E@sourceware.org> Date: Fri, 20 Jan 2023 18:00:00 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D42938c1a5b84= 207e9b6526e56d8e57e1ad3bab5f commit 42938c1a5b84207e9b6526e56d8e57e1ad3bab5f Author: Tom Tromey Date: Wed Dec 21 14:15:16 2022 -0700 Constify notif_client =20 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 =3D false; =20 /* Supported clients of notifications. */ =20 -static struct notif_client *notifs[] =3D +static const notif_client *const notifs[] =3D { ¬if_client_stop, }; @@ -58,7 +58,7 @@ gdb_static_assert (ARRAY_SIZE (notifs) =3D=3D REMOTE_NOTI= F_LAST); =20 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 =3D nc->alloc_event (); =20 @@ -74,7 +74,7 @@ remote_notif_ack (remote_target *remote, =20 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 =3D nc->alloc_event (); =20 @@ -91,11 +91,11 @@ remote_notif_parse (remote_target *remote, =20 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 =3D state->notif_queue.front (); + const notif_client *nc =3D state->notif_queue.front (); state->notif_queue.pop_front (); =20 gdb_assert (nc !=3D except); @@ -120,7 +120,7 @@ remote_async_get_pending_events_handler (gdb_client_dat= a data) void handle_notification (struct remote_notif_state *state, const char *buf) { - struct notif_client *nc; + const notif_client *nc; size_t i; =20 for (i =3D 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); =20 /* Send field 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); =20 /* 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); =20 /* Allocate an event. */ notif_event_up (*alloc_event) (); @@ -95,7 +95,7 @@ struct remote_notif_state =20 /* Notification queue. */ =20 - std::list notif_queue; + std::list notif_queue; =20 /* 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] {}; }; =20 -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); =20 void handle_notification (struct remote_notif_state *notif_state, const char *buf); =20 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); =20 -extern struct notif_client notif_client_stop; +extern const notif_client notif_client_stop; =20 extern bool notif_debug; =20 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 (); =20 - void remote_notif_get_pending_events (notif_client *nc); + void remote_notif_get_pending_events (const notif_client *nc); =20 int fetch_register_using_p (struct regcache *regcache, packet_reg *reg); @@ -4995,7 +4995,7 @@ remote_target::start_remote_1 (int from_tty, int exte= nded_p) mechanism. */ if (strcmp (rs->buf.data (), "OK") !=3D 0) { - struct notif_client *notif =3D ¬if_client_stop; + const notif_client *notif =3D ¬if_client_stop; =20 /* remote_notif_get_pending_replies acks this one, and gets the rest out. */ @@ -7219,7 +7219,7 @@ remote_target::stop_reply_queue_length () =20 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, =20 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 =3D (struct stop_reply *) event; @@ -7244,7 +7244,7 @@ remote_notif_stop_ack (remote_target *remote, =20 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 () =20 /* A client of notification Stop. */ =20 -struct notif_client notif_client_stop =3D +const notif_client notif_client_stop =3D { "Stop", "vStopped", @@ -7290,7 +7290,7 @@ struct notif_client notif_client_stop =3D void remote_target::remove_new_fork_children (threads_listing_context *context) { - struct notif_client *notif =3D ¬if_client_stop; + const notif_client *notif =3D ¬if_client_stop; =20 /* 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 =3D ¬if_client_stop; + const notif_client *notif =3D ¬if_client_stop; =20 remote_notif_get_pending_events (notif); for (auto &event : get_remote_state ()->stop_reply_queue) @@ -7896,7 +7896,7 @@ Packet: '%s'\n"), */ =20 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 =3D get_remote_state (); =20 @@ -7934,7 +7934,7 @@ remote_target::remote_notif_get_pending_events (notif= _client *nc) avoid having to export the whole remote_target class. */ =20 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 =3D get_remote_state (); - struct notif_client *notif =3D ¬if_client_stop; + const notif_client *notif =3D ¬if_client_stop; =20 /* Kill the fork child threads of any threads in inferior INF that are s= topped 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 gdba= rch *gdbarch, int *poffset); =20 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); =20 /* An abstract class that represents the set of callbacks that are made