From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id F1E663858425 for ; Wed, 21 Dec 2022 21:16:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1E663858425 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd2b.google.com with SMTP id z144so63696iof.3 for ; Wed, 21 Dec 2022 13:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6RjujfDhxSH5TPz8uuSh2v3SrG6LU/D1gL5JAeA/fkQ=; b=PPmPa72HcW5Y7ujxeWi0QFrDg0n5BZhCl8OfVGH9sMzDTeCeUrAAA83GH5lrIvWv0b 1o2FZoAuOnFuF0dr2v8EBCPKB8QZH8Zu5wZupWlxlXpp5AneYBTwtVjv9KVADfIVJ3N3 BUoG55BvDXIzxff4kLwFfE2bFaNPGIs09BQkDJSvVFbhc5FJJPmNKEuwbOiCetK3Y1BQ uFwaIQiRZyqzPvd2tiZE0tlmZ4TJjqrB2dNu25/pH1/00UQAlf6lOUuA32HhudRooWvE xTkjLJt9eq4XuGisZ3CjF2bCSgKlwyN90n4Lu1Ya2VGBB4Yc46D2ZhwtaHW+HeFZAzRB 5aQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6RjujfDhxSH5TPz8uuSh2v3SrG6LU/D1gL5JAeA/fkQ=; b=sRi2iAIco/OyVKpT8e2Wk7RwF/647eMcwZmwRf9SPbHjFdVBwf9TcjXvF6Ni4T0YzW K7rdUn7JEb0Q3RtPk8atS1czbwldPOVshqFsUBd/erjULuCVOmLPgEJAsLzafVHKxIeR 3l8tzd+Vwxab11IUAJ5Qs8drjW8zzLm6lgvdDmDXi9d5yejQyB2haViDlyNxOxzyThO/ JD/50JwxisSCluuFpf4rUWarvCHFwmhYIUL8mVOdgzwWoOdMYELDlQo2EZHbx47Q+E4K q8vwc2cnfUslKfeifAv9tlSWE0XH3FMib2CWXS4I83ocTf+7FDIr3rEp48BxfbkRNyFt NEMA== X-Gm-Message-State: AFqh2kosZnQdfJiAYcEM3o3RLvawp6seoMei1o1am5y3osfG3Sokktx0 W6wbGnBiQg/hRPXwA7dQPtduSp8WDRmj1jwz X-Google-Smtp-Source: AMrXdXtcb0ttUc/+QL3Fza0BiBm78Gg0Zgm/gzaj2ZLHaKwJJJbgYuzRW18XqT0zlgXmNiC4dEsgVg== X-Received: by 2002:a05:6602:5cd:b0:6bc:d712:8bcd with SMTP id w13-20020a05660205cd00b006bcd7128bcdmr1817195iox.21.1671657371123; Wed, 21 Dec 2022 13:16:11 -0800 (PST) Received: from localhost.localdomain (97-122-76-186.hlrn.qwest.net. [97.122.76.186]) by smtp.gmail.com with ESMTPSA id u69-20020a022348000000b00392238fe4b2sm3290816jau.133.2022.12.21.13.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 13:16:10 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Constify notif_client Date: Wed, 21 Dec 2022 14:16:01 -0700 Message-Id: <20221221211601.1105076-1-tromey@adacore.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: It seems to me that a notif_client is read-only, so this patch changes the code to use "const" everywhere. --- 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 95b45e3f984..a8f4458c27f 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[] = { ¬if_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 db444b049b0..76287d6ebbd 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 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_queue; + std::list 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 ea968ee0c59..62f99b76beb 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -845,7 +845,7 @@ class remote_target : public process_stratum_target 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); @@ -4996,7 +4996,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p) mechanism. */ if (strcmp (rs->buf.data (), "OK") != 0) { - struct notif_client *notif = ¬if_client_stop; + const notif_client *notif = ¬if_client_stop; /* remote_notif_get_pending_replies acks this one, and gets the rest out. */ @@ -7220,7 +7220,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); @@ -7228,7 +7228,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; @@ -7245,7 +7245,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 @@ -7271,7 +7271,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", @@ -7291,7 +7291,7 @@ struct notif_client notif_client_stop = void remote_target::remove_new_fork_children (threads_listing_context *context) { - struct notif_client *notif = ¬if_client_stop; + const notif_client *notif = ¬if_client_stop; /* For any threads stopped at a fork event, remove the corresponding fork child threads from the CONTEXT list. */ @@ -7327,7 +7327,7 @@ void remote_target::check_pending_events_prevent_wildcard_vcont (bool *may_global_wildcard) { - struct notif_client *notif = ¬if_client_stop; + const notif_client *notif = ¬if_client_stop; remote_notif_get_pending_events (notif); for (auto &event : get_remote_state ()->stop_reply_queue) @@ -7897,7 +7897,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 (); @@ -7935,7 +7935,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); } @@ -10059,7 +10059,7 @@ void remote_target::kill_new_fork_children (inferior *inf) { remote_state *rs = get_remote_state (); - struct notif_client *notif = ¬if_client_stop; + const notif_client *notif = ¬if_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 638ffc2e337..a2d0a0266df 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 -- 2.38.1