Fix '-data-read-memory-bytes' typo/assertion
authorDon Breazeal <donb@codesourcery.com>
Fri, 20 Nov 2015 17:45:44 +0000 (09:45 -0800)
committerDon Breazeal <donb@codesourcery.com>
Fri, 20 Nov 2015 17:45:44 +0000 (09:45 -0800)
This patch fixes a typo in target.c:read_memory_robust, where
it calls read_whatever_is_readable with the function arguments
in the wrong order.  Depending on the address being read, it
can cause an xmalloc with a huge size, resulting in an assertion
failure, or just read something other than what was requested.

The problem only arises when GDB is handling an MI
"-data-read-memory-bytes" request and the initial target_read returns
an error status.  Note that read_memory_robust is only called from
the MI code.

gdb/ChangeLog:

* gdb/target.c (read_memory_robust): Call
read_whatever_is_readable with arguments in the correct order.

gdb/ChangeLog
gdb/target.c

index ee1b6ad5263c7b7cca251313d391764a90be52d6..5a00b5f4b097249c9d43fb9d11738e15a0cdfa9a 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-19  Don Breazeal  <donb@codesourcery.com>
+
+       * target.c (read_memory_robust): Call read_whatever_is_readable
+       with arguments in the correct order.
+
 2015-11-19  Pedro Alves  <palves@redhat.com>
 
        * remote.c (remote_query_supported): Send the "xmlRegisters="
index 0ae6708f81ff9b43aea8f73f0eee6fe743f07166..2365cd3bd3fc647cef48d8fe02175a5a2f674950 100644 (file)
@@ -1836,8 +1836,9 @@ read_memory_robust (struct target_ops *ops,
              /* Got an error reading full chunk.  See if maybe we can read
                 some subrange.  */
              xfree (buffer);
-             read_whatever_is_readable (ops, offset + xfered_total, unit_size,
-                                        offset + xfered_total + to_read, &result);
+             read_whatever_is_readable (ops, offset + xfered_total,
+                                        offset + xfered_total + to_read,
+                                        unit_size, &result);
              xfered_total += to_read;
            }
          else