public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] gdb: xtensa: fix frame initialization when PC is invalid
@ 2016-03-29 18:18 Max Filippov
  2016-03-29 19:09 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Max Filippov @ 2016-03-29 18:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Maxim Grigoriev, Woody LaRue, Marc Gauthier, Max Filippov

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] gdb: xtensa: fix frame initialization when PC is invalid
  2016-03-29 18:18 [PATCH v2] gdb: xtensa: fix frame initialization when PC is invalid Max Filippov
@ 2016-03-29 19:09 ` Pedro Alves
  2016-03-29 19:56   ` Max Filippov
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2016-03-29 19:09 UTC (permalink / raw)
  To: Max Filippov, gdb-patches; +Cc: Maxim Grigoriev, Woody LaRue, Marc Gauthier

On 03/29/2016 07:17 PM, Max Filippov wrote:
> -      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))
>   	{

I'm surprised if this compiles without an "incompatible pointer type"
warning/error?  safe_read_memory_integer's last parameter is
'LONGEST *', while op1 is 'char', AFAICS.  So you need to change op1
to be a LONGEST to match.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] gdb: xtensa: fix frame initialization when PC is invalid
  2016-03-29 19:09 ` Pedro Alves
@ 2016-03-29 19:56   ` Max Filippov
  0 siblings, 0 replies; 3+ messages in thread
From: Max Filippov @ 2016-03-29 19:56 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches, Maxim Grigoriev, Woody LaRue, Marc Gauthier

On Tue, Mar 29, 2016 at 10:09 PM, Pedro Alves <palves@redhat.com> wrote:
> On 03/29/2016 07:17 PM, Max Filippov wrote:
>> -      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))
>>       {
>
> I'm surprised if this compiles without an "incompatible pointer type"
> warning/error?  safe_read_memory_integer's last parameter is
> 'LONGEST *', while op1 is 'char', AFAICS.  So you need to change op1
> to be a LONGEST to match.

You're right, sorry. I've checked that it builds and works, but I've missed
that it was configured with --disable-werror.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-29 19:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29 18:18 [PATCH v2] gdb: xtensa: fix frame initialization when PC is invalid Max Filippov
2016-03-29 19:09 ` Pedro Alves
2016-03-29 19:56   ` Max Filippov

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).