gdb: resume ongoing step after handling fork or vfork
[deliverable/binutils-gdb.git] / gdb / break-catch-sig.c
index 805084fda1f8da661d7dd6c20d2fe8eb959551ff..949b32625cdfd6d582825a23fce234d8f7d58eb9 100644 (file)
@@ -1,6 +1,6 @@
 /* Everything about signal catchpoints, for GDB.
 
-   Copyright (C) 2011-2017 Free Software Foundation, Inc.
+   Copyright (C) 2011-2022 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,6 +28,8 @@
 #include "valprint.h"
 #include "cli/cli-utils.h"
 #include "completer.h"
+#include "cli/cli-style.h"
+#include "cli/cli-decode.h"
 
 #include <string>
 
@@ -59,7 +61,7 @@ static struct breakpoint_ops signal_catchpoint_ops;
 
 /* Count of each signal.  */
 
-static unsigned int *signal_catch_counts;
+static unsigned int signal_catch_counts[GDB_SIGNAL_LAST];
 
 \f
 
@@ -145,7 +147,7 @@ signal_catchpoint_remove_location (struct bp_location *bl,
 
 static int
 signal_catchpoint_breakpoint_hit (const struct bp_location *bl,
-                                 struct address_space *aspace,
+                                 const address_space *aspace,
                                  CORE_ADDR bp_addr,
                                  const struct target_waitstatus *ws)
 {
@@ -180,12 +182,11 @@ static enum print_stop_action
 signal_catchpoint_print_it (bpstat bs)
 {
   struct breakpoint *b = bs->breakpoint_at;
-  ptid_t ptid;
   struct target_waitstatus last;
   const char *signal_name;
   struct ui_out *uiout = current_uiout;
 
-  get_last_target_status (&ptid, &last);
+  get_last_target_status (nullptr, nullptr, &last);
 
   signal_name = signal_to_name_or_int (last.value.sig);
 
@@ -228,7 +229,7 @@ signal_catchpoint_print_one (struct breakpoint *b,
 
       bool first = true;
       for (gdb_signal iter : c->signals_to_be_caught)
-        {
+       {
          const char *name = signal_to_name_or_int (iter);
 
          if (!first)
@@ -236,12 +237,13 @@ signal_catchpoint_print_one (struct breakpoint *b,
          first = false;
 
          text += name;
-        }
-      uiout->field_string ("what", text.c_str ());
+       }
+      uiout->field_string ("what", text);
     }
   else
     uiout->field_string ("what",
-                        c->catch_all ? "<any signal>" : "<standard signals>");
+                        c->catch_all ? "<any signal>" : "<standard signals>",
+                        metadata_style.style ());
   uiout->text ("\" ");
 
   if (uiout->is_mi_like_p ())
@@ -259,16 +261,16 @@ signal_catchpoint_print_mention (struct breakpoint *b)
   if (!c->signals_to_be_caught.empty ())
     {
       if (c->signals_to_be_caught.size () > 1)
-        printf_filtered (_("Catchpoint %d (signals"), b->number);
+       printf_filtered (_("Catchpoint %d (signals"), b->number);
       else
-        printf_filtered (_("Catchpoint %d (signal"), b->number);
+       printf_filtered (_("Catchpoint %d (signal"), b->number);
 
       for (gdb_signal iter : c->signals_to_be_caught)
-        {
+       {
          const char *name = signal_to_name_or_int (iter);
 
          printf_filtered (" %s", name);
-        }
+       }
       printf_filtered (")");
     }
   else if (c->catch_all)
@@ -332,7 +334,7 @@ create_signal_catchpoint (int tempflag, std::vector<gdb_signal> &&filter,
    list, which is empty if no filtering is required.  */
 
 static std::vector<gdb_signal>
-catch_signal_split_args (char *arg, bool *catch_all)
+catch_signal_split_args (const char *arg, bool *catch_all)
 {
   std::vector<gdb_signal> result;
   bool first = true;
@@ -343,12 +345,12 @@ catch_signal_split_args (char *arg, bool *catch_all)
       gdb_signal signal_number;
       char *endptr;
 
-      gdb::unique_xmalloc_ptr<char> one_arg (extract_arg (&arg));
-      if (one_arg == NULL)
+      std::string one_arg = extract_arg (&arg);
+      if (one_arg.empty ())
        break;
 
       /* Check for the special flag "all".  */
-      if (strcmp (one_arg.get (), "all") == 0)
+      if (one_arg == "all")
        {
          arg = skip_spaces (arg);
          if (*arg != '\0' || !first)
@@ -361,14 +363,14 @@ catch_signal_split_args (char *arg, bool *catch_all)
       first = false;
 
       /* Check if the user provided a signal name or a number.  */
-      num = (int) strtol (one_arg.get (), &endptr, 0);
+      num = (int) strtol (one_arg.c_str (), &endptr, 0);
       if (*endptr == '\0')
        signal_number = gdb_signal_from_command (num);
       else
        {
-         signal_number = gdb_signal_from_name (one_arg.get ());
+         signal_number = gdb_signal_from_name (one_arg.c_str ());
          if (signal_number == GDB_SIGNAL_UNKNOWN)
-           error (_("Unknown signal name '%s'."), one_arg.get ());
+           error (_("Unknown signal name '%s'."), one_arg.c_str ());
        }
 
       result.push_back (signal_number);
@@ -381,14 +383,14 @@ catch_signal_split_args (char *arg, bool *catch_all)
 /* Implement the "catch signal" command.  */
 
 static void
-catch_signal_command (char *arg, int from_tty,
+catch_signal_command (const char *arg, int from_tty,
                      struct cmd_list_element *command)
 {
   int tempflag;
   bool catch_all = false;
   std::vector<gdb_signal> filter;
 
-  tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
+  tempflag = command->context () == CATCH_TEMPORARY;
 
   arg = skip_spaces (arg);
 
@@ -423,13 +425,12 @@ initialize_signal_catchpoint_ops (void)
   ops->explains_signal = signal_catchpoint_explains_signal;
 }
 
+void _initialize_break_catch_sig ();
 void
-_initialize_break_catch_sig (void)
+_initialize_break_catch_sig ()
 {
   initialize_signal_catchpoint_ops ();
 
-  signal_catch_counts = XCNEWVEC (unsigned int, GDB_SIGNAL_LAST);
-
   add_catch_command ("signal", _("\
 Catch signals by their names and/or numbers.\n\
 Usage: catch signal [[NAME|NUMBER] [NAME|NUMBER]...|all]\n\
This page took 0.035288 seconds and 4 git commands to generate.