diff options
-rw-r--r-- | gdb/ChangeLog | 22 | ||||
-rw-r--r-- | gdb/infrun.c | 42 | ||||
-rw-r--r-- | gdb/linux-nat.c | 9 | ||||
-rw-r--r-- | gdb/linux-nat.h | 2 | ||||
-rw-r--r-- | gdb/nto-procfs.c | 8 | ||||
-rw-r--r-- | gdb/procfs.c | 6 | ||||
-rw-r--r-- | gdb/record-full.c | 2 | ||||
-rw-r--r-- | gdb/remote.c | 26 | ||||
-rw-r--r-- | gdb/target-debug.h | 20 | ||||
-rw-r--r-- | gdb/target-delegates.c | 36 | ||||
-rw-r--r-- | gdb/target.c | 8 | ||||
-rw-r--r-- | gdb/target.h | 17 |
12 files changed, 100 insertions, 98 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e8e0128..1a3a2ed 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,27 @@ 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 (forward_scope_exit::forward_scope_exit): Pass arguments to m_bind_function directly, instead of creating a std::bind and diff --git a/gdb/infrun.c b/gdb/infrun.c index cdfdf49..f696558 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 45da9fa..c285e91 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 c56a245..16f8a58 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 9ee42e6..40959d7 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 dd7534a..3c1dcba 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 8738512..ea0eddb 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 4b3f290..ad53621 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 d51754a..d9f7d46 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 43c9790..a25851e 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 ad7eba3..6f597a8 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 14ec07f..d9b947a 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. */ |