]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/remote.c
Remove args from target detach
[thirdparty/binutils-gdb.git] / gdb / remote.c
index be2c65b3cfc3b639c363d29d791b2155005da607..01b236fcd30276646fed920ce35e20bcf1e93678 100644 (file)
@@ -1,6 +1,6 @@
 /* Remote target communications for serial-line targets in custom GDB protocol
 
-   Copyright (C) 1988-2017 Free Software Foundation, Inc.
+   Copyright (C) 1988-2018 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -2024,8 +2024,8 @@ remote_pass_signals (struct target_ops *self,
 
 static int
 remote_set_syscall_catchpoint (struct target_ops *self,
-                              int pid, int needed, int any_count,
-                              int table_size, int *table)
+                              int pid, bool needed, int any_count,
+                              gdb::array_view<const int> syscall_counts)
 {
   const char *catch_packet;
   enum packet_result result;
@@ -2037,14 +2037,12 @@ remote_set_syscall_catchpoint (struct target_ops *self,
       return 1;
     }
 
-  if (needed && !any_count)
+  if (needed && any_count == 0)
     {
-      int i;
-
-      /* Count how many syscalls are to be caught (table[sysno] != 0).  */
-      for (i = 0; i < table_size; i++)
+      /* Count how many syscalls are to be caught.  */
+      for (size_t i = 0; i < syscall_counts.size (); i++)
        {
-         if (table[i] != 0)
+         if (syscall_counts[i] != 0)
            n_sysno++;
        }
     }
@@ -2066,13 +2064,13 @@ remote_set_syscall_catchpoint (struct target_ops *self,
       const int maxpktsz = strlen ("QCatchSyscalls:1") + n_sysno * 9 + 1;
       built_packet.reserve (maxpktsz);
       built_packet = "QCatchSyscalls:1";
-      if (!any_count)
+      if (any_count == 0)
        {
-         /* Add in catch_packet each syscall to be caught (table[i] != 0).  */
-         for (int i = 0; i < table_size; i++)
+         /* Add in each syscall to be caught.  */
+         for (size_t i = 0; i < syscall_counts.size (); i++)
            {
-             if (table[i] != 0)
-               string_appendf (built_packet, ";%x", i);
+             if (syscall_counts[i] != 0)
+               string_appendf (built_packet, ";%zx", i);
            }
        }
       if (built_packet.size () > get_remote_packet_size ())
@@ -2270,7 +2268,10 @@ static const char *
 remote_thread_name (struct target_ops *ops, struct thread_info *info)
 {
   if (info->priv != NULL)
-    return get_remote_thread_info (info)->name.c_str ();
+    {
+      const std::string &name = get_remote_thread_info (info)->name;
+      return !name.empty () ? name.c_str () : NULL;
+    }
 
   return NULL;
 }
@@ -3076,13 +3077,14 @@ remote_get_threads_with_ql (struct target_ops *ops,
 static void
 start_thread (struct gdb_xml_parser *parser,
              const struct gdb_xml_element *element,
-             void *user_data, VEC(gdb_xml_value_s) *attributes)
+             void *user_data,
+             std::vector<gdb_xml_value> &attributes)
 {
   struct threads_listing_context *data
     = (struct threads_listing_context *) user_data;
   struct gdb_xml_value *attr;
 
-  char *id = (char *) xml_find_attribute (attributes, "id")->value;
+  char *id = (char *) xml_find_attribute (attributes, "id")->value.get ();
   ptid_t ptid = read_ptid (id, NULL);
 
   data->items.emplace_back (ptid);
@@ -3090,15 +3092,15 @@ start_thread (struct gdb_xml_parser *parser,
 
   attr = xml_find_attribute (attributes, "core");
   if (attr != NULL)
-    item.core = *(ULONGEST *) attr->value;
+    item.core = *(ULONGEST *) attr->value.get ();
 
   attr = xml_find_attribute (attributes, "name");
   if (attr != NULL)
-    item.name = (const char *) attr->value;
+    item.name = (const char *) attr->value.get ();
 
   attr = xml_find_attribute (attributes, "handle");
   if (attr != NULL)
-    item.thread_handle = hex2bin ((const char *) attr->value);
+    item.thread_handle = hex2bin ((const char *) attr->value.get ());
 }
 
 static void
@@ -3321,7 +3323,10 @@ remote_threads_extra_info (struct target_ops *self, struct thread_info *tp)
       struct thread_info *info = find_thread_ptid (tp->ptid);
 
       if (info != NULL && info->priv != NULL)
-       return get_remote_thread_info (info)->extra.c_str ();
+       {
+         const std::string &extra = get_remote_thread_info (info)->extra;
+         return !extra.empty () ? extra.c_str () : NULL;
+       }
       else
        return NULL;
     }
@@ -4745,7 +4750,8 @@ remote_query_supported (void)
 
       /* Keep this one last to work around a gdbserver <= 7.10 bug in
         the qSupported:xmlRegisters=i386 handling.  */
-      if (remote_support_xml != NULL)
+      if (remote_support_xml != NULL
+         && packet_support (PACKET_qXfer_features) != PACKET_DISABLE)
        q = remote_query_supported_append (q, remote_support_xml);
 
       q = reconcat (q, "qSupported:", q, (char *) NULL);
@@ -5120,16 +5126,13 @@ remote_detach_pid (int pid)
    one.  */
 
 static void
-remote_detach_1 (const char *args, int from_tty)
+remote_detach_1 (int from_tty)
 {
   int pid = ptid_get_pid (inferior_ptid);
   struct remote_state *rs = get_remote_state ();
   struct thread_info *tp = find_thread_ptid (inferior_ptid);
   int is_fork_parent;
 
-  if (args)
-    error (_("Argument given to \"detach\" when remotely debugging."));
-
   if (!target_has_execution)
     error (_("No process to detach from."));
 
@@ -5159,15 +5162,15 @@ remote_detach_1 (const char *args, int from_tty)
 }
 
 static void
-remote_detach (struct target_ops *ops, const char *args, int from_tty)
+remote_detach (struct target_ops *ops, int from_tty)
 {
-  remote_detach_1 (args, from_tty);
+  remote_detach_1 (from_tty);
 }
 
 static void
-extended_remote_detach (struct target_ops *ops, const char *args, int from_tty)
+extended_remote_detach (struct target_ops *ops, int from_tty)
 {
-  remote_detach_1 (args, from_tty);
+  remote_detach_1 (from_tty);
 }
 
 /* Target follow-fork function for remote targets.  On entry, and
@@ -6934,7 +6937,13 @@ Packet: '%s'\n"),
                        event->ptid = read_ptid (thr + strlen (";thread:"),
                                                 NULL);
                      else
-                       event->ptid = magic_null_ptid;
+                       {
+                         /* Either the current thread hasn't changed,
+                            or the inferior is not multi-threaded.
+                            The event must be for the thread we last
+                            set as (or learned as being) current.  */
+                         event->ptid = event->rs->general_thread;
+                       }
                    }
 
                  if (rsa == NULL)
@@ -10302,7 +10311,7 @@ remote_write_qxfer (struct target_ops *ops, const char *object_name,
   struct remote_state *rs = get_remote_state ();
   int max_size = get_memory_write_packet_size (); 
 
-  if (packet->support == PACKET_DISABLE)
+  if (packet_config_support (packet) == PACKET_DISABLE)
     return TARGET_XFER_E_IO;
 
   /* Insert header.  */
@@ -10344,7 +10353,7 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name,
   struct remote_state *rs = get_remote_state ();
   LONGEST i, n, packet_len;
 
-  if (packet->support == PACKET_DISABLE)
+  if (packet_config_support (packet) == PACKET_DISABLE)
     return TARGET_XFER_E_IO;
 
   /* Check whether we've cached an end-of-object packet that matches
@@ -10656,9 +10665,10 @@ remote_search_memory (struct target_ops* ops,
   int found;
   ULONGEST found_addr;
 
-  /* Don't go to the target if we don't have to.
-     This is done before checking packet->support to avoid the possibility that
-     a success for this edge case means the facility works in general.  */
+  /* Don't go to the target if we don't have to.  This is done before
+     checking packet_config_support to avoid the possibility that a
+     success for this edge case means the facility works in
+     general.  */
   if (pattern_len > search_space_len)
     return 0;
   if (pattern_len == 0)
@@ -10703,7 +10713,7 @@ remote_search_memory (struct target_ops* ops,
     {
       /* The request may not have worked because the command is not
         supported.  If so, fall back to the simple way.  */
-      if (packet->support == PACKET_DISABLE)
+      if (packet_config_support (packet) == PACKET_DISABLE)
        {
          return simple_search_memory (ops, start_addr, search_space_len,
                                       pattern, pattern_len, found_addrp);