From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sources.redhat.com
Subject: [PATCH RFC] safe_read_memory_integer() return value...
Date: Wed, 29 May 2002 17:23:00 -0000 [thread overview]
Message-ID: <1020530000540.ZM4672@localhost.localdomain> (raw)
Earlier today, I discovered that safe_read_memory_integer() was never
returning a non-zero value. It appears to me from the its usage in
arm-tdep.c that it is intended to return zero if it fails to read the
target's memory, and a non-zero value if it is successful. The
patch below changes safe_read_memory_integer to behave precisely
in this fashion.
An earlier (unposted) version of this patch used GDB_RC_OK instead of
the constant 1. I changed my mind about using this constant after I
noticed that the return type of safe_read_memory_integer() and
do_captured_read_memory_integer() should change. That would have
necessitated including gdb.h in corefile.c as well as in those files
which include gdbcore.h. I decided that this was much too big of a
ripple.
If there are no objections, I'll commit this change tomorrow.
Kevin
* 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.
Index: corefile.c
===================================================================
RCS file: /cvs/src/src/gdb/corefile.c,v
retrieving revision 1.18
diff -u -p -r1.18 corefile.c
--- corefile.c 6 Mar 2002 06:28:33 -0000 1.18
+++ corefile.c 29 May 2002 23:39:08 -0000
@@ -260,7 +260,10 @@ dis_asm_print_address (bfd_vma addr, str
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_argu
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 *d
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 mema
status = catch_errors (do_captured_read_memory_integer, &args,
"", RETURN_MASK_ALL);
- if (!status)
+ if (status)
*return_value = args.result;
return status;
next reply other threads:[~2002-05-30 0:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-29 17:23 Kevin Buettner [this message]
2002-05-30 15:49 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1020530000540.ZM4672@localhost.localdomain \
--to=kevinb@redhat.com \
--cc=gdb-patches@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox