+2019-01-24 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.
+
2019-01-24 Pedro Alves <palves@redhat.com>
* common/forward-scope-exit.h
/* 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 { \
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. */
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);
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
int sigfirst, siglast;
enum gdb_signal oursig;
int allsigs;
- int nsigs;
- unsigned char *sigs;
if (args == NULL)
{
/* 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. */
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)
{
void
_initialize_infrun (void)
{
- int i;
- int numsigs;
struct cmd_list_element *c;
/* Register extra event sources in the event loop. */
&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;
/* 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;
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);
}
}
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);
}
ptid_t ptid;
/* Make sure we report all signals during attach. */
- pass_signals (0, NULL);
+ pass_signals ({});
TRY
{
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,
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;
/* 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;
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);
}
}
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;
/* 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);
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);
}
}
/* Make sure the target beneath reports all signals. */
- target_pass_signals (0, NULL);
+ target_pass_signals ({});
this->beneath ()->resume (ptid, step, signal);
}
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;
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++;
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])
{
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++;
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))
{
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. */
}
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);
}
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;
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;
}
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);
}
}
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
/* 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)
/* 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,
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
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. */