public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/3] Constify remote_console_output
  2019-01-06 22:46 [PATCH 0/3] Some remote-related constification Tom Tromey
  2019-01-06 22:46 ` [PATCH 1/3] Constify target_pass_signals and target_program_signals Tom Tromey
  2019-01-06 22:46 ` [PATCH 3/3] Constify some remote-notif functions Tom Tromey
@ 2019-01-06 22:46 ` Tom Tromey
  2 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-01-06 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies the parameter to remote_console_output.

2019-01-06  Tom Tromey  <tom@tromey.com>

	* remote.c (remote_console_output): Make parameter const.
---
 gdb/ChangeLog | 4 ++++
 gdb/remote.c  | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gdb/remote.c b/gdb/remote.c
index c40f926376..6b5870a70a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1024,7 +1024,7 @@ static void remote_async_inferior_event_handler (gdb_client_data);
 
 static bool remote_read_description_p (struct target_ops *target);
 
-static void remote_console_output (char *msg);
+static void remote_console_output (const char *msg);
 
 static void remote_btrace_reset (remote_state *rs);
 
@@ -6799,9 +6799,9 @@ remote_target::terminal_ours ()
 }
 
 static void
-remote_console_output (char *msg)
+remote_console_output (const char *msg)
 {
-  char *p;
+  const char *p;
 
   for (p = msg; p[0] && p[1]; p += 2)
     {
-- 
2.17.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/3] Constify some remote-notif functions
  2019-01-06 22:46 [PATCH 0/3] Some remote-related constification Tom Tromey
  2019-01-06 22:46 ` [PATCH 1/3] Constify target_pass_signals and target_program_signals Tom Tromey
@ 2019-01-06 22:46 ` Tom Tromey
  2019-01-06 22:46 ` [PATCH 2/3] Constify remote_console_output Tom Tromey
  2 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-01-06 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies the "buf" arguments to various remote-notif functions
and updates the users.

2019-01-06  Tom Tromey  <tom@tromey.com>

	* remote-notif.c (handle_notification, remote_notif_ack)
	(remote_notif_parse): Make "buf" const.
	* remote-notif.h (struct notif_client) <parse, ack>: Make "buf"
	const.
	(remote_notif_parse, remote_notif_ack, handle_notification):
	Likewise.
	* remote.c (remote_notif_stop_parse): Make "buf" const.
	(remote_target::remote_parse_stop_reply): Make "buf" const.
	(remote_notif_stop_ack): Make "buf" const.
---
 gdb/ChangeLog      | 12 ++++++++++++
 gdb/remote-notif.c |  6 +++---
 gdb/remote-notif.h | 11 ++++++-----
 gdb/remote.c       |  8 ++++----
 4 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index 9ccb5b9120..ae9a94d9c9 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -59,7 +59,7 @@ static void do_notif_event_xfree (void *arg);
 
 void
 remote_notif_ack (remote_target *remote,
-		  struct notif_client *nc, char *buf)
+		  struct notif_client *nc, const char *buf)
 {
   struct notif_event *event = nc->alloc_event ();
   struct cleanup *old_chain
@@ -79,7 +79,7 @@ remote_notif_ack (remote_target *remote,
 
 struct notif_event *
 remote_notif_parse (remote_target *remote,
-		    struct notif_client *nc, char *buf)
+		    struct notif_client *nc, const char *buf)
 {
   struct notif_event *event = nc->alloc_event ();
   struct cleanup *old_chain
@@ -126,7 +126,7 @@ remote_async_get_pending_events_handler (gdb_client_data data)
    update STATE.  */
 
 void
-handle_notification (struct remote_notif_state *state, char *buf)
+handle_notification (struct remote_notif_state *state, const char *buf)
 {
   struct notif_client *nc;
   size_t i;
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index a4a931b4b7..7973ad7fa0 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -55,13 +55,13 @@ typedef 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, char *buf,
+		 struct 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, char *buf,
+	       struct notif_client *self, const char *buf,
 	       struct notif_event *event);
 
   /* Check this notification client can get pending events in
@@ -106,15 +106,16 @@ struct remote_notif_state
   struct notif_event *pending_event[REMOTE_NOTIF_LAST];
 };
 
-void remote_notif_ack (remote_target *remote, notif_client *nc, char *buf);
+void remote_notif_ack (remote_target *remote, notif_client *nc,
+		       const char *buf);
 struct notif_event *remote_notif_parse (remote_target *remote,
 					notif_client *nc,
-					char *buf);
+					const char *buf);
 
 void notif_event_xfree (struct notif_event *event);
 
 void handle_notification (struct remote_notif_state *notif_state,
-			  char *buf);
+			  const char *buf);
 
 void remote_notif_process (struct remote_notif_state *state,
 			   struct notif_client *except);
diff --git a/gdb/remote.c b/gdb/remote.c
index 6b5870a70a..949c69c1cc 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -768,7 +768,7 @@ public: /* Remote specific methods.  */
   struct stop_reply *remote_notif_remove_queued_reply (ptid_t ptid);
   struct stop_reply *queued_stop_reply (ptid_t ptid);
   int peek_stop_reply (ptid_t ptid);
-  void remote_parse_stop_reply (char *buf, stop_reply *event);
+  void remote_parse_stop_reply (const char *buf, stop_reply *event);
 
   void remote_stop_ns (ptid_t ptid);
   void remote_interrupt_as ();
@@ -6864,7 +6864,7 @@ remote_target::stop_reply_queue_length ()
 
 void
 remote_notif_stop_parse (remote_target *remote,
-			 struct notif_client *self, char *buf,
+			 struct notif_client *self, const char *buf,
 			 struct notif_event *event)
 {
   remote->remote_parse_stop_reply (buf, (struct stop_reply *) event);
@@ -6872,7 +6872,7 @@ remote_notif_stop_parse (remote_target *remote,
 
 static void
 remote_notif_stop_ack (remote_target *remote,
-		       struct notif_client *self, char *buf,
+		       struct notif_client *self, const char *buf,
 		       struct notif_event *event)
 {
   struct stop_reply *stop_reply = (struct stop_reply *) event;
@@ -7201,7 +7201,7 @@ strprefix (const char *p, const char *pend, const char *prefix)
    result is stored in EVENT, or throws an error.  */
 
 void
-remote_target::remote_parse_stop_reply (char *buf, stop_reply *event)
+remote_target::remote_parse_stop_reply (const char *buf, stop_reply *event)
 {
   remote_arch_state *rsa = NULL;
   ULONGEST addr;
-- 
2.17.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] Constify target_pass_signals and target_program_signals
  2019-01-06 22:46 [PATCH 0/3] Some remote-related constification Tom Tromey
@ 2019-01-06 22:46 ` Tom Tromey
  2019-01-14 22:03   ` Simon Marchi
  2019-01-23 18:46   ` [PATCH] target_pass_signals/target_program_signals: Use gdb::array_view (Re: [PATCH 1/3] Constify target_pass_signals and target_program_signals) Pedro Alves
  2019-01-06 22:46 ` [PATCH 3/3] Constify some remote-notif functions Tom Tromey
  2019-01-06 22:46 ` [PATCH 2/3] Constify remote_console_output Tom Tromey
  2 siblings, 2 replies; 8+ messages in thread
From: Tom Tromey @ 2019-01-06 22:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This constifies the final parameter to target_pass_signals and
target_program_signals and updates the rest of gdb.

Note that I have no way to test the nto-procfs.c change.

gdb/ChangeLog
2019-01-06  Tom Tromey  <tom@tromey.com>

	* target-debug.h (target_debug_print_signals): Constify.
	* nto-procfs.c (nto_procfs_target::pass_signals): Update.
	* procfs.c (procfs_target::pass_signals): Update.
	* linux-nat.c (linux_nat_target::pass_signals): Update.
	* linux-nat.h (class linux_nat_target) <pass_signals>: Update.
	* target-delegates.c: Rebuild.
	* remote.c (remote_target::program_signals): Update.
	(remote_target::pass_signals): Update.
	* target.c (target_pass_signals): Constify argument.
	(target_program_signals): Likewise.
	* target.h (struct target_ops) <pass_signals, program_signals>:
	Constify argument.
	(target_pass_signals, target_program_signals): Constify argument.
---
 gdb/ChangeLog          | 16 ++++++++++++++++
 gdb/linux-nat.c        |  2 +-
 gdb/linux-nat.h        |  2 +-
 gdb/nto-procfs.c       |  5 +++--
 gdb/procfs.c           |  4 ++--
 gdb/remote.c           |  8 ++++----
 gdb/target-debug.h     |  2 +-
 gdb/target-delegates.c | 20 ++++++++++----------
 gdb/target.c           |  4 ++--
 gdb/target.h           |  9 +++++----
 10 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 73d4fd193a..c0d5f8dc66 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -788,7 +788,7 @@ static sigset_t pass_mask;
 
 /* Update signals to pass to the inferior.  */
 void
-linux_nat_target::pass_signals (int numsigs, unsigned char *pass_signals)
+linux_nat_target::pass_signals (int numsigs, const unsigned char *pass_signals)
 {
   int signo;
 
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index 14995266f9..c56a245c8b 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -45,7 +45,7 @@ public:
 
   ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
 
-  void pass_signals (int, unsigned char *) override;
+  void pass_signals (int, const unsigned char *) override;
 
   enum target_xfer_status xfer_partial (enum target_object object,
 					const char *annex,
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 1a12f54d8a..9ee42e6428 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -109,7 +109,7 @@ struct nto_procfs_target : public inf_child_target
 
   void mourn_inferior () override;
 
-  void pass_signals (int, unsigned char *) override;
+  void pass_signals (int, const unsigned char *) override;
 
   bool thread_alive (ptid_t ptid) override;
 
@@ -1442,7 +1442,8 @@ nto_procfs_target::store_registers (struct regcache *regcache, int regno)
 /* Set list of signals to be handled in the target.  */
 
 void
-nto_procfs_target::pass_signals (int numsigs, unsigned char *pass_signals)
+nto_procfs_target::pass_signals (int numsigs,
+				 const unsigned char *pass_signals)
 {
   int signo;
 
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 9e3d037b69..dd7534aa57 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -119,7 +119,7 @@ public:
 					ULONGEST offset, ULONGEST len,
 					ULONGEST *xfered_len) override;
 
-  void pass_signals (int, unsigned char *) override;
+  void pass_signals (int, const unsigned char *) override;
 
   void files_info () override;
 
@@ -2772,7 +2772,7 @@ procfs_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
 /* Set up to trace signals in the child process.  */
 
 void
-procfs_target::pass_signals (int numsigs, unsigned char *pass_signals)
+procfs_target::pass_signals (int numsigs, const unsigned char *pass_signals)
 {
   sigset_t signals;
   procinfo *pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
diff --git a/gdb/remote.c b/gdb/remote.c
index 324ed46809..c40f926376 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -474,12 +474,12 @@ public:
 
   void mourn_inferior () override;
 
-  void pass_signals (int, unsigned char *) override;
+  void pass_signals (int, const unsigned char *) override;
 
   int set_syscall_catchpoint (int, bool, int,
 			      gdb::array_view<const int>) override;
 
-  void program_signals (int, unsigned char *) override;
+  void program_signals (int, const unsigned char *) override;
 
   bool thread_alive (ptid_t ptid) override;
 
@@ -2555,7 +2555,7 @@ record_currthread (struct remote_state *rs, ptid_t currthread)
    it can simply pass through to the inferior without reporting.  */
 
 void
-remote_target::pass_signals (int numsigs, unsigned char *pass_signals)
+remote_target::pass_signals (int numsigs, const unsigned char *pass_signals)
 {
   if (packet_support (PACKET_QPassSignals) != PACKET_DISABLE)
     {
@@ -2681,7 +2681,7 @@ remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count,
    signals it should pass through to the inferior when detaching.  */
 
 void
-remote_target::program_signals (int numsigs, unsigned char *signals)
+remote_target::program_signals (int numsigs, const unsigned char *signals)
 {
   if (packet_support (PACKET_QProgramSignals) != PACKET_DISABLE)
     {
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 67d400a58c..d51754af59 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -209,7 +209,7 @@ target_debug_print_options (int options)
 }
 
 static void
-target_debug_print_signals (unsigned char *sigs)
+target_debug_print_signals (const unsigned char *sigs)
 {
   fputs_unfiltered ("{", gdb_stdlog);
   if (sigs != NULL)
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 2ff800cca3..43c979087f 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -62,8 +62,8 @@ struct dummy_target : public target_ops
   void follow_exec (struct inferior *arg0, char *arg1) override;
   int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view<const int> arg3) override;
   void mourn_inferior () override;
-  void pass_signals (int arg0, unsigned char * arg1) override;
-  void program_signals (int arg0, unsigned char * arg1) override;
+  void pass_signals (int arg0, const unsigned char * arg1) override;
+  void program_signals (int arg0, const unsigned char * arg1) override;
   bool thread_alive (ptid_t arg0) override;
   void update_thread_list () override;
   const char *pid_to_str (ptid_t arg0) override;
@@ -229,8 +229,8 @@ struct debug_target : public target_ops
   void follow_exec (struct inferior *arg0, char *arg1) override;
   int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view<const int> arg3) override;
   void mourn_inferior () override;
-  void pass_signals (int arg0, unsigned char * arg1) override;
-  void program_signals (int arg0, unsigned char * arg1) override;
+  void pass_signals (int arg0, const unsigned char * arg1) override;
+  void program_signals (int arg0, const unsigned char * arg1) override;
   bool thread_alive (ptid_t arg0) override;
   void update_thread_list () override;
   const char *pid_to_str (ptid_t arg0) override;
@@ -1659,18 +1659,18 @@ debug_target::mourn_inferior ()
 }
 
 void
-target_ops::pass_signals (int arg0, unsigned char * arg1)
+target_ops::pass_signals (int arg0, const unsigned char * arg1)
 {
   this->beneath ()->pass_signals (arg0, arg1);
 }
 
 void
-dummy_target::pass_signals (int arg0, unsigned char * arg1)
+dummy_target::pass_signals (int arg0, const unsigned char * arg1)
 {
 }
 
 void
-debug_target::pass_signals (int arg0, unsigned char * arg1)
+debug_target::pass_signals (int arg0, const unsigned char * arg1)
 {
   fprintf_unfiltered (gdb_stdlog, "-> %s->pass_signals (...)\n", this->beneath ()->shortname ());
   this->beneath ()->pass_signals (arg0, arg1);
@@ -1682,18 +1682,18 @@ debug_target::pass_signals (int arg0, unsigned char * arg1)
 }
 
 void
-target_ops::program_signals (int arg0, unsigned char * arg1)
+target_ops::program_signals (int arg0, const unsigned char * arg1)
 {
   this->beneath ()->program_signals (arg0, arg1);
 }
 
 void
-dummy_target::program_signals (int arg0, unsigned char * arg1)
+dummy_target::program_signals (int arg0, const unsigned char * arg1)
 {
 }
 
 void
-debug_target::program_signals (int arg0, unsigned char * arg1)
+debug_target::program_signals (int arg0, const unsigned char * arg1)
 {
   fprintf_unfiltered (gdb_stdlog, "-> %s->program_signals (...)\n", this->beneath ()->shortname ());
   this->beneath ()->program_signals (arg0, arg1);
diff --git a/gdb/target.c b/gdb/target.c
index f8e92f5696..e66584f147 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2112,13 +2112,13 @@ make_scoped_defer_target_commit_resume ()
 }
 
 void
-target_pass_signals (int numsigs, unsigned char *pass_signals)
+target_pass_signals (int numsigs, const unsigned char *pass_signals)
 {
   current_top_target ()->pass_signals (numsigs, pass_signals);
 }
 
 void
-target_program_signals (int numsigs, unsigned char *program_signals)
+target_program_signals (int numsigs, const unsigned char *program_signals)
 {
   current_top_target ()->program_signals (numsigs, program_signals);
 }
diff --git a/gdb/target.h b/gdb/target.h
index 36f8942679..14ec07fc0e 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -638,13 +638,13 @@ struct target_ops
     /* Documentation of this routine is provided with the corresponding
        target_* macro.  */
     virtual void pass_signals (int,
-			       unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
+			       const unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
       TARGET_DEFAULT_IGNORE ();
 
     /* Documentation of this routine is provided with the
        corresponding target_* function.  */
     virtual void program_signals (int,
-				  unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
+				  const unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
       TARGET_DEFAULT_IGNORE ();
 
     virtual bool thread_alive (ptid_t ptid)
@@ -1692,7 +1692,7 @@ extern int target_can_run ();
    about to receive a signal, it needs to be reported in any case, even
    if mentioned in a previous target_pass_signals call.   */
 
-extern void target_pass_signals (int nsig, unsigned char *pass_signals);
+extern void target_pass_signals (int nsig, const unsigned char *pass_signals);
 
 /* Set list of signals the target may pass to the inferior.  This
    directly maps to the "handle SIGNAL pass/nopass" setting.
@@ -1708,7 +1708,8 @@ extern void target_pass_signals (int nsig, unsigned char *pass_signals);
    example, when detaching (as threads may have been suspended with
    pending signals not reported to GDB).  */
 
-extern void target_program_signals (int nsig, unsigned char *program_signals);
+extern void target_program_signals (int nsig,
+				    const unsigned char *program_signals);
 
 /* Check to see if a thread is still alive.  */
 
-- 
2.17.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 0/3] Some remote-related constification
@ 2019-01-06 22:46 Tom Tromey
  2019-01-06 22:46 ` [PATCH 1/3] Constify target_pass_signals and target_program_signals Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Tom Tromey @ 2019-01-06 22:46 UTC (permalink / raw)
  To: gdb-patches

I noticed a few spots in the remote code that could be constified.
This series implements this.

Tested by the buildbot, but see patch #1 for a spot that couldn't be
tested.

Tom


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] Constify target_pass_signals and target_program_signals
  2019-01-06 22:46 ` [PATCH 1/3] Constify target_pass_signals and target_program_signals Tom Tromey
@ 2019-01-14 22:03   ` Simon Marchi
  2019-01-15  0:31     ` Tom Tromey
  2019-01-23 18:46   ` [PATCH] target_pass_signals/target_program_signals: Use gdb::array_view (Re: [PATCH 1/3] Constify target_pass_signals and target_program_signals) Pedro Alves
  1 sibling, 1 reply; 8+ messages in thread
From: Simon Marchi @ 2019-01-14 22:03 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2019-01-06 17:46, Tom Tromey wrote:
> This constifies the final parameter to target_pass_signals and
> target_program_signals and updates the rest of gdb.
> 
> Note that I have no way to test the nto-procfs.c change.

This LGTM.  Even if there was a typo, it would be a trivial fix.

Simon

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] Constify target_pass_signals and target_program_signals
  2019-01-14 22:03   ` Simon Marchi
@ 2019-01-15  0:31     ` Tom Tromey
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-01-15  0:31 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simon.marchi@polymtl.ca> writes:

Simon> On 2019-01-06 17:46, Tom Tromey wrote:
>> This constifies the final parameter to target_pass_signals and
>> target_program_signals and updates the rest of gdb.
>> 
>> Note that I have no way to test the nto-procfs.c change.

Simon> This LGTM.  Even if there was a typo, it would be a trivial fix.

Thanks.
The others are obvious, so I'm checking in the series now.

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] target_pass_signals/target_program_signals: Use gdb::array_view (Re: [PATCH 1/3] Constify target_pass_signals and target_program_signals)
  2019-01-06 22:46 ` [PATCH 1/3] Constify target_pass_signals and target_program_signals Tom Tromey
  2019-01-14 22:03   ` Simon Marchi
@ 2019-01-23 18:46   ` Pedro Alves
  2019-01-23 22:02     ` Tom Tromey
  1 sibling, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2019-01-23 18:46 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 01/06/2019 10:46 PM, Tom Tromey wrote:
> This constifies the final parameter to target_pass_signals and
> target_program_signals and updates the rest of gdb.
> 
> Note that I have no way to test the nto-procfs.c change.
> 
> gdb/ChangeLog
> 2019-01-06  Tom Tromey  <tom@tromey.com>
> 
> 	* target-debug.h (target_debug_print_signals): Constify.
> 	* nto-procfs.c (nto_procfs_target::pass_signals): Update.
> 	* procfs.c (procfs_target::pass_signals): Update.
> 	* linux-nat.c (linux_nat_target::pass_signals): Update.
> 	* linux-nat.h (class linux_nat_target) <pass_signals>: Update.
> 	* target-delegates.c: Rebuild.
> 	* remote.c (remote_target::program_signals): Update.
> 	(remote_target::pass_signals): Update.
> 	* target.c (target_pass_signals): Constify argument.
> 	(target_program_signals): Likewise.
> 	* target.h (struct target_ops) <pass_signals, program_signals>:
> 	Constify argument.
> 	(target_pass_signals, target_program_signals): Constify argument.

Hmm, this seems to be calling for gdb::array_view.

Patch below.  WDYT?

Having written this, though, I now see that alternatively, I guess we could
keep the pointer parameter, but drop the 'int numsigs' parameter and hardcode
GDB_SIGNAL_LAST instead of referring to numsigs, since the array size
is always going to be GDB_SIGNAL_LAST.

From 3aef4262e936b377f391ccbfc3622908b1ce067d Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Wed, 23 Jan 2019 18:17:20 +0000
Subject: [PATCH] target_pass_signals/target_program_signals: Use
 gdb::array_view

This replaces the pointer and length parameters of target_pass_signals
and target_program_signals with a gdb::array_view parameter, and fixes
the fallout.

In infrun.c, the signal_stop, signal_print, signal_program,
signal_catch, signal_pass globals are currently pointers to
heap-allocated memory.  I see no point in that, so I converted them to
arrays.  This allows simplifying the calls to
target_pass_signals/target_program_signals, since we can pass the
array directly, which can implicitly convert to gdb::array_view.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* infrun.c (signal_stop, signal_print, signal_program)
	(signal_catch, signal_pass): Now arrays instead of pointers.
	(update_signals_program_target, do_target_resume)
	(signal_catch_update, handle_command, _initialize_infrun): Adjust.
	* linux-nat.c (linux_nat_target::pass_signals)
	(linux_nat_target::create_inferior, linux_nat_target::attach):
	Adjust.
	* linux-nat.h (linux_nat_target::pass_signals): Adjust.
	* nto-procfs.c (nto_procfs_target::pass_signals): Adjust.
	* procfs.c (procfs_target::pass_signals): Adjust.
	* record-full.c (record_full_target::resume): Adjust.
	* remote.c (remote_target::pass_signals)
	(remote_target::program_signals): Adjust.
	* target-debug.h (target_debug_print_signals): Now takes a
	gdb::array_view as parameter.  Adjust.
	* target.h (target_ops) <pass_signals, program_signals>: Replace
	pointer and length parameters with gdb::array_view.
	(target_pass_signals, target_program_signals): Likewise.
	* target-delegates.c: Regenerate.
---
 gdb/infrun.c           | 42 +++++++++++++++---------------------------
 gdb/linux-nat.c        |  9 +++++----
 gdb/linux-nat.h        |  2 +-
 gdb/nto-procfs.c       |  8 ++++----
 gdb/procfs.c           |  6 +++---
 gdb/record-full.c      |  2 +-
 gdb/remote.c           | 26 +++++++++++++-------------
 gdb/target-debug.h     | 20 ++++++++------------
 gdb/target-delegates.c | 36 ++++++++++++++++--------------------
 gdb/target.c           |  8 ++++----
 gdb/target.h           | 17 ++++++++---------
 11 files changed, 78 insertions(+), 98 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index cdfdf49070..f696558a46 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -306,20 +306,19 @@ update_observer_mode (void)
 
 /* Tables of how to react to signals; the user sets them.  */
 
-static unsigned char *signal_stop;
-static unsigned char *signal_print;
-static unsigned char *signal_program;
+static unsigned char signal_stop[GDB_SIGNAL_LAST];
+static unsigned char signal_print[GDB_SIGNAL_LAST];
+static unsigned char signal_program[GDB_SIGNAL_LAST];
 
 /* Table of signals that are registered with "catch signal".  A
    non-zero entry indicates that the signal is caught by some "catch
-   signal" command.  This has size GDB_SIGNAL_LAST, to accommodate all
-   signals.  */
-static unsigned char *signal_catch;
+   signal" command.  */
+static unsigned char signal_catch[GDB_SIGNAL_LAST];
 
 /* Table of signals that the target may silently handle.
    This is automatically determined from the flags above,
    and simply cached here.  */
-static unsigned char *signal_pass;
+static unsigned char signal_pass[GDB_SIGNAL_LAST];
 
 #define SET_SIGS(nsigs,sigs,flags) \
   do { \
@@ -343,7 +342,7 @@ static unsigned char *signal_pass;
 void
 update_signals_program_target (void)
 {
-  target_program_signals ((int) GDB_SIGNAL_LAST, signal_program);
+  target_program_signals (signal_program);
 }
 
 /* Value to pass to target_resume() to cause all threads to resume.  */
@@ -2219,9 +2218,9 @@ do_target_resume (ptid_t resume_ptid, int step, enum gdb_signal sig)
        valid.  */
   if (step_over_info_valid_p ()
       || displaced_step_in_progress (tp->inf))
-    target_pass_signals (0, NULL);
+    target_pass_signals ({});
   else
-    target_pass_signals ((int) GDB_SIGNAL_LAST, signal_pass);
+    target_pass_signals (signal_pass);
 
   target_resume (resume_ptid, step, sig);
 
@@ -8251,7 +8250,7 @@ signal_catch_update (const unsigned int *info)
   for (i = 0; i < GDB_SIGNAL_LAST; ++i)
     signal_catch[i] = info[i] > 0;
   signal_cache_update (-1);
-  target_pass_signals ((int) GDB_SIGNAL_LAST, signal_pass);
+  target_pass_signals (signal_pass);
 }
 
 static void
@@ -8287,8 +8286,6 @@ handle_command (const char *args, int from_tty)
   int sigfirst, siglast;
   enum gdb_signal oursig;
   int allsigs;
-  int nsigs;
-  unsigned char *sigs;
 
   if (args == NULL)
     {
@@ -8297,9 +8294,8 @@ handle_command (const char *args, int from_tty)
 
   /* Allocate and zero an array of flags for which signals to handle.  */
 
-  nsigs = (int) GDB_SIGNAL_LAST;
-  sigs = (unsigned char *) alloca (nsigs);
-  memset (sigs, 0, nsigs);
+  const size_t nsigs = GDB_SIGNAL_LAST;
+  unsigned char sigs[nsigs] {};
 
   /* Break the command line up into args.  */
 
@@ -8436,8 +8432,8 @@ Are you sure you want to change it? "),
     if (sigs[signum])
       {
 	signal_cache_update (-1);
-	target_pass_signals ((int) GDB_SIGNAL_LAST, signal_pass);
-	target_program_signals ((int) GDB_SIGNAL_LAST, signal_program);
+	target_pass_signals (signal_pass);
+	target_program_signals (signal_program);
 
 	if (from_tty)
 	  {
@@ -8963,8 +8959,6 @@ infrun_async_inferior_event_handler (gdb_client_data data)
 void
 _initialize_infrun (void)
 {
-  int i;
-  int numsigs;
   struct cmd_list_element *c;
 
   /* Register extra event sources in the event loop.  */
@@ -9046,13 +9040,7 @@ leave it stopped or free to run as needed."),
 			   &setlist,
 			   &showlist);
 
-  numsigs = (int) GDB_SIGNAL_LAST;
-  signal_stop = XNEWVEC (unsigned char, numsigs);
-  signal_print = XNEWVEC (unsigned char, numsigs);
-  signal_program = XNEWVEC (unsigned char, numsigs);
-  signal_catch = XNEWVEC (unsigned char, numsigs);
-  signal_pass = XNEWVEC (unsigned char, numsigs);
-  for (i = 0; i < numsigs; i++)
+  for (size_t i = 0; i < GDB_SIGNAL_LAST; i++)
     {
       signal_stop[i] = 1;
       signal_print[i] = 1;
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 45da9fa997..c285e914d5 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -789,7 +789,8 @@ static sigset_t pass_mask;
 
 /* Update signals to pass to the inferior.  */
 void
-linux_nat_target::pass_signals (int numsigs, const unsigned char *pass_signals)
+linux_nat_target::pass_signals
+  (gdb::array_view<const unsigned char> pass_signals)
 {
   int signo;
 
@@ -798,7 +799,7 @@ linux_nat_target::pass_signals (int numsigs, const unsigned char *pass_signals)
   for (signo = 1; signo < NSIG; signo++)
     {
       int target_signo = gdb_signal_from_host (signo);
-      if (target_signo < numsigs && pass_signals[target_signo])
+      if (target_signo < pass_signals.size () && pass_signals[target_signo])
         sigaddset (&pass_mask, signo);
     }
 }
@@ -1096,7 +1097,7 @@ linux_nat_target::create_inferior (const char *exec_file,
      we have to mask the async mode.  */
 
   /* Make sure we report all signals during startup.  */
-  pass_signals (0, NULL);
+  pass_signals ({});
 
   inf_ptrace_target::create_inferior (exec_file, allargs, env, from_tty);
 }
@@ -1186,7 +1187,7 @@ linux_nat_target::attach (const char *args, int from_tty)
   ptid_t ptid;
 
   /* Make sure we report all signals during attach.  */
-  pass_signals (0, NULL);
+  pass_signals ({});
 
   TRY
     {
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index c56a245c8b..16f8a584bd 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -45,7 +45,7 @@ public:
 
   ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
 
-  void pass_signals (int, const unsigned char *) override;
+  void pass_signals (gdb::array_view<const unsigned char>) override;
 
   enum target_xfer_status xfer_partial (enum target_object object,
 					const char *annex,
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 9ee42e6428..40959d7715 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -109,7 +109,7 @@ struct nto_procfs_target : public inf_child_target
 
   void mourn_inferior () override;
 
-  void pass_signals (int, const unsigned char *) override;
+  void pass_signals (gdb::array_view<const unsigned char>) override;
 
   bool thread_alive (ptid_t ptid) override;
 
@@ -1442,8 +1442,8 @@ nto_procfs_target::store_registers (struct regcache *regcache, int regno)
 /* Set list of signals to be handled in the target.  */
 
 void
-nto_procfs_target::pass_signals (int numsigs,
-				 const unsigned char *pass_signals)
+nto_procfs_target::pass_signals
+  (gdb::array_view<const unsigned char> pass_signals)
 {
   int signo;
 
@@ -1452,7 +1452,7 @@ nto_procfs_target::pass_signals (int numsigs,
   for (signo = 1; signo < NSIG; signo++)
     {
       int target_signo = gdb_signal_from_host (signo);
-      if (target_signo < numsigs && pass_signals[target_signo])
+      if (target_signo < pass_signals.size () && pass_signals[target_signo])
         sigdelset (&run.trace, signo);
     }
 }
diff --git a/gdb/procfs.c b/gdb/procfs.c
index dd7534aa57..3c1dcba062 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -119,7 +119,7 @@ public:
 					ULONGEST offset, ULONGEST len,
 					ULONGEST *xfered_len) override;
 
-  void pass_signals (int, const unsigned char *) override;
+  void pass_signals (gdb::array_view<const unsigned char>) override;
 
   void files_info () override;
 
@@ -2772,7 +2772,7 @@ procfs_target::resume (ptid_t ptid, int step, enum gdb_signal signo)
 /* Set up to trace signals in the child process.  */
 
 void
-procfs_target::pass_signals (int numsigs, const unsigned char *pass_signals)
+procfs_target::pass_signals (gdb::array_view<const unsigned char> pass_signals)
 {
   sigset_t signals;
   procinfo *pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
@@ -2783,7 +2783,7 @@ procfs_target::pass_signals (int numsigs, const unsigned char *pass_signals)
   for (signo = 0; signo < NSIG; signo++)
     {
       int target_signo = gdb_signal_from_host (signo);
-      if (target_signo < numsigs && pass_signals[target_signo])
+      if (target_signo < pass_signals.size () && pass_signals[target_signo])
 	prdelset (&signals, signo);
     }
 
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 8738512f28..ea0eddb536 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1098,7 +1098,7 @@ record_full_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
         }
 
       /* Make sure the target beneath reports all signals.  */
-      target_pass_signals (0, NULL);
+      target_pass_signals ({});
 
       this->beneath ()->resume (ptid, step, signal);
     }
diff --git a/gdb/remote.c b/gdb/remote.c
index 4b3f2907b4..ad53621145 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -472,12 +472,12 @@ public:
 
   void mourn_inferior () override;
 
-  void pass_signals (int, const unsigned char *) override;
+  void pass_signals (gdb::array_view<const unsigned char>) override;
 
   int set_syscall_catchpoint (int, bool, int,
 			      gdb::array_view<const int>) override;
 
-  void program_signals (int, const unsigned char *) override;
+  void program_signals (gdb::array_view<const unsigned char>) override;
 
   bool thread_alive (ptid_t ptid) override;
 
@@ -2560,16 +2560,16 @@ record_currthread (struct remote_state *rs, ptid_t currthread)
    it can simply pass through to the inferior without reporting.  */
 
 void
-remote_target::pass_signals (int numsigs, const unsigned char *pass_signals)
+remote_target::pass_signals (gdb::array_view<const unsigned char> pass_signals)
 {
   if (packet_support (PACKET_QPassSignals) != PACKET_DISABLE)
     {
       char *pass_packet, *p;
-      int count = 0, i;
+      int count = 0;
       struct remote_state *rs = get_remote_state ();
 
-      gdb_assert (numsigs < 256);
-      for (i = 0; i < numsigs; i++)
+      gdb_assert (pass_signals.size () < 256);
+      for (size_t i = 0; i < pass_signals.size (); i++)
 	{
 	  if (pass_signals[i])
 	    count++;
@@ -2577,7 +2577,7 @@ remote_target::pass_signals (int numsigs, const unsigned char *pass_signals)
       pass_packet = (char *) xmalloc (count * 3 + strlen ("QPassSignals:") + 1);
       strcpy (pass_packet, "QPassSignals:");
       p = pass_packet + strlen (pass_packet);
-      for (i = 0; i < numsigs; i++)
+      for (size_t i = 0; i < pass_signals.size (); i++)
 	{
 	  if (pass_signals[i])
 	    {
@@ -2686,16 +2686,16 @@ remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count,
    signals it should pass through to the inferior when detaching.  */
 
 void
-remote_target::program_signals (int numsigs, const unsigned char *signals)
+remote_target::program_signals (gdb::array_view<const unsigned char> signals)
 {
   if (packet_support (PACKET_QProgramSignals) != PACKET_DISABLE)
     {
       char *packet, *p;
-      int count = 0, i;
+      int count = 0;
       struct remote_state *rs = get_remote_state ();
 
-      gdb_assert (numsigs < 256);
-      for (i = 0; i < numsigs; i++)
+      gdb_assert (signals.size () < 256);
+      for (size_t i = 0; i < signals.size (); i++)
 	{
 	  if (signals[i])
 	    count++;
@@ -2703,7 +2703,7 @@ remote_target::program_signals (int numsigs, const unsigned char *signals)
       packet = (char *) xmalloc (count * 3 + strlen ("QProgramSignals:") + 1);
       strcpy (packet, "QProgramSignals:");
       p = packet + strlen (packet);
-      for (i = 0; i < numsigs; i++)
+      for (size_t i = 0; i < signals.size (); i++)
 	{
 	  if (signal_pass_state (i))
 	    {
@@ -4796,7 +4796,7 @@ remote_target::start_remote (int from_tty, int extended_p)
       gdb_assert (wait_status == NULL);
 
       /* Report all signals during attach/startup.  */
-      pass_signals (0, NULL);
+      pass_signals ({});
 
       /* If there are already stopped threads, mark them stopped and
 	 report their stops before giving the prompt to the user.  */
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index d51754af59..d9f7d46dd9 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -209,20 +209,16 @@ target_debug_print_options (int options)
 }
 
 static void
-target_debug_print_signals (const unsigned char *sigs)
+target_debug_print_signals (gdb::array_view<const unsigned char> sigs)
 {
   fputs_unfiltered ("{", gdb_stdlog);
-  if (sigs != NULL)
-    {
-      int i;
-
-      for (i = 0; i < GDB_SIGNAL_LAST; i++)
-	if (sigs[i])
-	  {
-	    fprintf_unfiltered (gdb_stdlog, " %s",
-				gdb_signal_to_name ((enum gdb_signal) i));
-	  }
-    }
+
+  for (size_t i = 0; i < sigs.size (); i++)
+    if (sigs[i] != 0)
+      {
+	fprintf_unfiltered (gdb_stdlog, " %s",
+			    gdb_signal_to_name ((enum gdb_signal) i));
+      }
   fputs_unfiltered (" }", gdb_stdlog);
 }
 
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 43c979087f..a25851e9cf 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -62,8 +62,8 @@ struct dummy_target : public target_ops
   void follow_exec (struct inferior *arg0, char *arg1) override;
   int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view<const int> arg3) override;
   void mourn_inferior () override;
-  void pass_signals (int arg0, const unsigned char * arg1) override;
-  void program_signals (int arg0, const unsigned char * arg1) override;
+  void pass_signals (gdb::array_view<const unsigned char> arg0) override;
+  void program_signals (gdb::array_view<const unsigned char> arg0) override;
   bool thread_alive (ptid_t arg0) override;
   void update_thread_list () override;
   const char *pid_to_str (ptid_t arg0) override;
@@ -229,8 +229,8 @@ struct debug_target : public target_ops
   void follow_exec (struct inferior *arg0, char *arg1) override;
   int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view<const int> arg3) override;
   void mourn_inferior () override;
-  void pass_signals (int arg0, const unsigned char * arg1) override;
-  void program_signals (int arg0, const unsigned char * arg1) override;
+  void pass_signals (gdb::array_view<const unsigned char> arg0) override;
+  void program_signals (gdb::array_view<const unsigned char> arg0) override;
   bool thread_alive (ptid_t arg0) override;
   void update_thread_list () override;
   const char *pid_to_str (ptid_t arg0) override;
@@ -1659,48 +1659,44 @@ debug_target::mourn_inferior ()
 }
 
 void
-target_ops::pass_signals (int arg0, const unsigned char * arg1)
+target_ops::pass_signals (gdb::array_view<const unsigned char> arg0)
 {
-  this->beneath ()->pass_signals (arg0, arg1);
+  this->beneath ()->pass_signals (arg0);
 }
 
 void
-dummy_target::pass_signals (int arg0, const unsigned char * arg1)
+dummy_target::pass_signals (gdb::array_view<const unsigned char> arg0)
 {
 }
 
 void
-debug_target::pass_signals (int arg0, const unsigned char * arg1)
+debug_target::pass_signals (gdb::array_view<const unsigned char> arg0)
 {
   fprintf_unfiltered (gdb_stdlog, "-> %s->pass_signals (...)\n", this->beneath ()->shortname ());
-  this->beneath ()->pass_signals (arg0, arg1);
+  this->beneath ()->pass_signals (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->pass_signals (", this->beneath ()->shortname ());
-  target_debug_print_int (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_signals (arg1);
+  target_debug_print_signals (arg0);
   fputs_unfiltered (")\n", gdb_stdlog);
 }
 
 void
-target_ops::program_signals (int arg0, const unsigned char * arg1)
+target_ops::program_signals (gdb::array_view<const unsigned char> arg0)
 {
-  this->beneath ()->program_signals (arg0, arg1);
+  this->beneath ()->program_signals (arg0);
 }
 
 void
-dummy_target::program_signals (int arg0, const unsigned char * arg1)
+dummy_target::program_signals (gdb::array_view<const unsigned char> arg0)
 {
 }
 
 void
-debug_target::program_signals (int arg0, const unsigned char * arg1)
+debug_target::program_signals (gdb::array_view<const unsigned char> arg0)
 {
   fprintf_unfiltered (gdb_stdlog, "-> %s->program_signals (...)\n", this->beneath ()->shortname ());
-  this->beneath ()->program_signals (arg0, arg1);
+  this->beneath ()->program_signals (arg0);
   fprintf_unfiltered (gdb_stdlog, "<- %s->program_signals (", this->beneath ()->shortname ());
-  target_debug_print_int (arg0);
-  fputs_unfiltered (", ", gdb_stdlog);
-  target_debug_print_signals (arg1);
+  target_debug_print_signals (arg0);
   fputs_unfiltered (")\n", gdb_stdlog);
 }
 
diff --git a/gdb/target.c b/gdb/target.c
index ad7eba3fa3..6f597a8a1d 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2111,15 +2111,15 @@ make_scoped_defer_target_commit_resume ()
 }
 
 void
-target_pass_signals (int numsigs, const unsigned char *pass_signals)
+target_pass_signals (gdb::array_view<const unsigned char> pass_signals)
 {
-  current_top_target ()->pass_signals (numsigs, pass_signals);
+  current_top_target ()->pass_signals (pass_signals);
 }
 
 void
-target_program_signals (int numsigs, const unsigned char *program_signals)
+target_program_signals (gdb::array_view<const unsigned char> program_signals)
 {
-  current_top_target ()->program_signals (numsigs, program_signals);
+  current_top_target ()->program_signals (program_signals);
 }
 
 static int
diff --git a/gdb/target.h b/gdb/target.h
index 14ec07fc0e..d04465a58b 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -637,14 +637,12 @@ struct target_ops
 
     /* Documentation of this routine is provided with the corresponding
        target_* macro.  */
-    virtual void pass_signals (int,
-			       const unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
+    virtual void pass_signals (gdb::array_view<const unsigned char> TARGET_DEBUG_PRINTER (target_debug_print_signals))
       TARGET_DEFAULT_IGNORE ();
 
     /* Documentation of this routine is provided with the
        corresponding target_* function.  */
-    virtual void program_signals (int,
-				  const unsigned char * TARGET_DEBUG_PRINTER (target_debug_print_signals))
+    virtual void program_signals (gdb::array_view<const unsigned char> TARGET_DEBUG_PRINTER (target_debug_print_signals))
       TARGET_DEFAULT_IGNORE ();
 
     virtual bool thread_alive (ptid_t ptid)
@@ -1682,7 +1680,7 @@ extern int target_can_run ();
 
 /* Set list of signals to be handled in the target.
 
-   PASS_SIGNALS is an array of size NSIG, indexed by target signal number
+   PASS_SIGNALS is an array  indexed by target signal number
    (enum gdb_signal).  For every signal whose entry in this array is
    non-zero, the target is allowed -but not required- to skip reporting
    arrival of the signal to the GDB core by returning from target_wait,
@@ -1692,12 +1690,13 @@ extern int target_can_run ();
    about to receive a signal, it needs to be reported in any case, even
    if mentioned in a previous target_pass_signals call.   */
 
-extern void target_pass_signals (int nsig, const unsigned char *pass_signals);
+extern void target_pass_signals
+  (gdb::array_view<const unsigned char> pass_signals);
 
 /* Set list of signals the target may pass to the inferior.  This
    directly maps to the "handle SIGNAL pass/nopass" setting.
 
-   PROGRAM_SIGNALS is an array of size NSIG, indexed by target signal
+   PROGRAM_SIGNALS is an array indexed by target signal
    number (enum gdb_signal).  For every signal whose entry in this
    array is non-zero, the target is allowed to pass the signal to the
    inferior.  Signals not present in the array shall be silently
@@ -1708,8 +1707,8 @@ extern void target_pass_signals (int nsig, const unsigned char *pass_signals);
    example, when detaching (as threads may have been suspended with
    pending signals not reported to GDB).  */
 
-extern void target_program_signals (int nsig,
-				    const unsigned char *program_signals);
+extern void target_program_signals
+  (gdb::array_view<const unsigned char> program_signals);
 
 /* Check to see if a thread is still alive.  */
 
-- 
2.14.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] target_pass_signals/target_program_signals: Use gdb::array_view (Re: [PATCH 1/3] Constify target_pass_signals and target_program_signals)
  2019-01-23 18:46   ` [PATCH] target_pass_signals/target_program_signals: Use gdb::array_view (Re: [PATCH 1/3] Constify target_pass_signals and target_program_signals) Pedro Alves
@ 2019-01-23 22:02     ` Tom Tromey
  0 siblings, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2019-01-23 22:02 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tom Tromey, gdb-patches

Pedro> Hmm, this seems to be calling for gdb::array_view.

Pedro> Patch below.  WDYT?

I like it; after Andrew's comments I had put this sort of change on my
to-do-someday list ...

Tom

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-01-23 22:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-06 22:46 [PATCH 0/3] Some remote-related constification Tom Tromey
2019-01-06 22:46 ` [PATCH 1/3] Constify target_pass_signals and target_program_signals Tom Tromey
2019-01-14 22:03   ` Simon Marchi
2019-01-15  0:31     ` Tom Tromey
2019-01-23 18:46   ` [PATCH] target_pass_signals/target_program_signals: Use gdb::array_view (Re: [PATCH 1/3] Constify target_pass_signals and target_program_signals) Pedro Alves
2019-01-23 22:02     ` Tom Tromey
2019-01-06 22:46 ` [PATCH 3/3] Constify some remote-notif functions Tom Tromey
2019-01-06 22:46 ` [PATCH 2/3] Constify remote_console_output 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).