Test "set width/height -1"
[deliverable/binutils-gdb.git] / gdb / remote.c
index 4b3f2907b43806c158e6fda33e7e1a2d97ac40d1..36136e3e3ee617159f6331e76796ef7a79ff130d 100644 (file)
 #include "cli/cli-setshow.h"
 #include "target-descriptions.h"
 #include "gdb_bfd.h"
-#include "filestuff.h"
-#include "rsp-low.h"
+#include "common/filestuff.h"
+#include "common/rsp-low.h"
 #include "disasm.h"
 #include "location.h"
 
-#include "gdb_sys_time.h"
+#include "common/gdb_sys_time.h"
 
 #include "event-loop.h"
 #include "event-top.h"
 #include "tracepoint.h"
 #include "ax.h"
 #include "ax-gdb.h"
-#include "agent.h"
+#include "common/agent.h"
 #include "btrace.h"
 #include "record-btrace.h"
 #include <algorithm>
 #include "common/scoped_restore.h"
-#include "environ.h"
+#include "common/environ.h"
 #include "common/byte-vector.h"
 #include <unordered_map>
 
@@ -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.  */
@@ -5547,9 +5547,7 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
     }
 
   /* Switch to using the remote target now.  */
-  push_target (remote);
-  /* The target stack owns the target now.  */
-  target_holder.release ();
+  push_target (std::move (target_holder));
 
   /* Register extra event sources in the event loop.  */
   rs->remote_async_inferior_event_token
@@ -7340,7 +7338,6 @@ Packet: '%s'\n"),
          else if (strprefix (p, p1, "exec"))
            {
              ULONGEST ignored;
-             char pathname[PATH_MAX];
              int pathlen;
 
              /* Determine the length of the execd pathname.  */
@@ -7349,11 +7346,14 @@ Packet: '%s'\n"),
 
              /* Save the pathname for event reporting and for
                 the next run command.  */
+             char *pathname = (char *) xmalloc (pathlen + 1);
+             struct cleanup *old_chain = make_cleanup (xfree, pathname);
              hex2bin (p1, (gdb_byte *) pathname, pathlen);
              pathname[pathlen] = '\0';
+             discard_cleanups (old_chain);
 
              /* This is freed during event handling.  */
-             event->ws.value.execd_pathname = xstrdup (pathname);
+             event->ws.value.execd_pathname = pathname;
              event->ws.kind = TARGET_WAITKIND_EXECD;
 
              /* Skip the registers included in this packet, since
This page took 0.033095 seconds and 4 git commands to generate.