From: Ulrich Weigand Date: Wed, 17 Sep 2014 15:29:27 +0000 (+0200) Subject: PR gdb/17384: Do not print memory errors in safe_read_memory_integer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5e43d46791c4c66fd83947a12d4f716b561a9103;p=binutils-gdb.git PR gdb/17384: Do not print memory errors in safe_read_memory_integer If accessing memory via safe_read_memory_integer fails, that function used to print an error message even though callers were perfectly able to handle (and even expected!) failures. This patch removes the confusing message by changing the routine to directly use target_read_memory. gdb/ChangeLog: PR gdb/17384 * corefile.c (struct captured_read_memory_integer_arguments): Remove. (do_captured_read_memory_integer): Remove. (safe_read_memory_integer): Use target_read_memory directly instead of catching errors in do_captured_read_memory_integer. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1d326065eb5..9b456c04a2f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2014-09-17 Ulrich Weigand  + + PR gdb/17384 + * corefile.c (struct captured_read_memory_integer_arguments): Remove. + (do_captured_read_memory_integer): Remove. + (safe_read_memory_integer): Use target_read_memory directly instead + of catching errors in do_captured_read_memory_integer. + 2014-09-16 Maciej W. Rozycki * CONTRIBUTE (Coding Standards): For internals refer to wiki, diff --git a/gdb/corefile.c b/gdb/corefile.c index 1617392372d..a0bb2aab307 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -290,40 +290,6 @@ read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len) memory_error (status, memaddr); } -/* 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 -{ - CORE_ADDR memaddr; - int len; - enum bfd_endian byte_order; - 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) -{ - struct captured_read_memory_integer_arguments *args - = (struct captured_read_memory_integer_arguments*) data; - CORE_ADDR memaddr = args->memaddr; - int len = args->len; - enum bfd_endian byte_order = args->byte_order; - - args->result = read_memory_integer (memaddr, len, byte_order); - - 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. */ @@ -333,19 +299,13 @@ safe_read_memory_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order, LONGEST *return_value) { - int status; - struct captured_read_memory_integer_arguments args; - - args.memaddr = memaddr; - args.len = len; - args.byte_order = byte_order; + gdb_byte buf[sizeof (LONGEST)]; - status = catch_errors (do_captured_read_memory_integer, &args, - "", RETURN_MASK_ALL); - if (status) - *return_value = args.result; + if (target_read_memory (memaddr, buf, len)) + return 0; - return status; + *return_value = extract_signed_integer (buf, len, byte_order); + return 1; } LONGEST