public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: gdb-patches@sourceware.org
Cc: Maxim Grigoriev <maxim2405@gmail.com>,
	Woody LaRue <larue@cadence.com>,	Marc Gauthier <marc@cadence.com>,
	Max Filippov <jcmvbkbc@gmail.com>
Subject: [PATCH v2] gdb: xtensa: fix frame initialization when PC is invalid
Date: Tue, 29 Mar 2016 18:18:00 -0000	[thread overview]
Message-ID: <1459275473-11718-1-git-send-email-jcmvbkbc@gmail.com> (raw)

When gdb is used on core dump and PC is not pointing to a readable
memory read_memory_integer call in the xtensa_frame_cache throws an
error, making register inspection/backtracing impossible in that thread.

Use safe_read_memory_integer instead.

2016-03-29  Max Filippov  <jcmvbkbc@gmail.com>
gdb/
	* xtensa-tdep.c (xtensa_frame_cache): Use
	safe_read_memory_integer instead of read_memory_integer.
---
Changes v1->v2:
- use safe_read_memory_integer instead of TRY/CATCH block.

 gdb/xtensa-tdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 9e87fa5..9aa6232 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -1293,8 +1293,8 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache)
       ws = get_frame_register_unsigned (this_frame,
 					gdbarch_tdep (gdbarch)->ws_regnum);
 
-      op1 = read_memory_integer (pc, 1, byte_order);
-      if (XTENSA_IS_ENTRY (gdbarch, op1))
+      if (safe_read_memory_integer (pc, 1, byte_order, &op1)
+	  && XTENSA_IS_ENTRY (gdbarch, op1))
 	{
 	  int callinc = CALLINC (ps);
 	  ra = get_frame_register_unsigned
-- 
2.1.4

             reply	other threads:[~2016-03-29 18:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-29 18:18 Max Filippov [this message]
2016-03-29 19:09 ` Pedro Alves
2016-03-29 19:56   ` Max Filippov

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=1459275473-11718-1-git-send-email-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=larue@cadence.com \
    --cc=marc@cadence.com \
    --cc=maxim2405@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).