From: Yao Qi <qiyaoltc@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] Throw NOT_AVAILABLE_ERROR in read_stack and read_code
Date: Tue, 19 Apr 2016 07:50:00 -0000 [thread overview]
Message-ID: <1461052220-10149-3-git-send-email-yao.qi@linaro.org> (raw)
In-Reply-To: <1461052220-10149-1-git-send-email-yao.qi@linaro.org>
Nowadays, read_memory may throw NOT_AVAILABLE_ERROR (it is done by
patch http://sourceware.org/ml/gdb-patches/2013-08/msg00625.html)
however, read_stack and read_code still throws MEMORY_ERROR only. This
causes PR 19947, that is prologue unwinder is unable unwind because
code memory isn't available, but MEMORY_ERROR is thrown, while unwinder
catches NOT_AVAILABLE_ERROR.
#0 memory_error (err=err@entry=TARGET_XFER_E_IO, memaddr=memaddr@entry=140737349781158) at /home/yao/SourceCode/gnu/gdb/git/gdb/corefile.c:217
#1 0x000000000065f5ba in read_code (memaddr=memaddr@entry=140737349781158, myaddr=myaddr@entry=0x7fffffffd7b0 "\340\023<\001", len=len@entry=1)
at /home/yao/SourceCode/gnu/gdb/git/gdb/corefile.c:288
#2 0x000000000065f7b5 in read_code_unsigned_integer (memaddr=memaddr@entry=140737349781158, len=len@entry=1, byte_order=byte_order@entry=BFD_ENDIAN_LITTLE)
at /home/yao/SourceCode/gnu/gdb/git/gdb/corefile.c:363
#3 0x00000000004717e0 in amd64_analyze_prologue (gdbarch=gdbarch@entry=0x13c13e0, pc=140737349781158, current_pc=140737349781165, cache=cache@entry=0xda0cb0)
at /home/yao/SourceCode/gnu/gdb/git/gdb/amd64-tdep.c:2267
#4 0x0000000000471f6d in amd64_frame_cache_1 (cache=0xda0cb0, this_frame=0xda0bf0) at /home/yao/SourceCode/gnu/gdb/git/gdb/amd64-tdep.c:2437
#5 amd64_frame_cache (this_frame=0xda0bf0, this_cache=<optimised out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/amd64-tdep.c:2508
#6 0x000000000047214d in amd64_frame_this_id (this_frame=<optimised out>, this_cache=<optimised out>, this_id=0xda0c50)
at /home/yao/SourceCode/gnu/gdb/git/gdb/amd64-tdep.c:2541
#7 0x00000000006b94c4 in compute_frame_id (fi=0xda0bf0) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:481
#8 get_prev_frame_if_no_cycle (this_frame=this_frame@entry=0xda0b20) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1809
#9 0x00000000006bb6c9 in get_prev_frame_always_1 (this_frame=0xda0b20) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1983
#10 get_prev_frame_always (this_frame=this_frame@entry=0xda0b20) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1999
#11 0x00000000006bbe11 in get_prev_frame (this_frame=this_frame@entry=0xda0b20) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:2241
#12 0x00000000006bc13c in unwind_to_current_frame (ui_out=<optimised out>, args=args@entry=0xda0b20) at /home/yao/SourceCode/gnu/gdb/git/gdb/frame.c:1485
The fix is to let read_stack and read_code throw NOT_AVAILABLE_ERROR too,
in order to align with read_memory.
gdb:
2016-04-18 Yao Qi <yao.qi@linaro.org>
PR gdb/19947
* corefile.c (read_memory): Rename it to ...
(read_memory_object): ... it. Add parameter object.
(read_memory): Call read_memory_object.
(read_stack): Likewise.
(read_code): Likewise.
---
gdb/corefile.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 5ad4d40..6cc2afc 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -237,10 +237,11 @@ memory_error (enum target_xfer_status err, CORE_ADDR memaddr)
throw_error (exception, ("%s"), str);
}
-/* Same as target_read_memory, but report an error if can't read. */
+/* Helper function. */
-void
-read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
+static void
+read_memory_object (enum target_object object, CORE_ADDR memaddr,
+ gdb_byte *myaddr, ssize_t len)
{
ULONGEST xfered = 0;
@@ -250,7 +251,7 @@ read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
ULONGEST xfered_len;
status = target_xfer_partial (current_target.beneath,
- TARGET_OBJECT_MEMORY, NULL,
+ object, NULL,
myaddr + xfered, NULL,
memaddr + xfered, len - xfered,
&xfered_len);
@@ -264,16 +265,20 @@ read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
}
}
+/* Same as target_read_memory, but report an error if can't read. */
+
+void
+read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
+{
+ read_memory_object (TARGET_OBJECT_MEMORY, memaddr, myaddr, len);
+}
+
/* Same as target_read_stack, but report an error if can't read. */
void
read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
- int status;
-
- status = target_read_stack (memaddr, myaddr, len);
- if (status != 0)
- memory_error (TARGET_XFER_E_IO, memaddr);
+ read_memory_object (TARGET_OBJECT_STACK_MEMORY, memaddr, myaddr, len);
}
/* Same as target_read_code, but report an error if can't read. */
@@ -281,11 +286,7 @@ read_stack (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
void
read_code (CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
{
- int status;
-
- status = target_read_code (memaddr, myaddr, len);
- if (status != 0)
- memory_error (TARGET_XFER_E_IO, memaddr);
+ read_memory_object (TARGET_OBJECT_CODE_MEMORY, memaddr, myaddr, len);
}
/* Read memory at MEMADDR of length LEN and put the contents in
--
1.9.1
next prev parent reply other threads:[~2016-04-19 7:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 7:50 [PATCH 0/2] PR 19947: throw right exception in read_code and read_stack Yao Qi
2016-04-19 7:50 ` [PATCH 1/2] Use -fno-asynchronous-unwind-tables if C program is compiled without debug info on x86 Yao Qi
2016-04-19 13:35 ` Pedro Alves
2016-04-20 8:38 ` Yao Qi
2016-04-22 12:30 ` Pedro Alves
2016-04-22 14:23 ` Yao Qi
2016-04-22 14:36 ` Pedro Alves
2016-04-22 16:05 ` Yao Qi
2016-04-19 7:50 ` Yao Qi [this message]
2016-04-22 13:41 ` [PATCH 2/2] Throw NOT_AVAILABLE_ERROR in read_stack and read_code Pedro Alves
2016-05-04 14:08 ` Yao Qi
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=1461052220-10149-3-git-send-email-yao.qi@linaro.org \
--to=qiyaoltc@gmail.com \
--cc=gdb-patches@sourceware.org \
/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