aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2002-05-30 22:41:24 +0000
committerKevin Buettner <kevinb@redhat.com>2002-05-30 22:41:24 +0000
commitee8ff470c4c1c850ebe9f7f09695ca8be0a21540 (patch)
tree4ba3ca0f044a0db99e8490f122935716bbc72ec0
parent1c5cec28bb58d3d36dcb53c3f502b0594f62209e (diff)
downloadgdb-ee8ff470c4c1c850ebe9f7f09695ca8be0a21540.zip
gdb-ee8ff470c4c1c850ebe9f7f09695ca8be0a21540.tar.gz
gdb-ee8ff470c4c1c850ebe9f7f09695ca8be0a21540.tar.bz2
Make safe_read_memory_integer() return non-zero result when successful.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/corefile.c20
2 files changed, 24 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 585d4c7..1c470aa 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2002-05-30 Kevin Buettner <kevinb@redhat.com>
+
+ * corefile.c (do_captured_read_memory_integer): Return non-zero
+ result.
+ (safe_read_memory_integer): Copy result of memory read when
+ status is non-zero. Also, add comments.
+
2002-05-20 Jason Thorpe <thorpej@wasabisystems.com>
* Makefile.in (ppc_tdep_h): Define.
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 29eeac8..4f6eef2 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -260,7 +260,10 @@ dis_asm_print_address (bfd_vma addr, struct disassemble_info *info)
print_address (addr, info->stream);
}
-/* Read an integer from debugged memory, given address and number of bytes. */
+/* Argument / return result struct for use with
+ do_captured_read_memory_integer(). MEMADDR and LEN are filled in
+ by gdb_read_memory_integer(). RESULT is the contents that were
+ successfully read from MEMADDR of length LEN. */
struct captured_read_memory_integer_arguments
{
@@ -269,6 +272,13 @@ struct captured_read_memory_integer_arguments
LONGEST result;
};
+/* Helper function for gdb_read_memory_integer(). DATA must be a
+ pointer to a captured_read_memory_integer_arguments struct.
+ Return 1 if successful. Note that the catch_errors() interface
+ will return 0 if an error occurred while reading memory. This
+ choice of return code is so that we can distinguish between
+ success and failure. */
+
static int
do_captured_read_memory_integer (void *data)
{
@@ -278,9 +288,13 @@ do_captured_read_memory_integer (void *data)
args->result = read_memory_integer (memaddr, len);
- return 0;
+ return 1;
}
+/* Read memory at MEMADDR of length LEN and put the contents in
+ RETURN_VALUE. Return 0 if MEMADDR couldn't be read and non-zero
+ if successful. */
+
int
safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
{
@@ -291,7 +305,7 @@ safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
status = catch_errors (do_captured_read_memory_integer, &args,
"", RETURN_MASK_ALL);
- if (!status)
+ if (status)
*return_value = args.result;
return status;