This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Report `dump memory' errors


Hi,

$ rm -f x; gdb -q -nx -ex 'dump memory x 0x10 0x20' -ex q; od -An -tx1 <x
 d8 9e 96 e1 35 00 00 00 d8 9e 96 e1 35 00 00 00

No error is reported, uninitialized memory is dumped.


Thanks,
Jan


gdb/
2009-07-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Report error on inaccessible memory.
	* cli/cli-dump.c: Include gdbcore.h.
	(dump_memory_to_file): Call read_memory instead of target_read_memory.

gdb/testsuite/
2009-07-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.base/dump.exp (inaccessible memory is reported): New test.

--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -30,6 +30,7 @@
 #include <ctype.h>
 #include "target.h"
 #include "readline/readline.h"
+#include "gdbcore.h"
 
 #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
 
@@ -246,7 +247,7 @@ dump_memory_to_file (char *cmd, char *mode, char *file_format)
      value.  */
   buf = xmalloc (count);
   make_cleanup (xfree, buf);
-  target_read_memory (lo, buf, count);
+  read_memory (lo, buf, count);
   
   /* Have everything.  Open/write the data.  */
   if (file_format == NULL || strcmp (file_format, "binary") == 0)
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -58,6 +58,10 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${op
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
+
+gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \
+	 "inaccessible memory is reported"
+
 gdb_load ${binfile}
 
 # Clean up any stale output files from previous test runs


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]