Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Antoine Tremblay <antoine.tremblay@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Antoine Tremblay <antoine.tremblay@ericsson.com>
Subject: [PATCH 2/3] Fix inferior memory reading in GDBServer for ppc.
Date: Mon, 28 Nov 2016 12:28:00 -0000	[thread overview]
Message-ID: <20161128122758.7762-2-antoine.tremblay@ericsson.com> (raw)
In-Reply-To: <20161128122758.7762-1-antoine.tremblay@ericsson.com>

Before this patch, parse_spufs_run would read the inferior memory with
(*the_target)->read_memory, which returns the raw memory, rather than the
shadowed memory.

This is wrong since this function does not expect to read a breakpoint
instruction and can lead to invalid behavior.

This patch is built tested but not regression tested.

gdb/gdbserver/ChangeLog:

	* linux-ppc-low.c (parse_spufs_run): Use target_read_memory.
	(ppc_get_pc): Likewise.
---
 gdb/gdbserver/linux-ppc-low.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c
index 1d013f1..6fcad84 100644
--- a/gdb/gdbserver/linux-ppc-low.c
+++ b/gdb/gdbserver/linux-ppc-low.c
@@ -231,8 +231,8 @@ parse_spufs_run (struct regcache *regcache, int *fd, CORE_ADDR *addr)
     }
 
   /* Fetch instruction preceding current NIP.  */
-  if ((*the_target->read_memory) (curr_pc - 4,
-				  (unsigned char *) &curr_insn, 4) != 0)
+  if (target_read_memory (curr_pc - 4,
+			  (unsigned char *) &curr_insn, 4) != 0)
     return 0;
   /* It should be a "sc" instruction.  */
   if (curr_insn != INSTR_SC)
@@ -253,7 +253,7 @@ ppc_get_pc (struct regcache *regcache)
   if (parse_spufs_run (regcache, &fd, &addr))
     {
       unsigned int pc;
-      (*the_target->read_memory) (addr, (unsigned char *) &pc, 4);
+      target_read_memory (addr, (unsigned char *) &pc, 4);
       return ((CORE_ADDR)1 << 63)
 	| ((CORE_ADDR)fd << 32) | (CORE_ADDR) (pc - 4);
     }
-- 
2.9.2


  reply	other threads:[~2016-11-28 12:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 12:28 [PATCH 1/3] Fix inferior memory reading in GDBServer for arm/aarch32 Antoine Tremblay
2016-11-28 12:28 ` Antoine Tremblay [this message]
2016-11-28 12:28 ` [PATCH 3/3] Fix inferior memory reading in GDBServer for sparc Antoine Tremblay
2016-12-09 12:51   ` Antoine Tremblay
2016-11-30 20:46 ` [PATCH 1/3] Fix inferior memory reading in GDBServer for arm/aarch32 Luis Machado
2016-12-01 14:44 ` Yao Qi
2016-12-01 15:28   ` Antoine Tremblay
2016-12-01 15:55     ` Antoine Tremblay
2016-12-01 16:18       ` Antoine Tremblay
2016-12-01 18:10         ` Antoine Tremblay
2016-12-09 12:06           ` Yao Qi
2016-12-09 12:22             ` [PATCH v2] " Antoine Tremblay
2016-12-09 12:23     ` [PATCH 1/3] " Yao Qi
2016-12-09 12:46       ` [PATCH v3] " Antoine Tremblay
2017-01-09 11:55         ` Antoine Tremblay
2017-01-09 17:31         ` Yao Qi
2017-01-09 17:41           ` Antoine Tremblay

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=20161128122758.7762-2-antoine.tremblay@ericsson.com \
    --to=antoine.tremblay@ericsson.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