2013-01-14 Richard Sharman <richard_sharman@mitel.com>
authorPedro Alves <palves@redhat.com>
Mon, 14 Jan 2013 18:06:21 +0000 (18:06 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 14 Jan 2013 18:06:21 +0000 (18:06 +0000)
    Pedro Alves  <palves@redhat.com>

PR remote/14786

* remote.c (remote_threads_info): Make a copy of the reply from
qfThreadInfo and use that instead of rs->buf.

gdb/ChangeLog
gdb/remote.c

index 2dbbc6a5f6dbdfcc333beddfb1e459d95a2e10dc..963b67989fb60f00228459d8f498288bc31371b3 100644 (file)
@@ -1,3 +1,11 @@
+2013-01-14  Richard Sharman  <richard_sharman@mitel.com>
+           Pedro Alves  <palves@redhat.com>
+
+       PR remote/14786
+
+       * remote.c (remote_threads_info): Make a copy of the reply from
+       qfThreadInfo and use that instead of rs->buf.
+
 2013-01-14  Yao Qi  <yao@codesourcery.com>
 
        * dbxread.c (dbx_psymtab_to_symtab_1): Don't check PST is NULL.
index 59b2eb68e76864a54ddad0f1089b1ad31ef4e8a7..7ea9597cb0ebf551f49ce856d9a2419a0c458f84 100644 (file)
@@ -2759,6 +2759,15 @@ remote_threads_info (struct target_ops *ops)
       bufp = rs->buf;
       if (bufp[0] != '\0')             /* q packet recognized */
        {
+         struct cleanup *old_chain;
+         char *saved_reply;
+
+         /* remote_notice_new_inferior (in the loop below) may make
+            new RSP calls, which clobber rs->buf.  Work with a
+            copy.  */
+         bufp = saved_reply = xstrdup (rs->buf);
+         old_chain = make_cleanup (free_current_contents, &saved_reply);
+
          while (*bufp++ == 'm')        /* reply contains one or more TID */
            {
              do
@@ -2776,10 +2785,12 @@ remote_threads_info (struct target_ops *ops)
                    }
                }
              while (*bufp++ == ',');   /* comma-separated list */
+             free_current_contents (&saved_reply);
              putpkt ("qsThreadInfo");
              getpkt (&rs->buf, &rs->buf_size, 0);
-             bufp = rs->buf;
+             bufp = saved_reply = xstrdup (rs->buf);
            }
+         do_cleanups (old_chain);
          return;       /* done */
        }
     }